Trying to make a 2D game in dark basic classic

My name is Jake
I have just started using dark basic
Really a beginner in it

Today [b]I am trying to make a 2D game in dark basic classic[/b]

But I am having a little problem with [b]if statement provided after code of program[/b]

When my snake don't eat apple I mean I want to move the apples position when snakes x and y co-ordinates are equal to apples x,y co-ordinates But it isn't happening

See the code I have written

sync on
sync rate 60

hide mouse

Load image "snake.bmp",1
Load image "apple.bmp",2

xposs = 320
yposs = 240
xposa = rnd(640)
yposa = rnd(480)

paste image 1,xposs,yposs
paste image 2,xposa,yposa

speed = 2

if spacekey()=1 then speed=speed+1
if shiftkey()=1 then speed=speed-1

if upkey()=1 then yposs=yposs-speed
if downkey()=1 then yposs=yposs+speed
if leftkey()=1 then xposs=xposs-speed
if rightkey()=1 then xposs=xposs+speed

Rem if statement is required here

xposan = rnd(640)
yposan = rnd(480)

paste image 2,xposan,yposan

paste image 1,xposs,yposs
paste image 2,xposa,yposa


This type of statement I want to enter but it is not going to good

[code]if xposs=xposa and yposs=yposa then[/code]

it either twinkles apples all over screen or nothing happens at all, [b]Is there any other logic or idea. or any modification[/b]

Please do help me.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!