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

« back to all changes in this revision

Viewing changes to src/worldobjs/ice_block.cxx

  • 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: ice_block.cxx,v 1.21 2003/02/19 09:50:36 grumbel Exp $
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
 
 
20
 
#include "../col_map.hxx"
21
 
#include "../game_time.hxx"
22
 
#include "../gui/graphic_context.hxx"
23
 
#include "../pingu.hxx"
24
 
#include "../pingu_holder.hxx"
25
 
#include "../pingu_map.hxx"
26
 
#include "../pingus_resource.hxx"
27
 
#include "../world.hxx"
28
 
#include "../worldobjsdata/ice_block_data.hxx"
29
 
#include "ice_block.hxx"
30
 
 
31
 
namespace WorldObjs {
32
 
 
33
 
IceBlock::IceBlock (const WorldObjsData::IceBlockData& data_) 
34
 
  : data(new WorldObjsData::IceBlockData(data_)), 
35
 
    thickness(1.0),
36
 
    is_finished(false),
37
 
    last_contact(0),
38
 
    block_sur(PingusResource::load_surface ("iceblock", "worldobjs"))
39
 
{
40
 
}
41
 
 
42
 
IceBlock::~IceBlock ()
43
 
{
44
 
  delete data;
45
 
}
46
 
 
47
 
void
48
 
IceBlock::on_startup ()
49
 
{
50
 
  CL_Surface surf(PingusResource::load_surface("iceblock_cmap", "worldobjs"));
51
 
 
52
 
  world->get_colmap()->put(surf,
53
 
                           static_cast<int>(data->pos.x),
54
 
                           static_cast<int>(data->pos.y),
55
 
                           Groundtype::GP_GROUND);
56
 
}
57
 
 
58
 
void 
59
 
IceBlock::draw (GraphicContext& gc)
60
 
{
61
 
  if (is_finished)
62
 
    return;
63
 
 
64
 
  gc.draw(block_sur,
65
 
          data->pos,
66
 
          static_cast<int>((1.0 - thickness) * (block_sur.get_num_frames() - 1)));
67
 
}
68
 
 
69
 
void 
70
 
IceBlock::update()
71
 
{
72
 
  if (is_finished)
73
 
    return;
74
 
 
75
 
  PinguHolder* holder = world->get_pingus();
76
 
 
77
 
  for (PinguIter pingu = holder->begin(); pingu != holder->end(); ++pingu)
78
 
    {
79
 
      if (   (*pingu)->get_x() > data->pos.x     && (*pingu)->get_x() < data->pos.x + block_sur.get_width()
80
 
          && (*pingu)->get_y() > data->pos.y - 4 && (*pingu)->get_y() < data->pos.y + block_sur.get_height())
81
 
        {
82
 
          last_contact = world->get_game_time()->get_ticks();
83
 
        }
84
 
    }
85
 
 
86
 
  if (last_contact && last_contact + 1000 > world->get_game_time()->get_ticks())
87
 
    {
88
 
      //std::cout << "IceBlock: Catched Pingu: " << thickness  << std::endl;
89
 
      thickness -= 0.01f;
90
 
 
91
 
      if (thickness < 0)
92
 
        {
93
 
          is_finished = true;
94
 
          thickness = 0;
95
 
          CL_Surface surf(PingusResource::load_surface("iceblock_cmap", "worldobjs"));
96
 
          world->get_colmap ()->remove(surf, static_cast<int>(data->pos.x), static_cast<int>(data->pos.y));
97
 
          world->get_gfx_map()->remove(surf, static_cast<int>(data->pos.x), static_cast<int>(data->pos.y));
98
 
          return;
99
 
        }
100
 
    }
101
 
}
102
 
 
103
 
} // namespace WorldObjs
104
 
 
105
 
/* EOF */