Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: bilyp on November 13, 2011, 10:43:45 pm

Title: TiltBall - a puzzle game!
Post by: bilyp on November 13, 2011, 10:43:45 pm
TILTBALL!
Tiltball is my first game for the calc, written in axe.  :)

I asked a question for the math of this game earlier, but now i realize that i will probably need to ask more questions...

a brief overview of the game:

The ball falls from the cieling, due to gravity. the goal is to get the ball to the floor, without hitting the walls. There will be lines in the way of the ball, which the ball bounces off of. The only thing you can control is the rotation of the lines, as shown in the pictures below.

The original level:
(http://i1237.photobucket.com/albums/ff473/bilyp/calcgame2.jpg)
Now, after you press the -> arrow on the keyboard:
(http://i1237.photobucket.com/albums/ff473/bilyp/calcgame1.jpg)
all of the lines have been rotated counterclockwise around the center point.
That is the general idea.

I have the rotation of the lines worked out, but still have two of questions:

1. Is there any way to clip the lines without sacrificing too much speed?
2. How to calculate angle of bounce? so if the ball is coming in at velocity of xv, yv, and slope of the line m, how to bounce off?

Thanks in advance!
Title: Re: TiltBall - a puzzle game!
Post by: DJ Omnimaga on November 13, 2011, 11:12:09 pm
Hmm interesting, I wonder how cool this would be to play? Are those just mockups or actual calc/emulator screen captures? It would be nice to see it in action through an animated screenshot if possible yet. :)

On another note, however, I think I'm just tired, because at first I misread the game title as TitBall. O.O
Title: Re: TiltBall - a puzzle game!
Post by: epic7 on November 13, 2011, 11:14:28 pm
Lol me too!
Title: Re: TiltBall - a puzzle game!
Post by: bilyp on November 13, 2011, 11:36:14 pm
Haha sorry about that. Thanks for not having me banned though!  ;D The game is not nearly finished, so far i have only spent my time on the line rotation, but yeah, those were mockups. Here is a real screenshot!
(http://)
As you can see, it needs a lot of work, especially the ball collision...
Title: Re: TiltBall - a puzzle game!
Post by: DJ Omnimaga on November 13, 2011, 11:40:52 pm
Looks nice. :D A solution to the collision issues would be to make the ball move slower and make the lines twice as thick (probably by drawing 2 copies of them, the second copy being offset by 1 pixel below. Maybe add a 3rd copy offset 1 pixel to the right or left so lines remains thick even if rotated at 90° angle or something.

One thing to make sure is that the ball cannot fall at a speed higher than 1 pixel per frame. If speed becomes an issue then, just refresh the LCD content only every 3-4 frame.
Title: Re: TiltBall - a puzzle game!
Post by: bilyp on November 13, 2011, 11:49:16 pm
Well, actually collision testing is done by comparing the three points (first line point, second line point, and ball location) and testing if they are collinear, not by pxl-checking. but the 3-4 ticks before refresh is a good idea!

EDIT: Sorry I meant cycles, not ticks.
Title: Re: TiltBall - a puzzle game!
Post by: bilyp on November 14, 2011, 07:42:34 pm
Another question...
How would you go about doing trigonometric functions in axe, like tan-1() or sin-1(), to calculate the reverse of the tangent or sine of an angle. I looked all over the internet, but all I could find was that tan(X) = sin(X)/cos(X).
Title: Re: TiltBall - a puzzle game!
Post by: DJ Omnimaga on November 15, 2011, 01:07:15 am
You might want to ask in the Axe section, so more people will notice.
Title: Re: TiltBall - a puzzle game!
Post by: aeTIos on November 15, 2011, 01:25:13 pm
Well, actually collision testing is done by comparing the three points (first line point, second line point, and ball location) and testing if they are collinear, not by pxl-checking. but the 3-4 ticks before refresh is a good idea!
Actually, I think that pxl-check() is way faster. And drawing the screen every 4 frames saves more than 4 ticks I think O.o
Title: Re: TiltBall - a puzzle game!
Post by: ztrumpet on November 15, 2011, 03:40:09 pm
That looks really awesome.  Good luck with the collisions. :)

For arcsin/arctangent, the way I'd do it is with a Look Up Table (LUT).  Here is an arctangent one: http://ourl.ca/4129/191782
Title: Re: TiltBall - a puzzle game!
Post by: bilyp on November 15, 2011, 07:40:43 pm
I ended up posting in the Axe section (thank you DJ_O), and I did get a response, from Quigibo. I'll quote it here in case anyone wants to see the formula.

A surprisingly accurate approximation for arctangent is:

Code: [Select]
atan(x) ≈ (π/2)*x/(abs(x)+1)
Which, when converted from radians, can be implemented in fixed point notation as x*64//(abs(x)+256) however this has overflow problems in the numerator.  The best way to fix this issue is to split the equation into 2, one for large numbers, and one for small:

Code: [Select]
:Lbl atan
:If abs(r1)+256→r2>768
:  Return 64-(16384//r2)
:End
:Return r1*64//r2
Title: Re: TiltBall - a puzzle game!
Post by: Stefan Bauwens on November 16, 2011, 03:03:48 pm
Good luck with this. :)

Also it's DJ_O(with the O of Omnimaga, not zero :) )