00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #include <string>
00021 #include <iostream>
00022
00023 #include "SDL.h"
00024 #include "Person.h"
00025 #include "SDL_image.h"
00026 #include "SDL_mixer.h"
00027 #include "Level.h"
00028
00029 #include "List.h"
00030 #include "Parser.h"
00031 #include "CollisionHandler.h"
00032 #include "CommandManager.h"
00033 #include "Command.h"
00034
00035 #include "Screen.h"
00036
00037 using namespace std;
00038
00039 int main(int argc,char *argv[])
00040 {
00041
00042
00043
00044 string levelfile = "levels/factory";
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 SDL_Event event;
00061
00062
00063 Screen* screen = Screen::instance();
00064
00065
00066
00067
00068 if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
00069 {
00070 return false;
00071 }
00072
00073 Mix_AllocateChannels( 16 );
00074
00075
00076
00077 int ticks = SDL_GetTicks();
00078
00079 glfuncs* f = glfuncs::instance();
00080
00081 Level theonlylevel = Level();
00082 theonlylevel.levelLoad(levelfile);
00083
00084
00085
00086
00087 GLfloat whiteCoords[4];
00088 SDL_Surface *whiteSurface = f->load_image("whiteBG.png");
00089 int whiteBG = f->SDL_GL_LoadTexture(whiteSurface, whiteCoords);
00090
00091 GLfloat scramCoords[4];
00092 SDL_Surface *scramSurface = f->load_image("scramble.png");
00093 int scram = f->SDL_GL_LoadTexture(scramSurface, scramCoords);
00094
00095
00096 bool looping = true;
00097 bool leave = false;
00098
00099 do
00100 {
00101 do
00102 {
00103
00104 f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00105
00106 SDL_Rect screenRect = screen->getScreenRect();
00107 screenRect.x = 0;
00108 screenRect.y = 0;
00109 screen->drawScreen(whiteBG,whiteCoords,screenRect);
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 while((SDL_GetTicks() - ticks) < 1000/Screen::FRAMERATE)
00124 {
00125
00126 Sleep(0);
00127 }
00128
00129 if(!theonlylevel.update())
00130 break;
00131
00132
00133 theonlylevel.draw();
00134
00135
00136 ticks = SDL_GetTicks();
00137
00138
00139
00140 SDL_Rect scramRect;
00141 scramRect.w = 51;
00142 scramRect.h = 81;
00143 scramRect.x = 5;
00144 scramRect.y = screen->getScreenRect().h - 80;
00145 screen->drawScreen(scram,scramCoords,scramRect);
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 f->glFinish();
00167 SDL_GL_SwapBuffers();
00168
00169
00170
00171
00172
00173 while(SDL_PollEvent(&event))
00174 {
00175 if(event.type & SDL_KEYDOWN) {
00176 switch( event.key.keysym.sym )
00177 {
00178 case SDLK_ESCAPE:
00179 leave = true;
00180 break;
00181 default:
00182 break;
00183 }
00184 }
00185 }
00186
00187
00188 } while(!leave);
00189
00190 theonlylevel.reset();
00191
00192 }while(!leave);
00193
00194
00195
00196
00197
00198
00199
00200 SDL_Quit();
00201 return 0;
00202 }