Simple bouncing ball algorithm

Made some more progress on my DS coding. Po_Ng now has two bats and a ball. The ball bounces around the screen using this absurdly simple bit of code:

if (xpos < 0 || xpos >= 256) xv *= -1;
if (ypos < 0 || ypos >= 192) yv *= -1;

xpos += xv;
ypos += yv;

Yeah, making stuff bounce around the screen is that simple :) So simple I had to use Google to find out how…

Tomorrow I make it bounce off the bats too.

About James

I'm just a person who likes writing software in their spare time. I'm not an "indie games developer" and am not trying to escape my day job and live in the happy world of games dev. I'm more like one of those people that used to write games in their spare time in the 80s. My stuff would be PD or Shareware if this were the 80s or 90s. It's good to comment on the posts in here :)