top of page
Search

My Final Project :)

  • gcafaro6
  • Dec 14, 2019
  • 3 min read

var x = [];

var y = [];

var cSize = [];

var cSpeed= [];

var rColor= [];

var score= [];

var gameOver;


var numSquares = 5;


function setup() {

createCanvas(1000, 1000);

rectMode(CENTER);

x[0] = 500 ;

y[0] = 500;

cSize[0] = 400;

cSpeed[0]= 4;

rColor[0]=random(0,255);

gameOver= 0;

}

function draw() {

background(240);

if (gameOver) {

fill('gray');

textSize(40);

text('Game Over, Press "p" to start again',300,500);

}

else {

////draw all of my rectangles

//fill('blue')

for (var i = 0; i < x.length; i++){

x[i]= cSpeed [i] + x[i]

fill(color(rColor[i], 0, 0));

rect( x[i], y[i], cSize[i], cSize[i]);

x[i] = x[i] + cSpeed[i];


if ((x[i] > (1000-cSize[i]/2)) || (x[i] < cSize[i]/2)){

cSpeed[i] = -cSpeed[i];

}

}


fill(20);

textSize(30);

text('✴✴✴Click "s" to get the 7th square in the middle✴✴✴', 45,100);

text('❤Good Luck ❤', 400, 850);

}

}


function keyPressed(){

if (key === 's'){

cSpeed[cSpeed.length-2]= 0;

if (x.length <= numSquares){

//this is new, this is so we are able to make the second square after you press s the first time

if (x.length < 2){

x.push(500);

y.push(500);

cSize.push(cSize[cSize.length-1] * 0.5);

cSpeed.push(cSpeed[cSpeed.length-1] * 1.2);

cSpeed[cSpeed.length-2] = 0;

rColor.push(random(0, 255));

//print a message to look at in the console to confirm things are working

console.log("first square");

}

//if the right hand side of the current square is to the left of the larger square and if etc etc

else if (((x[x.length-1] - (cSize[x.length-1]/2)) > (x[x.length-2] -

(cSize[x.length-2]/2))) && ((x[x.length-1]+(cSize[x.length-1]/2)) <

(x[x.length-2] + (cSize[x.length-2])/2))){

x.push(500);

y.push(500);

cSize.push(cSize[cSize.length-1] * 0.5);

cSpeed.push(cSpeed[cSpeed.length-1] * 1.2);

cSpeed[cSpeed.length-2] = 0;

rColor.push(random(0, 255));

console.log("my square is inside the previous square");

}

else{

//if we lose the game

console.log("game loss");

cSpeed[x.length-1] = 0;

gameOver= 1;

}

}

}

if (key === 'p'){

if (gameOver){

x.splice(0, x.length);

y.splice(0, y.length);

cSize.splice(0, cSize.length);

cSpeed.splice(0, cSpeed.length);

rColor.splice(0, rColor.length);

x[0] = 500 ;

y[0] = 500;

cSize[0] = 400;

cSpeed[0]= 3;

rColor[0]=random(0,255);

gameOver= 0;

}

}

}



How does your idea utilize the technical skill sets to create something greater than the sum of its parts?

-The code different a-rays utilies the technical skill set for my project. Without these array, it can be a continues square going again and again.

Is your project ‘believable’ as a concept?

-Yes I believe my project is a game that is a believe able concept

Do you add your own creative flavor to the results?

-Yes, I made the squares get smaller and faster as they go and thats something I wanted to make a twist since theres only 6 blocks.

Does your final project ‘function’ as expected?

-Yes and no, the concept works perfectly but when it gets to the smaller square, the


Do you use both inputs and outputs in your design?

-

Was your project explained clearly during your class presentation?


-I hope so I didn't present yet? But I know it will be.

Did you have something ready to share during User Testing day?


-My project is all done and is ready to show my classmate something o'm very proud of

Have you comprehensive write up posted to blog (before due date)?


-Your reading it now if your reading this

Did you attempt to go beyond what we went over together in class?


-Yes I did, I learned so many new things to help my code. Including gameOver, numberSquare, and console.log. This project taught me a-lot of new codes.

If some parts of your project don’t work as expected, how do you address this in your final design (and document the issues)? My issue with the project is when it comes to the last square it wont stop in the middle once you press the key pressed assigned to the code to stop it. When i discuss this issue, I would say "there is time for this project to grow and when it comes to this one their's a-lot of coding that is put into it. Going forward I will figure out the problems and how to make me and my project grow.



 
 
 

Recent Posts

See All
Homework assignment 13

https://www.wired.com/2014/11/algorithms-great-can-also-ruin-lives/ Who is harmed by this algorithm, and how shall we define that harm?...

 
 
 
Game

In my game, I wanted to create something that kinda looks like my favorite game. Its where things are falling and you have catch them in...

 
 
 

Comments


Follow

©2019 by GC&A. Proudly created with Wix.com

bottom of page