{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
- bbox.set_size(80, 120);
+ bbox.set_size(90, 106);
sprite = sprite_manager->create("images/creatures/yeti/yeti.sprite");
sprite->set_action("right");
state = INIT;
#include "mainloop.hpp"
#include "worldmap.hpp"
#include "world.hpp"
+#include "sector.hpp"
#include "squirrel_error.hpp"
#include "wrapper_util.hpp"
player_status->set_keys(new_key);
}
+void debug_collrects(bool enable)
+{
+ Sector::show_collrects = enable;
+}
+
void save_state()
{
if(World::current() == NULL)
*/
void add_key(int new_key);
+/**
+ * enable/disable drawing of collision rectangles
+ */
+void debug_collrects(bool enable);
+
}
#endif
}
+static int debug_collrects_wrapper(HSQUIRRELVM vm)
+{
+ SQBool arg0;
+ if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a bool"));
+ return SQ_ERROR;
+ }
+
+ try {
+ Scripting::debug_collrects(arg0);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'debug_collrects'"));
+ return SQ_ERROR;
+ }
+
+}
+
} // end of namespace Wrapper
void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook)
throw SquirrelError(v, "Couldn't register function 'add_key'");
}
+ sq_pushstring(v, "debug_collrects", -1);
+ sq_newclosure(v, &debug_collrects_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'debug_collrects'");
+ }
+
// Register class DisplayEffect
sq_pushstring(v, "DisplayEffect", -1);
if(sq_newclass(v, SQFalse) < 0) {
Sector* Sector::_current = 0;
+bool Sector::show_collrects = false;
+
Sector::Sector()
: currentmusic(LEVEL_MUSIC), gravity(10),
player(0), solids(0), camera(0)
object->draw(context);
}
+ if(show_collrects) {
+ Color col(0.2, 0.2, 0.2, 0.7);
+ for(MovingObjects::iterator i = moving_objects.begin();
+ i != moving_objects.end(); ++i) {
+ MovingObject* object = *i;
+ const Rect& rect = object->get_bbox();
+
+ context.draw_filled_rect(rect, col, LAYER_FOREGROUND1 + 10);
+ }
+ }
+
context.pop_transform();
}
std::auto_ptr<ScriptManager> script_manager;
public: // TODO make this private again
+ /// show collision rectangles of moving objects (for debugging)
+ static bool show_collrects;
+
GameObjects gameobjects;
MovingObjects moving_objects;
SpawnPoints spawnpoints;
}
void
+DrawingContext::draw_filled_rect(const Rect& rect, const Color& color,
+ int layer)
+{
+ DrawingRequest request;
+
+ request.type = FILLRECT;
+ request.pos = transform.apply(rect.p1);
+ request.layer = layer;
+
+ request.drawing_effect = transform.drawing_effect;
+ request.alpha = transform.alpha;
+
+ FillRectRequest* fillrectrequest = new FillRectRequest;
+ fillrectrequest->size = Vector(rect.get_width(), rect.get_height());
+ fillrectrequest->color = color;
+ fillrectrequest->color.alpha = color.alpha * transform.alpha;
+ request.request_data = fillrectrequest;
+
+ requests->push_back(request);
+}
+
+void
DrawingContext::draw_surface_part(DrawingRequest& request)
{
SurfacePartRequest* surfacepartrequest
#include <memory>
#include "math/vector.hpp"
+#include "math/rect.hpp"
#include "surface.hpp"
#include "font.hpp"
#include "color.hpp"
/// Fills a rectangle.
void draw_filled_rect(const Vector& topleft, const Vector& size,
const Color& color, int layer);
+ void draw_filled_rect(const Rect& rect, const Color& color, int layer);
/// Processes all pending drawing requests and flushes the list.
void do_drawing();