~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/link_on_players.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
1
/*
2
2
  Plee the Bear
3
3
 
4
 
  Copyright (C) 2005-2009 Julien Jorge, Sebastien Angibaud
 
4
  Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
5
5
 
6
6
  This program is free software; you can redistribute it and/or modify it
7
7
  under the terms of the GNU General Public License as published by the
32
32
 
33
33
#include "engine/export.hpp"
34
34
 
35
 
#include <limits>
36
 
 
37
35
BASE_ITEM_EXPORT( link_on_players, ptb )
38
36
 
39
37
/*----------------------------------------------------------------------------*/
46
44
    m_minimal_length(0),
47
45
    m_maximal_length
48
46
  (std::numeric_limits<bear::universe::coordinate_type>::infinity()),
49
 
    m_current_sprite(&m_off), m_link_visual(NULL)
 
47
    m_link_visual(NULL)
50
48
{
51
49
 
52
50
} // link_on_players::link_on_players()
59
57
ptb::link_on_players::link_on_players( const link_on_players& that )
60
58
  : super(that), m_strength(that.m_strength),
61
59
    m_minimal_length(that.m_minimal_length),
62
 
    m_maximal_length(that.m_maximal_length), m_off(that.m_off),
63
 
    m_single(that.m_single), m_all(that.m_all), m_current_sprite(&m_off),
 
60
    m_maximal_length(that.m_maximal_length),
64
61
    m_link_visual(NULL)
65
62
{
66
63
  if (that.m_link_visual != NULL)
78
75
 
79
76
/*----------------------------------------------------------------------------*/
80
77
/**
81
 
 * \brief Load the resources needed by this item.
82
 
 */
83
 
void ptb::link_on_players::pre_cache()
84
 
{
85
 
  super::pre_cache();
86
 
  get_level_globals().load_image("gfx/coop/linker.png");
87
 
} // link_on_players::pre_cache()
88
 
 
89
 
/*----------------------------------------------------------------------------*/
90
 
/**
91
 
 * \brief Initialise the item.
92
 
 */
93
 
void ptb::link_on_players::build()
94
 
{
95
 
  super::build();
96
 
 
97
 
  m_off = get_level_globals().auto_sprite("gfx/coop/linker.png", "off");
98
 
  m_single = get_level_globals().auto_sprite("gfx/coop/linker.png", "single");
99
 
  m_all = get_level_globals().auto_sprite("gfx/coop/linker.png", "all");
100
 
 
101
 
  m_current_sprite = &m_off;
102
 
} // link_on_players::pre_cache()
103
 
 
104
 
/*----------------------------------------------------------------------------*/
105
 
/**
106
 
 * \brief Do one step in the progression of the item.
107
 
 * \param elapsed_time Elapsed time since the last call.
108
 
 */
109
 
void ptb::link_on_players::progress( bear::universe::time_type elapsed_time )
110
 
{
111
 
  m_current_sprite = &m_off;
112
 
 
113
 
  super::progress(elapsed_time);
114
 
} // link_on_players::progress()
115
 
 
116
 
/*----------------------------------------------------------------------------*/
117
 
/**
118
 
 * \brief Get the sprite representing the item.
119
 
 * \param visuals (out) The sprites of the item, and their positions.
120
 
 */
121
 
void ptb::link_on_players::get_visual
122
 
( std::list<bear::engine::scene_visual>& visuals ) const
123
 
{
124
 
  super::get_visual( visuals );
125
 
 
126
 
  add_visual( *m_current_sprite, visuals );
127
 
} // link_on_players::get_visual()
128
 
 
129
 
/*----------------------------------------------------------------------------*/
130
 
/**
131
78
 * \brief Set a field of type <real>.
132
79
 * \param name The name of the field.
133
80
 * \param value The new value of the field.
188
135
 
189
136
/*----------------------------------------------------------------------------*/
190
137
/**
191
 
 * \brief One player is colliding with the item.
192
 
 * \param p The player.
193
 
 */
194
 
void ptb::link_on_players::on_one_player( plee* p )
195
 
{
196
 
  m_current_sprite = &m_single;
197
 
} // link_on_players::on_one_player()
198
 
 
199
 
/*----------------------------------------------------------------------------*/
200
 
/**
201
138
 * \brief All players are colliding with the item.
202
139
 * \param p1 The first player.
203
140
 * \param p2 The second player.
204
141
 */
205
 
void ptb::link_on_players::on_all_players( plee* p1, plee* p2 )
 
142
void ptb::link_on_players::on_all_players( player* p1, player* p2 )
206
143
{
207
144
  // all players does not mean two players in single player game.
208
145
  if ( (p1 != NULL) && (p2 != NULL) )
209
146
    {
210
 
      m_current_sprite = &m_all;
211
 
 
212
147
      if ( !p1->is_linked_to(*p2) )
213
148
        {
214
149
          bear::universe::link* link