advice on tilemaps & level editor

You must understand the Game Editor concepts, before post here.

advice on tilemaps & level editor

Postby cs6505 » Wed Nov 16, 2005 1:46 am

Hi all. I am a newbi to GE, I just bought it this past weekend. I love this tool and can't wait until I actually make something half way decent. :D
I realize that GE has built in tile mapping and scrolling. I wanted to make a small scrolling game with a level editor included to add replay value. I am thinking I could store the levels in a simple text file and then load them into an array and then render them to the screen. Is this possible with GE and if so, what is the best way to go about it? Thanks for any advice.

cs
cs6505
 
Posts: 7
Joined: Sun Oct 23, 2005 8:30 pm
Score: 0 Give a positive score

Re: advice on tilemaps & level editor

Postby makslane » Wed Nov 16, 2005 5:49 pm

cs6505 wrote:I realize that GE has built in tile mapping and scrolling


The use of tiles is just an option that you can use. You can make your game without tiles by using a single image in your actor.

cs6505 wrote:I wanted to make a small scrolling game with a level editor included to add replay value. I am thinking I could store the levels in a simple text file and then load them into an array and then render them to the screen.


You can't change tiles in game mode, but you can simulate by using normal actors:

1) Create an actor "parentTile"
2) Create an actor "tile"
3) Make the parentTile parent of actor tile. This will help you to move the tiles
4) Add your tile animation in the tile actor
5) In the "Create Actor" event stop the animation with the "Change Animation Direction" action
6) Make a clone array with tile actor (like 20x16)

Now, make a txt file with the map info like this:
0 0 0 0 0 .... 0
1 0 0 0 0 .... 0

Make an array to hold the map info (in the Global Code editor):
int map[16][20];

Create a function to read the map (in the Global Code editor):

Code: Select all
void readLevel(char *file)
{
  int value, i, j;
 
  if(!levelRead)
  {
 
    FILE *fp = fopen(file, "r");
 
    if(fp)
    {
        levelRead = 1; //Don repeat reads
 
        for(i = 0; i < 16; i++)
        {
            for(j = 0; j < 20; j++)
            {
                fscanf(fp, "%d", &value);
                map[i*20 + j] = value;
            }
        }
 
        fclose(fp);
    }
  }
}


And read the map in the view "Create Actor" event:
readLevel("level1.txt");

Download the complete sample here:
http://game-editor.com/examples/tile_map.zip
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby cs6505 » Thu Nov 17, 2005 2:02 am

Thanks for quick response and answer.
Is it possible to scroll using this technique if the map is bigger than the screen? Thanks again.

cs
cs6505
 
Posts: 7
Joined: Sun Oct 23, 2005 8:30 pm
Score: 0 Give a positive score

Postby makslane » Thu Nov 17, 2005 2:29 am

Just make the map bigger than the view actor and move the view actor to make the scroll
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Chai » Thu Nov 17, 2005 11:23 pm

WOW!! that is very awsome. >_< I LIKE IT
User avatar
Chai
 
Posts: 361
Joined: Sat Apr 30, 2005 2:26 pm
Location: Thailand
Score: 30 Give a positive score

Postby CdaMarinersFan » Fri Nov 18, 2005 12:27 am

Heh heh, Makslane, you're like a prophet of 2d game building! :D lol
Image
User avatar
CdaMarinersFan
 
Posts: 109
Joined: Wed May 11, 2005 11:20 pm
Score: 0 Give a positive score

Postby DilloDude » Wed Apr 05, 2006 1:45 am

What is a good way to do this with different types of actors and using text instead of numbers? For example, cycle through each code in the tex file while updating x and y coordinates and checking a section of string and if it is MT, create actor mountain at those coordinates, if it is R|, create actor river with animpos = 1 and so on. Also, a way of going through positions and finding actors and saving them in a text file would be good.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Fuzzy » Wed Apr 05, 2006 6:58 am

A little known trick is that you can use a graphics file as a font; its refered to several times in various tutorials.

Instead of using unicode characters, you use pictures instead. So the number one might look like a fish, and the letter A could be a tree, rather than looking like a 1 or A symbol.

from there, you just have to load a text file into a text actor, and you have a type of tiled actor, which CAN change dynamically in game.

The limitation of course, its that it cannot easily be animated.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby DilloDude » Thu Apr 06, 2006 12:20 am

I considered this before, but thought maybe it wasn't exactly what I wanted, but now, I think it might be. One problem - I have two types of actors that need to have thier specific x and y coordinates, mainly for determining distance. Is there a way I can search a string for a character, and then find its position in the string (in which line and which character in that line). I was also thinking about automatically determining height and width of the map, but I think it would be easier to determine it manually, and save the variables with the string.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Thu Aug 24, 2006 4:27 am

I am thinking of a level reading system that either saves a variable or reads text, and creates actors from an array like in the breakout demo. The thing I'm considering is performance. If I have a lot of clones instead of tiles, how much is the performance difference likely to be, considering that most of them will only have create actor events, but other actors might have collisions with them?
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest