Separate example game to Example.GameLib.

This commit is contained in:
2020-04-20 03:11:23 +02:00
committed by Valeriano A.R
parent 08068a825b
commit 8349b60b34
51 changed files with 829 additions and 935 deletions

244
src/Anim.c Normal file
View File

@@ -0,0 +1,244 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#include <stdio.h>
#include <stdlib.h>
#include "Draw.h"
#include "Anim.h"
////////////////////////////////////////////////
// Animation //
///////////////
//
typedef struct {
DrawImg img;
int w;
float fps;
int frames;
int ftime;
int time;
} Animation;
/////////////////////////////
// Anim_LoadAnim
//
//
Anim Anim_LoadAnim(char *fichero, int width, int frames, float fps) {
DrawImg img;
Animation *anim;
int w, h;
img = Draw_LoadImage(fichero);
if (!img) {
return (NULL);
}
Draw_GetSize(img, &w, &h);
Draw_SetOffset(img, -(width / 2), -(h / 2));
// Create the animation container
anim = malloc(sizeof(Animation));
anim->img = img;
anim->w = width;
if (width <= 0) {
anim->w = w / frames;
}
anim->fps = fps;
anim->frames = frames;
anim->ftime = 1000 / fps;
anim->time = anim->ftime * frames;
return ((Anim)anim);
}
/////////////////////////////
// Anim_GetTime
//
//
int Anim_GetTime(Anim a) {
Animation *anim = a;
return (anim->time);
}
/////////////////////////////
// Anim_GetSize
//
// Gets the animation size.
void Anim_GetSize(Anim a, int *w, int *h) {
Animation *anim = a;
int waux;
*w = anim->w;
Draw_GetSize(anim->img, &waux, h);
}
/////////////////////////////
// Anim_SetOffset
// Anim_GetOffset
//
//
void Anim_SetOffset(Anim a, int x, int y) {
Animation *anim = a;
Draw_SetOffset(anim->img, x, y);
}
void Anim_GetOffset(Anim a, int *x, int *y) {
Animation *anim = a;
Draw_GetOffset(anim->img, x, y);
}
/////////////////////////////
// Anim_SetFlip
// Anim_GetFlip
//
//
void Anim_SetFlip(Anim a, int flip) {
Animation *anim = a;
Draw_SetFlip(anim->img, flip);
}
int Anim_GetFlip(Anim a) {
Animation *anim = a;
return Draw_GetFlip(anim->img);
}
/////////////////////////////
// Anim_Draw
//
//
void Anim_Draw(Anim a, int time_ms, int x, int y, float scale[2]) {
Animation *anim = a;
int frame;
frame = (time_ms / anim->ftime) % anim->frames;
Draw_DrawImgPartHoriz(anim->img, x, y, anim->w, frame, scale);
}
/////////////////////////////
// AnimPlay_Copy
//
//
void AnimPlay_Copy(AnimPlay *ad, AnimPlay *ao) {
ad->img = ao->img;
ad->imgPart = ao->imgPart;
ad->w = ao->w;
ad->h = ao->h;
ad->i = ao->i;
ad->j = ao->j;
ad->anim = ao->anim;
ad->time_ms = ao->time_ms;
}
/////////////////////////////
// AnimPlay_SetImg
// AnimPlay_SetAnim
// AnimPlay_SetImgPart
//
//
void AnimPlay_SetImg(AnimPlay *ap, DrawImg img) {
ap->anim = NULL;
ap->time_ms = 0;
ap->img = img;
ap->imgPart = NULL;
}
void AnimPlay_SetAnim(AnimPlay *ap, Anim ani) {
ap->pause = 0;
if (ap->anim == ani) {
return;
}
ap->anim = ani;
ap->time_ms = 0;
ap->img = NULL;
ap->imgPart = NULL;
}
void AnimPlay_SetImgPart(AnimPlay *ap, DrawImg img, int w, int h, int i,
int j) {
ap->anim = NULL;
ap->time_ms = 0;
ap->img = NULL;
ap->imgPart = img;
ap->w = w;
ap->h = h;
ap->i = i;
ap->j = j;
}
/////////////////////////////
// AnimPlay_Draw
//
//
void AnimPlay_Draw(AnimPlay *ani, int x, int y, float scale[2]) {
if (ani->anim) {
Anim_Draw(ani->anim, ani->time_ms, x, y, scale);
return;
}
if (ani->img) {
Draw_DrawImg(ani->img, x, y, scale);
return;
}
if (ani->imgPart) {
Draw_DrawImgPart(ani->imgPart, x, y, ani->w, ani->h, ani->i, ani->j, scale);
return;
}
}
/////////////////////////////
// AnimPlay_GetOffset
// AnimPlay_GetSize
//
//
void AnimPlay_GetOffset(AnimPlay *ani, int *x, int *y) {
if (ani->anim) {
Anim_GetOffset(ani->anim, x, y);
return;
}
if (ani->img) {
Draw_GetOffset(ani->img, x, y);
return;
}
if (ani->imgPart) {
Draw_GetOffset(ani->imgPart, x, y);
return;
}
}
void AnimPlay_GetSize(AnimPlay *ani, int *w, int *h) {
if (ani->anim) {
Anim_GetSize(ani->anim, w, h);
return;
} else if (ani->img) {
Draw_GetSize(ani->img, w, h);
return;
}
if (ani->imgPart) {
Draw_GetSize(ani->imgPart, w, h);
return;
}
}
/////////////////////////////
// AnimPlay_SetPause
//
//
void AnimPlay_SetPause(AnimPlay *ani, int p) { ani->pause = p; }
/////////////////////////////
// AnimPlay_IncTime
//
//
void AnimPlay_IncTime(AnimPlay *ani, int t) {
if (ani->anim){
if (!ani->pause) {
ani->time_ms += t;
}
}
}

112
src/Anim.h Normal file
View File

@@ -0,0 +1,112 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _ANIM_H_
#define _ANIM_H_
#include "Draw.h"
////////////////////////////////////////////////
// Anim //
//////////
//
typedef void *Anim;
/////////////////////////////
// Anim_LoadAnim
//
//
Anim Anim_LoadAnim(char *fichero, int width, int frames, float fps);
/////////////////////////////
// Anim_GetTime
//
//
int Anim_GetTime(Anim anim);
/////////////////////////////
// Anim_GetSize
//
// Gets the animation size.
void Anim_GetSize(Anim anim, int *w, int *h);
/////////////////////////////
// Anim_SetOffset
// Anim_GetOffset
//
//
void Anim_SetOffset(Anim anim, int x, int y);
void Anim_GetOffset(Anim anim, int *x, int *y);
/////////////////////////////
// Anim_SetFlip
// Draw_GetFlip
//
//
void Anim_SetFlip(Anim anim, int flip);
int Anim_GetFlip(Anim anim);
/////////////////////////////
// Anim_Draw
//
//
void Anim_Draw(Anim anim, int time_ms, int x, int y, float scale[2]);
////////////////////////////////////////////////
// AnimPlay //
//////////////
//
typedef struct {
Anim anim;
int pause;
int time_ms;
DrawImg img;
DrawImg imgPart;
int w, h, i, j;
} AnimPlay;
/////////////////////////////
// AnimPlay_Copy
//
//
void AnimPlay_Copy(AnimPlay *ad, AnimPlay *ao);
/////////////////////////////
// AnimPlay_SetImg
// AnimPlay_SetAnim
// AnimPlay_SetImgPart
//
//
void AnimPlay_SetImg(AnimPlay *ap, DrawImg img);
void AnimPlay_SetAnim(AnimPlay *ap, Anim ani);
void AnimPlay_SetImgPart(AnimPlay *ap, DrawImg img, int w, int h, int i, int j);
/////////////////////////////
// AnimPlay_Draw
//
//
void AnimPlay_Draw(AnimPlay *ani, int x, int y, float scale[2]);
/////////////////////////////
// AnimPlay_GetOffset
// AnimPlay_GetSize
//
//
void AnimPlay_GetOffset(AnimPlay *ani, int *x, int *y);
void AnimPlay_GetSize(AnimPlay *ani, int *w, int *h);
/////////////////////////////
// AnimPlay_SetPause
//
//
void AnimPlay_SetPause(AnimPlay *ani, int p);
/////////////////////////////
// AnimPlay_IncTime
//
//
void AnimPlay_IncTime(AnimPlay *ani, int t);
#endif

363
src/Audio.c Normal file
View File

@@ -0,0 +1,363 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifdef WIN32
#define _WIN32_WINNT 0x0501
#include <windows.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <SDL/SDL.h>
#include "Util.h"
#include "Audio.h"
static void Audio_MixerCallback(void *ud, Uint8 *stream, int l);
////////////////////////////////////////////////
// AudioWave //
///////////////
// Reference to a sound.
typedef struct TAudioWave TAudioWave, *AudioWave;
struct TAudioWave {
unsigned int sampleRate;
int channels;
int bpb;
int BPB;
Uint32 len;
Uint8 *buffer;
AudioWave next;
};
AudioWave _waves = NULL;
////////////////////////////////////////////////
// AudioChan //
///////////////
// Reference to a sound.
typedef struct TAudioChan TAudioChan, *AudioChan;
struct TAudioChan {
AudioWave wave;
Uint32 pos;
unsigned char rightvol;
unsigned char leftvol;
int loop;
AudioChan next;
};
AudioChan _channels = NULL;
AudioChan _free_channels = NULL;
/////////////////////////////
// Audio_Init
//
// Initializes the game audio.
int Audio_Init() {
SDL_AudioSpec as;
SDL_AudioSpec as2;
// Initialize audio subsistem
#ifdef WIN32
// Force DSound Driver on win32
putenv("SDL_AUDIODRIVER=dsound");
#endif
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
Print("Audio_Init: Failure initializing SDL Audio.\n");
Print("\tSDL Error: %s\n", SDL_GetError());
return (0);
}
// Open the audio device using the desired parameters
as.freq = 44100;
as.format = AUDIO_S16SYS;
as.channels = 2;
as.samples = 2048;
as.callback = Audio_MixerCallback;
if (SDL_OpenAudio(&as, &as2) < 0) {
Print("Audio_Init: Failure opening audio.\n");
Print("\tSDL Error: %s\n", SDL_GetError());
return (0);
}
// Asert results
if (as2.format != AUDIO_S16SYS || as2.freq != 44100 || as2.channels != 2) {
Print("Audio_Init: Failure opening audio. (44.1Khz/16b/2c).\n");
SDL_CloseAudio();
return (0);
}
// Unpause and ready to go
SDL_PauseAudio(0);
return (1);
}
/////////////////////////////
// Audio_MixerCallback
//
// 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;
int len = l / 4; // Asume 16bpb and 2 output chan
int chan_remain;
int len_mix;
int i;
// Clean
memset(stream, 0, l);
// Mix all the channels
prevchan = NULL;
chan = _channels;
while (chan) {
if (!chan->wave) {
// Remove finished channels
AudioChan aux_chan = chan->next;
chan->next = _free_channels;
_free_channels = chan;
chan = aux_chan;
if (prevchan) {
prevchan->next = chan;
} else {
_channels = chan;
}
continue;
}
// Prepare the pointers
ptr_out = (signed short *)stream;
ptr_wave = ((signed short *)chan->wave->buffer) + chan->pos;
wave = chan->wave;
// Determine mixing lenght
chan_remain = wave->len - chan->pos;
if (chan_remain > len) {
len_mix = len;
} else {
if (chan->loop) {
len_mix = len;
} else {
len_mix = chan_remain;
}
chan->wave = NULL;
}
// Mix the buffer
for (i = 0; i < len_mix; i++) {
int temp;
// Left Channel
temp = ptr_out[0];
temp += (ptr_wave[0] * chan->leftvol) >> 8;
if (temp > (1 << 14)) {
ptr_out[0] = 1 << 14;
} else if (temp < -(1 << 14)) {
ptr_out[0] = -(1 << 14);
} else {
ptr_out[0] = temp;
}
// Right Channel
temp = ptr_out[1];
temp += (ptr_wave[0] * chan->rightvol) >> 8;
if (temp > (1 << 14)) {
ptr_out[1] = 1 << 14;
} else if (temp < -(1 << 14)) {
ptr_out[1] = -(1 << 14);
} else {
ptr_out[1] = temp;
}
// Next sample
ptr_out += 2;
if (ptr_wave >=
(((signed short *)wave->buffer) + (wave->len - 1))) {
ptr_wave = ((signed short *)wave->buffer);
} else {
ptr_wave++;
}
}
chan->pos += len_mix;
if (chan->wave == NULL && chan->loop == 1) {
chan->wave = wave;
while (chan->pos > wave->len) {
chan->pos -= wave->len;
}
}
// Next channel
prevchan = chan;
chan = chan->next;
}
}
/////////////////////////////
// Audio_Frame
//
// Notify a frame update to the audio subsystem.
void Audio_Frame() {}
/////////////////////////////
// Audio_LoadSound
//
// Loads a sound, giving a reference.
AudioSnd Audio_LoadSound(char *filename) {
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) {
Print("Audio_LoadSound: Failure opening file.\n");
return (NULL);
}
// Read id "RIFF"
fread(id, 4, sizeof(char), f);
if (strcmp(id, "RIFF")) {
Print("Audio_LoadSound: File is not RIFF.\n");
fclose(f);
return (NULL);
}
// File size (-"RIFF")
fseek(f, 4, SEEK_CUR); // size
// Read id "WAVE"
fread(id, 4, sizeof(char), f);
if (strcmp(id, "WAVE")) {
Print("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) {
Print("Audio_LoadSound: File too short.\n");
fclose(f);
return (NULL);
}
fread(&formatTag, 1, sizeof(short), f); // 1=PCM
if (formatTag != 1) {
Print("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) {
Print("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")) {
Print("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 (wave);
}
/////////////////////////////
// Audio_PlaySound
//
// Loads a sound, giving a reference.
AudioChn Audio_PlaySound(AudioSnd snd, float leftvol, float rightvol,
int loop) {
AudioChan chan;
AudioWave wave;
if (!snd) {
return (NULL);
}
// Cast AudioSnd to AudioWave
wave = snd;
// Get a free channel
if (_free_channels) {
chan = _free_channels;
_free_channels = chan->next;
chan->next = NULL;
} else {
chan = malloc(sizeof(TAudioChan));
chan->next = NULL;
}
// Initialize the channel
chan->wave = wave;
chan->pos = 0;
chan->rightvol = (rightvol * 255);
chan->leftvol = (leftvol * 255);
chan->loop = loop;
// Include in sounds list
chan->next = _channels;
_channels = chan;
return chan;
}
/////////////////////////////
// Audio_StopChan
//
// Stops an audio chanel
void Audio_StopChan(AudioChn c) {
AudioChan chan;
chan = c;
if (c == NULL) {
return;
}
chan->loop = 0;
chan->wave = NULL;
}

48
src/Audio.h Normal file
View File

@@ -0,0 +1,48 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _AUDIO_H_
#define _AUDIO_H_
/////////////////////////////
// Audio_Init
//
// Initializes the game audio.
int Audio_Init();
/////////////////////////////
// Audio_Frame
//
// Notify a frame update to the audio subsystem.
void Audio_Frame();
////////////////////////////////////////////////
// AudioSnd //
//////////////
// Reference to a sound.
typedef void *AudioSnd;
////////////////////////////////////////////////
// AudioChn //
//////////////
// Reference to a playing sound.
typedef void *AudioChn;
/////////////////////////////
// Audio_LoadSound
//
// Loads a sound, giving a reference.
AudioSnd Audio_LoadSound(char *filename);
/////////////////////////////
// Audio_PlaySound
//
// Loads a sound, giving a reference.
AudioChn Audio_PlaySound(AudioSnd snd, float leftvol, float rightvol, int loop);
/////////////////////////////
// Audio_StopChan
//
// Stops an audio chanel
void Audio_StopChan(AudioChn chan);
#endif

1157
src/Draw.c Normal file

File diff suppressed because it is too large Load Diff

169
src/Draw.h Normal file
View File

@@ -0,0 +1,169 @@
// Copyright (C) 2011-2015 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _DRAW_H_
#define _DRAW_H_
/////////////////////////////
// Draw_Init
//
// Initializes the game window.
int Draw_Init(int width, int height, char *title, int pfps, int fps);
/////////////////////////////
// Draw_Clean
//
// Cleans the game window.
void Draw_Clean(unsigned char r, unsigned char g, unsigned char b);
/////////////////////////////
// Draw_Loop
//
// Loops updating the game window.
void Draw_Loop(void (*proc)(void *data), void (*draw)(void *data, float f),
void *data);
/////////////////////////////
// Draw_BreakLoop
//
// Breaks the drawing loop
void Draw_BreakLoop();
/////////////////////////////
// Draw_OverrideExit
//
// Overrides the default exit mechanism
void Draw_OverrideExit(int override);
/////////////////////////////
// Draw_Flush
//
// Performs all the queued draw actions.
void Draw_Flush();
////////////////////////////////////////////////
// DrawImg //
/////////////
// Reference to a image.
typedef void *DrawImg;
/////////////////////////////
// Draw_CreateImage
//
DrawImg Draw_CreateImage(int w, int h);
/////////////////////////////
// Draw_LoadImage
//
// Loads a image, giving a reference.
DrawImg Draw_LoadImage(char *filename);
/////////////////////////////
// Draw_GetSize
//
// Gets the image size.
void Draw_GetSize(DrawImg img, int *w, int *h);
/////////////////////////////
// Draw_SetOffset
// Draw_GetOffset
//
// Sets and Gets the image offset.
void Draw_SetOffset(DrawImg img, int x, int y);
void Draw_GetOffset(DrawImg img, int *x, int *y);
/////////////////////////////
// Draw_SetFlip
// Draw_GetFlip
//
//
void Draw_SetFlip(DrawImg img, int flip);
int Draw_GetFlip(DrawImg img);
/////////////////////////////
// Draw_DrawImg
//
// Draws an image.
void Draw_DrawImg(DrawImg img, int x, int y, float scale[2]);
/////////////////////////////
// Draw_DrawImgResized
//
// Draws an image, resizing.
void Draw_DrawImgResized(DrawImg img, int x, int y, float w, float h);
/////////////////////////////
// Draw_DrawImgPart
//
// Draws an image part.
void Draw_DrawImgPart(DrawImg img, int x, int y, int w, int h, int i, int j, float scale[2]);
/////////////////////////////
// Draw_DrawImgPartHoriz
//
// Draws an image part horizontally.
void Draw_DrawImgPartHoriz(DrawImg img, int x, int y, int w, int i, float scale[2]);
/////////////////////////////
// Draw_ImgParallax
//
//
void Draw_ImgParallax(DrawImg img, int imgSize[2], int imgOffset[2],
float parallaxFactor[2], int gamePos[2], int gameSize[2]);
/////////////////////////////
// Draw_SetColor
//
//
void Draw_SetColor(float r, float g, float b, float a);
////////////////////////////////////////////////
// DrawFnt //
/////////////
// Reference to a Font.
typedef void *DrawFnt;
/////////////////////////////
// Draw_DefaultFont
//
// Creates the default font.
DrawFnt Draw_DefaultFont(unsigned char r, unsigned char g, unsigned char b,
unsigned char a);
/////////////////////////////
// Draw_LoadFont
//
// Load a font from a file.
DrawFnt Draw_LoadFont(char *fichero, int min, int max);
/////////////////////////////
// Draw_FontScale
//
void Draw_FontScale(DrawFnt f, float scale[2]);
/////////////////////////////
// Draw_DrawText
//
// Draws text using a font
void Draw_DrawText(DrawFnt f, char *text, int x, int y);
/////////////////////////////
// Draw_SaveRGBAToBMP
//
//
void Draw_SaveRGBAToBMP(char *filename, unsigned char *data, int width,
int height);
/////////////////////////////
// Draw_SaveRGBAToPNG
//
//
void Draw_SaveRGBAToPNG(char *filename, unsigned char *data, int width,
int height);
/////////////////////////////
// Draw_SaveScreenshoot
//
//
void Draw_SaveScreenshoot(char *filename);
#endif

1056
src/Entity.c Normal file

File diff suppressed because it is too large Load Diff

281
src/Entity.h Normal file
View File

@@ -0,0 +1,281 @@
// Copyright (C) 2011-2014 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _ENTITY_H_
#define _ENTITY_H_
#include "Util.h"
#include "Draw.h"
#include "Anim.h"
////////////////////////////////////////////////
// Entity
//
#define EntityFlag_Collision 1
#define EntityFlag_Overlap 2
#define EntityFlag_Light 4
#define EntityFlag_BlockTop 0x00000100
#define EntityFlag_BlockRight 0x00000200
#define EntityFlag_BlockBottom 0x00000400
#define EntityFlag_BlockLeft 0x00000800
#define EntityFlag_Block 0x0000FF00
#define EntityFlag_PlatformCollision 0x00000101
#define EntityFlag_BlockCollision 0x0000FF01
typedef struct TEntity TEntity, *Entity;
struct TEntity {
Entity base;
int type;
vec2 oldpos;
vec2 pos0;
vec2 pos;
int flags;
int internalFlags;
int zorder;
float sortYOffset;
vec2 dir;
vec2 vel;
vec2 bod_offset;
float radius;
float width;
float height;
float mass;
float elast;
float backFric_static;
float backFric_dynamic;
float fric_static;
float fric_dynamic;
AnimPlay anim;
float color0[4];
float color[4];
float light[4];
float defaultColor[4];
float scale0[2];
float scale[2];
void (*oncopy)(Entity ent);
void (*oninit)(Entity ent);
void (*ondelete)(Entity ent);
void (*proc)(Entity ent, int ft);
void (*postproc)(Entity ent, int ft);
int (*collision)(Entity ent, Entity ent2, float t, vec2 n);
void (*overlap)(Entity ent, Entity ent2);
int A;
int B;
int C;
int D;
Entity child;
float maxX, minX;
float maxY, minY;
Entity next;
};
/////////////////////////////
// Entity_New
//
Entity Entity_New();
/////////////////////////////
// Entity_Init
//
Entity Entity_Init(Entity e);
/////////////////////////////
// Entity_Destroy
//
void Entity_Destroy(Entity e);
/////////////////////////////
// Entity_Copy
//
Entity Entity_Copy(Entity e);
/////////////////////////////
// Entity_CalcBBox
//
//
void Entity_CalcBBox(Entity e);
/////////////////////////////
// Entity_BBoxIntersect
//
//
int Entity_BBoxIntersect(Entity ent1, Entity ent2);
/////////////////////////////
// Entity_Draw
//
void Entity_Draw(Entity e, int x, int y, float f);
/////////////////////////////
// Entity_IsVisible
//
int Entity_IsVisible(Entity e, int x, int y, int w, int h);
/////////////////////////////
// Entity_Process
//
void Entity_Process(Entity e, int ft);
/////////////////////////////
// Entity_PostProcess
//
void Entity_PostProcess(Entity e, int ft);
////////////////////////////////////////////////
// CollisionInfo
//
#define CollisionResponse_Circle 1
#define CollisionResponse_Line 2
typedef struct TCollisionInfo TCollisionInfo, *CollisionInfo;
struct TCollisionInfo {
int responseType;
Entity ent1;
Entity ent2;
float t;
vec2 n;
int applyFriction;
CollisionInfo next;
};
/////////////////////////////
// CollisionInfo_New
//
//
CollisionInfo CollisionInfo_New(int responseType, Entity ent1, Entity ent2,
float t, vec2 n, int applyFriction);
/////////////////////////////
// CollisionInfo_Destroy
//
//
void CollisionInfo_Destroy(CollisionInfo *collInfoRef);
/////////////////////////////
// CollisionInfo_Add
//
//
void CollisionInfo_Add(CollisionInfo *collInfo, int responseType, Entity ent1,
Entity ent2, float t, vec2 n, int applyFriction);
/////////////////////////////
// CollisionInfo_CheckRepetition
//
//
int CollisionInfo_CheckRepetition(CollisionInfo collInfo, Entity ent1,
Entity ent2);
/////////////////////////////
// Entity_CheckCollision
//
//
int Entity_CheckCollision(Entity ent1, Entity ent2, CollisionInfo *collInfoRef);
/////////////////////////////
// Entity_CollisionResponseClircle
//
// Normal response to a collision of spheres.
void Entity_CollisionResponseCircle(Entity b1, Entity b2, float t, vec2 n);
/////////////////////////////
// Entity_CollisionResponseLine
//
// Normal response to a collision with a line.
void Entity_CollisionResponseLine(Entity ent, Entity ent2, float t, vec2 n,
int applyFriction);
/////////////////////////////
// Entity_CollisionInfoResponse
//
//
int Entity_CollisionInfoResponse(CollisionInfo collInfo);
/////////////////////////////
// Entity_Overlaps
//
void Entity_Overlaps(Entity b1, Entity b2);
/////////////////////////////
// Entity_GetPos
// Entity_SetPos
// Entity_AddPos
// Entity_UpdatePos
//
void Entity_GetPos(Entity e, vec2 pos);
void Entity_SetPos(Entity e, vec2 pos);
void Entity_AddPos(Entity e, vec2 pos);
void Entity_UpdatePos(Entity e, vec2 pos);
/////////////////////////////
// Entity_AddVel
// Entity_SetVel
// Entity_SetVelH
// Entity_SetVelV
// Entity_AddVelLimit
// Entity_AddVelLimitH
// Entity_AddVelLimitH
//
void Entity_AddVel(Entity e, vec2 vel);
void Entity_SetVel(Entity e, vec2 vel);
void Entity_SetVelH(Entity e, float v);
void Entity_SetVelV(Entity e, float v);
void Entity_AddVelLimit(Entity e, vec2 vel, float limit);
void Entity_AddVelLimitH(Entity e, float v, float limit);
void Entity_AddVelLimitV(Entity e, float v, float limit);
/////////////////////////////
// Entity_SetColor
// Entity_AddColor
// Entity_MultColor
// Entity_AddColor
// Entity_SetDefaultColor
//
void Entity_SetColor(Entity e, float r, float g, float b, float a);
void Entity_AddColor(Entity e, float r, float g, float b, float a);
void Entity_MultColor(Entity e, float r, float g, float b, float a);
void Entity_SetLight(Entity e, float r, float g, float b, float rad);
void Entity_SetDefaultColor(Entity e, float r, float g, float b, float a);
/////////////////////////////
// Entity_SetScale
// Entity_GetScale
//
void Entity_SetScale(Entity e, float scale[2]);
void Entity_GetScale(Entity e, float scale[2]);
/////////////////////////////
// Entity_Iluminate
//
void Entity_Iluminate(Entity e, Entity *elist, int n);
/////////////////////////////
// Entity_MarkUpdateLight
//
void Entity_MarkUpdateLight(Entity e, Entity *elist, int n);
/////////////////////////////
// Entity_IsLight
//
int Entity_IsLight(Entity e);
/////////////////////////////
// Entity_IsUpdateLight
//
int Entity_IsUpdateLight(Entity e);
/////////////////////////////
// Entity_IsMoving
//
int Entity_IsMoving(Entity e);
#endif

260
src/FontData.h Normal file
View File

@@ -0,0 +1,260 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
static unsigned char fontdata_8x8[2048] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xfe,0xfe,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x38,0x7c,0xfe,0x00,0x00,
0x00,0x00,0xfe,0x7c,0x38,0x10,0x00,0x00,
0x20,0x30,0x38,0x3c,0x38,0x30,0x20,0x00,
0x04,0x0c,0x1c,0x3c,0x1c,0x0c,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x00,
0x6c,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,
0x6c,0x6c,0xfe,0x6c,0xfe,0x6c,0x6c,0x00,
0x18,0x3e,0x60,0x3c,0x06,0x7c,0x18,0x00,
0x00,0xc6,0xcc,0x18,0x30,0x66,0xc6,0x00,
0x38,0x6c,0x38,0x76,0xdc,0xcc,0x76,0x00,
0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,
0x0c,0x18,0x30,0x30,0x30,0x18,0x0c,0x00,
0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x00,
0x00,0x6c,0x38,0xfe,0x38,0x6c,0x00,0x00,
0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x30,0x00,
0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
0x06,0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,
0x3c,0x66,0x6e,0x76,0x66,0x3c,0x00,0x00,
0x18,0x38,0x78,0x18,0x18,0x18,0x00,0x00,
0x3c,0x66,0x06,0x1c,0x30,0x7e,0x00,0x00,
0x3c,0x66,0x0c,0x06,0x66,0x3c,0x00,0x00,
0x1c,0x3c,0x6c,0xcc,0xfe,0x0c,0x00,0x00,
0x7e,0x60,0x7c,0x06,0x66,0x3c,0x00,0x00,
0x1c,0x30,0x60,0x7c,0x66,0x3c,0x00,0x00,
0x7e,0x06,0x06,0x0c,0x18,0x18,0x00,0x00,
0x3c,0x66,0x3c,0x66,0x66,0x3c,0x00,0x00,
0x3c,0x66,0x3e,0x06,0x0c,0x38,0x00,0x00,
0x00,0x18,0x18,0x00,0x18,0x18,0x00,0x00,
0x00,0x18,0x18,0x00,0x18,0x18,0x30,0x00,
0x00,0x06,0x18,0x60,0x18,0x06,0x00,0x00,
0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,
0x00,0x60,0x18,0x06,0x18,0x60,0x00,0x00,
0x3c,0x66,0x06,0x0c,0x18,0x00,0x18,0x00,
0x3c,0x66,0x5a,0x5a,0x5e,0x60,0x3c,0x00,
0x3c,0x66,0x66,0x7e,0x66,0x66,0x00,0x00,
0x7c,0x66,0x7c,0x66,0x66,0x7c,0x00,0x00,
0x3c,0x60,0x60,0x60,0x60,0x3c,0x00,0x00,
0x78,0x6c,0x66,0x66,0x6c,0x78,0x00,0x00,
0x7e,0x60,0x78,0x60,0x60,0x7e,0x00,0x00,
0x7e,0x60,0x78,0x60,0x60,0x60,0x00,0x00,
0x3c,0x66,0x60,0x6e,0x66,0x3e,0x00,0x00,
0x66,0x66,0x7e,0x66,0x66,0x66,0x00,0x00,
0x3c,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,
0x06,0x06,0x06,0x06,0x66,0x3c,0x00,0x00,
0xc6,0xcc,0xd8,0xf8,0xcc,0xc6,0x00,0x00,
0x60,0x60,0x60,0x60,0x60,0x7c,0x00,0x00,
0xc6,0xee,0xfe,0xd6,0xc6,0xc6,0x00,0x00,
0xc6,0xe6,0xf6,0xde,0xce,0xc6,0x00,0x00,
0x3c,0x66,0x66,0x66,0x66,0x3c,0x00,0x00,
0xfc,0xc6,0xc6,0xfc,0xc0,0xc0,0x00,0x00,
0x78,0xcc,0xcc,0xcc,0xdc,0x7e,0x00,0x00,
0x7c,0x66,0x66,0x7c,0x6c,0x66,0x00,0x00,
0x7c,0xc6,0x70,0x1c,0xc6,0x7c,0x00,0x00,
0x7e,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
0x66,0x66,0x66,0x66,0x66,0x3c,0x00,0x00,
0x66,0x66,0x66,0x66,0x3c,0x18,0x00,0x00,
0xc6,0xc6,0xd6,0xfe,0xee,0xc6,0x00,0x00,
0xc6,0x6c,0x38,0x38,0x6c,0xc6,0x00,0x00,
0xc6,0x6c,0x38,0x30,0x30,0x30,0x00,0x00,
0xfe,0x0c,0x18,0x30,0x60,0xfe,0x00,0x00,
0x3c,0x30,0x30,0x30,0x30,0x30,0x3c,0x00,
0xc0,0x60,0x30,0x18,0x0c,0x06,0x02,0x00,
0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00,
0x18,0x3c,0x66,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,
0x18,0x18,0x0c,0x00,0x00,0x00,0x00,0x00,
0x00,0x3c,0x06,0x3e,0x66,0x3e,0x00,0x00,
0x60,0x60,0x7c,0x66,0x66,0x7c,0x00,0x00,
0x00,0x3c,0x60,0x60,0x60,0x3c,0x00,0x00,
0x06,0x06,0x3e,0x66,0x66,0x3e,0x00,0x00,
0x00,0x3c,0x66,0x7e,0x60,0x3c,0x00,0x00,
0x1c,0x30,0x7c,0x30,0x30,0x30,0x00,0x00,
0x00,0x3e,0x66,0x66,0x3e,0x06,0x3c,0x00,
0x60,0x60,0x7c,0x66,0x66,0x66,0x00,0x00,
0x30,0x00,0x30,0x30,0x30,0x18,0x00,0x00,
0x0c,0x00,0x0c,0x0c,0x0c,0x0c,0x78,0x00,
0x60,0x66,0x6c,0x78,0x6c,0x66,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x0c,0x00,0x00,
0x00,0xec,0xfe,0xd6,0xc6,0xc6,0x00,0x00,
0x00,0x7c,0x66,0x66,0x66,0x66,0x00,0x00,
0x00,0x3c,0x66,0x66,0x66,0x3c,0x00,0x00,
0x00,0x7c,0x66,0x66,0x7c,0x60,0x60,0x00,
0x00,0x3e,0x66,0x66,0x3e,0x06,0x06,0x00,
0x00,0x7c,0x66,0x60,0x60,0x60,0x00,0x00,
0x00,0x3c,0x60,0x3c,0x06,0x7c,0x00,0x00,
0x30,0x30,0x7c,0x30,0x30,0x1c,0x00,0x00,
0x00,0x66,0x66,0x66,0x66,0x3e,0x00,0x00,
0x00,0x66,0x66,0x66,0x3c,0x18,0x00,0x00,
0x00,0xc6,0xc6,0xd6,0xfe,0x6c,0x00,0x00,
0x00,0xcc,0x78,0x30,0x78,0xcc,0x00,0x00,
0x00,0x66,0x66,0x66,0x3c,0x18,0x30,0x00,
0x00,0x7e,0x0c,0x18,0x30,0x7e,0x00,0x00,
0x0c,0x18,0x18,0x30,0x18,0x18,0x0c,0x00,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,
0x30,0x18,0x18,0x0c,0x18,0x18,0x30,0x00,
0x76,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x38,0x6c,0xc6,0xc6,0xfe,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

679
src/GameLib.c Normal file
View File

@@ -0,0 +1,679 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <SDL/SDL.h>
#include "Time.h"
#include "Util.h"
#include "Draw.h"
#include "Input.h"
#include "Audio.h"
#include "Anim.h"
#include "Entity.h"
#include "GameLib.h"
// Globals
Entity *_entity = NULL;
int *_entity_flag = NULL;
int _n_entities = 0;
int _n_entities_res = 0;
int _entities_lock = 0;
int _entities_compactate = 0;
void (*_gameproc)() = NULL;
void (*_gamepostproc)() = NULL;
void (*_gamepredraw)(float f) = NULL;
void (*_gamedraw)(float f) = NULL;
int _pft;
int _game_size[2];
int _game_pos0[2];
int _game_pos1[2];
long long t_proc;
long long t_col;
long long t_over;
long long t_postproc;
long long t_draw;
int fproc_count;
int fdraw_count;
typedef struct TParallaxBackground TParallaxBackground, *ParallaxBackground;
struct TParallaxBackground {
DrawImg img;
int imgSize[2];
int imgOffset[2];
float parallaxFactor[2];
};
#define MaxParallaxBackgrounds 10
TParallaxBackground _parallaxBackground[MaxParallaxBackgrounds];
int _nParallaxBackgrounds = 0;
int gamelib_debug = 0;
/////////////////////////////
// GameLib_Init
//
// Initializes the game.
int GameLib_Init(int w, int h, char *title, int pfps, int fps) {
if (!Draw_Init(w, h, title, pfps, fps)) {
return (0);
}
if (!Input_Init()) {
return (0);
}
Audio_Init();
_game_size[0] = w;
_game_size[1] = h;
_game_pos0[0] = 0;
_game_pos0[1] = 0;
_game_pos1[0] = 0;
_game_pos1[1] = 0;
_pft = 1000 / pfps;
return (1);
}
/////////////////////////////
// GameLib_AddEntity
//
// Adds an entity to the game.
void GameLib_AddEntity(Entity e) {
if (_n_entities >= _n_entities_res) {
Entity *entity_aux;
int *entity_flag_aux;
int i;
// Grow the array
if (_n_entities_res == 0)
_n_entities_res = 32;
else
_n_entities_res *= 2;
entity_aux = malloc(sizeof(Entity) * _n_entities_res);
entity_flag_aux = malloc(sizeof(int) * _n_entities_res);
for (i = 0; i < _n_entities; i++) {
entity_aux[i] = _entity[i];
entity_flag_aux[i] = _entity_flag[i];
}
if (_entity) {
free(_entity);
free(_entity_flag);
}
_entity = entity_aux;
_entity_flag = entity_flag_aux;
}
// Add the entity
_entity[_n_entities] = e;
_entity_flag[_n_entities] = 1;
_n_entities++;
// Mark for light update
Entity_MarkUpdateLight(e, _entity, _n_entities);
Entity_CalcBBox(e);
Entity_Init(e);
}
/////////////////////////////
// GameLib_UnrefEntity
//
// removes the reference to the entity.
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 {
_entity[i] = NULL;
_entity_flag[i] = 0;
}
_entities_compactate = 1;
// Mark for light update
Entity_MarkUpdateLight(e, _entity, _n_entities);
return (i);
}
}
return (-1);
}
/////////////////////////////
// GameLib_DelEntity
//
// Adds an entity to the game.
int GameLib_DelEntity(Entity e) {
int i;
if ((i = GameLib_UnrefEntity(e)) == -1) {
return (0);
}
if (_entities_lock) {
// Delete latter
_entity[i] = e;
_entity_flag[i] = -1;
} else {
// Delete now
Entity_Destroy(e);
}
return (1);
}
/////////////////////////////
// GameLib_Compactate
//
//
void GameLib_Compactate() {
int i, j;
j = 0;
if (!_entities_compactate)
return;
for (i = 0; i < _n_entities; i++) {
if (!_entity[i] || _entity_flag[i] == -2)
continue;
if (_entity_flag[i] == -1) {
Entity_Destroy(_entity[i]);
continue;
}
if (i > j) {
_entity[j] = _entity[i];
_entity_flag[j] = _entity_flag[i];
}
j++;
}
_n_entities = j;
_entities_compactate = 0;
}
/////////////////////////////
// GameLib_ProcLoop
//
// Process the loop.
void GameLib_ProcLoop(void *data) {
int i, j;
int repeat, count;
long long time;
// Step the gamePosition
_game_pos0[0] = _game_pos1[0];
_game_pos0[1] = _game_pos1[1];
// Process
time = Time_GetTime();
_entities_lock = 1;
if (_gameproc) {
_gameproc();
}
for (i = 0; i < _n_entities; i++) {
if (!_entity[i])
continue;
Entity_Process(_entity[i], _pft);
}
GameLib_Compactate();
_entities_lock = 0;
t_proc += Time_GetTime() - time;
// Colisions between entities
time = Time_GetTime();
_entities_lock = 1;
count = 0;
do {
repeat = 0;
CollisionInfo collInfo = NULL;
for (i = 0; i < _n_entities; i++) {
if (!(_entity[i]->flags & EntityFlag_Collision) ||
_entity[i]->mass < 0.0f)
continue;
if (_entity[i]->vel[0] <= 0.0f && _entity[i]->vel[0] >= -0.0f &&
_entity[i]->vel[1] <= 0.0f && _entity[i]->vel[1] >= -0.0f) {
continue;
}
for (j = 0; j < _n_entities; j++) {
if (i == j || !(_entity[j]->flags & EntityFlag_Collision) ||
CollisionInfo_CheckRepetition(collInfo, _entity[i],
_entity[j]) ||
!Entity_BBoxIntersect(_entity[i], _entity[j])) {
continue;
}
Entity_CheckCollision(_entity[i], _entity[j], &collInfo);
}
}
if (Entity_CollisionInfoResponse(collInfo)) {
repeat = 1;
}
CollisionInfo_Destroy(&collInfo);
count++;
} while (repeat && count < 50);
// Stop remaining collisions
if (count == 10) {
for (i = 0; i < _n_entities; i++) {
if (!(_entity[i]->flags & EntityFlag_Collision) ||
_entity[i]->mass < 0.0f)
continue;
for (j = 0; j < _n_entities; j++) {
if (i == j || !(_entity[j]->flags & EntityFlag_Collision) ||
!Entity_BBoxIntersect(_entity[i], _entity[j])) {
continue;
}
if (Entity_CheckCollision(_entity[i], _entity[j], NULL)) {
vec2_set(_entity[i]->vel, 0, 0);
Entity_CalcBBox(_entity[i]);
vec2_set(_entity[j]->vel, 0, 0);
Entity_CalcBBox(_entity[j]);
}
}
}
}
GameLib_Compactate();
_entities_lock = 0;
t_col += Time_GetTime() - time;
// Process Overlaps
time = Time_GetTime();
_entities_lock = 1;
for (i = 0; i < _n_entities; i++) {
if (!(_entity[i]->flags & EntityFlag_Overlap) ||
_entity[i]->mass < 0.0f)
continue;
for (j = 0; j < _n_entities; j++) {
if (!(_entity[j]->flags & EntityFlag_Overlap) || i == j)
continue;
Entity_Overlaps(_entity[i], _entity[j]);
}
}
GameLib_Compactate();
_entities_lock = 0;
t_over += Time_GetTime() - time;
// Sort
int n, n2, swap;
n = _n_entities;
do {
n2 = 0;
for (i = 1; i < n; i++) {
Entity ent1 = _entity[i - 1];
Entity ent2 = _entity[i];
swap = 0;
if (ent1->zorder > ent2->zorder) {
// Lower level
swap = 1;
} else if (ent1->zorder < ent2->zorder) {
// Upper level
} else {
// Same level
float y1 = ent1->pos[1] + ent1->sortYOffset;
float y2 = ent2->pos[1] + ent2->sortYOffset;
if (y1 > y2) {
swap = 1;
}
}
if (swap) {
Entity ent;
ent = _entity[i];
_entity[i] = _entity[i - 1];
_entity[i - 1] = ent;
n2 = i;
}
}
n = n2;
} while (n > 0);
// PostProcess
time = Time_GetTime();
_entities_lock = 1;
for (i = 0; i < _n_entities; i++) {
Entity_PostProcess(_entity[i], _pft);
if (Entity_IsMoving(_entity[i])) {
Entity_MarkUpdateLight(_entity[i], _entity, _n_entities);
}
}
if (_gamepostproc) {
_gamepostproc();
}
GameLib_Compactate();
_entities_lock = 0;
t_postproc += Time_GetTime() - time;
fproc_count++;
}
/////////////////////////////
// GameLib_DrawLoop
//
//
void GameLib_DrawLoop(void *data, float f) {
long long time;
int i;
int game_pos[2];
GameLib_GetPosInstant(game_pos, f);
time = Time_GetTime();
// PreDraw
if (_gamepredraw) {
_gamepredraw(f);
} else {
if (_nParallaxBackgrounds == 0) {
// Clean screen
Draw_Clean(0, 0, 0);
}
}
// Draw parallax backgrounds
for (i = 0; i < _nParallaxBackgrounds; i++) {
Draw_ImgParallax(
_parallaxBackground[i].img, _parallaxBackground[i].imgSize,
_parallaxBackground[i].imgOffset,
_parallaxBackground[i].parallaxFactor, game_pos, _game_size);
}
// Draw entities
GameLib_Compactate();
for (i = 0; i < _n_entities; i++) {
Entity e = _entity[i];
// Check visivility
if (!Entity_IsVisible(e, game_pos[0], game_pos[1], _game_size[0],
_game_size[1])) {
continue;
}
// Update ilumination of this entity
if (Entity_IsUpdateLight(e)) {
Entity_Iluminate(e, _entity, _n_entities);
}
Entity_Draw(e, -game_pos[0], -game_pos[1], f);
}
Draw_SetColor(1, 1, 1, 1);
_entities_lock = 1;
if (_gamedraw) {
_gamedraw(f);
}
GameLib_Compactate();
_entities_lock = 0;
t_draw += Time_GetTime() - time;
fdraw_count++;
if (Input_GetKey(InputKey_DumpProfiling) == InputKey_Pressed &&
fproc_count > 0 && fdraw_count > 0) {
Print("Profiling:::::::::\n");
Print("t_proc.....:%6lld\n", t_proc / fproc_count);
Print("t_col......:%6lld\n", t_col / fproc_count);
Print("t_over.....:%6lld\n", t_over / fproc_count);
Print("t_postproc.:%6lld\n", t_postproc / fproc_count);
Print("t_draw.....:%6lld\n", t_draw / fdraw_count);
t_proc = 0;
t_col = 0;
t_over = 0;
t_postproc = 0;
t_draw = 0;
fproc_count = 0;
fdraw_count = 0;
}
}
/////////////////////////////
// GameLib_Loop
//
// Loops the game.
void GameLib_Loop(void (*gameproc)(), void (*gamepostproc)(),
void (*gamepredraw)(float f), void (*gamedraw)(float f)) {
_gameproc = gameproc;
_gamepostproc = gamepostproc;
_gamepredraw = gamepredraw;
_gamedraw = gamedraw;
t_proc = 0;
t_col = 0;
t_over = 0;
t_postproc = 0;
t_draw = 0;
fproc_count = 0;
fdraw_count = 0;
Draw_Loop(GameLib_ProcLoop, GameLib_DrawLoop, NULL);
}
/////////////////////////////
// GameLib_GetPos
// GameLib_SetPos
// GameLib_UpdatePos
// GameLib_SetPos
// GameLib_GetPosInstant
//
//
void GameLib_GetPos(int pos[2]) {
pos[0] = _game_pos1[0];
pos[1] = _game_pos1[1];
}
void GameLib_SetPos(int pos[2]) {
_game_pos0[0] = pos[0];
_game_pos0[1] = pos[1];
_game_pos1[0] = pos[0];
_game_pos1[1] = pos[1];
}
void GameLib_UpdatePos(int pos[2]) {
_game_pos1[0] = pos[0];
_game_pos1[1] = pos[1];
}
void GameLib_GetSize(int size[2]) {
size[0] = _game_size[0];
size[1] = _game_size[1];
}
void GameLib_GetPosInstant(int pos[2], float f) {
pos[0] = _game_pos0[0] + f * (_game_pos1[0] - _game_pos0[0]);
pos[1] = _game_pos0[1] + f * (_game_pos1[1] - _game_pos0[1]);
}
/////////////////////////////
// GameLib_MoveToPos
// GameLib_MoveToPosH
// GameLib_MoveToPosV
//
//
void GameLib_MoveToPos(vec2 pos, float f) {
GameLib_MoveToPosH(pos, f);
GameLib_MoveToPosV(pos, f);
}
void GameLib_MoveToPosH(vec2 pos, float f) {
_game_pos1[0] =
_game_pos1[0] + (pos[0] - (_game_pos1[0] + (_game_size[0] / 2.0f))) * f;
}
void GameLib_MoveToPosV(vec2 pos, float f) {
_game_pos1[1] =
_game_pos1[1] + (pos[1] - (_game_pos1[1] + (_game_size[1] / 2.0f))) * f;
}
/////////////////////////////
// GameLib_ForEachEn
//
// Deletes every entity.
void GameLib_DelEnts() {
int i;
for (i = 0; i < _n_entities; i++) {
if (!_entity[i])
continue;
Entity_Destroy(_entity[i]);
}
_n_entities = 0;
}
/////////////////////////////
// GameLib_ForEachEn
//
// Iterates every entity.
void GameLib_ForEachEnt(int (*func)(Entity ent)) {
int i;
for (i = 0; i < _n_entities; i++) {
if (!_entity[i])
continue;
if (!func(_entity[i])) {
break;
}
}
}
/////////////////////////////
// GameLib_SearchEnt
//
// Searches throught the entities.
Entity GameLib_SearchEnt(int (*func)(Entity ent, void *d), void *d) {
int i;
Entity ent = NULL;
for (i = 0; i < _n_entities; i++) {
if (!_entity[i])
continue;
if (func(_entity[i], d)) {
ent = _entity[i];
break;
}
}
return ent;
}
/////////////////////////////
// GameLib_EntityCustomCheckCollision
//
//
int GameLib_EntityCustomCheckCollision(Entity ent, vec2 vel) {
int collision = 0;
CollisionInfo collInfo = NULL;
vec2 originalVel;
int j;
vec2_copy(originalVel, ent->vel);
vec2_copy(ent->vel, vel);
Entity_CalcBBox(ent);
for (j = 0; j < _n_entities; j++) {
if (!(_entity[j]->flags & EntityFlag_Collision) ||
!Entity_BBoxIntersect(ent, _entity[j])) {
continue;
}
Entity_CheckCollision(ent, _entity[j], &collInfo);
if (collInfo != NULL) {
collision = 1;
break;
}
}
vec2_copy(ent->vel, originalVel);
Entity_CalcBBox(ent);
CollisionInfo_Destroy(&collInfo);
return collision;
}
/////////////////////////////
// GameLib_PlaySound
//
//
void GameLib_PlaySound(AudioSnd snd, int x, int y) {
float vleft, vright, dx, dy;
int r, cx, cy, off;
// Get the screen context
cx = _game_pos1[0] + _game_size[0] / 2;
cy = _game_pos1[1] + _game_size[1] / 2;
if (_game_size[0] > _game_size[1]) {
r = _game_size[0] / 2;
} else {
r = _game_size[1] / 2;
}
r = r * 1.2f;
off = r / 10.0f;
// Calculate volumes
dx = x - (cx + off);
dy = y - (cy);
vright = 1.0f - (sqrtf(dx * dx + dy * dy) / (float)r);
dx = x - (cx - off);
dy = y - (cy);
vleft = 1.0f - (sqrtf(dx * dx + dy * dy) / (float)r);
// Clamp to 0
if (vleft < 0.0f)
vleft = 0.0f;
if (vright < 0.0f)
vright = 0.0f;
if (vleft <= 0.0f && vright <= 0.0f) {
return;
}
// PLAY!
Audio_PlaySound(snd, vleft, vright, 0);
}
/////////////////////////////
// GameLib_PlayLoopingSound
//
//
AudioChn GameLib_PlayLoopingSound(AudioSnd snd) {
// PLAY!
return Audio_PlaySound(snd, 1.0f, 1.0f, 1);
}
/////////////////////////////
// GameLib_EntitySetLight
//
//
void GameLib_EntitySetLight(Entity e, float r, float g, float b, float rad) {
if (Entity_IsLight(e)) {
Entity_MarkUpdateLight(e, _entity, _n_entities);
Entity_SetLight(e, r, g, b, rad);
Entity_MarkUpdateLight(e, _entity, _n_entities);
} else {
Entity_SetLight(e, r, g, b, rad);
}
}
/////////////////////////////
// GameLib_ConvertScreenPositionToGamePosition
//
//
void GameLib_ConvertScreenPositionToGamePosition(vec2 screenPos, vec2 gamePos, float f) {
int game_pos[2];
game_pos[0] = _game_pos0[0] + f * (_game_pos1[0] - _game_pos0[0]);
game_pos[1] = _game_pos0[1] + f * (_game_pos1[1] - _game_pos0[1]);
gamePos[0] = (screenPos[0] * _game_size[0]) + game_pos[0];
gamePos[1] = (screenPos[1] * _game_size[1]) + game_pos[1];
}
/////////////////////////////
// GameLib_AddParallaxBackground
//
//
void GameLib_AddParallaxBackground(DrawImg img, int imgSize[2],
int imgOffset[2], float parallaxFactor[2]) {
int idx = _nParallaxBackgrounds;
if ((idx + 1) >= MaxParallaxBackgrounds) {
Print("GameLib: Can't add parallaxBackground, limit reached.");
return;
}
_parallaxBackground[idx].img = img;
_parallaxBackground[idx].imgSize[0] = imgSize[0];
_parallaxBackground[idx].imgSize[1] = imgSize[1];
_parallaxBackground[idx].imgOffset[0] = imgOffset[0];
_parallaxBackground[idx].imgOffset[1] = imgOffset[1];
_parallaxBackground[idx].parallaxFactor[0] = parallaxFactor[0];
_parallaxBackground[idx].parallaxFactor[1] = parallaxFactor[1];
_nParallaxBackgrounds++;
}
/////////////////////////////
// GameLib_CleanParallaxBackgrounds
//
//
void GameLib_CleanParallaxBackgrounds() { _nParallaxBackgrounds = 0; }

130
src/GameLib.h Normal file
View File

@@ -0,0 +1,130 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _GAMELIB_H_
#define _GAMELIB_H_
#include "Time.h"
#include "Util.h"
#include "Draw.h"
#include "Input.h"
#include "Audio.h"
#include "Anim.h"
#include "Entity.h"
/////////////////////////////
// GameLib_Init
//
// Initializes the game.
int GameLib_Init(int w, int h, char *title, int pfps, int fps);
/////////////////////////////
// GameLib_AddEntity
//
// Adds an entity to the game.
void GameLib_AddEntity(Entity e);
/////////////////////////////
// GameLib_UnrefEntity
//
// removes the reference to the entity.
int GameLib_UnrefEntity(Entity e);
/////////////////////////////
// GameLib_DelEntity
//
// Adds an entity to the game.
int GameLib_DelEntity(Entity e);
/////////////////////////////
// GameLib_Loop
//
// Loops the game.
void GameLib_Loop(void (*gameproc)(), void (*gamepostproc)(),
void (*gamepredraw)(float f), void (*gamedraw)(float f));
/////////////////////////////
// GameLib_GetPos
// GameLib_SetPos
// GameLib_UpdatePos
// GameLib_SetPos
// GameLib_GetPosInstant
//
//
void GameLib_GetPos(int pos[2]);
void GameLib_SetPos(int pos[2]);
void GameLib_UpdatePos(int pos[2]);
void GameLib_GetSize(int size[2]);
void GameLib_GetPosInstant(int pos[2], float f);
/////////////////////////////
// GameLib_MoveToPos
// GameLib_MoveToPosH
// GameLib_MoveToPosV
//
//
void GameLib_MoveToPos(vec2 pos, float f);
void GameLib_MoveToPosH(vec2 pos, float f);
void GameLib_MoveToPosV(vec2 pos, float f);
/////////////////////////////
// GameLib_ForEachEn
//
// Deletes every entity.
void GameLib_DelEnts();
/////////////////////////////
// GameLib_ForEachEnt
//
// Iterates every entity.
void GameLib_ForEachEnt(int (*func)(Entity ent));
/////////////////////////////
// GameLib_SearchEnt
//
// Searches throught the entities.
Entity GameLib_SearchEnt(int (*func)(Entity ent, void *d), void *d);
/////////////////////////////
// GameLib_EntityCustomCheckCollision
//
//
int GameLib_EntityCustomCheckCollision(Entity ent, vec2 vel);
/////////////////////////////
// GameLib_PlaySound
//
// Play a sound position aware.
void GameLib_PlaySound(AudioSnd snd, int x, int y);
/////////////////////////////
// GameLib_PlayLoopingSound
//
// Play a sound looping
AudioChn GameLib_PlayLoopingSound(AudioSnd snd);
/////////////////////////////
// GameLib_EntitySetLight
//
//
void GameLib_EntitySetLight(Entity e, float r, float g, float b, float rad);
/////////////////////////////
// GameLib_ConvertScreenPositionToGamePosition
//
//
void GameLib_ConvertScreenPositionToGamePosition(vec2 screenPos, vec2 gamePos, float f);
/////////////////////////////
// GameLib_AddParallaxBackground
//
//
void GameLib_AddParallaxBackground(DrawImg img, int imgSize[2],
int imgOffset[2], float parallaxFactor[2]);
/////////////////////////////
// GameLib_CleanParallaxBackgrounds
//
//
void GameLib_CleanParallaxBackgrounds();
#endif

188
src/Input.c Normal file
View File

@@ -0,0 +1,188 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#include <math.h>
#include <SDL/SDL.h>
#ifdef EMSCRIPTEN
#define SDL_GetKeyState SDL_GetKeyboardState
#endif
#include "Util.h"
#include "Input.h"
// Globals
InputKeyStatus _keys[InputKey_Max];
int _pointerDown = 0;
float _pointerX = 0;
float _pointerY = 0;
int _clicked = 0;
float _clickedPositionX = 0;
float _clickedPositionY = 0;
/////////////////////////////
// Input_Init
//
// Initializes the game input.
int Input_Init() {
int i;
// Mark released all the keys
for (i = 0; i < InputKey_Max; i++) {
_keys[i] = InputKey_Released;
}
return (1);
}
/////////////////////////////
// Input_Frame
//
// Notify a frame update to the input subsystem.
void Input_Frame() {
Uint8 *keys;
// Get keyboard state
keys = (Uint8 *)SDL_GetKeyState(NULL);
// Process Keys
Input_SetKey(InputKey_Action1, keys[SDLK_z] | keys[SDLK_o]);
Input_SetKey(InputKey_Action2, keys[SDLK_x] | keys[SDLK_p]);
Input_SetKey(InputKey_Up, keys[SDLK_UP] | keys[SDLK_w]);
Input_SetKey(InputKey_Down, keys[SDLK_DOWN] | keys[SDLK_s]);
Input_SetKey(InputKey_Left, keys[SDLK_LEFT] | keys[SDLK_a]);
Input_SetKey(InputKey_Right, keys[SDLK_RIGHT] | keys[SDLK_d]);
Input_SetKey(InputKey_Jump, keys[SDLK_SPACE]);
Input_SetKey(InputKey_Continue,
keys[SDLK_RETURN] | keys[SDLK_KP_ENTER] | _pointerDown);
Input_SetKey(InputKey_DumpProfiling, keys[SDLK_m]);
}
/////////////////////////////
// Input_PostFrame
//
// Notify a frame update to the input subsystem.
void Input_PostFrame() {
Input_SetKey(InputKey_Exit, 0);
_clicked = 0;
}
/////////////////////////////
// Input_SetKey
//
// Notify a key press to the input subsystem.
void Input_SetKey(InputKey key, int status) {
if (!status) {
_keys[key] = InputKey_Released;
} else {
if (_keys[key] >= InputKey_Pressed) {
_keys[key] = InputKey_Holded;
} else {
_keys[key] = InputKey_Pressed;
}
}
}
/////////////////////////////
// Input_GetKey
//
// Reports a the status of a key.
InputKeyStatus Input_GetKey(InputKey key) { return (_keys[key]); }
/////////////////////////////
// Input_SetPointerPosition
//
void Input_SetPointerPosition(float x, float y) {
_pointerX = x;
_pointerY = y;
}
/////////////////////////////
// Input_SetPointerDown
//
void Input_SetPointerDown(int pointerDown) {
if (pointerDown == 0 && _pointerDown == 1) {
_clicked = 1;
_clickedPositionX = _pointerX;
_clickedPositionY = _pointerY;
}
_pointerDown = pointerDown;
}
/////////////////////////////
// Input_GetPointerPosition
//
int Input_GetPointerPosition(vec2 pointer) {
pointer[0] = _pointerX;
pointer[1] = _pointerY;
return _pointerDown;
}
/////////////////////////////
// Input_GetClickedPosition
//
int Input_GetClickedPosition(vec2 clickPosition) {
clickPosition[0] = _clickedPositionX;
clickPosition[1] = _clickedPositionY;
return _clicked;
}
/////////////////////////////
// Input_AnyKey
//
//
int Input_AnyKey() {
int i;
for (i = 0; i < InputKey_Max; i++) {
if (_keys[i] == InputKey_Pressed) {
return (1);
}
}
return (0);
}
/////////////////////////////
// Input_GetDir
//
// Reports the direction of the dpad.
int Input_GetDir(vec2 dir) {
float vlen;
Uint8 buttons;
int mx, my;
float dlen;
extern int _width, _height;
// Get mouse state
buttons = SDL_GetMouseState(&mx, &my);
if (buttons) {
// Use the mouse
vec2_set(dir, mx - (_width / 2), my - (_height / 2.0f));
dlen = 1.0f / sqrtf(vec2_dot(dir, dir));
vec2_scale(dir, dir, dlen);
return (1);
} else {
// Use the keyboar
vec2_set(dir, 0.0f, 0.0f);
if (Input_GetKey(InputKey_Up)) {
dir[1] -= 1.0f;
}
if (Input_GetKey(InputKey_Down)) {
dir[1] += 1.0f;
}
if (Input_GetKey(InputKey_Left)) {
dir[0] -= 1.0f;
}
if (Input_GetKey(InputKey_Right)) {
dir[0] += 1.0f;
}
vlen = vec2_dot(dir, dir);
if (vlen > 0.0f) {
vlen = sqrtf(vlen);
vec2_scale(dir, dir, 1.0f / vlen);
return (1);
} else {
return (0);
}
}
}

100
src/Input.h Normal file
View File

@@ -0,0 +1,100 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _INPUT_H_
#define _INPUT_H_
#include "Util.h"
/////////////////////////////
// Input_Init
//
// Initializes the game input.
int Input_Init();
/////////////////////////////
// Input_Frame
//
// Notify a frame update to the input subsystem.
void Input_Frame();
/////////////////////////////
// Input_PostFrame
//
// Notify a frame update end to the input subsystem.
void Input_PostFrame();
////////////////////////////////////////////////
// InputKey //
//////////////
// Key enumeration.
typedef enum {
InputKey_Action1,
InputKey_Action2,
InputKey_Up,
InputKey_Down,
InputKey_Left,
InputKey_Right,
InputKey_Jump,
InputKey_Continue,
InputKey_Exit,
InputKey_DumpProfiling,
InputKey_Max
} InputKey;
/////////////////////////////
// Input_SetKey
//
// Notify a key press to the input subsystem.
void Input_SetKey(InputKey key, int status);
////////////////////////////////////////////////
// InputKeyStatus //
///////////////////
// Key status enumeration.
typedef enum {
InputKey_Released,
InputKey_Pressed,
InputKey_Holded
} InputKeyStatus;
/////////////////////////////
// Input_GetKey
//
// Reports a the status of a key.
InputKeyStatus Input_GetKey(InputKey key);
/////////////////////////////
// Input_SetPointerPosition
//
void Input_SetPointerPosition(float x, float y);
/////////////////////////////
// Input_SetPointerDown
//
void Input_SetPointerDown(int pointerDown);
/////////////////////////////
// Input_GetPointerPosition
//
int Input_GetPointerPosition(vec2 pointer);
/////////////////////////////
// Input_GetClickedPosition
//
int Input_GetClickedPosition(vec2 clickPosition);
/////////////////////////////
// Input_AnyKey
//
//
int Input_AnyKey();
/////////////////////////////
// Input_GetDir
//
// Reports the direction of the dpad.
int Input_GetDir(vec2 dir);
#endif

95
src/QuadArray2D.c Normal file
View File

@@ -0,0 +1,95 @@
// Copyright (C) 2013 Valeriano Alfonso Rodriguez (Kableado)
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "QuadArray2D.h"
QuadArray2D QuadArray2D_Create(int resVertex) {
QuadArray2D quadArray = NULL;
quadArray = malloc(sizeof(TQuadArray2D));
quadArray->vertexData = malloc(sizeof(float) * Vertex2D_Length * resVertex);
quadArray->nVertex = 0;
quadArray->resVertex = resVertex;
return quadArray;
}
void QuadArray2D_Destroy(QuadArray2D *quadArray) {
if (!quadArray)
return;
if (!quadArray[0])
return;
free(quadArray[0]->vertexData);
free(quadArray[0]);
quadArray[0] = NULL;
}
void QuadArray2D_Clean(QuadArray2D quadArray) { quadArray->nVertex = 0; }
void QuadArray2D_AddVertex(QuadArray2D quadArray, float v[]) {
if (quadArray->resVertex <= quadArray->nVertex) {
// Grow vertexData
quadArray->resVertex *= 2;
float *newVertexData =
malloc(sizeof(float) * Vertex2D_Length * quadArray->resVertex);
memcpy(newVertexData, quadArray->vertexData,
sizeof(float) * Vertex2D_Length * quadArray->nVertex);
free(quadArray->vertexData);
quadArray->vertexData = newVertexData;
}
// Add the vertex
memcpy(quadArray->vertexData + (Vertex2D_Length * quadArray->nVertex), v,
sizeof(float) * Vertex2D_Length);
quadArray->nVertex++;
}
void QuadArray2D_AddQuad(QuadArray2D quadArray, float x0, float y0, float u0,
float v0, float x1, float y1, float u1, float v1,
float color[]) {
float v[Vertex2D_Length];
// Set the color
v[4] = color[0];
v[5] = color[1];
v[6] = color[2];
v[7] = color[3];
// 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);
}

31
src/QuadArray2D.h Normal file
View File

@@ -0,0 +1,31 @@
// Copyright (C) 2013 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _QUADARRAY2D_H_
#define _QUADARRAY2D_H_
// Vertex2D -> (x,y) (u,v) (r,g,b,a)
#define Vertex2D_Length 8
////////////////////////////////////////////////
// QuadArray2D
//
typedef struct TQuadArray2D TQuadArray2D, *QuadArray2D;
struct TQuadArray2D {
float *vertexData;
int nVertex;
int resVertex;
};
QuadArray2D QuadArray2D_Create(int resVertex);
void QuadArray2D_Destroy(QuadArray2D *quadArray);
void QuadArray2D_Clean(QuadArray2D quadArray);
void QuadArray2D_AddVertex(QuadArray2D quadArray, float v[]);
void QuadArray2D_AddQuad(QuadArray2D quadArray, float x0, float y0, float u0,
float v0, float x1, float y1, float u1, float v1,
float color[]);
#endif

62
src/Time.c Normal file
View File

@@ -0,0 +1,62 @@
// Copyright (C) 2011-2014 Valeriano Alfonso Rodriguez (Kableado)
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include "Time.h"
/////////////////////////////
// Time_GetTime
//
// Gets the current time in usecs.
/////////////////////////////
// Time_Pause
//
// Pauses the execution for t usecs.
#if WIN32
#include <windows.h>
// WIN32
long long Time_GetTime() {
LARGE_INTEGER freq;
LARGE_INTEGER tim;
long long int microt;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&tim);
microt = (tim.QuadPart * 1000000) / freq.QuadPart;
return (microt);
}
void Time_Pause(int pausa) {
long long tend, t, diff;
t = Time_GetTime();
tend = t + pausa;
do {
diff = tend - t;
if (diff > 1000) {
Sleep(diff / 1000);
} else {
Sleep(0);
}
t = Time_GetTime();
} while (tend >= t);
}
#else
// UNIX
long long Time_GetTime() {
struct timeval t;
long long usecs;
gettimeofday(&t, NULL);
usecs = (t.tv_sec * 1000000ll) + (t.tv_usec);
return (usecs);
}
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);
}
#endif // if WIN32

18
src/Time.h Normal file
View File

@@ -0,0 +1,18 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _TIME_H_
#define _TIME_H_
/////////////////////////////
// Time_GetTime
//
// Gets the current time in usecs.
long long Time_GetTime();
/////////////////////////////
// Time_Pause
//
// Pauses the execution for t usecs.
void Time_Pause(int pausa);
#endif

360
src/Util.c Normal file
View File

@@ -0,0 +1,360 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include "Util.h"
/////////////////////////////
// SolveQuadratic
//
// Solves a Quadratic equation using a, b and c coeficients.
int SolveQuadratic(float a, float b, float c, float *Rmin, float *Rmax) {
float root;
float divisor;
float b2;
b2 = b * b;
root = b2 - 4.0 * a * c;
if (root < 0) {
// Complex
return (0);
}
divisor = (2.0 * a);
if (fabs(divisor) == 0.0f) {
// +inf -inf
return (0);
}
root = sqrtf(root);
Rmin[0] = (float)((-b - root) / divisor);
Rmax[0] = (float)((-b + root) / divisor);
return (1);
}
////////////////////////////////////////////////
// vec2 //
//////////
// A 2D vector.
float vec2_norm(vec2 v) {
float len;
len = vec2_len(v);
vec2_scale(v, v, 1.0f / len);
return (len);
}
void vec2_orthogonalize4(vec2 v) {
if (fabs(v[0]) > fabs(v[1])) {
if (v[0] >= 0) {
v[0] = 1.0f;
v[1] = 0.0f;
} else {
v[0] = -1.0f;
v[1] = 0.0f;
}
} else {
if (v[1] >= 0) {
v[1] = 1.0f;
v[0] = 0.0f;
} else {
v[1] = -1.0f;
v[0] = 0.0f;
}
}
}
void vec2_orthogonalize8(vec2 v) {
float diff = fabs(fabs(v[0]) - fabs(v[1]));
if (diff > 0.2f) {
if (fabs(v[0]) > fabs(v[1])) {
if (v[0] >= 0) {
v[0] = 1.0f;
v[1] = 0.0f;
} else {
v[0] = -1.0f;
v[1] = 0.0f;
}
} else {
if (v[1] >= 0) {
v[1] = 1.0f;
v[0] = 0.0f;
} else {
v[1] = -1.0f;
v[0] = 0.0f;
}
}
} else {
if (v[0] > 0.0f) {
v[0] = 0.707f;
} else {
v[0] = -0.707f;
}
if (v[1] > 0.0f) {
v[1] = 0.707f;
} else {
v[1] = -0.707f;
}
}
}
/////////////////////////////
// Intersec_RayUnitCircle
//
// Intersection between a ray and a Unit Circle.
int Intersec_RayUnitCircle(vec2 orig, vec2 vel, vec2 center, float *t) {
float a, b, c;
float Rmin, Rmax;
vec2 distv;
float qlvel;
float qdistv;
// Check if the collision is even posible
qlvel = vec2_dot(vel, vel);
if (fabs(qlvel) <= 0.0f)
return (0);
vec2_minus(distv, orig, center);
qdistv = vec2_dot(distv, distv);
// Solve as a unit circle
a = qlvel;
b = 2.0f * vec2_dot(distv, vel);
c = qdistv - 1.0f;
if (SolveQuadratic(a, b, c, &Rmin, &Rmax)) {
if (Rmin >= -0.0f && Rmin < Rmax && Rmin <= 1.0f) {
*t = Rmin;
return (1);
}
if (Rmax >= -0.0f && Rmin > Rmax && Rmax <= 1.0f) {
*t = Rmax;
return (1);
}
}
return (0);
}
/////////////////////////////
// Colision_CircleCircle
//
// Colision point of a circle against another circle.
int Colision_CircleCircle(vec2 cir1, float rad1, vec2 vel, vec2 cir2,
float rad2, float *t, vec2 n) {
vec2 vel_a, orig_a, cen_a, temp;
float rads, invrads;
float maxx, minx;
float maxy, miny;
// Check if the collision is even posible
rads = rad1 + rad2;
minx = cir1[0] - rads;
maxx = cir1[0] + rads;
if (vel[0] > 0) {
maxx += vel[0];
} else {
minx += vel[0];
}
if (cir2[0] < minx || cir2[0] > maxx)
return (0);
miny = cir1[1] - rads;
maxy = cir1[1] + rads;
if (vel[1] > 0) {
maxy += vel[1];
} else {
miny += vel[1];
}
if (cir2[1] < miny || cir2[1] > maxy)
return (0);
// Convert to a unit circle vs ray
invrads = 1.0f / rads;
vec2_scale(vel_a, vel, invrads);
vec2_scale(orig_a, cir1, invrads);
vec2_scale(cen_a, cir2, invrads);
if (Intersec_RayUnitCircle(orig_a, vel_a, cen_a, t)) {
// Calculate n
vec2_scaleadd(temp, cir1, vel, *t);
vec2_minus(n, temp, cir2);
vec2_scale(n, n, invrads);
return (1);
}
return (0);
}
/////////////////////////////
// Intersect_RayEdge
//
// Intersection between a ray and a edge.
int Intersect_RayEdge(vec2 pos, vec2 vel, vec2 norm, vec2 edgePos, float len,
float *t) {
vec2 pos2, intersection, perp, edgePos2;
float delta, d1, d2, hLen;
vec2_plus(pos2, pos, vel);
hLen = len / 2;
// Check intersection against the line
delta = vec2_dot(norm, edgePos);
d1 = vec2_dot(pos, norm) - delta;
d2 = vec2_dot(pos2, norm) - delta;
if (d1 >= -0.0001f && d2 <= 0.0001f) {
// Intersection with line, Calculate intersection point
*t = d1 / (d1 - d2);
vec2_scaleadd(intersection, pos, vel, *t);
// Perpendicular
vec2_perp(perp, norm);
// Check sides
vec2_scaleadd(edgePos2, edgePos, perp, -hLen);
delta = -vec2_dot(perp, edgePos2);
d1 = (-vec2_dot(perp, intersection)) - delta;
vec2_scaleadd(edgePos2, edgePos, perp, hLen);
delta = vec2_dot(perp, edgePos2);
d2 = vec2_dot(perp, intersection) - delta;
if (d1 <= 0.0f && d2 <= 0.0f) {
// Intersection inside Edge.
return (1);
}
}
return (0);
}
/////////////////////////////
// absmod
//
int absmod(int v, int d) {
if (v < 0) {
v += d * (((v / d) * (-1)) + 1);
return (v);
} else {
return (v % d);
}
}
float fabsmod(float v, int d) {
if (v < 0) {
v += d * ((((int)(v / d)) * (-1)) + 1);
return (v);
} else {
v -= d * (((int)(v / d)) + 1);
return (v);
}
}
/////////////////////////////
// IsBigEndian
//
int IsBigEndian() {
union {
unsigned int i;
char c[4];
} bint = {0x01020304};
return bint.c[0] == 1;
}
/////////////////////////////
// EndsWith
//
int EndsWith(char *str, char *suffix) {
if (!str || !suffix)
return 0;
int lenStr = strlen(str);
int lenSuffix = strlen(suffix);
if (lenSuffix > lenStr)
return 0;
return strncmp(str + lenStr - lenSuffix, suffix, lenSuffix) == 0;
}
/////////////////////////////
// Rand
//
// (LGC++) + cambio de semilla
#define __seed_n 30
#define __seed_a 30
#define __seed_b 5
#define __seed_c 10
#define __seed_d 15
//#define __LGC_a 1664525ul
//#define __LGC_c 1013904223ul
//#define __LGC_m 4294967296ul
#define __LGC_a 16807ul
#define __LGC_c 2
#define __LGC_m 2147483647ul
unsigned __seeds[30];
int __seed_i = -1;
unsigned __rand_count;
unsigned __rand_orig_seed;
void Rand_Seed(unsigned seed) {
int i;
__seeds[0] = seed;
for (i = 1; i < 30; i++) {
__seeds[i] = (__seeds[i - 1] * __LGC_a + __LGC_c) % __LGC_m;
//__seeds[i]=(__seeds[i-1]*__LGC_a+__LGC_c);
}
__seed_i = 29;
// Cambio de semilla
__rand_count = 0;
__rand_orig_seed = seed;
}
unsigned Rand_Get() {
unsigned val;
int a, b, c, d;
if (__seed_i == -1) {
Rand_Seed(1);
}
a = __seed_i - __seed_a;
if (a < 0)
a += __seed_n;
b = __seed_i - __seed_b;
if (b < 0)
b += __seed_n;
c = __seed_i - __seed_c;
if (c < 0)
c += __seed_n;
d = __seed_i - __seed_d;
if (d < 0)
d += __seed_n;
val = __seeds[a] ^ __seeds[b] ^ __seeds[c] ^ __seeds[d];
a = __seed_i - 1;
if (a < 0)
a = __seed_n - 1;
__seeds[__seed_i] = (__seeds[a] * __LGC_a + __LGC_c) % __LGC_m;
//__seeds[__seed_i]=(__seeds[a]*__LGC_a+__LGC_c);
__seed_i++;
if (__seed_i == __seed_n)
__seed_i = 0;
// Cambio de semilla
__rand_count++;
if (__rand_count > (1 << 15)) {
Rand_Seed(__rand_orig_seed + 1);
}
return (val);
}
/////////////////////////////
// Print
//
// Prints the formated text
int Print(char *fmt, ...) {
va_list ap;
int n;
// Print
va_start(ap, fmt);
n = vprintf(fmt, ap);
va_end(ap);
// Flush
fflush(stdout);
return (n);
}

99
src/Util.h Normal file
View File

@@ -0,0 +1,99 @@
// Copyright (C) 2011 Valeriano Alfonso Rodriguez (Kableado)
#ifndef _UTIL_H_
#define _UTIL_H_
#include <stdlib.h>
#include <stdarg.h>
/////////////////////////////
// SolveQuadratic
//
// Solves a Quadratic equation using a, b and c coeficients.
int SolveQuadratic(float a, float b, float c, float *Rmin, float *Rmax);
////////////////////////////////////////////////
// vec2 //
//////////
// A 2D vector.
typedef float vec2[2];
#define vec2_set(v, x, y) \
(v)[0] = (x); \
(v)[1] = (y);
#define vec2_copy(v1, v2) \
(v1)[0] = (v2)[0]; \
(v1)[1] = (v2)[1];
#define vec2_plus(v, v1, v2) \
(v)[0] = (v1)[0] + (v2)[0]; \
(v)[1] = (v1)[1] + (v2)[1];
#define vec2_minus(v, v1, v2) \
(v)[0] = (v1)[0] - (v2)[0]; \
(v)[1] = (v1)[1] - (v2)[1];
#define vec2_scale(v, v1, s) \
(v)[0] = (v1)[0] * (s); \
(v)[1] = (v1)[1] * (s);
#define vec2_dot(v1, v2) ((v1)[0] * (v2)[0] + (v1)[1] * (v2)[1])
#define vec2_len(v) sqrtf((v)[0] * (v)[0] + (v)[1] * (v)[1])
#define vec2_perp(v, n) \
(v)[0] = -(n)[1]; \
(v)[1] = (n)[0];
#define vec2_scaleadd(v, v1, v2, s) \
(v)[0] = (v2)[0] * (s) + (v1)[0]; \
(v)[1] = (v2)[1] * (s) + (v1)[1];
float vec2_norm(vec2 v);
#define vec2_interpol(v, v1, v2, f) \
(v)[0] = (v1)[0] - f * ((v1)[0] - (v2)[0]); \
(v)[1] = (v1)[1] - f * ((v1)[1] - (v2)[1]);
void vec2_orthogonalize4(vec2 v);
void vec2_orthogonalize8(vec2 v);
/////////////////////////////
// Intersec_RayUnitCircle
//
// Intersection between a ray and a Unit Circle.
int Intersec_RayUnitCircle(vec2 orig, vec2 vel, vec2 center, float *t);
/////////////////////////////
// Intersect_CircleCircle
//
// Colision point of a circle against another circle.
int Colision_CircleCircle(vec2 cir1, float ra, vec2 vel, vec2 cb, float rb,
float *t, vec2 n);
/////////////////////////////
// Intersect_RayEdge
//
// Intersection between a ray and a edge.
int Intersect_RayEdge(vec2 pos, vec2 vel, vec2 norm, vec2 edgePos, float len,
float *t);
/////////////////////////////
// absmod
//
int absmod(int v, int d);
float fabsmod(float v, int d);
/////////////////////////////
// IsBigEndian
//
int IsBigEndian();
/////////////////////////////
// EndsWith
//
int EndsWith(char *str, char *suffix);
/////////////////////////////
// Rand
//
void Rand_Seed(unsigned seed);
unsigned Rand_Get();
#define Rand_GetFloat(x) (((float)(Rand_Get() % 1048576)) / 1048576.0f)
/////////////////////////////
// Print
//
// Prints the formated text
int Print(char *fmt, ...);
#endif

6224
src/lodepng.c Normal file

File diff suppressed because it is too large Load Diff

1760
src/lodepng.h Normal file

File diff suppressed because it is too large Load Diff