]> Dogcows Code - chaz/yoink/blobdiff - src/Character.cc
fixed documentation about where to find licenses
[chaz/yoink] / src / Character.cc
index a857cbebfa6fffbb76facc3830c220d67df59b52..c6a47f9c9ed1f5e605e42b23d6d7fcbfc8702286 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <iostream>
 
@@ -42,6 +40,7 @@ private:
        moof::vector2 location;
 };
 
+
 class ResistanceForce
 {
 public:
@@ -74,18 +73,17 @@ Character::Character(const std::string& name) :
        // forces
        state_.force = moof::vector2(0.0, 0.0);
        //state_.forces.push_back(SpringForce(moof::vector2(5.0, 4.0)));
-       state_.forces.push_back(ResistanceForce(2.0));
+       //state_.forces.push_back(ResistanceForce(2.0));
        //state_.forces.push_back(moof::linear_state<2>::gravity_force(-9.8));
 
        // starting position
        state_.position = moof::vector2(5.0, 5.0);
-       state_.momentum = moof::vector2(0.0, 0.0);
+       state_.momentum = moof::vector2(3.0, 0.0);
        state_.recalculate();
 
        prev_state_ = state_;
 }
 
-
 void Character::update(moof::scalar t, moof::scalar dt)
 {
        moof::rigid_body2::update(t, dt); // update physics
@@ -98,40 +96,28 @@ void Character::update(moof::scalar t, moof::scalar dt)
 
        aabb_.init(a, b);
        sphere_.init(center, a);
-}
 
+       int frame = animation.getFrame();
+       tilemap.tile(frame);
+}
 
 void Character::draw(moof::scalar alpha) const
 {
        moof::state2 state = moof::rigid_body2::state(alpha);
-       moof::vector2 position = state.position;
+       const moof::vector2& position = state.position;
 
-       //glColor3f(1.0f, 1.0f, 1.0f);
-       tilemap.bind();
+       const moof::scalar s = 0.5;
 
-       int frame = animation.getFrame();
-       moof::texture::orientation orientation = moof::texture::normal;
-
-       if (state_.velocity[0] < 0.0) orientation = moof::texture::reverse;
-
-       moof::scalar coords[8];
-       tilemap.tile_coordinates(frame, coords, orientation);
+       moof::vector3 coords[4];
 
-       moof::scalar s = 0.5;
+       coords[0] = moof::vector3(position[0] - s, position[1] - s, SCALAR(0.0));
+       coords[1] = moof::vector3(position[0] + s, position[1] - s, SCALAR(0.0));
+       coords[2] = moof::vector3(position[0] + s, position[1] + s, SCALAR(0.0));
+       coords[3] = moof::vector3(position[0] - s, position[1] + s, SCALAR(0.0));
 
-       glBegin(GL_TRIANGLE_FAN);
-               glTexCoord(coords[0], coords[1]);
-               glVertex(position[0]-s, position[1]-s);
-               glTexCoord(coords[2], coords[3]);
-               glVertex(position[0]+s, position[1]-s);
-               glTexCoord(coords[4], coords[5]);
-               glVertex(position[0]+s, position[1]+s);
-               glTexCoord(coords[6], coords[7]);
-               glVertex(position[0]-s, position[1]+s);
-       glEnd();
+       tilemap.draw(coords);
 }
 
-
 /*int Character::getOctant(const moof::Aabb<3>& aabb) const
 {
        int octantNum = -1;
@@ -242,7 +228,6 @@ void Character::draw(moof::scalar alpha) const
 }
 */
 
-
 void Character::addImpulse(moof::vector2 impulse)
 {
        state_.momentum += impulse;
This page took 0.024513 seconds and 4 git commands to generate.