This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 21 Jun 2003 01:59:01 am    Post subject:

I am creating a snake game for my 83+ in BASIC. When you start up the game you first see the title screen. At the title screen, while "PRESS ANY KEY" is flashing on and off waiting for a key to be pressed, there is a snake trying to eat pieces of food. Ideally, that is what I want to happen. I have been unsuccessful in creating this. If you guys have any suggestions or ideas of how I can do this, then I would greatly appreciate to hear them. Also, example code would be appreciated as well.

Last edited by Guest on 10 Sep 2005 09:28:23 pm; edited 1 time in total
Back to top
gorchy


Newbie


Joined: 30 May 2003
Posts: 19

Posted: 21 Jun 2003 03:03:36 am    Post subject:

one way to make an endless snake could be:

Code:
1->A
30->C
30->R
while 1
C+1(A=3)-1(A=1->C
R+1(A=4)-1(A=2->R
Pxl-change(R,C
Getkey->G
If not(Ans
End
Ans-23->A
If G=34
4->A
End

in this prgm the direction of the snake is stored into A (1-left/2-up/3-right/4-down)

this is not like the original snake because the snake has no end but i´ve no idea how to do this. Confused
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Jun 2003 06:30:57 am    Post subject:

The flashy intro screen:

Output(4,8,"A SNAKE GAME //cool title huh
Repeat K //loop until key is pressed
getKey->K //check for key
//do AI snake stuff if you want to here
Output(7,1,sub("Press a key ",1+11(ø>0),11 //draw press a key or lots of spaces (11) to clear it up depending on the value of ø
ø+1-10(ø>5->ø //increase ø or reset it, change the 10 and 5 for slower flashing text
End

If you do it on the graph screen, change the output to text( the coordinates to what you want and the number of spaces to 38 and add this after 1+11(ø>0),11:
+27(ø>0

Resulting in
Text(25,25,sub("Press a key //lots of spaces here ",1+11(ø>0),11+27(ø>0

AI for the snake:
//a and b are the x and y coordinates of the snake
//c is x coordinate of food
//d is y coordinate of food
A+(A<C)-(A>C->A //change x position towards food
If A=C:B+(B<D)-(B>D->B //change y pos towards food, only if x pos hasn't been changed to avoid diagonal movement
If A=C and B=D:Then //if snake eats food, create new food
randInt(1,95->C
randInt(1,63->D
End
pixelOn(B,A //draw snake at new place


Last edited by Guest on 21 Jun 2003 06:41:00 am; edited 1 time in total
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 23 Jun 2003 12:52:14 pm    Post subject:

ok, i added on to the Wizards code, and made this program :

Code:
10->Z
Z->dim(L1
Fill(0,L1
L1->L2
FnOff
GridOff
AxesOff
ClrDraw
randInt(0,94->C
randInt(0,62->D
31->B
47->A
Repeat getKey
A+(A<C)-(A>C->A
If A=C:B+(B<D)-(B>D->B
If A=C and B=D:Then
randInt(0,94->C
randInt(0,62->D
Z+5->Z
End
Pxl-On(D,C
Pxl-On(B,A
augment({B},L1->L1
augment({A},L2->L2
Z->dim(L1
Z->dim(L2
Pxl-Off(L1(Z),L2(Z
End

that program will have an AI Snake until a key is pressed, and u may want to have it start over if it runs into itself Wink


Last edited by Guest on 23 Jun 2003 01:07:48 pm; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement