Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite Rotation
#1
I see in the documentation that there is a flag for setting the sprite rotation. However, there is a comment next to FLAG_ROTATE that says "unsupported, Tilted compatibility". 

Does this mean that as Tilengine currently stands (release 1.20) that sprites cannot be rotated? If this is the case, is there an explanation as to why sprites cannot be rotated if using Tiled? Was this flag included with the intent that they can be rotated in future releases?
Reply
#2
Hi Daniel,

Tilengine reads the FLIP_X and FLIP_Y flags from Tiled editor to do horizontal and/or vertical flipping of tiles and sprites. Tiled later added the ROTATION flag that swaps x/y axis. Combined with the other two flags, this allows it to do simple rotation in 90º steps. This feature isn't supported by the Tilengine renderer, as it is not representative of 2D graphics hardware. Backgrounds can be rotated with TLN_SetLayerTransform() 

At this moment sprites don't support any kind of rotation yet (just scaling with TLN_SetSpriteScaling()) but I plan on adding full 360º rotation in a future release. I have an internal version that has preliminar support, but combining sprite rotation with raster effects and keep good performance is not trivial...
Reply
#3
(05-18-2018, 05:37 PM)megamarc Wrote: At this moment sprites don't support any kind of rotation yet (just scaling with TLN_SetSpriteScaling()) but I plan on adding full 360º rotation in a future release. I have an internal version that has preliminar support, but combining sprite rotation with raster effects and keep good performance is not trivial...

Heh that's why SNES had dedicated hardware for that, and even then, it only worked as a raster effect on backgrounds!  That's why the entire background is black in the first boss battle in Super Mario World - the rotating dinosaur boss, as tiny as he is, is actually a "background" in the system!  (megamarc probably already knows this but I like talking about it)

Also if you did implement it, I would expect it to not have any anti-aliasing and be all pixelated and "twinkly" as it rotates around, the same way it looked back then Smile Back when I first played it as a teenager, when my best friend and I first saw that effect (on that boss actually, when the SNES came out), we decided to call it "pixel movement" because it appeared to be moving each individual pixel.  We wanted to name it because we hadn't seen it before and it was something only the SNES could do.
Reply
#4
Of course! Don't expect any kind of anti-aliasing, just the good-old blocky pixels. This is not an intended feature, just a side effect of how real 2D tiled hardware works.

In fact only few high-end arcade boards supported sprite rotation. As you say, the SNES rotated a background layer, not sprites. And the Neo*Geo had tile scaling (just shrinking to be exact, not upscaling), and no rotation of any kind. The scaling dinosaur boss in Super Mario World, and the bosses of levels 2 and 5 in Super Contra 3 were in fact backgrounds.

Rotating a background is quite trivial, as for each pixel in the whole screen, there's a corresponding source pixel in the background. But for sprites that's not the case. Determining coverage area on each scanline is complex because not all pixels are covered by the sprite, and even inside the boundin box area not all destination pixels have a corresponding source pixel. And it must be done in few calculations to keep high framerate, with as much caching and LUT tables as possible...

Have you tried the new features? Full background bitmaps and mouse support should enable you to do "Worms" without much effort
Reply
#5
Thanks for the response. I enjoy reading some of these threads where you guys share your knowledge of retro games. It's very interesting.

So how does it work with 45º rotation? Would one have to just use an additional sprite image drawn at 45º?
Reply
#6
I'm glad you enjoy the comments here :-)

Classic 2D hardware didn't allow rotation, games with pseudo rotation had some frames drawn pre-rotated between 0 and 90º, and combining them with horizontal and vertical flip simulated full 360º rotation. For 45º, yes, you need a frame drawn at this angle.
Reply
#7
(05-30-2018, 05:40 AM)Daniel H. Wrote: Thanks for the response. I enjoy reading some of these threads where you guys share your knowledge of retro games. It's very interesting.

So how does it work with 45º rotation? Would one have to just use an additional sprite image drawn at 45º?

Check out this 2nd level boss from Super Contra 3 / Super Probotector (I prefer the latter, because it's the version we grew up with and robots are way cooler than humans)
https://youtu.be/pybOtiV2ggI?t=601

The level previous to this boss has a cool top-down mode where instead of rotating the player, the whole background rotates instead, so "up" is always "forward".  This background uses the scaling/rotating feature as you'd expect.

But when the boss appears, it scales and rotates the whole time, on a background that is still rotating with the player when he turns around!  How is that possible when only one background can be scaled and rotated?  Well the boss is actually using the background rotating & scaling feature.  The road itself is just a pile of tricks!

It's my guess that the white lines are just being drawn in real time using line drawing code or something, using a flat colour because they're just boxes.  But the cracks in the road are just sprites!  If you watch them closely, they snap between 8 degrees of angles.  So there's actually 8 pre-drawn crack sprites at different angles.  And the rest of the road is just a flat fill colour. This is why the background looks so much simpler here than in the level previous.

It's a technical marvel, and well worth it - it blew our little minds; it was very cinematic and dramatic, with the boss zooming in and out, and the view rotating and panning - while other games were just scrolling left to right.

(05-28-2018, 01:09 AM)megamarc Wrote: Have you tried the new features? Full background bitmaps and mouse support should enable you to do "Worms" without much effort

I will definitely have to have a play with it!  I think Godot can do it, but I've yet to finish my other game first.  In any case I will need to play around with Tilengine even if I don't go with it for my main project, it's very tempting.
Reply
#8
Hi Domarius,
I checked the level 2 rotating Contra 3 boss, and it's tricky! The white paint road lines create a illusion of two independent rotation planes, something that the SNES definitely couldn't do. I don't know what trick they used, this kind of hardware doesn't have direct framebuffer access where you can draw arbitrary shapes. Everything must be converted to sprites or tilemaps. But that's the charm of smart developers, the illusions they can create with a limited set of resources.
Reply
#9
I can only imagine how tough that Contra 3 boss battle must've been to code! I'm sure those early game developers were very creative individuals.
Reply
#10
Yes, those developers were really skilled and clever people. We're used today to high-level languages with much abstraction, and source code editors with advanced navigation tools. But all those programs were coded in pure assembly language, with basic text editors under sereve constraints of memory and cpu power. So it's not only the things they managed to do, but also the tools and environment used.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)