Tile engines anyone?

Started by abstauber, Tue 30/03/2010 08:44:47

Previous topic - Next topic

abstauber

Yes, this comes up every now and then ;)

For some unexplainable reasons I got curious in scripting up a tile engine, or at least playing around with it. But then I've learned that a map editor could come handy, multiple layers would be nice and so on... also after some searching I found out that at least Khris, Scarab and Jim Reed are already working on the same thing.

Well, my motivation in reinventing the wheel over and over again is quite low right now.

@Current Tile Engine Coders
Are your creations going to be released as modules?

Gilbert

I think it depends on how specific the engine you want it to.

In fact it is not difficult to code your own engine, provided it's intended to be tailor-made for your own game, without "general purpose features". It all depends on whether you're having fun with making your own thing (this is what I personally like, even though you're inventing the wheels once again and possibly you can just adopt others' engines and do much more advanced stuff), or you rather save your effort in improving other aspects of your games. Neither idea is wrong in itself.

If you're looking for "reusable" engines, either the engines have to be "general enough" to cover your own needs (and probably also provide features that you don't need) or you may have to modify them to suit your own needs. But if you make your own engine you can always just make it to suit your own needs, 100%.

For example, my yet-to-be-released game has a simple tile engine and it features a fully functional map editor too:

In fact it took me about 1 month to finish the skeleton of the whole game and it's already technically complete, missing only polish like sound and cutscenes, etc. I'm just too lazy busy to continue it at the moment and this game has been on hold for 6 whole years now (ah well...).

And no, I won't make a module out of it as this game used AGS V2.6SP1, in which there wasn't even module support. :=

abstauber

Hey, that looks pretty cool, I wonder how much more projects you hide in your sleeves ;)
AGS 2.6 was last with DOS support, right? So it somehow makes sense, as it's last really portable release.

Anyway in my case I wouldn't be lurking in an "game engine forum" if I had fun coding my own engine, even if it's an engine inside an engine ;D

Khris

I don't really have anything to show for yet. I wanted to replicate the Chrono Trigger engine, and while I sort of know how it works (it uses two layers very elegantly), I've played through Golden Sun 2 recently and it has an even more advanced layer engine.

To me it really is about reinventing the wheel, that's were the fun is, but I haven't gotten around to much yet.

Gilbert

Quote from: abstauber on Tue 30/03/2010 10:01:27
AGS 2.6 was last with DOS support, right? So it somehow makes sense, as it's last really portable release.

In fact the last version with DOS support was V2.62 (V2.7 was the first to drop the support), so if I start off with new games I'll go with this. The reason I used V2.6SP2 for this was because it was the latest version when I started and I scripted a lot of stuff to work around limitations (like say, repeatedly_execute_always() was not implemented yet). If I had to upgrade it to a newer version I would have to re-work a lot of stuff such as trimming the then-unnecessary workarounds (though not absolutely required) and most importantly, my scripts were a mess that I wouldn't want to spend time in reunderstanding them to fix them. ::)

abstauber

At a certain level reinventing the wheel is sure interesting, but I know myself - after getting the basics done, I loose interest. Actually creating the game is a much bigger motivation ;)

Still I'm very curios, how others implemented those tiles. E.g. I've stumbled upon Revelation by dkh and he utilises a really cool map editor: notepad  :o
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=32496.0


@Khris: Hooray for Chrono Trigger ;D That is by far the best SNES RPG I've ever played, even though FF6 was great as well.

Jim Reed

Quote from: abstauber on Tue 30/03/2010 08:44:47@Current Tile Engine Coders
Are your creations going to be released as modules?
Not likely, sorry.

As for layers, I use two for the background, one for the sprites, and two for the foreground.
640x480 16x16px tiles @~30fps. If you don't watch out, redrawing of tiles can really eat the framerate.

abstauber

Hehe, no need to be sorry. Don't get me wrong - this is not a public cry for giving me code ( I prefer PMs for that :P )

I'd just really like this to be done in AGS. And unlike gamemaker, doing it in AGS feels right and punchy :)

Wonkyth

You could probably find some non-AGS code somewhere and transcribe it, AGS is pretty good that way.
"But with a ninja on your face, you live longer!"

Dualnames

Quote from: abstauber on Wed 31/03/2010 07:56:14
I've stumbled upon Revelation by dkh and he utilises a really cool map editor: notepad  :o
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=32496.0

wow, and to think. Hey, wait colourwise has a tile thingy. In fact it has an editor too!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#10
I have a tiled map editor made as AGS game. Originally it was supposed to be RPG editor, but I felt like not making AGS RPG yet and left it temporarily.
Editor features:
- 6 layers
- toggling layer visibility
- extra "walkable area" layer with toggling visibility and/or setting transparency
- reading tiles from AGS sprites; I could not make it load custom graphics from game folder - they always had screwed colours for some reason, so I disabled that option for now
- creating map of an any size (width/height)
- saving and loading map
- really cute and cool interface  ;D






I remember those features worked nice so far. Don't know if it may be of any use though... I started to write engine itself, but, as it often happen to me, put it away until better times because lack of inspiration  :P

Ryan Timothy B

Yeah you're almost better just making your own.  Everyone has their own technique or design.
Like mine for instance is for a strategy game level editor Exactly like the Starcraft editor.  Ignore the programming graphics.  I haven't worked on this in a while, been busy with other games. :P


(Click to enlarge)

Also it has fog!  (which will probably never make it, since it 'might' be too laggy)

Scarab

Quote from: abstauber on Tue 30/03/2010 08:44:47
@Current Tile Engine Coders
Are your creations going to be released as modules?

Possibly, however I grew up playing RPGs on Gameboy, and as such my engine is designed to emulate those kinds of games, and supports no layers, so this might not be what you're looking for.

The reason it is dead in the water right now is because I have been having trouble exporting maps from the editor into the game (using .txt files), and I need to become better at using the File functions before I can continue.

Khris

About handling map data:
ProMotion can export GBA tile map data and currently, the only thing my editor does is import & display that.
I was planning to export the data as code in a txt file so that it only needs to be pasted into a script as-is.

That way the level data is in the game, not in editable files outside.

Btw:
There's a pretty sophisticated Chrono Trigger map editor out there, and playing with it I learned how they do dungeons and village houses: all rooms are on one big map; and all tiles contain a scroll flag.
Using the flags, the big map will stop scrolling at the edge of a room.

Wonkyth

Wouldn't it be better to use an image for levels?
"But with a ninja on your face, you live longer!"

abstauber

You guys should definately colaborate ;)

@Khris: This is actually pretty cool. I've also thought about parsing PMs map exports.
But as said, simply parsing ASCII codes is way easier for my limited project.

@Dualy: Yay and Colourwise even has isometric tiles :) Somehow I must have forgotten about it.

@Crimson Wiz:
Fancy stuff! Co-evolution made this looking like Jim's :)

It's really impressive how many people have tile projects in the pipe.

Matti

This was my first attempt in tile-based scripting ever. I should finish that stupid game at some point.

It's rather simple and I won't make a module or something. The background consists of 10x10 tiles and each tile has ~4 variables who store some info (kind of tile/"subkind" of tile/building/player). Everytime something is changed the whole background is being drawn again. First the landscape, then the buildings, then the borders.

But if I find some time in the future I might elaborate the whole thing to make something decent with it.

Khris

wonkyth:
I sort of do that already; ProMotion is great as a map/tile editor; e.g. you can at any time convert a drawn image to tiles, remove unused ones, or draw on one tile and have all occurrences updated on the fly.
I have yet to find a better tool.
Actually, it also supports layers so it's possible to draw layered tile maps; unfortunately, it crashed on me as soon as I started using two layers.

abstauber:
It's not too hard to parse the file, the format is well documented.
Here's the core function, if anybody's interested:

Code: ags
bool ReadMap(String filename) {
  File*f;
  String fs;
  
  // open sprite file
  fs = String.Format("tiles/%s#tiles.pcx", filename);
  error = "Sprite file not found";
  if (!File.Exists(fs)) return false;
    
  error = "Error importing sprite file";
  tile_images = DynamicSprite.CreateFromFile(fs);
  tiledims = tile_images.Height;
  
  if (tile_images == null) return false;
 
  fs = String.Format("tiles/%s#map001.map", filename);
  error = "Map file not found";
  if (!File.Exists(fs)) return false;

  f = File.Open(fs, eFileRead);
  error = "Error opening map file";
  if (f == null) return false;

  mapwidth = f.ReadDoubleword();
  mapheight = f.ReadDoubleword();
  int tiles = mapwidth * mapheight;
  int i;
  int info;
  String s;
  while (i < tiles && i < 5000) {
    info = f.Readword();
    s = BitString(info, 16);
    Tile[i].image = BitStringToInt(s.Substring(0, 10));
    if (BitStringToInt(s.Substring(10, 1))) Tile[i].mirrored_x = true;
    if (BitStringToInt(s.Substring(11, 1))) Tile[i].mirrored_y = true;
    i++;
  }
  f.Close();
  
  // setup viewscreen with tile info
  ViewScreen.SetMap(mapwidth*tiledims, mapheight*tiledims);
  ViewScreen.SetBounds(true);
  
  return true;
}

Crimson Wizard

By the way, since we touched this topic here, does anyone know, why this may be that when I create dynamic sprite from file, all colours became screwed?
I tried everything, it seems, like making graphic colour amount match game's colour amount, trying different colour settings in game, etc, nothing seem to help.

Jim Reed

#19
The heart of my tile drawing function. Will render any tile/map size.
The offset is for effects like screen shaking and such.

Code: ags

int sprite_x=((counter%ROWSIZE)*(TILE_PIXEL_WIDTH))+MAP_X_OFFSET; 
int sprite_y=((counter/ROWSIZE)*(TILE_PIXEL_HEIGHT))+MAP_Y_OFFSET;


Edit:
counter is an int, looping through the tile array.
The tiles don't have x and y positions, so it's easy to draw a map of letssay 400 tiles (20x20 tile map)
You just make an tile[400] array and run it through the above code, seting up the rowsize to 20 beforehand.

SMF spam blocked by CleanTalk