if ((dx > -playerWidth) && (dx < badguyWidth)) {
if (dy > 0) {
attackDirection.x = 0;
- attackDirection.y = -1;
+ attackDirection.y = 1;
} else {
attackDirection.x = 0;
- attackDirection.y = 1;
+ attackDirection.y = -1;
}
if ((attackDirection.x != oldWallDirection.x) || (attackDirection.y != oldWallDirection.y)) {
sprite->set_action("charging");
#include "bouncing_snowball.hpp"
-static const float JUMPSPEED = 450;
+static const float JUMPSPEED = -450;
static const float WALKSPEED = 80;
BouncingSnowball::BouncingSnowball(const lisp::Lisp& reader)
#include "object/tilemap.hpp"
#include "log.hpp"
-static const float FISH_JUMP_POWER = 600;
+static const float FISH_JUMP_POWER = -600;
static const float FISH_WAIT_TIME = 1;
Fish::Fish(const lisp::Lisp& reader)
void
Fish::collision_tile(uint32_t tile_attributes)
{
- if ((tile_attributes & Tile::WATER) && (physic.get_velocity_y() <= 0)) {
+ if ((tile_attributes & Tile::WATER) && (physic.get_velocity_y() >= 0)) {
// initialize stop position if uninitialized
if (stop_y == 0) stop_y = get_pos().y + get_bbox().get_height();
}
// set sprite
- sprite->set_action(physic.get_velocity_y() > 0 ? "normal" : "down");
+ sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down");
// we can't afford flying out of the tilemap, 'cause the engine would remove us.
if ((get_pos().y - 31.8) < 0) // too high, let us fall
#include "object/sprite_particle.hpp"
static const float FLYTIME = 1.0;
-static const float FLYSPEED = 100.0;
+static const float FLYSPEED = -100.0;
namespace {
const float PUFF_PROBABILITY = 0.1; /**< chanche of puffs being spawned in the current cycle */
#include "jumpy.hpp"
-static const float JUMPSPEED=600;
+static const float JUMPSPEED=-600;
static const float JUMPY_MID_TOLERANCE=4;
static const float JUMPY_LOW_TOLERANCE=2;
void
Kugelblitz::activate()
{
- physic.set_velocity_y(-300);
+ physic.set_velocity_y(300);
physic.set_velocity_x(-20); //fall a little to the left
direction = 1;
dying = false;
case WALKING:
{
sprite->set_action("jump");
- physic.set_velocity_y(700);
+ physic.set_velocity_y(-700);
action = JUMPING;
action_timer.start(JUMP_TIME);
break;
#include "random_generator.hpp"
namespace {
- const float VERTICAL_SPEED = 450; /**< y-speed when jumping */
+ const float VERTICAL_SPEED = -450; /**< y-speed when jumping */
const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */
const float MIN_RECOVER_TIME = 0.1; /**< minimum time to stand still before starting a (new) jump */
const float MAX_RECOVER_TIME = 1.0; /**< maximum time to stand still before starting a (new) jump */
if(state != JUMPING) return CONTINUE;
// check if we hit the floor while falling
- if ((hit.normal.y < 0) && (physic.get_velocity_y() < 0)) {
+ if ((hit.normal.y < 0) && (physic.get_velocity_y() > 0)) {
set_state(STANDING);
}
// check if we hit the roof while climbing
- if ((hit.normal.y > 0) && (physic.get_velocity_y() > 0)) {
+ if ((hit.normal.y > 0) && (physic.get_velocity_y() < 0)) {
physic.set_velocity_y(0);
}
const float WALKSPEED = 80;
const float KICKSPEED = 500;
const int MAXSQUISHES = 10;
- const float KICKSPEED_Y = 500; /**< y-velocity gained when kicked */
+ const float KICKSPEED_Y = -500; /**< y-velocity gained when kicked */
}
Snail::Snail(const lisp::Lisp& reader)
#include "spidermite.hpp"
static const float FLYTIME = 1.2;
-static const float FLYSPEED = 100.0;
+static const float FLYSPEED = -100.0;
SpiderMite::SpiderMite(const lisp::Lisp& reader)
: BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
#include "log.hpp"
static const float WALKSPEED = 100;
-static const float JUMP_ON_SPEED_Y = 400;
-static const float JUMP_OFF_SPEED_Y = 500;
+static const float JUMP_ON_SPEED_Y = -400;
+static const float JUMP_OFF_SPEED_Y = -500;
Totem::Totem(const lisp::Lisp& reader)
: BadGuy(reader, "images/creatures/totem/totem.sprite")
namespace {
const float JUMP_DOWN_VX = 250; /**< horizontal speed while jumping off the dais */
- const float JUMP_DOWN_VY = 250; /**< vertical speed while jumping off the dais */
+ const float JUMP_DOWN_VY = -250; /**< vertical speed while jumping off the dais */
const float RUN_VX = 350; /**< horizontal speed while running */
const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */
- const float JUMP_UP_VY = 800; /**< vertical speed while jumping on the dais */
+ const float JUMP_UP_VY = -800; /**< vertical speed while jumping on the dais */
- const float STOMP_VY = 250; /** vertical speed while stomping on the dais */
+ const float STOMP_VY = -250; /** vertical speed while stomping on the dais */
const float LEFT_STAND_X = 16; /**< x-coordinate of left dais' end position */
const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */
} else
if (state == DIVING) {
state = CLIMBING;
- physic.set_velocity_y(speed);
+ physic.set_velocity_y(-speed);
sprite->set_action(dir == LEFT ? "left" : "right");
} else
if (state == CLIMBING) {
if (state == FLYING) {
if (should_we_dive()) {
state = DIVING;
- physic.set_velocity_y(-2*fabsf(physic.get_velocity_x()));
+ physic.set_velocity_y(2*fabsf(physic.get_velocity_x()));
sprite->set_action(dir == LEFT ? "diving-left" : "diving-right");
}
return;
float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
physic.set_velocity_x(speed + xm);
- physic.set_velocity_y(-BULLET_STARTING_YM);
+ physic.set_velocity_y(BULLET_STARTING_YM);
if (kind == ICE_BULLET) {
life_count = 6; //ice-bullets get "extra lives" for bumping off walls
{
if(kind == FIRE_BULLET) {
// @not completely framerate independant :-/
- physic.set_velocity_y(physic.get_velocity_y() - 50 * elapsed_time);
+ physic.set_velocity_y(physic.get_velocity_y() + 50 * elapsed_time);
}
if(physic.get_velocity_y() > 900)
physic.set_velocity_y(900);
{
pos = start_position;
sprite = sprite_manager->create("images/objects/coin/coin.sprite");
- physic.set_velocity_y(800);
+ physic.set_velocity_y(-800);
physic.set_velocity_x(vel_x);
}
OneUp::OneUp(const Vector& pos)
: MovingSprite(pos, "images/powerups/1up/1up.sprite", LAYER_FLOATINGOBJECTS, COLGROUP_TOUCHABLE)
{
- physic.set_velocity(100, 400);
+ physic.set_velocity(100, -400);
}
void
if (floor_normal.y != 0) {
if ((floor_normal.x * vx) > 0) {
// we overdo it a little, just to be on the safe side
- vy = vx * (floor_normal.x / floor_normal.y) * 2;
+ vy = -vx * (floor_normal.x / floor_normal.y) * 2;
}
}
}
if(controller->pressed(Controller::JUMP) && can_jump && on_ground()) {
if (duck) {
if (physic.get_velocity_x() != 0) // only jump a little bit when running ducked
- physic.set_velocity_y(300);
+ physic.set_velocity_y(-300);
else { //do a backflip
backflipping = true;
- physic.set_velocity_y(580);
+ physic.set_velocity_y(-580);
backflip_timer.start(0.15);
}
}
else if (fabs(physic.get_velocity_x()) > MAX_WALK_XM) // jump higher if we are running
- physic.set_velocity_y(580);
+ physic.set_velocity_y(-580);
else
- physic.set_velocity_y(520);
+ physic.set_velocity_y(-520);
//bbox.move(Vector(0, -1));
jumping = true;
else
sound_manager->play("sounds/jump.wav");
} else if(!controller->hold(Controller::JUMP)) { // Let go of jump key
- if (!backflipping && jumping && physic.get_velocity_y() > 0) {
+ if (!backflipping && jumping && physic.get_velocity_y() < 0) {
jumping = false;
physic.set_velocity_y(0);
}
Vector(base.x + 1, base.y + base.height), false)
|| Sector::current()->trybreakbrick(
Vector(base.x + base.width - 1, base.y + base.height), false)) {
- physic.set_velocity_y(2);
+ physic.set_velocity_y(-2);
butt_jump = true;
}
vx += MAX_RUN_XM * 2;
}
if ((controller->hold(Controller::UP)) || (controller->hold(Controller::JUMP))) {
- vy += MAX_RUN_XM * 2;
+ vy -= MAX_RUN_XM * 2;
}
if (controller->hold(Controller::DOWN)) {
- vy -= MAX_RUN_XM * 2;
+ vy += MAX_RUN_XM * 2;
}
if (controller->hold(Controller::ACTION)) {
set_ghost_mode(false);
*/
if(hit.normal.y < 0) { // landed on floor?
- if(physic.get_velocity_y() < 0)
+ if(physic.get_velocity_y() > 0)
physic.set_velocity_y(0);
on_ground_flag = true;
Platform* platform = dynamic_cast<Platform*> (&other);
if(platform != NULL) {
if(platform->get_speed().y > 0)
- physic.set_velocity_y(-platform->get_speed().y);
+ physic.set_velocity_y(platform->get_speed().y);
//physic.set_velocity_x(platform->get_speed().x);
}
} else if(hit.normal.y > 0) { // bumped against the roof
- physic.set_velocity_y(.1);
+ physic.set_velocity_y(-.1);
// hack platform so that we are not glued to it from below
Platform* platform = dynamic_cast<Platform*> (&other);
if(platform != NULL) {
- physic.set_velocity_y(-platform->get_speed().y);
+ physic.set_velocity_y(platform->get_speed().y);
}
}
}
physic.enable_gravity(true);
physic.set_acceleration(0, 0);
- physic.set_velocity(0, 700);
+ physic.set_velocity(0, -700);
player_status->coins -= 25;
set_bonus(NO_BONUS);
dying = true;
Player::bounce(BadGuy& )
{
if(controller->hold(Controller::JUMP))
- physic.set_velocity_y(520);
+ physic.set_velocity_y(-520);
else
- physic.set_velocity_y(300);
+ physic.set_velocity_y(-300);
}
//Scripting Functions Below
if(other.get_flags() & FLAG_SOLID) {
if(hit.normal.y < 0) { // landed on floor
- if(physic.get_velocity_y() < 0)
+ if(physic.get_velocity_y() > 0)
physic.set_velocity_y(0);
} else if(hit.normal.y > 0) { // bumped against roof
physic.set_velocity_y(.1);
#include "sprite/sprite_manager.hpp"
#include "video/drawing_context.hpp"
-static const float INITIALJUMP = 400;
+static const float INITIALJUMP = -400;
static const float SPEED = 150;
-static const float JUMPSPEED = 300;
+static const float JUMPSPEED = -300;
Star::Star(const Vector& pos)
: MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
void
Physic::set_velocity_y(float nvy)
{
- vy = -nvy;
+ vy = nvy;
}
void
Physic::set_velocity(float nvx, float nvy)
{
vx = nvx;
- vy = -nvy;
+ vy = nvy;
}
void
float
Physic::get_velocity_y() const
{
- return -vy;
+ return vy;
}
Vector
Physic::get_velocity() const
{
- return Vector(vx, -vy);
+ return Vector(vx, vy);
}
void
void
Physic::set_acceleration_y(float nay)
{
- ay = -nay;
+ ay = nay;
}
void
Physic::set_acceleration(float nax, float nay)
{
ax = nax;
- ay = -nay;
+ ay = nay;
}
float
float
Physic::get_acceleration_y() const
{
- return -ay;
+ return ay;
}
Vector
Physic::get_acceleration() const
{
- return Vector(ax, -ay);
+ return Vector(ax, ay);
}
void