Author Topic: Snake Source Code  (Read 35202 times)

0 Members and 1 Guest are viewing this topic.

Offline T3kN1c

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Snake Source Code
« on: January 12, 2012, 05:27:40 pm »
I am pretty interested in calculator programming simply because I have no connector cable, so I have to program everything I want to be on my calculator. By hand... Anyway, I was wondering if anyone could post a TI-BASIC snake program, and explain it a little.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Snake Source Code
« Reply #1 on: January 12, 2012, 05:29:45 pm »
I don't know of any TI basics, but I do know of Axe (like Basic) ones! you don't have a connector? where do you live? I have like six lol! there pretty cheap
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Snake Source Code
« Reply #2 on: January 12, 2012, 05:33:50 pm »
Code: [Select]
:Lbl 1
:AxesOff
:FnOff
:0→Xmin
:94→Xmax
:0→Ymax
:‾62→Ymin
:ClrHome
:ClrDraw
:RecallPic 0
:For(X,2,500
:End
:ClrDraw
:Lbl MN
:0→P
:Menu("     SNAKE     ","PLAY",P,"HIGH SCORE",S,"QUIT",Q
:Lbl P
:Menu("   DIFFICULTY   ","EASY",E,"MEDIUM",M,"HARD",H
:Lbl E:25→T
:1→D:Goto C
:Lbl M:50→T
:2→D:Goto C
:Lbl H:100→T
:3→D:Goto C
:0→Q
:Lbl C
:ClrDraw
:DelVar L
:If P=0:Then
:Output(4,5,"PREPARE"
:Output(5,4,"TO QUALIFY"
:Else
:ClrHome
:Output(4,6,"READY"
:End
:Pause
:ClrHome
:Output(4,6,"1"
:For(X,2,250
:End
:Output(4,8,"2"
:For(X,2,250
:End
:Output(4,10,"3"
:For(X,2,250
:End
:ClrHome
:Output(4,7,"GO!!"
:For(X,2,100
:End
:ClrDraw
:For(X,0,Q
:Pxl-On(randInt(1,61),randInt(1,93
:End
:Horizontal 0
:Horizontal ‾62
:Vertical 0
:Vertical 94
:26→R
:48→B
:32→A
:While 1
:Repeat pxl-Test(A,B) or L=320
:Pxl-On(A,B
:L+1→L
:getKey
:If Ans:Ans→R
:B+(R=26)-(R=24→B
:A-(R=25)+(R=34→A
:End
:If L=320:Then
:P+1→P
:PT→Q
:ClrHome
:Output(3,4,"CONGRATS!!"
:Output(4,6,"GO TO"
:Output(5,5,"LEVEL"
:Output(5,11,P
:Pause
:Goto C
:End
:ClrHome
:Output(3,4,"YOU'RE DEAD"
:Output(4,5,"SCORE:"
:P*320+L→S
:Output(4,11,S
:Pause
:If S>H and D=3
:Then:S→H
:Input "NAME:",Str0:End
:If S>M and D=2
:Then:S→M
:Input "NAME:",Str9:End
:If S>E and D=1
:Then:S→E
:Input "NAME:",Str8:End
:ClrHome
:Lbl S
:{E,M,H}→∟SNHS
:Output(2,2,"HIGH SCORES"
:Output(4,1,"E"
:Output(4,3,Str8
:Output(5,1,"M"
:Output(5,3,Str9
:Output(6,1,"H"
:Output(6,3,Str0
:Output(4,10,∟SNHS(1)
:Output(5,10,∟SNHS(2)
:Output(6,10,∟SNHS(3)
:Pause
:ClrHome
:DelVar P
:DelVar Q
:DelVar L
:Goto MN
:Lbl Q

heres one..I assume since it came with the game it is free to , and you'll need to make a pic (it's just the title screen)
« Last Edit: January 12, 2012, 05:37:40 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

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: Snake Source Code
« Reply #3 on: January 12, 2012, 06:12:33 pm »
Here's the one that I would personally recommend: http://tibasicdev.wikidot.com/archives:nibbles  It bases collision detection and everything off the graph screen, so it produces some interesting and fast code.

If you'd like a homescreen version, you could try this one: http://tibasicdev.wikidot.com/snake

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: Snake Source Code
« Reply #4 on: January 12, 2012, 06:50:30 pm »
By the way welcome to the forums. :)

I would have shared some extra examples of snake games, but unfortunately all 5 snake games I made, back in 2002, were lost due to broken floppy disk and their code were pretty poor anyway.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Snake Source Code
« Reply #5 on: January 12, 2012, 07:01:57 pm »
Welcome to Omni! If you want to view the source of programs that you have downloaded, an excellent tool to use is SourceCoder. All you need to do is load the program from your computer and it will make it into text. It can also do the reverse (text to program), but that won't help your situation XD

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Snake Source Code
« Reply #6 on: January 12, 2012, 08:29:24 pm »
* Art_of_camelot is shocked Xeda didn't suggest hex. :P

Offline T3kN1c

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: Snake Source Code
« Reply #7 on: January 13, 2012, 12:39:36 pm »
Thanks for all the help everyone! I'll look into everything and try it out.

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Snake Source Code
« Reply #8 on: January 13, 2012, 03:07:05 pm »
If you'd like a homescreen version, you could try this one: http://tibasicdev.wikidot.com/snake

Wow, that's a lot of optimization...

This is my (I know, less optimized, but without Lbls and Gotos) Snake code I wrote a while ago when I was new to programming. It turned out quite well, with a decent, but constant speed:

Code: [Select]
:128→dim(L1)
:128→dim(L2)
:{16,8}→dim([A])
:Fill(0,[A])
:1→L:1→O
:2→N:1→X:2→Y
:1→H:0→V:0→B
:X→L1(O):Y→L2(O)
:ClrHome
:randInt(1,8)→G
:randInt(1+[A](1,G)+[A](2,G),16)→F
:Output(G,F,"*")
:Repeat B
:getKey→A
:If A
:Then
:If A=105
:Pause
:If V((A=24)+(A=26))
:Then
:0→V
:A-25→H
:End
:If H((A=25)+(A=34))
:Then
:0→H
:(A=34)-(A=25)→V
:End
:End
:H+X→X
:V+Y→Y
:If (X=0)+(X=17)+(Y=0)+(Y=9)
:Then
:If X=0 :16→X
:If X=17:1→X
:If Y=0 :8→Y
:If Y=9 :1→Y
:End
:If [A](X,Y)
:1→B
:If not(B)
:Then
:Output(Y,X,"O")
:1→[A](X,Y)
:X→L1(N)
:Y→L2(N)
:N+1-128(N=128)→N
:If (X=F)(Y=G)
:Then
:randInt(1,16)→F
:randInt(1,8)→G
:While [A](F,G)
:randInt(1,16)→F
:randInt(1,8)→G
:End
:L+1→L
:Output(G,F,"*")
:Else
:0→[A](L1(O),L2(O))
:Output(L2(O),L1(O)," ")
:O+1-128(O=128)→O
:End
:End
:End
:ClrHome
:Output(2,4,"Game Over!")
:Output(5,4,"Score:")
:Output(5,11,L)
:DelVar L1
:DelVar L2
:DelVar [A]

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Snake Source Code
« Reply #9 on: April 18, 2012, 02:24:33 am »
Incredibly late post...again. But I am actually writing a tutorial/helper that involves a snake program I wrote. I was supposed to make this like a year ago but then life, school, and work took over...so I'm still working on it but it should be coming out hopefully in the next few weeks.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

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: Snake Source Code
« Reply #10 on: April 18, 2012, 02:26:22 am »
Nice to see you again Meishe91, are you planning a return eventually? Also good luck with the tutorial. :)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Snake Source Code
« Reply #11 on: April 18, 2012, 02:28:37 am »
I have no idea. I was just kinda thinking about Axe the other day and was like "I wonder how far that's gotten now..."
I would like to start doing some things again but I don't know really. I mean I started the tutorial like two months ago and haven't gotten a chance to finish it :P Really need to though. We shall see.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Brownie

  • LV0 Newcomer (Next: 5)
  • Posts: 1
  • Rating: +0/-0
    • View Profile
Re: Snake Source Code
« Reply #12 on: March 12, 2013, 12:35:06 pm »
what is the tail of the snakes code

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Snake Source Code
« Reply #13 on: March 12, 2013, 12:38:26 pm »
Which kind of cable do you need? Which calculator do you own? If it's just a mini usb cable: They are everywhere. Look around the house and I'm sure you'll find one. If it's an oldskool 2,5mm jack I/O cable you can buy it on ebay or make one yourself. There are some tutorials out there on how to build your own cable.
If you like my work: why not give me an internet?