Author Topic: TiltBall - a puzzle game!  (Read 3382 times)

0 Members and 1 Guest are viewing this topic.

Offline bilyp

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +9/-1
  • Axing the z80
    • View Profile
TiltBall - a puzzle game!
« 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:

Now, after you press the -> arrow on the keyboard:

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!
« Last Edit: November 14, 2011, 07:44:42 pm by bilyp »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TiltBall - a puzzle game!
« Reply #1 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
« Last Edit: November 13, 2011, 11:13:13 pm by DJ_O »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #2 on: November 13, 2011, 11:14:28 pm »
Lol me too!

Offline bilyp

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +9/-1
  • Axing the z80
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #3 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!

As you can see, it needs a lot of work, especially the ball collision...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TiltBall - a puzzle game!
« Reply #4 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.

Offline bilyp

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +9/-1
  • Axing the z80
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #5 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.
« Last Edit: November 15, 2011, 07:36:29 pm by bilyp »

Offline bilyp

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +9/-1
  • Axing the z80
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #6 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).

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TiltBall - a puzzle game!
« Reply #7 on: November 15, 2011, 01:07:15 am »
You might want to ask in the Axe section, so more people will notice.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: TiltBall - a puzzle game!
« Reply #8 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
I'm not a nerd but I pretend:

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #9 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

Offline bilyp

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +9/-1
  • Axing the z80
    • View Profile
Re: TiltBall - a puzzle game!
« Reply #10 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
« Last Edit: November 16, 2011, 08:13:49 pm by bilyp »

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: TiltBall - a puzzle game!
« Reply #11 on: November 16, 2011, 03:03:48 pm »
Good luck with this. :)

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


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me