Introduced Collision data.
}
}
}
+ /// \todo add collision info obtained from file.
fin.close();
return 0;
}
#ifndef SPRITEBASE
#define SPRITEBASE
+#include "Collision.h"
#include <string>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
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
#ifndef BACKGROUND
#define BACKGROUND
#include "fns.h"
+#include "Collision.h"
#include <string>
#include <iostream>
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
public:
#ifndef BEHAVIOR
#define BEHAVIOR
-#include "Sprite.h"
-#include "Background.h"
+#include "fns.h"
#include <vector>
-#include <map>
#include <string>
using std::vector;
{
public:
Behavior();
- Behavior(string Name):name(Name);
+ Behavior(string Name):name(Name){}/**< \todo finish this */
virtual void load();/**< Loading Behavior*/
virtual void update();/**< Update Behavior*/
virtual void unload();/**< Delete Behavior*/
--- /dev/null
+#ifndef BEHAVIORS
+#define BEHAVIORS
+#include "Behavior.h"
+#include <vector>
+#include <string>
+
+using std::vector;
+using std::string;
+
+/**
+ This is an action that a Behavior, Sprite, or other object can have.
+
+ This class is tasked with the following:
+ - All actions for the World Level.
+ */
+
+class LevelBehavior : public Behavior
+{
+public:
+ LevelBehavior();
+ virtual void load();/**< Loading Behavior*/
+ virtual void update();/**< Update Behavior*/
+ virtual void unload();/**< Delete Behavior*/
+ //Level* level;
+};
+
+/**
+ This is an action that a Behavior, Sprite, or other object can have.
+
+ This class is tasked with the following:
+ - All actions for Sprites.
+ */
+class SpriteBehavior : public Behavior
+{
+public:
+ SpriteBehavior();
+ virtual void load();/**< Loading Behavior*/
+ virtual void update();/**< Update Behavior*/
+ virtual void unload();/**< Delete Behavior*/
+ //Sprite* sprite;
+};
+#endif
--- /dev/null
+#ifndef COLLISION
+#define COLLISION
+#include "fns.h"
+#include <vector>
+#include <string>
+
+using std::vector;
+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.
+ */
+
+class Collision
+{
+public:
+ Collision();
+ virtual bool rectColl(Collision &c);
+ virtual bool circColl(Collision &c);
+ /// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
+protected:
+ string name;///< Name of this behavior \todo make this actually be useful
+};
+
+/**
+ This defines CollisionRectangle boundaries and data for objects/levels
+
+ This class is tasked with the following:
+ - being a parent container for actions.
+ */
+
+class CollisionRectangle : public Collision
+{
+public:
+ CollisionRectangle();
+};
+
+/**
+ This defines CollisionCircle boundaries and data for objects/levels
+
+ This class is tasked with the following:
+ - being a parent container for actions.
+ */
+
+class CollisionCircle : public Collision
+{
+public:
+ CollisionCircle();
+};
+#endif
/** load background */
mBackground= new Background(screen, n);//mBackground = LoadImage("Backgrounds/bg.bmp");
}
+
+Level::Level(SDL_Surface* screen,string n, string behavior/** \todo implement obtaining correct behavior maybe a fn get Behavior */) : mScreen(screen), mName(n)
+{
+ /** load background */
+ mBackground= new Background(screen, n);//mBackground = LoadImage("Backgrounds/bg.bmp");
+ /// \todo make this wotk
+ //mBehavior.load();
+}
+
Level::~Level()
{
for (size_t i = 0; i < mSprites.size(); ++i) {
/** Will handle all movement and dynamic triggers. */
void Level::update(){
-
+ /// \todo fix this too
+ //mBehavior.update();
}
#define LEVEL
#include "Sprite.h"
#include "Background.h"
+#include "Behaviors.h"
#include <vector>
#include <map>
+
+
#include <string>
using std::vector;
public:
Level(SDL_Surface *screen);
Level(SDL_Surface *screen, string name);
+ Level(SDL_Surface *screen, string name, string behavior);
~Level();
- virtual void drawScene();/**< Draws everything that is set to draw on the screen. */
+ void drawScene();/**< Draws everything that is set to draw on the screen. */
void LoadBG(string name);/**< Loads the Background. */
virtual void postEvent(SDL_Event event);/**< Passes along SDL events */
virtual void update();/**< Loop that runs every game frame that calculates movement, placement, etc. as well as obtains key strokes (limited by keyboard hardware)*/
string mName;
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.*/
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 */
};
mSprites.push_back(sun);
}
-void LevelWorld::drawScene()
-{
- Uint32 color;
- /** Create a black mBackgroundground using the mScreen pixel format (32 bpp) */
- color = SDL_MapRGB(mScreen->format, 0, 0, 0);
- SDL_FillRect(mScreen, NULL, color);
-
- /** Draw BG */
- mBackground->draw();
-
- /** Draw Sprites*/
- DrawSprites();
-
- /** Flip the working image buffer with the mScreen buffer */
- SDL_Flip (mScreen);
-}
/** Will handle all movement and dynamic triggers. */
void LevelWorld::update()
#include <string>
#include "fns.h"
#include "Actor.h"
+#include "Behaviors.h"
+#include "Collision.h"
/**
Characters and other mobile objects displayed on screen with animations.
SDL_Surface *mScreen;/**< Screen to be drawn to. */
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