PDA

View Full Version : ANIMS ARE CRAZY


Violet CLM
Oct 16, 2010, 02:16 AM
<a href="http://www.tachyonlabs.com/sam/crazyanims.j2l">EVERYONE
THIS IS AMAZING!!!</a>

I was playing around with my python implementation of .j2l files and surreptitiously adding what I thought were new features, and then it occurred to me to check if JJ2 actually had them already... and it DOES. JJ2 (but not JCS, of course) <em>lets you use flipped tiles and <strong>other animations</strong> for animated tile frames.</em>

MIND: BLOWN.
<span style="font-size:3pt;">(my earlier attempt to change the order of the layers through the .j2l file was, unfortunately, unsuccessful.)
(also it doesn't work in TSF; you'd need different values)</span>

ETA: I am trying to get it to work in TSF but I think j2ff doesn't support it, so I need to roll my own; be patient.
ETA2: <a href="http://www.tachyonlabs.com/sam/practicalexample.j2l">Here</a>'s another 1.23-style example for cooba, showing that, in combination with belts and Reworder, working electric barriers can indeed be made. Uses Newspaz's Tubelectric conversion.

EvilMike
Oct 16, 2010, 02:30 AM
It's too bad it doesn't work in TSF (and outright crashes it). This limits what you can really do with this, since your level is basically 1.23-only.

It would be nice to see an implementation of this using the 1.24 level format, because those at least can't be opened in 1.23, and thus can't crash it. Also, anyone using this feature won't have to tell people that their level is "1.23-only", which as far as I know, has never been necessary in the past.

Violet CLM
Oct 16, 2010, 03:37 AM
<a href="http://www.tachyonlabs.com/sam/crazyanimstsf.j2l">TSF implementation</a>. It looks like 1.24 only can handle animated tiles as frames, not flipped tiles (signage issue, no doubt), but those are the more exciting cases anyway.

Nerd
Oct 16, 2010, 04:00 AM
I had something like this in mind, but never bothered to check if it would actually work (as I was quite sceptical about it, and am not a JCSer anyway). Nice find, and will come in handy for making animated scenery blocks.

Slaz
Oct 16, 2010, 04:55 AM
I'd say this has even more value in TSF since tileset size will come in handy for big complex animations and puzzles! ;)

minmay
Oct 16, 2010, 06:12 AM
Could you elaborate on how exactly animated tiles as frames in other animations behave? The examples only show a little bit.

(And could someone hurry up with JCS+ already? I really want to incorporate this into Episodic Ground Force Pack Episode 2.)

Dermo
Oct 16, 2010, 08:33 AM
I'm assuming opening this in JCS will break the levels. What's the exact name of the tileset for the second one?

Also your levels would have been winners if they were submitted into the contest (http://www.jazz2online.com/jcf/showthread.php?t=18859).

Violet CLM
Oct 16, 2010, 11:42 AM
minmay: sure!
In a level's dictionary, tiles are referred to through shorts. Using 1.23 numbers for reference, values 0-1023 for those shorts refer to unflipped tiles, and 1024-2047 to flipped tiles. Within each of those ranges, up to 1020 of those tiles are actual 32x32 images from the tileset, whereas the rest are potentially animated tiles, starting from 1023 (and 2047) and working back down. So a level with a 10 tile tileset and two animated tiles would, assuming everything appears flipped, have values 0,1,2,3,4,5,6,7,8,9; 1022,1023; 1024,1025,1026,1027,1028,1029,1030,1031, 1032, 1033; 2046, 2047. What's important is that a single value, with no parameters elsewhere, tells JCS/JJ2 whether to load a flipped or unflipped and animated or unanimated tile for display and other interaction.

Now, animated tiles are themselves stored in the .j2l as a series of frames, and each of those frames is described by a short. As it turns out, that short uses the same function as does the rest of the game for figuring out which tile, flipped tile, animated tile, or flipped animated tile to display as a frame. Consequently, hex-editing values higher than the tile count into the frame of an animation can give crazy results.

Once you get to the actual display of this ingame, just speaking theoretically, there are at least two possible ways JJ2 could handle animated tiles. Minimally, the frame displayed at any given time for an animated tile, ignoring the cases of destruct scenery and other such events freezing animations regardless of speed, depends on how much time has elapsed since the beginning of the level (call it the gametick), the speed of the animation, and the sequence of frames within it.

So, one way JJ2 could handle this would be every gametick to see which animations should advance a frame and update all dictionary words containing that animation accordingly. The words, as stored in memory, would not actually contain animated tiles; instead, a separate list of where animated tiles appear in words would know which tiles to update and how often. However, this is not what JJ2 appears to do, perhaps because it would interact poorly with destruct scenery, perhaps for optimization reasons, perhaps arbitrarily.

Instead, based on this, it looks like every time JJ2 draws a tile to the screen, it uses a figure-out-which-tile-this-really-is function on the short value originally stored in the .j2l. If it's a simple tile, it just grabs that 32x32 image. If it's an animation, it asks the animation what its current frame is, and then uses the same figuring out function on the number the animation gives it, which can in turn refer to another animation, causing JJ2 to ask again what the current frame to display should be. I haven't tried, but I see no reason why you could not continue down this line, embedding animations into other embedded animations, until you hit the limit, although I assume any recursion would crash the game.

Functionally: suppose you have an animation A of a dancing flower. You also have a two-tile animation B, with speed 1, whose first frame is a blank tile and whose second frame is animation A. Whenever animation B is displaying its first frame, it will appear blank. But when it's displaying its second frame, the player will see whichever frame of animation A is the current one as determined by combining A's own speed and frame sequence with the gametick.

Dermo: I think it's the tileset <a href="http://www.jazz2online.com/downloads/1270/super-sparks/">in this upload.</a>

ETA: Here, have a visual example. Given two normal animations, and one animation half the speed of the other two which switches back and forth between them, you should get a sequence like on the bottom. Of course, if the first two animations had different speeds and/or lengths, then that would make for a less regular pattern; alternatively, you might want to do something like put a trigger scenery event on the two-frame animation, to switch the level back and forth between all dancing mushrooms and all dancing flowers.
<img src="http://www.tachyonlabs.com/sam/visualanims.png">

minmay
Oct 16, 2010, 12:14 PM
ETA: Here, have a visual example. Given two normal animations, and one animation half the speed of the other two which switches back and forth between them, you should get a sequence like on the bottom. Of course, if the first two animations had different speeds and/or lengths, then that would make for a less regular pattern; alternatively, you might want to do something like put a trigger scenery event on the two-frame animation, to switch the level back and forth between all dancing mushrooms and all dancing flowers.
<img src="http://www.tachyonlabs.com/sam/visualanims.png">
This is the interaction I was most curious about. Thanks.

By the way, <a href="http://www.cowmuffins.net/stuff/jcsinsanity.png">JCS does not like trying to display these.</a> And, in response to Dermo's question, you get some nice access violations.

Violet CLM
Oct 16, 2010, 12:51 PM
Yeah, JCS just doesn't know what to do with them. I have no answer at all for why it grabs zoomed out versions of other tiles from the tileset.

Obi1mcd
Oct 16, 2010, 03:22 PM
Wow, this is awesome. I sort of wondered if something like this could be done, but I have zero technical skills, and wouldn't know how anyway. Great job, this could be really useful in levels. Would it then be possible to use trigger scenery to swap from one animating tile to another?

n0
Oct 16, 2010, 08:26 PM
Freaking. Awesome. Between this and Reworder, you can do... anything!

Violet CLM
Oct 17, 2010, 02:47 PM
Speaking of Reworder, I'm just leaving <a href="http://www.tachyonlabs.com/sam/crazyanims3.j2l">this</a> here because I'm not totally sure myself why it does what it does. Minimally, the crates on the right turn the trigger on, and the crates on the left turn the trigger off. If you turn it on, then off, it will be off forever; if you turn it off, then on, it will be on forever; if you die, things go wonky, so this is best restricted to multiplayer levels.

(Normally, if you try to link two words with Reworder and have destruct/etc. events on the same animation in each, they'll go blank. I realized that this is because the first event restricts display to the first frame of the animation, and then the second event tries to read that frame as an animation and fails. So I gave it an animation as a first frame, and this is what happened.)

GoldRabbit
Oct 18, 2010, 04:12 AM
Would it be possible to create an infinite loop?
Say, in an online game, you want an area to be occupied by only one person at a time. Person enters area, automatically destroys trigger crate, thus locking himself in that area. Same person exits area by destroying another crate, leaving the area empty. Can the cycle continue? As in, another person comes, destroys first crate, locks himself etc. or same person comes and does the same thing again.

I'm really interested as this could help IMMENSELY with my level and with many interesting concepts, for that matter.

Jgke
Oct 18, 2010, 05:55 AM
It could be done with MCE crates, but they don't work properly in multiplayer. I can send you a level with an example of this room, but it works properly only in singleplayer.

Stijn
Oct 18, 2010, 10:02 AM
What happens when you use an animation as a frame in itself?

Probably the game crashes, but who knows! It could be awesome!

Foly
Oct 18, 2010, 10:10 AM
I've been learning pascal in delphi lately, I still only know the basics but I'm wondering: Is there something specific I need to know to start modifying j2l files/jcs or do I just need to continue and wait till I learn required functions (like readfile functions or something like that).

Violet CLM
Oct 18, 2010, 12:37 PM
TBD (am I abbreviating that right?): I don't <em>think</em> so, While I don't want to say that for sure yet until I've made one or two more tests, it seems unlikely, since trigger crates can only turn triggers on, and if the trigger is already on, they don't turn it on again, they just have no effect. (Yes, the difference is observable.)

Stijn: I'd been holding off on that because I assumed it would just crash, but I tried it just for you, and JJ2 crashed as quickly as it possibly could.

Foly: To the extent that you need anything specific, it would definitely be the required functions. But I guess that's not really a helpful reply. For any more systematic editing of .j2l et. al files, you'll want to be able to read and write files (including ascii values, not just plain text), use zlib compression and decompression, and calculate CRC32 checksums. Occasionally you'll need to understand bitwise operations, but only rarely. Everything else is just basic programming. What I'm doing here, though, just changing individual values in data1, requires no more than a hex editor and <a href="http://downlink.lordprime.com/jazzjackrabbit/2/code/j2ff.zip">j2ff</a>, which hopefully Overlord doesn't mind me sharing the link to. (Only seems to work for 1.23 levels.) Animated tiles aren't documented anywhere, but they have a pretty simple storage format and begin at offset 15988 in data1.

djazz
May 23, 2011, 12:21 PM
I'm happy to announce that WebJCS (https://chrome.google.com/webstore/detail/aknledcfpmoikjolpgdpadhmhnbemnjd) now supports "crazy animations", both flipped tiles and other animations can be used as frames. You can't save yet in WebJCS, and only do simple drawing, but viewing works great!
Crazy Anims in WebJCS (http://i.imgur.com/K5SxV.png)


Edit:
Above WebJCS link is outdated, use the link to the WebJCS thread (http://www.jazz2online.com/jcf/showthread.php?p=471684#post471684) instead.
With this new version, you can save your Crazy Animations!

Ktos.
May 25, 2011, 10:42 AM
I have got a question, would that be possibile to create a standard tile without animation at the beggining, but after shooting it, could it be possibile for those four pieces of tile to display animation after destroying it?

Nerd
May 25, 2011, 11:47 AM
It's perfectly possible, done in the same fashion as the other examples. I tested it and JJ2 didn't crash.

Violet CLM
May 25, 2011, 01:29 PM
However, if you're looking for a way to have the four pieces slowly fade away or something, that probably won't happen. The animation of the four pieces is in sync with any other instances of that animation in the level, it doesn't begin when the tile is destroyed.

djazz
Nov 20, 2011, 09:35 AM
I asked the JCS creator Michiel if he knew this while making JCS, here is his answer:
I didn't know about the recursive animation. Is that different between hardware accelerated (DirectDraw) and software modes? I think it may have been a side-effect of caching tiles to DDraw surfaces in 4x1 chunks, and I vaguely remember resolving tile pointers in a cached list once per frame as all of the rendering was hand-coded in assembly and the extra indirection would hurt. It's been a while though. Still cool that you guys found this out. Keep on hacking guys!

He's very impressed with WebJCS and he also said:
You know I expect a fully-working web version of JJ2 at some point (feel free to use the binary source assets). Somebody's got to do it...

While he was there I also asked about the source code of JCS:
I think I may have the old source code JJ2 and JCS at work somewhere, but I similarly remember that I lost it somewhere in a crash/move/whatever.

Google+ ftw (https://plus.google.com/u/0/117867264011846764007/)!

Violet CLM
Nov 20, 2011, 09:43 AM
I vaguely remember resolving tile pointers in a cached list once per frame
Well, that would do it! Nice. Anything you can do to, uh, encourage him to determine whether the source codes (mostly JJ2, since pretty much all we could really get from JCS at this point would potentially be the names of some seemingly useless bytes) were indeed lost would of course be tremendously appreciated. :P