Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Deep Toaster on September 04, 2011, 11:01:55 am

Title: Flip
Post by: Deep Toaster on September 04, 2011, 11:01:55 am
/me
There hasn't been much activity in the good ol' TI-BASIC section, has there?

Anyway, I had an idea last night, so I went off to make my first serious TI-BASIC program in over a year. Right now it doesn't have much, but it seems reasonably fast enough that a simple physics platformer could come out of it.

The biggest challenge, as with gravity in Axe and any other language, was how to make it detect a collision when the character could be traveling ten pixels in one frame. This program does that with list operations, which I've found to be the most powerful yet overlooked aspects of TI-BASIC.

Of course, the more platforms there are, the slower it gets. Here's the program running with one platform:

http://img.removedfromgame.com/imgs/t1.gif

Here it is running with four:

http://img.removedfromgame.com/imgs/t4.gif

And here's a full eight:

(http://img.removedfromgame.com/imgs/t8.gif)

(Only one image here because some browsers (*cough* Safari) crash when they see a page with more than one animation.

All these screenshots are of a plain TI-83 Plus. On a TI-84, it's several times faster -- the perfect speed for a platformer:

http://img.removedfromgame.com/imgs/u8.gif

On the other hand, it would definitely slow down once enemies and other game components are added, but right now (on TI-84s) it's too fast for the TI-OS's keypresses anyway. (Arrow keys always pause a bit before repeating.)

Again, I'm not sure if I'll actually make a game of this, but it was a quick and fun little challenge to go back to TI-BASIC again.
Title: Re: Real gravity in pure TI-BASIC
Post by: ralphdspam on September 04, 2011, 01:03:53 pm
Wow!  It looks very nice!  :D
Title: Re: Real gravity in pure TI-BASIC
Post by: ben_g on September 04, 2011, 02:54:52 pm
looks good.

The problem with it being slower with more platforms can be solved by dividing the screen in 4 (or more) sections, then only check for collision in the section the player is in.
Title: Re: Real gravity in pure TI-BASIC
Post by: AngelFish on September 04, 2011, 02:56:12 pm
The problem with that is that it becomes difficult to address the lists efficiently if you have four different sections. TI-BASIC has very limited symbol selection.
Title: Re: Real gravity in pure TI-BASIC
Post by: Deep Toaster on September 04, 2011, 03:00:43 pm
The problem with it being slower with more platforms can be solved by dividing the screen in 4 (or more) sections, then only check for collision in the section the player is in.
Unfortunately that would make it slower as a whole, because I'd need to test which section it's in (and on borders, sections overlap).
Title: Re: Real gravity in pure TI-BASIC
Post by: Juju on September 04, 2011, 03:19:12 pm
Looks pretty nice indeed. Of course it's better in Axe, but making this in BASIC would be cool.
Title: Re: Real gravity in pure TI-BASIC
Post by: Builderboy on September 04, 2011, 04:27:38 pm
That sounds like you have some very very clever list operations going on right there!  What kind of algorithms are you employing? 
Title: Re: Real gravity in pure TI-BASIC
Post by: Deep Toaster on September 04, 2011, 08:32:31 pm
They're not really clever. I just meant I think too often we overlook the fact that lists in BASIC can be added, subtracted, multiplied, divided, and compared with each other and real numbers much faster than loops.
Title: Re: Real gravity in pure TI-BASIC
Post by: DJ Omnimaga on September 04, 2011, 10:22:43 pm
Nice stuff Deep. It's fun to see what can be done in TI-BASIC.
Title: Re: Real gravity in pure TI-BASIC
Post by: ztrumpet on September 11, 2011, 03:11:34 pm
This is pretty awesome, Deep.  I certainly think something cool could be made of this; if it can be made faster, would you continue work on it?

Edit:  I decided to optimize what I saw to optimize in the main loop: (Code "removed" by request)
:Repeat K=20
:getKey-25→K
:C+2→C
:Ans+A→F
:max((Ans-L1)(B≥L2 and B≤L3 and Ans≥L1 and A≤L1
:If Ans
:Then
:DelVar CF-Ans→F
:If K=‾4
:‾10→C
:End
:B+2K(1=abs(K
:If F-A or Ans-B
:Then
:Text(‾1,A,B,"
:Text(‾1,F,Ans,"°
:RecallPic 0
:Ans→B
:F→A
:End
:End

Edit 2: Optimized more. :D
Title: Re: Real gravity in pure TI-BASIC
Post by: Munchor on September 11, 2011, 03:17:16 pm
Awesome, I always love to see you guys making cool programs in TI-Basic!
Title: Re: Real gravity in pure TI-BASIC
Post by: Deep Toaster on September 26, 2011, 07:32:34 pm
ztrumpet, amazing. I shifted the B stuff around and squeezed two more bytes out of that :D

Unfortunately, it's now hopelessly slow on a TI-83 Plus, and I haven't even added enemy hit detection yet D:

(http://img.removedfromgame.com/imgs/1-test.gif)
Title: Re: Goal
Post by: ztrumpet on September 26, 2011, 08:31:05 pm
Hey Deep, take the "-1," out of ":Text(‾1,F,G,"°".  It'll look the same, except it won't erase quite as big of a spot.  Other than that, it looks really awesome. :D
Title: Re: Goal
Post by: boot2490 on September 26, 2011, 08:31:06 pm
I made something like this for a ti basic developer contest...
I tried to make a basketball free throw for the 1K contest.
The program was actually REALLY FUCKING AMAZING. It would do a simple power and angle bar and then when you actually let go of the ball, it simulated a real parabola (I checked the formula later) and it ran BLAZING fast. To make an arc from the bottom left to the middle of the wall took ONE SECOND at most, and then IT BOUNCED OFF THE WALL AND FLOOR. It simulated bouncing, gravity, force, and angle, and it was 600 BYTES. I should post it some time.
Title: Re: Goal
Post by: Deep Toaster on September 26, 2011, 08:32:53 pm
Hey Deep, take the "-1," out of ":Text(‾1,F,G,"°".  It'll look the same, except it won't erase quite as big of a spot.
But it would be slower :/ Maybe.
Other than that, it looks really awesome. :D
Thanks!
Title: Re: Flip
Post by: Deep Toaster on December 11, 2011, 12:38:09 am
This project has been renamed to Flip and will be my Cemetech Contest #8 (http://cemete.ch/n484) entry.

The game now features three types of enemies (moving Xs, static turrets, and "instant zap" zones), as well as Dimension (http://omniurl.tk/8474/)/Bipolar (http://omniurl.tk/8481/)/Madness (http://omniurl.tk/10691/)-style two-map levels.

Here's a screenshot showing all of these on a TI-84 Plus:

(http://img.removedfromgame.com/imgs/12-10-11.gif)
Title: Re: Flip
Post by: ztrumpet on December 11, 2011, 09:15:38 am
That looks pretty cool, Deep!  Good luck keeping the speed up.