HOW: Object-Animated Objects Tiled?. And Game Framework

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
dreyk533
Prole
Posts: 2
Joined: Sun Aug 12, 2012 7:32 pm

HOW: Object-Animated Objects Tiled?. And Game Framework

Post by dreyk533 »

Hello, I'm working right now in this little game, but I have problems with creating levels and place objects animated and static from Tiled Map Editor, I can not make a connection between the program and the code of the game, as well as the creation new levels.

Well, here attached the framework if they can help me and anyone else who is starting in lua like me.
Attachments
0.0.10.zip
Framework, coins, player, score, and map
(55.36 KiB) Downloaded 208 times
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: HOW: Object-Animated Objects Tiled?. And Game Framework

Post by Kadoba »

Sorry I didn't see this before.

ATL doesn't have direct support for animated tiles but it's still possible. First you need to iterate through all of the tiles and then store the ones you want to animate. Then have an updater function switch the tiles frames. You could also create an animated tile object and draw over the tiles you wish to animate.

Here's one way to do it:

Code: Select all

-- Setup
local ATL = require "AdvTiledLoader"
local map = ATL.load("mymap.tmx")

-- We'll place our animated tile information in here
local animated = {}

-- Set the next tile in the animation
animated.next = {}
animated.next[map.tiles[1]] = map.tiles[2]
animated.next[map.tiles[2]] = map.tiles[1]

-- The delay between frames and the current time accrued 
animated.delay = 0.5
animated.time = 0 

-- Find all of the animated tiles and store their location
for i, tileLayer in pairs(map.tileLayers) do
   for x, y, tile in tileLayer.tileData:iterate() do
      if tile.properties.animated then
         animated[ #animated+1 ] = {tileLayer=tileLayer, x=x, y=y}
      end
   end
end

-- Update the animations
local a, tile
function love.update(dt)
   a.time = a.time + dt
   if a.time > a.delay then
      a.time = a.time % a.delay
      -- Change each animated tile to the next tile in the animation
      for i = 1,#a do
         tile = a[i].tileLayer.tileData( a[i].x, a[i].y )
         a[i].tileLayer.tileData:set( a[i].x, a[i].y, a.next[ tile ]  or tile)
      end
   end
   map:forceRedraw()
end

-- Draw the map
function love.draw()
   map:draw()
end
dreyk533
Prole
Posts: 2
Joined: Sun Aug 12, 2012 7:32 pm

Re: HOW: Object-Animated Objects Tiled?. And Game Framework

Post by dreyk533 »

I dont get it. Do you see http://projecthawkthorne.com/ ? a lua game based on the tv series community? Well, on tiled map editor you put a Object properties and placed the type, and hippy eg course it appears on the map when compiling the game. nodes in the folder the file is hippy.lua, even not as such connections fail.
Attachments
Untitled.png
Untitled.png (177.62 KiB) Viewed 3623 times
print2.png
print2.png (564.97 KiB) Viewed 3623 times
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: HOW: Object-Animated Objects Tiled?. And Game Framework

Post by coffee »

dreyk533 wrote:I dont get it. Do you see http://projecthawkthorne.com/ ? a lua game based on the tv series community?
hola! Actually it's even more that a Lua game. It's done with LOVE framework
viewtopic.php?f=5&t=9302&p=57754

And you should trust Kadoba advices! He made Advanced Tiled Loader (http://love2d.org/forums/viewtopic.php?f=5&t=2567) used also by hawkthorne I think. You can't find greater expertise than him on the matter here.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: HOW: Object-Animated Objects Tiled?. And Game Framework

Post by Kadoba »

Actually I think I got confused or something. I thought the topic was about animated tiles, not objects. Ignore what I said before.

Objects are interpreted however you want. The goal of ATL is to load data from .tmx files and provide simple rendering and a structure for you to build on. All object functionality, including animations, is up to you. So there is no one way to animate things.

Generally though these are the steps you need to take:
1. Find an animation library such as anim8 or ANAL.
2. Iterate through the ObjectLayer.objects and create your objects and animations with the data
3. Define custom layers to animate your objects
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: HOW: Object-Animated Objects Tiled?. And Game Framework

Post by qaisjp »

Apply two data's to it "animated" and "animset"
Then in love check those two and draw it.
Lua is not an acronym.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests