Author Topic: Camera/Tilemap Rotation  (Read 2356 times)

ntdb

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Camera/Tilemap Rotation
« on: Sat, Apr 30, 2011 »
Hey all, I have a mechanic in mind that requires a clever bit of work. Using Flixel 2.5, what is the best way to rotate the camera (around the player) or the tilemap (around the tilemap's center)? As the docs say, changing camera.angle produces weird results and seems to break camera follow preferences. I'm open to jerry rigging this however I need to, I'll build off of whatever mechanism I can come up with. Thanks!

And thanks Adam for your work, it's exciting and inspiring!

zadvornykh

  • Active Member
  • ***
  • Posts: 205
  • Karma: +1/-0
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #1 on: Sun, May 1, 2011 »
Rotate around which axis (x, y, z)?

Can you just rotate the world?

ntdb

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #2 on: Sun, May 1, 2011 »
FlxTilemaps resist rotation because of the way they read in tile data I believe. Right now I'm rotating the camera (requires adjusting the x/y values of the camera as it turns) but looking for a better solution, it really makes fun controls difficult.

auriplane

  • Snails!!
  • Contributor
  • ****
  • Posts: 497
  • Karma: +1/-0
  • Snails!!
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #3 on: Sun, May 1, 2011 »
How big is the map?  Is it too expensive to make pre-rotated versions of the map, and rotate actor coordinates when switching tilemaps?

KWarp

  • Active Member
  • ***
  • Posts: 105
  • Karma: +0/-0
  • Game Programmer
    • View Profile
    • kwarp.com
Re: Camera/Tilemap Rotation
« Reply #4 on: Mon, May 2, 2011 »
If your main mechanic is rotation, you might want to consider plain-old Flash and ditch FlxTilemaps entirely. Rendering rotated bitmaps is just as slow as the standard Flash renderer.

To understand recursion, you must first understand recursion.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: Camera/Tilemap Rotation
« Reply #5 on: Mon, May 2, 2011 »
without too much pain/suffering i think you could extend flxtilemap to be able to do rotation in a cool way.  the thing about the tilemaps is they render themselves to a buffer, so they're not doing a bunch of unnecessary drawing, etc.  but you could extend flxtilemap to have different behavior and still have decent performance i think.

if i was going to do this, my approach would go something like:

  • extend flxtilemap and have it create a buffer that is twice the size of the screen, instead of same size
  • update the "dirty" check in .draw() to make sense with the rotation stuff
  • rig up some new follow behavior to make sure the origin of theflxtilemap buffer is always at the player center

HOWEVER this would mean that any items in the world that weren't part of the tilemap would have to be rotated around separately, whcih could be quite CPU intensive, depending.

what i suspect you want is essentially to not really move ANYthing around, nor rotate the tilemap, but simply rotate the display of the world so that the player is always facing up, or something like that.  eventually this will be pretty easy to do with the camera system, you'll just have to create a pretty large camera buffer so it can rotate safely, and the player sprite might alias or blur a little unless you specifically render the player in his own special camera or something.

however, currently the camera system rotation and scaling just uses the native flash style, which means that for the camera to rotate and scale properly it needs to be couched in an extra display object so that flash can handle that offset.  this is actually pretty easy, and it's at the very top of my to-do list, but it just hasn't happened yet.  since it won't affect the external API, and i can easily test it in mode, i might actually try putting that in tomorrow, its so silly that you can't scale or rotate cameras intuitively!

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: Camera/Tilemap Rotation
« Reply #6 on: Mon, May 2, 2011 »
ok, the beta branch has WAY better rotation and scaling options for cameras, have fun!!

ntdb

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #7 on: Tue, May 3, 2011 »
Haha I just saw the joke mode on twitter. Thanks a bunch, I look forward to giving it a shot. I'm confident that camera rotation will be the best way to go, it's just a matter of tuning physics/movement properly at this point.

dylanjbray

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #8 on: Mon, Jul 4, 2011 »
Hi,

Just started using Flixel, really solid framework!

I pulled this down from the Beta branch and I've been playing with rotating the camera.  Currently it looks like the centerpoint the camera rotates around doesn't adjust for the zoom level, resulting in odd behaviour for anything other than 1:1 zoom.  For example, a zoom level of 2 results in the camera rotating around the bottom right-hand corner of the screen.

Any ideas on how to go about fixing this?

Cheers,

Dylan

MRKSTWRT

  • Active Member
  • ***
  • Posts: 116
  • Karma: +0/-0
    • View Profile
Re: Camera/Tilemap Rotation
« Reply #9 on: Tue, Jul 5, 2011 »
Dylan are you sure the Flash Player has the corret resolution for your game ((game width x game height) * zoom)?