Author Topic: Rotation & scaling for sprites with even width / height  (Read 1657 times)

xraven13

  • Active Member
  • ***
  • Posts: 213
  • Karma: +0/-0
    • View Profile
    • GemaNeko
Hi there...

So, I am making Pacman kinda game where every rotation and scaling needs to be really precise because it's a grid based game...

Problem is that all sprites in this game have even width & height or to be more precise they are all 32x32... 
Since 32 is even number, it's impossible to do correct rotation because wrong center pixel is selected... Correct pixel would be 15.5 - 16.5 I think ?  And Flixel "says" that 16 is the middle which is not correct...

Does anyone know is it possible to tweak Flixel to work like this ?  Because I think problem could be in Bitmaps ?  Thanks.

xraven13

  • Active Member
  • ***
  • Posts: 213
  • Karma: +0/-0
    • View Profile
    • GemaNeko
I think problem could be in conversion between integers and real numbers ?

I made a little fix, depending on the angle I change the offset, but it's still not perfect, and it's not best solution for sure... 
No one really encountered this problem ? Is this common or I am making mistake somewhere, I am not sure...

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
First you have to decide what is "right" in your scenario. Then your problem would be more specific in terms of division and/or other stuff.
blog, twitter, Check out my award winning game, Rot Gut:

Alextfish

  • Active Member
  • ***
  • Posts: 174
  • Karma: +0/-0
    • View Profile
I think most Pacman-style games would embed separate sprites for pointing left/right and for pointing up/down, rather than using automatic rotation. That lets you alter the graphics in other ways too if you want to. It's probably the simplest solution in your case.

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
I second with Alextfish.
blog, twitter, Check out my award winning game, Rot Gut:

Foxtacy

  • Aspiring Indie Game Developer, Prototype Musician, Lame Pixel Artist
  • Member
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
    • Need songs? :3
Good afternoon my good friends!

Well, i think i have one possible solution for your problem!

if you want to use only ONE animation sequence, make sure it's pointed DOWN. on the sprite.png file,

Then, you might want to create 4 constants with angle values, such as:

Angles.UP = 90;
Angles.DOWN = 270;
Angles.LEFT  = 0;
Angles.RIGHT = 180;

Or something like that!

Please notice! that the angles, could vary from -180 to 180, 0 to 359, or from 0 radian to 2PI, depending on the method you're using to acquire the angle.

I'm having a BIG trouble with this crazy angle values myself X_X, but i managed to noticed that! :D

Hope i have helped :3
Waiting is wasting