2014-02-16 10:41:12 +00:00
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
#include "run.h"
|
|
|
|
#include "fight.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "end.h"
|
|
|
|
#include "graphics.h"
|
|
|
|
#include "3dutils.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "legoblocks.h"
|
|
|
|
#include "glapi.h"
|
|
|
|
|
|
|
|
int gamemode;
|
|
|
|
|
|
|
|
bool changed;
|
|
|
|
|
|
|
|
bool gameinitialized = false;
|
|
|
|
|
|
|
|
void initFontTexture(void);
|
|
|
|
|
|
|
|
void initScenes(void){
|
2014-02-16 13:34:15 +00:00
|
|
|
knobgllist = glGenLists(1);
|
|
|
|
setDetail(detail);
|
|
|
|
|
2014-02-16 10:41:12 +00:00
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
//Simple loading-screen
|
|
|
|
enable2D();
|
2014-02-16 10:41:12 +00:00
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
SDL_GL_SwapBuffers();
|
2014-02-16 10:41:12 +00:00
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
initFontTexture();
|
2014-02-16 10:41:12 +00:00
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
print(0.08, 0.4, "Loading...", 0.2);
|
|
|
|
SDL_GL_SwapBuffers();
|
2014-02-16 10:41:12 +00:00
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
disable2D();
|
2014-02-16 10:41:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-16 13:34:15 +00:00
|
|
|
SKYBOX = -1;
|
|
|
|
initTextures();
|
|
|
|
initFight();
|
|
|
|
initMenu();
|
|
|
|
initEnd();
|
|
|
|
changeGameMode(MENUMODE);
|
|
|
|
//changeGameMode(ENDMODE);
|
|
|
|
gameinitialized = true;
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void changeGameMode(int newmode){
|
2014-02-16 13:34:15 +00:00
|
|
|
gamemode = newmode;
|
|
|
|
changed = true;
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void calculateFrame(int framecount){
|
2014-02-16 13:34:15 +00:00
|
|
|
switch(gamemode){
|
|
|
|
case MENUMODE:
|
|
|
|
calculateMenu(framecount);
|
|
|
|
break;
|
|
|
|
case FIGHTMODE:
|
|
|
|
calculateFight(framecount);
|
|
|
|
break;
|
|
|
|
case ENDMODE:
|
|
|
|
calculateEnd(framecount);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
updateAudio();
|
|
|
|
changed = false;
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void drawFrame(int framecount){
|
2014-02-16 13:34:15 +00:00
|
|
|
if (changed) calculateFrame(framecount);
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
switch(gamemode){
|
|
|
|
case MENUMODE:
|
|
|
|
drawMenu(framecount);
|
|
|
|
break;
|
|
|
|
case FIGHTMODE:
|
|
|
|
drawFight(framecount);
|
|
|
|
break;
|
|
|
|
case ENDMODE:
|
|
|
|
drawEnd(framecount);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_GL_SwapBuffers();
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*int SKY_FRONT_ID;
|
|
|
|
int SKY_BACK_ID;
|
|
|
|
int SKY_LEFT_ID;
|
|
|
|
int SKY_RIGHT_ID;
|
|
|
|
int SKY_TOP_ID;
|
|
|
|
int SKY_BOTTOM_ID;*/
|
|
|
|
|
|
|
|
bool texturesloaded = false;
|
|
|
|
|
|
|
|
Texture *flaretexture;
|
|
|
|
Texture *skyfronttexture;
|
|
|
|
Texture *skybacktexture;
|
|
|
|
Texture *skylefttexture;
|
|
|
|
Texture *skyrighttexture;
|
|
|
|
Texture *skytoptexture;
|
|
|
|
Texture *skybottomtexture;
|
|
|
|
Texture *damageHead;
|
|
|
|
Texture *damageTorso;
|
|
|
|
Texture *damageHand;
|
|
|
|
Texture *damageLeg;
|
|
|
|
Texture *tuxtexture;
|
|
|
|
Texture *faceTexture;
|
|
|
|
|
|
|
|
void initFontTexture(void){
|
2014-02-16 13:34:15 +00:00
|
|
|
if (!texturesloaded){
|
|
|
|
float trans[3] = {1, 0, 0};
|
|
|
|
fonttexture = new Texture();
|
|
|
|
fonttexture->loadImage(DATAPATH"font.png", trans);
|
|
|
|
} else{
|
|
|
|
fonttexture->reload();
|
|
|
|
}
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void initTextures(void){
|
2014-02-16 13:34:15 +00:00
|
|
|
/*SKY_FRONT_ID = DRUID.loadTexture(SKYFRONT);
|
|
|
|
SKY_BACK_ID = DRUID.loadTexture(SKYBACK);
|
|
|
|
SKY_LEFT_ID = DRUID.loadTexture(SKYLEFT);
|
|
|
|
SKY_RIGHT_ID = DRUID.loadTexture(SKYRIGHT);
|
|
|
|
SKY_TOP_ID = DRUID.loadTexture(SKYTOP);
|
|
|
|
SKY_BOTTOM_ID = DRUID.loadTexture(SKYBOTTOM);*/
|
|
|
|
|
|
|
|
if (!texturesloaded){
|
|
|
|
skyfronttexture = new Texture();
|
|
|
|
skyfronttexture->loadImage(SKYFRONT);
|
|
|
|
skybacktexture = new Texture();
|
|
|
|
skybacktexture->loadImage(SKYBACK);
|
|
|
|
skylefttexture = new Texture();
|
|
|
|
skylefttexture->loadImage(SKYLEFT);
|
|
|
|
skyrighttexture = new Texture();
|
|
|
|
skyrighttexture->loadImage(SKYRIGHT);
|
|
|
|
skytoptexture = new Texture();
|
|
|
|
skytoptexture->loadImage(SKYTOP);
|
|
|
|
skybottomtexture = new Texture();
|
|
|
|
skybottomtexture->loadImage(SKYBOTTOM);
|
|
|
|
|
|
|
|
|
|
|
|
float something[3] = {1, 0, 0.5};
|
|
|
|
damageHead = new Texture();
|
|
|
|
damageHead->loadImage(DAMAGEHEAD, something);
|
|
|
|
damageTorso = new Texture();
|
|
|
|
damageTorso->loadImage(DAMAGETORSO, something);
|
|
|
|
damageHand = new Texture();
|
|
|
|
damageHand->loadImage(DAMAGEHAND, something);
|
|
|
|
damageLeg = new Texture();
|
|
|
|
damageLeg->loadImage(DAMAGELEG, something);
|
|
|
|
faceTexture = new Texture();
|
|
|
|
something[2] = 1;
|
|
|
|
faceTexture->loadImage(FACE, something);
|
|
|
|
|
|
|
|
float zeros[3] = {0, 0, 0};
|
|
|
|
flaretexture = new Texture();
|
|
|
|
flaretexture->loadImage(DATAPATH"flare.png", zeros);
|
|
|
|
|
|
|
|
|
|
|
|
float pink[3] = {1, 0, 1};
|
|
|
|
tuxtexture = new Texture();
|
|
|
|
tuxtexture->loadImage(DATAPATH"tux.png", pink);
|
|
|
|
} else{
|
|
|
|
skyfronttexture->reload();
|
|
|
|
skybacktexture->reload();
|
|
|
|
skylefttexture->reload();
|
|
|
|
skyrighttexture->reload();
|
|
|
|
skytoptexture->reload();
|
|
|
|
skybottomtexture->reload();
|
|
|
|
|
|
|
|
damageHead->reload();
|
|
|
|
damageTorso->reload();
|
|
|
|
damageHand->reload();
|
|
|
|
damageLeg->reload();
|
|
|
|
|
|
|
|
flaretexture->reload();
|
|
|
|
|
|
|
|
tuxtexture->reload();
|
|
|
|
}
|
|
|
|
texturesloaded = true;
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setDetail(int detail){
|
2014-02-16 13:34:15 +00:00
|
|
|
switch(detail){
|
|
|
|
case 0:
|
|
|
|
knobdetail = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
knobdetail = 5;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
knobdetail = 8;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
knobdetail = 16;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
initKnob();
|
2014-02-16 10:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|