NOGDUS $1670.00 has been donated to NOGDUS!
June 23, 2017, 08:47:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 2 [3]   Go Down
  Print  
Author Topic: Setting a transparent color in Pixie  (Read 12380 times)
0 Members and 1 Guest are viewing this topic.
Cycl0ne
Guest
« Reply #30 on: April 24, 2011, 12:52:49 PM »

Does this make sense at all, or am I missing something here?

Hey Mattias, IT WORKS great ! :-) I put up switch() statement with 9 levels of light (from 0xffffff to 0x000000) and it REALY works charming ;-)


Logged
Mattias Gustavsson
Moderator
Offline Offline

Respect: 58
« Reply #31 on: April 24, 2011, 01:15:44 PM »

That's great to hear Cheesy And if you're able to use RLE8 for the art, then it will be most efficient - but even if you can't, I think it should be alright.

Btw, speaking of switch statements to map values, I'm a big fan of using arrays for that instead... so instead of something like:
Code:
switch ( level )
{
    case 0: value = 0x000000;
    case 1: value = 0x1C1C1C;
    case 2: value = 0x383838;
    case 3: value = 0x545454;
    case 4: value = 0x707070;
    case 5: value = 0x8C8C8C;
    case 6: value = 0xA8A8A8;
    case 7: value = 0xC4C4C4;
    case 8: value = 0xE0E0E0;
    case 9: value = 0xFCFCFC;
}


or similar, I will instead do:
Code:
unsigned int valueMap[] = { 0x000000,0x1C1C1C,0x383838,0x545454,0x707070,0x8C8C8C,0xA8A8A8,0xC4C4C4,0xE0E0E0,0xFCFCFC, );

Assert( level < sizeof(valueMap)/sizeof(valueMap[0]) );
value = valueMap[ level ];

Which I think is both easier to read, and can actually give better performance, depending on the compiler Cheesy
Logged
Cycl0ne
Guest
« Reply #32 on: April 24, 2011, 01:30:51 PM »

Yes, this is a really cool idea and i even have another one Smiley

one could take the unsigned short as a array, so the color hasnt to be constantly recalculated? :-P
Logged
Mattias Gustavsson
Moderator
Offline Offline

Respect: 58
« Reply #33 on: April 24, 2011, 01:33:21 PM »

Yeah, that would work even better Cheesy
Logged
Cycl0ne
Guest
« Reply #34 on: April 24, 2011, 01:45:32 PM »

That's great to hear Cheesy And if you're able to use RLE8 for the art, then it will be most efficient - but even if you can't, I think it should be alright.

Yes I promise i will use RLE8 as soon as all graphics are finished Smiley until then i stick to PNG ;-) And i promise, i will put all stuff into the Archive, which will be the new Archive that is ZLib compressed ;-)

hmm another thought of me:
can i create lots of sprites, all using the same bitmap?
Logged
Mattias Gustavsson
Moderator
Offline Offline

Respect: 58
« Reply #35 on: April 24, 2011, 01:53:33 PM »

Do you mean doing this?
Code:
mySprite.SetBitmap("myBitmap.pix");
anotherSprite.SetBitmap("myBitmap.pix");

Then yes, absolutely - both sprites will reference the same Resource_Bitmap, and when both sprites have been destroyed (or set to a different bitmap), then the bitmap resource will be freed.

Btw, it is a good idea to call:
Code:
siResourceManager->LoadBitmapStrip("myBitmap.pix");
for all bitmaps you're using in, say, a level before the level starts - otherwise you might get a lot of loading/unloading of resources while the game is running. Calling the Load functions on the resourcemanager makes sure that resources stay in memory until you call
Code:
siResourceManager->UnloadBitmapStrip("myBitmap.pix");
Note though, that if there's still a sprite which uses the bitmap, it will still not get unloaded until that sprites gets removed or has its bitmap changed. Resources are reference counted.
Logged
Cycl0ne
Guest
« Reply #36 on: April 24, 2011, 03:41:05 PM »

Ok,

im designing the renderengine. And now comes up the next question:
i like it to fix sprites to a coordinate and just switch them on and off.. Do you think it is a performance issue if i got 4000 sprites where 3980 are FALSE in visibility?
Logged
Mattias Gustavsson
Moderator
Offline Offline

Respect: 58
« Reply #37 on: April 24, 2011, 04:01:57 PM »

No, I think that would be fine - it would just be looping through 4000 entries in a contiguous array, and doing a comparison on each - that's stuff  which modern computers are really fast at.

But IF you would later find that it is too slow, there's a couple of options you could do... One alternative is to use multiple sprite managers, and assign sprites to different ones, and then toggle entire managers on/off (look at SpriteSystem.h/cpp for setting up multiple sprite managers).

Another, and maybe better, option, is to call SpriteManager::RemoveSprite and SpriteManager::AddSprite, to change visibility for your sprites - and keep a separate list of all the sprites you have. That way, the spritemanager would not have to care about sprites which aren't visible.
Logged
Cycl0ne
Guest
« Reply #38 on: April 25, 2011, 01:08:18 PM »

Ok another design question. you know the game.
how would you store the asset of the game? You got Wall Ornates and Floor Ornates and Items. Would you store everything in a big array and traverse it everytime the player moves? or would you split it into level arrays? or would you split it to every place the player could be?

Im thinking of a big level array where i will look into it, if the player has something in sight or the player activated something. What do you think?

Oh here is a demo of the wall render engine:
http://dl.dropbox.com/u/5037811/Test.rar

You can walk with cursor keys. (no turning at the moment).  And you can switch the light by pressing X and C.. (from 8 to 0 and back).

Oh and no collision detection. if you move out of map, you will allways see walls ;-)
Logged
Tags:
Pages: 1 2 [3]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!