Final Project

My project was inspired by a silly idea I had for a flip book of my personal failures revolving around the bouncing ball problem from early on in the class. That evolved into slides containing the ball that you had to click or else the game would end. Eventually I figured with all the problems the year had I could make it America and the ball representing the horrible things popping up all over the country. The user has to keep clicking on the ball as it bounces around the map until they win. Every time the map goes off the canvas, the ball gets faster and more red and the background gets darker. The screen will also begin to crack. Encouraging and frightened dialogue will also appear at the bottom and top respectively, and I’ve included instructions and a brief introduction in the console at the start of the game. I wish I had more time to flesh out the theme of the multiple problems of the year and could’ve made multiple minigames rather than just one, or a more involved animation, but after how poorly my proposal turned out I’m very happy with what I have.

sketch

var slides = []
var threat = 0
var prevent = 0
var incomingX = -100
var incomingY = -100
var incomingSize = 20
var u
var t
var rectY = -200
var flag;
var pic;
var hasDrawn = false
var lineX = []
var lineY= []
var gameStart = false
var hasWritten = false


function makeSlide(sX, sY, sDX, slideTime, ballX, ballY, bounceX, bounceY){ 
  slide = {x: sX, y: sY, dx: sDX, timing: slideTime, drawFunction: drawSlide, stepFunction: slideSlide, extra: drawBall, extraMove: ballMove, extraX: ballX, extraY: ballY, moveX: bounceX, moveY: bounceY}
  return slide
}


function drawSlide(){ 
	imageMode(CENTER)
	image(pic, this.x, this.y, 350, 350)
}


function slideSlide(){
	this.x += this.dx
	if(this.x >= 600 || this.x <= -200){
		this.dx *= -1
	} if (this.x == 600){
    		this.dx -= 2
    	} else if (this.x == -200){
    		this.dx += 2
    	} 
}
 

function drawBall(){
	stroke(0, 0, 0)
	fill(256 - threat, (256 -(threat * 13)), 256 -(threat * 13))
	circle(constrain(this.extraX, this.x - 155, this.x + 175), constrain(this.extraY, 30, 350), 40)
}


function ballMove(){
	this.extraX += this.dx 
	this.extraX += this.moveX
	this.extraY += this.moveY
    if (this.extraX >= this.x + 175 || this.extraX <= this.x - 155){
    	this.moveX *= -1
    } if (this.extraY >= 330 || this.extraY <= 30){
    	this.moveY *= -1
    }
    if (mouseIsPressed & dist(mouseX, mouseY, this.extraX, this.extraY) <= 20){
    	prevent += 1	
    }
     else if (this.x == 600 || this.x == -20){
    	threat += 1
    }
}


function preload(){ 
  pic = loadImage("https://i.imgur.com/VD23NPD.png")
  flag = loadImage("https://i.imgur.com/xFTfp2y.jpg")
}


function setup() { 
	angleMode(DEGREES)
	frameRate(15)
    createCanvas(400, 400);

Leave a Reply