Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisOptimism committed Apr 8, 2021
1 parent 85104e6 commit a351120
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ <h1>NEW ROUND?</h1>
<div class="menu">
<h1>Press Enter to start</h1>
</div>
<div id="game"></div>
</main>
<script src="js/coins.js"></script>
<script src="js/obstacles.js"></script>
<script src="js/firstaid.js"></script>
<script src="js/background.js"></script>
<script src="js/foreground.js"></script>
<script src="js/shot.js"></script>
<script src="js/Shotvillan.js"></script>
<script src="js/shotvillan.js"></script>
<script src="js/tesla.js"></script>
<script src="js/villan.js"></script>
<script src="js/player.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Background {
// TransitionEvent
// Level #2
if (this.turns >= 30 && this.turns < 60) {
song.rate(1.03)
game.backgroundImagesNight.forEach(bgImg => {
bgImg.x -= bgImg.speed
image(bgImg.src, bgImg.x, 0, width, height)
Expand All @@ -30,7 +31,7 @@ class Background {
}
})
}

// level #3
if (this.turns >= 60) {
game.backgroundImages.forEach(bgImg => {
bgImg.x = 0;
Expand Down
6 changes: 3 additions & 3 deletions js/foreground.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Foreground {
this.turns = 0;
}
draw() {
// Level 1
// Level #1
if (game.background.turns < 30) {
image(game.dogImage, this.x2 + 400, 0, width, height);
image(game.foregroundImage, this.x, 0, width, height);
Expand All @@ -21,7 +21,7 @@ class Foreground {
}
}
// transition
// Level 2
// Level #2
if (game.background.turns >= 30 && game.background.turns < 60) {
image(game.foregroundImageNight, this.x, 0, width, height)
image(game.foregroundImageNight, this.x + width, 0, width, height)
Expand All @@ -31,7 +31,7 @@ class Foreground {
}
}

// final Level
// Level #3
if (game.background.turns >= 60) {
image(game.dogImage, this.x2 + 400, 0, width, height);
image(game.foregroundImage, this.x, 0, width, height);
Expand Down
2 changes: 1 addition & 1 deletion js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Game {
this.playerImage;
this.backgroundImages;
this.foregroundImage;
this.mySound;

this.coins = [];
this.coinImage;
Expand Down Expand Up @@ -204,6 +203,7 @@ class Game {
text(`LEVEL ${this.player.level}`, 460, 50);
pop();
if (this.background.turns === 30) {

game.player.level = 2;
game.gameSpeed = 1.5;
}
Expand Down
4 changes: 3 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ let song;
let menuSong;

function setup() {
createCanvas(1000, 600);
let canvas = createCanvas(1000, 600);
canvas.parent('game')
if (menuSong.isLoaded()) {
menuSong.loop();
}

}

function preload() {
Expand Down

0 comments on commit a351120

Please sign in to comment.