Skip to content

Commit

Permalink
Alternative approach to rotating egg powerup.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LMH0013 committed Mar 8, 2014
1 parent a73d9e6 commit 516867a
Show file tree
Hide file tree
Showing 22 changed files with 7 additions and 36 deletions.
Binary file removed data/images/powerups/egg/egg-1.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-10.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-11.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-12.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-13.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-14.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-15.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-16.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-17.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-18.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-19.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-2.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-3.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-4.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-5.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-6.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-7.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-8.png
Binary file not shown.
Binary file removed data/images/powerups/egg/egg-9.png
Binary file not shown.
File renamed without changes
28 changes: 2 additions & 26 deletions data/images/powerups/egg/egg.sprite
Original file line number Diff line number Diff line change
@@ -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")
)
)

15 changes: 5 additions & 10 deletions src/object/growup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 516867a

Please sign in to comment.