Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Tanja on 2007-11-27, 06:41:07 AM

Title: animated tiles
Post by: Tanja on 2007-11-27, 06:41:07 AM
my problem is a little bit different from that in jams thread back in march, and since his thread is very old...

i made an animated tile with the tileset editor, and in the preview window it works fine. but the tile is not animated when i add it to the layer.
do i have to create some "anim tile definition"?
could the problem be that i made my tileset bigger to draw the needed tiles into it, long after i used it to create the layer? (i added the new tiles properly to the frameset and tileset, though)

i go and try it with a new graphic sheet...
edit: no, that won't work.  i used a older but unused graphic sheet, and made the same animation. but without success in animating it in a new layer.
even with a completely new graphic sheet it won't work. so, it must be scripted anywhere?
Title: Re: animated tiles
Post by: bluemonkmn on 2007-11-27, 07:48:59 AM
If the tile is animated in the Tileset preview, but not when you run the game, it probably means you didn't make a rule to increase the counter associated with the tile.  The counter does not increase automatically.  Your rules are totally in charge of when the counter changes.
Title: Re: animated tiles
Post by: Tanja on 2007-11-27, 07:53:47 AM
indeed i hadn't a rule for that. i'll try to make one.
Title: Re: animated tiles
Post by: Tanja on 2007-11-27, 01:18:49 PM
it works. hooray!
depends a counter always on the frame rate? how can i prevent things playing faster or slower at different computers?
Title: Re: animated tiles
Post by: bluemonkmn on 2007-11-28, 07:21:29 AM
I have not implemented built-in support for time-based animation in version 2.0, but I might improve that for 2.1.  However, you can implement your own time-based features.  For example, instead of incrementing the counter every frame, you could set it to be equal to the number of tenths of seconds since the beginning of today with some expression like this (using the "=" function output to Counter.CurrentValue):
Code: [Select]
(int)(System.DateTime.Now.Subtract(System.DateTime.Today).TotalSeconds * 10)(Not sure if that's exactly correct, but hopefully it's close.)

Be careful how you set the maximum counter value.  Make sure it's big enough to hold the number of seconds in a day * 10. (10*60*60*24=864000)
See information about System.DateTime.Subtract here:
http://msdn2.microsoft.com/en-us/library/8ysw4sby.aspx (http://msdn2.microsoft.com/en-us/library/8ysw4sby.aspx)
Title: Re: animated tiles
Post by: Tanja on 2007-11-28, 07:42:14 AM
Argument '2': cannot convert from 'int' to 'CounterOperation'

you have written (int) before that other stuff. i often get the message a "double" or other values (?) couldn't be converted to an "int". is there a list of what conversions work? and what the meaning of int, double, ref and so on is. how and where they are used.
Title: Re: animated tiles
Post by: bluemonkmn on 2007-11-28, 07:51:12 AM
The "=" function does not take a CounterOperation parameter. Are you sure you selected the right function?  I have to go to work, so I can't explain conversions in more detail right now, but hopefully this will help.
Title: Re: animated tiles
Post by: Tanja on 2007-11-28, 08:23:42 AM
(using the "=" function output to Counter.CurrentValue)

sorry, my fault. first it didn't work, but then i realized MY counter is not given in the expression. so i wrote: Counter.New_Counter_1.CurrentValue ;D
hooray!
Title: Re: animated tiles
Post by: Tanja on 2007-12-17, 03:53:20 PM
I have not implemented built-in support for time-based animation in version 2.0, but I might improve that for 2.1.

please do so!
i would need it. the counter you have shown me counts constantly, but its value changes the whole day, and i don't know how to make it count a timespan like 5 seconds.

edit:
but because animated tiles are involved, i could perhaps do a trick, couldn't i? i let do a tile animation based on your counter. and when the tile animation reaches a certain frame, i have got my 5 seconds! gotta try that....
Title: Re: animated tiles
Post by: bluemonkmn on 2007-12-17, 05:28:57 PM
Using a timer for a counter value on an animation that doesn't loop won't work well because the counter won't start at 0, so the animation won't start on the first frame.  I don't understand how you could have a tile that should only animate for 5 second, though.  What kind of tile only animates for 5 seconds?
Title: Re: animated tiles
Post by: Tanja on 2007-12-18, 03:30:31 AM
i wanted to make the snowstorm with it. when the player touches a plan rectangle, a snowstorm map will be set for overlay. the snowstorm is supposed to last for 5 seconds. the snowstorm tiles shall be animated. i thougt i could make an animation for these tiles, and at the end of the five seconds they vanish into thin air (animation drawn by me). at his point the five seconds are over and the overlay map can disappear.
Title: Re: animated tiles
Post by: bluemonkmn on 2007-12-18, 08:12:40 AM
Oh, then it doesn't matter where the animation begins or ends, just that it lasts 5 seconds.  Maybe when the snowstorm is triggered you could use the "=" function to copy the value of the timer counter to another counter and add 50 (5 seconds in tenth-of-second counter units).  Like
Function: =
Value: 50+StormCounter.CurrentValue
Output: TimerCounter.CurrentValue

Then have another rule to check when TimerCounter >= StormCounter, and when true, clear the overlay map.
Title: Re: animated tiles
Post by: Tanja on 2007-12-18, 01:39:04 PM
fine, i got the same idea as you, with this counter value + number of custom frames.
this should work.
Title: Re: animated tiles
Post by: Tanja on 2008-01-08, 08:20:40 AM
is the frame number of a tile animation always equal to the actual value of its counter?

Oh, then it doesn't matter where the animation begins or ends, just that it lasts 5 seconds.

because it does matters, the storm has an end and a beginning.
Title: Re: animated tiles
Post by: bluemonkmn on 2008-01-08, 08:45:05 PM
is the frame number of a tile animation always equal to the actual value of its counter?
Yes, with a couple notes:
1. Don't forget about the repeat count.  If the repeat count of all your frames is 10, and the counter value is 15, then you will only be looking at the second distinct frame.
2. The animation loops, of course, so if you have 3 frames (each with repeat count of 10), then when the counter value is 35, you will be looking at the first frame again, and when it is 45, you will be looking at the second frame again.
Title: Re: animated tiles
Post by: Tanja on 2008-01-09, 03:06:36 AM
yeah okay. i dismissed the real time counter now and hope the storm will not look silly on some computers. like said, a build-in time-based feature would be a good thing  ;D