Permalink
Browse files

Added boat controls (WASD)

  • Loading branch information...
1 parent 7a62b0a commit 6395cf4b800dee2e7f13896d3a68aa30fd00c0cc @gnuvince committed Jan 26, 2012
Showing with 30 additions and 2 deletions.
  1. +29 −0 Application/Sources/Scene/Boat.cpp
  2. +1 −1 Application/Sources/Scene/Boat.h
  3. +0 −1 Application/Sources/Scene/MainScene.cpp
@@ -93,6 +93,35 @@ void Boat::Animate( const WaterSurface& waterSurface, real time, real dt )
+
+
+ if (MainWindow::Get()->IsKeyPressed('w')) {
+ Transformation<real> t = GetLocalTransformation();
+ t.Translate(Vector3<real>(cos(angle - PI/2)*-20*dt, 0, -sin(angle - PI/2)*-20*dt));
+ SetLocalTransformation(t);
+ }
+
+ if (MainWindow::Get()->IsKeyPressed('s')) {
+ Transformation<real> t = GetLocalTransformation();
+ t.Translate(Vector3<real>(cos(angle - PI/2)*10*dt, 0, -sin(angle - PI/2)*10*dt));
+ SetLocalTransformation(t);
+ }
+
+ if (MainWindow::Get()->IsKeyPressed('a')) {
+ Transformation<real> t = GetLocalTransformation();
+ t.RotateY(dt);
+ SetLocalTransformation(t);
+ angle += dt;
+ }
+
+ if (MainWindow::Get()->IsKeyPressed('d')) {
+ Transformation<real> t = GetLocalTransformation();
+ t.RotateY(-dt);
+ SetLocalTransformation(t);
+ angle -= dt;
+ }
+
+
UnusedParameter( time );
}
@@ -26,7 +26,7 @@ class Boat : public CoreLib::Node<real>
CoreLib::Cube<real> mHull;
CoreLib::BlinnPhongMaterial<real> mHullMaterial;
-
+ real angle;
};
}
@@ -91,7 +91,6 @@ void MainScene::CreateCamera()
///////////////////////////////////////
mBoat.AddChild( &mCamera );
- mBoat.Update();
}

0 comments on commit 6395cf4

Please sign in to comment.