]> Dogcows Code - chaz/yoink/blobdiff - src/Character.cc
initial mesh testing
[chaz/yoink] / src / Character.cc
index a857cbebfa6fffbb76facc3830c220d67df59b52..c5d48385c8793bc71db777f4e3416bc4dabe3909 100644 (file)
@@ -79,7 +79,7 @@ Character::Character(const std::string& name) :
 
        // starting position
        state_.position = moof::vector2(5.0, 5.0);
-       state_.momentum = moof::vector2(0.0, 0.0);
+       state_.momentum = moof::vector2(1.0, 0.0);
        state_.recalculate();
 
        prev_state_ = state_;
@@ -98,37 +98,27 @@ 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;
-
-       //glColor3f(1.0f, 1.0f, 1.0f);
-       tilemap.bind();
-
-       int frame = animation.getFrame();
-       moof::texture::orientation orientation = moof::texture::normal;
+       const moof::vector2& position = state.position;
 
-       if (state_.velocity[0] < 0.0) orientation = moof::texture::reverse;
+       const moof::scalar s = 0.5;
 
-       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);
 }
 
 
This page took 0.02262 seconds and 4 git commands to generate.