Trying to make a 2D game in dark basic classic - Programmers Heaven

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Trying to make a 2D game in dark basic classic

Posts: 1Member
Hello
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

[code]
sync on
sync rate 60

hide mouse

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

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

do
sync
cls
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

loop
[/code]

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]