00001 #ifndef __BACKGROUND_H 00002 #define __BACKGROUND_H 00003 00004 00005 class Background; 00006 00007 #include <string> 00008 #include "graphics.h" 00009 #include "util.h" 00010 00011 class Background 00012 { 00013 public: 00014 Background (Graphics &); 00015 00016 // Load background class using a static image 00017 Background (string, Graphics &); 00018 00019 // Destructor 00020 ~Background(); 00021 00022 // Utility functions to actually set up a static image 00023 // background. 00024 void SetStatic (string); 00025 void SetStatic (Surface *); 00026 00027 00028 // Functions to draw the background onto the surface 00029 // if needed. 00030 bool Draw (); 00031 bool Draw (Surface *); 00032 00033 // Needed to replace sprites on the screen 00034 // the Rect's should be in screen-coordinates 00035 void DrawRect (Rect &R); 00036 void DrawRect (Surface *, Rect &R); 00037 00038 // Sets the location in the world. subworld-coordinates 00039 bool SetPosition (float, float); 00040 00041 // Get the coordinates 00042 float GetX () const { return xOffset; } 00043 float GetY () const { return yOffset; } 00044 int GetWidth() const { return (staticImage) ? staticImage->w : 0; } 00045 int GetHeight() const { return (staticImage) ? staticImage->h : 0; } 00046 float GetMaxX() const { return xMax; } 00047 float GetMaxY() const { return yMax; } 00048 int GetXint() const { return (int)(xOffset + 0.5); } 00049 int GetYint() const { return (int)(yOffset + 0.5); } 00050 int GetScreenWidth() const { return GD.getWidth(); } 00051 int GetScreenHeight() const { return GD.getHeight(); } 00052 00053 private: 00054 // Need access to the current graphics device 00055 Graphics &GD; 00056 00057 // Private rect blit 00058 void DrawRect (Surface *dest, Rect &R, Rect &S); 00059 00060 // Vars for static redraw 00061 bool staticBackground; 00062 Surface *staticImage; 00063 00064 // true of Draw() should redraw 00065 bool needRedraw; 00066 00067 // Offset from 0,0 in the world. 00068 // i.e. subworld-coordinates 00069 float xOffset, yOffset; 00070 float xMax, yMax; 00071 }; 00072 00073 #endif 00074