Skip to content

Commit

Permalink
fixed the landing page - gonna add a ending page and then also add ra…
Browse files Browse the repository at this point in the history
…in and flower sounds
  • Loading branch information
johyunjihyunji committed Oct 15, 2024
1 parent 8b78489 commit 5d4afa2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion background/flower.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function updateScoreFlower(charX, charWidth) {
if (flowers[i].collidesWith(charX, charWidth)) {
flowers.splice(i, 1);
flowers.collected = true
return score += 2;
return score += 1;
}
else {
return score
Expand Down
34 changes: 25 additions & 9 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let score = 10;
let flowers = [];

// Gamestate
let Gamestate = false;
let gameState = false;

function preload() {
//Images and Gif
Expand Down Expand Up @@ -70,18 +70,22 @@ function setup() {
for (let i = 0; i < numGrassPokes; i++) {
grassPokes.push(new GrassPoke(i));
}

// Start button
startButton = createButton('Start Game');
startButton.position(width/2 - 50, height/2 + 100);
startButton.mousePressed(startGame);
}

function draw() {
if (Gamestate) {
if (gameState) {
drawgame()
} else {
landingPage()
drawlanding ()
}
}

function landingPage() {
startButton = createButton('Start Game');
function drawlanding() {

// Background - Perplexity.AI helped with creating gradient background
let c1 = color('#432749'); // purple
Expand All @@ -103,9 +107,20 @@ function landingPage() {
line(0, y, width, y);
}

image(landingpage, width / 2, height / 2, landingpage.width * 0.6, landingpage.height * 0.6)
startButton.position(width/2 - 50, height/2 + 100);
startButton.mousePressed(startGame);
// Apply grain
push();
blendMode(OVERLAY);
tint(255, 80);
image(grainImage, 0, 0, width , height);
image(grainImage, width, height, width , height);
image(grainImage, 0, height, width , height);
image(grainImage, width, 0, width , height);
pop();

// Title
push();
image(landingpage, width / 2, height / 2, landingpage.width * 0.6, landingpage.height * 0.6);
pop();
}

function startGame() {
Expand All @@ -115,11 +130,12 @@ function startGame() {

mainTrack.loop();
startButton.remove();
gameState = true;
}



function gamedraw() {
function drawgame() {
// background

// Perplexity.AI helped with creating gradient background
Expand Down

0 comments on commit 5d4afa2

Please sign in to comment.