How to handle entities ?
Hello everyone, i'm currently at the point where i will start to code those things ... and i'm really lost .
I'm doing a 2D a-rpg ( ~SoM ), tile-based
Let me exeplain what i got, and i what i want :
- Every item/object/entities ( or whatever you call that ) is loaded from some easy .xml files . Each item is stored in a singleton manager ( cRessourceManager ); each item has an ID ; some have a Unique Id, it means that there can be only ONE item loaded at time with this ID, if the programs try to load an item with a unique ID and if the ID is spoted in the manager, the new item will replace the old one . On the other hand, lots of item has semi-unique ID ( unique id + a number ; BigSkeletton01, BigSkeleton02 ect ...)
Each item know his own ID .
Every item that have a method draw() and update() is stored is annother vector , and those 2 method are called every frame .
Till now, i just had item like "button", or some "image" , nothing really related to an RPG .
My problem is, i dont know if the way im storing all that will be ok efficient collision detection and the more important, if my item will be able to "communicate" proprely with each-other
Some ex :
If the play shot an arrow , i want to be able to find the first obstacle in the way, and then, link the arrow , the shooter, and the obstacle together to be able to perfom the damage calculation .
If you got any idea, advise, tips ect...i'm here ^^
With the way you are storing your data, you could
make the arrow know who fires it (the arrows owner)
move the arrow to its next position
check all other entities if they are also in this position
calculate damage using this entity, arrow and arrows owner
Or a quicker way to do this is to store each entity position in another layer of your map. When the arrow moves to its new position it only needs to check which entity is associated with this tile.
make the arrow know who fires it (the arrows owner)
move the arrow to its next position
check all other entities if they are also in this position
calculate damage using this entity, arrow and arrows owner
Or a quicker way to do this is to store each entity position in another layer of your map. When the arrow moves to its new position it only needs to check which entity is associated with this tile.
Ok, so basically i stored a pointeur of every entities that can be collide ( typo.?) in an array of my map, and then i can chek what's goign on every frame .
Hum u said a "quicker way", i'm gonna mouvement and collision per pixel ( not per tile ), so yeah, ur idea seems quite nice !
I can first label all tile where there is something collidable on, and then , if the arrow ( for example ), move trought a tile previously labeled, i can do a per pixel check ..
Thx
Hum u said a "quicker way", i'm gonna mouvement and collision per pixel ( not per tile ), so yeah, ur idea seems quite nice !
I can first label all tile where there is something collidable on, and then , if the arrow ( for example ), move trought a tile previously labeled, i can do a per pixel check ..
Thx
If the RPG world gets large u will get problems, you need to clip the world to the current room.
So you need a type of division tree in your world, and then by traversing down the tree the game only needs to load the objects required for this Room/Divided world that way its only 10 items to check for a basic collision in the first place instead of 100 000.
It gets worse when you want to make an RTS game with this type of system since there isnt any definite crossing points or rooms!
So you need a type of division tree in your world, and then by traversing down the tree the game only needs to load the objects required for this Room/Divided world that way its only 10 items to check for a basic collision in the first place instead of 100 000.
It gets worse when you want to make an RTS game with this type of system since there isnt any definite crossing points or rooms!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement