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 / How to paste an image with alpha channel?

Author
Message
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 4th Mar 2013 23:39 Edited at: 4th Mar 2013 23:40
Hello.

I'm making an RTS and am working on unit selection.

I have an image I want to past unto the screen to represent the unit is selected. It works fine, But it does not take it's alpha into consideration.
I can't use a sprite because it will only paste on the latest call. I could make a new sprite for every selected unit i need. But I'm not sure how much memory that would take. And being an RTS I really want to save memory were I can.

is there a way to turn alpha mode on for images to paste onto the screen?

Thanks.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Mar 2013 23:49
I can't use a sprite because it will only paste on the latest call. I could make a new sprite for every selected unit i need. But I'm not sure how much memory that would take. And being an RTS I really want to save memory were I can.
I'm not sure what you mean, using a sprite isn't different from pasting an image.
You can change the image of the one sprite if you don't want to have multiple sprites. If that's your concern a sprite is (supposedly) very light weight; all its pixels are read from the referenced image and aren't copied or anything such and the sprite itself can probably have a representation of just a few hundred bytes (assuming it is internally represented as a plane mesh with locked z-position etc.).
Or did you mean something else?


"Why do programmers get Halloween and Christmas mixed up?"
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 5th Mar 2013 00:05 Edited at: 5th Mar 2013 00:07
Here let me ask a different question.

how do sprites work? if I use "sprite" will it create a new entry that will live for the remainder of the program. or will it only exist for the call. Like how a local variable only lives once inside a function?

I ask because I don't know how many sprites/images I'll need. the user might select only 2 units, but the user might select his whole army as well, and with dark imposters I plan to add a high unit cap.
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 5th Mar 2013 00:40
I decide to go with sprites. since they don't copy the image. I also added code that would remove a units selected sprite when it is not selected anymore.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 5th Mar 2013 00:42
Quote: "how do sprites work? if I use "sprite" will it create a new entry that will live for the remainder of the program. or will it only exist for the call. Like how a local variable only lives once inside a function?

I ask because I don't know how many sprites/images I'll need. the user might select only 2 units, but the user might select his whole army as well, and with dark imposters I plan to add a high unit cap. "


Hands On DarkBASIC Pro

I think I suggested this before...

Check for TDKs tutorials, but I never used those... HODBPro has everything I ever needed... for basic functions...

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2013 00:52
Did you set the transparency parameter on the paste image command?

paste image imgNo, x, y, 1

"You're all wrong. You're all idiots." ~Fluffy Rabbit
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 5th Mar 2013 01:10
Quote: "Did you set the transparency parameter on the paste image command?

paste image imgNo, x, y, 1"


I did now >.<

Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 5th Mar 2013 16:32
... Well I feel so stupid. I could have sworn Paste Image did not have that property... Thanks.

well. Time to put a paper bag over my head.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Mar 2013 17:33
Quote: "how do sprites work? if I use "sprite" will it create a new entry that will live for the remainder of the program. or will it only exist for the call."

Yeah, they're a bit peculiar in that you re-issue the sprite command whenever you want to move them or change their image. The sprite does exist until you invoke delete sprite onto it however, so it is no different than the other resources you have in DBPro


"Why do programmers get Halloween and Christmas mixed up?"
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 6th Mar 2013 17:23 Edited at: 6th Mar 2013 18:24
Also, if you don't want to create a new sprite every time a unit is selected, you can use paste sprite instead which works just as paste image does but also allows you to take advantage of the typical sprite functionalitites such as scaling, fading and resizing.

Login to post a reply

Server time is: 2026-07-07 04:32:40
Your offset time is: 2026-07-07 04:32:40