1
// $Id: ice_block.cxx,v 1.21 2003/02/19 09:50:36 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 "../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"
33
IceBlock::IceBlock (const WorldObjsData::IceBlockData& data_)
34
: data(new WorldObjsData::IceBlockData(data_)),
38
block_sur(PingusResource::load_surface ("iceblock", "worldobjs"))
42
IceBlock::~IceBlock ()
48
IceBlock::on_startup ()
50
CL_Surface surf(PingusResource::load_surface("iceblock_cmap", "worldobjs"));
52
world->get_colmap()->put(surf,
53
static_cast<int>(data->pos.x),
54
static_cast<int>(data->pos.y),
55
Groundtype::GP_GROUND);
59
IceBlock::draw (GraphicContext& gc)
66
static_cast<int>((1.0 - thickness) * (block_sur.get_num_frames() - 1)));
75
PinguHolder* holder = world->get_pingus();
77
for (PinguIter pingu = holder->begin(); pingu != holder->end(); ++pingu)
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())
82
last_contact = world->get_game_time()->get_ticks();
86
if (last_contact && last_contact + 1000 > world->get_game_time()->get_ticks())
88
//std::cout << "IceBlock: Catched Pingu: " << thickness << std::endl;
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));
103
} // namespace WorldObjs