Bear Hop Game
- anmonaco
- Apr 29, 2019
- 1 min read
For my AP project I created a game that involved a jumping bear. To create this game I used two main functions, one for the bear and one for the obstacles. I hand drew the bear using shapes and colors, as well as the obstacles. I used simple physics concepts of gravity and drag force to create a nice, smooth jump for the bear. Then I used a lot of random variation to generate the obstacles. I used the modulus and millis function to make the game increase in difficulty as it goes on. I created a score counter, and even found confetti to make the game look more fun.
My greatest challenge was to get the collisions work. I had to specifically define the area of the bear and the obstacles to get the code to stop when it overlapped. I wrote this code and used trial and error and testing to solve this issue:
this.collide = function(glaciers) {
if (penguin.y > this.y1 && penguin.y < this.y3) {
if (penguin.x < this.x1 && penguin.x > this.x3)
return true;
}
return false;
}
Official AP Game: https://editor.p5js.org/anna10128/sketches/shCEF_Ywj

Comments