1
// $Id: ExplosiveParticle.cc,v 1.3 2001/08/12 18:36:42 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "../ColMap.hh"
21
#include "../PinguMap.hh"
22
#include "../World.hh"
23
#include "../particles/ParticleHolder.hh"
24
#include "ExplosiveParticle.hh"
26
ExplosiveParticle::ExplosiveParticle (int x, int y, float x_a, float y_a)
27
: Particle (x, y, x_a, y_a),
30
sprite = Sprite (PingusResource::load_surface
31
("Particles/explosive",
35
ExplosiveParticle::~ExplosiveParticle ()
40
ExplosiveParticle::update(float delta)
42
CL_Vector new_pos = pos + velocity * delta;
44
CL_Vector incr = pos - new_pos;
47
// FIXME: This thing needs to be more abstract, we just need it far
48
// to often to reimplement it over and over again.
49
while (int(new_pos.x) != int(pos.x)
50
|| int(new_pos.y) != int(pos.y))
54
if (pos.x < 0 || pos.y < 0
55
|| pos.x + 1 > world->get_width ()
56
|| pos.y + 1 > world->get_height ())
62
if (world->get_colmap ()->getpixel ((int) pos.x, (int) pos.y))
72
ExplosiveParticle::detonate ()
75
CL_Surface bomber_radius = PingusResource::load_surface ("Other/bomber_radius", "pingus");
76
world->get_particle_holder ()->add_pingu_explo((int)pos.x, (int)pos.y);
78
// FIXME: Ugly do handle the colmap and the gfx map seperatly
79
world->get_colmap()->remove(bomber_radius,
80
int(pos.x) - (bomber_radius.get_width()/2),
81
int(pos.y) - (bomber_radius.get_height()/2));
82
world->get_gfx_map()->remove(bomber_radius,
83
int(pos.x) - (bomber_radius.get_width()/2),
84
int(pos.y) - (bomber_radius.get_height()/2));
88
ExplosiveParticle::draw_offset(int ofx, int ofy, float s)
90
sprite.put_screen (int(pos.x + ofx), int(pos.y + ofy));
94
ExplosiveParticle::is_alive(void)