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.

DarkBASIC Professional Discussion / Pasting image over backdrop

Author
Message
3than
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location:
Posted: 5th Oct 2011 11:52
Hi.
I'm trying to make a really simple program here. If you click the left mouse button, an image appears on the screen. In this case if you shoot, blood will appear on the screen. Here's my code:



And the image is attached.

I've just got one problem. When you click the mouse button, yes, the image gets pasted onto the screen, but when you let go, the image disappears. Unless you click and hold the mouse button, the image will disappear. I believe this is because I put the backdrop on, and it's automatically set to overlap any images pasted onto the screen. Am I right? I don't know if I am.

ANYWAY, how do you get the image to stay pasted onto the screen without the backdrop overlapping it?
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 5th Oct 2011 14:34 Edited at: 5th Oct 2011 15:24
Edit: I figured out how to do it with just load image & paste image. See the next post. This solution was my first stab, when I was drawing blank on how to accomplish it, and it uses sprites.



Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 5th Oct 2011 15:14 Edited at: 5th Oct 2011 15:27
Found a way to do it with images and the paste image command. You have to store the mouse location x & y when the mouse is clicked. Then paste the image to the stored location every loop . When the next click happens it will update the stored locations to the latest mouse x, y position.

I could add code to avoid the double pasting of the image on each update to the mouse x/y location... but I think you can figure out how to only do the paste image inside the if on the first click.



Your signature has been erased by a mod please reduce it to 600 x 120.
3than
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location:
Posted: 5th Oct 2011 15:17
Thanks.
It... Half-worked.
When you click the left mouse button and let go, it does stay there. But, when you click on another place on the screen, it MOVES the sprite there instead of adding another one.

I'm gonna try something else, now. I'm gonna make a crosshair that follows the location of the mouse, and makes a bullet hole if you click. And, instead of moving the sprite, I'm gonna try something different.

Here's my code:



And it worked!!
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 5th Oct 2011 15:49 Edited at: 5th Oct 2011 15:51
Quote: "Thanks.
It... Half-worked.
When you click the left mouse button and let go, it does stay there. But, when you click on another place on the screen, it MOVES the sprite there instead of adding another one."


The moving of the image without retaining was intentional on my part. I Didn't realize that wasn't behavior you were going for, from both your post and your code. It's possible to have the image remain, but it looks like you moved onto something else and got working what you wanted.

Your signature has been erased by a mod please reduce it to 600 x 120.
3than
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location:
Posted: 5th Oct 2011 17:30
Heh, thanks for your help anyway

Login to post a reply

Server time is: 2026-07-11 14:36:32
Your offset time is: 2026-07-11 14:36:32