~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/particles/explosive_particle.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: explosive_particle.cpp 2986 2007-08-17 16:20:09Z grumbel $
 
2
//
 
3
//  Pingus - A free Lemmings clone
 
4
//  Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
 
5
//
 
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.
 
10
//
 
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.
 
15
//
 
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.
 
19
#if 0
 
20
#include "../col_map.hpp"
 
21
#include "../pingu_map.hpp"
 
22
#include "../world.hpp"
 
23
#include "../particles/particle_holder.hpp"
 
24
#include "../resource.hpp"
 
25
#include "explosive_particle.hpp"
 
26
 
 
27
ExplosiveParticle::ExplosiveParticle (int x, int y, float x_a, float y_a)
 
28
                                    : Particle (x, y, x_a, y_a),
 
29
                                      alive (true)
 
30
{
 
31
}
 
32
 
 
33
ExplosiveParticle::~ExplosiveParticle ()
 
34
{
 
35
}
 
36
 
 
37
void
 
38
ExplosiveParticle::update (float delta)
 
39
{
 
40
  Vector new_pos = pos + velocity * delta;
 
41
 
 
42
  Vector incr = pos - new_pos;
 
43
  incr.normalize ();
 
44
 
 
45
  // FIXME: This thing needs to be more abstract, we just need it far
 
46
  // to often to reimplement it over and over again.
 
47
  while (   static_cast<int>(new_pos.x) != static_cast<int>(pos.x)
 
48
         || static_cast<int>(new_pos.y) != static_cast<int>(pos.y))
 
49
    {
 
50
      pos -= incr;
 
51
 
 
52
      if (   pos.x < 0
 
53
          || pos.y < 0
 
54
          || pos.x + 1 > WorldObj::get_world()->get_width ()
 
55
          || pos.y + 1 > WorldObj::get_world()->get_height())
 
56
        {
 
57
          alive = false;
 
58
          return;
 
59
        }
 
60
 
 
61
      if (WorldObj::get_world()->get_colmap()->getpixel(static_cast<int>(pos.x), static_cast<int>(pos.y)))
 
62
        {
 
63
          detonate();
 
64
        }
 
65
    }
 
66
 
 
67
  pos = new_pos;
 
68
}
 
69
 
 
70
void
 
71
ExplosiveParticle::detonate ()
 
72
{
 
73
  alive = false;
 
74
  WorldObj::get_world()->get_particle_holder ()->add_pingu_explo((int)pos.x, (int)pos.y);
 
75
 
 
76
  CollisionMask mask = Resource::load_collision_mask("Other/bomber_radius", "pingus");
 
77
  WorldObj::get_world()->remove(mask,
 
78
                                int(pos.x) - (bomber_radius.get_width()/2),
 
79
                                int(pos.y) - (bomber_radius.get_height()/2));
 
80
}
 
81
 
 
82
//void
 
83
//ExplosiveParticle::draw_offset(int ofx, int ofy, float /*s*/)
 
84
//{
 
85
//  sprite.put_screen (int(pos.x + ofx), int(pos.y + ofy));
 
86
//}
 
87
 
 
88
 
 
89
bool
 
90
ExplosiveParticle::is_alive(void)
 
91
{
 
92
  return alive;
 
93
}
 
94
 
 
95
/* EOF */
 
96
#endif