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.

DarkBASIC Discussion / Snake Problem

Author
Message
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 20th Jul 2004 20:05
This is really annoying me. Whats going on is whnever i try ad make the food (Green Cubes) the snake won't move and the text showing how many points you've got doesn't show up, But when you delete the FOR NEXT loop that makes the food the snake moves and the Text shows. I Don't Know How to get both to work at the same time.

Hope You Guys Can Help
Thanks In Advance
Axelman.

CURRENT PROJECT: Enemy At The Gates
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 20th Jul 2004 21:03
Ok, the reason why this doesn't work is because the for loop has to finish executing before the movement commands work, so when the final food piece has been placed, only then will it get to the do...loop. I recommend you make use of the timer() command and a subroutine.
When you place a foodpiece, you set a variable as timer + rnd(1000) in this case (might I note that this is only 1 second, you might want to increase it). Then you put an if-statement in your loop checking whether timer() is greater than the variable. If it is, jump to the subroutine, and add another foodpiece.

AMD Athlon XP2800+
GeForce FX5200 128MB
1024MB DDR 333MHz RAM
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 21st Jul 2004 18:39
Cool, Thanks alot Kentaree, I didn't think of using Labels and Timers. Thanks Again, youve been a great help.

CURRENT PROJECT: Enemy At The Gates
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 21st Jul 2004 20:02 Edited at: 21st Jul 2004 20:04
Well, I tried it But it didn't work so i've tried this instead, which is the old 'Classic' Way to play snake, with one piece appearing at a time. I still have to add the tail tho.

Thanks All!!

*EDIT:
oops, sorry, wrong code.
Look Below
*EDIT

CURRENT PROJECT: Enemy At The Gates
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 21st Jul 2004 20:04


CURRENT PROJECT: Enemy At The Gates

Login to post a reply

Server time is: 2025-05-24 21:38:08
Your offset time is: 2025-05-24 21:38:08