top of page
Search
  • Writer's pictureDavid McDonald

Final Project

Updated: Dec 17, 2019

For my final project I started out with the idea for a art project but decided that i would want to experiment with a game instead.

At first I decided that I would make a endless runner type game named "Night Runner" with loops and arrays used to make the effect of running on the rooftops of a city.

I had made the title screen a building with a sunset and a tall building.

I had got everything except the platforms to work but noticed how the player looked like he was sinking into the building.

I started think about sand and how I can use that in a game so I decided to rename the game to "Night Sand Temple" instead and had a enemy that I called a fireball bouncing around the screen.

I decided to look at the game at a top down view and said that the player was now a spaceship of some kind and whenever they touch the brown part representing sand that meant they were caught in the sand and 1 could travel slower and make it easier for a game over and 2 made it more of a goal to stay in the blue section.

That would still be a problem cause what if the player decided to just go out of bounds so I made it that if the player goes out of bounds that counts as a death.

In the end the final name ended up being pretty simple ending off as 'Space Temple'.

I ended up making the most out of a failed concept and looked at the same game from a literal different angle.



The Code:

// the players x position

var runX;


// the players Y position

var runY;


var gameState;


var jumpH;


var gravity;


var paddleX;


var paddleSize;


var xSpeed;

var ySpeed;


var ballY;

var ballX;

var ballSize;


var score;


function setup() {

// put setup code here

createCanvas(1200, 1200);


gameState = 0;


runX = 200;

runY = 350;


jumpH = 0;


gravity = 0.5;


xSpeed = 5;

ySpeed = -2;

ballSize = 100;

ballX= 50;

ballY= 100;


paddleX = 0;


paddleSize = 1200;


score = 0;


}


function draw() {




//title screen

if (gameState == 0){

// put drawing code here

background(255, 204, 0);


fill('red')

ellipse(600,400,300)


fill('white')

rect(200,400,800,900)

fill('grey')

rect(100,400,1000,200)


fill('purple');

textSize(50);

text('Space Temple', 500, 100);

text('Press "s" to start the game', 400, 300);

text('press left and right to move',400,500);

text('press up to jump',400,600);


}

else if (gameState == 2){

background('black');

fill('red');

textSize(100);

text('U Died',600,600);

}

//Game is active

if (gameState == 1){


background(0, 0, 255);

fill(255);

textSize(20);

text("Score: " + score, 50, 50);



runY = runY + jumpH;


//need building collision

if (runY < 350){

runY = runY + gravity;

}


if (jumpH < 0 ){

//how much is the float

jumpH = jumpH + 0.1;

}


fill('black');

rect(runX, runY,50,50);


for(var i = 0; i<3; i++){

fill('#B5651D');

rect(i * 400 ,400,600,850);

}

//FireBall

fill('red');

ellipse(ballX,ballY,ballSize,ballSize);

//this moves the ball horizontall

ballX += xSpeed;

ballY += ySpeed;


//bouncing off the left and right of the screen

if ((ballX > (1250-ballSize/2)) || (ballX < (ballSize/2))){

xSpeed = -xSpeed;

score += 1; }


//bouncing off the top of the screen

if (ballY < ballSize/2){

ySpeed = - ySpeed;

score += 1;

}

//bounce off the 'paddle'

if ((ballY > (1200-ballSize/2)) && (ballX > (paddleX - paddleSize/2)) &&

(ballX < (paddleX+paddleSize/2))){

ySpeed = -ySpeed;

score += 1;

}

fill('blue');

rect(paddleX, 1200, paddleSize, 10);


}

//gameover

if (runX < 0){

gameState = 2;

}


if (runY < 0){

gameState = 2;

}


if (runX > 1200){

gameState = 2;

if (runX > 1200){

gameState = 2;

}


}

//end of draw

}







function keyPressed(){

//Start button

if(key === 's'){

gameState = 1;

}


if (keyCode === LEFT_ARROW){

runX -=25;

}

else if (keyCode === RIGHT_ARROW){

runX +=25;

}


if (keyCode === UP_ARROW){

if (jumpH > -0.1){

jumpH = -5;

}

}

}



















































































































































































































































3 views0 comments

Recent Posts

See All

Interactive drawing Program

At first I wanted to edit the paddleball code to add a function like a boost button, but I ended up preferring the mouseX and mouseY functions so I decided to focus on an interactive drawing program.

Post: Blog2_Post
bottom of page