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! / Line to Sprite??? Anyone help??

Author
Message
Iceman
19
Years of Service
User Offline
Joined: 10th Jan 2003
Location:
Posted: 12th Aug 2010 21:21
Hi all.

Im doing a drawing program, and need a bit of help.

Im looking for a simple routine to let me make a line I draw on the screen turn in to a sprite.

Now I know that I could just store the x/y coords of the first "dot" (where I start to draw) and then when I release the mouse button, I can store that coord as say a/b (where I end the drawn line) and then just use the two sets of coords to grab that area of screen.

BUT.... the problem with that is that if there is anything at all around the line I draw, it too will become part of the sprited line.

So what I was thinking was...is there some way to make DBP work out the exact edge of the line and within a pixel or two, just grab as close to the line as poss???

Any help would be great on this....as the only other way I can think of doing it is by limiting the line to, say, 256 pixels and grabbing each and every dot as a separate sprite.

But I really want to grab the drawn line as a single pixel...so....anyone help please.
Grog Grueslayer
Valued Member
17
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Aug 2010 05:29
I'm betting you could create a bitmap the minute you start to draw and use that bitmap to store the line. While the user is drawing it's constantly checking the lowest x and y coordinates the line is being drawn at and the highest x and y coordinates. When the user is done you've got a separate bitmap with just the line drawn where you know the screen limits to grab the image for a sprite.

LBFN
15
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 13th Aug 2010 19:30
Hey Iceman,

I'm not sure if this is exactly what you are looking for, but I think you can easily adapt it to fit your needs if not. What it does is allow you to move the mouse wherever you want, click and hold the LMB and a line is drawn from the starting point to where the mouse is currently positioned. An image is grabbed of the line and it is stored on a separate bitmap. The separate bitmap is copied to the screen. This way, you can dynamically draw to the screen and let go of the LMB when you have it where you want. Spacebar exits.



LB

So many games to code.......so little time.
Iceman
19
Years of Service
User Offline
Joined: 10th Jan 2003
Location:
Posted: 14th Aug 2010 20:23
Yes...nice idea that LBFN.... Will give it a try....ty

Login to post a reply

Server time is: 2022-12-06 11:45:34
Your offset time is: 2022-12-06 11:45:34