(particles-rain
)
- (spawnpoint (name "main") (x 1728) (y 192))
+ (spawnpoint (name "main") (x 2496) (y 128))
(background
(image "ghostforest.jpg")
(speed 1.000000)
(poisonivy (x 100) (y 438))
(kugelblitz (x 219) (y 32))
(kugelblitz (x 700) (y 32))
- (kugelblitz (x 1363) (y 183))
- (kugelblitz (x 2459) (y 64))
- (kugelblitz (x 3215) (y 79))
+ (kugelblitz (x 1076) (y 366))
+ (kugelblitz (x 2728) (y 13))
+ (kugelblitz (x 2201) (y 6))
(kugelblitz (x 3762) (y 130))
)
)
#include "kugelblitz.hpp"
#include "object/tilemap.hpp"
+#include "object/camera.hpp"
#include "tile.hpp"
#define LIFETIME 5
#define BASE_SPEED 200
#define RAND_SPEED 150
+static const float X_OFFSCREEN_DISTANCE = 1600;
+static const float Y_OFFSCREEN_DISTANCE = 1200;
+
Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
: groundhit_pos_set(false)
{
movement_timer.start(MOVETIME);
}
}
- if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() != 0)
- std::cout << Sector::current()->solids->get_tile_at(get_pos())->getAttributes() << std::endl;
if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) {
//HIT WATER
Sector::current()->add_object(new Electrifier(75,1421,1.5));
else remove_me();
}
+void
+Kugelblitz::try_activate()
+{
+ //FIXME: Don't activate Kugelblitz before it's on-screen
+ float scroll_x = Sector::current()->camera->get_translation().x;
+ float scroll_y = Sector::current()->camera->get_translation().y;
+
+ /* Activate badguys if they're just around the screen to avoid
+ * the effect of having badguys suddenly popping up from nowhere.
+ */
+ if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE &&
+ start_position.x < scroll_x - bbox.get_width() &&
+ start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
+ start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) {
+ dir = RIGHT;
+ set_state(STATE_ACTIVE);
+ activate();
+ } else if (start_position.x > scroll_x &&
+ start_position.x < scroll_x + X_OFFSCREEN_DISTANCE &&
+ start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
+ start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) {
+ dir = LEFT;
+ set_state(STATE_ACTIVE);
+ activate();
+ } else if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE &&
+ start_position.x < scroll_x + X_OFFSCREEN_DISTANCE &&
+ ((start_position.y > scroll_y &&
+ start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) ||
+ (start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE &&
+ start_position.y < scroll_y))) {
+ dir = start_position.x < scroll_x ? RIGHT : LEFT;
+ set_state(STATE_ACTIVE);
+ activate();
+ } else if(state == STATE_INIT
+ && start_position.x > scroll_x - X_OFFSCREEN_DISTANCE
+ && start_position.x < scroll_x + X_OFFSCREEN_DISTANCE
+ && start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE
+ && start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) {
+ dir = LEFT;
+ set_state(STATE_ACTIVE);
+ activate();
+ }
+}
+
IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz")
void explode();
private:
+ void try_activate();
HitResponse hit(const CollisionHit& hit);
Vector pos_groundhit;
bool groundhit_pos_set;
Timer movement_timer;
Timer lifetime;
int direction;
+ State state;
};
#endif
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
+
+#include <config.h>
#include "electrifier.hpp"
#include "sector.hpp"
#include "object/tilemap.hpp"
#ifndef __ELECTRIFIER_H__
#define __ELECTRIFIER_H__
-#include <config.h>
#include "resources.hpp"
#include "game_object.hpp"
#include "timer.hpp"
x2 = x1 + 32 + movement.x;
y1 = object->pos.y;
y2 = y1 + 32 + movement.y;
+ bool water = false;
// test with all tiles in this rectangle
int starttilex = int(x1-1) / 32;
const Tile* tile = solids->get_tile(x, y);
if(!tile)
continue;
- // skip non-solid tiles
- if(!(tile->getAttributes() & Tile::SOLID))
+ // skip non-solid tiles, except water
+ if (tile->getAttributes() & Tile::WATER)
+ water = true;
+ if(!water && !(tile->getAttributes() & Tile::SOLID))
continue;
if(tile->getAttributes() & Tile::SLOPE) { // slope tile
return -1; //no collision
}
else {
- if ((hit.normal.x == 1) && (hit.normal.y == 0))
- return 1; //collision from right
- else return 0; //collision from above
+ if (water)
+ return 0; //collision with water tile - don't draw splash
+ else {
+ if ((hit.normal.x == 1) && (hit.normal.y == 0))
+ return 2; //collision from right
+ else return 1; //collision from above
+ }
}
}
int col = collision(particle, Vector(-movement, movement));
if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (col >= 0)) {
//Create rainsplash
- if (particle->pos.y <= SCREEN_HEIGHT + abs_y){
- bool vertical = (col == 1);
+ if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)){
+ bool vertical = (col == 2);
int splash_x, splash_y;
if (!vertical) { //check if collision happened from above
splash_x = int(particle->pos.x);
float abs_y = Sector::current()->camera->get_translation().y;
particle->pos.y += movement;
particle->pos.x -= movement;
- if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (collision(particle, Vector(-movement, movement)) >= 0)) {
- if (particle->pos.y <= SCREEN_HEIGHT + abs_y) {
+ int col = collision(particle, Vector(-movement, movement));
+ if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (col >= 0)) {
+ if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
Sector::current()->add_object(new Bomb(particle->pos, LEFT));
}
int new_x = (rand() % int(virtual_width)) + int(abs_x);