Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » 2d RPG type games

This thread is locked; no one can reply to it. rss feed Print
 1   2 
2d RPG type games
piccolo
Member #3,163
January 2003
avatar

hmm for object that don't move like trees and houses i put the bottom part on the lower layer then the top on the layer above it. like so.

http://www.allegro.cc/depot/screenshots/3138_large.jpg layer 2

http://www.allegro.cc/depot/screenshots/3139_large.jpg layer 3

this way you can put you none passable zones and the base of the house or tree. when you do this it make the object appear 3D because the top part of the object will be draw after the player object so it will look like the player is be hide the tree.

wow
-------------------------------
i am who you are not am i

Rick
Member #3,572
June 2003
avatar

That's find if you characters are smaller than a few tiles. If one of your characters is 4 tiles tall and stands in front of your house, the top part will be drawn over him breaking the illusion. That is why I'm thinking of just giving all objects collision rectangles.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

piccolo
Member #3,163
January 2003
avatar

thats not a problem ether. what you do is break your characters in to parts draw the parts on different layers. i am also working on a characters editor the works with characters parts. that is also for my MMrpg and is located in the depot.

wow
-------------------------------
i am who you are not am i

Rick
Member #3,572
June 2003
avatar

Wow, I guess I didn't think about putting characters on different layers. That seems like it would be a pain. I'll stick with just making collision rectangles and check against those.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

23yrold3yrold
Member #1,134
March 2001
avatar

I just sort my game objects by y coordinate and draw top down. :P

My big sticking point (and I have an idea for this that suits my engine, but it merits discussion here and I haven't seen it brought up) is brideges and things you can walk iver/under. Fenix Blade, as well as quite a few of the old SNES RPG's, can do this and it's very effective both in terms of looking cool and possibly making map layouts a bit more efficient.

Attached a quick montage for visual reference:

{"name":"590613","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a698b3e99672e36c106cf99a6cce39ec.png","w":600,"h":140,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a698b3e99672e36c106cf99a6cce39ec"}590613

Ideas on how to do that?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

OICW
Member #4,069
November 2003
avatar

Maybe putting those bridges onto different layer. Or even better idea: having separate layers for each ground level - only problem is with travelling between them.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

Or even better idea: having separate layers for each ground level - only problem is with travelling between them.

This is my thinking, yes.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

piccolo
Member #3,163
January 2003
avatar

there should not be a problem this is how my games works.

edit

1void CharacterList::draw(BITMAP* bmp,int lay,View v )
2{
3 
4for( int i = 0; i < numItems; i++ )
5 {
6 if (characterList<i>->CharacterObject.Get_layer()== lay)
7 {
8
9 characterList<i>->CharacterObject.do_moveing();
10 characterList<i>->CharacterObject.animate();
11 characterList<i>->CharacterObject.draw(bmp,v);
12 characterList<i>->CharacterObject.showname(bmp,v);
13 characterList<i>->CharacterObject.showlife(bmp,v);
14 characterList<i>->CharacterObject.talk(bmp,v);
15 }
16
17 }
18 
19 
20 
21}

that is the same as
drawlayer(1);
drawplayer();//if player on this layer
drawlayer(2);
drawplayer();//if player on this layer
drawlayer(3);
drawplayer();//if player on this layer
drawlayer(4);

wow
-------------------------------
i am who you are not am i

Onewing
Member #6,152
August 2005
avatar

I'm just going to babble here, but maybe it's some food for thought.

Why not have infinite layers? In fact, represent layers with Z (as in X,Y,Z). Each tile stores an X,Y and Z variable as well as b,t,l,r variable (bottom, top, left, right). Now, in your map editor, at any time you can pick which layer (Z) you are adding to. So you could have grass at Z=0 and Z=10 (where 0 would be lower depth-wise than grass at 10). Next, you set the b,t,l,r variables, which determine if you can pass the position of the tile. Alternatively, you could just use BB, but even with b,t,l,r I don't see why this would anger free movement (although it might get a little finicky at the edges).

Now here's the kicker: our player is at layer z. That's z, not Z. Meaning, the player is not on a static layer, but his layer actually changes. Say for example you go through a door, well the door has as underlying code that sets the player's z to its Z variable. Thus, in 23's picture (the far left one) above with the bridge and the door, say when you exit that door your now on Z=20 so z = 20. But, before z = 0, so you'd be below the bridge. There's still a bit of confusion in the collision, but maybe it's an idea. :)

[edit]
In the end, you'll have to sort your tiles from Z=0 to Z=highest in some kind of structure and then draw them going through your sorted list with the method above.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

Elverion
Member #6,239
September 2005
avatar

23yrold3yrold, the second image is from Secret of Evermore (during the Prehistoria chapter), and the third from Final Fantasy 3? I'm not so sure about the first one. But yes, I would say that the best way to do that would be to put the ground over multiple layers, and move the character up or down layers when they come in contact with things like stairs or ladders. Stairs could be done by having invisible collision points at both top and bottom of the stair sprite. If the character is on layer 1, and hits the collision point at the top of the stairs, move him to layer 2. Just the opposite, if he hits the bottom of the stairs while on layer 2, move him to layer 1.

Walking over/under the bridge would be pretty easy to do, I think. On the layer that you would walk under the bridge, you do not place 'blocking' tiles, and your depth is greater than the tiles above, so you appear under it with no problem. On the above layer, though, you should place invisible non-walkable tiles at the sides of the bridge to prevent the character from walking into nothingness. Again, your depth would be less now that you are up a layer, so you would appear above it.

--
SolarStrike Software - MicroMacro home - Automation software.

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

23yrold3yrold, the second image is from Secret of Evermore (during the Prehistoria chapter), and the third from Final Fantasy 3? I'm not so sure about the first one.

Final Fantasy IV.

And Onewing/Elverion pretty much suggested it the way I'd do it. Everything in my game is an object, sorted by z for layer and then y for objects on the same layer that overlap. Tiles would have triggers moving objects between layers as they pass over them. I don't know if that's how the old classics did it, but it's my way.

Now, how to draw transparent water over the player's lower legs when he's walking in liquid. Another trick some old classics (and Fenix Blade) did .... and one that still stumps me a bit.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

OICW
Member #4,069
November 2003
avatar

Quote:

Now, how to draw transparent water over the player's lower legs when he's walking in liquid. Another trick some old classics (and Fenix Blade) did .... and one that still stumps me a bit.

Funny, I was just thinking about that too when I began reading your post. I think that it's the same as walking in the high grass (another Fenix Blade feature): you just draw seafloor, then begin drawing of translucent water tiles and when it comes to player you draw him and then again the water tiles. Which will end in half of the body (legs) covered by water. Just add some nifty effect of ripples around player and you got it.

Where is Sirocco? He could help...

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Onewing
Member #6,152
August 2005
avatar

Quote:

you just draw seafloor, then begin drawing of translucent water tiles and when it comes to player you draw him and then again the water tiles.

I don't know, that sounds like over-complicating things. I've got two ideas:

1) The FFIV way (or some rpg game...). When over a forest tile, the lower half of the body turns translucent. This could just be code inside the player object, in which when the player is on certain tiles, the lower half is draw translucently (that shouldn't be too difficult to do) on top of the forest tile. Thus, when on a water tile, the player code knows to draw the bottom half translucently. Now, we still have the problem of the ripple effect. This is a special function in the tile object that basically is run when the player is moving on top of a water tile. This special function draws the ripple before the player is drawn, so the solid part of the player is drawn over the ripple, while the translucent part appears below the ripple, creating some sort of depth.

2) I scratched this idea as I was writing it. :-X

------------
Solo-Games.org | My Tech Blog: The Digital Helm

piccolo
Member #3,163
January 2003
avatar

my game can do this as well. what i do is. my player is made up of parts so using my above post code i draw all parts of the play where they need to go. in this case :
ground layer 1 player feet or bottom half layer 1 translucent water layer 2 player top half layer 2. in that order.

wow
-------------------------------
i am who you are not am i

Rick
Member #3,572
June 2003
avatar

Since I started this thread I'm using it for transfer of text. Feel free to ignore the following.

1bool collide(Object* a, Object* b)
2{
3 Rect aRect, bRect;
4 
5 //get the actual location of the collision rect. This means the offset collision rect is added to the objects location
6 aRect = a->getCollisionRect();
7 bRect = b->getCollisionRect();
8 
9 if(aRect->Left > bRect->Right) return false;
10 if(aRect->Right < bRect->Left) return false;
11 if(aRect->Top > bRect->Bottom) return false;
12 if(aRect->Bottom < bRect->Top) return false;
13 
14 return true;
15}
16 
17Rect getIntersectingRect(Object* a, Object* b)
18{
19 Rect aRect, bRect, result;
20 
21 aRect = a->getCollisionRect();//returns the actual location (adds x & y to colision rect)
22 bRect = b->getCollisionRect();
23 
24 result.Left = max(aRect.Left, bRect.Left);
25 result.Top = max(aRect.Top, bRect.Top);
26 result.Right = min(aRect.Right, bRect.Right);
27 result.Bottom = min(aRect.Bottom, bRect.Bottom);
28}
29 
30 
31 
32void checkCollision()
33{
34 Iter innerIter, outerIter;
35 Rect overlap;
36 Object* pushBackObj;
37 
38 for(outerIter=object.being()..)
39 {
40 for(innerIter=innerIter++;)
41 {
42 //persons to persons don't collide, only persons to non persons can collide
43 if(!(*outerIter)->isPerson() || !(*innerIter)->isPerson())
44 {
45 if(collide((*outerIter), (*innerIter)))
46 {
47 overlap = getIntersetingRect((*outerIter), (*innerIter));
48 
49 //we now know the overlapping rectangle.
50 //find which one is the person and based on direction they were going adjust their
51 //position to snug up against the static object they hit
52 if((*outerIter)->isPerson())
53 pushBackObj = (*outerIter);
54 else
55 pushBackObj = (*innerIter);
56 
57 //pushBackObj needs to be adjusted by the overlapping rect
58 //depending on the direction it was going
59 switch(pushBackObj->getDirection)
60 {
61 case NORTH:
62 //take the height of the overlapping rect and subtract that from the objects y location
63 pushBackObj->adjustY(-(overlap.bottom - overlap.top))
64 break;
65 case SOUTH:
66 pushBackObj->adjustY((overlap.bottom - overlap.top))
67 break;
68 case EAST:
69 pushBackObj->adjustX((overlap.right - overlap.left))
70 break;
71 cast WEST:
72 pushBackObj->adjustX(-(overlap.right - overlap.left))
73 break;
74 }
75 }
76 }
77 }
78 }
79}
80 
81 
82 
83if(key[KEY_W] && !moveNorth)
84{
85 player->setDirection(NORTH); //sets the direction vector of the player
86 player->setState(MOVE);
87 
88 moveNorth = true;
89}
90else
91{
92 player->setState(ILDE);
93 
94 moveNorth = false;
95}
96 
97qezc=diangle movement??
98 
99 
100 
101void logic()
102{
103 for(objects)
104 {
105 if(object->getState() == MOVE)
106 {
107 //move the object
108 object->move(); //performs the actual vector movement code
109 }
110 }
111 
112 
113 //after everything has moved check collisions that might move things back a few pixels
114 checkCollision();
115}

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

Thus, when on a water tile, the player code knows to draw the bottom half translucently.

But now not only is the water showing over the legs, so is the seafloor. :) I think OICW was onto something there; draw sea floor tiles, draw player or other objects, draw water, draw ripples (if any). Then specially draw the player again, but filter out the part of the sprite that's underwater so only the top half is drawn and it looks like his lower half is submerged. That actually seems a pretty good idea ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

I'd just draw the normal water tile, then the player, then a translucent special water tile with ripples ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

2d-forever
Member #8,051
November 2006

OK, I'm not much into this (I'm just the artsitic friend of the one who plans on making the game ^^ ).

Anyway, you mention the problem of
A) walking in front of and behind textures, not into them.
B) walking in grasslands etc.

A)
Why don't you just make your character AND some kind of indication of the feets. This way, it's not the question if the character collides with the basis of a building. The character is forced to stop when the indicator (feets) hit the basis. Combined with the house in two layers, the character will be able to walk up to the wall, but no further!

B)
If you are using .gif-files anyway, why don't just place a new .gif making the illusion of high grass moving. If this is placed over the character, it would look as if the character were moving, not the layer over him/her.

Richard Phipps
Member #1,632
November 2001
avatar

Rick
Member #3,572
June 2003
avatar

I would think the "foreground" layer could handle walking in water or high grass. That's pretty much what Thomas is saying.

I was put a collision rect around what would be the base of objects. Then do simple BB collison checks. It seems to be working well.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

OICW
Member #4,069
November 2003
avatar

Oh by the way Rick: I thought that you're working on that isometric board game.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Rick
Member #3,572
June 2003
avatar

I was but I have drawing technical issues that always get in the way, harder than these top down, and it takes away from programming the gameplay, which is what I enjoy more.

========================================================
Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

OICW
Member #4,069
November 2003
avatar

Hehe, me too, me too. That's why I abandoned the idea of isometric engine.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

23yrold3yrold
Member #1,134
March 2001
avatar

If I were going to go isometric nowadays, I'd just use a 3D grid and camera angle like Final Fantasy Tactics. :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

OICW
Member #4,069
November 2003
avatar

Yeah, I'm thinking that if I'm going to make RTS or RPG I'd go for normal tiles or switch to complete 3d.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

 1   2 


Go to: