This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:fall2021:c4eng:projects:tic80jspong [2021/09/30 19:56] – created wedge | haas: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**, | ||
+ | * 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 |