Author Topic: CSE BASIC Graph Screen Snake  (Read 6220 times)

0 Members and 1 Guest are viewing this topic.

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
CSE BASIC Graph Screen Snake
« on: July 29, 2013, 10:25:05 am »
Hi. I noticed Hayleia's BASIC snake game on the homescreen, and I wondered how fast it could be on the graphscreen.
Made this today while seeking Weregoose's snake game code for help. (He posted code to it a while ago, and I've used it since, but idk how to contact him about it.)
It uses a trick called the pathfinding tail eater. So no lists! :D Anyhow, here's the code, at 351 bytes:
Spoiler For the code:
::"SNAKE
:ClrHome
:ClrDraw
:AxesOff
:BackgroundOn WHITE
:120→A
:84→B
:118→D
:84→E
:26→K
:132→Xmax
:Vertical Ans
:‾Ans→Xmin
:Vertical Ans
:82→Ymax
:Horizontal Ans
:‾Ans→Ymin
:Horizontal Ans
:For(C,0,E9
:2randInt(2,128→F
:2randInt(2,40→G
:0
:Repeat K=45 or pxl-Test(B,A
:If Ans
:Then
:E+2(pxl-Test(E+1,D)-pxl-Test(E-1,D→X
:D+2(pxl-Test(E,D+1)-pxl-Test(E,D-1
:Pt-Off(D-132,82-E
:Ans→D
:X→E
:End
:Pxl-On(B,A,ORANGE
:Pxl-On(B+(K=25)-(K=34),A+(K=24)-(K=26),ORANGE
:Pxl-On(G,F,GREEN
:getKey
:If max(Ans={24,25,26,34,45
:Ans→K
:A+2(K=26)-2(K=24→A
:B+2(K=34)-2(K=25→B
:End
:If A=F and B=G
:End
:ClrDraw
:ClrHome
:Disp "SCORE:",C
Unfortunately, the snake is quite skinny due to me using pixels (necessary point-pixel usage to the pathfinding tail eater):
« Last Edit: August 13, 2013, 09:46:42 pm by dinosteven »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #1 on: July 29, 2013, 10:35:25 am »
Hi. I noticed Hayleia's BASIC snake game on the homescreen
But... Mine is on the graphscreen too ???
I just use Text commands instead of pixels/points/lines because it is easier/faster.
Also, it uses lists but doesn't make any calculation on them.

Anyway, yours looks great and fast !
And the fact the snake is skinny is not really a problem on a screen sithout blur, and it gives the snake more space to move in.
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 dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #2 on: July 29, 2013, 10:52:30 am »
Oh lol, I thought it was homescreen from the pic. My bad for not reading your code, sorry!
Regarding lists... I don't believe it will cause a slowdown. But I'm running out of memory, after downloading every CSE program on ticalc. And each element taking up 9 bytes, something like 5,200 elements would overflow, being pixel based. (80*260/4 cuz I'm doing every other pixel). You don't have that problem because you're using text, and it can't get that big. But for the pro players on mine... ERR:OVERFLOW - so I don't use lists.
« Last Edit: July 29, 2013, 11:04:08 am by dinosteven »

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 Graph Screen Snake
« Reply #3 on: July 29, 2013, 11:02:30 am »
Looking cool! Suddenly I'm amazed how fast the CSE was, i thought it was slower, lol

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

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #4 on: July 29, 2013, 12:08:03 pm »
Yeah that looks pretty cool !

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CSE BASIC Graph Screen Snake
« Reply #5 on: July 29, 2013, 08:15:36 pm »
Actually Merthsoft on Cemetech (where Weregoose can be found, by the way) made a similar Snake game (using Pt-On commands and graphics, but it had obstacles as well), but yours looks cool anyway  (and is smaller) :P

http://www.cemetech.net/programs/index.php?mode=file&id=877
« Last Edit: July 29, 2013, 08:16:40 pm by DJ Omnimaga »
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #6 on: July 29, 2013, 08:41:41 pm »
Yeah, I actually downloaded that and another snake game before being disappointed at them using lists. imo lists are only useful temporarily due to the 9 bytes per element issue due to supporting 14 digits and imaginary numbers etc. - most of which don't get used (usually only ints are stored in them). I wish TI made it custom strings rather than custom lists.
I'm not on Cemetech, but I'll try to see if I can find Weregoose there. (Does cemetech have PMs?)
This is really just a test for speed. I'm going to test his code from 1 end of the screen to another end and multiply the time by 3 to compare with mine. (I'm pretty sure 3 should be the factor between pts to pxls). If mine is faster, I might flush it out with highscrores, making it look better, showing the score, more features etc.

EDIT: No disrespect meant to any of those authors, I swear! I just meant to that lists slow things down even though they are useful, and I wanted to make a faster version without lists, but not necessarily with all the features a list can help make. Slower doesn't mean worse, but my goal here is speed. I wasn't attacking their work at all. Sorry for coming across as disrespectful to them. :P
« Last Edit: July 31, 2013, 01:36:09 pm by dinosteven »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CSE BASIC Graph Screen Snake
« Reply #7 on: July 29, 2013, 08:45:21 pm »
Yeah the thing though is that lists are sometimes the only way to do something efficiently in BASIC (eg for saving in RPGs or tilemapping), but the 9 bytes per element thing is annoying, which is why tr1p1ea planned lists of 1 byte integers for some data in xLIB CSE. Strings are really slow in BASIC. >.<

(Note: I think it's wrong to insult someone's work only for using lists, matrices, pics or whatever, unless he was using ASM or Axe)
« Last Edit: July 29, 2013, 08:47:20 pm by DJ Omnimaga »
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #8 on: July 29, 2013, 08:55:09 pm »
1 byte int lists??!!?!?!? YES. That would be great. I usually use strings because they're just so much more memory efficient - lists temporarily during execution, then I translate them into strings for long term. Int arrays of 1 byte would be a dream come true.
« Last Edit: July 29, 2013, 08:55:25 pm by dinosteven »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CSE BASIC Graph Screen Snake
« Reply #9 on: July 29, 2013, 08:58:37 pm »
Yeah I used strings in certain games as well, such as Illusiat 13 maps. They are only fast there because there can only be two different floor tiles to check for walking collision. Of course with 1 bytes in lists I wouldn't be able to store everything, though, such as character HP, MP, experience and gold, because the limit would be 255.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #10 on: July 29, 2013, 09:02:12 pm »
I've dealt with that pretty easily in Axe by using 2 bytes to store it. Just multiply the first byte by 256 and add. And voila, you have a range of 16 thousand.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CSE BASIC Graph Screen Snake
« Reply #11 on: July 29, 2013, 09:05:56 pm »
True, although that still doesn't solve the HP, exp and gold issue. >.< In most RPGs, experience and gold can reach 9,999,999 and some RPGs can reach 99,999 HP. I remember someone made a routine to multiply two two bytes numbers but that seemed to make it particularly confusing to dechiper the data. >.<. Damage calculations was even worse when an enemy had elemental weaknesses and your formulas used multiplications. But again even commercial console games had overflow issues anyway. :P
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #12 on: July 29, 2013, 10:56:45 pm »
Oh wow... I would've expected numbers like 10,000, not 10,000,000. But more bytes = more space. It's a simple matter of multiplying by the base and adding. In BASIC, it's easy, right?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: CSE BASIC Graph Screen Snake
« Reply #13 on: July 30, 2013, 12:34:08 am »
Yeah in BASIC you can pretty much use any number.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: CSE BASIC Graph Screen Snake
« Reply #14 on: July 30, 2013, 02:07:43 am »
Any number that is <= 9000.

But in all seriousness, its great to see these little games coming out. It means that there is interest in the 84C and the more familiar people become with its capabilities, the more games we are going to see! :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."