From 98ba22e7064db57316dfff1ae127feb3dceeb73e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 13:58:22 +0200 Subject: Initial commit --- docs/html/_car_8cpp_source.html | 182 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 docs/html/_car_8cpp_source.html (limited to 'docs/html/_car_8cpp_source.html') diff --git a/docs/html/_car_8cpp_source.html b/docs/html/_car_8cpp_source.html new file mode 100644 index 0000000..86062e9 --- /dev/null +++ b/docs/html/_car_8cpp_source.html @@ -0,0 +1,182 @@ + + + + +Rally X: source/logic/Car.cpp Source File + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + +
+
Rally X + +
+
ELEN3009 Project by Justin Wernick and David Schneider
+
+
+ + + + + +
+
+
source/logic/Car.cpp
+
+
+Go to the documentation of this file.
00001 #include "Car.h"
+00002 
+00003 Car::Car(double x, double y, BitmapStore::Image image, Maze::Direction facing)
+00004     :GameObject(x,y,image,facing),
+00005     _speed(_baseSpeed)
+00006 {
+00007 }
+00008 
+00009 double Car::speed() const
+00010 {
+00011     return _speed;
+00012 }
+00013 
+00014 void Car::move(const Maze& maze)
+00015 {
+00016     double targetX = 0;
+00017     double targetY = 0;
+00018 
+00019     int checkX = 0;
+00020     int checkY = 0;
+00021 
+00022     switch(_facing)
+00023     {
+00024         case Maze::UP:
+00025             targetX = MazeMath::round(_x);
+00026             targetY = _y - _speed;
+00027             checkX = floor(targetX);
+00028             checkY = floor(targetY);
+00029             break;
+00030         case Maze::DOWN:
+00031             targetX = MazeMath::round(_x);
+00032             targetY = _y + _speed;
+00033             checkX = floor(targetX);
+00034             checkY = ceil(targetY);
+00035             break;
+00036         case Maze::LEFT:
+00037             targetX = _x - _speed;
+00038             targetY = MazeMath::round(_y);
+00039             checkX = floor(targetX);
+00040             checkY = floor(targetY);
+00041             break;
+00042         case Maze::RIGHT:
+00043             targetX = _x + _speed;
+00044             targetY = MazeMath::round(_y);
+00045             checkX = ceil(targetX);
+00046             checkY = floor(targetY);
+00047             break;
+00048     }
+00049 
+00050     if (!maze.getSolid(checkX, checkY))
+00051     {
+00052         //can move that way
+00053         _x = targetX;
+00054         _y = targetY;
+00055     }
+00056     else
+00057     {
+00058         //can not move to targetX and targetY, but move to the edge of current block
+00059         switch(_facing)
+00060         {
+00061             case Maze::UP:
+00062                 _y = floor(_y);
+00063                 break;
+00064             case Maze::DOWN:
+00065                 _y = ceil(_y);
+00066                 break;
+00067             case Maze::LEFT:
+00068                 _x = floor(_x);
+00069                 break;
+00070             case Maze::RIGHT:
+00071                 _x = ceil(_x);
+00072                 break;
+00073         }
+00074     }
+00075 }
+
+
+ +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator
+ + +
+ +
+ + + + + + + -- cgit v1.2.3