Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on March 19, 2015, 06:53:26 pm

Title: Snake Game
Post by: meishe91 on March 19, 2015, 06:53:26 pm
Well...it has been quite a while since I posted here. Hey everyone.

Anyways, point of this. A few years ago I wrote a snake game. That snake game was probably one of the smallest snake games (if not the smallest), at least at the time. 361 bytes (or whatever the unit is...I don't remember).

I was planning on not only releasing the game to you guys, but was also going to write a complete tutorial on basic game writing because I had kept each stage of the game. It would have just been about one way of going about a game. Places to start, how to think about it, maybe some optimization. I don't remember all the details.

Unfortunately, I have not come bearing this tutorial. I do come though with the game...in text form. I've been planning on just posting it for a while now so you guys could play with it, but haven't had the time/motivation. So I figured why not today.

Code: [Select]
ClrHome
{8.4,7.4→L1
DelVar DDelVarS2→C
DelVar Y1→X //DelVar Y then 1→X
Repeat min(L1≠F
randInt(1,16)+.1randInt(1,8→F
End
Output(10fPart(F),iPart(F),"+
Repeat L>1
getKey→K
Output(10fPart(L1(1)),iPart(L1(1)),"*
If Y
Then
(K=26)-(K=24→X
If Ans
DelVar Y
Else
.1((K=34)-(K=25→Y
If Ans
DelVar X
End
Output(10fPart(L1(C)),iPart(L1(C)),"_ //_ = Space
X+L1(1
Ans-16((Ans>=17)-(Ans<1
Y+Ans
Ans-.8((fPart(Ans)=.9-not(fPart(Ans
augment({Ans},L1→L1
If F=L1(1
Then
S+1→S
Repeat min(L1≠F
randInt(1,16)+.1randInt(1,8→F
End
Output(10fPart(Ans),iPart(Ans),"+
C+1→C
End
C→dim(L1
sum(L1=L1(1→L
End
ClrHome
Output(1,1,"SCORE:_
Output(1,8,S

I'll be honest, I don't remember how exactly everything works. But I do know that it basically just refreshes the start of the snake, deletes the last, and ya. Hopefully some of you guys can answer the questions about what things are doing what :P

I remember I had Kerm look this over after I wrote it and I don't think he saw any other spots to make it smaller or faster. I'm curious if you guys see anything.
I also apologize for if there is a typo somewhere in there. I don't think there is one, but could be.
Enjoy.

SIDE NOTE:
If I ever am able to get the actual file off my calculator I'll try to attach that.
Title: Re: Snake Game
Post by: TIfanx1999 on March 19, 2015, 11:17:33 pm
Hey there, it's been a while! Good to see you around!
Title: Re: Snake Game
Post by: Juju on March 20, 2015, 12:12:57 am
Yep, been a while, welcome back ^_^