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.

Author
Message
FireDragon
22
Years of Service
User Offline
Joined: 21st Oct 2003
Location:
Posted: 22nd Oct 2003 04:08 Edited at: 22nd Oct 2003 04:10
Hello I am new to DarkBASIC Pro and would like to ask a simple question. I was experimenting with user defined types and came up with this.


alieninfo as mytype
Type mytype
xcoords
ycoords
EndType

load image "ani-invader.bmp",1

do
if upkey()=1 then alieninfo.ycoords=-1
if downkey()=1 then alieninfo.ycoords=+1
if rightkey()=1 then alieninfo.xcoords=+1
if leftkey()=1 then alieninfo.xcoords=-1
sprite 1,0,0,1
spritex=sprite x(1)+alieninfo.xcoords
spritey=sprite y(1)+alieninfo.ycoords
paste sprite 1,spritex,spritey

loop



My only problem is that I can only move the sprite 1 space to up, down, left or right. I know there must be a simple solution to this.

Cheers,
FireDragon

PS: I've noticed that other code snippets on the fourm are seen by pressing +code snippet. How is that done?
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 22nd Oct 2003 04:20
The problem is that you are never changing the x and y coords values. See the source code I attached to this message which is a modification of yours which works

I hope you can see what i've done.

Also, you don't need all that paste sprite stuff. Again, see my code (click the SOURCE button on this thread).

Cheers,

Rich

"It's easy to be mean when death equals a high score screen."
"You can take your Quake and go away, I'd rather play Bubble Bobble any day."
FireDragon
22
Years of Service
User Offline
Joined: 21st Oct 2003
Location:
Posted: 22nd Oct 2003 04:29
Oh I see what my problem was.

Thanks for solving my problems

FireDragon
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 22nd Oct 2003 19:26
The answer to your other question is:

1) Click 'code' (top right of 'Post Message' window)

2) Write or paste your code.

3) Click 'code' again

Then carry on with your message as before

Login to post a reply

Server time is: 2026-07-07 03:24:03
Your offset time is: 2026-07-07 03:24:03