Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 29
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: Sprite Array  (Read 2162 times)

0 Members and 1 Guest are viewing this topic.

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Sprite Array
« on: May 16, 2011, 12:08:39 am »
In case anyone is interested in playing with it, I just opened up the sprite array to script access. We have always had the ability to get an entity's current sprite, but now we can select a specific animation and frame. Moreover, this gives us access to the other sprite properties, the biggest probably being current offset.

Aside from helping to get rid of a lot of "load sprite" calls (why bother when you can now use dummy animations as an engine managed sprite cache), this should really help with debugging and specialized graphic effects. I have tested all the get calls, but not changing. Let me know if you find any issues (except file name... I seriously doubt a change attempt will do anything but crash the engine, I just included it for posterity. No need to mention if it doesn't work.)

 ;)

DC

« Last Edit: May 16, 2011, 12:11:08 am by Damon Caskey »
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: Sprite Array
« Reply #1 on: May 16, 2011, 01:14:08 am »
Great.
No doubt this is an exciting feature.
But tell you the truth I really want the feature drawing a part of a sprite,
something like drawspritea(sprite,x,y,width,height)



Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: Sprite Array
« Reply #2 on: May 16, 2011, 01:29:02 am »
That is sprite clipping, which is very complex to do.
Take a look at sprite.c and you'll see a lot of duplicate functions (nearly 2000 lines) are there to serve the clipping purpose.

However, if you don't mind the performance, there's a workaround. You can create a smaller screen, draw your sprite on the screen and then draw the screen.



Edit*

If any developer wants to change the sprite clipping code, I suggest to add a clipping area to the screen, instead of the sprite itself.


For example:

set_clip_area(screen, 50, 50, 120, 120);

Then any draw action to the screen will be limited in this area, until it is cleared.

However, there'll involve a lot of changes in the draw/sprite code.
« Last Edit: May 16, 2011, 01:43:04 am by utunnels »

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Sprite Array
« Reply #3 on: May 16, 2011, 07:17:14 am »
Sounds interesting. Nothing at the moment that I need that might use this but will look into it and see what the imagination can conjure up with this  :steamroller:

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Sprite Array
« Reply #4 on: May 16, 2011, 08:04:43 am »
Here is one use: Showing all on screen enemy life bars and icons instead of just the one you're fighting. You could do this already by getting handles from the default icons, and up until now that is exactly how I made it work. The problem came when you wanted to make playable alternates of these characters using the same model sheets while also displaying unique "player" icons. It got real messy real quick hacking up a work around. Now you just put the icons in an animation frame, pull them, draw them, and done.



It would also be useful for pretty much any kind of direct draw sprites you want to use. Currently when you use the loadsprite() command, the sprite is loaded and it never goes away; there is no "unload" capability. To add insult to injury, the engine even berates you in the log about it. Now, you can get those sprites from a model, and let the engine worry about managing them.

The offset thing is another big help. I'd be here all day listing the uses for that. Just having read access alone is going to eliminate a ton of code from my work.

DC
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Sprite Array
« Reply #5 on: May 16, 2011, 08:15:29 am »
Impressive :wow!:

Any chance of adding a feature to access a array list of enemies via script?

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Sprite Array
« Reply #6 on: May 16, 2011, 08:50:01 am »
There is no such thing as an enemy array, so no. But in prinicipal what you are asking for is easy to do. Otherwise how could I have displayed enemy icons?

Just enumerate the entity collection and then evaluate to filter out what you do/don't want:

Code: [Select]
void main()
{
    void    vEnt;                                                                           //Entity placeholder.
    int     iType;                                                                          //Entity type.
    int     iValid;                                                                         //Entity valid.
    int     iDead;                                                                          //Entity death status.
    int     iECnt;                                                                          //Current # of entities in play.
int     iEnt;                                                                           //Entity counter.
 
    iECnt   = openborvariant("ent_max");                                                    //Get current entity count.
 
for(iEnt=0; iEnt<iECnt; iEnt++)                                                         //Loop entity collection.
{
vEnt    = getentity(iEnt);                                                          //Get entity handle.
       
        if(vEnt)                                                                            //Valid handle?
        {
            iValid  = getentityproperty(vEnt, "exists");                                    //Get exists confirmation.
            iDead   = getentityproperty(vEnt, "dead");                                      //Get death status.
            iType   = getentityproperty(vEnt, "type");                                      //Get type.
       
            if(vEnt                                                                         //Valid handle?
                && iValid                                                                   //Valid entity?
                && !iDead                                                                   //Alive?                                           
                && iType == openborconstant("TYPE_ENEMY"))                                  //Enemy type?
            {
                //Do some stuff.
            }
        }
}
}

DC








OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Sprite Array
« Reply #7 on: May 16, 2011, 10:41:32 am »
Didn't know about openborvariant("ent_max"), knew about openborvariant("count_enemies"); which for obvious reasons wouldn't work as needed.

Thanx!
 :peace:

 



 0%




mighty
SimplePortal 2.3.3 © 2008-2010, SimplePortal