Skip to content

Commit

Permalink
Merge branch 'main' of github.com:QuarkNerd/GameJamBoilerPlate
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarkNerd committed Apr 12, 2023
2 parents ff0c9f9 + d36d0fd commit 0e60dc7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Binary file added img/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const WIDTH = canvas.getAttribute('width');
const worlds = ["mario", "minecraft", "missing"];
const images = {};

["mario", "mariowall", "minecraft", "minecraftwall", "missing", "missingwall"].forEach(fileName => {
["mario", "mariowall", "minecraft", "minecraftwall", "missing", "missingwall", "bg"].forEach(fileName => {
const img = new Image();
img.src = `img/${fileName}.png`;
images[fileName] = img;
Expand All @@ -28,6 +28,8 @@ let circle = {
y: canvas.height / 2,
vy: 0
};
let bgOffset = 0;
let bgOffsetMax = 1200;

let pipes = [];
let lasers = [];
Expand Down Expand Up @@ -61,8 +63,14 @@ function init() {

function drawBackground() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "black";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(images["bg"], -bgOffset, 0);
if (bgOffset > 400) {
ctx.drawImage(images["bg"], -bgOffset + 1200, 0);
}
if (bgOffset > 1200) {
bgOffset = 0;
}
bgOffset++;
}

function drawCircle() {
Expand Down

0 comments on commit 0e60dc7

Please sign in to comment.