PROJECT (FINAL)
- Kevin Menelas
- Dec 17, 2019
- 2 min read
This project had many trials and tribulations. It started out as simple game of pong but that did not turn out as planned. So instead I turned it into a game of self control. There were many MANY problems. I couldn't get the ball to bounce off of anything, the paddles wouldn't move, the ball would keep going through the paddles etc. So I decided to make it something simple and yet kind of funny. I turned it into a game where the only way to win is to not play at all. Here' the code:
var paddle1X;
var paddle1Y;
var paddle2X;
var paddle2Y;
//ball variable
var ballSize;
var ballY;
var ballX;
var paddleSpeed;
var xSpeed = [];
var ySpeed = [];
var ballSize;
var ballX;
var ballY;
var paddleSize;
var bXloc;
var bYloc;
var numB;
let gameState = 0
const intro = 0
const nothing = 1
const stop = 2
const dude =3
const fine = 4
const lose = 5
function setup() {
// put setup code here\
createCanvas(1250, 620);
paddle1X = 100;
paddle1Y = 100;
paddle2X = 1100;
paddle2Y = 100;
ballSize = 100;
ballX = 625;
ballY = 100;
// xSpeed = [];
// ySpeed = [];
paddleSize = 600;
bXloc = [];
bYloc = [];
numB = 1;
for(var i=0; i < numB; i++){
bXloc[i] = random(60, 600);
bYloc[i] = random(100, 400);
xSpeed[i] = random(-10, 10);
ySpeed[i] = random(-10, 10);
}
}
function mousePressed() {
if (gameState < 5) {
gameState++;
} else {
gameState = 0;
}
}
function draw() {
if(gameState == 0){
background(255);
textSize(30);
fill('black')
text('Do not click anything. There is no game.',625, 310);
}
if(gameState == 1){
background(1, 49, 161);
textSize(30)
fill('white')
textAlign(CENTER);
text('Why are you still here? I said there is nothing here.',625, 310);
}
if(gameState == 2){
background(100);
textSize(30)
fill(142, 241, 0)
textAlign(CENTER);
text('Following directions is not your strong suit, is it?' ,625, 310);
}
if(gameState == 3){
background(161, 1, 1);
textSize(30)
fill(0, 237, 241)
textAlign(CENTER);
text('I cannot believe you are still here.' ,625, 310);
}
if(gameState == 4){
background(96, 0, 141);
textSize(30)
fill(245, 241, 1)
textAlign(CENTER);
text('Okay fine. I lied. There is a game. Let me show you' ,625, 310);
}
if (gameState == 5){
background('black')
fill(random(0,250), random(0,250),random(0,250));
rect(paddle1X, paddle1Y, 10, 400);
fill(random(0,250), random(0,250),random(0,250));
rect(paddle2X, paddle2Y, 10, 400);
fill(random(0,250), random(0,250),random(0,250));
ellipse(ballX, ballY, ballSize, ballSize);
//text
textAlign(CENTER);
textSize(24);
fill(random(0,250), random(0,250),random(0,250));
text('You fool! You fell victim to one of the classic blunders.' ,625, 310);
textSize(24);
fill(random(0,250), random(0,250),random(0,250));
text('The true game was not playing at all.',675, 350);
}
}
function keyPressed(){
if (keyCode === UP_ARROW){
paddle1Y -= 10;
}
else if(keyCode === DOWN_ARROW){
paddle1Y += 10;
}
}
Comments