Author Topic: script: Changing Tileset  (Read 5649 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
script: Changing Tileset
« on: 2007-12-17, 12:35:31 PM »
here is the background story:
at a certain point in the game a event takes place. yet i don't know if this event will be: a pressed key, a countdown which comes to zero, the player reaching a certain x/y, or the player touching a plan rectangle (you can imagine more things)
this event will cause a heavy snowstorm. i planned to do something like a layer filled with animated snow/wind tiles, which is shown for a short time and is hiding the other layers.

the main part of my question is: when the snow storm is over, the world/map has been frozen, all things are covered with ice.
i guess the easiest thing would be to change the tilesets several layers are depending on. i could make a normal tileset and one with the same graphics, but freezed.
(maybe is this too tricky. i can imagine another way: to build all my layers twice: with normal and with freezed tiles. but i don't want to, because it is the double amount of time, and i will not have this time when semester end draws near.)

i ask your advice.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: script: Changing Tileset
« Reply #1 on: 2007-12-17, 01:50:22 PM »
One of the major ideas behind tilesets is that they support this inherently.  For example, for every tile you make, use 2 frames instead of the regular 1, where the first is the regular image and the second is the frozen image, and base all of those tiles' animation on a counter called "frozen" or something.  Then, when the world is frozen, increase the counter to 1, which will switch all of the tiles to the frozen image.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: script: Changing Tileset
« Reply #2 on: 2007-12-17, 02:24:54 PM »
hey, sounds good.
but if i would use 2 tilesets instead of one, i had a very big advantage. i could easier create the 2 graphics sheets for that. seeking through maybe a hundred tiles to find the frozen bit, could get annoying.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: script: Changing Tileset
« Reply #3 on: 2007-12-17, 04:10:40 PM »
and what's more, i also need to change the player graphics. he would have a normal look, a wet look and an icy look. but the player states are animated. i think it would be a huge effort to adapt my scripting. i have a lot of problems without that.
also the map tiles are animated, both in their normal and icy look. (ok, not at the moment, but i've planned it)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: script: Changing Tileset
« Reply #4 on: 2007-12-17, 04:59:20 PM »
Well, the sprites can simply have two different groups of states, one for "wet", one for "icy", and when switching states, just switch locally based on the current group.

As for the animations, you can still use a counter for the difference between normal and icy by finding the lowest common multiple (LCM) of the lengths of all of the animations in the animated tiles and resetting the counter to zero when it reaches that value, then add that amount when turning icy.  You would just have something like:

N1 N2 N3 I1 I2 I3

Where N = normal frames, I = Icy frames.  The LCM here is 3.

Another option would be to add 2 instead of 1 to the counter every frame, and interleave the icy frames in between, then offset the counter by 1 when it turns icy.  If you would like an example, just ask.  It would look something like:

N1 I1 N2 I2 N3 I3
Edward Dassmesser

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: script: Changing Tileset
« Reply #5 on: 2007-12-17, 05:06:34 PM »
hey, sounds good.
but if i would use 2 tilesets instead of one, i had a very big advantage. i could easier create the 2 graphics sheets for that. seeking through maybe a hundred tiles to find the frozen bit, could get annoying.

I don't quite understand what you mean here.  The tileset would still contain the same number of tiles, and each tile would represent the both normal and icy.  The tileset can contain graphics from multiple graphic sheets, since it is based on a frameset rather than a graphic sheet.
Edward Dassmesser