Jump to content


Photo

Animating Tiles


  • Please log in to reply
10 replies to this topic

#1 Aero88

Aero88

    GMC Member

  • GMC Member
  • 419 posts
  • Version:GM8

Posted 30 April 2012 - 04:58 PM

Hi, I am using GM 8.1 Pro and I am interested in making efforts to increase the efficiency of my programming. Currently I have been using objects when I needed tiles that are animated, but I am now wondering if it is possible to animate tiles themselves in GM rather than using separate objects for each type of animated tile. Any help is appreciated. Thanks for your time.

Edited by Aero88, 03 May 2012 - 03:22 PM.

  • 0

#2 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1606 posts
  • Version:GM8

Posted 30 April 2012 - 05:13 PM

Hi, I am using GM 8.1 Pro and I am interested in making efforts to increase the efficiency of my programming. Currently I have been using objects when I needed tiles that are animated, but I am now wondering if it is possible to animate tiles themselves in GM rather than using separate objects for each type of animated tile. Any help is appreciated. Thanks for your time.


Don't use a separate object for each tile! That's very inefficient in terms of processing speed and memory usage.

I don't think there is a way to create animated tiles since tiles are used to draw a static image that requires no processing whatsoever. They are used to save processing speed when all you want are static images on the ground. However, you can use sprites to draw animated images. Draw them all in the draw event of 1 object.
Make sure you draw the ones that are actually visible on the screen. Don't draw sprites that are far off the screen since it would slow down the game.
  • 0

#3 Aero88

Aero88

    GMC Member

  • GMC Member
  • 419 posts
  • Version:GM8

Posted 30 April 2012 - 06:20 PM

So are you saying that you have to build an imaginary grid in a single object containing all the coordinates for each tile I wish to animate? Sounds like it could be tricky and time consuming to get everything lined up just right, but I guess it wouldn't be all that terrible once the I get a system set up for it.
  • 0

#4 Weird Dragon

Weird Dragon

    GMC Member

  • Global Moderators
  • 1916 posts
  • Version:GM:Studio

Posted 30 April 2012 - 09:24 PM

You could take a look at this chapter in the help file:

The GameMaker Language (GML) > Game graphics > Tiles

There are actually quite a few possibilities with those functions.
  • 0

#5 Aero88

Aero88

    GMC Member

  • GMC Member
  • 419 posts
  • Version:GM8

Posted 30 April 2012 - 10:47 PM

Thanks. I'll look through it and see what I can find.
  • 0

#6 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 565 posts
  • Version:GM8.1

Posted 30 April 2012 - 10:59 PM

Here is an example I whipped up
http://www.freefileh...nimationexample
  • 0

#7 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 4714 posts
  • Version:GM8

Posted 30 April 2012 - 11:45 PM

tile_set_region() or tile_set_background() should work just fine in conjunction with tile_layer_find() for what you want.
  • 0

#8 Aero88

Aero88

    GMC Member

  • GMC Member
  • 419 posts
  • Version:GM8

Posted 02 May 2012 - 01:27 AM

Here is an example I whipped up
http://www.freefilehosting.net/tileanimationexample


Thanks. I am not at my home computer at the moment so I can't download it just yet, but I will take a look at this as soon as I can.

@TheouAegis - I'll look into those functions as well thanks you your suggestions.
  • 0

#9 Aero88

Aero88

    GMC Member

  • GMC Member
  • 419 posts
  • Version:GM8

Posted 03 May 2012 - 03:21 PM

I had a chance to download and look at your example and it helped a lot. Thanks for taking the time to throw that together! This will diffinatly help me out.
  • 0

#10 Migsta

Migsta

    GMC Member

  • GMC Member
  • 173 posts
  • Version:Unknown

Posted 24 September 2012 - 03:13 AM

Hmmm, I had this same question. Is there a way to do animated tiles like a shore line with animated water? I wasn't expecting to see an animated character...wacky...
  • 0

#11 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 565 posts
  • Version:GM8.1

Posted 24 September 2012 - 10:18 AM

The same way. The animated character it just to show the fact tiles can be move AND animated. I believe you can modify multiple tiles at once by using their layers.

This is the code that animates the tile
    tile_x = (tile_x+0.3) mod animate_length; //this loops the animation (look up Smart Codes in the GMC)
    tile_set_region(my_tile,floor(tile_x)*tile_w,tile_y*tile_h,tile_w,tile_h); //this moves the tile origin

If you comment out the code for making the character walk, and paste the above in the code block, the tile will animate.

Edited by C_Pike, 24 September 2012 - 10:24 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users