Alternative approach to rotating egg powerup.
authorLMH <lmh.0013@gmail.com>
Sat, 8 Mar 2014 19:53:47 +0000 (09:53 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 8 Mar 2014 19:53:47 +0000 (09:53 -1000)
Instead of using successive images of the egg rotated at different angles, a single egg image is used and rotated dependent on horizontal displacement.  This significantly reduces the number of images used, and also shortens the code a bit.

23 files changed:
data/images/powerups/egg/egg-0.png [deleted file]
data/images/powerups/egg/egg-1.png [deleted file]
data/images/powerups/egg/egg-10.png [deleted file]
data/images/powerups/egg/egg-11.png [deleted file]
data/images/powerups/egg/egg-12.png [deleted file]
data/images/powerups/egg/egg-13.png [deleted file]
data/images/powerups/egg/egg-14.png [deleted file]
data/images/powerups/egg/egg-15.png [deleted file]
data/images/powerups/egg/egg-16.png [deleted file]
data/images/powerups/egg/egg-17.png [deleted file]
data/images/powerups/egg/egg-18.png [deleted file]
data/images/powerups/egg/egg-19.png [deleted file]
data/images/powerups/egg/egg-2.png [deleted file]
data/images/powerups/egg/egg-3.png [deleted file]
data/images/powerups/egg/egg-4.png [deleted file]
data/images/powerups/egg/egg-5.png [deleted file]
data/images/powerups/egg/egg-6.png [deleted file]
data/images/powerups/egg/egg-7.png [deleted file]
data/images/powerups/egg/egg-8.png [deleted file]
data/images/powerups/egg/egg-9.png [deleted file]
data/images/powerups/egg/egg.png [new file with mode: 0644]
data/images/powerups/egg/egg.sprite
src/object/growup.cpp

diff --git a/data/images/powerups/egg/egg-0.png b/data/images/powerups/egg/egg-0.png
deleted file mode 100644 (file)
index 6f63e35..0000000
Binary files a/data/images/powerups/egg/egg-0.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-1.png b/data/images/powerups/egg/egg-1.png
deleted file mode 100644 (file)
index 863b78b..0000000
Binary files a/data/images/powerups/egg/egg-1.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-10.png b/data/images/powerups/egg/egg-10.png
deleted file mode 100644 (file)
index cb804d7..0000000
Binary files a/data/images/powerups/egg/egg-10.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-11.png b/data/images/powerups/egg/egg-11.png
deleted file mode 100644 (file)
index 9e326b2..0000000
Binary files a/data/images/powerups/egg/egg-11.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-12.png b/data/images/powerups/egg/egg-12.png
deleted file mode 100644 (file)
index 1ee1f18..0000000
Binary files a/data/images/powerups/egg/egg-12.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-13.png b/data/images/powerups/egg/egg-13.png
deleted file mode 100644 (file)
index 2b5e0a5..0000000
Binary files a/data/images/powerups/egg/egg-13.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-14.png b/data/images/powerups/egg/egg-14.png
deleted file mode 100644 (file)
index 707fc97..0000000
Binary files a/data/images/powerups/egg/egg-14.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-15.png b/data/images/powerups/egg/egg-15.png
deleted file mode 100644 (file)
index 37266c8..0000000
Binary files a/data/images/powerups/egg/egg-15.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-16.png b/data/images/powerups/egg/egg-16.png
deleted file mode 100644 (file)
index 9e24d1c..0000000
Binary files a/data/images/powerups/egg/egg-16.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-17.png b/data/images/powerups/egg/egg-17.png
deleted file mode 100644 (file)
index a6193d4..0000000
Binary files a/data/images/powerups/egg/egg-17.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-18.png b/data/images/powerups/egg/egg-18.png
deleted file mode 100644 (file)
index e064139..0000000
Binary files a/data/images/powerups/egg/egg-18.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-19.png b/data/images/powerups/egg/egg-19.png
deleted file mode 100644 (file)
index cd2e385..0000000
Binary files a/data/images/powerups/egg/egg-19.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-2.png b/data/images/powerups/egg/egg-2.png
deleted file mode 100644 (file)
index ed6b220..0000000
Binary files a/data/images/powerups/egg/egg-2.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-3.png b/data/images/powerups/egg/egg-3.png
deleted file mode 100644 (file)
index e0f4bbb..0000000
Binary files a/data/images/powerups/egg/egg-3.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-4.png b/data/images/powerups/egg/egg-4.png
deleted file mode 100644 (file)
index e041ad7..0000000
Binary files a/data/images/powerups/egg/egg-4.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-5.png b/data/images/powerups/egg/egg-5.png
deleted file mode 100644 (file)
index 0fc79ce..0000000
Binary files a/data/images/powerups/egg/egg-5.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-6.png b/data/images/powerups/egg/egg-6.png
deleted file mode 100644 (file)
index fd2bfb3..0000000
Binary files a/data/images/powerups/egg/egg-6.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-7.png b/data/images/powerups/egg/egg-7.png
deleted file mode 100644 (file)
index d9426ab..0000000
Binary files a/data/images/powerups/egg/egg-7.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-8.png b/data/images/powerups/egg/egg-8.png
deleted file mode 100644 (file)
index 9a7fc19..0000000
Binary files a/data/images/powerups/egg/egg-8.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg-9.png b/data/images/powerups/egg/egg-9.png
deleted file mode 100644 (file)
index ff38eaf..0000000
Binary files a/data/images/powerups/egg/egg-9.png and /dev/null differ
diff --git a/data/images/powerups/egg/egg.png b/data/images/powerups/egg/egg.png
new file mode 100644 (file)
index 0000000..6f63e35
Binary files /dev/null and b/data/images/powerups/egg/egg.png differ
index df9f2c1..d1eac26 100644 (file)
@@ -1,31 +1,7 @@
 (supertux-sprite
        (action
-         (name "right")
-         (images "egg-0.png"
-                        "egg-1.png"
-                 "egg-2.png"
-                 "egg-3.png"
-                 "egg-4.png"
-                 "egg-5.png"
-                 "egg-6.png"
-                 "egg-7.png"
-                 "egg-8.png"
-                 "egg-9.png"
-                 "egg-10.png"
-                 "egg-11.png"
-                 "egg-12.png"
-                 "egg-13.png"
-                 "egg-14.png"
-                 "egg-16.png"
-                 "egg-17.png"
-                 "egg-18.png"
-        )
-        (fps 20)
-        )
-            (action
-                (name "left")
-                (mirror-action "right")
-                        (fps 20)
+         (name "default")
+         (images "egg.png")
        )        
 )
 
index 1bc7fcc..e4c32b0 100644 (file)
@@ -14,6 +14,8 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include <math.h>
+
 #include "audio/sound_manager.hpp"
 #include "object/growup.hpp"
 #include "object/player.hpp"
@@ -32,8 +34,6 @@ GrowUp::GrowUp(Direction direction) :
   //set light for glow effect
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.2f, 0.2f, 0.0f));
-  
-  sprite->set_action((direction == LEFT) ? "left" : "right");
 }
 
 void
@@ -44,6 +44,8 @@ GrowUp::update(float elapsed_time)
 
 void
 GrowUp::draw(DrawingContext& context){
+  //Set Sprite rotation angle
+  sprite->set_angle(get_pos().x * 360.0f / (32.0f * M_PI));
   //Draw the Sprite.
   MovingSprite::draw(context);
   //Draw the light when dark
@@ -63,15 +65,8 @@ GrowUp::collision_solid(const CollisionHit& hit)
     physic.set_velocity_y(0);
   if(hit.bottom && physic.get_velocity_y() > 0)
     physic.set_velocity_y(0);
-  if(hit.left || hit.right) {
+  if(hit.left || hit.right)
     physic.set_velocity_x(-physic.get_velocity_x());
-    if(hit.left)
-      sprite->set_action("right");
-    else {
-      sprite->set_action("left");
-    }
-
-  }
 }
 
 HitResponse