Collisions moved to more reasonable location. Added global vairable This which will...
authorunknown <ivan@.ne.tamu.edu>
Wed, 12 Jan 2011 22:53:55 +0000 (16:53 -0600)
committerunknown <ivan@.ne.tamu.edu>
Wed, 12 Jan 2011 22:53:55 +0000 (16:53 -0600)
Animation.h
Background.h
Collision.h
Level.h
Sprite.h
main.cpp

index 8db9525..a4b3800 100644 (file)
@@ -4,10 +4,18 @@
 #include <string>
 #include <SDL/SDL.h>
 #include <SDL/SDL_image.h>
+#include <vector>
+
+using std::vector;
 
 struct SpriteFrame{
        SDL_Surface *image;/**< Pointer to an image. */
-       int pause;;/**< Tells the amount of time to pause between this frame and the next. */
+       int pause;/**< Tells the amount of time to pause between this frame and the next. */
+       int width;/**< Base width of the frame's image. */
+       int height;/**< Base height of the frame's image. */
+       vector<Point2D> hotSpots;/**< Hot spots that can be used for locating objects on the sprite default is tagged to center of the sprite \todo implement default*/
+       Point2D animationPeg;/**< The offeset from position to place the image. Defaults to (0,0) \todo implement */
+       vector<Collision> bounds;/**< The collision data for this sprite */
 };
 
 /**
@@ -28,7 +36,6 @@ class Animation
         mNumFrames,/**< Number of frames in this Animation */
         mW,/**< Animation's current width */
         mH;/**< The animation's current Height */
-       Collision collisionData;
 
        private:
        std::string mname;//add name to anim file HERE
index 51c0365..f2361d3 100644 (file)
@@ -3,8 +3,11 @@
 #include "fns.h"
 #include "Collision.h"
 #include <string>
+#include <vector>
 #include <iostream>
 
+using std::string;
+using std::vector;
 /**
   The Background
 
@@ -15,7 +18,7 @@
 
 class Background{
        private:
-       std::string _name;///<The background's name
+       string _name;///<The background's name
        SizeD _imageSize;///<The actual background image's full size.
 
        SDL_Surface *mBackground;///<pointer to the actual screen 
@@ -24,13 +27,13 @@ class Background{
        SizeD mScreenSize;///<This is the size of the screen to be drawn to. used to get the sections of the background when moving and for screen-at-a-time scrolling.
        SDL_Rect source;///< This is the rectangle that gets taken from the actual background image (h,w) determine the size of the rectangle to sample from the background image. (x,y) determine the position of the rectangle's top left corner on the actual background image.
        bool wrapping;
-       Collision collisionData;///<The collision data for this Background \todo implement collisions
+       vector<Collision> collisionData;///<The collision data for this Background \todo implement collisions
 
        
        public:
        Background(     SDL_Surface *screen,
-                               std::string name="default", 
-                               std::string filename="bg.bmp", 
+                               string name="default", 
+                               string filename="bg.bmp", 
                                bool wrap=true, 
                                Point2D ScreenPosition=Point2D(0,0), 
                                SizeD screenSize=SizeD(800,600),
@@ -38,10 +41,10 @@ class Background{
                                SizeD bgSize=SizeD(800,600)
        );
        void draw();/**< Draw background. */
-       std::string getName(){ return _name; }/** Returns name. */
-       void setName(std::string name){ _name = name; }/** Set Name. */
+       string getName(){ return _name; }/** Returns name. */
+       void setName(string name){ _name = name; }/** Set Name. */
        SizeD size(){ return _imageSize;}/** returns image size */
-       SDL_Surface* load(std::string name="default");///< Loads a Bacground by name.
+       SDL_Surface* load(string name="default");///< Loads a Bacground by name.
        SizeD getPosition(){return mPos;}
        void setWrap(bool tf);
        bool getWrap();
index 752c97f..1228f15 100644 (file)
@@ -11,15 +11,16 @@ using std::string;
   This defines Collision boundaries and data for objects/levels
 
   This class is tasked with the following:
-    - being a parent container for actions.
+    - being a parent for collisions.
  */
 
 class Collision
 {
 public:
        Collision();
-       virtual bool rectColl(Collision &c);
-       virtual bool circColl(Collision &c);
+       Point2D pos;/**< The position of the center of the collision data */
+       virtual bool rectColl(Collision &c);/**< Check collision with Rectangle */
+       virtual bool circColl(Collision &c);/**< Check collision with Circle */
        /// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
 protected:
        string name;///< Name of this behavior \todo make this actually be useful
@@ -29,25 +30,32 @@ protected:
   This defines CollisionRectangle boundaries and data for objects/levels
 
   This class is tasked with the following:
-    - being a parent container for actions.
+    - Defining a collision rectangle.
+       - Checking collisions with other Rectangles
+       - Checking collisions with circles
  */
 
 class CollisionRectangle : public Collision
 {
 public:
        CollisionRectangle();
+       int width;
+       int height;
 };
 
 /**
   This defines CollisionCircle boundaries and data for objects/levels
 
   This class is tasked with the following:
-    - being a parent container for actions.
+    - Defining a collision circle.
+       - Checking collisions with Rectangles
+       - Checking collisions with other circles
  */
 
 class CollisionCircle : public Collision
 {
 public:
        CollisionCircle();
+       int radius;/**< The raidus of the circle */
 };
 #endif
diff --git a/Level.h b/Level.h
index 8ae7a22..7aff340 100644 (file)
--- a/Level.h
+++ b/Level.h
@@ -45,12 +45,13 @@ protected://allow inheritance
        Background* mBackground;/**< Pointer to the current Background. */
        SDL_Surface *mScreen;/**< Pointer to the screen. */
        //LevelBehavior mBehavior;/**< will be used to define the start actions, update, and leaving actions of the level */
-       vector<Sprite*> mSprites;/**< Vector of all sprites on the level. \todo Maybe make into map? This should be a list of World objects once implemented.*/
+       vector<Sprite*> mSprites;/**< Vector of all sprites on the level. \todo Maybe make into map? This should be a list of World objects once implemented. \todo add accessor or move to public*/
+       map<string,Actor> mActors;/**< This level's actors. */
+       vector<Animation> mAnim;/**< This level's Animations */
        void DrawIMG();/**< Draws an image to the screen. (Not used) */
        void DrawIMG(SDL_Surface *img, int x, int y);/**< Draws the specified image to the screen at location (x,y) */
        void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2);/**< Draws an image at the specified location (x,y) that is blitted with width w and height h from the point (x2,y2) of the given image */
        void DrawSprites();/**< Draws all Sprites. */
-       map<string,Actor> mActors;/**< This level's actors. */
-       vector<Animation> mAnim;/**< This level's Animations */
+       
 };
 #endif
index 70f585c..3fc47da 100644 (file)
--- a/Sprite.h
+++ b/Sprite.h
@@ -5,7 +5,6 @@
 #include "fns.h"
 #include "Actor.h"
 #include "Behaviors.h"
-#include "Collision.h"
 
 /**
   Characters and other mobile objects displayed on screen with animations.
@@ -47,7 +46,6 @@ class Sprite
        Point2D mPos;/**< Object's position */
        bool mVisible;/**< Determine if Object should be visible */
        //SpriteBehavior mBehavior;/**< \todo implement*/
-       Collision collisionData;/**< Collision data \todo implement*/
        int ZOrder;/**< Stacking order. Determines what draws on top. \todo implement. */
 };
 #endif
index d55b70f..23bec13 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -81,6 +81,8 @@ bufp[0] = color;
     }
 }
 
+///This is a pointer so that all objects in-game can obtain data that is needed everywhere. \todo make so that we have This.game or This->game
+Game* This;
 
 //-------------------------------------------------------------------//
 // Function : main()    - Params : argc, argv
@@ -90,7 +92,7 @@ bufp[0] = color;
 int main (int argc, char *argv[])
 {
        Game g;
-
+       This = &g;
        g.run();
 
     return 0;