Jump to content


Photo
* * * * * 1 votes

Auto Tile Your Walls By Nocturne


  • Please log in to reply
67 replies to this topic

#1 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 23 January 2009 - 11:17 AM

  • Title: Auto Tile Your Walls
  • Description: Example,script and templates for TDS/RPG auto tiling walls
  • GM Version: GM7Pro
  • Registered: No (don´t think so)
  • File Type: zip file with gmk, gml, png and photoshop psd files
  • File Size: 0.5MB
  • File Link: Posted Image

Additional Info
This is an example with template images and a script for anyone who is doing a TDS or RPG game and wants to use one wall object, but have nice corners and connecting graphics. The png files inluded are a large template file with each of the necessary tiles numbered for ease of use and an example of a finished wall tile. There is a bonus for photoshop users as I have included a template with caps, rulers and effects for you to use as a base.

The script itself is very easy to use and should not be modified! Just load it into the scripts section of your game and then copy and paste the code from the create event of the obj_Wall in my example file into the create event of your object wall. Then load up a tile set that you have created and change the names in your wall object create event to the tile set. If you want to use sprites instead of tiles then I have included code for that too...

To make your own tiles just check out the template file and you will see that each block that is needed has a number and a black edge. These edges correspond to the outside edges of the wall and the numbers correspond to the position within the tile set. It´s a bit of work but very rewarding when finished, especially when you use a seamless image as a base! If you need a size that is not 32x32px then just adapt the code (explained in the comments) and scale up/down the template file... And please don´t rip the included graphics...

Here is a screenshot of a room tiled with Auto Tile...
Posted Image
I used this script in my Gauntlet game with 64x64px tiles so if you want to see how it works in a game click the link in my sig...


As always, no credit is necessary (but apreciated!) and if you download this please comment!!!!


NOTE: This has been modified and should now present no graphic problems due to the size of the tiles...

Edited by Nocturne, 08 April 2011 - 08:18 AM.

  • 5

#2 alex_pof

alex_pof

    GMC Member

  • New Member
  • 1296 posts

Posted 23 January 2009 - 10:12 PM

That is really good and useful! One of the better things ive seen in a while.

I think you should make the tiles to be 2 rows that way you wouldn't have a problem with some graphics cards not working.
  • 0

#3 gurilazs

gurilazs

    GMC Member

  • New Member
  • 385 posts

Posted 23 January 2009 - 11:02 PM

Very helpful mark! Thanks.
  • 0

#4 Diptoman

Diptoman

    GMC Member

  • GMC Member
  • 1742 posts
  • Version:GM8

Posted 24 January 2009 - 06:59 AM

Incredible!
The code used in the script looks as boring as ....(something I can't even imagine).... But the result is worth it.
  • 0

#5 daman123125

daman123125

    AZN Game Programmer

  • GMC Member
  • 1955 posts
  • Version:GM8

Posted 24 January 2009 - 07:05 AM

Kind of like Mouse's Mice's Lazy Tiles. But this is much more efficient for me. Great job. ;)
EDIT: Slight mistake. :)

Edited by daman123125, 25 February 2009 - 01:52 AM.

  • 0

#6 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 24 January 2009 - 07:17 AM

Thanks Guys !

@alex_pof - I suppose you could change the loop in the create event to have two of them and cut the tile sheet in half... the only problem their is that there are 47 tiles, so you would need to make the last one (48) blank... Maybe this code would work?

for (a=1; a<3; a+=1;)
{
for (i=0; i<25 i+=1;)
	{
	if imagesingle=(i) {xx=i*32; yy=0;}
	if imagesingle=(i+24) {xx=i*32; yy=32;}
	}
}
tile_add(tile,xx,yy,32,32,x,y,-1000);

I´ll test it later and post back...

@gurilazs and daman - thanks!

@dmsuper - Not only boring, but very,very,very,(+inf) frustrating!!! The game I used it in first (Gauntlet) didn´t take a year to develop for nothing!!! But as you say, the result was worth it!

Edited by Mark13673, 24 January 2009 - 08:44 AM.

  • 0

#7 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 28 January 2009 - 10:15 AM

The link has now been updated with a revised version (complete with new templates and example files) and the compatibility issues with some graphics cards have been resolved. The new code is commented too...

PS: Please comment if you download this (48 downloads and 4 comments?)...

Edited by Mark13673, 28 January 2009 - 10:15 AM.

  • 0

#8 tamper2

tamper2

    GMC Member

  • New Member
  • 369 posts

Posted 28 January 2009 - 03:21 PM

Very nice example.
I really liked it.
The only comment I have for it is about the imagesingle...
That variable really confused me, because I didn't understand how you decieded which imagesingle says what...
I don't understand how does it choose that if(...) and if(...) then imagesingle=...
That's the only thing that I want to be more commented :P
Except for that, great example!
Tamper :D
  • 0

#9 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 28 January 2009 - 06:06 PM

Thanks Tamper.

I didn´t comment that script too much as it was really boring and difficult to do! Basically it is a bunch of nested conditions that check all the possible combinations of placing the wall objects for collisions with other wall objects and if there is a collision it either sets imagesingle or starts off another series of conditional checks until there is only one possible number for imagesingle... and it´s difficult to comment something like that without repeating yourself 47 times!!!!
  • 0

#10 Supertramp

Supertramp

    GMC Member

  • GMC Member
  • 353 posts

Posted 28 January 2009 - 06:11 PM

i made my own script that does exactly the same - they are almost identical
good job, i'm glad someone put the script up so we don't have to spend ages trying to place each tile by hand!
10/10 :P

Edited by Supertramp, 28 January 2009 - 06:11 PM.

  • 0

#11 Rolfero

Rolfero

    GMC Member

  • New Member
  • 144 posts

Posted 24 February 2009 - 08:57 PM

Is there any way to instead of creating a tile, changing the image_index to a subimage to look just like that, so you could that way remove/add "tiles" while the game is running?
  • 0

#12 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 24 February 2009 - 11:06 PM

@Rolfero - Sure! Check out the create event of the wall object and you will see that there is an alternate code at the bottom for using sprites and image-index instead of tiles... just make sure the sprite follows the supllied template of 47 sub-images and it will work fine!
  • 0

#13 Rolfero

Rolfero

    GMC Member

  • New Member
  • 144 posts

Posted 24 February 2009 - 11:12 PM

:) Great! Thanks! Does you want credit?
  • 0

#14 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 25 February 2009 - 12:27 AM

Naw... it´s not necessary, but if you want to my ego would be pleased... :)
  • 0

#15 Drizzt7

Drizzt7

    GMC Member

  • New Member
  • 125 posts

Posted 25 February 2009 - 12:45 AM

One theoretical way that this can be done faster is by using something similar to this:

//scr_auto_tile(x, y, width, height, object);
//Uses: used to set the image_index, i.e. image_index = scr_auto_tile(x, y, 32, 32, obj_wall);
var xx, yy, tile_w, tile_h, obj;
xx = argument0; //X-position to check for
yy = argument1; //Y-position to check for
tile_w = argument2; //The width of the tiles (32)
tile_h = argument3; //The height of the tiles (32)
obj = argument4; //The tile object to check for

return place_meeting(xx + tile_w, yy, obj) + 2 * place_meeting(xx - tile_w, yy, obj) + 4 * place_meeting(xx, yy + tile_h, obj) + 8 * place_meeting(xx, yy - tile_h, obj)
 //Etc. until you include all of the possible places.  
//Then, you match up all of the places in the sprite/tile set to what it would be according to the number returned by image_index here, and voila!
//You have one line that does all the matching!  This can also be done dynamically very quickly, most likely.

  • 0

#16 JunkGame

JunkGame

    GMC Member

  • New Member
  • 8 posts

Posted 25 February 2009 - 02:14 AM

I really like your example and what it does. That is a very neat way to do wallpapers
  • 0

#17 x-death

x-death

    Flash Developer

  • GMC Member
  • 3402 posts

Posted 25 February 2009 - 01:38 PM

it looks like you took an idea off someone else. i remember a member of this forum called mice, he/she made an excellent example of this a while ago. and it wasn't specific to one view. it worked for all views. and it could be called from a simple script as well.

very handy i used it all the time when creating games for small school and tafe projects. very handy.this is just a cheap version of that though. sorry if i sound mean. but its what i think, can't help that.
  • 0

#18 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16793 posts
  • Version:GM:Studio

Posted 25 February 2009 - 01:59 PM

Not mean in the least x-death... There are always different solutions to the same problem! Just look at the metaballs example in this forum... (and all the text, menu etc.... examples). Form follows function after-alll! This little example was born out of necessity as my Gauntlet game had many huge levels and I really didn´t fancy placing all of the tiles by hand...

EDIT: Decided to look and see what mice did... And I´m glad I did as it´s very similar to my example only for platform games! If anyone is interested, here is a link...

Edited by Mark13673, 25 February 2009 - 02:03 PM.

  • 0

#19 x-death

x-death

    Flash Developer

  • GMC Member
  • 3402 posts

Posted 26 February 2009 - 01:55 AM

Not mean in the least x-death... There are always different solutions to the same problem! Just look at the metaballs example in this forum... (and all the text, menu etc.... examples). Form follows function after-alll! This little example was born out of necessity as my Gauntlet game had many huge levels and I really didn´t fancy placing all of the tiles by hand...

EDIT: Decided to look and see what mice did... And I�m glad I did as it�s very similar to my example only for platform games! If anyone is interested, here is a link...

but i will admit mices example can be very confusing sometimes. that is were your two examples are different this one isn't as confusing.
  • 0

#20 Jonolio

Jonolio

    GMC Member

  • New Member
  • 7 posts

Posted 01 March 2009 - 04:58 AM

Hi, I'm new to this forum. I downloaded this but when I tried to run it there was a fatal error:

FATAL ERROR in
action number 1
of Create Event
for object solid_block:

COMPILATION ERROR in code action
Error in code at line 9:
scr_auto_tile();

at position 2: Unknown function or script: scr_auto_tile

What do I do? I didn't modify the script apart from changing the tile size to 24x24 and doing the "if room=... then tile=... etc"


EDIT: Oops! I fixed it, I forgot to place the cod into gamemaker, but now when I run it all the tiles are wrong...
help! :P

EDIT: I forgot to change two numbers,but now that Ihave done that, the very edge pieces are mostly right, but none of the middle pieces are correct...

EDIT: I feel kinda' stupid for even posting, didn't realise this couldn't be adapted for platform games...

Edited by Jonolio, 01 March 2009 - 05:39 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users