Author Topic: [CSE Basic] Snake  (Read 7829 times)

0 Members and 4 Guests are viewing this topic.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
[CSE Basic] Snake
« on: July 29, 2013, 03:54:39 am »
Latest update here

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).



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.
« Last Edit: July 29, 2013, 08:51:28 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #1 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. ;)
« Last Edit: July 29, 2013, 04:01:19 am by Art_of_camelot »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [CSE Basic] Snake
« Reply #2 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).
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #3 on: July 29, 2013, 04:19:27 am »
Ah, I see. You don't have something you could record it live with(camera/cellphone)?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [CSE Basic] Snake
« Reply #4 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.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [CSE Basic] Snake
« Reply #5 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!

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [CSE Basic] Snake
« Reply #6 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #7 on: July 29, 2013, 05:12:43 am »
A video is fine too. :)

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [CSE Basic] Snake
« Reply #8 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #9 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.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [CSE Basic] Snake
« Reply #10 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

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #11 on: July 29, 2013, 05:21:54 am »
Oh, that's really nice actually. I don't remember a upload script. x.x

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [CSE Basic] Snake
« Reply #12 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [CSE Basic] Snake
« Reply #13 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

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [CSE Basic] Snake
« Reply #14 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. :)
« Last Edit: July 29, 2013, 05:33:32 am by Art_of_camelot »