pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/movers Makefile.am,NONE,1.1 linear_mo


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/movers Makefile.am,NONE,1.1 linear_mover.cxx,NONE,1.1 linear_mover.hxx,NONE,1.1
Date: 12 Feb 2003 22:43:40 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/movers
In directory dark:/tmp/cvs-serv7222/movers

Added Files:
        Makefile.am linear_mover.cxx linear_mover.hxx 
Log Message:
added mover/collider implementations


--- NEW FILE: Makefile.am ---
# Pingus - A free Lemmings clone
# Copyright (C) 1999 Ingo Ruhnke <address@hidden>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

libdir=$(prefix)/share/games/@PACKAGE@/libs

EXTRA_DIST = README

# -- Dynamic Libs --
#lib_LTLIBRARIES = libpingus_movers.la


# -- Static Libs --
noinst_LIBRARIES = libpingus_movers.a

libpingus_movers_a_SOURCES =       \
         linear_mover.cxx   linear_mover.hxx

# EOF #

--- NEW FILE: linear_mover.cxx ---
//  $Id: linear_mover.cxx,v 1.1 2003/02/12 22:43:38 torangan Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#include "linear_mover.hxx"
#include "../collider.hxx"

namespace Movers {

LinearMover::LinearMover(World* const world_arg, const Vector& pos_arg)
  : Mover(world_arg, pos_arg)
{
}

LinearMover::~LinearMover()
{
}

void LinearMover::update(const Vector& move, const Collider& collision_at)
{
  float move_length = move.length();
  Vector target_pos = pos + move;
  Vector step_vector = move;

  // Make the step vector (i.e. change to a unit vector)
  step_vector.normalize();

  collision = false;

  // Move to the destination one unit vector at a time
  for (float i = 0; i < move_length && !collision; ++i)
    {
      pos += step_vector;

      collision = collision_at(world, pos);
    }

  // If on a collision pixel, back away from it.
  if (collision)
    pos -= step_vector;

  remaining_move = target_pos - pos;
}

} // namespace Movers

/* EOF */

--- NEW FILE: linear_mover.hxx ---
//  $Id: linear_mover.hxx,v 1.1 2003/02/12 22:43:38 torangan Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PINGUS_LINEAR_MOVER_HXX
#define HEADER_PINGUS_LINEAR_MOVER_HXX

#include "../mover.hxx"

class Collider;

namespace Movers {

class LinearMover : public Mover
{
  public:
    /** Constructor */
    LinearMover(World* const world_arg, const Vector& pos_arg);

    /** Destructor */
    ~LinearMover();

    /** Updates the position of the object taking into account collisions */
    void update(const Vector& move, const Collider& collision_at);
};

} // namespace Movers

#endif

/* EOF */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]