-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string>\r
-#include <SDL/SDL.h>\r
-#include <iostream>\r
-#include <sstream>\r
-#include <vector>\r
-#include "fns.h"\r
-#include "Game.h"\r
-\r
-using namespace std;\r
-\r
-template<class T> string to_string(const T& t)\r
-{\r
- ostringstream os;\r
- os << t;\r
- return os.str();\r
-}\r
-//locks the screen for drawing pixels to the screen\r
-void Slock(SDL_Surface *screen)\r
-{ \r
- if ( SDL_MUSTLOCK(screen) )\r
- { \r
- if ( SDL_LockSurface(screen) < 0 )\r
- {\r
- return;\r
- }\r
- }\r
-}\r
-\r
-void Sulock(SDL_Surface *screen)\r
-{ \r
- if ( SDL_MUSTLOCK(screen) )\r
- {\r
- SDL_UnlockSurface(screen);\r
- }\r
-}\r
-\r
-void DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G, Uint8 B)\r
-{\r
-Uint32 color = SDL_MapRGB(screen->format, R, G, B);\r
- switch (screen->format->BytesPerPixel)\r
- {\r
- case 1: // Assuming 8-bpp\r
- {\r
- Uint8 *bufp;\r
- bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;\r
- *bufp = color;\r
- }\r
- break;\r
- case 2: // Probably 15-bpp or 16-bpp\r
- {\r
- Uint16 *bufp;\r
- bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;\r
- *bufp = color;\r
- }\r
- break;\r
- case 3: // Slow 24-bpp mode, usually not used\r
- {\r
- Uint8 *bufp;\r
- bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;\r
- if(SDL_BYTEORDER == SDL_LIL_ENDIAN)\r
- {\r
-bufp[0] = color;\r
- bufp[1] = color >> 8;\r
- bufp[2] = color >> 16;\r
- } else {\r
- bufp[2] = color;\r
- bufp[1] = color >> 8;\r
- bufp[0] = color >> 16;\r
- }\r
- }\r
- break;\r
- case 4: // Probably 32-bpp\r
- {\r
- Uint32 *bufp;\r
- bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;\r
- *bufp = color;\r
- }\r
- break;\r
- }\r
-}\r
-\r
-\r
-//-------------------------------------------------------------------//\r
-// Function : main() - Params : argc, argv\r
-// Main program function\r
-// This function calls the init() function then loops on draw function \r
-// until an escape condition is reached\r
-int main (int argc, char *argv[])\r
-{\r
- Game g;\r
-\r
- g.run();\r
-\r
- return 0;\r
-}\r
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#include <SDL/SDL.h>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include "fns.h"
+#include "Game.h"
+
+using namespace std;
+
+template<class T> string to_string(const T& t)
+{
+ ostringstream os;
+ os << t;
+ return os.str();
+}
+//locks the screen for drawing pixels to the screen
+void Slock(SDL_Surface *screen)
+{
+ if ( SDL_MUSTLOCK(screen) )
+ {
+ if ( SDL_LockSurface(screen) < 0 )
+ {
+ return;
+ }
+ }
+}
+
+void Sulock(SDL_Surface *screen)
+{
+ if ( SDL_MUSTLOCK(screen) )
+ {
+ SDL_UnlockSurface(screen);
+ }
+}
+
+void DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G, Uint8 B)
+{
+Uint32 color = SDL_MapRGB(screen->format, R, G, B);
+ switch (screen->format->BytesPerPixel)
+ {
+ case 1: // Assuming 8-bpp
+ {
+ Uint8 *bufp;
+ bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
+ *bufp = color;
+ }
+ break;
+ case 2: // Probably 15-bpp or 16-bpp
+ {
+ Uint16 *bufp;
+ bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;
+ *bufp = color;
+ }
+ break;
+ case 3: // Slow 24-bpp mode, usually not used
+ {
+ Uint8 *bufp;
+ bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;
+ if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
+ {
+bufp[0] = color;
+ bufp[1] = color >> 8;
+ bufp[2] = color >> 16;
+ } else {
+ bufp[2] = color;
+ bufp[1] = color >> 8;
+ bufp[0] = color >> 16;
+ }
+ }
+ break;
+ case 4: // Probably 32-bpp
+ {
+ Uint32 *bufp;
+ bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;
+ *bufp = color;
+ }
+ break;
+ }
+}
+
+
+//-------------------------------------------------------------------//
+// Function : main() - Params : argc, argv
+// Main program function
+// This function calls the init() function then loops on draw function
+// until an escape condition is reached
+int main (int argc, char *argv[])
+{
+ Game g;
+
+ g.run();
+
+ return 0;
+}
+