Skip to content

Commit

Permalink
Owl: Added initial code for an "Owl" badguy.
Browse files Browse the repository at this point in the history
Graphics are based on a drawing by Grumbel. The badguy simply flies from right
to left for now.

SVN-Revision: 6558
  • Loading branch information
Florian Forster committed Mar 6, 2010
1 parent c171b6f commit 47acf21
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 0 deletions.
Binary file added data/images/creatures/owl/left-0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/owl/left-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/owl/left-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/owl/left-3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/owl/left-4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/owl/left-5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions data/images/creatures/owl/owl.sprite
@@ -0,0 +1,18 @@
(supertux-sprite
(action
(name "left")
(fps 10.0)
(hitbox 14 7 35 45)
(images "left-0.png"
"left-1.png"
"left-2.png"
"left-3.png"
"left-4.png"
"left-5.png"))

(action
(name "right")
(fps 10.0)
(hitbox 14 7 35 45)
(mirror-action "left"))
)
163 changes: 163 additions & 0 deletions data/levels/test/owl.stl

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions src/badguy/owl.cpp
@@ -0,0 +1,75 @@
// SuperTux
// Copyright (C) 2008 Wolfgang Becker <uafr@gmx.de>
// Copyright (C) 2010 Florian Forster <supertux at octo.it>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 "badguy/owl.hpp"

#include "audio/sound_manager.hpp"
#include "sprite/sprite.hpp"
#include "supertux/object_factory.hpp"

#define FLYING_SPEED 120.0

Owl::Owl(const Reader& reader) :
BadGuy(reader, "images/creatures/owl/owl.sprite")
{
set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
}

Owl::Owl(const Vector& pos, Direction d)
: BadGuy(pos, d, "images/creatures/owl/owl.sprite")
{
set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
}

void
Owl::initialize()
{
physic.set_velocity_x(dir == LEFT ? -FLYING_SPEED : FLYING_SPEED);
physic.enable_gravity(false);
sprite->set_action(dir == LEFT ? "left" : "right");
}

bool
Owl::collision_squished(GameObject&)
{
kill_fall ();
return true;
}

void
Owl::collision_solid(const CollisionHit& hit)
{
if(hit.top || hit.bottom) {
physic.set_velocity_y(0);
} else if(hit.left || hit.right) {
kill_fall ();
}
}

HitResponse
Owl::collision_player(Player& player, const CollisionHit& hit)
{
//Hack to tell if we should die
HitResponse response = BadGuy::collision_player(player, hit);
if(response == FORCE_MOVE) {
kill_fall ();
}

return ABORT_MOVE;
}

/* EOF */
39 changes: 39 additions & 0 deletions src/badguy/owl.hpp
@@ -0,0 +1,39 @@
// SuperTux
// Copyright (C) 2008 Wolfgang Becker <uafr@gmx.de>
// Copyright (C) 2010 Florian Forster <supertux at octo.it>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#ifndef HEADER_SUPERTUX_BADGUY_OWL_HPP
#define HEADER_SUPERTUX_BADGUY_OWL_HPP

#include "badguy/badguy.hpp"

class Owl : public BadGuy
{
public:
Owl(const Reader& reader);
Owl(const Vector& pos, Direction d);

void initialize();
void collision_solid(const CollisionHit& hit);

protected:
bool collision_squished(GameObject& object);
HitResponse collision_player(Player& player, const CollisionHit& hit);
};

#endif /* HEADER_SUPERTUX_BADGUY_OWL_HPP */

/* EOF */
2 changes: 2 additions & 0 deletions src/supertux/object_factory.cpp
Expand Up @@ -46,6 +46,7 @@
#include "badguy/mrbomb.hpp"
#include "badguy/mriceblock.hpp"
#include "badguy/mrtree.hpp"
#include "badguy/owl.hpp"
#include "badguy/plant.hpp"
#include "badguy/poisonivy.hpp"
#include "badguy/root.hpp"
Expand Down Expand Up @@ -194,6 +195,7 @@ ObjectFactory::init_factories()
add_factory<MrBomb>("mrbomb");
add_factory<MrIceBlock>("mriceblock");
add_factory<MrTree>("mrtree");
add_factory<Owl>("owl");
add_factory<Plant>("plant");
add_factory<PoisonIvy>("poisonivy");
add_factory<ShortFuse>("short_fuse");
Expand Down

0 comments on commit 47acf21

Please sign in to comment.