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.

2D All the way! / moving sprites with the mouse

Author
Message
whipped6
19
Years of Service
User Offline
Joined: 31st Aug 2006
Location:
Posted: 22nd Sep 2006 02:33
hiyas everybody i need help moving sprites with the mouse if you could just give me the code that will be fine to...

game creator
Tinkergirl
23
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 22nd Sep 2006 23:05
Generally, you want to read where the mouse is on the screen - mousex() and mousey() will give you these values. You then want to use those as the X and Y of your sprite.

I know it's not just code, but I hope it puts you on the right track. Remember to check out the help files in DB if you think you're stuck too - they're quite handy.

smoked
20
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: USA - california
Posted: 23rd Sep 2006 03:04
gimme da codez...lmao

whipped6
19
Years of Service
User Offline
Joined: 31st Aug 2006
Location:
Posted: 23rd Sep 2006 03:28
the code to move and load a sprite is this

DO
sync on
load image "pawn.bmp",1
sprite 1,0,0,1
if mouseclick()
sprite 1,mousex(),mousey(),1
endif
sync
LOOP

game creator
smoked
20
Years of Service
User Offline
Joined: 2nd Oct 2005
Location: USA - california
Posted: 23rd Sep 2006 23:29 Edited at: 23rd Sep 2006 23:29
Quote: "
the code to move and load a sprite is this

"


instead try it like this


RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Sep 2006 00:15
whipped, please listen to what I told you in IRC dude. You NEED to read them tutorials!

Your signature has been erased by a mod because it's larger than 600x120...
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 6th Oct 2006 02:28
REM THE WHOLE GAME IS IN THE MAIN LOOP! EVERYTHING!
DO
REM EVERY LOOP OF THIS TURNS THE SYNC ON!( once prior to the main loop is fine )
sync on
REM EVERY LOOP OF THIS TRIES TO RELOAD THE SAME IMAGE! ( once )
load image "pawn.bmp",1
REM EVERY LOOP OF THIS TRIES TO PLACE THE SPRITE AT 0,0 ( once )
sprite 1,0,0,1

if mouseclick()
sprite 1,mousex(),mousey(),1
endif
sync
LOOP

good effort for trying to help but you killed it all by not looking over your small code and rushed it perhaps. the example would be a bad way to approach it, until some commands were moved around and shuffled

whipped6
19
Years of Service
User Offline
Joined: 31st Aug 2006
Location:
Posted: 7th Oct 2006 22:06
dood one thing im a beginner second thing the code i have is perfeclty fine the rem is for organizing your code

game creator

Login to post a reply

Server time is: 2026-07-08 03:49:08
Your offset time is: 2026-07-08 03:49:08