diff --git a/GameEnts.c b/GameEnts.c index c682fd3..5d46edd 100644 --- a/GameEnts.c +++ b/GameEnts.c @@ -396,7 +396,7 @@ void GameEnts_Init(){ img_hole_spiked=Draw_LoadImage("data/hole_spiked.png"); Draw_SetOffset(img_hole_spiked,-16,-16); - anim_hole_lava=Anim_LoadAnim("data/hole_lava.png",2,3); + anim_hole_lava=Anim_LoadAnim("data/hole_lava.png",32,2,3); Anim_SetOffset(anim_hole_lava,-16,-16); img_player_up=Draw_LoadImage("data/player_up.png"); @@ -411,10 +411,10 @@ void GameEnts_Init(){ img_savepoint=Draw_LoadImage("data/save_point.png"); Draw_SetOffset(img_savepoint,-16,-16); - anim_savepoint_active=Anim_LoadAnim("data/save_point_active.png",2,5); + anim_savepoint_active=Anim_LoadAnim("data/save_point_active.png",32,2,5); Anim_SetOffset(anim_savepoint_active,-16,-16); - anim_exitpoint=Anim_LoadAnim("data/exit_point.png",2,10); + anim_exitpoint=Anim_LoadAnim("data/exit_point.png",32,2,10); Anim_SetOffset(anim_exitpoint,-16,-48); img_endpoint=Draw_LoadImage("data/end_point.png"); @@ -438,7 +438,7 @@ void GameEnts_Init(){ img_arrow_right=Draw_LoadImage("data/arrow_right.png"); Draw_SetOffset(img_arrow_right,-16,-16); - anim_fire=Anim_LoadAnim("data/fire.png",3,5); + anim_fire=Anim_LoadAnim("data/fire.png",32,3,5); Anim_SetOffset(anim_fire,-16,-48); img_player_broken=Draw_LoadImage("data/player_broken.png"); diff --git a/GameLib/Anim.c b/GameLib/Anim.c index 7b6b020..510e346 100644 --- a/GameLib/Anim.c +++ b/GameLib/Anim.c @@ -25,7 +25,7 @@ typedef struct { // Anim_LoadAnim // // -Anim Anim_LoadAnim(char *fichero,int frames,float fps){ +Anim Anim_LoadAnim(char *fichero,int width,int frames,float fps){ DrawImg img; Animation *anim; int w,h; @@ -39,7 +39,10 @@ Anim Anim_LoadAnim(char *fichero,int frames,float fps){ // Create the animation container anim=malloc(sizeof(Animation)); anim->img=img; - anim->w=w/frames; + anim->w=width; + if(width<=0){ + anim->w=w/frames; + } anim->fps=fps; anim->frames=frames; anim->ftime=1000/fps; diff --git a/GameLib/Anim.h b/GameLib/Anim.h index 862fa83..4d873a0 100644 --- a/GameLib/Anim.h +++ b/GameLib/Anim.h @@ -17,7 +17,7 @@ typedef void *Anim; // Anim_LoadAnim // // -Anim Anim_LoadAnim(char *fichero,int frames,float fps); +Anim Anim_LoadAnim(char *fichero,int width,int frames,float fps); ///////////////////////////// diff --git a/GameLib/Audio.c b/GameLib/Audio.c index 10e3dc5..4506b83 100644 --- a/GameLib/Audio.c +++ b/GameLib/Audio.c @@ -18,30 +18,35 @@ static void Audio_MixerCallback(void *ud,Uint8 *stream,int l); // AudioWave // /////////////// // Reference to a sound. -typedef struct Tag_AudioWave { - SDL_AudioSpec spec; +typedef struct TAudioWave TAudioWave, *AudioWave; +struct TAudioWave { + unsigned int sampleRate; + int channels; + int bpb; + int BPB; Uint32 len; Uint8 *buffer; - struct Tag_AudioWave *next; -} AudioWave; -AudioWave *_waves=NULL; + AudioWave next; +}; +AudioWave _waves=NULL; //////////////////////////////////////////////// // AudioChan // /////////////// // Reference to a sound. -typedef struct Tag_AudioChan { - AudioWave *wave; +typedef struct TAudioChan TAudioChan, *AudioChan; +struct TAudioChan { + AudioWave wave; Uint32 pos; unsigned char rightvol; unsigned char leftvol; - struct Tag_AudioChan *next; -} AudioChan; -AudioChan *_channels=NULL; -AudioChan *_free_channels=NULL; + AudioChan next; +}; +AudioChan _channels=NULL; +AudioChan _free_channels=NULL; ///////////////////////////// // Audio_Init @@ -58,7 +63,7 @@ int Audio_Init(){ #endif if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0){ printf("Audio_Init: Failure initializing SDL Audio.\n"); - printf("Audio_Init: SDL Error: %s\n",SDL_GetError()); + printf("\tSDL Error: %s\n",SDL_GetError()); return(0); } @@ -66,15 +71,11 @@ int Audio_Init(){ as.freq = 44100; as.format = AUDIO_S16SYS; as.channels = 2; -#ifdef EMSCRIPTEN - as.samples = 4096; -#else - as.samples = 1024; -#endif + as.samples = 2048; as.callback = Audio_MixerCallback; if(SDL_OpenAudio(&as, &as2) < 0){ printf("Audio_Init: Failure opening audio.\n"); - printf("Audio_Init: SDL Error: %s\n",SDL_GetError()); + printf("\tSDL Error: %s\n",SDL_GetError()); return(0); } @@ -101,16 +102,16 @@ int Audio_Init(){ // Mixes the audio channels. static void Audio_MixerCallback(void *ud,Uint8 *stream,int l){ signed short *ptr_out,*ptr_wave; - AudioChan *prevchan; - AudioChan *chan; - AudioWave *wave; + AudioChan prevchan; + AudioChan chan; + AudioWave wave; int len=l/4; // Asume 16bpb and 2 output chan int chan_remain; int len_mix; int i; // Clean - memset(stream,0,len); + memset(stream,0,l); // Mix all the channels prevchan=NULL; @@ -118,7 +119,7 @@ static void Audio_MixerCallback(void *ud,Uint8 *stream,int l){ while(chan){ if(!chan->wave){ // Remove finished channels - AudioChan *aux_chan=chan->next; + AudioChan aux_chan=chan->next; chan->next=_free_channels; _free_channels=chan; chan=aux_chan; @@ -197,41 +198,105 @@ void Audio_Frame(){ // // Loads a sound, giving a reference. AudioSnd Audio_LoadSound(char *filename){ - AudioWave *wave; -#ifndef EMSCRIPTEN - // Allocate and load the sound - wave=malloc(sizeof(AudioWave)); - if( SDL_LoadWAV(filename, - &wave->spec, &wave->buffer, &wave->len) == NULL ) - { - printf("Audio_LoadSound: Failure Loading sound: %s\n",filename); - printf("Audio_LoadSound: SDL Error: %s\n",SDL_GetError()); - free(wave); + int error = 0; + FILE *f; + char id[5] = { 0, 0, 0, 0, 0 }, *sndBuffer = NULL; + short formatTag, channels, bitsPerSample; + int formatLen, sampleRate, dataSize; + + f = fopen(filename, "rb"); + if (!f) { + printf("Audio_LoadSound: Failure opening file.\n"); return(NULL); } - // Asert results - if( wave->spec.format != AUDIO_S16 || - wave->spec.freq != 44100 || - wave->spec.channels != 1 ) - { - printf("Audio_LoadSound: Failure opening sound. (44.1Khz/16b/1c).\n"); - SDL_FreeWAV(wave->buffer); - free(wave); - return(0); + // Read id "RIFF" + fread(id, 4, sizeof(char), f); + if (strcmp(id, "RIFF")) { + printf("Audio_LoadSound: File is not RIFF.\n"); + fclose(f); + return(NULL); } - // Correct the lenght - wave->len/=2; + // File size (-"RIFF") + fseek(f, 4, SEEK_CUR); // size + + // Read id "WAVE" + fread(id, 4, sizeof(char), f); + if (strcmp(id, "WAVE")) { + printf("Audio_LoadSound: File is not WAVE.\n"); + fclose(f); + return(NULL); + } + + // Read the format + fread(id, 1, sizeof(char) * 4, f); // Read "fmt " + fread(&formatLen, 1, sizeof(int), f); + if (formatLen < 14) { + printf("Audio_LoadSound: File too short.\n"); + fclose(f); + return (NULL ); + } + fread(&formatTag, 1, sizeof(short), f); // 1=PCM + if (formatTag != 1) { + printf("Audio_LoadSound: Not PCM format.\n"); + fclose(f); + return (NULL ); + } + fread(&channels, 1, sizeof(short), f); + fread(&sampleRate, 1, sizeof(int), f); + fseek(f, 2, SEEK_CUR); // avgBytesSec + fseek(f, 2, SEEK_CUR); // blockAlign + fread(&bitsPerSample, 1, sizeof(short), f); + fseek(f, formatLen - 14, SEEK_CUR); // Align read + + // Assert sound format + if (sampleRate!=44100 || channels!=1 || bitsPerSample!=2) { + printf("Audio_LoadSound: Format not supported: " + "sampleRate:%d; channels:%d; BPB:%d\n", + sampleRate, channels, bitsPerSample); + fclose(f); + return(NULL); + } + + // Skip no "data" blocks + do{ + int lenRead=fread(id, 1, sizeof(char) * 4, f); + if(lenRead<4){ break; } + if (strcmp(id, "data")) { + fread(&dataSize, 1, sizeof(int), f); + fseek(f, dataSize, SEEK_CUR); + }else{ + break; + } + }while(1); + if (strcmp(id, "data")) { + printf("Audio_LoadSound: DATA block not found\n"); + fclose(f); + return (NULL ); + } + + // Read the "data" block + fread(&dataSize, 1, sizeof(int), f); + sndBuffer = malloc(sizeof(char)*dataSize); + fread(sndBuffer, dataSize, sizeof(char), f); + + fclose(f); + + // Build the wave object + AudioWave wave = malloc(sizeof(TAudioWave)); + wave->sampleRate = sampleRate; + wave->channels = channels; + wave->buffer = (Uint8 *) sndBuffer; + wave->BPB = bitsPerSample; + wave->bpb = wave->bpb * 8; + wave->len = dataSize / (wave->BPB * wave->channels); // Take a reference wave->next=_waves; _waves=wave; - return((AudioSnd)wave); -#else - return(NULL); -#endif + return (wave); } @@ -242,8 +307,8 @@ AudioSnd Audio_LoadSound(char *filename){ void Audio_PlaySound(AudioSnd snd, float leftvol, float rightvol) { - AudioChan *chan; - AudioWave *wave; + AudioChan chan; + AudioWave wave; if(!snd) return; @@ -256,7 +321,7 @@ void Audio_PlaySound(AudioSnd snd, _free_channels=chan->next; chan->next=NULL; }else{ - chan=malloc(sizeof(AudioChan)); + chan=malloc(sizeof(TAudioChan)); chan->next=NULL; } diff --git a/GameLib/Draw.c b/GameLib/Draw.c index 800eb58..ce3e5fc 100644 --- a/GameLib/Draw.c +++ b/GameLib/Draw.c @@ -6,19 +6,27 @@ #include #ifdef WIN32 + // Windows #define _WIN32_WINNT 0x0501 #include #include #include + #define USE_OpenGL 1 + #define USE_OpenGLES 0 #else #ifdef EMSCRIPTEN - //#include - //#define GL_GLEXT_PROTOTYPES 1 - //#include + // Emscripten + #include + #define GL_GLEXT_PROTOTYPES 1 + #include #include - #include + #define USE_OpenGL 0 + #define USE_OpenGLES 1 #else + // UNIX #include + #define USE_OpenGL 1 + #define USE_OpenGLES 0 #endif #endif #include "lodepng.c" @@ -57,8 +65,71 @@ QuadArray2D _quadArray=NULL; DrawImage _currentImg=NULL; float _color[4]; +#if USE_OpenGLES + +GLuint Draw_CompileShader(GLenum type, const char *source){ + GLuint shader = glCreateShader(type); + if (shader == 0) { + return 0; + } + + //load the shader source to the shader object and compile it + glShaderSource(shader, 1, &source, NULL); + glCompileShader(shader); + + //check if the shader compiled successfully + GLint compiled; + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + if (!compiled) { + glDeleteShader(shader); + return 0; + } + + return shader; +} +GLuint Draw_BuildProgram( + const char *vertexShaderSource, + const char *fragmentShaderSource) +{ + // Compile shaders + GLuint vertexShader = Draw_CompileShader(GL_VERTEX_SHADER, vertexShaderSource); + GLuint fragmentShader = Draw_CompileShader(GL_FRAGMENT_SHADER, fragmentShaderSource); + if(vertexShader==0 || fragmentShader==0){ + return 0; + } + + //create a GL program and link it + GLuint programObject = glCreateProgram(); + glAttachShader(programObject, vertexShader); + glAttachShader(programObject, fragmentShader); + glLinkProgram(programObject); + + //check if the program linked successfully + GLint linked; + glGetProgramiv(programObject, GL_LINK_STATUS, &linked); + if (!linked) + { + glDeleteProgram(programObject); + return 0; + } + return programObject; +} + +GLuint vertPosLoc; +GLuint vertTexLoc; +GLuint vertColorLoc; + +GLuint textureLoc; +GLuint projectionMatrixLoc; + + +GLuint vertexObject; + +#define Max_Vertices 6000 + +#endif ///////////////////////////// // Draw_Init @@ -78,6 +149,13 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ } #endif + // Set globals + proc_t_frame=1000000/pfps; + draw_t_frame=1000000/fps; + _fps=fps; + _width=width; + _height=height; + // Initialize SDL if(SDL_Init(SDL_INIT_VIDEO)<0){ printf("Draw_Init: Failure initializing SDL.\n"); @@ -85,7 +163,7 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ return(0); } - +#if USE_OpenGL // Prepare OpenGL inicialization SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8); @@ -94,7 +172,7 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - +#endif // Initialize video mode _screen=SDL_SetVideoMode(width,height,32,SDL_HWSURFACE|SDL_OPENGL); @@ -104,14 +182,10 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ return(0); } SDL_WM_SetCaption(title, NULL); - proc_t_frame=1000000/pfps; - draw_t_frame=1000000/fps; - _fps=fps; - _width=width; - _height=height; +#if USE_OpenGL // Set the desired state - //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glDisable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); @@ -146,6 +220,90 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ glMatrixMode (GL_MODELVIEW); glLoadIdentity (); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + +#else + + // Show device info + char *str; + printf("\n*********************************\n"); + printf("*** Draw Info\n"); + str=(char *)glGetString(GL_VENDOR); + printf(" Vendor: %s\n",str); + str=(char *)glGetString(GL_RENDERER); + printf(" Renderer: %s\n",str); + str=(char *)glGetString(GL_VERSION); + printf(" Version: %s\n",str); + printf("*********************************\n"); + + const char vertexShaderSource[] = + "attribute vec4 aPosition; \n" + "attribute vec2 aTexCoord; \n" + "attribute vec4 aColor; \n" + "varying vec2 vTexCoord; \n" + "varying vec4 vColor; \n" + "uniform mat4 sProjectionMatrix; \n" + "void main() { \n" + " gl_Position = aPosition * \n" + " sProjectionMatrix; \n" + " vTexCoord = aTexCoord; \n" + " vColor = aColor; \n" + "} \n"; + + const char fragmentShaderSource[] = + "precision mediump float; \n" + "varying vec2 vTexCoord; \n" + "varying vec4 vColor; \n" + "uniform sampler2D sTexture; \n" + "void main() { \n" + " gl_FragColor = texture2D(sTexture, vTexCoord)*vColor; \n" + "} \n"; + + GLuint programObject=Draw_BuildProgram( + vertexShaderSource, + fragmentShaderSource); + glUseProgram(programObject); + + vertPosLoc = glGetAttribLocation(programObject, "aPosition"); + vertTexLoc = glGetAttribLocation(programObject, "aTexCoord"); + vertColorLoc = glGetAttribLocation(programObject, "aColor"); + + textureLoc = glGetUniformLocation(programObject, "sTexture"); + projectionMatrixLoc = glGetUniformLocation(programObject, "sProjectionMatrix"); + + glGenBuffers(1, &vertexObject); + glBindBuffer(GL_ARRAY_BUFFER, vertexObject ); + glBufferData(GL_ARRAY_BUFFER, Vertex2D_Length*sizeof(float)*Max_Vertices, + NULL, GL_DYNAMIC_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, vertexObject ); + + glVertexAttribPointer(vertPosLoc, 2, GL_FLOAT,GL_FALSE, + Vertex2D_Length*sizeof(float), (void*)(0*sizeof(float))); + glVertexAttribPointer(vertTexLoc, 2, GL_FLOAT, GL_FALSE, + Vertex2D_Length*sizeof(float), (void*)(2*sizeof(float))); + glVertexAttribPointer(vertColorLoc, 4, GL_FLOAT, GL_FALSE, + Vertex2D_Length*sizeof(float), (void*)(4*sizeof(float))); + + glEnableVertexAttribArray(vertPosLoc); + glEnableVertexAttribArray(vertTexLoc); + glEnableVertexAttribArray(vertColorLoc); + + glUniform1i(textureLoc, 0); + + GLfloat projectionMatrix[16]={ + 2.0f/(float)_width, 0.0, 0.0, -1.0, + 0.0, 2.0/(float)_height, 0.0, -1.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + }; + glUniformMatrix4fv(projectionMatrixLoc, + 1, GL_FALSE, projectionMatrix); + +#endif + // Enable Alpha blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -159,6 +317,123 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps){ } + +///////////////////////////// +// Draw_UploadGLTexture +// +// Uploads a OpenGL texture. +GLuint Draw_UploadGLTexture(int w, int h, unsigned char *pixels){ + GLuint tex; + + // Generate OpenGL texture + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + // Load OpenGL texture + glBindTexture(GL_TEXTURE_2D, tex); +#if USE_OpenGL + glPixelStorei( GL_UNPACK_ROW_LENGTH, w ); +#endif + glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + return(tex); +} + + +///////////////////////////// +// Draw_Flush +// +// Performs all the queued draw actions. +void Draw_Flush(){ + if(_currentImg==NULL || _quadArray->nVertex<=0){ + return; + } + if(_currentImg->tex==-1){ + _currentImg->tex=Draw_UploadGLTexture(_currentImg->w, _currentImg->h, _currentImg->data); + } + +#if USE_OpenGL + // Draw the quad array + glBindTexture(GL_TEXTURE_2D, _currentImg->tex); + glColorPointer( 4, GL_FLOAT, Vertex2D_Length*sizeof(float), + (GLvoid *)(_quadArray->vertexData+4) ); + glTexCoordPointer( 2, GL_FLOAT, Vertex2D_Length*sizeof(float), + (GLvoid *)(_quadArray->vertexData+2) ); + glVertexPointer( 2, GL_FLOAT, Vertex2D_Length*sizeof(float), + (GLvoid *)(_quadArray->vertexData) ); + glDrawArrays(GL_TRIANGLES,0,_quadArray->nVertex); + +#else + + // Draw the quad array + glBindTexture(GL_TEXTURE_2D, _currentImg->tex); + glBufferSubData(GL_ARRAY_BUFFER, 0, + Vertex2D_Length*sizeof(float)*_quadArray->nVertex, + _quadArray->vertexData); + glDrawArrays(GL_TRIANGLES, 0, _quadArray->nVertex); + +#endif + + // Empty it + QuadArray2D_Clean(_quadArray); +} + + +///////////////////////////// +// Draw_Clean +// +// Cleans the game window. +void Draw_Clean( + unsigned char r, + unsigned char g, + unsigned char b) +{ +#ifndef EMSCRIPTEN + glClearColor(r/255.0f,g/255.0f,b/255.0f,1.0f); + glClear(GL_COLOR_BUFFER_BIT); +#else + Draw_Flush(); + float fr=r/255.0f; + float fg=g/255.0f; + float fb=b/255.0f; + GLfloat vVertices[] = { + 0.0, 0.0, // Position 0 + 0.0, 0.0, // TexCoord 0 + fr, fg, fb, 1.0, // Color + + 0.0, _height, // Position 1 + 0.0, 1.0, // TexCoord 1 + fr, fg, fb, 1.0, // Color + + _width, _height, // Position 2 + 1.0, 1.0, // TexCoord 2 + fr, fg, fb, 1.0, // Color + + _width, _height, // Position 2 + 1.0, 1.0, // TexCoord 2 + fr, fg, fb, 1.0, // Color + + _width, 0.0, // Position 3 + 1.0, 0.0, // TexCoord 3 + fr, fg, fb, 1.0, // Color + + 0.0, 0.0, // Position 0 + 0.0, 0.0, // TexCoord 0 + fr, fg, fb, 1.0, // Color + }; + glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vVertices), vVertices); + glDrawArrays(GL_TRIANGLES, 0, 6); +#endif +} + + ///////////////////////////// // Draw_LoopIteration // @@ -270,47 +545,6 @@ void Draw_Loop(int (*proc)(),void (*draw)(float f)){ } -///////////////////////////// -// Draw_Clean -// -// Cleans the game window. -void Draw_Clean( - unsigned char r, - unsigned char g, - unsigned char b) -{ - glClearColor(r/255.0f,g/255.0f,b/255.0f,1.0f); - glClear(GL_COLOR_BUFFER_BIT); -} - - -///////////////////////////// -// Draw_UploadGLTexture -// -// Uploads a OpenGL texture. -GLuint Draw_UploadGLTexture(int w, int h, unsigned char *pixels){ - GLuint tex; - - // Generate OpenGL texture - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - // Load OpenGL texture - glBindTexture(GL_TEXTURE_2D, tex); - //glPixelStorei( GL_UNPACK_ROW_LENGTH, w ); - glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, - w, h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - return(tex); -} - - ///////////////////////////// // Draw_CreateImage // @@ -394,42 +628,6 @@ void Draw_GetOffset(DrawImg img,int *x,int *y){ } -///////////////////////////// -// Draw_Flush -// -// Performs all the queued draw actions. -void Draw_Flush(){ - if(_currentImg==NULL){ - return; - } - if(_currentImg->tex==-1){ - _currentImg->tex=Draw_UploadGLTexture(_currentImg->w, _currentImg->h, _currentImg->data); - } - - // Draw the quad array - glBindTexture(GL_TEXTURE_2D, _currentImg->tex); - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - - glColorPointer( 4, GL_FLOAT, Vertex2D_Length*sizeof(float), - (GLvoid *)(_quadArray->vertexData+4) ); - glTexCoordPointer( 2, GL_FLOAT, Vertex2D_Length*sizeof(float), - (GLvoid *)(_quadArray->vertexData+2) ); - glVertexPointer( 2, GL_FLOAT, Vertex2D_Length*sizeof(float), - (GLvoid *)(_quadArray->vertexData) ); - - glDrawArrays(GL_QUADS,0,_quadArray->nVertex); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - // Empty it - QuadArray2D_Clean(_quadArray); -} - - ///////////////////////////// // Draw_DrawImg // @@ -518,7 +716,6 @@ void Draw_DrawImgPart(DrawImg img,int x,int y,int w,int i){ // // void Draw_SetColor(float r,float g,float b,float a){ - glColor4f(r,g,b,a); _color[0]=r; _color[1]=g; _color[2]=b; @@ -643,6 +840,7 @@ void Draw_DrawText(DrawFnt f,char *text,int x,int y){ // // void Draw_SaveScreenshoot(char *filename){ +#if USE_OpenGL SDL_Surface *surf; unsigned char *image_line; int i,half_height,line_size; @@ -690,6 +888,7 @@ void Draw_SaveScreenshoot(char *filename){ // Cleanup SDL_FreeSurface(surf); +#endif } diff --git a/GameLib/Draw.h b/GameLib/Draw.h index c7704b0..5cdc5d2 100644 --- a/GameLib/Draw.h +++ b/GameLib/Draw.h @@ -11,13 +11,6 @@ int Draw_Init(int width,int height,char *title,int pfps,int fps); -///////////////////////////// -// Draw_Loop -// -// Loops updating the game window. -void Draw_Loop(int (*proc)(),void (*draw)(float f)); - - ///////////////////////////// // Draw_Clean // @@ -28,6 +21,13 @@ void Draw_Clean( unsigned char b); +///////////////////////////// +// Draw_Loop +// +// Loops updating the game window. +void Draw_Loop(int (*proc)(),void (*draw)(float f)); + + ///////////////////////////// // Draw_Flush // diff --git a/GameLib/QuadArray2D.c b/GameLib/QuadArray2D.c index ef29a08..ff98778 100644 --- a/GameLib/QuadArray2D.c +++ b/GameLib/QuadArray2D.c @@ -69,7 +69,10 @@ void QuadArray2D_AddQuad(QuadArray2D quadArray, // Add the vertexes v[0]=x0; v[1]=y0; v[2]=u0; v[3]=v0; QuadArray2D_AddVertex(quadArray,v); v[0]=x1; v[1]=y0; v[2]=u1; v[3]=v0; QuadArray2D_AddVertex(quadArray,v); + v[0]=x1; v[1]=y1; v[2]=u1; v[3]=v1; QuadArray2D_AddVertex(quadArray,v); + v[0]=x1; v[1]=y1; v[2]=u1; v[3]=v1; QuadArray2D_AddVertex(quadArray,v); v[0]=x0; v[1]=y1; v[2]=u0; v[3]=v1; QuadArray2D_AddVertex(quadArray,v); + v[0]=x0; v[1]=y0; v[2]=u0; v[3]=v0; QuadArray2D_AddVertex(quadArray,v); } diff --git a/GameLib/Time.c b/GameLib/Time.c index 7566670..7762d44 100644 --- a/GameLib/Time.c +++ b/GameLib/Time.c @@ -1,4 +1,4 @@ -// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado) +// Copyright (C) 2011-2014 Valeriano Alfonso Rodriguez (Kableado) #include #include @@ -45,25 +45,6 @@ void Time_Pause(int pausa){ }while(tend>=t); } #else -#ifdef MACOSX -#include -// MacOSX -long long Time_GetTime(){ - static mach_timebase_info_data_t info = {0,0}; - uint64_t t; - if(info.denom==0){ - mach_timebase_info(&info); - } - t=mach_absolute_time()*(info.numer / info.denom); - return(t/1000); -} -void Time_Pause(int pausa){ - struct timeval tv; - tv.tv_sec=(long long)pausa/1000000; - tv.tv_usec=(long long)pausa%1000000; - select(0, NULL, NULL, NULL, &tv); -} -#else // UNIX long long Time_GetTime(){ struct timeval t; @@ -78,7 +59,6 @@ void Time_Pause(int pausa){ tv.tv_usec=(long long)pausa%1000000; select(0, NULL, NULL, NULL, &tv); } -#endif // if MACOSX #endif // if WIN32 diff --git a/Makefile.common b/Makefile.common index e71f767..bc8814b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -49,7 +49,7 @@ $(BUILDDIR): clean: rm -f $(OBJS) $(BUILDDIR)/$(RESULT) -run: $(BUILDDIR)/$(RESULT) +run: $(BUILDDIR) $(BUILDDIR)/$(RESULT) $(LAUNCHER) ./$(BUILDDIR)/$(RESULT) debug rebuild: clean all diff --git a/Makefile.emscripten b/Makefile.emscripten index c3ffb1f..bc4cb45 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -3,7 +3,8 @@ LAUNCHER= start RM=rm -rf LIBS= -CFLAGS= -s LEGACY_GL_EMULATION=1 -s ASM_JS=1 -O1 +CFLAGS= -s FULL_ES2=1 -s ASM_JS=1 -O1 +#LDFLAGS= --embed-file data LDFLAGS= --preload-file data RESULT=game.html diff --git a/Makefile.macosx b/Makefile.macosx deleted file mode 100644 index 5acd8c8..0000000 --- a/Makefile.macosx +++ /dev/null @@ -1,9 +0,0 @@ -LIBS=-lm -ldl -framework Cocoa -framework SDL -framework OpenGL macosx/SDLMain.m -CFLAGS=-g -DDEBUG -Wall -DMACOSX -ObjC -Dmain=SDL_main -CC=gcc -RM=rm -rf - -RESULT=game -BUILDDIR=build-macosx - -include Makefile.common \ No newline at end of file diff --git a/data/Explosion16.bfxrsound b/data-orig/Explosion16.bfxrsound similarity index 100% rename from data/Explosion16.bfxrsound rename to data-orig/Explosion16.bfxrsound diff --git a/data/Explosion2.bfxrsound b/data-orig/Explosion2.bfxrsound similarity index 100% rename from data/Explosion2.bfxrsound rename to data-orig/Explosion2.bfxrsound diff --git a/data/Hit_Hurt10.bfxrsound b/data-orig/Hit_Hurt10.bfxrsound similarity index 100% rename from data/Hit_Hurt10.bfxrsound rename to data-orig/Hit_Hurt10.bfxrsound diff --git a/data/Hit_Hurt16.bfxrsound b/data-orig/Hit_Hurt16.bfxrsound similarity index 100% rename from data/Hit_Hurt16.bfxrsound rename to data-orig/Hit_Hurt16.bfxrsound diff --git a/data/Laser_Shoot2.bfxrsound b/data-orig/Laser_Shoot2.bfxrsound similarity index 100% rename from data/Laser_Shoot2.bfxrsound rename to data-orig/Laser_Shoot2.bfxrsound diff --git a/data/Powerup10.bfxrsound b/data-orig/Powerup10.bfxrsound similarity index 100% rename from data/Powerup10.bfxrsound rename to data-orig/Powerup10.bfxrsound diff --git a/data/Powerup30.bfxrsound b/data-orig/Powerup30.bfxrsound similarity index 100% rename from data/Powerup30.bfxrsound rename to data-orig/Powerup30.bfxrsound diff --git a/data/arrow_down.xcf b/data-orig/arrow_down.xcf similarity index 100% rename from data/arrow_down.xcf rename to data-orig/arrow_down.xcf diff --git a/data/arrow_left.xcf b/data-orig/arrow_left.xcf similarity index 100% rename from data/arrow_left.xcf rename to data-orig/arrow_left.xcf diff --git a/data/arrow_right.xcf b/data-orig/arrow_right.xcf similarity index 100% rename from data/arrow_right.xcf rename to data-orig/arrow_right.xcf diff --git a/data/arrow_up.xcf b/data-orig/arrow_up.xcf similarity index 100% rename from data/arrow_up.xcf rename to data-orig/arrow_up.xcf diff --git a/data/arrowshooter_down.xcf b/data-orig/arrowshooter_down.xcf similarity index 100% rename from data/arrowshooter_down.xcf rename to data-orig/arrowshooter_down.xcf diff --git a/data/arrowshooter_left.xcf b/data-orig/arrowshooter_left.xcf similarity index 100% rename from data/arrowshooter_left.xcf rename to data-orig/arrowshooter_left.xcf diff --git a/data/arrowshooter_right.xcf b/data-orig/arrowshooter_right.xcf similarity index 100% rename from data/arrowshooter_right.xcf rename to data-orig/arrowshooter_right.xcf diff --git a/data/arrowshooter_up.xcf b/data-orig/arrowshooter_up.xcf similarity index 100% rename from data/arrowshooter_up.xcf rename to data-orig/arrowshooter_up.xcf diff --git a/data/barrel.xcf b/data-orig/barrel.xcf similarity index 100% rename from data/barrel.xcf rename to data-orig/barrel.xcf diff --git a/data/barrel2.xcf b/data-orig/barrel2.xcf similarity index 100% rename from data/barrel2.xcf rename to data-orig/barrel2.xcf diff --git a/data/column.xcf b/data-orig/column.xcf similarity index 100% rename from data/column.xcf rename to data-orig/column.xcf diff --git a/data/end.xcf b/data-orig/end.xcf similarity index 100% rename from data/end.xcf rename to data-orig/end.xcf diff --git a/data/end_point.xcf b/data-orig/end_point.xcf similarity index 100% rename from data/end_point.xcf rename to data-orig/end_point.xcf diff --git a/data/exit_point.xcf b/data-orig/exit_point.xcf similarity index 100% rename from data/exit_point.xcf rename to data-orig/exit_point.xcf diff --git a/data/fire.xcf b/data-orig/fire.xcf similarity index 100% rename from data/fire.xcf rename to data-orig/fire.xcf diff --git a/data/floor.xcf b/data-orig/floor.xcf similarity index 100% rename from data/floor.xcf rename to data-orig/floor.xcf diff --git a/data/floor_center.xcf b/data-orig/floor_center.xcf similarity index 100% rename from data/floor_center.xcf rename to data-orig/floor_center.xcf diff --git a/data/floor_left.xcf b/data-orig/floor_left.xcf similarity index 100% rename from data/floor_left.xcf rename to data-orig/floor_left.xcf diff --git a/data/floor_right.xcf b/data-orig/floor_right.xcf similarity index 100% rename from data/floor_right.xcf rename to data-orig/floor_right.xcf diff --git a/data/hole_lava.xcf b/data-orig/hole_lava.xcf similarity index 100% rename from data/hole_lava.xcf rename to data-orig/hole_lava.xcf diff --git a/data/hole_spiked.xcf b/data-orig/hole_spiked.xcf similarity index 100% rename from data/hole_spiked.xcf rename to data-orig/hole_spiked.xcf diff --git a/data/lamp.xcf b/data-orig/lamp.xcf similarity index 100% rename from data/lamp.xcf rename to data-orig/lamp.xcf diff --git a/data/logo.xcf b/data-orig/logo.xcf similarity index 100% rename from data/logo.xcf rename to data-orig/logo.xcf diff --git a/data/player_broken.xcf b/data-orig/player_broken.xcf similarity index 100% rename from data/player_broken.xcf rename to data-orig/player_broken.xcf diff --git a/data/player_down.xcf b/data-orig/player_down.xcf similarity index 100% rename from data/player_down.xcf rename to data-orig/player_down.xcf diff --git a/data/player_right.xcf b/data-orig/player_right.xcf similarity index 100% rename from data/player_right.xcf rename to data-orig/player_right.xcf diff --git a/data/player_up.xcf b/data-orig/player_up.xcf similarity index 100% rename from data/player_up.xcf rename to data-orig/player_up.xcf diff --git a/data/rock.xcf b/data-orig/rock.xcf similarity index 100% rename from data/rock.xcf rename to data-orig/rock.xcf diff --git a/data/save_point.xcf b/data-orig/save_point.xcf similarity index 100% rename from data/save_point.xcf rename to data-orig/save_point.xcf diff --git a/data/save_point_active.xcf b/data-orig/save_point_active.xcf similarity index 100% rename from data/save_point_active.xcf rename to data-orig/save_point_active.xcf diff --git a/data/._level_03.txt b/data/._level_03.txt deleted file mode 100644 index 5b4b4a0..0000000 Binary files a/data/._level_03.txt and /dev/null differ diff --git a/data/arrow_down.bmp b/data/arrow_down.bmp deleted file mode 100644 index be60c59..0000000 Binary files a/data/arrow_down.bmp and /dev/null differ diff --git a/data/arrow_left.bmp b/data/arrow_left.bmp deleted file mode 100644 index 1251de3..0000000 Binary files a/data/arrow_left.bmp and /dev/null differ diff --git a/data/arrow_right.bmp b/data/arrow_right.bmp deleted file mode 100644 index 96e36b8..0000000 Binary files a/data/arrow_right.bmp and /dev/null differ diff --git a/data/arrow_up.bmp b/data/arrow_up.bmp deleted file mode 100644 index 5554f78..0000000 Binary files a/data/arrow_up.bmp and /dev/null differ diff --git a/data/arrowshooter_down.bmp b/data/arrowshooter_down.bmp deleted file mode 100644 index ac1d23a..0000000 Binary files a/data/arrowshooter_down.bmp and /dev/null differ diff --git a/data/arrowshooter_left.bmp b/data/arrowshooter_left.bmp deleted file mode 100644 index e4d92db..0000000 Binary files a/data/arrowshooter_left.bmp and /dev/null differ diff --git a/data/arrowshooter_right.bmp b/data/arrowshooter_right.bmp deleted file mode 100644 index 9b923c1..0000000 Binary files a/data/arrowshooter_right.bmp and /dev/null differ diff --git a/data/arrowshooter_up.bmp b/data/arrowshooter_up.bmp deleted file mode 100644 index 700db4b..0000000 Binary files a/data/arrowshooter_up.bmp and /dev/null differ diff --git a/data/barrel.bmp b/data/barrel.bmp deleted file mode 100644 index dd717b7..0000000 Binary files a/data/barrel.bmp and /dev/null differ diff --git a/data/barrel2.bmp b/data/barrel2.bmp deleted file mode 100644 index 70e04df..0000000 Binary files a/data/barrel2.bmp and /dev/null differ diff --git a/data/column.bmp b/data/column.bmp deleted file mode 100644 index d0207a2..0000000 Binary files a/data/column.bmp and /dev/null differ diff --git a/data/column_faded.bmp b/data/column_faded.bmp deleted file mode 100644 index 490c41e..0000000 Binary files a/data/column_faded.bmp and /dev/null differ diff --git a/data/end.bmp b/data/end.bmp deleted file mode 100644 index b4b021f..0000000 Binary files a/data/end.bmp and /dev/null differ diff --git a/data/end_point.bmp b/data/end_point.bmp deleted file mode 100644 index a1c8a9e..0000000 Binary files a/data/end_point.bmp and /dev/null differ diff --git a/data/exit_point.bmp b/data/exit_point.bmp deleted file mode 100644 index f7b8265..0000000 Binary files a/data/exit_point.bmp and /dev/null differ diff --git a/data/fire.bmp b/data/fire.bmp deleted file mode 100644 index f619eb6..0000000 Binary files a/data/fire.bmp and /dev/null differ diff --git a/data/floor.bmp b/data/floor.bmp deleted file mode 100644 index 7c823d8..0000000 Binary files a/data/floor.bmp and /dev/null differ diff --git a/data/floor_center.bmp b/data/floor_center.bmp deleted file mode 100644 index ff69864..0000000 Binary files a/data/floor_center.bmp and /dev/null differ diff --git a/data/floor_left.bmp b/data/floor_left.bmp deleted file mode 100644 index cd1fd94..0000000 Binary files a/data/floor_left.bmp and /dev/null differ diff --git a/data/floor_right.bmp b/data/floor_right.bmp deleted file mode 100644 index be87394..0000000 Binary files a/data/floor_right.bmp and /dev/null differ diff --git a/data/hole_lava.bmp b/data/hole_lava.bmp deleted file mode 100644 index dea5816..0000000 Binary files a/data/hole_lava.bmp and /dev/null differ diff --git a/data/hole_spiked.bmp b/data/hole_spiked.bmp deleted file mode 100644 index 07cc5fa..0000000 Binary files a/data/hole_spiked.bmp and /dev/null differ diff --git a/data/lamp.bmp b/data/lamp.bmp deleted file mode 100644 index 664fb77..0000000 Binary files a/data/lamp.bmp and /dev/null differ diff --git a/data/level_03.txt b/data/level_03.txt index d890b0f..1978e76 100644 --- a/data/level_03.txt +++ b/data/level_03.txt @@ -14,10 +14,10 @@ ##||........||..||........||## ################ ##||..LLLLBB||..||..LLLL..||## ##............## ##||............||........||## ##............## - ##||||||||..||||||||||||||||ll########............## - ##||||||||||||||||............................EE..## + ##||||||||||||||||||||||||||ll########............## + ##||||||||..||||||............................EE..## ##||||||||..||||||||||||||||llmmmmmmmm............## - ##||....BB....||..........||mm mm............## + ##||....BB..||............||mm mm............## ##||..LLLL..||||||BBLLLL..||mm mm............## ##||........||||||........||mm mmmmmmmmmmmmmm## ##||||||||||||||||||||||||||mm diff --git a/data/logo.bmp b/data/logo.bmp deleted file mode 100644 index dab7d27..0000000 Binary files a/data/logo.bmp and /dev/null differ diff --git a/data/maps.copy/level_00.txt b/data/maps.copy/level_00.txt deleted file mode 100644 index 1004956..0000000 --- a/data/maps.copy/level_00.txt +++ /dev/null @@ -1,23 +0,0 @@ -33 23 - - ############ll################ ######ll############ll#### - ##..........................## ##......................## - ##..................||......ll########....||||||||||||||....## - ##..S1..............||..............S2....||................## - ##..................||......llmmmmmmmm....||....||||||||||||## - ##..........................mm mm....||................## - ##mmmmmmmmmmllmmmmmmmmmmmmmmmm mmmmmmmmmmmmll..llmmmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - ##########S3########## - ##..................## - ##..................## - ll..................ll - mm..BBBBBB..BBBBBB..mm - mm||||||||ll||||||||mm - mm..................mm - mm..................mm - mm........EE........mm - mmmmmmmmmmmmmmmmmmmmmm diff --git a/data/maps.copy/level_01.txt b/data/maps.copy/level_01.txt deleted file mode 100644 index 6739f4e..0000000 --- a/data/maps.copy/level_01.txt +++ /dev/null @@ -1,51 +0,0 @@ -100 100 - - ################## - ##......S1......## - ##..............## - ##..............## - ##..............## - ##mmmmll..llmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm -############S2############## -##||||||||........||||||||## -##||||||||..BBll..||||||||## -ll||....||||BB....||||||||ll -mm||..||||||||||||||||||||mm -mm||..||||||||||||||||||||mm -mm||..||||||||||||||||||||mm -mm||..........BB||||BB..||mm -mm||||||||||..||||||||||||mm -mmmmmmmmmmll..llmmmmmmmmmmmm - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm -############S3############ -##......||......||......## -##......||..BB..||......## -ll......||||||||||..BB..ll -mm||||||rrrrllrrrr||||||mm -mm......................mm -mm||||||....BB....||||||mm -mm......rr||||||rr......mm -mm......||rrrrrr||......mm -mm....BB||......||......mm -mmmmmmmmmmll..llmmmmmmmmmm - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm - ########..######## - ##..............## - ##..............## - ##..............## - ##......EE......## - ##mmmmmmmmmmmmmm## diff --git a/data/maps.copy/level_02.txt b/data/maps.copy/level_02.txt deleted file mode 100644 index 3e421b8..0000000 --- a/data/maps.copy/level_02.txt +++ /dev/null @@ -1,23 +0,0 @@ -33 23 - - ############ll################ ########################## - ##..........................## ##......................## - ##..................LL......ll########....LLLLLLLLLLLLLL....## - ##..S1..............LL..............S2....LL................## - ##..................LL......llmmmmmmmm....LL....LLLLLLLLLLLL## - ##..........................mm mm....LL................## - ##mmmmmmmmmmllmmmmmmmmmmmmmmmm mmmmmmmmmmmmll..llmmmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - ##########S3########## - ##..................## - ##..................## - ll..................ll - ##..BBBBBB..BBBBBB..## - ##LLLLLLLLrr||||||||## - ##..................## - ##..................## - ##........EE........## - ##mmmmmmmmmmmmmmmmmm## diff --git a/data/maps.copy/level_03.txt b/data/maps.copy/level_03.txt deleted file mode 100644 index d890b0f..0000000 --- a/data/maps.copy/level_03.txt +++ /dev/null @@ -1,29 +0,0 @@ -100 100 - ################## - ##......S1......## - ##..............## - ##..............## - ##..............## - ##mmmmll..llmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - ##############S2############## - ##||||||||||||..||||||||||||## - ##||........||..||........||## ################ - ##||..LLLLBB||..||..LLLL..||## ##............## - ##||............||........||## ##............## - ##||||||||..||||||||||||||||ll########............## - ##||||||||||||||||............................EE..## - ##||||||||..||||||||||||||||llmmmmmmmm............## - ##||....BB....||..........||mm mm............## - ##||..LLLL..||||||BBLLLL..||mm mm............## - ##||........||||||........||mm mmmmmmmmmmmmmm## - ##||||||||||||||||||||||||||mm - mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - - - - diff --git a/data/maps.copy/level_04.txt b/data/maps.copy/level_04.txt deleted file mode 100644 index 270edf5..0000000 --- a/data/maps.copy/level_04.txt +++ /dev/null @@ -1,26 +0,0 @@ -33 26 - - ############ll################ ######ll##########ll###### - ##..........................## ##................VV....## - ##..........................ll########......................## - ##..S1..............................S2......................## - ##..........................llmmmmmmmm>>....................## - ##..................AA......mm mm........AA............## - ##mmmmmmmmmmllmmmmmmmmmmmmmmmm mmmmmmmmmmmmll..llmmmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - ##########S3########## - ##..................## - ##............BBBB..## - ##................<<## - ll..BBBB............ll - ##>>................## - ##............BBBB..## - ##................<<## - ll..BBBB............ll - ##>>................## - ##..................## - ##........EE........## - ##mmmmmmmmmmmmmmmmmm## diff --git a/data/maps.copy/level_05.txt b/data/maps.copy/level_05.txt deleted file mode 100644 index 7340676..0000000 --- a/data/maps.copy/level_05.txt +++ /dev/null @@ -1,69 +0,0 @@ -100 100 - - ################## - ##......S1......## - ##..............## - ##..............## - ##..............## - ##mmmmll..llmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm -####ll######S2######ll#### -##......................## -##..BB..BB......BB..BB..## -##......................## -##LLLLLLLLrr||rrLLLLLLLL## -##......AA......AA......## -##mmmmmmmmll..llmmmmmmmm## - mm..mm - mm..mm - mm..mm - mm..mm -############S3############ -##....VV..VV..........LL## -##LLLLLLLLLLLLLLLLLL..LL## -##LL..................LL## -##LL..LLLLLLLLLLLLLLLLLL## -##LL..................LL## -##LLLLLLLLLLLLLLLLLL..LL## -##LL..................LL## -##LL..LLLLLLLLLLLLLLLLLL## -##LL..........AA..AA....## -##mmmmmmmmll..llmmmmmmmm## - mm..mm - mm..mm - mm..mm - mm..mm - mm..mm -######VV##VVS4############ -##LLLLLLLLLL..LLLLLLLLLL## -##LLLLLLLLLL..........LL## ->>LLLLLLLLLLLLLLLLLL..LL## -mmLL..................LL## -mmLL..LLLLLLLLLLLLLLLLLL<< -mmLL..................LLmm ->>LLLLLLLLLLLLLLLLLL..LLmm -mmLL..................LLmm -mmLL..LLLLLLLLLLLLLLLLLL<< -mmLL..........LLLLLLLLLLmm -mmLLLLLLLLLL..LLLLLLLLLLmm -mmmmmmmmmmmm..AAmmAAmmmmmm - ll..ll - mm..mm - mm..mm - mm..mm - mm..mm - ########..######## - ##..............## - ##..............## - ##..............## - ##......EE......## - ##mmmmmmmmmmmmmm## - - - - diff --git a/data/maps.copy/level_06.txt b/data/maps.copy/level_06.txt deleted file mode 100644 index 902fd7c..0000000 --- a/data/maps.copy/level_06.txt +++ /dev/null @@ -1,21 +0,0 @@ -100 100 - - -################## -##......S1......## -##..............## -##..............## -##..............## -##mmmmll..llmmmm## - mm..mm - mm..mm - mm..mm - mm..mm -########..######## -##..............## -##..............## -##..............## -##......FF......## -##mmmmmmmmmmmmmm## - - diff --git a/data/player_broken.bmp b/data/player_broken.bmp deleted file mode 100644 index 34ea7ff..0000000 Binary files a/data/player_broken.bmp and /dev/null differ diff --git a/data/player_down.bmp b/data/player_down.bmp deleted file mode 100644 index b1da764..0000000 Binary files a/data/player_down.bmp and /dev/null differ diff --git a/data/player_left.bmp b/data/player_left.bmp deleted file mode 100644 index 6b1ae8a..0000000 Binary files a/data/player_left.bmp and /dev/null differ diff --git a/data/player_right.bmp b/data/player_right.bmp deleted file mode 100644 index ceafe94..0000000 Binary files a/data/player_right.bmp and /dev/null differ diff --git a/data/player_up.bmp b/data/player_up.bmp deleted file mode 100644 index 9474e25..0000000 Binary files a/data/player_up.bmp and /dev/null differ diff --git a/data/rock.bmp b/data/rock.bmp deleted file mode 100644 index f854233..0000000 Binary files a/data/rock.bmp and /dev/null differ diff --git a/data/save_point.bmp b/data/save_point.bmp deleted file mode 100644 index 4d66760..0000000 Binary files a/data/save_point.bmp and /dev/null differ diff --git a/data/save_point_active.bmp b/data/save_point_active.bmp deleted file mode 100644 index 246bc8f..0000000 Binary files a/data/save_point_active.bmp and /dev/null differ diff --git a/game.save b/game.save index 658b252..83747a5 100644 Binary files a/game.save and b/game.save differ diff --git a/macosx/.DS_Store b/macosx/.DS_Store deleted file mode 100644 index 6ac8ba5..0000000 Binary files a/macosx/.DS_Store and /dev/null differ diff --git a/macosx/SDLMain.h b/macosx/SDLMain.h deleted file mode 100644 index c56d90c..0000000 --- a/macosx/SDLMain.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SDLMain.m - main entry point for our Cocoa-ized SDL app - Initial Version: Darrell Walisser - Non-NIB-Code & other changes: Max Horn - - Feel free to customize this file to suit your needs -*/ - -#ifndef _SDLMain_h_ -#define _SDLMain_h_ - -#import - -@interface SDLMain : NSObject -@end - -#endif /* _SDLMain_h_ */ diff --git a/macosx/SDLMain.m b/macosx/SDLMain.m deleted file mode 100644 index 150d552..0000000 --- a/macosx/SDLMain.m +++ /dev/null @@ -1,381 +0,0 @@ -/* SDLMain.m - main entry point for our Cocoa-ized SDL app - Initial Version: Darrell Walisser - Non-NIB-Code & other changes: Max Horn - - Feel free to customize this file to suit your needs -*/ - -#include -#include "SDLMain.h" -#include /* for MAXPATHLEN */ -#include - -/* For some reaon, Apple removed setAppleMenu from the headers in 10.4, - but the method still is there and works. To avoid warnings, we declare - it ourselves here. */ -@interface NSApplication(SDL_Missing_Methods) -- (void)setAppleMenu:(NSMenu *)menu; -@end - -/* Use this flag to determine whether we use SDLMain.nib or not */ -#define SDL_USE_NIB_FILE 0 - -/* Use this flag to determine whether we use CPS (docking) or not */ -#define SDL_USE_CPS 1 -#ifdef SDL_USE_CPS -/* Portions of CPS.h */ -typedef struct CPSProcessSerNum -{ - UInt32 lo; - UInt32 hi; -} CPSProcessSerNum; - -extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); - -#endif /* SDL_USE_CPS */ - -static int gArgc; -static char **gArgv; -static BOOL gFinderLaunch; -static BOOL gCalledAppMainline = FALSE; - -static NSString *getApplicationName(void) -{ - const NSDictionary *dict; - NSString *appName = 0; - - /* Determine the application name */ - dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); - if (dict) - appName = [dict objectForKey: @"CFBundleName"]; - - if (![appName length]) - appName = [[NSProcessInfo processInfo] processName]; - - return appName; -} - -#if SDL_USE_NIB_FILE -/* A helper category for NSString */ -@interface NSString (ReplaceSubString) -- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; -@end -#endif - -@interface NSApplication (SDLApplication) -@end - -@implementation NSApplication (SDLApplication) -/* Invoked from the Quit menu item */ -- (void)terminate:(id)sender -{ - /* Post a SDL_QUIT event */ - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); -} -@end - -/* The main class of the application, the application's delegate */ -@implementation SDLMain - -/* Set the working directory to the .app's parent directory */ -- (void) setupWorkingDirectory:(BOOL)shouldChdir -{ - if (shouldChdir) - { - char parentdir[MAXPATHLEN]; - CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); - if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) { - chdir(parentdir); /* chdir to the binary app's parent */ - } - CFRelease(url); - CFRelease(url2); - } -} - -#if SDL_USE_NIB_FILE - -/* Fix menu to contain the real app name instead of "SDL App" */ -- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName -{ - NSRange aRange; - NSEnumerator *enumerator; - NSMenuItem *menuItem; - - aRange = [[aMenu title] rangeOfString:@"SDL App"]; - if (aRange.length != 0) - [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; - - enumerator = [[aMenu itemArray] objectEnumerator]; - while ((menuItem = [enumerator nextObject])) - { - aRange = [[menuItem title] rangeOfString:@"SDL App"]; - if (aRange.length != 0) - [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; - if ([menuItem hasSubmenu]) - [self fixMenu:[menuItem submenu] withAppName:appName]; - } -} - -#else - -static void setApplicationMenu(void) -{ - /* warning: this code is very odd */ - NSMenu *appleMenu; - NSMenuItem *menuItem; - NSString *title; - NSString *appName; - - appName = getApplicationName(); - appleMenu = [[NSMenu alloc] initWithTitle:@""]; - - /* Add menu items */ - title = [@"About " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Hide " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; - - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; - [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; - - [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Quit " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - - - /* Put menu into the menubar */ - menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:appleMenu]; - [[NSApp mainMenu] addItem:menuItem]; - - /* Tell the application object that this is now the application menu */ - [NSApp setAppleMenu:appleMenu]; - - /* Finally give up our references to the objects */ - [appleMenu release]; - [menuItem release]; -} - -/* Create a window menu */ -static void setupWindowMenu(void) -{ - NSMenu *windowMenu; - NSMenuItem *windowMenuItem; - NSMenuItem *menuItem; - - windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - - /* "Minimize" item */ - menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; - [windowMenu addItem:menuItem]; - [menuItem release]; - - /* Put menu into the menubar */ - windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; - [windowMenuItem setSubmenu:windowMenu]; - [[NSApp mainMenu] addItem:windowMenuItem]; - - /* Tell the application object that this is now the window menu */ - [NSApp setWindowsMenu:windowMenu]; - - /* Finally give up our references to the objects */ - [windowMenu release]; - [windowMenuItem release]; -} - -/* Replacement for NSApplicationMain */ -static void CustomApplicationMain (int argc, char **argv) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - SDLMain *sdlMain; - - /* Ensure the application object is initialised */ - [NSApplication sharedApplication]; - -#ifdef SDL_USE_CPS - { - CPSProcessSerNum PSN; - /* Tell the dock about us */ - if (!CPSGetCurrentProcess(&PSN)) - if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) - if (!CPSSetFrontProcess(&PSN)) - [NSApplication sharedApplication]; - } -#endif /* SDL_USE_CPS */ - - /* Set up the menubar */ - [NSApp setMainMenu:[[NSMenu alloc] init]]; - setApplicationMenu(); - setupWindowMenu(); - - /* Create SDLMain and make it the app delegate */ - sdlMain = [[SDLMain alloc] init]; - [NSApp setDelegate:sdlMain]; - - /* Start the main event loop */ - [NSApp run]; - - [sdlMain release]; - [pool release]; -} - -#endif - - -/* - * Catch document open requests...this lets us notice files when the app - * was launched by double-clicking a document, or when a document was - * dragged/dropped on the app's icon. You need to have a - * CFBundleDocumentsType section in your Info.plist to get this message, - * apparently. - * - * Files are added to gArgv, so to the app, they'll look like command line - * arguments. Previously, apps launched from the finder had nothing but - * an argv[0]. - * - * This message may be received multiple times to open several docs on launch. - * - * This message is ignored once the app's mainline has been called. - */ -- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename -{ - const char *temparg; - size_t arglen; - char *arg; - char **newargv; - - if (!gFinderLaunch) /* MacOS is passing command line args. */ - return FALSE; - - if (gCalledAppMainline) /* app has started, ignore this document. */ - return FALSE; - - temparg = [filename UTF8String]; - arglen = SDL_strlen(temparg) + 1; - arg = (char *) SDL_malloc(arglen); - if (arg == NULL) - return FALSE; - - newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)); - if (newargv == NULL) - { - SDL_free(arg); - return FALSE; - } - gArgv = newargv; - - SDL_strlcpy(arg, temparg, arglen); - gArgv[gArgc++] = arg; - gArgv[gArgc] = NULL; - return TRUE; -} - - -/* Called when the internal event loop has just started running */ -- (void) applicationDidFinishLaunching: (NSNotification *) note -{ - int status; - - /* Set the working directory to the .app's parent directory */ - [self setupWorkingDirectory:gFinderLaunch]; - -#if SDL_USE_NIB_FILE - /* Set the main menu to contain the real app name instead of "SDL App" */ - [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; -#endif - - /* Hand off to main application code */ - gCalledAppMainline = TRUE; - status = SDL_main (gArgc, gArgv); - - /* We're done, thank you for playing */ - exit(status); -} -@end - - -@implementation NSString (ReplaceSubString) - -- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString -{ - unsigned int bufferSize; - unsigned int selfLen = [self length]; - unsigned int aStringLen = [aString length]; - unichar *buffer; - NSRange localRange; - NSString *result; - - bufferSize = selfLen + aStringLen - aRange.length; - buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar)); - - /* Get first part into buffer */ - localRange.location = 0; - localRange.length = aRange.location; - [self getCharacters:buffer range:localRange]; - - /* Get middle part into buffer */ - localRange.location = 0; - localRange.length = aStringLen; - [aString getCharacters:(buffer+aRange.location) range:localRange]; - - /* Get last part into buffer */ - localRange.location = aRange.location + aRange.length; - localRange.length = selfLen - localRange.location; - [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; - - /* Build output string */ - result = [NSString stringWithCharacters:buffer length:bufferSize]; - - NSDeallocateMemoryPages(buffer, bufferSize); - - return result; -} - -@end - - - -#ifdef main -# undef main -#endif - - -/* Main entry point to executable - should *not* be SDL_main! */ -int main (int argc, char **argv) -{ - /* Copy the arguments into a global variable */ - /* This is passed if we are launched by double-clicking */ - if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { - gArgv = (char **) SDL_malloc(sizeof (char *) * 2); - gArgv[0] = argv[0]; - gArgv[1] = NULL; - gArgc = 1; - gFinderLaunch = YES; - } else { - int i; - gArgc = argc; - gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1)); - for (i = 0; i <= argc; i++) - gArgv[i] = argv[i]; - gFinderLaunch = NO; - } - -#if SDL_USE_NIB_FILE - NSApplicationMain (argc, argv); -#else - CustomApplicationMain (argc, argv); -#endif - return 0; -} - diff --git a/macosx/SDL_dev.zip b/macosx/SDL_dev.zip deleted file mode 100644 index e860dfb..0000000 Binary files a/macosx/SDL_dev.zip and /dev/null differ