Pong clone as another beginner project, with mouse control and low difficulty because it targets my then 3 year old son.
He liked it. The characters are loosely based on a certain
animation series he likes
and the version he got also contained audio taken from their videos which I will not include here. The ball shape is a spider human, copied from a drawing he made.
Not much to say about the code, still mostly ugly but again so much fun. Finished it in a real hurry late night to have him play it the next morning.
The ball is reflected not according to segments that return a certain angle, but dynamically depending on how far away
from the middle of the player the ball collided:
ballPPmSY = (Tadaagruen.y + 32.5) - balltarget.y) / 120);
where ballPPmsY, in connection with an up/down boolean, says how far the ball goes up or down per ms. The player's square size is 90*60 but the painted
head and body shape is odd so so I adjust with a magic number (32.5) to shift the middle a bit downwards. balltarget is where the ball hits (the upper left corner of it?),
120 is another magic number to keep the angle from sharpening too abruptly. Negative ballPPmSY are made positive and switch the direction bool downwards, 0 is straight and the rest makes the ball go upwards.
Download the Game
here the bad code.
Copyright © 2016-2023 FileNewOpen.com