|
-
Feb 21st, 2003, 08:47 PM
#1
Thread Starter
Junior Member
Random positions
I am making a snake game. I need to know how to make little fruit pop up in different area on the form. also I would like to know how to make a barrier for the snake so if it hits the wall it will die. Thanx in advance for any replies.
-
Feb 22nd, 2003, 09:10 AM
#2
For the fruits use a random number generator.
For the barrier, simply do an out-of-bounds check for the head each step.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 22nd, 2003, 04:24 PM
#3
Hyperactive Member
Your code for the random fruit position should look like this:
VB Code:
Private Function MoveFruit()
Randomize
X = Int(Rnd * MapWidth) * FruitWidth
Y = Int(Rnd * MapHeight) * FruitHeight
Fruit.Move X, Y
End Function
MapWidth and MapHeight would be the number of tiles wide the map is, not pixels.
[vbcode]
' comment
Rem remark
[/vbcode]
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
|