using namespace std;
Background::Background(SDL_Surface *screen, std::string name, std::string filename, bool wrap, Point2D ScreenPosition, SizeD ScreenSize, Point2D bgSamplePos, SizeD bgSize):mScreen(screen),_name(name),wrapping(wrap),mPos(ScreenPosition),mScreenSize(ScreenSize){
-
+/// \todo refactor all width as w height as h X as x Y as y so on and so forth for everything. different things are annoying
mScreenSize.width = screen->w;
mScreenSize.height = screen->h;
source.w = bgSize.width;
}
void Background::draw(){
/** \todo make the drawing for everything be sectioned if that'd make it faster otherwise create tiling for backgrounds smaller than the screen size*/
- /** \todo we need to make this do wrapping if wanted/decide if it should be a good default.*/
+ /** \todo decide if wrapping should be a good default.*/
///destination rectangle only position is used and describes where the output is drawn.
if(wrapping){
SDL_Rect extraX;///<keeps track of pos and size of the sample that hangs off the x
dests.x=0;
dests.y=0;
///hanging off the right side
- if(mPos.x+_imageSize > mScreenSize){
- extraX.x = _imageSize.width-mPos.x;
- extraX.Y = _imageSize.height-mPos.y;
- extraX.w = mPos.x;
- extrax.h = mScreenSize.height;
+ if(mPos.X > 0 || mPos.Y > 0 /*+ _imageSize.width > mScreenSize.width*/){
+ extraX.x = 0;
+ extraX.y = 0;
+ extraX.w = mPos.X;
+ extraX.h = mScreenSize.height - mPos.Y;
SDL_BlitSurface(mBackground, &extraX, mScreen, &dests);
}
///hanging off the left side
- if(mPos+.x_imageSize < mScreenSize){
+ if(mPos.X + _imageSize.width < mScreenSize.width){
extraX.x = 0;
- extraX.Y = 0;
- extraX.w = -mPos.x;
- extrax.h = mScreenSize.height;
+ extraX.y = 0;
+ extraX.w = -mPos.X;
+ extraX.h = mScreenSize.height;
SDL_BlitSurface(mBackground, &extraX, mScreen, &dests);
}
return mBackground;
}
-void Background::setWrapping(bool tf){
+void Background::setWrap(bool tf){
wrapping=tf;
}
/** Will handle all movement and dynamic triggers. */
void Level::update()
{
- Uint8 *keys = SDL_GetKeyState(NULL);
+ /*int* numkeys;*//// \todo Get keyboard as whole input to function correctly.
+ Uint8 *keys = SDL_GetKeyState(/*numkeys*/NULL);
+ //std::cout << *numkeys << ">>>";
if ( keys[SDLK_LEFT] ) { mSprites[0]->xadd(-1); }
if ( keys[SDLK_RIGHT] ) { mSprites[0]->xadd(1); }
if ( keys[SDLK_UP] ) { mSprites[0]->yadd(-1); }
void startAnim() {mAnimating = 1;}/**< Causes the animation to play. */
void stopAnim() {mAnimating = 0;}/**< Causes the animation to stop. */
void rewind() {mActor.mFrame = 0;}/**< Resets the Sprite's animation to the first frame. */
- void xadd(int num) {mX += num;}/**< Increase X coordiante by a given amount. */
- void yadd(int num) {mY += num;}/**< Increase Y coordinate by a given amount. */
- void xset(int x) {mX = x;}/**< Sets the Sprite's X Coordinate. */
- void yset(int y) {mY = y;}/**< Sets the Sprite's Y coordinate. */
- void setPosition(int x, int y) {mX = x; mY = y;}/**< Sets the Sprite's X an Y coordinate. */
+ void xadd(int num) {mPos.X += num;}/**< Increase X coordiante by a given amount. */
+ void yadd(int num) {mPos.Y += num;}/**< Increase Y coordinate by a given amount. */
+ void xset(int x) {mPos.X = x;}/**< Sets the Sprite's X Coordinate. */
+ void yset(int y) {mPos.Y = y;}/**< Sets the Sprite's Y coordinate. */
+ void setPosition(int x, int y) {mPos.X = x; mPos.Y = y;}/**< Sets the Sprite's X an Y coordinate. */
std::string name;
private:
std::string mName;/**< Sprite's name */
- Point2D mPos;
- int mX,mY; /**< Sprite's position \todo make a 2D point class and use instead. */
+ Point2D mPos;/**< Sprite's position */
bool mAnimating;/**< Tells whether to animate or not */
bool mDrawn;/**< Tells if the object has been drawn the first time */
bool mVisible;/**< Determine if Sprite should be visible */