Page 1 of 1

Tiles

PostPosted: Mon May 25, 2009 3:44 am
by Caaz Games
How would i make a tile based game?
like pokemon style, where he takes a couple steps and always lands on a tile.
and i'd also like to know how to make where it just jumps, thanks and +1 to whoever tells me :D...

i'm not sure what size things will be so please tell me how i can manipulate it so that it will be good for all sizes.
and later i would need gravity using these. thanks.

Re: Tiles

PostPosted: Mon May 25, 2009 4:29 am
by skydereign
Well, these are some possible ways. You can pick whichever, depending on what you are comfortable with. One way is to use a two-dimensional array to hold the tile types, then the actor checks if the spot is available. Another method is to just make sure the actor moves a tile at a time, and while moving, checks if the next spot is open, with CollisionFree. You can also have actors check if there is a collision, a north tile, south tile, east tile, and west tile. They change variables depending on collisions. For the actual moving, you can either do it animation based that has a variable that controls movement, so you only can move again if on the animation finish of a move, if the key is down, then move again. In that code, you would need a type of recognition of other tiles. The animation itself would start with a frame of the player standing, and the end would result in him being in the neighboring square. Then the the finish of that animation, it sets the x or y accordingly. By jump do you mean no transition walking? Also, how would you add gravity to a tile based game? Maybe you are thinking of something else... But anyway, the animations can either make the transition smooth or not. Also you could use variables to control when the player stops moving... If any of these sounds good, I can explain them further. If none of these seem right, I can explain other methods.

Re: Tiles

PostPosted: Mon May 25, 2009 5:14 am
by Caaz Games
well, i want' to make a game like this...
http://www.neopets.com/games/play.phtml ... ality=high
you can push stuff around and ballons go up tiles, and rocks go down, the player moves freely without gravity.
it's all tiles, and if you play it you'll see what i mean by 'jumping' the guy just flashes through the tiles...
tiles will be 60x60 for me... thanks again.

Re: Tiles

PostPosted: Mon May 25, 2009 5:38 am
by skydereign
Okay, well the player movement would be really easy. I would probably use an array to determine each spot. Not sure if it is the best way though..
Code: Select all
#define dimX 10
#define dimY 10
int MAP[dimX][dimY];

Then, depending on what each sub has, you can move or not. The balloons and rocks check if their is a certain object above or below them, represented by some number. If there is not, then it will rise. The actor itself would be placed on the grid, and if the spot is available, then you can move by adding 60 to your x or y value. These would be good to look at before you really try anything, even if you don't use the methods within, it gives a good idea of what factors exist in tile based games, or gives a general idea of keeping track of where things are and whatnot. I could make a simple demo if need be.
http://game-editor.com/forum/viewtopic.php?f=5&t=6569&start=0&hilit=strategy
http://game-editor.com/forum/viewtopic.php?f=5&t=6568&start=0

Re: Tiles

PostPosted: Mon May 25, 2009 6:19 am
by Caaz Games
yes a demo would be nice :D you're really helpful.

Re: Tiles

PostPosted: Mon May 25, 2009 9:39 pm
by DST
I would go with the array method, because it will allow you to add custom maps without having to recompile the game, and
you may at some point want to use a custom level editor (that you make in ge), and arrays can be easily stored to txt/dat files and reopened.

An array would allow you to add complex pathfinding, and you can determine cell contents by real values; the cell either is 1 grass or 2 rock or 3 water. This would make it easier to add quantum effects to the map (like if a forest were burned down, or if the level was flooded with water).

And will also expand your understanding of game making and data handling.

CollisionFree or collision with an child collider are way less efficient that simply checking cell integers, even if they may be simpler to use at first. They also can't be customized or have maps added, and require you to build huge maps inside of ge.

The more stuff you add in the editor mode, i.e. actors, clones, and tiles, the closer you get to overloading the program and crashing the game.

Re: Tiles

PostPosted: Thu May 28, 2009 2:16 am
by skydereign
Here you go, this just gives a general idea. It is not perfect, really a very rough sketch of what a tile game should be or use.

Re: Tiles

PostPosted: Sat May 30, 2009 3:49 am
by Caaz Games
Okay so i've been looking at the code and stuff, and there's one thing i need to understand...
Code: Select all
x=X*60;
y=Y*60;

my best guess is that's how big the tile is... 60px by 60px, and you used X to mean 1=60 so when you say X++; that would move it one over, right? so if i change 60 to say... 10, it would instead be 1=10 so everytime it would go it would move 10px?...

and the player's draw actor, it's complicated... i need some understanding on the way you have the keydowns, i've tried using it but it failed miserably.

Re: Tiles

PostPosted: Sat May 30, 2009 4:05 am
by skydereign
Yes, all the references to 60 would be switched to 10. You might as well #define that, or use the width of your tile. My computer is broken right now, essentially the graphics don't work, and so I can't look into the draw code right now, but I can explain what I think I did. The main idea behind it, I don't like using keydown events, I tend to do everything in draw... so you could split it us, because all it does is check the spot you are moving to. So instead, use just say, keydown right. In this, it will have a switch statement, using the tile array with the coordinates of x+1, y, the subs. If it is 0, case 0, then move there and adjust the array you are on. What it is doing for that is setting the xy you are on to 0 and moving your xy right one. If there is a wall, case 1, then do nothing. If there is a rock, case 2, move the rock and move the actor. This is the general idea of the draw, if I can get my computer working, I could make a commented demo, not using the draw script for it. That is if this explanation did not help.

Re: Tiles

PostPosted: Sat May 30, 2009 7:25 am
by Caaz Games
no no, the demo helped alot :D. +1
just some little things i'm wondering about :P
like in the rock's draw

Code: Select all
x=X*60;
y=Y*60;

if(Y<MaxY-1 && objectGrid[X][Y+1]==0)
{
    objectGrid[X][Y]=0;
    Y++;
}
objectGrid[X][Y]=2;

now i get what controls the cases, that last line, right?... and how this gravity works, Y keeps getting added ++; so it goes one tile down, and how it checks if something is onder it... but what's
Code: Select all
if(Y<MaxY-1 && ...

i'm not familiar with that part.
... if i put this on a timer the gravity would go slower right? ...
and now i understand why i can push rocks into the wall and go through the wall, by pushing it...

and one more thing, i've noticed that the grid is limited, yet i found no place where it referenced that fact... and where i could edit it.

PS. yay learned like 7 things while looking through this... PPS i found out why i messed up the draw actor keydown script :P

Re: Tiles

PostPosted: Sat May 30, 2009 7:32 am
by skydereign
That is too limit the rock from going beyond the bounds of the grid, which would leave the array, causing gameEditor to crash. And yes, putting a timer on that event would slow down the fall of gravity. The grid itself is limited by the size of the array. I believe if you look at the movement codes, like in that of the player, it will have less than or greater than, those make sure you stay in the bounds of the array. You can change the size/dimensions in global code. As far as fixing the problem with pushing rocks through walls, you would just need a second check.

Re: Tiles

PostPosted: Sun May 31, 2009 6:24 pm
by Caaz Games
thank you! i understand it all, i think, and i need more help i'll come back :P