Qbasicnews.com

Full Version: Rpg-engine layer problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
ok i'm posting this from my school without the sourcecode at hand so i can't be too clear, anyway you might be able to help me:

npcX(pc) = the player controlled character
npcY(pc) = the player controlled character
cameraX = npcX(pc) -160 'start position to render the tiles
cameraY = npcY(pc) - 100
npcX(n) = x-axis npc
npcY(n) = y-axis npc
map(40,40) = map data

ok this might look a bit vague but just a lil insight,

anyway the problem:
i've got 3 layers, the engine put the characters in front of all layer,
but it checks if the npcY(n) is on or one above a layer 3 tile.
Then the layer 3 tile is put above the character. The problem is how to calculate the position to put the layer 3 tiles above the character. Currently it correctly put it above the main character but thats because i made some routines which are dependent on cameraX and cameraY which is calculated from the npc(pc) axis values, but the tiles are moving falsly above the other npcs to the left and right when i walk with my character.

Anyway can someone help me with the right routines, (the engine is based on a pixel by pixel tutorial with that cameraX = playerX - 160)
Just separate it.

Either make a separate page for tiles and redraw when the character moves or redraw everything every time someone moves.

Basically what I'm saying is just draw layer1, layer2, layer3, and that's it.
Heh, k wans't clear enough. I'm already drawing 3 planes in 1 layer and that's working alright. The problem is because my sprites cover to tiles in height and that doens't co-operate well. anyway i'm working on it ;-) thnx anyway
What he means to say is - Everytime some thing on the screen changes do the following:

1. Clear the screen
2. Update all layers
3. Put Layer1
4. Put Layer2
5. Put Layer3
Big Grin yeah i understand that, i got a pretty advanced engine running like that. But i got a problem with calculating the proper screen position of the tiles from layer 3 which must be plot above the character. The problem is that the way i calculate now is dependen on the cameraX, cameraY, and that way depended on the main char while it must work with my other chars well too. my engine

1 put layer 1
2 put layer 2
3 put layer 3
4 put sprites(chars) (if char under layer 3 tile, plot tile above char)

it's working almost alright only if i walks it flips to the left, right, up and down of the char. I will post a demo ASAP.
thnx anyway
Some code might help me understand what exactly you are doing.
i know what he's doing. same thing i was doing awhile back. objects like chairs go under characters when the characters are below them, and over them when they are above them. so walking around a chair from bottom to top would put the chair from under him to over him. a pseudo-3d effect which i use in my project too.

Spearor, my engine has an editor which allows you to draw boundaries on each tile. you draw a rectangle on the tile, and the engine refers to the rectangle for both collision-detection and layering. if the pc is above y1, the tile is layered over him and he cannot move down further on it. if he is below y2, the tile is under him and he cannot move up.

to test a tile, when the player moves, cycle through the tiles onscreen and by calculating his position, you can test the tile he is about to walk on - you will test it's boundary field. (or no-go zone, i call it heh.)

hope that makes sense to you. i've found it a great way to kill two birds with one stone. :king:
Spearor: You have email? I have something you might wanna see.

Think: Crono Trigger and FF6. Yeah the main chars can run. ;*)
thnx guys, yeah toad that's the problem... i think i understand your solution, though not completely. You might wanna put up some code... This is from my school again so i haven't got the code with me but next time i will post it. And relsoft i like to see what you got, you can send it to (my gf's adress=)): liske_koet@hotmail.com

btw some specs in advance of my engine, it's my 1st serious project in any programming language and it's pretty ambitious too (like so many were ;-))
on a

AMD 2000+ : +/- 440 fps
P3 666 : +/- 230 fps

p*p movement, with 10 moving NPC's, Y-filtering like Toad mentioned, of course collusion(pixel collusion, so it's easy to walk on a 1 walkable tile between 2 unwalkable)i, capable of animated tiles and some basic script functions (talk, setplayerposition etc.)

so the basic kind of novice demo.
Anyway i post the code/demo soon...

thnx again for responses
sounds like you're having fun, Spearor. Smile

the way i do it is this. i have an editor that lets me scroll through the tiles that i have made. such as nature.put, where i keep all the trees, rocks, etc. after i pick a tile, i can draw a rectangle over it. i then specify what happens when the character is above or below either y1 or y2. when i save what i've done, the program writes all the tile info to a binary file, and the game engine reads that data and goes from there. but for starters you could try just doing it by hand to see how it works:

Code:
TYPE TileAttr
   NoGoX1 AS INTEGER
   NoGoY1 AS INTEGER
   NoGoX2 AS INTEGER
   NoGoY2 AS INTEGER
   ZOrder AS INTEGER
END TYPE

DIM Tile(1 to NumTiles) AS TileAttr

Tile(1).NoGoX1 = 2
Tile(1).NoGoY1 = 4
Tile(1).NoGoX2 = 16
Tile(1).NoGoY2 = 16
Tile(1).ZOrder = Z.LY1

while the character is walking around, test which tile he's about to walk on. if it's tile one and he's tile-relatively less than 4 (NoGoY1) and ZOrder = Z.LY1 (bring to front if Less than Y1), redraw that tile.

that's all i can say for now, got to go to work. write more later Smile
Pages: 1 2