4 // Copyright (C) 2005 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #include "sprite/sprite.hpp"
24 #include "sprite/sprite_manager.hpp"
25 #include "lisp/writer.hpp"
26 #include "video/drawing_context.hpp"
27 #include "resources.hpp"
28 #include "object_factory.hpp"
30 Rock::Rock(const lisp::Lisp& reader)
32 reader.get("x", bbox.p1.x);
33 reader.get("y", bbox.p1.y);
34 bbox.set_size(31.8, 31.8);
35 sprite = sprite_manager->create("images/objects/rock/rock.sprite");
37 flags |= FLAG_SOLID | FLAG_PORTABLE;
46 Rock::write(lisp::Writer& writer)
48 writer.start_list("rock");
50 writer.write_float("x", bbox.p1.x);
51 writer.write_float("y", bbox.p1.y);
53 writer.end_list("rock");
57 Rock::draw(DrawingContext& context)
59 sprite->draw(context, get_pos(), LAYER_OBJECTS);
63 Rock::update(float elapsed_time)
67 set_group(COLGROUP_MOVING);
68 movement = physic.get_movement(elapsed_time);
70 physic.set_velocity(0, 0);
72 set_group(COLGROUP_DISABLED);
79 Rock::collision(GameObject& object, const CollisionHit& )
85 if(object.get_flags() & FLAG_SOLID) {
86 physic.set_velocity(0, 0);
94 Rock::grab(MovingObject& , const Vector& pos, Direction)
96 movement = pos - get_pos();
100 IMPLEMENT_FACTORY(Rock, "rock");