This commit is contained in:
2014-08-22 23:20:44 +02:00
committed by Valeriano A.R
parent 616602f91c
commit f12d831878
4 changed files with 13 additions and 19 deletions

View File

@@ -198,7 +198,6 @@ void Audio_Frame(){
// //
// Loads a sound, giving a reference. // Loads a sound, giving a reference.
AudioSnd Audio_LoadSound(char *filename){ AudioSnd Audio_LoadSound(char *filename){
int error = 0;
FILE *f; FILE *f;
char id[5] = { 0, 0, 0, 0, 0 }, *sndBuffer = NULL; char id[5] = { 0, 0, 0, 0, 0 }, *sndBuffer = NULL;
short formatTag, channels, bitsPerSample; short formatTag, channels, bitsPerSample;
@@ -289,7 +288,7 @@ AudioSnd Audio_LoadSound(char *filename){
wave->channels = channels; wave->channels = channels;
wave->buffer = (Uint8 *) sndBuffer; wave->buffer = (Uint8 *) sndBuffer;
wave->BPB = bitsPerSample; wave->BPB = bitsPerSample;
wave->bpb = wave->bpb * 8; wave->bpb = wave->BPB * 8;
wave->len = dataSize / (wave->BPB * wave->channels); wave->len = dataSize / (wave->BPB * wave->channels);
// Take a reference // Take a reference

View File

@@ -447,9 +447,6 @@ int _draw_exitoverrided=0;
long long _accTime; long long _accTime;
int Draw_LoopIteration(){ int Draw_LoopIteration(){
SDL_Event event; SDL_Event event;
Uint8* keys;
// Update screen
SDL_GL_SwapBuffers();
// Process Events // Process Events
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
@@ -496,6 +493,7 @@ int Draw_LoopIteration(){
#ifndef EMSCRIPTEN #ifndef EMSCRIPTEN
// Process keys for Draw // Process keys for Draw
Uint8* keys;
keys=(Uint8 *)SDL_GetKeyState(NULL); keys=(Uint8 *)SDL_GetKeyState(NULL);
if(keys[SDLK_F12]){ if(keys[SDLK_F12]){
// Screenshot key // Screenshot key
@@ -503,9 +501,6 @@ int Draw_LoopIteration(){
} }
#endif #endif
// Sound Frame
Audio_Frame();
// Process // Process
if(_proc_func){ if(_proc_func){
if(_accTime>100000){ if(_accTime>100000){
@@ -519,11 +514,13 @@ int Draw_LoopIteration(){
} }
} }
// Sound Frame
Audio_Frame();
// Draw // Draw
SDL_GL_SwapBuffers();
if(_draw_func){ if(_draw_func){
float frameFactor=0.0f; _draw_func(_data, (float)_accTime/(float)proc_t_frame);
frameFactor=(float)_accTime/(float)proc_t_frame;
_draw_func(_data,frameFactor);
Draw_Flush(); Draw_Flush();
} }
@@ -552,8 +549,6 @@ void Draw_Loop(
void (*draw)(void *data,float f), void (*draw)(void *data,float f),
void *data) void *data)
{ {
long long newTime;
long long procTime1,procTime2,drawTime1,drawTime2,waitTime;
_proc_func=proc; _proc_func=proc;
_draw_func=draw; _draw_func=draw;
@@ -561,14 +556,14 @@ void Draw_Loop(
if(_draw_looping){return;} if(_draw_looping){return;}
_draw_looping=1; _draw_looping=1;
#ifndef EMSCRIPTEN #ifndef EMSCRIPTEN
long long procTime1,procTime2,drawTime1,drawTime2;
_accTime=proc_t_frame; _accTime=proc_t_frame;
procTime1=drawTime1=Time_GetTime(); procTime1=drawTime1=Time_GetTime();
while(Draw_LoopIteration()){ while(Draw_LoopIteration()){
// Wait to round draw_t_frame // Wait to round draw_t_frame
drawTime2=Time_GetTime(); drawTime2=Time_GetTime();
waitTime=draw_t_frame-(drawTime2-drawTime1); Time_Pause(draw_t_frame-(drawTime2-drawTime1));
Time_Pause(waitTime);
drawTime2=Time_GetTime(); drawTime2=Time_GetTime();
drawTime1=drawTime2; drawTime1=drawTime2;
@@ -811,7 +806,6 @@ DrawImage Draw_DefaultFontImage(
{ {
DrawImage img; DrawImage img;
int x,y,c; int x,y,c;
Uint32 color,color2;
// Create the image and colors // Create the image and colors
img=Draw_CreateImage(8*256,8); img=Draw_CreateImage(8*256,8);
@@ -825,7 +819,7 @@ DrawImage Draw_DefaultFontImage(
img->data[offset+1]=g; img->data[offset+1]=g;
img->data[offset+2]=b; img->data[offset+2]=b;
if(((fontdata_8x8[c*8+y]>>(7-x)) & 0x01)==1){ if(((fontdata_8x8[c*8+y]>>(7-x)) & 0x01)==1){
img->data[offset+3]=0xFF; img->data[offset+3]=a;
}else{ }else{
img->data[offset+3]=0x00; img->data[offset+3]=0x00;
} }

View File

@@ -384,7 +384,7 @@ int CollisionInfo_CheckRepetition(CollisionInfo collInfo,Entity ent1,Entity ent2
// //
int Entity_CheckCollision(Entity ent1,Entity ent2,CollisionInfo *collInfoRef){ int Entity_CheckCollision(Entity ent1,Entity ent2,CollisionInfo *collInfoRef){
float t; float t;
vec2 n,p; vec2 n;
vec2 vel; vec2 vel;
int flags=ent1->flags|ent2->flags; int flags=ent1->flags|ent2->flags;

View File

@@ -33,7 +33,8 @@ long long Time_GetTime(){
void Time_Pause(int pausa){ void Time_Pause(int pausa){
long long tend,t,diff; long long tend,t,diff;
tend=Time_GetTime()+pausa; t=Time_GetTime();
tend=t+pausa;
do{ do{
diff=tend-t; diff=tend-t;
if(diff>1000){ if(diff>1000){