~ubuntu-branches/ubuntu/trusty/plee-the-bear/trusty-proposed

« back to all changes in this revision

Viewing changes to plee-the-bear/src/ptb/item/code/hazelnut.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Plee the Bear
 
3
 
 
4
  Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
 
5
 
 
6
  This program is free software; you can redistribute it and/or modify it
 
7
  under the terms of the GNU General Public License as published by the
 
8
  Free Software Foundation; either version 2 of the License, or (at your
 
9
  option) any later version.
 
10
 
 
11
  This program is distributed in the hope that it will be useful, but WITHOUT
 
12
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
13
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
14
  more details.
 
15
 
 
16
  You should have received a copy of the GNU General Public License along
 
17
  with this program; if not, write to the Free Software Foundation, Inc.,
 
18
  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 
 
20
  contact: plee-the-bear@gamned.org
 
21
 
 
22
  Please add the tag [PTB] in the subject of your mails.
 
23
*/
 
24
/**
 
25
 * \file hazelnut.cpp
 
26
 * \brief Implementation of the ptb::hazelnut class.
 
27
 * \author Sebastien Angibaud
 
28
 */
 
29
#include "ptb/item/hazelnut.hpp"
 
30
 
 
31
#include "ptb/player.hpp"
 
32
#include "ptb/level_variables.hpp"
 
33
 
 
34
BASE_ITEM_EXPORT( hazelnut, ptb )
 
35
 
 
36
/*----------------------------------------------------------------------------*/
 
37
/**
 
38
 * \brief Contructor.
 
39
 */
 
40
ptb::hazelnut::hazelnut()
 
41
{
 
42
  set_can_move_items(false);
 
43
  set_elasticity(1);
 
44
  set_friction(0.98);
 
45
  set_mass(20);
 
46
  set_density(2);
 
47
} // hazelnut::hazelnut()
 
48
 
 
49
/*----------------------------------------------------------------------------*/
 
50
/**
 
51
 * \brief Load the media required by this class.
 
52
 */
 
53
void ptb::hazelnut::pre_cache()
 
54
{
 
55
  super::pre_cache();
 
56
 
 
57
  get_level_globals().load_animation("animation/owl/hazelnut.canim");
 
58
} // hazelnut::pre_cache()
 
59
 
 
60
/*----------------------------------------------------------------------------*/
 
61
/**
 
62
 * \brief Initialize the item.
 
63
 */
 
64
void ptb::hazelnut::build()
 
65
{
 
66
  super::build();
 
67
 
 
68
  set_animation
 
69
    ( get_level_globals().get_animation("animation/owl/hazelnut.canim") );
 
70
 
 
71
  set_size( get_animation().get_size() );
 
72
} // hazelnut::build()
 
73
 
 
74
/*---------------------------------------------------------------------------*/
 
75
/**
 
76
 * \brief Do one iteration in the progression of the item.
 
77
 * \param elapsed_time Elapsed time since the last call.
 
78
 */
 
79
void ptb::hazelnut::progress( bear::universe::time_type elapsed_time )
 
80
{
 
81
  super::progress(elapsed_time);
 
82
 
 
83
  if ( has_bottom_contact() )
 
84
    add_internal_force( bear::universe::force_type(0, 200000) );
 
85
} // hazelnut::progress()
 
86
 
 
87
/*----------------------------------------------------------------------------*/
 
88
/**
 
89
 * \brief Check if the collision is with a player.
 
90
 * \param that The other item of the collision.
 
91
 * \param info Some informations about the collision.
 
92
 */
 
93
void ptb::hazelnut::collision_check_and_apply
 
94
( bear::engine::base_item& that, bear::universe::collision_info& info )
 
95
{
 
96
  player* p = dynamic_cast<player*>(&that);
 
97
 
 
98
  if ( p != NULL )
 
99
    {
 
100
      if ( !level_variables::get_hazelnut(get_level()) )
 
101
        {
 
102
          if ( info.get_collision_side() != bear::universe::zone::middle_zone)
 
103
            {
 
104
              level_variables::set_hazelnut(get_level(), true);
 
105
              kill();
 
106
            }
 
107
          else
 
108
            default_collision(info);
 
109
        }
 
110
      else
 
111
        default_collision(info);
 
112
    }
 
113
  else
 
114
    default_collision(info);
 
115
} // hazelnut::collision_check_and_apply()
 
116
 
 
117
/*----------------------------------------------------------------------------*/
 
118
/**
 
119
 * \brief Call collision_check_and_apply().
 
120
 * \param that The other item of the collision.
 
121
 * \param info Some informations about the collision.
 
122
 */
 
123
void ptb::hazelnut::collision
 
124
( bear::engine::base_item& that, bear::universe::collision_info& info )
 
125
{
 
126
  collision_check_and_apply(that, info);
 
127
} // hazelnut::collision()