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

« back to all changes in this revision

Viewing changes to bear-engine/lib/src/generic_items/code/block_align_top.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
 
  Bear Engine
3
 
 
4
 
  Copyright (C) 2005-2009 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 [Bear] in the subject of your mails.
23
 
*/
24
 
/**
25
 
 * \file block_align_top.cpp
26
 
 * \brief Implementation of the bear::block_align_top class.
27
 
 * \author Sebastien Angibaud
28
 
 */
29
 
#include "generic_items/block_align_top.hpp"
30
 
 
31
 
#include "universe/collision_info.hpp"
32
 
#include "universe/collision_repair.hpp"
33
 
#include "engine/export.hpp"
34
 
 
35
 
BASE_ITEM_EXPORT( block_align_top, bear )
36
 
 
37
 
/*----------------------------------------------------------------------------*/
38
 
/**
39
 
 * \brief Contructor.
40
 
 */
41
 
bear::block_align_top::block_align_top()
42
 
  : m_top_friction(1)
43
 
{
44
 
 
45
 
} // block_align_top::block_align_top()
46
 
 
47
 
/*----------------------------------------------------------------------------*/
48
 
/**
49
 
 * \brief Check if the collision is on a solid side and align the other item.
50
 
 * \param that The other item of the collision.
51
 
 * \param info Some informations about the collision.
52
 
 */
53
 
void bear::block_align_top::collision_check_and_align
54
 
( engine::base_item& that, universe::collision_info& info )
55
 
{
56
 
  if ( satisfy_collision_condition(that) )
57
 
    if ( ( that.get_left() + that.get_size().x/2 >= get_left() ) &&
58
 
         ( that.get_left() + that.get_size().x/2 <= get_right() ) )
59
 
    {
60
 
      bear::universe::position_type pos(info.get_bottom_left_on_contact());
61
 
      pos.y = get_top()+0.1;
62
 
 
63
 
      if ( ! info.other_item().is_phantom() )
64
 
        {
65
 
          info.other_item().set_bottom_left( pos );
66
 
          info.other_item().set_bottom_contact();
67
 
          set_top_contact();
68
 
          
69
 
          info.get_collision_repair().set_contact_normal
70
 
            (info.other_item(), bear::universe::vector_type(0, 1));
71
 
          
72
 
          that.set_contact_friction(m_top_friction);
73
 
          z_shift(that);
74
 
        }
75
 
    }
76
 
} // block_align_top::collision_check_and_align()
77
 
 
78
 
/*----------------------------------------------------------------------------*/
79
 
/**
80
 
 * \brief Call collision_check_and_align().
81
 
 * \param that The other item of the collision.
82
 
 * \param info Some informations about the collision.
83
 
 */
84
 
void bear::block_align_top::collision
85
 
( engine::base_item& that, universe::collision_info& info )
86
 
{
87
 
  collision_check_and_align(that, info);
88
 
} // block_align_top::collision()
89
 
 
90
 
/*----------------------------------------------------------------------------*/
91
 
/**
92
 
 * \brief Set a field of type \c real.
93
 
 * \param name The name of the field.
94
 
 * \param value The new value of the field.
95
 
 * \return false if the field "name" is unknow, true otherwise.
96
 
 */
97
 
bool
98
 
bear::block_align_top::set_real_field( const std::string& name, double value )
99
 
{
100
 
  bool result = true;
101
 
 
102
 
  if (name == "top_friction")
103
 
    m_top_friction = value;
104
 
  else
105
 
    result = super::set_real_field(name,value);
106
 
 
107
 
  return result;
108
 
} // block_aligne_top::set_real_field()