|
-
Mar 28th, 2004, 02:02 PM
#1
Thread Starter
Lively Member
Snake Help
So I followed NoteMe's BitBlt Snake tutorial, by the way its great and easy to follow . Anyway, I'm trying to do what you suggested at the bottom of that page by adding the head and tail and whatnot. I have the walls, head, tail and where if the snake hits its own body.
I need help on the part were if the snake is going up, it cant go down. if its going left it cant go right etc. Is there a way to disable keys like if the snake is going up, then the down key is disabled?
Thanks in advance.
-
Mar 28th, 2004, 03:59 PM
#2
Are you using my movement method from the tutorial? Then check the facing of the head in an inner If test in the code....
Algorithm:
- The user pressed left
- Check to see if the snake head is facing right
- If then do nothing
- If NOT then face left
Do the same with all directions..
DId you get it? If not I can make you a code sample...but it's great learning for you, if you figgure it out after reading my Algorithm...
-
Mar 29th, 2004, 07:52 PM
#3
Thread Starter
Lively Member
Originally posted by NoteMe
Are you using my movement method from the tutorial? Then check the facing of the head in an inner If test in the code....
Algorithm:
- The user pressed left
- Check to see if the snake head is facing right
- If then do nothing
- If NOT then face left
Do the same with all directions..
DId you get it? If not I can make you a code sample...but it's great learning for you, if you figgure it out after reading my Algorithm...
I am using the movement from the tutorial. SO owuld it be something like this:
VB Code:
if keycode=37 and facing=3 then 'check if left is pressed and facing right
'do nothin
else if
Snake(0).facing=1 'goes left
end if
im just not sure what to do for the "do nothing" part. Or would it be better to use a boolean variable?
-
Mar 29th, 2004, 09:27 PM
#4
Frenzied Member
you could do it something like this:
VB Code:
If KeyCode = vbKeyLeft And facing <> 3 Then 'check if left is pressed and facing anything but right
Snake(0).facing = 1 'goes left
End If
-
Mar 30th, 2004, 02:57 AM
#5
Both ways are fine....just do it the way you feel most comfortable with...
-
Mar 30th, 2004, 04:50 PM
#6
Thread Starter
Lively Member
Thanks alot for the help. I used cyborg's code and worked perfectly. Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|