Update of /cvsroot/super-tux/supertux/src/object
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13952/src/object
Modified Files:
block.h particlesystem.cpp player.cpp portable.h
Added Files:
bell.cpp bell.h
Log Message:
added a bell object which is a new better way to do reset points
Index: block.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/block.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- block.h 29 Nov 2004 00:12:25 -0000 1.3
+++ block.h 30 Mar 2005 01:52:14 -0000 1.4
@@ -1,5 +1,5 @@
-#ifndef __BOX_H__
-#define __BOX_H__
+#ifndef __BLOCK_H__
+#define __BLOCK_H__
#include "special/moving_object.h"
Index: particlesystem.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/particlesystem.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- particlesystem.cpp 16 Mar 2005 11:35:16 -0000 1.3
+++ particlesystem.cpp 30 Mar 2005 01:52:14 -0000 1.4
@@ -137,7 +137,7 @@
virtual_width = screen->w * 2;
- // create some random snowflakes
+ // create some random raindrops
size_t raindropcount = size_t(virtual_width/8.0);
for(size_t i=0; i<raindropcount; ++i) {
RainParticle* particle = new RainParticle;
Index: player.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/player.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- player.cpp 25 Mar 2005 20:39:55 -0000 1.4
+++ player.cpp 30 Mar 2005 01:52:14 -0000 1.5
@@ -257,9 +257,21 @@
return;
}
- if(input.fire == false)
+ if(input.fire == false && grabbed_object) {
grabbed_object = 0;
-
+ // move the grabbed object a bit away from tux
+ Vector pos = get_pos() +
+ Vector(dir == LEFT ? -bbox.get_width() : bbox.get_width(),
+ bbox.get_height()*0.66666 - 32);
+ MovingObject* object = dynamic_cast<MovingObject*> (grabbed_object);
+ if(object) {
+ object->set_pos(pos);
+ } else {
+#ifdef DEBUG
+ std::cout << "Non MovingObjetc grabbed?!?\n";
+#endif
+ }
+ }
if(!dying)
handle_input();
Index: portable.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/object/portable.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- portable.h 19 Dec 2004 13:34:12 -0000 1.1
+++ portable.h 30 Mar 2005 01:52:14 -0000 1.2
@@ -14,10 +14,19 @@
class Portable
{
public:
- /**
- * called each frame when the object has been grabbed.
- */
+ virtual ~Portable()
+ { }
+
+ /**
+ * called each frame when the object has been grabbed.
+ */
virtual void grab(MovingObject& object, const Vector& pos) = 0;
+
+ /** called when object isn't grabbed anymore */
+ virtual void ungrab(MovingObject& object)
+ {
+ (void) object;
+ }
};
#endif
--- NEW FILE: bell.h ---
#ifndef __BELL_H__
#define __BELL_H__
#include "lisp/lisp.h"
#include "special/moving_object.h"
#include "special/sprite.h"
#include "serializable.h"
using namespace SuperTux;
/**
* A bell: When tux touches it, it begins ringing and you will respawn at this
* position.
*/
class Bell : public MovingObject, public Serializable
{
public:
Bell(const lisp::Lisp& lisp);
~Bell();
void write(lisp::Writer& writer);
void action(float elapsed_time);
void draw(DrawingContext& context);
HitResponse collision(GameObject& other, const CollisionHit& hit);
private:
Sprite* sprite;
bool ringing;
};
#endif
--- NEW FILE: bell.cpp ---
#include <config.h>
#include "bell.h"
#include "resources.h"
#include "special/sprite_manager.h"
#include "video/drawing_context.h"
#include "player.h"
#include "object_factory.h"
#include "gameloop.h"
#include "sector.h"
Bell::Bell(const lisp::Lisp& lisp)
: ringing(false)
{
lisp.get("x", bbox.p1.x);
lisp.get("y", bbox.p1.y);
bbox.set_size(32, 32);
sprite = sprite_manager->create("bell");
}
Bell::~Bell()
{
delete sprite;
}
void
Bell::write(lisp::Writer& writer)
{
writer.start_list("bell");
writer.write_float("x", bbox.p1.x);
writer.write_float("y", bbox.p1.y);
writer.end_list("bell");
}
void
Bell::action(float )
{
}
void
Bell::draw(DrawingContext& context)
{
sprite->draw(context, get_pos(), LAYER_TILES);
}
HitResponse
Bell::collision(GameObject& other, const CollisionHit& )
{
if(ringing)
return ABORT_MOVE;
Player* player = dynamic_cast<Player*> (&other);
if(player) {
ringing = true;
// TODO play sound
sprite->set_action("ringing");
GameSession::current()->set_reset_point(Sector::current()->get_name(),
get_pos());
}
return ABORT_MOVE;
}
IMPLEMENT_FACTORY(Bell, "bell");
|