Hi guys! I'm making a level editor for my game and I wondered if there are any "Global events" like, for making my life easyer. BEcause you see, I want both tiles and tilesets to be image files which can be loaded, and, since I thought this was impossible I soon encountered my next problem. I tried to forget the image files and just used actives, but then i need to have like, 3 events for each tile! I'm already familiar with the array object so this is the part that is bugging me. Please help me out guys. Thanks in advance.
Yes i do mean that it applies to all the tiles. I am familiar about both behaviours and "groups" or "qualifiers". I dont think just knowing that solves my problem lol
Seriously. I don't want to freaken program each and every tile! I would also like to be able to load tiles from image files but still be able to "Paste them into background" on the load of the array to save some runtime 'n' stuff.
From what I guess, even if you can code a level editor to just copy and paste tiles from a tilesheet, you will encounter a problem saving the level where it has no idea what those tiles are, it's just a heap of pictures pasted onto the screen. Therefore, every tile needs a value and to be saved as a value in an INI or array and then once again loaded with that value so the program can automatically paste those tiles from the set itself to load the level. Then you have the problem of telling MMF what values each tile carries so that it can save and load it accordingly through events, and I'm not sure with an image file that will be a simple task. (The program needs to distinguish each tile from eachother) but I think some of the genius coders around here would have an idea of how to do it efficiently.
Using actives, you may well have to use a few events for each tile. Alternatively, set all of their alt. values to subsequent values, (1,2,3,4..etc) and have the event editor recognise them through these when writing to your level file instead of saying "What object is it? If it's that object, then write this value." you might get away with "When a tile is placed, write value [Alt. value A of selected object] to slot." Haven't done this myself so I can't say if it's going to work as well. I'm sure it can be done though.
It will pay off to find a way to simply program all of them in a few events rather than 3 events duplicated for 100 tiles (300 events!).
Concerning custom tilesets and tiles, I'm not sure.
Text blitter is ideal, but is very complicated. I advise try using the Active Picture object; use the command 'Get Picture' to tell it to load a new image, that image being your whole tileset. You can retrieve one in your folder using the expression:
"$Apppath + /TileSetName.png"
now you've loaded your tileset into the picture. You need to have an Array Object which has the data for each tile at each location on your grid, this is something you create in a level editor. You load this object in the same manner, and then run a loop like this:
Always:
Start "X" for (Horizontal Size / 32) Loops
On Loop "X":
Start "Y" for (Vertical Size / 32) Loops
On Loop "Y":
Here, use the ability on the Active Picture object called 'Add Backdrop'
Add Backdrop: At location (LoopIndex("X") * 32, LoopIndex("Y") * 32), with tile value (get value from array), width & height 32
thus the loop will go through each square of your level, and for each spot, it will chop a square out of the image in your active picture object, and add it as a backdrop at that location, creating a finished image in the end. The act of creating the array object that has all your level data is a bit more complicated, you'll need to create some sort of level editor. I'd advise seeing examples for that
Thank you Pixelthief mate! Exactly what I needed... I DO know how to write values and such in the editor, (thus i know how to make one) but how do I chop squares out of the picture then? Well probably the same consept anyway...
when you use the function, it will ask you for the "X & Y" value of the source; these are the location in the picture object that it takes the tile from. So if your tiles are arranged in a big rectangle, like this:
(forgive me nifflas)
then you can store the X & Y coordinates of the tile as a single variable in your array. For example, I use the format: X + (100 * Y), so that at runtime, I can find the proper tile in my spritesheet as:
X = (ArrayValue mod 100) * 32
Y = int(ArrayValue / 100) * 32
Then, it takes the rectangle at these coordinates using the same width & height