|
|
This thread is locked; no one can reply to it.
|
1
2
|
| 2d RPG type games |
|
Rick
Member #3,572
June 2003
|
How to games like the below: handle collision? My thought was that objects (but not characters) are bound to the grid with a passable/not passable flag. These games, like this one, often simulate depth. If you look at the 2 people standing by the buildings you can see their heads are "on" the building. How do they handle this? Do you just give characters a collision rectangle around their feet and do a BB collision check with their feet rectangle against actual grid squares that these non passable objects are on? Then draw non character objects first, then characters so they are drawn overlapping these objects? I'm just thinking there is a standard way of making a game like the above and I'm curious of what it is. ======================================================== |
|
LennyLen
Member #5,313
December 2004
|
From what I've played of games like that, I doubt they even do bounding box collision, but just don't allow movement at all into such tiles. As to the drawing, imagine that he screen is horizontal and you are at the bottom (front). Once you've drawn your background tiles, draw any objects from the back first.
|
|
Rick
Member #3,572
June 2003
|
The above game doesn't seem to move characters from tile to tile. It seems to have free movement, so some sort of checking would need to be done to see if a character can move on a tile? If it's free movement and doesn't use BB collision, how else would you do that? ======================================================== |
|
X-G
Member #856
December 2000
|
Uh, what exactly is the problem? Throw a bounding box that only partially covers the sprite (like around the feet) and go to town, sorting sprites by depth before you draw them? -- |
|
Rick
Member #3,572
June 2003
|
There is no problem, I was just curious on how these games handle collision. Quote: Throw a bounding box that only partially covers the sprite (like around the feet) and go to town, sorting sprites by depth before you draw them? Depth being the top of the sprite or the BB of the sprite, or another given variable about the sprite? In this game you can walk "behind" the top of the building giving it more of a "depth". Am I right to assume the building is bound to the map grid and made up of smaller squares. If so do you BB each of those squares or do you make a big BB around the entire building. I'm just curious on how these things are done, and how others would do them. ======================================================== |
|
CursedTyrant
Member #7,080
April 2006
|
It can be done like this: It should work fine, I remember doing something like this in one of my games. Of course it could be wrong, I didn't test it and I am a bit tired. Of course it would vary depending on the pivot point of your tiles, so you'd have to adjust a few things. EDIT: Not entirely sure if it's even on-topic... need more sleep. --------- |
|
X-G
Member #856
December 2000
|
You just make certain tiles unwalkable, and make certain tiles always overlap NPCs; yes, you cheat. Assuming the base of your buildings are wide enough no one will ever notice. -- |
|
Rick
Member #3,572
June 2003
|
So if you are doing free movement of characters (they aren't tied to any tile), do you do BB collision between the characters BB and actual tile areas? I would think after you place your building tiles down, making 1 big rect the BB on that building would speed things up, since now you have 1 check (player BB vs building BB) as opposed to the player BB vs each tile the building is made up of. Does that seem logical or would it not make a difference really? ======================================================== |
|
X-G
Member #856
December 2000
|
With actual tile areas. It's really not as slow as you might think, since at most you need to check four tiles for walkability (assuming the player's bounding box is smaller than one tile), which cuts down the time you need to spend drastically. -- |
|
OICW
Member #4,069
November 2003
|
You may look at AGDN on the tutorials, there is nice tutorial where he makes engine like that you posted screenie. There's some sort of free movement. [My website][CppReference][Pixelate][Allegators worldwide][Who's online] |
|
Paul whoknows
Member #5,081
September 2004
|
A few boxes are enough. {"name":"590582","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/6576b097f2a239ecbe1e2755e0492529.png","w":320,"h":240,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/5\/6576b097f2a239ecbe1e2755e0492529"} ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
|
KnightWhoSaysNi
Member #7,339
June 2006
|
I am working on the somewhat of the same thing. What I am trying to do is sort of like what Paul whoknows posted. I have 6 tile layers: 3 ground (below sprites grass, dirt, etc), 2 sky (above sprites tree branches, bridges) and 1 collision. The collision layer is invisible in the game but not in the editor. I have a seperate tile sheet with different shapes and sizes: boxes, rectangles, circles all colored yellow. They are drawn onto the map just like an other tile but in the collision layer. I have not implemented the collision yet because I have not learned about pixel perfect collision only bounding boxes plus I haven't made the game I have only made the editor. The collision tile layer is updated and moved just like the other layers. Instead of drawing it to the screen I am going to draw it to a seperate bitmap and check collison from there. |
|
Mordredd
Member #5,291
December 2004
|
See, there are many people working on similar projects. Anyways, the result is half an engine instead of a complete game. I recommend you to fuse to a single developer team. That is what I think will lead you you to success. Btw, I love pixelling 2d tiles. In case there will be a group of at least three programmers (and thus a real chance to get such a game finished), I`d love to help out.
|
|
Simon Parzer
Member #3,330
March 2003
|
My tile engine works with collision detection. Every tile has a flag "walkable". If it's false the player can't step on it. I have some sort of a movement queue implemented, so it only checks the tile you would be walking over next. And yes, the player doesn't "jump" from tile to tile, he really "walks". With animation and everything. I can share the code and/or a small techdemo if anyone cares. @Micah: Two people are slower than one person. Three people are slower than two people. At least when it comes to conception and planning, which is the foundation of making a game. I'd rather have half an engine or a poor game than nothing at all. |
|
Elverion
Member #6,239
September 2005
|
I've played around with these sorts of things plenty a long time ago, and I found the simplest method was to have the map be just a grid of walkable/non-walkable tiles as you have stated, and the character represented by x,y coordinates rather than a bounding box. When moving, just do something like this: if( key[KEY_UP] ) { if( is_free(x, y - MOVE_SPEED ) { do_animation(); y -= MOVE_SPEED; } } do other keys here. Where is_free(x, y) checks if the position is not in contact with a non-walkable tile or some sort of solid object(such as an NPC). If you want the character to move over full tiles rather than just a speed(or, "free movement" as someone called it), just use newx and newy variables and interpolate rather than changing the coordinates right away. And for handling depth, when the map is loaded, you should assign each tile a depth. depth = -(y); works very well. Movable objects should, of course, update their depth each time they are moved, and when drawing, the array needs to be sorted. Most of what I have said is probably stuff you already knew, but it reaffirms your thoughts that they can work rather well. I've had good experiences with them, at least. -- |
|
Ceagon Xylas
Member #5,495
February 2005
|
My two cents. Don't move your character and then check for collision, if collided then move them back. That can get buggy. //Not good method if(key[KEY_RIGHT]) { player.x++; if(collided(player.x,player.y)) player.x--; } Rather, check for the collision first, and permit passage if there's no collision. if(key[KEY_RIGHT]) { if(collided(player.x+1,player.y) player.x++; }
|
|
Mordredd
Member #5,291
December 2004
|
Of course, working in a group is different from working alone. It seems that people do not understand that 15 minutes of gameplay can't be called a game. On the inet everyone is a pro and working on his big deal, but in fact you`re not getting more than a crappy tileengine, which itself makes half an engine. When it comes down to splitting tasks you could supply even a team of ten hobbyist developers: Webdesign and Webmastering, Engine ( 2 programmers ), Scripting, Storywriting, Music, Music Handling, Graphics ( Ingame, GUI )... Engine writing should be modular, so you can split tasks again. You see: if programmer a let`s say is going to write on the rendering routines where programmer b works on the ai, there is no need for knowing each other personally. Often every programmer wants to do everything, so this will lead to chaos. But that is not my idea's weakness...
|
|
Simon Parzer
Member #3,330
March 2003
|
Quote: Engine writing should be modular, so you can split tasks again. You see: if programmer a let`s say is going to write on the rendering routines where programmer b works on the ai, there is no need for knowing each other personally. Often every programmer wants to do everything, so this will lead to chaos. But that is not my idea's weakness...
Ok, let's try it. Open a "new team project" thread and I'm in. I can supply working code for drawing routines and a tile engine. Furthermore I have several great game ideas, some really innovative stuff. I'm sure we'll find another programmer, then you do the graphics. Musicians and webmasters should be easy to find, too. About the "Engine writing should be modular": {"name":"590595","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/835938715af9625fe3deb744a3b70866.png","w":700,"h":300,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/3\/835938715af9625fe3deb744a3b70866"} |
|
Rick
Member #3,572
June 2003
|
Would it be valid to create depth for static objects vs moveable objects at the editor level? Like for a tree I can put it's branches and leafs on a foreground level, so when the player walks on it they always get drawn over the player. ======================================================== |
|
piccolo
Member #3,163
January 2003
|
it is valid and that is what i am doing in my game http://www.allegro.cc/depot/Thegame/. my game is what i came up with after i looked at the AGDN rpg tutorial. i will up data it now so you get fresh example. wow |
|
Elverion
Member #6,239
September 2005
|
As piccolo said, it is valid. In fact, many old RPGs done it this way. Typically, the depth of each tile is determined by which layer it is on. The problem arises with larger, movable sprites, though. Consider if, for example, a larger than normal creature of some sort were to walk in front of the tree. If part of its sprite is taler than the tile width, then he would appear in front of the tree stump, but underneath the tree's branches. To counteract this, I would suggest you still take Y position into consideration when calculating the depth value for your tiles. -- |
|
Rick
Member #3,572
June 2003
|
I didn't think about that Elverion. The problem is my tree is placed as x amount of separate tiles. To use the whole Y value sorting thing I would have to have the tree as one image it seems. ======================================================== |
|
Elverion
Member #6,239
September 2005
|
Ideally, yes. But you can also use the layer to find out the correct depth, and that should work with multiple tiles. depth = -( y + layer offset ) So, as long as you place the stumps at the base layer (which you should, because they would represent a non-walkable tile), and the branches a layer above that, I think that should work. This might be a bit more work than is necessary, so you might just use the simple method with layers. -- |
|
Rick
Member #3,572
June 2003
|
I think I'll just put all "objects" on the same layer and just sort by the y value of it's collision rectangle. ======================================================== |
|
Ceagon Xylas
Member #5,495
February 2005
|
You'll wind up putting layers in later |
|
|
1
2
|