os << t;\r
return os.str();\r
}\r
-\r
-// Allocate a pointer to an SDL_Surface for the screen buffer \r
-// and for the image we want to load and display on screen.\r
-SDL_Surface *back = NULL;\r
-SDL_Surface *screen = NULL;\r
-SDL_Surface *image = NULL;\r
-\r
-//Sprite vikings1;\r
-//Sprite vikings2;\r
-//Sprite sun;\r
-\r
-vector<Sprite> SpriteList;//see about differnt containter HERE\r
-\r
-void DrawSprites()\r
-{\r
- for(int i=0; i<SpriteList.size(); ++i)\r
- {\r
- SpriteList[i].clearBG();\r
- }\r
- for(int i=0; i<SpriteList.size(); ++i)\r
- {\r
- SpriteList[i].updateBG();\r
- }\r
- for(int i=0; i<SpriteList.size(); ++i)\r
- {\r
- SpriteList[i].draw();\r
- }\r
-}\r
-\r
-//functions from other main\r
-\r
//locks the screen for drawing pixels to the screen\r
void Slock(SDL_Surface *screen)\r
{ \r
}\r
}\r
\r
-/*void draw ()\r
-{\r
-\r
- Uint32 color;\r
-\r
- // Create a black background using the screen pixel format (32 bpp)\r
- color = SDL_MapRGB (screen->format, 0, 0, 0);\r
- SDL_FillRect (screen, NULL, color);\r
-\r
- // Set the image offset\r
- SDL_BlitSurface(image, NULL, screen, &rect);\r
-\r
- // Flip the working image buffer with the screen buffer\r
- SDL_Flip (screen);\r
-\r
- // Add a little pause...\r
- SDL_Delay (1);\r
-}*/\r
-\r
-//blits whole image to specified location\r
-void DrawIMG(SDL_Surface *img, int x, int y)\r
-{\r
- SDL_Rect dest;\r
- dest.x = x;\r
- dest.y = y;\r
- SDL_BlitSurface(img, NULL, screen, &dest);\r
-}\r
-\r
-//blits the part of the image defined by x y w and h to the psecified position\r
-void DrawIMG(SDL_Surface *img, int x, int y,\r
- int w, int h, int x2, int y2)\r
-{\r
- SDL_Rect dest;\r
- dest.x = x;\r
- dest.y = y;\r
- SDL_Rect src;\r
- src.x = x2;\r
- src.y = y2;\r
- src.w = w;\r
- src.h = h;\r
- SDL_BlitSurface(img, &src, screen, &dest);\r
-}\r
-\r
-void DrawBG()\r
-{\r
- DrawIMG(back, 0, 0);\r
-}\r
-\r
-//-------------------------------------------------------------------//\r
-// Function : init() - Params : none\r
-// SDL Initialisation function\r
-// Instead of having a heavy and loaded main function, all the \r
-// setting up of our application is handled here\r
-\r
-bool init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-\r
-//-------------------------------------------------------------------//\r
-// Function : draw() - Params : none\r
-// Frame rendering function\r
-// This function is called on every loop, to draw the scene\r
-// It draws then swaps the work and screen buffer to display the scene\r
-void DrawScene(SDL_Surface *screen)\r
-{\r
- /*Tutorial 1\r
- Slock(screen);\r
- for(int x=0;x<640;x++)\r
- { \r
- for(int y=0;y<480;y++)\r
- {\r
- DrawPixel(screen, x,y,y/2,y/2,x/3);\r
- }\r
- }\r
- Sulock(screen);\r
- */\r
- \r
- Uint32 color;\r
-\r
- // Create a black background using the screen pixel format (32 bpp)\r
- color = SDL_MapRGB (screen->format, 0, 0, 0);\r
- SDL_FillRect (screen, NULL, color);\r
- \r
- //Draw BG\r
- DrawBG();\r
- \r
- /*\r
- vikings1.clearBG();\r
- vikings2.clearBG();\r
- sun.clearBG();\r
-\r
- vikings1.updateBG();\r
- vikings2.updateBG();\r
- sun.updateBG();\r
-\r
- vikings1.draw();\r
- vikings2.draw();\r
- sun.draw();\r
- \r
- //*/\r
- DrawSprites();\r
-\r
- // Set the image offset (change to draw a set of passed images)\r
- //DrawIMG(image,x,y);\r
- \r
- // Flip the working image buffer with the screen buffer\r
- SDL_Flip (screen);\r
- \r
- // Add a little pause...\r
- SDL_Delay (1);\r
-}\r
-\r
-\r
-\r
\r
//-------------------------------------------------------------------//\r
// Function : main() - Params : argc, argv\r