top of page
Search

Bouncing Ball Assignment

  • danielgrinchenko
  • Sep 15, 2020
  • 1 min read

I had to code a bouncing ball. My goal was to make it so that every time the ball hit the wall it would randomly change speed and it would randomly change color. I started by declaring all of my variables. I declared position variables to change the positions of the x and y coordinates. I declared r,g,b values to make it so they randomly change and randomly assign a color to the ball after every bounce. I then added speed variables to make it so the ball bounces differently every time. They would also randomly change after every bounce. I then proceeded into my main code. I made a conditional for both of my position variables. I set the bounds so the ball doesn't bounce of the screen and I put another conditional to help randomly change the speed. I ran into a error where my ball gets stuck on the edge. I tried to fix it using an acceleration variable but it did not end up working. Lastly, I drew my ball and gave it random color values.


 
 
 

Recent Posts

See All
Final Project Part 2

For my final project I took inspiration from one of the projects I worked on earlier in the semester. It was a failed attempt at a maze...

 
 
 
Final Project

For my final I wanted to work on my midterm hockey game. I added some decorations to the hockey rink to make it look more like an actual...

 
 
 
Assignment 8: Circuits

All my circuit does is light up LED lights with the press of a button. The catch is that is spells out the word "Hi" with a smiley face...

 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2020 by Dan's Website. Proudly created with Wix.com

bottom of page