Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » draw_sprite fonction

This thread is locked; no one can reply to it. rss feed Print
draw_sprite fonction
solveigus
Member #20,167
May 2021

Hi everyone!

I have to drag a BITMAP for a project, and then drop it. I'm using the sprite function, but I think my conditions are wrong, because I can only drag it within the coordinates I put to click on it.
Can someone help me? Thank you!!

#SelectExpand
1if((mouse_b&1) && (mouse_x>20 && mouse_x<=73 && mouse_y>=15 && mouse_y<=95)) 2 { 3 draw_sprite(page,image,mouse_x,mouse_y); 4 }

amarillion
Member #940
January 2001
avatar

Hey, I don't fully understand your question. Can you explain your question a bit more please?

Dizzy Egg
Member #10,824
March 2009
avatar

You need more conditions; what you are saying if is I first click on on my image, then put my image where my mouse_x and mouse_y is; what you need to do is more conditions:

if I click mouse when the cursor is on my image (x > 20 x < 73 y > 15 y < 95)
then whilst the mouse is held down (mouse_b & 1)...
...update new co-ordinates with image x/image y
when I let go of mouse draw image with new co-ordinates image x/image y

The best thing you could do is share your full code, then one of us can edit it to show you how it works.

All you are doing at the moment is one check, which only works within you original mouse position.

Just post your code, it's easier! 8-)

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Go to: