top of page
Search

Assignment 8

  • ncampanelli0
  • Nov 7, 2019
  • 1 min read

I attempted to make pong. I have a problem in getting the collision detection to work. I tried importing somebody else's code (p5 2d collide library) for testing purposes and I had the exact same wonky hit detection as when I wrote my own detection statement. Other problems I had involved collision detection to prevent the paddles from going offscreen (only going down, up worked perfectly fine, I assumed the logic for this would be if paddle >= to the height of the canvas, don't allow it to move, the opposite of up which is 0, this surprisingly didn't work) and a problem with multiple keys being input interfering with the controls between player 1 and player 2. Besides that everything else is working from bouncing the ball from the sides of the screen, a working score counter and a reset mechanic.


The main thing I focused on in trying to solve the hit detection was a variety of if statements (I resorted to trial and error after a while) as well as attempting to make use of dist() which seemed to work until I noticed, no it isn't. I made use of text() and print() to figure out what was happening in the code and made more educated guesses on the parameters of the if statements. As always the code is commented to state what everything is and variable names are recognizable.


note: ignore the index.js file, I can't delete it for whatever reason.

 
 
 

Recent Posts

See All
Final assignment (trivia project)

How I came to this idea for a project was simple. Back when I was in high school I made a trivia style game. This game was written for...

 
 
 
Assignment 9 (drawing program)

I made a drawing program with multiple colors that can be selected (with black being used as the eraser color as the background is...

 
 
 
Assignment 8 (bug fixes)

change log: 1. Revised collision for ball to bounce off paddles properly (instead of requiring perfect pixel alignment with a sweet spot,...

 
 
 

Comentários


©2019 by creative coding art and games. Proudly created with Wix.com

bottom of page