User Tools

Site Tools


haas:fall2021:c4eng:projects:tic80jspong

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
haas:fall2021:c4eng:projects:tic80jspong [2021/09/30 19:56] – created wedgehaas:fall2021:c4eng:projects:tic80jspong [2021/09/30 20:03] (current) wedge
Line 1: Line 1:
 +Here is a copy of the pong code we wrote in class. A few modifications have been made from the version we ended up running in class:
 +
 +  * code has been commented
 +  * sprite wideness has been implemented
 +    * one of the array elements
 +    * a for loop implemented for paddle sprite display (based on paddle width)
 +  * instead of hard-coding numbers, calculate them based on screen size
 +    * two variables, **screenwidth** and **screenheight**, were created to store screen dimensions.
 +  * starting ball direction and reset ball direction is now random
 +    * custom function **getRandomDirection()** created to handle the random choosing of the direction
 +  * the collision detection box is now aware of the bottom of the paddle
 +
 +Code can be copied and pasted into a TIC-80 code editor (probably want to clear out the existing demo code). 
 +
 +Note the assumed tiles that need to be present (#257 and #258)
 +
 <code javascript> <code javascript>
 // program: pong.tic // program: pong.tic
haas/fall2021/c4eng/projects/tic80jspong.1633031794.txt.gz · Last modified: 2021/09/30 19:56 by wedge