Skip to content

Commit 066e8d3

Browse files
Added platformer
Blocks are probably broken rn and the bg always moves and rotation is weird but it works.
1 parent 73a6945 commit 066e8d3

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/game/loading.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub fn load_level(
1111
cc_1001: &mut Color,
1212
cc_1002: &mut Color,
1313

14+
current_mode: &mut String,
15+
1416
current_song: &mut String,
1517
load_song: bool,
1618
main_levels: Vec<MainLevel>
@@ -77,6 +79,8 @@ pub fn load_level(
7779
} else {
7880
main_levels[value.parse::<usize>().unwrap()].song.to_string()
7981
}
82+
} else if key == "mode" {
83+
*current_mode = value.to_string();
8084
}
8185
}
8286

src/game/playing/physics/main_physics.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub fn physics_handle(
88
on_ground: &mut bool,
99
rotation: &mut f32,
1010
world_offset: &mut f32,
11-
movement_speed: f32
11+
movement_speed: f32,
12+
current_mode: &String
1213
) {
1314
player.y += velocity_y.get();
1415
// *velocity_y += gravity;
@@ -27,5 +28,13 @@ pub fn physics_handle(
2728
*rotation += 0.1
2829
}
2930

30-
*world_offset += movement_speed
31+
if current_mode == "2" {
32+
if is_key_down(KeyCode::Left) {
33+
*world_offset -= movement_speed
34+
} else if is_key_down(KeyCode::Right) {
35+
*world_offset += movement_speed
36+
}
37+
} else {
38+
*world_offset += movement_speed
39+
}
3140
}

src/game/saving.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ pub fn level_to_string(
88
cc_1001: Color,
99
cc_1002: Color,
1010

11-
current_song: String
11+
current_song: String,
12+
current_mode: String
1213
) -> String {
1314
let mut level_string: String = format!(
14-
"version:{};song:{};cc_1001:{},{},{};cc_1002:{},{},{};;;",
15+
"version:{};song:{};mode:{};cc_1001:{},{},{};cc_1002:{},{},{};;;",
1516

1617
level_version,
1718
current_song,
19+
current_mode,
1820

1921
cc_1001.r,
2022
cc_1001.g,

src/main.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ async fn main() {
477477
let mut logged_in: bool = false;
478478
let mut current_difficulty: u8 = 0;
479479
let mut bg_offset: f32 = 0.0;
480+
let mut current_mode: String = "1".to_string();
480481

481482
let mut cc_1001: Color = Color::new(0.0, 0.0, 0.2, 1.0);
482483
let mut cc_1002: Color = Color::new(0.0, 0.0, 0.3, 1.0);
@@ -656,6 +657,7 @@ async fn main() {
656657
&mut obj_grid,
657658
&mut cc_1001,
658659
&mut cc_1002,
660+
&mut current_mode,
659661
&mut current_song,
660662
false,
661663
main_levels.clone()
@@ -710,7 +712,8 @@ async fn main() {
710712
&mut on_ground,
711713
&mut rotation,
712714
&mut world_offset,
713-
movement_speed.0.get()
715+
movement_speed.0.get(),
716+
&current_mode
714717
);
715718

716719
playing::hitboxes::hitbox_collision(
@@ -857,6 +860,7 @@ async fn main() {
857860
&mut obj_grid,
858861
&mut cc_1001,
859862
&mut cc_1002,
863+
&mut current_mode,
860864
&mut current_song,
861865
true,
862866
main_levels.clone()
@@ -939,7 +943,8 @@ async fn main() {
939943
level_version,
940944
cc_1001,
941945
cc_1002,
942-
current_song.clone()
946+
current_song.clone(),
947+
current_mode.clone()
943948
);
944949

945950
let save_result: Result<(), std::io::Error> = std::fs::write(
@@ -1169,6 +1174,7 @@ async fn main() {
11691174
&mut obj_grid,
11701175
&mut cc_1001,
11711176
&mut cc_1002,
1177+
&mut current_mode,
11721178
&mut current_song,
11731179
true,
11741180
main_levels.clone()
@@ -1242,7 +1248,8 @@ async fn main() {
12421248
level_version,
12431249
cc_1001,
12441250
cc_1002,
1245-
current_song.clone()
1251+
current_song.clone(),
1252+
current_mode.clone()
12461253
);
12471254

12481255
level_upload_response = ureq::post(&upload_url)

0 commit comments

Comments
 (0)