#include "object/gameobjs.hpp"
#include "object/camera.hpp"
#include "object/background.hpp"
+#include "object/gradient.hpp"
#include "object/particlesystem.hpp"
#include "object/particlesystem_interactive.hpp"
#include "object/tilemap.hpp"
try {
return create_object(name, reader);
} catch(std::exception& e) {
- msg_warning(e.what() << "");
+ msg_warning << e.what() << "" << std::endl;
}
return 0;
fix_old_tiles();
if(!camera) {
- msg_warning("sector '" << name << "' does not contain a camera.");
+ msg_warning << "sector '" << name << "' does not contain a camera." << std::endl;
update_game_objects();
add_object(new Camera(this));
}
bkgd_bottom.blue = static_cast<float> (b) / 255.0f;
if(backgroundimage != "") {
- Background* background = new Background;
+ Background* background = new Background();
background->set_image(
std::string("images/background/") + backgroundimage, bgspeed);
add_object(background);
} else {
- Background* background = new Background;
- background->set_gradient(bkgd_top, bkgd_bottom);
- add_object(background);
+ Gradient* gradient = new Gradient();
+ gradient->set_gradient(bkgd_top, bkgd_bottom);
+ add_object(gradient);
}
std::string particlesystem;
spawnpoints.push_back(sp);
}
} else {
- msg_warning("Unknown token '" << iter.item() << "' in reset-points.");
+ msg_warning << "Unknown token '" << iter.item() << "' in reset-points." << std::endl;
}
}
}
if(object) {
add_object(object);
} else {
- msg_warning("Unknown object '" << iter.item() << "' in level.");
+ msg_warning << "Unknown object '" << iter.item() << "' in level." << std::endl;
}
}
}
}
}
if(!sp) {
- msg_warning("Spawnpoint '" << spawnpoint << "' not found.");
+ msg_warning << "Spawnpoint '" << spawnpoint << "' not found." << std::endl;
if(spawnpoint != "main") {
activate("main");
} else {
if(solids == 0) {
solids = tilemap;
} else {
- msg_warning("Another solid tilemaps added. Ignoring");
+ msg_warning << "Another solid tilemaps added. Ignoring" << std::endl;
}
}
Camera* camera = dynamic_cast<Camera*> (object);
if(camera) {
if(this->camera != 0) {
- msg_warning("Multiple cameras added. Ignoring");
+ msg_warning << "Multiple cameras added. Ignoring" << std::endl;
continue;
}
this->camera = camera;
// test with all tiles in this rectangle
int starttilex = int(x1) / 32;
int starttiley = int(y1) / 32;
- int max_x = int(x2);
- // the +1 is somehow needed to make characters stay on the floor
- int max_y = int(y2+1);
+ int max_x = int(x2 + (1 - DELTA));
+ int max_y = int(y2 + (1 - DELTA));
CollisionHit temphit;
for(int x = starttilex; x*32 < max_x; ++x) {
float y2 = dest.p2.y;
// test with all tiles in this rectangle
- int starttilex = int(x1-1) / 32;
- int starttiley = int(y1-1) / 32;
- int max_x = int(x2+1);
- int max_y = int(y2+1);
+ int starttilex = int(x1) / 32;
+ int starttiley = int(y1) / 32;
+ int max_x = int(x2);
+ int max_y = int(y2);
uint32_t result = 0;
for(int x = starttilex; x*32 < max_x; ++x) {
|| !moving_object_2->is_valid())
continue;
- Rect dest2 = moving_object_2->get_bbox();
- // We're using the old position of the object here,
- // this might seem a bit wrong but improves some situations
- // like stacked boxes and badguys alot
- //
- dest2.move(moving_object_2->get_movement());
+ Rect dest = moving_object_2->dest;
+
Vector rel_movement
= movement - moving_object_2->get_movement();
- //Vector movement =
-
- if(Collision::rectangle_rectangle(temphit, object->dest, rel_movement, dest2)
+
+ if(Collision::rectangle_rectangle(temphit, object->dest, rel_movement, dest)
&& temphit.time > hit.time) {
hit = temphit;
collided_with = moving_object_2;
// the static object "wins" move tux out of the collision
object->dest.move(-hit.normal * (hit.depth + DELTA));
return false;
- } else if(other_response == TEST) {
+ } else if(other_response == PASS_MOVEMENT) {
object->dest.move(moving_object->get_movement());
//object->movement += moving_object->get_movement();
}
Vector movement = moving_object->get_movement();
// test if x or y movement is dominant
- if(fabsf(moving_object->get_movement().x) > fabsf(moving_object->get_movement().y)) {
+ if(fabsf(moving_object->get_movement().x) < fabsf(moving_object->get_movement().y)) {
// test in x direction first, then y direction
moving_object->dest.move(Vector(0, -movement.y));
for(int i = 0; i < 2; ++i) {
- bool res = collision_static(moving_object, /*Vector(movement.x, 0)*/ movement);
+ bool res = collision_static(moving_object, Vector(movement.x, 0));
if(res)
break;
}
moving_object->dest.move(Vector(0, movement.y));
for(int i = 0; i < 2; ++i) {
- bool res = collision_static(moving_object, /*Vector(0, movement.y)*/ movement);
+ bool res = collision_static(moving_object, Vector(0, movement.y));
if(res)
break;
}
// test in y direction first, then x direction
moving_object->dest.move(Vector(-movement.x, 0));
for(int i = 0; i < 2; ++i) {
- bool res = collision_static(moving_object, movement/*Vector(0, movement.y)*/);
+ bool res = collision_static(moving_object, Vector(0, movement.y));
if(res)
break;
}
moving_object->dest.move(Vector(movement.x, 0));
for(int i = 0; i < 2; ++i) {
- bool res = collision_static(moving_object, movement /*Vector(movement.x, 0)*/);
+ bool res = collision_static(moving_object, Vector(movement.x, 0));
if(res)
break;
}