#include "gameloop.h"
#include "display_manager.h"
#include "lispwriter.h"
+#include "camera.h"
Sprite* img_mriceblock_flat_left;
Sprite* img_mriceblock_flat_right;
lispreader.read_float("y", &base.y);
base.width = 0;
base.height = 0;
- base.xm = 0;
- base.ym = 0;
kind = kind_;
base.y = y;
base.width = 0;
base.height = 0;
- base.xm = 0;
- base.ym = 0;
stay_on_platform = false;
kind = kind_;
// hack so that the bomb doesn't hurt until it expldes...
dying = DYING_SQUISHED;
} else if(kind == BAD_FLAME) {
- base.ym = 0; // we misuse base.ym as angle for the flame
+ angle = 0;
physic.enable_gravity(false);
set_sprite(img_flame, img_flame);
} else if(kind == BAD_BOUNCINGSNOWBALL) {
void
BadGuy::write(LispWriter& writer)
{
- writer.startList(badguykind_to_string(kind));
+ writer.start_list(badguykind_to_string(kind));
- writer.writeFloat("x", base.x);
- writer.writeFloat("y", base.y);
- writer.writeBool("stay-on-platform", stay_on_platform);
+ writer.write_float("x", base.x);
+ writer.write_float("y", base.y);
+ writer.write_bool("stay-on-platform", stay_on_platform);
- writer.endList(badguykind_to_string(kind));
+ writer.end_list(badguykind_to_string(kind));
}
void
check_horizontal_bump();
if(mode == KICK && changed != dir)
{
+ float scroll_x = World::current()->camera->get_translation().x;
+
/* handle stereo sound (number 10 should be tweaked...)*/
if (base.x < scroll_x + screen->w/2 - 10)
play_sound(sounds[SND_RICOCHET], SOUND_LEFT_SPEAKER);
dying = DYING_NOT; // now the bomb hurts
timer.start(EXPLODETIME);
+ float scroll_x = World::current()->camera->get_translation().x;
+
/* play explosion sound */ // FIXME: is the stereo all right? maybe we should use player cordinates...
if (base.x < scroll_x + screen->w/2 - 10)
play_sound(sounds[SND_EXPLODE], SOUND_LEFT_SPEAKER);
{
static const float radius = 100;
static const float speed = 0.02;
- base.x = old_base.x + cos(base.ym) * radius;
- base.y = old_base.y + sin(base.ym) * radius;
+ base.x = old_base.x + cos(angle) * radius;
+ base.y = old_base.y + sin(angle) * radius;
- base.ym = fmodf(base.ym + elapsed_time * speed, 2*M_PI);
+ angle = fmodf(angle + elapsed_time * speed, 2*M_PI);
}
void
void
BadGuy::action(float elapsed_time)
{
- // Remove if it's far off the screen:
- if (base.x < scroll_x - OFFSCREEN_DISTANCE)
- {
- remove_me();
- return;
- }
-
+ float scroll_x = World::current()->camera->get_translation().x;
+ float scroll_y = World::current()->camera->get_translation().y;
+
// BadGuy fall below the ground
if (base.y > World::current()->get_level()->height * 32) {
remove_me();
}
// Once it's on screen, it's activated!
- if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
+ if (base.x > scroll_x - X_OFFSCREEN_DISTANCE &&
+ base.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE &&
+ base.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
+ base.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE)
seen = true;
if(!seen)
}
void
-BadGuy::draw(ViewPort& viewport, int)
+BadGuy::draw(Camera& viewport, int)
{
float scroll_x = viewport.get_translation().x;
float scroll_y = viewport.get_translation().y;
}
Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
- sprite->draw(base.x, base.y);
+ sprite->draw(viewport.world2screen(Vector(base.x, base.y)));
if (debug_mode)
fillrect(base.x - scroll_x, base.y - scroll_y, base.width, base.height, 75,0,75, 150);