Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Hayleia on July 29, 2013, 03:54:39 am

Title: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 03:54:39 am
Latest update here (http://ourl.ca/19302/355998)

So yeah, I heard a lot of people complaining about speed on the CSE, then I saw xLib, CalcuZap and Buttonz not being so slow and I was wondering if Basic had a reasonable speed too (I am talking about pure Basic, not using libs like Legand of Zelda: Sord of Atari).

This is why I coded that Snake game. Don't expect too much of this, it is just a snake, without any surprise. Speed is acceptable but it is true that it would be better if faster. That may also be because of my inexistant optimizing skills in Basic.

edit also w00t, it fits in 29-1 bytes.

Spoiler For the code:
:AxesOff
:FnOff
:ClrDraw
:26?D:10?L:L?C
:TextColr(BROWN
:For(?,1,20
:   Text(~1,2,?*12,"?
:   Text(~1,137,?*12,"?
:End
:For(?,1,8
:   Text(~1,?*15+2,0,"?
:   Text(~1,?*15+2,252,"?
:End
:TextColor(GREEN
:DelVar ?XDelVar ?Y
:seq(12-L+?,?,1,L??X
:seq(32-L+?,?,1,L??Y
:Fill(12,?X
:Fill(32,?Y
:32?A:24?B
:Repeat K=45
:   getKey?K
:   If not(min(abs(K-{24,25,26,34:K?D
:   1+?C+1,L-1?N
:   ?Y(C)+15((D=34)-(D=25?V
:   ?X(C)+12((D=26)-(D=24?U
:   N?C
:   If Pxl-Test(V+7,U+4
:      Goto Q
:   Text(~1,?Y(N),?X(N),"
:   V??Y(N:U??X(N
:   Text(~1,V,U,"*
:   Pxl-On(V+7,U+4
:   If U=B and V=A
:   Then
:      augment(?X,{0,0,0,0??X
:      augment(?Y,{0,0,0,0??Y
:      L+4?L
:      Repeat not(Pxl-Test(A+7,B+4
:         12randInt(1,20?B
:         2+15randInt(1,8?A
:      End
:      TextColor(RED
:      Text(~1,A-2,B,"o
:      TextColor(GREEN
:   End
:End
:Lbl Q
:ClrDraw
:DelVar ?XDelVar ?Y
:ClrHome
:Output(1,1,"Game Over

edit edit Stretched gif (don't ask me why it is stretched, I don't know).
(http://www.omnimaga.org/index.php?action=dlattach;topic=16705.0;attach=15801;image)


edit edit edit @Xeda : I finally didn't use your code to check if there are two occurences of the same point in the lists because I was fearing that the speed of the calculations would depend on the length of the lists.
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 04:00:50 am
You should see if you can capture a video or a gif with an emulator. You know, for those of us without the CSE. ;)
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 04:18:19 am
You should see if you can capture a video or a gif with an emulator. You know, for those of us without the CSE. ;)
Yeah, I thought about that (I always do that for the monochrome models) but I don't know what to record with : Wabbitemu doesn't work with the CSE (or I missed something) and jsTIfied asks for a ROM, and the only rom dumper I found needs TiLP which I always failed to install (so I use TI-Connect).
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 04:19:27 am
Ah, I see. You don't have something you could record it live with(camera/cellphone)?
Title: Re: [CSE Basic] Snake
Post by: Streetwalrus on July 29, 2013, 05:02:49 am
You should see if you can capture a video or a gif with an emulator. You know, for those of us without the CSE. ;)
Yeah, I thought about that (I always do that for the monochrome models) but I don't know what to record with : Wabbitemu doesn't work with the CSE (or I missed something) and jsTIfied asks for a ROM, and the only rom dumper I found needs TiLP which I always failed to install (so I use TI-Connect).
Yeah someone should make a WabbitEmu-like ROM dumper (dump boot pages as appvars then patch them together with the OS), as well as a BootFree equivalent for the CSE.
Title: Re: [CSE Basic] Snake
Post by: Sorunome on July 29, 2013, 05:05:32 am
Wait, you have a CSE? Awesome!
Also, the snake game is looking cool, but yeah, an animated screenie would be awesome!
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 05:09:54 am
Lol, I have the CSE since April.
And yeah, I agree myself that an animated screenshot would be awesome. So if someone can do it, please do. In the meanwhile, I'll try to record a video and convert it as a gif somehow.
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 05:12:43 am
A video is fine too. :)
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 05:14:06 am
Yeah, but it is a bit heavy to be uploaded lol. And I don't have a Youtube account so I can't put it there.
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 05:15:34 am
Ah, ok. I was going to suggest putting it on OmnimagaTV, but I think that still requires you to initially have a Youtube account.
Title: Re: [CSE Basic] Snake
Post by: Sorunome on July 29, 2013, 05:18:37 am
No, it doesn't, there's a upload script somewhere but nopony ever checks it.
Just email it me with what i should put in the description/the tags/the title.
mail:
mail [at] sorunome [dot] de
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 05:21:54 am
Oh, that's really nice actually. I don't remember a upload script. x.x
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 05:25:44 am
Ok, I converted that video into a gif. The image is stretched for some reason but since the goal was to judge the speed I think it is not a problem.
And thanks Sorunome for your help anyway, even if I don't need it anymore.
Title: Re: [CSE Basic] Snake
Post by: Sorunome on July 29, 2013, 05:26:53 am
That's actually pretty fast O.o
But yeah, you could still upload it to OmnimagaTV :P
Title: Re: [CSE Basic] Snake
Post by: TIfanx1999 on July 29, 2013, 05:32:57 am
Thanks for posting a screenie Hayleia. You're right! Speed is actually quite nice! :) Also, what Sorunome said, if you want to. :)
Title: Re: [CSE Basic] Snake
Post by: Streetwalrus on July 29, 2013, 05:44:15 am
Eyup it's pretty fast. O.O
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 05:47:27 am
Well thanks all for judging the speed. In fact I am so used to Axe that I can't judge Basic speed anymore lol.

(However, please don't judge my skills at that game, I was holding the camera with my main hand and playing with the other one without seeing the calc screen due to the oversized Android, and without seeing the keys I was pushing either. I don't say that I play better when I have my two hands and when I am in front of the screen, but for once I have an excuse to say why I play badly).

Also, I just remember now that I have a gmail account so I may have a youtube account -.-°
Title: Re: [CSE Basic] Snake
Post by: Hayleia on July 29, 2013, 08:50:45 am
Double posting for an update.
Now using the small font instead of the large one (don't know why I used the large one in fact), which means a larger playable area. However, I don't know why but if you eat an apple in the first two rows, you lose. So I made them spawn anywhere but in those rows.

(it is also now 469 bytes large instead of 511)
Title: Re: [CSE Basic] Snake
Post by: DJ Omnimaga on July 29, 2013, 08:03:35 pm
This actually looks pretty nice and fast. Actually Sord of Atari used the Text() command as well but with large space fonts. The only ASM lib used was the 160x240 setting program, but the game could have been made for larger res in pure basic as well.