(20111228) 01:00
This commit is contained in:
@@ -93,6 +93,7 @@ int Draw_Init(int width,int height,char *title,int fps){
|
||||
glDepthMask( GL_FALSE);
|
||||
|
||||
// Triplebuffer swap
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
SDL_GL_SwapBuffers();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
SDL_GL_SwapBuffers();
|
||||
@@ -116,7 +117,7 @@ int Draw_Init(int width,int height,char *title,int fps){
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glPushMatrix ();
|
||||
glLoadIdentity ();
|
||||
glOrtho (0,width, 0, height, -1000, 1000);
|
||||
glOrtho (0,_width, 0, _height, -1000, 1000);
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glPushMatrix ();
|
||||
glLoadIdentity ();
|
||||
@@ -136,7 +137,7 @@ int Draw_Init(int width,int height,char *title,int fps){
|
||||
void Draw_Loop(int (*proc)(),void (*draw)()){
|
||||
int done=0;
|
||||
SDL_Event event;
|
||||
Uint8* keys;
|
||||
// Uint8* keys;
|
||||
long long time,time2;
|
||||
long long t_frame=0;
|
||||
|
||||
@@ -159,28 +160,35 @@ void Draw_Loop(int (*proc)(),void (*draw)()){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Process keys for Draw
|
||||
keys=SDL_GetKeyState(NULL);
|
||||
if(keys[SDLK_F12]){
|
||||
// Screenshot key
|
||||
SDL_SaveBMP(_screen,"shot.bmp");
|
||||
}
|
||||
|
||||
// Input and sound Frame
|
||||
Input_Frame();
|
||||
*/
|
||||
// Sound Frame
|
||||
Audio_Frame();
|
||||
|
||||
// Process
|
||||
// Measure time
|
||||
time2=Time_GetTime();
|
||||
t_frame+=time2-time;
|
||||
time=time2;
|
||||
if(t_frame>50000){
|
||||
t_frame=50000;
|
||||
}
|
||||
|
||||
// Process
|
||||
if(proc){
|
||||
while(t_frame>_t_frame && !done){
|
||||
//while(t_frame>0 && !done){
|
||||
Input_Frame();
|
||||
if(!proc()){
|
||||
done=1;
|
||||
}
|
||||
t_frame-=_t_frame;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,6 +430,15 @@ void Draw_DrawImgPart(DrawImg img,int x,int y,int w,int i){
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_SetColor
|
||||
//
|
||||
//
|
||||
void Draw_SetColor(float r,float g,float b,float a){
|
||||
glColor4f(r,g,b,a);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// DrawFnt //
|
||||
/////////////
|
||||
7
Draw.h
7
Draw.h
@@ -72,6 +72,13 @@ void Draw_DrawImg(DrawImg img,int x,int y);
|
||||
void Draw_DrawImgPart(DrawImg img,int x,int y,int w,int i);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_SetColor
|
||||
//
|
||||
//
|
||||
void Draw_SetColor(float r,float g,float b,float a);
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// DrawFnt //
|
||||
/////////////
|
||||
|
||||
457
DrawSDL.c
457
DrawSDL.c
@@ -1,457 +0,0 @@
|
||||
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
|
||||
|
||||
#ifdef WIN32
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <SDL/SDL.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Time.h"
|
||||
#include "Util.h"
|
||||
#include "Draw.h"
|
||||
#include "Input.h"
|
||||
#include "Audio.h"
|
||||
|
||||
|
||||
// Globals
|
||||
SDL_Surface *_screen=NULL;
|
||||
long long _t_frame=17000;
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_Init
|
||||
//
|
||||
// Initializes the game window.
|
||||
int Draw_Init(int width,int height,char *title,int fps){
|
||||
#ifdef WIN32
|
||||
// Stdout on the parent console
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
if(GetStdHandle(STD_OUTPUT_HANDLE)!=0){
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
fclose(stderr);
|
||||
freopen("CONIN$","r",stdin);
|
||||
freopen("CONOUT$","w",stdout);
|
||||
freopen("CONOUT$","w",stderr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialize SDL
|
||||
if(SDL_Init(SDL_INIT_VIDEO)<0){
|
||||
printf("Draw_Init: Failure initializing SDL.\n");
|
||||
printf("Draw_Init: SDL Error: %s\n",SDL_GetError());
|
||||
return(0);
|
||||
}
|
||||
|
||||
// Initialize video mode
|
||||
_screen=SDL_SetVideoMode(width,height,32,SDL_HWSURFACE);
|
||||
if( _screen == NULL){
|
||||
printf("Draw_Init: Failure initializing video mode.\n");
|
||||
printf("Draw_Init: SDL Error: %s\n",SDL_GetError());
|
||||
return(0);
|
||||
}
|
||||
SDL_WM_SetCaption(title, NULL);
|
||||
_t_frame=1000000/fps;
|
||||
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_Loop
|
||||
//
|
||||
// Loops updating the game window.
|
||||
void Draw_Loop(int (*proc)(),void (*draw)()){
|
||||
int done=0;
|
||||
SDL_Event event;
|
||||
Uint8* keys;
|
||||
long long time,time2;
|
||||
long long t_frame=0;
|
||||
|
||||
t_frame=0;
|
||||
while(!done){
|
||||
|
||||
// Update screen
|
||||
time=Time_GetTime();
|
||||
//SDL_GL_SwapBuffers();
|
||||
SDL_Flip(_screen);
|
||||
|
||||
|
||||
// Process Events
|
||||
while(SDL_PollEvent(&event) ){
|
||||
if(event.type == SDL_QUIT ){
|
||||
done=1;
|
||||
}
|
||||
if(event.type == SDL_KEYDOWN ){
|
||||
if(event.key.keysym.sym == SDLK_ESCAPE ) {
|
||||
done=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process keys for Draw
|
||||
keys=SDL_GetKeyState(NULL);
|
||||
if(keys[SDLK_F12]){
|
||||
// Screenshot key
|
||||
SDL_SaveBMP(_screen,"shot.bmp");
|
||||
}
|
||||
|
||||
// Input and sound Frame
|
||||
Input_Frame();
|
||||
Audio_Frame();
|
||||
|
||||
// Process
|
||||
time2=Time_GetTime();
|
||||
t_frame+=time2-time;
|
||||
time=time2;
|
||||
if(proc){
|
||||
while(t_frame>_t_frame && !done){
|
||||
if(!proc()){
|
||||
done=1;
|
||||
}
|
||||
t_frame-=_t_frame;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
draw();
|
||||
|
||||
Time_Pause(0);
|
||||
t_frame+=Time_GetTime()-time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_Clean
|
||||
//
|
||||
// Cleans the game window.
|
||||
void Draw_Clean(
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
|
||||
// Draw a full rectangle
|
||||
rect.x=0;
|
||||
rect.y=0;
|
||||
rect.w=_screen->w;
|
||||
rect.h=_screen->h;
|
||||
SDL_FillRect(_screen, &rect,
|
||||
SDL_MapRGB(_screen->format, r, g, b));
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// DrawImage //
|
||||
///////////////
|
||||
// Image container.
|
||||
typedef struct Tag_DrawImage {
|
||||
SDL_Surface *surf;
|
||||
int x,y;
|
||||
} DrawImage;
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_LoadSurface
|
||||
//
|
||||
// Loads a surface.
|
||||
SDL_Surface *Draw_LoadSurface(char *filename){
|
||||
SDL_Surface *surf;
|
||||
|
||||
// Load the BMP as a surface
|
||||
surf=SDL_LoadBMP(filename);
|
||||
if(surf == NULL){
|
||||
printf("Draw_LoadImage: Failure Loading image: %s\n",filename);
|
||||
printf("Draw_LoadImage: SDL Error: %s\n",SDL_GetError());
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// FIX: Setting up the alpha channel.
|
||||
if(surf->format->BytesPerPixel==4){
|
||||
int i,len,trans;
|
||||
|
||||
// set the correct values
|
||||
surf->format->Amask=0xFF000000;
|
||||
surf->format->Ashift=24;
|
||||
|
||||
// Check if the image has some area transparent
|
||||
trans=0;
|
||||
len=surf->w*surf->h;
|
||||
for(i=0;i<len;i++){
|
||||
if((((Uint32 *)surf->pixels)[i]&0xFF000000)!=0xFF000000){
|
||||
trans=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(trans){
|
||||
// Make it use the alpha channel
|
||||
SDL_SetAlpha(surf, SDL_SRCALPHA, 255);
|
||||
}
|
||||
}
|
||||
|
||||
return(surf);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_LoadImage
|
||||
//
|
||||
// Loads a image, giving a reference.
|
||||
DrawImg Draw_LoadImage(char *filename){
|
||||
DrawImage *image;
|
||||
SDL_Surface *surf;
|
||||
|
||||
// Loads the surface
|
||||
surf=Draw_LoadSurface(filename);
|
||||
if(surf == NULL){
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// Create the image container
|
||||
image=malloc(sizeof(DrawImage));
|
||||
image->surf=surf;
|
||||
image->x=0;
|
||||
image->y=0;
|
||||
|
||||
return((DrawImg)image);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_GetSize
|
||||
//
|
||||
// Gets the image size.
|
||||
void Draw_GetSize(DrawImg img,int *w,int *h){
|
||||
DrawImage *image=img;
|
||||
|
||||
// Gets the image size
|
||||
*w=image->surf->w;
|
||||
*h=image->surf->h;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_SetOffset
|
||||
// Draw_GetOffset
|
||||
//
|
||||
// Sets and Gets the image offset.
|
||||
void Draw_SetOffset(DrawImg img,int x,int y){
|
||||
DrawImage *image=img;
|
||||
|
||||
// Sets the image offset
|
||||
image->x=x;
|
||||
image->y=y;
|
||||
}
|
||||
void Draw_GetOffset(DrawImg img,int *x,int *y){
|
||||
DrawImage *image=img;
|
||||
|
||||
// Gets the image offset
|
||||
*x=image->x;
|
||||
*y=image->y;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DrawImg
|
||||
//
|
||||
// Draws an image.
|
||||
void Draw_DrawImg(DrawImg img,int x,int y){
|
||||
DrawImage *image=img;
|
||||
SDL_Rect orig;
|
||||
SDL_Rect dest;
|
||||
|
||||
// Prepare the rects
|
||||
orig.x=0;
|
||||
orig.y=0;
|
||||
dest.x=x+image->x;
|
||||
dest.y=y+image->y;
|
||||
orig.w=dest.w=image->surf->w;
|
||||
orig.h=dest.h=image->surf->h;
|
||||
|
||||
// Blit the surface on the screen
|
||||
SDL_BlitSurface(image->surf,&orig,_screen,&dest);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DrawImgPart
|
||||
//
|
||||
// Draws an image part.
|
||||
void Draw_DrawImgPart(DrawImg img,int x,int y,int w,int i){
|
||||
DrawImage *image=img;
|
||||
SDL_Rect orig;
|
||||
SDL_Rect dest;
|
||||
|
||||
// Prepare the rects
|
||||
orig.x=w*i;
|
||||
orig.y=0;
|
||||
dest.x=x+image->x;
|
||||
dest.y=y+image->y;
|
||||
orig.w=dest.w=w;
|
||||
orig.h=dest.h=image->surf->h;
|
||||
|
||||
// Blit the surface on the screen
|
||||
SDL_BlitSurface(image->surf,&orig,_screen,&dest);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DrawImgTrans
|
||||
//
|
||||
// Draws an image transformed.
|
||||
void Draw_DrawImgTrans(DrawImg img,int x,int y,float angle){
|
||||
DrawImage *image=img;
|
||||
SDL_Rect orig;
|
||||
SDL_Rect dest;
|
||||
|
||||
// Prepare the rects
|
||||
orig.x=0;
|
||||
orig.y=0;
|
||||
dest.x=x+image->x;
|
||||
dest.y=y+image->y;
|
||||
orig.w=dest.w=image->surf->w;
|
||||
orig.h=dest.h=image->surf->h;
|
||||
|
||||
// Blit the surface on the screen
|
||||
SDL_BlitSurface(image->surf,&orig,_screen,&dest);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// DrawFnt //
|
||||
/////////////
|
||||
// Reference to a Font.
|
||||
typedef struct {
|
||||
SDL_Surface *surf;
|
||||
int w,h;
|
||||
int min,max;
|
||||
} DrawFont;
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DefaultFont
|
||||
//
|
||||
// Creates a surface with the default font.
|
||||
#include "FontData.h"
|
||||
SDL_Surface *Draw_DefaultFontSurface(
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b,
|
||||
unsigned char a)
|
||||
{
|
||||
SDL_Surface *surf;
|
||||
int x,y,c;
|
||||
Uint32 color,color2;
|
||||
|
||||
// Create the surface
|
||||
surf = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
8*256, 8, 32,0,0,0,0);
|
||||
surf->format->Amask=0xFF000000;
|
||||
surf->format->Ashift=24;
|
||||
SDL_SetAlpha(surf, SDL_SRCALPHA, 255);
|
||||
|
||||
// Draw the font
|
||||
SDL_LockSurface(surf);
|
||||
color =SDL_MapRGBA(surf->format,r,g,b,a);
|
||||
color2=SDL_MapRGBA(surf->format,r,g,b,0);
|
||||
for(c=0;c<256;c++){
|
||||
for(y=0;y<8;y++){
|
||||
for(x=0;x<8;x++){
|
||||
if(((fontdata_8x8[c*8+y]>>(7-x)) & 0x01)==1){
|
||||
//Imagen_PutPixel(dest,c*8+x,y,color);
|
||||
((Uint32 *)surf->pixels)[(c*8+x)+(8*256*y)]=
|
||||
color;
|
||||
}else{
|
||||
//Imagen_PutPixel(dest,c*8+x,y,color2);
|
||||
((Uint32 *)surf->pixels)[(c*8+x)+(8*256*y)]=
|
||||
color2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_UnlockSurface(surf);
|
||||
|
||||
return(surf);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DefaultFont
|
||||
//
|
||||
// Creates the default font.
|
||||
DrawFnt Draw_DefaultFont(
|
||||
unsigned char r,
|
||||
unsigned char g,
|
||||
unsigned char b,
|
||||
unsigned char a)
|
||||
{
|
||||
DrawFont *font;
|
||||
|
||||
// Create the default font
|
||||
font=malloc(sizeof(DrawFont));
|
||||
font->surf = Draw_DefaultFontSurface(r,g,b,a);
|
||||
font->w=8;
|
||||
font->h=8;
|
||||
font->min=0;
|
||||
font->max=128;
|
||||
|
||||
return((DrawFnt)font);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_LoadFont
|
||||
//
|
||||
// Load a font from a file.
|
||||
DrawFnt Draw_LoadFont(char *fichero,int min,int max){
|
||||
DrawFont *font;
|
||||
int w,h;
|
||||
|
||||
// Create the font form the image
|
||||
font=malloc(sizeof(DrawFont));
|
||||
font->surf = Draw_LoadSurface(fichero);
|
||||
font->w=font->surf->w/(max-min);
|
||||
font->h=font->surf->h;
|
||||
font->min=min;
|
||||
font->max=max;
|
||||
|
||||
return((DrawFnt)font);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Draw_DrawText
|
||||
//
|
||||
// Draws text using a font
|
||||
void Draw_DrawText(DrawFnt f,char *text,int x,int y){
|
||||
DrawFont *font=f;
|
||||
SDL_Rect orig;
|
||||
SDL_Rect dest;
|
||||
char *ptr;
|
||||
|
||||
// Prepare the rects
|
||||
orig.w=dest.w=font->w;
|
||||
orig.h=dest.h=font->h;
|
||||
orig.y=0;
|
||||
dest.x=x;
|
||||
dest.y=y;
|
||||
|
||||
// Iterate the string
|
||||
ptr=text;
|
||||
while(*ptr){
|
||||
if((*ptr)<font->max){
|
||||
orig.x=((*ptr)-font->min)*font->w;
|
||||
dest.x=x;
|
||||
dest.y=y;
|
||||
// Blit every character
|
||||
SDL_BlitSurface(font->surf,&orig,_screen,&dest);
|
||||
}
|
||||
x+=font->w;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
129
Entity.c
129
Entity.c
@@ -38,9 +38,11 @@ Entity *Entity_New(){
|
||||
e->fric_static=0.0f;
|
||||
e->fric_dynamic=0.0f;
|
||||
|
||||
//e->img=NULL;
|
||||
AnimPlay_SetImg(&e->anim,NULL);
|
||||
|
||||
e->color[0]=e->color[1]=e->color[2]=e->color[3]=1.0f;
|
||||
e->light[0]=e->light[1]=e->light[2]=e->light[3]=1.0f;
|
||||
|
||||
e->oncopy=NULL;
|
||||
e->ondelete=NULL;
|
||||
e->proc=NULL;
|
||||
@@ -91,8 +93,15 @@ Entity *Entity_Copy(Entity *e){
|
||||
n->fric_static=e->fric_static;
|
||||
n->fric_dynamic=e->fric_dynamic;
|
||||
|
||||
//n->img=e->img;
|
||||
AnimPlay_Copy(&n->anim,&e->anim);
|
||||
n->color[0]=e->color[0];
|
||||
n->color[1]=e->color[1];
|
||||
n->color[2]=e->color[2];
|
||||
n->color[3]=e->color[3];
|
||||
n->light[0]=e->light[0];
|
||||
n->light[1]=e->light[1];
|
||||
n->light[2]=e->light[2];
|
||||
n->light[3]=e->light[3];
|
||||
|
||||
n->oncopy=e->oncopy;
|
||||
n->ondelete=e->ondelete;
|
||||
@@ -118,6 +127,7 @@ Entity *Entity_Copy(Entity *e){
|
||||
//
|
||||
//
|
||||
void Entity_Draw(Entity *e,int x,int y){
|
||||
Draw_SetColor(e->color[0],e->color[1],e->color[2],e->color[3]);
|
||||
AnimPlay_Draw(&e->anim,e->pos[0]+x,e->pos[1]+y);
|
||||
}
|
||||
|
||||
@@ -127,6 +137,7 @@ void Entity_Draw(Entity *e,int x,int y){
|
||||
//
|
||||
//
|
||||
void Entity_Process(Entity *b,int ft){
|
||||
b->flags&=~EntityFlag_UpdatedPos;
|
||||
|
||||
// Launch method
|
||||
if(b->proc){
|
||||
@@ -165,6 +176,8 @@ void Entity_PostProcess(Entity *e,int ft){
|
||||
1.0f-(e->fric_dynamic+(e->fric_static/len)));
|
||||
}
|
||||
|
||||
|
||||
e->flags|=EntityFlag_UpdatedPos;
|
||||
}
|
||||
|
||||
// Animate
|
||||
@@ -175,7 +188,7 @@ void Entity_PostProcess(Entity *e,int ft){
|
||||
/////////////////////////////
|
||||
// Entity_CollisionResponse
|
||||
//
|
||||
// Response to a collision
|
||||
// Normal response to a collision.
|
||||
void Entity_CollisionResponse(
|
||||
Entity *b1,Entity *b2,float t,vec2 n)
|
||||
{
|
||||
@@ -278,10 +291,11 @@ void Entity_Overlaps(Entity *b1,Entity *b2){
|
||||
vec2 len;
|
||||
float dist;
|
||||
|
||||
if(!(b1->flags&EntityFlag_Overlap) || !(b2->flags&EntityFlag_Overlap))
|
||||
return;
|
||||
// if(!(b1->flags&EntityFlag_Overlap) || !(b2->flags&EntityFlag_Overlap))
|
||||
// return;
|
||||
|
||||
vec2_minus(len,b1->pos,b2->pos);
|
||||
#if 0
|
||||
if(fabs(len[0])>b1->radius)
|
||||
return;
|
||||
if(fabs(len[1])>b1->radius)
|
||||
@@ -298,6 +312,23 @@ void Entity_Overlaps(Entity *b1,Entity *b2){
|
||||
if(b2->radius>dist && b2->overlap){
|
||||
b2->overlap(b2,b1);
|
||||
}
|
||||
#else
|
||||
vec2_set(len,fabs(b1->pos[0]-b2->pos[0]),fabs(b1->pos[1]-b2->pos[1]));
|
||||
if(b1->overlap){
|
||||
if( len[0]<=b1->radius &&
|
||||
len[1]<=b1->radius)
|
||||
{
|
||||
b1->overlap(b1,b2);
|
||||
}
|
||||
}
|
||||
if(b2->overlap){
|
||||
if( len[0]<=b2->radius &&
|
||||
len[1]<=b2->radius)
|
||||
{
|
||||
b2->overlap(b2,b1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -323,5 +354,91 @@ void Entity_AddVelLimit(Entity *e,vec2 vel,float limit){
|
||||
vec2_scale(vel_temp,dir,vlen);
|
||||
vec2_plus(e->vel,e->vel,vel_temp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_SetColor
|
||||
//
|
||||
//
|
||||
void Entity_SetColor(Entity *e,float r,float g,float b,float a){
|
||||
e->color[0]=r;
|
||||
e->color[1]=g;
|
||||
e->color[2]=b;
|
||||
e->color[3]=a;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_AddColor(Entity *e,float r,float g,float b,float a){
|
||||
e->color[0]+=r;
|
||||
if(e->color[0]>1.0f)
|
||||
e->color[0]=1.0f;
|
||||
e->color[1]+=g;
|
||||
if(e->color[1]>1.0f)
|
||||
e->color[1]=1.0f;
|
||||
e->color[2]+=b;
|
||||
if(e->color[2]>1.0f)
|
||||
e->color[2]=1.0f;
|
||||
e->color[3]+=a;
|
||||
if(e->color[3]>1.0f)
|
||||
e->color[3]=1.0f;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_SetLight(Entity *e,float r,float g,float b,float rad){
|
||||
e->light[0]=r;
|
||||
e->light[1]=g;
|
||||
e->light[2]=b;
|
||||
e->light[3]=rad;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_Iluminate(Entity *e,Entity **elist,int n){
|
||||
int i;
|
||||
vec2 vdist;
|
||||
float qdist,dist,f;
|
||||
float qrad;
|
||||
|
||||
if(!(e->flags&EntityFlag_Light)){
|
||||
Entity_SetColor(e,
|
||||
e->light[0],
|
||||
e->light[1],
|
||||
e->light[2],
|
||||
1.0f);
|
||||
}else{
|
||||
Entity_SetColor(e,1.0f,1.0f,1.0f,1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
for(i=0;i<n;i++){
|
||||
if(e==elist[i] || !(elist[i]->flags&EntityFlag_Light))
|
||||
continue;
|
||||
|
||||
vec2_minus(vdist,e->pos,elist[i]->pos);
|
||||
qdist=vec2_dot(vdist,vdist);
|
||||
qrad=elist[i]->light[3]*elist[i]->light[3];
|
||||
if(qdist<qrad){
|
||||
//dist=sqrtf(qdist);
|
||||
//f=1.0f-dist/elist[i]->light[3];
|
||||
f=1.0f-qdist/qrad;
|
||||
Entity_AddColor(e,
|
||||
f*elist[i]->light[0],
|
||||
f*elist[i]->light[1],
|
||||
f*elist[i]->light[2],
|
||||
1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
Entity.h
42
Entity.h
@@ -9,6 +9,9 @@
|
||||
|
||||
#define EntityFlag_Collision 1
|
||||
#define EntityFlag_Overlap 2
|
||||
#define EntityFlag_Light 4
|
||||
#define EntityFlag_UpdateLight 8
|
||||
#define EntityFlag_UpdatedPos 16
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
@@ -32,6 +35,9 @@ typedef struct Tag_Entity {
|
||||
|
||||
AnimPlay anim;
|
||||
|
||||
float color[4];
|
||||
float light[4];
|
||||
|
||||
void (*oncopy)(struct Tag_Entity *ent);
|
||||
void (*ondelete)(struct Tag_Entity *ent);
|
||||
void (*proc)(struct Tag_Entity *ent,int ft);
|
||||
@@ -92,6 +98,14 @@ void Entity_Process(Entity *e,int ft);
|
||||
void Entity_PostProcess(Entity *e,int ft);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_CollisionResponse
|
||||
//
|
||||
// Normal response to a collision.
|
||||
void Entity_CollisionResponse(
|
||||
Entity *b1,Entity *b2,float t,vec2 n);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_Collide
|
||||
//
|
||||
@@ -113,4 +127,32 @@ void Entity_Overlaps(Entity *b1,Entity *b2);
|
||||
void Entity_AddVelLimit(Entity *e,vec2 vel,float limit);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_SetColor
|
||||
//
|
||||
//
|
||||
void Entity_SetColor(Entity *e,float r,float g,float b,float a);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_AddColor(Entity *e,float r,float g,float b,float a);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_SetLight(Entity *e,float r,float g,float b,float rad);
|
||||
|
||||
/////////////////////////////
|
||||
// Entity_AddColor
|
||||
//
|
||||
//
|
||||
void Entity_Iluminate(Entity *e,Entity **elist,int n);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
112
GameEnts.c
112
GameEnts.c
@@ -4,6 +4,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "GameLib.h"
|
||||
extern int gamelib_debug;
|
||||
|
||||
#include "GameEnts.h"
|
||||
|
||||
@@ -88,6 +89,19 @@ void player_proc(Entity *e,int ft){
|
||||
vec2 vel;
|
||||
int pos[2],size[2],delta[2];
|
||||
|
||||
if (gamelib_debug) {
|
||||
if (Input_GetKey(InputKey_Jump)==InputKey_Pressed) {
|
||||
if (!(e->flags&EntityFlag_Collision)) {
|
||||
e->flags|=(EntityFlag_Collision|EntityFlag_Overlap);
|
||||
GameLib_EntitySetLight(e,0.4f,0.4f,0.4f,5*32.0f);
|
||||
}else {
|
||||
e->flags&=~(EntityFlag_Collision|EntityFlag_Overlap);
|
||||
GameLib_EntitySetLight(e,0.7f,0.7f,0.7f,20*32.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(Input_GetDir(vel)){
|
||||
vec2 up,right;
|
||||
float updown,leftright;
|
||||
@@ -131,6 +145,30 @@ void player_proc(Entity *e,int ft){
|
||||
GameLib_SetPos(pos);
|
||||
}
|
||||
|
||||
int player_collision(Entity *e1,Entity *e2,float t,vec2 n){
|
||||
if(e2->type==Ent_Barrel){
|
||||
/*
|
||||
vec2_scale(e1->vel,e1->vel,0.5f);
|
||||
vec2_plus(e2->vel,e2->vel,e1->vel);
|
||||
*/
|
||||
float vlen,dotp;
|
||||
vec2 vdir;
|
||||
vlen=sqrtf(vec2_dot(e1->vel,e1->vel));
|
||||
if(vlen>0.0f){
|
||||
vec2_scale(vdir,e1->vel,1.0f/vlen);
|
||||
if(vec2_dot(vdir,n)>0.9){
|
||||
Entity_CollisionResponse(e1,e2,t,vdir);
|
||||
return(0);
|
||||
}else{
|
||||
return(1);
|
||||
}
|
||||
}else{
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void barrel_proc(Entity *e,int ft){
|
||||
float qvel;
|
||||
int tnow;
|
||||
@@ -262,8 +300,10 @@ void savepoint_overlap(Entity *e1,Entity *e2){
|
||||
}
|
||||
if(e1!=_savepoint){
|
||||
AnimPlay_SetAnim(&e1->anim,anim_savepoint_active);
|
||||
GameLib_EntitySetLight(e1,0.0f,0.0f,0.5f,4*32.0f);
|
||||
if(_savepoint){
|
||||
AnimPlay_SetImg(&_savepoint->anim,img_savepoint);
|
||||
GameLib_EntitySetLight(_savepoint,0.0f,0.0f,0.5f,2*32.0f);
|
||||
}
|
||||
_savepoint=e1;
|
||||
}
|
||||
@@ -306,9 +346,10 @@ void timeoutent_proc(Entity *e,int ft){
|
||||
|
||||
|
||||
void GameEnts_Init(){
|
||||
Entity *ent;
|
||||
|
||||
|
||||
// Load Graphics
|
||||
//////////////////////////////
|
||||
// Load Resources
|
||||
|
||||
img_barrel=Draw_LoadImage("data/barrel.bmp");
|
||||
Draw_SetOffset(img_barrel,-16,-32);
|
||||
@@ -393,19 +434,35 @@ void GameEnts_Init(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// Create the entity templates
|
||||
|
||||
ent_player=Entity_New();
|
||||
ent=Entity_New();
|
||||
ent->mass=-1.0f;
|
||||
ent->flags=0;
|
||||
Entity_SetLight(ent,0.2f,0.2f,0.2f,1.0f);
|
||||
|
||||
|
||||
ent_player=Entity_Copy(ent);
|
||||
ent_player->type=Ent_Player;
|
||||
ent_player->radius=16.0f;
|
||||
ent_player->mass=70.0f;
|
||||
ent_player->fric_static=0.5f;
|
||||
ent_player->flags=
|
||||
EntityFlag_Collision|EntityFlag_Overlap|EntityFlag_Light;
|
||||
Entity_SetLight(ent_player,0.4f,0.4f,0.4f,5*32.0f);
|
||||
AnimPlay_SetImg(&ent_player->anim,img_player_down);
|
||||
ent_player->proc=player_proc;
|
||||
ent_player->collision=player_collision;
|
||||
|
||||
|
||||
ent_barrel=Entity_New();
|
||||
ent_barrel=Entity_Copy(ent);
|
||||
ent_barrel->type=Ent_Barrel;
|
||||
ent_barrel->flags=
|
||||
EntityFlag_Collision|EntityFlag_Overlap;
|
||||
ent_barrel->radius=16.0f;
|
||||
ent_barrel->mass=100.0f;
|
||||
ent_barrel->fric_static=0.5f;
|
||||
@@ -413,19 +470,18 @@ void GameEnts_Init(){
|
||||
AnimPlay_SetImg(&ent_barrel->anim,img_barrel);
|
||||
|
||||
|
||||
ent_column=Entity_New();
|
||||
ent_column=Entity_Copy(ent);
|
||||
ent_column->type=Ent_Column;
|
||||
ent_column->flags=EntityFlag_Collision;
|
||||
//ent_column->flags=0;
|
||||
ent_column->radius=12;
|
||||
ent_column->mass=-1.0f;
|
||||
AnimPlay_SetImg(&ent_column->anim,img_column);
|
||||
ent_column_faded=Entity_Copy(ent_column);
|
||||
AnimPlay_SetImg(&ent_column_faded->anim,img_column_faded);
|
||||
|
||||
|
||||
|
||||
ent_floor=Entity_New();
|
||||
ent_floor=Entity_Copy(ent);
|
||||
ent_floor->type=Ent_Floor;
|
||||
ent_floor->zorder=-1;
|
||||
ent_floor->flags=0;
|
||||
@@ -437,7 +493,7 @@ void GameEnts_Init(){
|
||||
ent_floor_center=Entity_Copy(ent_floor);
|
||||
AnimPlay_SetImg(&ent_floor_center->anim,img_floor_center);
|
||||
|
||||
ent_hole_spiked=Entity_New();
|
||||
ent_hole_spiked=Entity_Copy(ent);
|
||||
ent_hole_spiked->type=Ent_Hole_Spiked;
|
||||
ent_hole_spiked->zorder=-1;
|
||||
ent_hole_spiked->flags=EntityFlag_Overlap;
|
||||
@@ -445,25 +501,29 @@ void GameEnts_Init(){
|
||||
AnimPlay_SetImg(&ent_hole_spiked->anim,img_hole_spiked);
|
||||
ent_hole_spiked->overlap=hole_spiked_overlap;
|
||||
|
||||
ent_hole_filled=Entity_New();
|
||||
ent_hole_filled=Entity_Copy(ent);
|
||||
ent_hole_filled->type=Ent_Hole_Filled;
|
||||
ent_hole_filled->zorder=-1;
|
||||
ent_hole_filled->flags=0;
|
||||
AnimPlay_SetImg(&ent_hole_filled->anim,img_barrel2);
|
||||
|
||||
ent_hole_lava=Entity_New();
|
||||
ent_hole_lava=Entity_Copy(ent);
|
||||
ent_hole_lava->type=Ent_Hole_Lava;
|
||||
ent_hole_lava->zorder=-1;
|
||||
ent_hole_lava->flags=EntityFlag_Overlap;
|
||||
ent_hole_lava->flags=EntityFlag_Overlap|EntityFlag_Light;
|
||||
ent_hole_lava->radius=18;
|
||||
AnimPlay_SetAnim(&ent_hole_lava->anim,anim_hole_lava);
|
||||
Entity_SetLight(ent_hole_lava,1.0f,0.0f,0.0f,4*32.0f);
|
||||
ent_hole_lava->overlap=hole_lava_overlap;
|
||||
|
||||
|
||||
ent_arrow_up=Entity_New();
|
||||
ent_arrow_up=Entity_Copy(ent);
|
||||
ent_arrow_up->type=Ent_Arrow;
|
||||
ent_arrow_up->flags=EntityFlag_Collision;
|
||||
ent_arrow_up->radius=7;
|
||||
//ent_arrow_up->flags=EntityFlag_Collision;
|
||||
ent_arrow_up->flags=EntityFlag_Collision|EntityFlag_Light;
|
||||
Entity_SetLight(ent_arrow_up,0.2f,0.2f,0.2f,2*32.0f);
|
||||
ent_arrow_up->radius=4;
|
||||
ent_arrow_up->mass=0.1f;
|
||||
ent_arrow_up->collision=arrow_collision;
|
||||
ent_arrow_up->proc=timeoutent_proc;
|
||||
ent_arrow_up->A=120;
|
||||
@@ -480,11 +540,10 @@ void GameEnts_Init(){
|
||||
vec2_set(ent_arrow_right->vel,4,0);
|
||||
|
||||
|
||||
ent_arrowshooter_up=Entity_New();
|
||||
ent_arrowshooter_up=Entity_Copy(ent);
|
||||
ent_arrowshooter_up->type=Ent_ArrowShooter;
|
||||
ent_arrowshooter_up->flags=EntityFlag_Collision;
|
||||
ent_arrowshooter_up->radius=15;
|
||||
ent_arrowshooter_up->mass=-1.0f;
|
||||
ent_arrowshooter_up->oncopy=arrowshooter_oncopy;
|
||||
ent_arrowshooter_up->proc=arrowshooter_proc;
|
||||
AnimPlay_SetImg(&ent_arrowshooter_up->anim,img_arrowshooter_up);
|
||||
@@ -500,11 +559,12 @@ void GameEnts_Init(){
|
||||
ent_arrowshooter_right->child=ent_arrow_right;
|
||||
|
||||
|
||||
ent_savepoint_1=Entity_New();
|
||||
ent_savepoint_1=Entity_Copy(ent);
|
||||
ent_savepoint_1->type=Ent_SavePoint;
|
||||
ent_savepoint_1->zorder=0;
|
||||
ent_savepoint_1->flags=EntityFlag_Overlap;
|
||||
ent_savepoint_1->radius=16;
|
||||
ent_savepoint_1->flags=EntityFlag_Overlap|EntityFlag_Light;
|
||||
ent_savepoint_1->radius=20;
|
||||
Entity_SetLight(ent_savepoint_1,0.0f,0.0f,0.5f,2*32.0f);
|
||||
AnimPlay_SetImg(&ent_savepoint_1->anim,img_savepoint);
|
||||
ent_savepoint_1->overlap=savepoint_overlap;
|
||||
ent_savepoint_1->ondelete=savepoint_ondelete;
|
||||
@@ -527,24 +587,26 @@ void GameEnts_Init(){
|
||||
ent_savepoint_9->A=9;
|
||||
|
||||
|
||||
ent_exitpoint=Entity_New();
|
||||
ent_exitpoint=Entity_Copy(ent);
|
||||
ent_exitpoint->type=Ent_ExitPoint;
|
||||
ent_exitpoint->flags=EntityFlag_Overlap;
|
||||
ent_exitpoint->radius=16;
|
||||
ent_exitpoint->flags=EntityFlag_Overlap|EntityFlag_Light;
|
||||
Entity_SetLight(ent_exitpoint,0.5f,0.5f,0.5f,5*32.0f);
|
||||
ent_exitpoint->radius=20;
|
||||
AnimPlay_SetAnim(&ent_exitpoint->anim,anim_exitpoint);
|
||||
ent_exitpoint->overlap=exitpoint_overlap;
|
||||
ent_endpoint=Entity_Copy(ent_exitpoint);
|
||||
AnimPlay_SetImg(&ent_endpoint->anim,img_endpoint);
|
||||
ent_endpoint->overlap=endpoint_overlap;
|
||||
|
||||
ent_fire=Entity_New();
|
||||
ent_fire=Entity_Copy(ent);
|
||||
ent_fire->type=Ent_Effect;
|
||||
ent_fire->flags=0;
|
||||
ent_fire->flags=EntityFlag_Light;
|
||||
Entity_SetLight(ent_fire,1.0f,0.0f,0.0f,3*32.0f);
|
||||
AnimPlay_SetAnim(&ent_fire->anim,anim_fire);
|
||||
ent_fire->proc=timeoutent_proc;
|
||||
ent_fire->A=60;
|
||||
|
||||
ent_player_broken=Entity_New();
|
||||
ent_player_broken=Entity_Copy(ent);
|
||||
ent_player_broken->type=Ent_Effect;
|
||||
ent_player_broken->flags=0;
|
||||
AnimPlay_SetImg(&ent_player_broken->anim,img_player_broken);
|
||||
|
||||
141
GameLib.c
141
GameLib.c
@@ -33,7 +33,10 @@ long long t_col;
|
||||
long long t_over;
|
||||
long long t_postproc;
|
||||
long long t_draw;
|
||||
int f_count;
|
||||
int fproc_count;
|
||||
int fdraw_count;
|
||||
|
||||
int gamelib_debug=0;
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
@@ -93,6 +96,9 @@ void GameLib_AddEntity(Entity *e){
|
||||
_entity[_n_entities]=e;
|
||||
_entity_flag[_n_entities]=1;
|
||||
_n_entities++;
|
||||
|
||||
// Mark for light update
|
||||
GameLib_EntityUpdateLight(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +110,7 @@ int GameLib_UnrefEntity(Entity *e){
|
||||
int i;
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if(e==_entity[i]){
|
||||
// Mark or unref
|
||||
if(_entities_lock){
|
||||
_entity_flag[i]=-2;
|
||||
}else{
|
||||
@@ -111,6 +118,9 @@ int GameLib_UnrefEntity(Entity *e){
|
||||
_entity_flag[i]=0;
|
||||
}
|
||||
_entities_compactate=1;
|
||||
|
||||
// Mark for light update
|
||||
GameLib_EntityUpdateLight(e);
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
@@ -197,11 +207,11 @@ int GameLib_ProcLoop(){
|
||||
count=0;
|
||||
do{
|
||||
repeat=0;
|
||||
for(i=0;i<_n_entities-1;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Collision))
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Collision) || _entity[i]->mass<0.0f)
|
||||
continue;
|
||||
for(j=i+1;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Collision))
|
||||
for(j=0;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Collision) || i==j)
|
||||
continue;
|
||||
if(Entity_Collide(_entity[i],_entity[j])){
|
||||
repeat=1;
|
||||
@@ -212,11 +222,11 @@ int GameLib_ProcLoop(){
|
||||
}while(repeat && count<10);
|
||||
// Stop remaining collisions
|
||||
if(count==10){
|
||||
for(i=0;i<_n_entities-1;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Collision))
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Collision) || _entity[i]->mass<0.0f)
|
||||
continue;
|
||||
for(j=i+1;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Collision))
|
||||
for(j=0;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Collision) || i==j)
|
||||
continue;
|
||||
if(Entity_Collide(_entity[i],_entity[j])){
|
||||
vec2_set(_entity[i]->vel,0,0);
|
||||
@@ -231,11 +241,11 @@ int GameLib_ProcLoop(){
|
||||
// Process Overlaps
|
||||
time=Time_GetTime();
|
||||
GameLib_Compactate();_entities_lock=1;
|
||||
for(i=0;i<_n_entities-1;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Overlap))
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if(!(_entity[i]->flags&EntityFlag_Overlap) || _entity[i]->mass<0.0f)
|
||||
continue;
|
||||
for(j=i+1;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Overlap))
|
||||
for(j=0;j<_n_entities;j++){
|
||||
if(!(_entity[j]->flags&EntityFlag_Overlap) || i==j)
|
||||
continue;
|
||||
Entity_Overlaps(_entity[i],_entity[j]);
|
||||
}
|
||||
@@ -280,6 +290,9 @@ int GameLib_ProcLoop(){
|
||||
for(i=0;i<_n_entities;i++){
|
||||
Entity *e;
|
||||
Entity_PostProcess(_entity[i],_ft);
|
||||
if(_entity[i]->flags&EntityFlag_UpdatedPos){
|
||||
GameLib_EntityUpdateLight(_entity[i]);
|
||||
}
|
||||
}
|
||||
if(_gamepostproc){
|
||||
_gamepostproc();
|
||||
@@ -287,7 +300,7 @@ int GameLib_ProcLoop(){
|
||||
GameLib_Compactate();
|
||||
t_postproc+=Time_GetTime()-time;
|
||||
|
||||
f_count++;
|
||||
fproc_count++;
|
||||
|
||||
return(_running);
|
||||
}
|
||||
@@ -303,6 +316,9 @@ void GameLib_DrawLoop(){
|
||||
|
||||
time=Time_GetTime();
|
||||
|
||||
// Update Lights
|
||||
//GameLib_UpdateIlumination();
|
||||
|
||||
// Limpiar pantalla
|
||||
Draw_Clean(0,0,0);
|
||||
|
||||
@@ -322,6 +338,12 @@ void GameLib_DrawLoop(){
|
||||
if(e->pos[1]>(_game_pos[1]+_game_size[1]+128))
|
||||
continue;
|
||||
|
||||
// Update ilumination of this entity
|
||||
if(e->flags&EntityFlag_UpdateLight){
|
||||
Entity_Iluminate(e,_entity,_n_entities);
|
||||
e->flags&=~EntityFlag_UpdateLight;
|
||||
}
|
||||
|
||||
Entity_Draw(e,-_game_pos[0],-_game_pos[1]);
|
||||
}
|
||||
if(_gamedraw){
|
||||
@@ -329,7 +351,10 @@ void GameLib_DrawLoop(){
|
||||
}
|
||||
GameLib_Compactate();
|
||||
|
||||
|
||||
t_draw+=Time_GetTime()-time;
|
||||
|
||||
fdraw_count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,15 +377,18 @@ void GameLib_Loop(
|
||||
t_over=0;
|
||||
t_postproc=0;
|
||||
t_draw=0;
|
||||
f_count=0;
|
||||
fproc_count=0;
|
||||
fdraw_count=0;
|
||||
Draw_Loop(GameLib_ProcLoop,GameLib_DrawLoop);
|
||||
|
||||
if (gamelib_debug) {
|
||||
printf("Profiling:::::::::\n");
|
||||
printf("t_proc.....:%6lld\n",t_proc/f_count);
|
||||
printf("t_col......:%6lld\n",t_col/f_count);
|
||||
printf("t_over.....:%6lld\n",t_over/f_count);
|
||||
printf("t_postproc.:%6lld\n",t_postproc/f_count);
|
||||
printf("t_draw.....:%6lld\n",t_draw/f_count);
|
||||
printf("t_proc.....:%6lld\n",t_proc/fproc_count);
|
||||
printf("t_col......:%6lld\n",t_col/fproc_count);
|
||||
printf("t_over.....:%6lld\n",t_over/fproc_count);
|
||||
printf("t_postproc.:%6lld\n",t_postproc/fproc_count);
|
||||
printf("t_draw.....:%6lld\n",t_draw/fdraw_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -464,3 +492,76 @@ void GameLib_PlaySound(AudioSnd snd,int x,int y){
|
||||
// PLAY!
|
||||
Audio_PlaySound(snd,vleft,vright);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_Iluminate
|
||||
//
|
||||
//
|
||||
void GameLib_Iluminate(){
|
||||
int i;
|
||||
|
||||
for(i=0;i<_n_entities;i++){
|
||||
Entity_Iluminate(_entity[i],_entity,_n_entities);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_EntitySetLight
|
||||
//
|
||||
//
|
||||
void GameLib_EntitySetLight(Entity *e,float r,float g,float b,float rad){
|
||||
if(e->flags&EntityFlag_Light){
|
||||
GameLib_EntityUpdateLight(e);
|
||||
Entity_SetLight(e,r,g,b,rad);
|
||||
GameLib_EntityUpdateLight(e);
|
||||
}else{
|
||||
Entity_SetLight(e,r,g,b,rad);
|
||||
e->flags|=EntityFlag_UpdateLight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_EntityUpdateLight
|
||||
//
|
||||
//
|
||||
void GameLib_EntityUpdateLight(Entity *e){
|
||||
if(e->flags&EntityFlag_Light){
|
||||
int i;
|
||||
vec2 max,min;
|
||||
|
||||
vec2_set(max,e->pos[0]+e->light[3],e->pos[1]+e->light[3]);
|
||||
vec2_set(min,e->pos[0]-e->light[3],e->pos[1]-e->light[3]);
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if( min[0]<=_entity[i]->pos[0] &&
|
||||
max[0]>=_entity[i]->pos[0] &&
|
||||
min[1]<=_entity[i]->pos[1] &&
|
||||
max[1]>=_entity[i]->pos[1])
|
||||
{
|
||||
_entity[i]->flags|=EntityFlag_UpdateLight;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
e->flags|=EntityFlag_UpdateLight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_UpdateIlumination
|
||||
//
|
||||
//
|
||||
void GameLib_UpdateIlumination(){
|
||||
int i;
|
||||
|
||||
for(i=0;i<_n_entities;i++){
|
||||
if(_entity[i]->flags&EntityFlag_UpdateLight){
|
||||
Entity_Iluminate(_entity[i],_entity,_n_entities);
|
||||
_entity[i]->flags&=~EntityFlag_UpdateLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
28
GameLib.h
28
GameLib.h
@@ -89,4 +89,32 @@ void GameLib_ForEachEnt(int (*func)(Entity *ent));
|
||||
void GameLib_PlaySound(AudioSnd snd,int x,int y);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_Iluminate
|
||||
//
|
||||
//
|
||||
void GameLib_Iluminate();
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_EntitySetLight
|
||||
//
|
||||
//
|
||||
void GameLib_EntitySetLight(Entity *e,float r,float g,float b,float rad);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_EntityUpdateLight
|
||||
//
|
||||
//
|
||||
void GameLib_EntityUpdateLight(Entity *e);
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// GameLib_UpdateIlumination
|
||||
//
|
||||
//
|
||||
void GameLib_UpdateIlumination();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -222,6 +222,8 @@ int GameMap_CreateLevel(int level,int point){
|
||||
_startpoint=point;
|
||||
GameLib_ForEachEnt(GameMapAux_CreatePlayer);
|
||||
|
||||
// Iluminate
|
||||
//GameLib_Iluminate();
|
||||
|
||||
return(1);
|
||||
}
|
||||
44
Input.c
44
Input.c
@@ -25,7 +25,7 @@ int Input_Init(){
|
||||
for(i=0;i<InputKey_Max;i++){
|
||||
_keys[i]=InputKey_Released;
|
||||
}
|
||||
|
||||
/*
|
||||
// Check for joystick
|
||||
if(SDL_NumJoysticks()>0){
|
||||
// Open joystick
|
||||
@@ -44,7 +44,7 @@ int Input_Init(){
|
||||
if(SDL_JoystickOpened(0))
|
||||
SDL_JoystickClose(_joy);
|
||||
}
|
||||
|
||||
*/
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -55,15 +55,45 @@ int Input_Init(){
|
||||
// Notify a frame update to the input subsystem.
|
||||
void Input_Frame(){
|
||||
Uint8* keys;
|
||||
Uint8 buttons;
|
||||
int mx,my;
|
||||
vec2 mdir;
|
||||
float temp;
|
||||
int mup,mdown,mleft,mright;
|
||||
extern int _width,_height;
|
||||
|
||||
|
||||
// Get mouse state
|
||||
buttons=SDL_GetMouseState(&mx,&my);
|
||||
vec2_set(mdir,mx-(_width/2),my-(_height/2.0f));
|
||||
temp=1.0f/sqrtf(vec2_dot(mdir,mdir));
|
||||
vec2_scale(mdir,mdir,temp);
|
||||
mup=mdown=mleft=mright=0;
|
||||
|
||||
// Virtual Dpad on screen using mouse position
|
||||
if(buttons){
|
||||
if(mdir[0]>0.5f){
|
||||
mright=1;
|
||||
}
|
||||
if(mdir[0]<-0.5f){
|
||||
mleft=1;
|
||||
}
|
||||
if(mdir[1]>0.5f){
|
||||
mdown=1;
|
||||
}
|
||||
if(mdir[1]<-0.5f){
|
||||
mup=1;
|
||||
}
|
||||
}
|
||||
|
||||
// Process Keys
|
||||
keys=SDL_GetKeyState(NULL);
|
||||
Input_SetKey(InputKey_Action1,keys[SDLK_z]);
|
||||
Input_SetKey(InputKey_Action1,keys[SDLK_z]|buttons);
|
||||
Input_SetKey(InputKey_Action2,keys[SDLK_x]);
|
||||
Input_SetKey(InputKey_Up,keys[SDLK_UP]);
|
||||
Input_SetKey(InputKey_Down,keys[SDLK_DOWN]);
|
||||
Input_SetKey(InputKey_Left,keys[SDLK_LEFT]);
|
||||
Input_SetKey(InputKey_Right,keys[SDLK_RIGHT]);
|
||||
Input_SetKey(InputKey_Up,keys[SDLK_UP]|mup);
|
||||
Input_SetKey(InputKey_Down,keys[SDLK_DOWN]|mdown);
|
||||
Input_SetKey(InputKey_Left,keys[SDLK_LEFT]|mleft);
|
||||
Input_SetKey(InputKey_Right,keys[SDLK_RIGHT]|mright);
|
||||
Input_SetKey(InputKey_Jump,keys[SDLK_SPACE]);
|
||||
Input_SetKey(InputKey_Continue,keys[SDLK_RETURN]|keys[SDLK_KP_ENTER]);
|
||||
|
||||
|
||||
3
Makefile
3
Makefile
@@ -14,15 +14,12 @@ endif # windir
|
||||
|
||||
|
||||
ifeq ($(TARGET_ARCH),mingw)
|
||||
OPENGL_DRAW=opengl
|
||||
include Makefile.win32
|
||||
else
|
||||
ifeq ($(TARGET_ARCH),linux)
|
||||
OPENGL_DRAW=opengl
|
||||
include Makefile.linux
|
||||
else
|
||||
ifeq ($(TARGET_ARCH),macosx)
|
||||
OPENGL_DRAW=opengl
|
||||
include Makefile.macosx
|
||||
endif # macosx
|
||||
endif # linux
|
||||
|
||||
11
Makefile.common
Normal file → Executable file
11
Makefile.common
Normal file → Executable file
@@ -37,13 +37,8 @@ $(BUILDDIR)/Time.o: Time.c $(HEADS)
|
||||
$(BUILDDIR)/Util.o: Util.c $(HEADS)
|
||||
$(CC) -c Util.c -o $(BUILDDIR)/Util.o $(CFLAGS)
|
||||
|
||||
ifeq ($(OPENGL_DRAW),opengl)
|
||||
$(BUILDDIR)/Draw.o: DrawGL.c $(HEADS)
|
||||
$(CC) -c DrawGL.c -o $(BUILDDIR)/Draw.o $(CFLAGS)
|
||||
else
|
||||
$(BUILDDIR)/Draw.o: DrawSDL.c $(HEADS)
|
||||
$(CC) -c DrawSDL.c -o $(BUILDDIR)/Draw.o $(CFLAGS)
|
||||
endif
|
||||
$(BUILDDIR)/Draw.o: Draw.c $(HEADS)
|
||||
$(CC) -c Draw.c -o $(BUILDDIR)/Draw.o $(CFLAGS)
|
||||
|
||||
$(BUILDDIR)/Input.o: Input.c $(HEADS)
|
||||
$(CC) -c Input.c -o $(BUILDDIR)/Input.o $(CFLAGS)
|
||||
@@ -77,6 +72,6 @@ clean:
|
||||
rm -f $(OBJS) $(BUILDDIR)/$(RESULT)
|
||||
|
||||
run: $(BUILDDIR)/$(RESULT)
|
||||
./$(BUILDDIR)/$(RESULT)
|
||||
./$(BUILDDIR)/$(RESULT) debug
|
||||
|
||||
|
||||
|
||||
68
data/level_03 - copia.txt
Normal file
68
data/level_03 - copia.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
100 100
|
||||
|
||||
##############
|
||||
#SSSS#.1.#SSS#
|
||||
#SSSS#...#SSS#
|
||||
#SSSS#...#SSS#
|
||||
#SSSS#B#.#SSS#
|
||||
#S..SSB..#SSS#
|
||||
#S.SSmmmmmSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.....BSSB.S#
|
||||
#SSSSS.SSSSSS#
|
||||
#mmmmm.mmmmmm#
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
######.#######
|
||||
#SSSS#2..SSSS#
|
||||
#SSSS#B#.SSSS#
|
||||
#S..SSB..SSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.....BSSB.S#
|
||||
#SSSSS.SSSSSS#
|
||||
#mmmmm.mmmmmm#
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
######.######
|
||||
#.....3.....#
|
||||
#.B.B...B.B.#
|
||||
#...........#
|
||||
#LLLSSSSSLLL#
|
||||
#...A...A...#
|
||||
#mmmmm.mmmmm#
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
######.######
|
||||
#.....4.....#
|
||||
#.B.B...B.B.#
|
||||
#...........#
|
||||
#LLLLLSLLLLL#
|
||||
#...A...A...#
|
||||
#mmmmm.mmmmm#
|
||||
m.m
|
||||
m.m ###########
|
||||
m.m #LLLLLLLL.#
|
||||
m.m #...L...L.#
|
||||
m.m #.L.L.L.L<#
|
||||
m.m #.L.L.L.L.#
|
||||
m.####.L.L.L.L<######
|
||||
m....5.L.L.L.L.......
|
||||
mmmmmm>L.L.L.L.mmmmmm
|
||||
m.L.L.L.L.m
|
||||
m>L.L.L.L.m
|
||||
m.L...L...m
|
||||
m.LLLLLLLL#
|
||||
mmmmmmmmmm#
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
100 100
|
||||
|
||||
##############
|
||||
#SSSSm.1.mSSS#
|
||||
#SSSSm...mSSS#
|
||||
#SSSSm...mSSS#
|
||||
#SSSSmBm.mSSS#
|
||||
#S..SSB..mSSS#
|
||||
#SSSS#.1.#SSS#
|
||||
#SSSS#...#SSS#
|
||||
#SSSS#...#SSS#
|
||||
#SSSS#B#.#SSS#
|
||||
#S..SSB..#SSS#
|
||||
#S.SSmmmmmSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.....BSSB.S#
|
||||
@@ -17,8 +17,8 @@
|
||||
m.m
|
||||
m.m
|
||||
######.#######
|
||||
#SSSSm2..SSSS#
|
||||
#SSSSmBm.SSSS#
|
||||
#SSSS#2..SSSS#
|
||||
#SSSS#B#.SSSS#
|
||||
#S..SSB..SSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
#S.SSSSSSSSSS#
|
||||
@@ -50,18 +50,52 @@
|
||||
#...........#
|
||||
#LLLLLSLLLLL#
|
||||
#...A...A...#
|
||||
#mmmmmmmmmmm#
|
||||
#mmmmm.mmmmm#
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
######5######
|
||||
#..V.V.....L#
|
||||
#LLLLLLLLL.L#
|
||||
#L.........L#
|
||||
#L.LLLLLLLLL#
|
||||
#L.........L#
|
||||
#LLLLLLLLL.L#
|
||||
#L.........L#
|
||||
#L.LLLLLLLLL#
|
||||
#L.....A.A..#
|
||||
#mmmmm.mmmmm#
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
###V#V6######
|
||||
#LLLLL.LLLLL#
|
||||
#LLLLL.....L#
|
||||
>LLLLLLLLL.L#
|
||||
mL.........L#
|
||||
mL.LLLLLLLLL<
|
||||
mL.........Lm
|
||||
>LLLLLLLLL.Lm
|
||||
mL.........Lm
|
||||
mL.LLLLLLLLL<
|
||||
mL.....LLLLLm
|
||||
mLLLLL.LLLLLm
|
||||
mmmmmm.AmAmmm
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
m.m
|
||||
####.####
|
||||
#.......#
|
||||
#.......#
|
||||
#.......#
|
||||
#...E...#
|
||||
#mmmmmmm#
|
||||
|
||||
|
||||
|
||||
############
|
||||
#mmm.mmm# #....L.....#
|
||||
m.m #..L.L.S..<#
|
||||
m.m #..L.L.S...#
|
||||
m.#######..L.L.S..<#
|
||||
m........2.L.L.S...#
|
||||
mmmmmmmmmmmL.L.S...#
|
||||
m.>L.L.S...#
|
||||
m....L.S...#
|
||||
m.>..L.S...########
|
||||
m.B....S..........#
|
||||
mmmmmmmmmmmmmmmmm
|
||||
37
data/level_04.txt
Normal file
37
data/level_04.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
100 100
|
||||
|
||||
1
|
||||
#######7#######
|
||||
#SSSSSS.SSSSSS#
|
||||
#S....S.S....S#
|
||||
#S.LLBS.S.LL.S#
|
||||
#S...........S#
|
||||
#SSSS.SSSSSSSS#####
|
||||
#SSSS.SSS.........8
|
||||
#SSSSSSSSSSSSSmmmmm
|
||||
#S..B...S....Sm
|
||||
#S.LL.SSSBLL.Sm
|
||||
#S....SSS....Sm
|
||||
#SSSSSSSSSSSSSm
|
||||
mmmmmmmmmmmmmmm
|
||||
|
||||
|
||||
|
||||
|
||||
m.m
|
||||
m.m #####################
|
||||
m.m #S....SSS.....S...BB#
|
||||
m.m #S.SSBSSS.SSS.SSS....
|
||||
m.m #S............SSSS..m
|
||||
m.m #SSSL.LLL.LLL.LSSSS.m
|
||||
m.####SSSL.LLL.LLL..LLSS.m
|
||||
m....8......L.B.......LS.m
|
||||
mmmmmmSSSS.LLL.LLL..LLSS.m
|
||||
mSSSSSLLL.LLL.LSSSS.m
|
||||
m.SSS....S...LSS....m
|
||||
m..LLLLLL.LLLLLL.SS.m
|
||||
mB...............SS.m
|
||||
mmmmmmmmmmmmmmmmmmmmm
|
||||
|
||||
|
||||
|
||||
95
main.c
95
main.c
@@ -6,6 +6,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "GameLib.h"
|
||||
extern int gamelib_debug;
|
||||
|
||||
#include "GameEnts.h"
|
||||
#include "GameMap.h"
|
||||
@@ -21,7 +22,6 @@ DrawImg img_logo;
|
||||
DrawImg img_end;
|
||||
|
||||
DrawFnt font;
|
||||
DrawFnt font_shad;
|
||||
|
||||
int ProcTitle(){
|
||||
if( Input_GetKey(InputKey_Jump)==InputKey_Pressed||
|
||||
@@ -30,20 +30,30 @@ int ProcTitle(){
|
||||
play=1;
|
||||
return(0);
|
||||
}
|
||||
if( (Input_GetKey(InputKey_Action1)==InputKey_Pressed||
|
||||
Input_GetKey(InputKey_Action2)==InputKey_Pressed) &&
|
||||
game_started)
|
||||
{
|
||||
play=1;
|
||||
game_started=0;
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void DrawTitle(){
|
||||
Draw_Clean(0,0,0);
|
||||
Draw_SetColor(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
Draw_DrawImg(img_logo,170,100);
|
||||
if(!game_started){
|
||||
Draw_DrawText(font ,"Press [Space] to Start.",300,300);
|
||||
Draw_DrawText(font,"Press [Space] to Start.",300,300);
|
||||
}else{
|
||||
Draw_DrawText(font ,"Press [Space] to Continue.",300,300);
|
||||
Draw_DrawText(font,"Press [Space] to Continue.",300,300);
|
||||
Draw_DrawText(font,"Press [X] to Start.",300,316);
|
||||
}
|
||||
|
||||
Draw_DrawText(font ,"By Kableado (VAR)",200,440);
|
||||
Draw_DrawText(font,"By Kableado (VAR)",200,440);
|
||||
|
||||
}
|
||||
|
||||
@@ -60,13 +70,13 @@ int ProcEnd(){
|
||||
|
||||
void DrawEnd(){
|
||||
Draw_Clean(0,0,0);
|
||||
Draw_SetColor(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
Draw_DrawImg(img_end,170,100);
|
||||
|
||||
Draw_DrawText(font ,"Congratulations you saved the kittie!",250,320);
|
||||
Draw_DrawText(font ,"Thanks for playing!",250,350);
|
||||
|
||||
Draw_DrawText(font ,"Press [Space] to Title.",300,400);
|
||||
Draw_DrawText(font,"Congratulations you saved the kittie!",250,320);
|
||||
Draw_DrawText(font,"Thanks for playing!",250,350);
|
||||
Draw_DrawText(font,"Press [Space] to Title.",300,400);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,23 +104,61 @@ void PostProcGame(){
|
||||
void DrawGame(){
|
||||
char string[1024];
|
||||
|
||||
Draw_SetColor(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
sprintf(string, "Level: %d.%d",game_level+1,game_level_point);
|
||||
Draw_DrawText(font_shad,string,17,17);
|
||||
Draw_DrawText(font ,string,16,16);
|
||||
Draw_SetColor(0,0,0,0.5f);
|
||||
Draw_DrawText(font,string,17,17);
|
||||
Draw_SetColor(1,1,1,1);
|
||||
Draw_DrawText(font,string,16,16);
|
||||
|
||||
if(game_level_reset==2){
|
||||
Draw_DrawText(font_shad,"Level Complete",301,301);
|
||||
Draw_DrawText(font ,"Level Complete.",300,300);
|
||||
Draw_SetColor(0,0,0,0.5f);
|
||||
Draw_DrawText(font,"Level Complete",301,301);
|
||||
Draw_SetColor(1,1,0,1);
|
||||
Draw_DrawText(font,"Level Complete.",300,300);
|
||||
}else
|
||||
if(game_level_reset==1){
|
||||
Draw_DrawText(font_shad,"You are dead.",301,301);
|
||||
Draw_DrawText(font ,"You are dead.",300,300);
|
||||
Draw_SetColor(0,0,0,0.5f);
|
||||
Draw_DrawText(font,"You are dead.",301,301);
|
||||
Draw_SetColor(1,0,0,1);
|
||||
Draw_DrawText(font,"You are dead.",300,300);
|
||||
}else
|
||||
if(game_level_reset==3){
|
||||
play=2;
|
||||
GameLib_BreakLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadGame(char *fname){
|
||||
FILE *f;
|
||||
|
||||
f=fopen(fname,"rb");
|
||||
if(!f)
|
||||
return;
|
||||
|
||||
fread(&game_level,1,sizeof(int),f);
|
||||
fread(&game_level_point,1,sizeof(int),f);
|
||||
|
||||
GameMap_CreateLevel(game_level,game_level_point);
|
||||
game_started=1;
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void SaveGame(char *fname){
|
||||
FILE *f;
|
||||
|
||||
f=fopen(fname,"wb");
|
||||
if(!f)
|
||||
return;
|
||||
|
||||
fwrite(&game_level,1,sizeof(int),f);
|
||||
fwrite(&game_level_point,1,sizeof(int),f);
|
||||
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,16 +166,23 @@ int main(int argc,char *argv[]){
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
if (argc>1) {
|
||||
if (!strcmp(argv[1],"debug")) {
|
||||
gamelib_debug=1;
|
||||
}
|
||||
}
|
||||
|
||||
GameLib_Init(640,480,"Game",60);
|
||||
|
||||
img_logo=Draw_LoadImage("data/logo.bmp");
|
||||
img_end=Draw_LoadImage("data/end.bmp");
|
||||
|
||||
font=Draw_DefaultFont(255,0,0,255);
|
||||
font_shad=Draw_DefaultFont(0,0,0,127);
|
||||
|
||||
font=Draw_DefaultFont(255,255,255,255);
|
||||
|
||||
GameEnts_Init();
|
||||
|
||||
LoadGame("game.save");
|
||||
|
||||
do{
|
||||
play=0;
|
||||
Draw_Loop(ProcTitle,DrawTitle);
|
||||
@@ -138,9 +193,10 @@ int main(int argc,char *argv[]){
|
||||
game_level=0;
|
||||
game_level_point=1;
|
||||
game_level_reset=0;
|
||||
|
||||
GameMap_CreateLevel(game_level,game_level_point);
|
||||
}
|
||||
game_started=1;
|
||||
}
|
||||
GameLib_Loop(ProcGame,PostProcGame,DrawGame);
|
||||
}
|
||||
if(play==2){
|
||||
@@ -148,5 +204,8 @@ int main(int argc,char *argv[]){
|
||||
}
|
||||
}while(play);
|
||||
|
||||
|
||||
SaveGame("game.save");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user