Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / need help making 2d snake

Author
Message
KeithMAN
17
Years of Service
User Offline
Joined: 24th Jul 2007
Location:
Posted: 11th Aug 2007 03:10
I got The snake head image
THe snake body
the food for the snake
objects for the snake to colide
and snake bitmap world

I NEED HELP WITH
How do I make it so the food randomly apears on the screen
how do I make his bodys get longer
HOw can I make it so I dont have to keep presing the keys to make him go forward and if its not to hard, I no how, a little bit, but can someone explain a bit on 2d moveing(moving your object/main character)

hey those are some nifty lamps you got there
running is for your health,you know?
impressed?,well i'm the bestgood
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 12th Aug 2007 00:22
This is mainly about coding, should go DarkBasic discussion.

(N-1)/n*100<n2/n-n/2+n/4*2+100
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Aug 2007 01:20 Edited at: 12th Aug 2007 01:25
Quote: " How do I make it so the food randomly apears on the screen"

Use
 randomize timer() 
near the start of your program and use random x and y coordinates for placement [see the help files for rnd() if you have a question]. You should check to make sure nothing is in the place where you intend to place the food.

Quote: " how do I make his bodys get longer"

This would depend on how you are displaying the images and how you are tracking them. I would suggest using arrays with sprites.

Quote: "HOw can I make it so I dont have to keep presing the keys to make him go forward "

You check the keystate of the key that you want to use to move forward. You could just use the up arrow key, which can be coded like this
 if upkey()=1 then (code to move snake) 
.
If you want to use a different key, but don't know what number the key is, you can use [/code] k=scancode() : print k
 to tell you the key number.  You then use the code [code] if keystate(k)=1 then (code to move snake) 
If it were me, I would have the program automatically move the snake forward based upon the direction it is pointing, the user would only have to turn left or right. In later levels, you could speed up the snake to make it harder.

Quote: "can someone explain a bit on 2d moveing(moving your object/main character)
"

Typically, sprites are used for 2D movement. They are easily controlled. However, DBC has poor collision detection capabilities and some collisions may not get detected. Anyway, you should decide how many sprites in total that you want in your game: 30 sprites for the snake, 3 sprites for food, 6 for other objects for a total of 39 (or something like this). You then track the location and status of the sprites using arrays. For example, you could use dim snake(30,10) and then snake(4,1)=100 (x coord), snake(4,2)=200 (y coord), etc. to track different aspects about each snake piece (which image to use, it's x and y locations, what direction it is moving, etc.)

Hope this helps you,

LB
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Aug 2007 00:25
pretty sure I posted on a thread just like this yesterday.
type it into search.

Your signature has been erased by a mod because it was rubbish.

Login to post a reply

Server time is: 2025-05-15 19:24:05
Your offset time is: 2025-05-15 19:24:05