Skip to content

Commit

Permalink
add index.html and css files
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey008 committed Dec 5, 2024
1 parent 1660ca2 commit 79201e3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
29 changes: 27 additions & 2 deletions projects/platformer/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ function registerSetup(setup) {
setupGame = setup;
}


function main() {
ctx.clearRect(0, 0, 1400, 750); //erase the screen so you can draw everything in it's most current position

if (player.deadAndDeathAnimationDone) {
deathOfPlayer();
return;
}
if (shouldDrawGrid) {
drawGrid();
}

drawPlatforms();
drawProjectiles();
Expand Down Expand Up @@ -421,12 +425,33 @@ function drawPlatforms() {
}
}

function toggleGrid() {
shouldDrawGrid = true;
}

function drawGrid() {
// vertical grid lines
for (let i = 100; i < canvas.width; i += 100) {
createPlatform(i, canvas.height, -1, -canvas.height);
createPlatform(i, canvas.height, -1, -canvas.height + 35);
// add text indicating x value at top of game
ctx.font = "125% serif";
ctx.fillText(
i, // text
i - 15, // x location
25 // y location
);
}

// horizontal grid lines
for (let i = 100; i < canvas.height; i += 100) {
createPlatform(canvas.width, i, -canvas.width, -1);
createPlatform(canvas.width, i, -canvas.width + 45, -1);
// add text indicating y value at left side of game
ctx.font = "125% serif";
ctx.fillText(
i, // text
10, // x location
i + 5 // y location
);
}
}

Expand Down
17 changes: 8 additions & 9 deletions projects/platformer/platformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(function () {
* Comment the function call out to remove the grid
*/

// drawGrid();
toggleGrid();

/////////////////////////////////////////////////
//////////ONLY CHANGE BELOW THIS POINT///////////
Expand All @@ -39,27 +39,26 @@ $(function () {
// You must decide the x position, y position, width, and height of the platforms
// example usage: createPlatform(x,y,width,height)




createPlatform(100, 625, 125, 5); //top
createPlatform(300, 500, 125, 5);
createPlatform(500, 400, 125, 5);
createPlatform(700, 300, 125, 5);
createPlatform(900, 200, 125, 5);
// TODO 2
// Create collectables
// You must decide on the collectable type, the x position, the y position, the gravity, and the bounce strength
// Your collectable choices are 'database' 'diamond' 'grace' 'kennedi' 'max' and 'steve'; more can be added if you wish
// example usage: createCollectable(type, x, y, gravity, bounce)
createCollectable("diamond", 500, 410, 20, 0.5);





// TODO 3
// Create cannons
// You must decide the wall you want the cannon on, the position on the wall, and the time between shots in milliseconds
// Your wall choices are: 'top' 'left' 'right' and 'bottom'
// example usage: createCannon(side, position, delay, width, height)




/////////////////////////////////////////////////
//////////ONLY CHANGE ABOVE THIS POINT///////////
/////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions projects/platformer/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const friction = 1.5; // how much the player is slowed each frame
const maxSpeed = 8; // maximum horizontal speed, not vertical
const playerJumpStrength = 12; // this is subtracted from the speedY each jump
const projectileSpeed = 8; // the speed of projectiles
let shouldDrawGrid = false;

/////////////////////////////////////////////////
//////////ONLY CHANGE ABOVE THIS POINT///////////
Expand Down

0 comments on commit 79201e3

Please sign in to comment.