Skip to main content
gamedev.net
🔒 Locked

Collision, and entity problem .

Started by Ey-Lord 1 reply 1.5k views
Original Post
Ey-Lord
Ey-Lord
Hello guys :) Yeah another collision problem :/ I'm writing a small document, before starting to code somehintg, where i'm checking if i can handle some easy things . For exemple , if i can know what to draw on the screen, or if my enetites will be able to interact with each other, or if my input will be recived by the correct entities ect ... So far, i've run into one problem . I'm making a 2D rpg tile-based, i want movement to be per pixel and not per tile . That raise the problem of collision data . What is the best way to store this ? ( i want something easy to make ( for each tile ) and fast to parse when i will be checking if any entities has collide with something else ). Also, the per/pixel thing gave me another problem . Let's say i got a pnj somewhere on the map, and the door near him, if the npj send a "action" request, how will i know if he is near the door, so he will open it, or if another pnj has came in front of him and the door, so in taht case, my first pnj will just "talk" or something with the 2nd pnj . ( i think it will heavily rely on the way i will store collision data ) Thx by advance . EDIT : Ok let's reconsider the problem . A few info on my game : - I use tile for the really basic terrain ( sand, grass, floor, and wall maybe ) . I wont use anything like small tile for montain or so, as there wont be a "world map" on my game. - Every other object will be considered as a unique entitie (a door,a house from outside, a carpet, a monster, a npc, a plyer ect ... ) I use 32*32 tile, but in memory each tile is divided into 4 16*16 tile . So i think i will just assign a number a this small tile, to make the collision ( easier than real pixel-perfect thing ). But i dont see how i will do for entities, i really need per-pixel movement and collision ( its for a A-RPG ). Should i build a array ( 1 number for exery pixel of the texture ) and use taht for collision ? If i do taht i see one problem . For exemple, the texture of a monster . Part of it will be some alpha channel, so easily set to "free" in the array, but then i must have an aera for the "leg" or whatever, for collision detection with other entities , and other part will be something " hitable", for exemple an arrow should be able to hit it . But how can i do taht ? it seems boring to do for every monster, and memory/time-consuming, isnt it? I think i'm lost somewhere :p [Edited by - Ey-Lord on December 21, 2005 10:33:25 AM]
Ey-Lord
Ey-Lord
Thx for your answer .

Bascily, you described a "mix" approch of the problem
- per-tile for terrain & non-moving object
- per-pixel for moving sprite

I see some problem with that ( maybe i'm wrong ... ):

The only easy solution would be a colision map with 2 value possible ( in this case the alpha channel seems to fit for the job ) .
But for monster for exemple, if thius method gives an accurate collision method ( with arrow, spell ect ... ) i dont see how i can perform entity-entity collision or entity-ground collision , because, for the monster ( or any npc ), only the feet will actually be on the ground, not the whole srpite . And the whole part with is condiering arrow-collidable , but walkable, must also be draw b4 the part of another entity who might be just " behind" this one (for exemple, a big monster, and a samll pnj, sitting right next, i MUST draw the monster first, and even if the pnj is in the same tiles as the monster, theiir "feet" are on different tiles )

Hum again i need to think this a bit more, i'll come back later with something clearer ;)
thx

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.