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 / Trying to make 2D snake game

Years of Service
User Offline
Joined: 30th Jun 2010
Posted: 30th Jun 2010 21:08
Trying to make a 2D snake game
with real basic knowledge of dark basic

The other code is fine i know

I have a problem here

How to write this

Well I am a C++ user not dark basic so please help me
BN2 Productions
Years of Service
User Offline
Joined: 22nd Jan 2004
Posted: 30th Jun 2010 23:59 Edited at: 1st Jul 2010 00:00
well you can't do that in DBC. If I am reading that right (only very basic level C++ experience, so bear with) what you would mean is something to the effect of:

Here are things I noticed here:

1) == doesn't exist in dbc, its just one = that works for both "set equal to" and "check if equal to". There is no difference (== might work, haven't tried it, but definitely not needed)

2) Images don't work that way. Seems like you would want either to use sprites (in which case you would have something like IF SPRITE X(1)=Sprite X(2) then....) or keep track of each images location separately in variables (such as PlayerX,PlayerY,DotX,DotY). Since I assume you will want multiple Dots, I would definitely suggest using an Array (see DIM command). Paste image is much faster than any kind of sprites, the downside is that you will need to manually clear the screen (which you are doing anyway).

So, an altered version of your main loop (just sorta improvising, you will probably want to tweek it)

Hope this helps!

Great Quote:
"Time...LINE??? Time isn't made out of is made out of circles. That is why clocks are round!" -Caboose
Years of Service
User Offline
Joined: 30th Jun 2010
Posted: 2nd Jul 2010 20:28
I am very very thank you for U r work in my program
Well I haven't tried your version yet

But I was busy 2 days studing more about DBC and before reading u r replay I got the thing you wanted to say that == is not required and also dont work , I tried ;p

well But Please Look at this I made a little change to my program please try running it on u r DBC just put any image and run it

See I have made some change to program major change

Still I want to write the if statement because my snake cant eat apple

and when I tried putting if statement there was some kinda loop that like apples were everywhere

I tried this kind of if statement can you tell me what is wrong in it.

this statement I tried putting in the code where I have commented But it gives Major errors while running

(BTW please bear with my English.)
Years of Service
User Offline
Joined: 23rd Jul 2006
Posted: 9th Jul 2010 03:10 Edited at: 9th Jul 2010 03:11

Is this what you were going for? In this case, the IF THEN is in a block and doesn't require THEN. Use an ENDIF at the end of the block of the code for the conditional.

Your commented code might look like this

If you are testing a single line, the IF THEN statment will contain THEN:
if a=5 then print a

Enjoy your day.

Login to post a reply

Server time is: 2020-08-13 17:40:12
Your offset time is: 2020-08-13 17:40:12