Skip to content

Commit 73a6945

Browse files
Made the bg move during gameplay
I will make it like this in the editor eventually (probably)
1 parent c60040d commit 73a6945

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/main.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ async fn main() {
476476
let mut password: String = "".to_string();
477477
let mut logged_in: bool = false;
478478
let mut current_difficulty: u8 = 0;
479+
let mut bg_offset: f32 = 0.0;
479480

480481
let mut cc_1001: Color = Color::new(0.0, 0.0, 0.2, 1.0);
481482
let mut cc_1002: Color = Color::new(0.0, 0.0, 0.3, 1.0);
@@ -829,6 +830,12 @@ async fn main() {
829830
play_audio_path("Resources/Music/menu-music.mp3", master_volume, true, &sink);
830831
game_state.0.set(GameState::LevelSelect)
831832
}
833+
834+
if movement_speed.0.get() > default_movement_speed.0.get() * 1.3 {
835+
bg_offset += 0.4 * movement_speed.0.get()
836+
} else {
837+
bg_offset += 0.2 * movement_speed.0.get()
838+
}
832839
}
833840

834841
GameState::CreatorMenu => {
@@ -1405,20 +1412,22 @@ async fn main() {
14051412
}
14061413

14071414
GameState::Playing => {
1408-
draw_texture_ex(
1409-
&default_bg,
1410-
0.0,
1411-
0.0,
1412-
cc_1001,
1413-
DrawTextureParams {
1414-
dest_size: None,
1415-
source: None,
1416-
rotation: 0.0,
1417-
flip_x: false,
1418-
flip_y: false,
1419-
pivot: None
1420-
}
1421-
);
1415+
for i in 0..2 {
1416+
draw_texture_ex(
1417+
&default_bg,
1418+
(i * 1920) as f32 - (bg_offset % 1920.0),
1419+
0.0,
1420+
cc_1001,
1421+
DrawTextureParams {
1422+
dest_size: None,
1423+
source: None,
1424+
rotation: 0.0,
1425+
flip_x: false,
1426+
flip_y: false,
1427+
pivot: None
1428+
}
1429+
);
1430+
}
14221431

14231432
draw_rectangle_ex(
14241433
player.x,

0 commit comments

Comments
 (0)