From 98b43c59b35fee3909b252710597560d983016fc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Jan 2011 16:53:55 -0600 Subject: [PATCH] Collisions moved to more reasonable location. Added global vairable This which will give us acess to the game. Decide on reorganization of parts --- Animation.h | 11 +++++++++-- Background.h | 17 ++++++++++------- Collision.h | 18 +++++++++++++----- Level.h | 7 ++++--- Sprite.h | 2 -- main.cpp | 4 +++- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Animation.h b/Animation.h index 8db9525..a4b3800 100644 --- a/Animation.h +++ b/Animation.h @@ -4,10 +4,18 @@ #include #include #include +#include + +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 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 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 diff --git a/Background.h b/Background.h index 51c0365..f2361d3 100644 --- a/Background.h +++ b/Background.h @@ -3,8 +3,11 @@ #include "fns.h" #include "Collision.h" #include +#include #include +using std::string; +using std::vector; /** The Background @@ -15,7 +18,7 @@ class Background{ private: - std::string _name;/// collisionData;/// mSprites;/**< Vector of all sprites on the level. \todo Maybe make into map? This should be a list of World objects once implemented.*/ + vector 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 mActors;/**< This level's actors. */ + vector 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 mActors;/**< This level's actors. */ - vector mAnim;/**< This level's Animations */ + }; #endif diff --git a/Sprite.h b/Sprite.h index 70f585c..3fc47da 100644 --- 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 diff --git a/main.cpp b/main.cpp index d55b70f..23bec13 100644 --- 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; -- 2.11.0