From: sf17k Date: Sun, 29 May 2011 19:26:28 +0000 (-0400) Subject: cleanup, renamed rotations to yaw/pitch X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=9e06cb73424ca3f0eb971350c5dfb3cdaec0d5bf;p=lugaru.git cleanup, renamed rotations to yaw/pitch --- diff --git a/Source/Game.cpp b/Source/Game.cpp index 44c4e64..2beac5a 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -16,10 +16,10 @@ XYZ dialoguecamera[max_dialogues][max_dialoguelength]; XYZ participantlocation[max_dialogues][10]; int participantfocus[max_dialogues][max_dialoguelength]; int participantaction[max_dialogues][max_dialoguelength]; -float participantrotation[max_dialogues][10]; +float participantyaw[max_dialogues][10]; XYZ participantfacing[max_dialogues][max_dialoguelength][10]; -float dialoguecamerarotation[max_dialogues][max_dialoguelength]; -float dialoguecamerarotation2[max_dialogues][max_dialoguelength]; +float dialoguecamerayaw[max_dialogues][max_dialoguelength]; +float dialoguecamerapitch[max_dialogues][max_dialoguelength]; int indialogue; int whichdialogue; int directing; @@ -27,325 +27,106 @@ float dialoguetime; int dialoguegonethrough[20]; namespace Game{ - GLuint terraintexture; - GLuint terraintexture2; - GLuint terraintexture3; - GLuint screentexture; - GLuint screentexture2; - GLuint logotexture; - GLuint loadscreentexture; - GLuint Maparrowtexture; - GLuint Mapboxtexture; - GLuint Mapcircletexture; - GLuint cursortexture; - GLuint Mainmenuitems[10]; - - int selected; - int keyselect; - int indemo; - - bool won; - - bool entername; - - char registrationname[256]; - float registrationnumber; - - int newdetail; - int newscreenwidth; - int newscreenheight; - - bool gameon; - float deltah,deltav; - int mousecoordh,mousecoordv; - int oldmousecoordh,oldmousecoordv; - float rotation,rotation2; - SkyBox skybox; - bool cameramode; - int olddrawmode; - int drawmode; - bool firstload; - bool oldbutton; - - float leveltime; - float loadtime; + GLuint terraintexture = 0; + GLuint terraintexture2 = 0; + GLuint terraintexture3 = 0; + GLuint screentexture = 0; + GLuint screentexture2 = 0; + GLuint logotexture = 0; + GLuint loadscreentexture = 0; + GLuint Maparrowtexture = 0; + GLuint Mapboxtexture = 0; + GLuint Mapcircletexture = 0; + GLuint cursortexture = 0; + GLuint Mainmenuitems[10] = {}; + + int selected = 0; + int keyselect = 0; + + int newdetail = 0; + int newscreenwidth = 0; + int newscreenheight = 0; + + bool gameon = 0; + float deltah = 0; + float deltav = 0; + int mousecoordh = 0; + int mousecoordv = 0; + int oldmousecoordh = 0; + int oldmousecoordv = 0; + float yaw = 0; + float pitch = 0; + SkyBox *skybox = NULL; + bool cameramode = 0; + bool firstload = 0; + + GLuint hawktexture = 0; + float hawkyaw = 0; + float hawkcalldelay = 0; + float leveltime = 0; + float loadtime = 0; Model hawk; XYZ hawkcoords; XYZ realhawkcoords; - GLuint hawktexture; - float hawkrotation; - float hawkcalldelay; Model eye; Model iris; Model cornea; - bool stealthloading; - - std::vector campaignlevels; - int whichchoice; - int actuallevel; - bool winhotspot; - bool windialogue; - - bool minimap; + bool stealthloading = 0; - int musictype,oldmusictype,oldoldmusictype; - bool realthreat; - - Model rabbit; - XYZ rabbitcoords; + int musictype = 0; XYZ mapcenter; - float mapradius; - - Text* text; - float fps; + float mapradius = 0; - XYZ cameraloc; - float cameradist; + Text *text = NULL; + float fps = 0; - int drawtoggle; + bool editorenabled = 0; + int editortype = 0; + float editorsize = 0; + float editoryaw = 0; + float editorpitch = 0; - bool editorenabled; - int editortype; - float editorsize; - float editorrotation; - float editorrotation2; - - float brightness; - - int quit; - int tryquit; + int tryquit = 0; XYZ pathpoint[30]; - int numpathpoints; - int numpathpointconnect[30]; - int pathpointconnect[30][30]; - int pathpointselected; - - int endgame; - bool scoreadded; - int numchallengelevels; - - bool console; - int archiveselected; - char consoletext[15][256]; - int consolechars[15]; - bool chatting; - char displaytext[15][256]; - int displaychars[15]; - float displaytime[15]; - float displayblinkdelay; - bool displayblink; - int displayselected; - bool consolekeydown; - float consoleblinkdelay; - bool consoleblink; - int consoleselected; - bool autocam; - - unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; - unsigned short consolekey; - bool oldattackkey; - - int loading; - float talkdelay; + int numpathpoints = 0; + int numpathpointconnect[30] = {}; + int pathpointconnect[30][30] = {}; + int pathpointselected = 0; + + int endgame = 0; + bool scoreadded = 0; + int numchallengelevels = 0; + + bool console = false; + char consoletext[15][256] = {}; + int consolechars[15] = {}; + bool chatting = 0; + char displaytext[15][256] = {}; + int displaychars[15] = {}; + float displaytime[15] = {}; + float displayblinkdelay = 0; + bool displayblink = 0; + int displayselected = 0; + float consoleblinkdelay = 0; + bool consoleblink = 0; + int consoleselected = 0; + + unsigned short crouchkey=0,jumpkey=0,forwardkey=0,chatkey=0,backkey=0,leftkey=0,rightkey=0,drawkey=0,throwkey=0,attackkey=0; + unsigned short consolekey=0; + + int loading = 0; - int numboundaries; - XYZ boundary[360]; - - int whichlevel; - int oldenvironment; - int targetlevel; - float changedelay; - - float musicvolume[4]; - float oldmusicvolume[4]; - int musicselected; - int change; + int oldenvironment = 0; + int targetlevel = 0; + float changedelay = 0; - bool waiting; - Account* accountactive; -} - -void Game::newGame() -{ - text=NULL; - text=new Text(); - - terraintexture = 0; - terraintexture2 = 0; - terraintexture3 = 0; - screentexture = 0; - screentexture2 = 0; - logotexture = 0; - loadscreentexture = 0; - Maparrowtexture = 0; - Mapboxtexture = 0; - Mapcircletexture = 0; - cursortexture = 0; - - memset(Mainmenuitems, 0, sizeof(Mainmenuitems)); - - selected = 0; - keyselect = 0; - indemo = 0; - - won = 0; - - entername = 0; - - memset(registrationname, 0, sizeof(registrationname)); - registrationnumber = 0; - - newdetail = 0; - newscreenwidth = 0; - newscreenheight = 0; - - gameon = 0; - deltah = 0,deltav = 0; - mousecoordh = 0,mousecoordv = 0; - oldmousecoordh = 0,oldmousecoordv = 0; - rotation = 0,rotation2 = 0; - -// SkyBox skybox; - - cameramode = 0; - olddrawmode = 0; - drawmode = 0; - firstload = 0; - oldbutton = 0; - - leveltime = 0; - loadtime = 0; - -// Model hawk; - -// XYZ hawkcoords; -// XYZ realhawkcoords; - - hawktexture = 0; - hawkrotation = 0; - hawkcalldelay = 0; -/* - Model eye; - Model iris; - Model cornea; -*/ - stealthloading = 0; - - whichchoice = 0; - actuallevel = 0; - winhotspot = false; - windialogue = false; - - minimap = 0; - - musictype = 0,oldmusictype = 0,oldoldmusictype = 0; - realthreat = 0; - -// Model rabbit; -// XYZ rabbitcoords; - -// XYZ mapcenter; - mapradius = 0; - -// Text text; - fps = 0; - -// XYZ cameraloc; - cameradist = 0; - - drawtoggle = 0; - - editorenabled = 0; - editortype = 0; - editorsize = 0; - editorrotation = 0; - editorrotation2 = 0; - - brightness = 0; - - quit = 0; - tryquit = 0; - -// XYZ pathpoint[30]; - numpathpoints = 0; - memset(numpathpointconnect, 0, sizeof(numpathpointconnect)); - memset(pathpointconnect, 0, sizeof(pathpointconnect)); - pathpointselected = 0; - - endgame = 0; - scoreadded = 0; - numchallengelevels = 0; - - console = false; - archiveselected = 0; - - memset(consoletext, 0, sizeof(consoletext)); - memset(consolechars, 0, sizeof(consolechars)); - chatting = 0; - memset(displaytext, 0, sizeof(displaytext)); - memset(displaychars, 0, sizeof(displaychars)); - memset(displaytime, 0, sizeof(displaytime)); - displayblinkdelay = 0; - displayblink = 0; - displayselected = 0; - consolekeydown = 0; - consoleblinkdelay = 0; - consoleblink = 0; - consoleselected = 0; - autocam = 0; - - crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0; - consolekey = 0; - oldattackkey = 0; - - loading = 0; - talkdelay = 0; - - numboundaries = 0; -// XYZ boundary[360]; - - whichlevel = 0; - oldenvironment = 0; - targetlevel = 0; - changedelay = 0; - - memset(musicvolume, 0, sizeof(musicvolume)); - memset(oldmusicvolume, 0, sizeof(oldmusicvolume)); - musicselected = 0; - change = 0; - -//------------ - - waiting = false; - mainmenu = 0; - - accountactive = NULL; -} - -void Game::deleteGame(){ - if(text) - delete text; - for(int i=0;i<10;i++){ - if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] ); - } - glDeleteTextures( 1, &cursortexture ); - glDeleteTextures( 1, &Maparrowtexture ); - glDeleteTextures( 1, &Mapboxtexture ); - glDeleteTextures( 1, &Mapcircletexture ); - glDeleteTextures( 1, &terraintexture ); - glDeleteTextures( 1, &terraintexture2 ); - if(screentexture>0)glDeleteTextures( 1, &screentexture ); - if(screentexture2>0)glDeleteTextures( 1, &screentexture2 ); - glDeleteTextures( 1, &hawktexture ); - glDeleteTextures( 1, &logotexture ); - glDeleteTextures( 1, &loadscreentexture ); - - Dispose(); + bool waiting = false; + Account* accountactive = NULL; } void Game::fireSound(int sound) { @@ -415,18 +196,8 @@ void Game::inputText(char* str, int* charselected, int* nb_chars) { } } -void Game::setKeySelected() { - waiting=true; - printf("launch thread\n"); - SDL_Thread* thread = SDL_CreateThread(Game::setKeySelected_thread,NULL); - if ( thread == NULL ) { - fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError()); - waiting=false; - return; - } -} - -int Game::setKeySelected_thread(void* data) { +int setKeySelected_thread(void* data) { + using namespace Game; int keycode=-1; SDL_Event evenement; while(keycode==-1) { @@ -475,11 +246,13 @@ int Game::setKeySelected_thread(void* data) { return 0; } -void Game::DrawGL() { - if ( stereomode == stereoNone ) { - DrawGLScene(stereoCenter); - } else { - DrawGLScene(stereoLeft); - DrawGLScene(stereoRight); - } +void Game::setKeySelected() { + waiting=true; + printf("launch thread\n"); + SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread,NULL); + if ( thread == NULL ) { + fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError()); + waiting=false; + return; + } } diff --git a/Source/Game.h b/Source/Game.h index 32dbced..ec30c86 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -61,100 +61,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define NB_CAMPAIGN_MENU_ITEM 7 -extern GLuint rabbittexture; - -struct TextureInfo; - -class CampaignLevel -{ -private: - int width; - struct Position - { - int x; - int y; - }; -public: - std::string mapname; - std::string description; - int choosenext; - /* - 0 = Immediately load next level at the end of this one. - 1 = Go back to the world map. - 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated. - */ - //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't. - std::vector nextlevel; - Position location; - - CampaignLevel() : width(10) { - choosenext = 1; - location.x = 0; - location.y = 0; - } - - int getStartX() { - return 30+120+location.x*400/512; - } - - int getStartY() { - return 30+30+(512-location.y)*400/512; - } - - int getEndX() { - return getStartX()+width; - } - - int getEndY() { - return getStartY()+width; - } - - XYZ getCenter() { - XYZ center; - center.x=getStartX()+width/2; - center.y=getStartY()+width/2; - return center; - } - - int getWidth() { - return width; - } - - istream& operator<< (istream& is) { - is.ignore(256,':'); - is.ignore(256,':'); - is.ignore(256,' '); - is >> mapname; - is.ignore(256,':'); - is >> description; - for(int pos = description.find('_');pos!=string::npos;pos = description.find('_',pos)) { - description.replace(pos,1,1,' '); - } - is.ignore(256,':'); - is >> choosenext; - is.ignore(256,':'); - int numnext,next; - is >> numnext; - for(int j=0;j> next; - nextlevel.push_back(next-1); - } - is.ignore(256,':'); - is >> location.x; - is.ignore(256,':'); - is >> location.y; - return is; - } - - friend istream& operator>> (istream& is, CampaignLevel& cl) { - return cl << is; - } -}; - -namespace Game -{ - //public: +namespace Game { extern GLuint terraintexture; extern GLuint terraintexture2; extern GLuint terraintexture3; @@ -170,14 +77,6 @@ namespace Game extern int selected; extern int keyselect; - extern int indemo; - - extern bool won; - - extern bool entername; - - extern char registrationname[256]; - extern float registrationnumber; extern int newdetail; extern int newscreenwidth; @@ -187,13 +86,10 @@ namespace Game extern float deltah,deltav; extern int mousecoordh,mousecoordv; extern int oldmousecoordh,oldmousecoordv; - extern float rotation,rotation2; - extern SkyBox skybox; + extern float yaw,pitch; + extern SkyBox *skybox; extern bool cameramode; - extern int olddrawmode; - extern int drawmode; extern bool firstload; - extern bool oldbutton; extern float leveltime; extern float loadtime; @@ -202,7 +98,7 @@ namespace Game extern XYZ hawkcoords; extern XYZ realhawkcoords; extern GLuint hawktexture; - extern float hawkrotation; + extern float hawkyaw; extern float hawkcalldelay; extern Model eye; @@ -210,41 +106,22 @@ namespace Game extern Model cornea; extern bool stealthloading; + extern int loading; - extern std::vector campaignlevels; - extern int whichchoice; - extern int actuallevel; - extern bool winhotspot; - extern bool windialogue; - - extern bool minimap; - - extern int musictype,oldmusictype,oldoldmusictype; - extern bool realthreat; - - extern Model rabbit; - extern XYZ rabbitcoords; + extern int musictype; extern XYZ mapcenter; extern float mapradius; - extern Text* text; + extern Text *text; extern float fps; - extern XYZ cameraloc; - extern float cameradist; - - extern int drawtoggle; - extern bool editorenabled; extern int editortype; extern float editorsize; - extern float editorrotation; - extern float editorrotation2; - - extern float brightness; + extern float editoryaw; + extern float editorpitch; - extern int quit; extern int tryquit; extern XYZ pathpoint[30]; @@ -258,7 +135,6 @@ namespace Game extern int numchallengelevels; extern bool console; - extern int archiveselected; extern char consoletext[15][256]; extern int consolechars[15]; extern bool chatting; @@ -268,81 +144,43 @@ namespace Game extern float displayblinkdelay; extern bool displayblink; extern int displayselected; - extern bool consolekeydown; extern float consoleblinkdelay; extern bool consoleblink; extern int consoleselected; - extern bool autocam; + + extern int oldenvironment; + extern int targetlevel; + extern float changedelay; + + extern bool waiting; + extern Account* accountactive; extern unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; extern unsigned short consolekey; - extern bool oldattackkey; + + void newGame(); + void deleteGame(); void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha); void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize); - void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize); - bool AddClothes(const char *fileName, GLubyte *array); void InitGame(); - void LoadScreenTexture(); void LoadStuff(); void LoadingScreen(); - void LoadCampaign(); - std::vector ListCampaigns(); - void FadeLoadingScreen(float howmuch); - void Dispose(); int DrawGLScene(StereoSide side); - void DrawMenu(); - void DrawGL(); void LoadMenu(); - //factored from Tick() -sf17k - void MenuTick(); - void doTutorial(); - void doDebugKeys(); - void doJumpReversals(); - void doAerialAcrobatics(); - void doAttacks(); - void doPlayerCollisions(); - void doAI(int i); - //end factored void Tick(); void TickOnce(); void TickOnceAfter(); void SetUpLighting(); - void Loadlevel(int which); - void Loadlevel(const char *name); - void Setenvironment(int which); GLvoid ReSizeGLScene(float fov, float near); - int findPathDist(int start,int end); int checkcollide(XYZ startpoint, XYZ endpoint); int checkcollide(XYZ startpoint, XYZ endpoint, int what); - extern int loading; - extern float talkdelay; void fireSound(int sound=fireendsound); void setKeySelected(); - extern int numboundaries; - extern XYZ boundary[360]; - - extern int whichlevel; - extern int oldenvironment; - extern int targetlevel; - extern float changedelay; - - extern float musicvolume[4]; - extern float oldmusicvolume[4]; - extern int musicselected; - extern int change; - void newGame(); - void deleteGame(); - extern bool waiting; - //private: - int setKeySelected_thread(void*); - int thread(void *data); void inputText(char* str, int* charselected, int* nb_chars); void flash(); - //bool waiting; - extern Account* accountactive; } #ifndef __forceinline @@ -377,10 +215,10 @@ extern XYZ dialoguecamera[max_dialogues][max_dialoguelength]; extern XYZ participantlocation[max_dialogues][10]; extern int participantfocus[max_dialogues][max_dialoguelength]; extern int participantaction[max_dialogues][max_dialoguelength]; -extern float participantrotation[max_dialogues][10]; +extern float participantyaw[max_dialogues][10]; extern XYZ participantfacing[max_dialogues][max_dialoguelength][10]; -extern float dialoguecamerarotation[max_dialogues][max_dialoguelength]; -extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength]; +extern float dialoguecamerayaw[max_dialogues][max_dialoguelength]; +extern float dialoguecamerapitch[max_dialogues][max_dialoguelength]; extern int indialogue; extern int whichdialogue; extern int directing; diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 09bdb16..11a9401 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -25,10 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Awards.h" #include "Menu.h" -#include - -using namespace std; - extern XYZ viewer; extern int environment; extern float texscale; @@ -111,6 +107,15 @@ extern bool gamestarted; extern bool showdamagebar; + + +int drawtoggle = 0; +int numboundaries = 0; +XYZ boundary[360]; +int change = 0; + + + enum drawmodes { normalmode, motionblurmode, radialzoommode, realmotionblurmode, doublevisionmode, glowmode, @@ -123,9 +128,12 @@ void Game::flash() { // shouldn't be that way, these should be attributes and Pe flashamount=1; flashdelay=1; } + +void DrawMenu(); + /*********************> DrawGLScene() <*****/ int Game::DrawGLScene(StereoSide side) -{ +{ static float texcoordwidth,texcoordheight; static float texviewwidth, texviewheight; static int i,j,k,l; @@ -136,6 +144,7 @@ int Game::DrawGLScene(StereoSide side) static char string[256]=""; static char string2[256]=""; static char string3[256]=""; + static int drawmode = 0; if ( stereomode == stereoAnaglyph ) { switch(side) { @@ -171,7 +180,7 @@ int Game::DrawGLScene(StereoSide side) static int changed; changed=0; - olddrawmode=drawmode; + int olddrawmode=drawmode; if(ismotionblur&&!loading){ if((findLengthfast(&player[0].velocity)>200)&&velocityblur&&!cameramode){ drawmode=motionblurmode; @@ -251,7 +260,7 @@ int Game::DrawGLScene(StereoSide side) static XYZ terrainlight; static float distance; if(drawmode==normalmode) - ReSizeGLScene(90,.1f); + Game::ReSizeGLScene(90,.1f); if(drawmode!=normalmode) glViewport(0,0,texviewwidth,texviewheight); glDepthFunc(GL_LEQUAL); @@ -274,12 +283,12 @@ int Game::DrawGLScene(StereoSide side) //shake glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1); //sway - glRotatef(rotation2+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0); - glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0); + glRotatef(pitch+sin(woozy/2)*(player[0].damage/player[0].damagetolerance)*5,1,0,0); + glRotatef(yaw+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0); } if(cameramode||freeze||winfreeze){ - glRotatef(rotation2,1,0,0); - glRotatef(rotation,0,1,0); + glRotatef(pitch,1,0,0); + glRotatef(yaw,0,1,0); } if(environment==desertenvironment){ @@ -305,7 +314,7 @@ int Game::DrawGLScene(StereoSide side) glRotatef((float)(abs(Random()%100))/1000,1,0,0); glRotatef((float)(abs(Random()%100))/1000,0,1,0); } - skybox.draw(); + skybox->draw(); glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0); glPopMatrix(); glTranslatef(-viewer.x,-viewer.y,-viewer.z); @@ -320,7 +329,7 @@ int Game::DrawGLScene(StereoSide side) if(frustum.SphereInFrustum(player[k].coords.x,player[k].coords.y+player[k].scale*3,player[k].coords.z,player[k].scale*7)&&player[k].occluded<25) for(i=0;i=1) glDisable(GL_BLEND); if(distance>=.5){ - checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords; + checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords; checkpoint.y+=1; if(!player[k].occluded==0) i=checkcollide(viewer,checkpoint,player[k].lastoccluded); @@ -479,7 +488,7 @@ int Game::DrawGLScene(StereoSide side) glDisable(GL_LIGHTING); glEnable(GL_BLEND); glTranslatef(hawkcoords.x,hawkcoords.y,hawkcoords.z); - glRotatef(hawkrotation,0,1,0); + glRotatef(hawkyaw,0,1,0); glTranslatef(25,0,0); distance=findDistancefast(&viewer,&realhawkcoords)*1.2; glColor4f(light.color[0],light.color[1],light.color[2],(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance); @@ -505,7 +514,7 @@ int Game::DrawGLScene(StereoSide side) if(distance>=1) glDisable(GL_BLEND); if(distance>=.5){ - checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords; + checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].yaw,0)*player[k].scale+player[k].coords; checkpoint.y+=1; if(!player[k].occluded==0) i=checkcollide(viewer,checkpoint,player[k].lastoccluded); @@ -950,8 +959,8 @@ int Game::DrawGLScene(StereoSide side) whichdialogue=hotspottype[closest]-20; for(j=0;jglPrint(10,30,string,0,.8,1024,768); - sprintf (string, "Name: %s", registrationname); - text->glPrint(10,260,string,0,.8,1024,768); - - if(editorenabled) sprintf (string, "Map editor enabled."); else @@ -1215,11 +1220,11 @@ int Game::DrawGLScene(StereoSide side) if(editorenabled){ sprintf (string, "Object size: %f",editorsize); text->glPrint(10,75,string,0,.8,1024,768); - if(editorrotation>=0)sprintf (string, "Object rotation: %f",editorrotation); - else sprintf (string, "Object rotation: Random"); + if(editoryaw>=0)sprintf (string, "Object yaw: %f",editoryaw); + else sprintf (string, "Object yaw: Random"); text->glPrint(10,90,string,0,.8,1024,768); - if(editorrotation2>=0)sprintf (string, "Object rotation2: %f",editorrotation2); - else sprintf (string, "Object rotation2: Random"); + if(editorpitch>=0)sprintf (string, "Object pitch: %f",editorpitch); + else sprintf (string, "Object pitch: Random"); text->glPrint(10,105,string,0,.8,1024,768); sprintf (string, "Object type: %d",editortype); text->glPrint(10,120,string,0,.8,1024,768); @@ -1413,7 +1418,7 @@ int Game::DrawGLScene(StereoSide side) } } - if(minimap&&indialogue==-1){ + if(difficulty<2&&indialogue==-1){ // minimap float mapviewdist = 20000; glDisable(GL_DEPTH_TEST); @@ -1491,7 +1496,7 @@ int Game::DrawGLScene(StereoSide side) glPushMatrix(); glScalef(1/(1/radius*256*terrain.scale*.4),1/(1/radius*256*terrain.scale*.4),1); glPopMatrix(); - glRotatef(player[0].lookrotation*-1+180,0,0,1); + glRotatef(player[0].lookyaw*-1+180,0,0,1); glTranslatef(-(center.x/terrain.scale/256*-2+1),(center.z/terrain.scale/256*-2+1),0); for(i=0;i Game::ListCampaigns() { - DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns")); - struct dirent *campaign = NULL; - if(!campaigns) { - perror("Problem while loading campaigns"); - cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl; - exit(EXIT_FAILURE); - } - vector campaignNames; - while ((campaign = readdir(campaigns)) != NULL) { - string name(campaign->d_name); - if(name.length()<5) - continue; - if(!name.compare(name.length()-4,4,".txt")) { - campaignNames.push_back(name.substr(0,name.length()-4)); - } - } - closedir(campaigns); - return campaignNames; -} - -void Game::LoadCampaign() { - if(!accountactive) - return; - ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str())); - ipstream.ignore(256,':'); - int numlevels; - ipstream >> numlevels; - campaignlevels.clear(); - for(int i=0;i> cl; - campaignlevels.push_back(cl); - } - ipstream.close(); - - ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str())); - if(test.good()) { - LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0); - } else { - LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); - } - - if(accountactive->getCampaignChoicesMade()==0) { - accountactive->setCampaignScore(0); - accountactive->resetFasttime(); - } -} - -void Game::DrawMenu() { +void DrawMenu() { // !!! FIXME: hack: clamp framerate in menu so text input works correctly on fast systems. SDL_Delay(15); glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - ReSizeGLScene(90,.1f); + Game::ReSizeGLScene(90,.1f); //draw menu background glClear(GL_DEPTH_BUFFER_BIT); @@ -2122,7 +2078,7 @@ void Game::DrawMenu() { glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, Mainmenuitems[4]); + glBindTexture( GL_TEXTURE_2D, Game::Mainmenuitems[4]); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(-1,-1,0); @@ -2175,14 +2131,14 @@ void Game::DrawMenu() { glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glPopMatrix(); - if(!waiting) { // hide the cursor while waiting for a key + if(!Game::waiting) { // hide the cursor while waiting for a key glPushMatrix(); - glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0); + glTranslatef(Game::mousecoordh-screenwidth/2,Game::mousecoordv*-1+screenheight/2,0); glScalef((float)screenwidth/64,(float)screenwidth/64,1); glTranslatef(1,-1,0); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); - glBindTexture( GL_TEXTURE_2D, cursortexture); + glBindTexture( GL_TEXTURE_2D, Game::cursortexture); glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index f6fd203..ee82765 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -28,7 +28,6 @@ extern float screenwidth,screenheight; extern float viewdistance; extern XYZ viewer; extern XYZ lightlocation; -extern float lightambient[3],lightbrightness[3]; extern float fadestart; extern float texscale; extern float gravity; @@ -79,8 +78,8 @@ extern int dialogueboxsound[20][20]; extern char dialoguetext[20][20][128]; extern char dialoguename[20][20][64]; extern XYZ dialoguecamera[20][20]; -extern float dialoguecamerarotation[20][20]; -extern float dialoguecamerarotation2[20][20]; +extern float dialoguecamerayaw[20][20]; +extern float dialoguecamerapitch[20][20]; extern int indialogue; extern int whichdialogue; extern float dialoguetime; @@ -98,16 +97,16 @@ void LOG(const std::string &fmt, ...) // !!! FIXME: write me. } -void Game::Dispose() +void Dispose() { LOGFUNC; - if(endgame==2){ - accountactive->endGame(); - endgame=0; + if(Game::endgame==2){ + Game::accountactive->endGame(); + Game::endgame=0; } - Account::saveFile(":Data:Users", accountactive); + Account::saveFile(":Data:Users", Game::accountactive); //textures.clear(); @@ -133,6 +132,35 @@ void Game::Dispose() #endif } +void Game::newGame(){ + text = new Text(); + skybox = new SkyBox(); +} + +void Game::deleteGame(){ + if(skybox) + delete skybox; + if(text) + delete text; + for(int i=0;i<10;i++){ + if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] ); + } + glDeleteTextures( 1, &cursortexture ); + glDeleteTextures( 1, &Maparrowtexture ); + glDeleteTextures( 1, &Mapboxtexture ); + glDeleteTextures( 1, &Mapcircletexture ); + glDeleteTextures( 1, &terraintexture ); + glDeleteTextures( 1, &terraintexture2 ); + if(screentexture>0)glDeleteTextures( 1, &screentexture ); + if(screentexture2>0)glDeleteTextures( 1, &screentexture2 ); + glDeleteTextures( 1, &hawktexture ); + glDeleteTextures( 1, &logotexture ); + glDeleteTextures( 1, &loadscreentexture ); + + Dispose(); +} + + void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) { *textureid = Texture::Load(fileName,mipmap,hasalpha); @@ -142,7 +170,7 @@ void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,G *textureid = Texture::Load(fileName,mipmap,false,array,skinsize); } -void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) +void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) { int i; int bytesPerPixel; @@ -181,53 +209,6 @@ void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte } } -bool Game::AddClothes(const char *fileName, GLubyte *array) -{ - int i; - int bytesPerPixel; - - LOGFUNC; - - //upload_image( fileName ); - //LoadTGA( fileName ); - //Load Image - unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); - //Load Image - bool opened; - opened=upload_image( fileNamep ,1); - - float alphanum; - //Is it valid? - if(opened){ - if(tintr>1)tintr=1; - if(tintg>1)tintg=1; - if(tintb>1)tintb=1; - - if(tintr<0)tintr=0; - if(tintg<0)tintg=0; - if(tintb<0)tintb=0; - - bytesPerPixel=texture.bpp/8; - - int tempnum=0; - alphanum=255; - for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){ - if(bytesPerPixel==3)alphanum=255; - else if((i+1)%4==0)alphanum=texture.data[i]; - //alphanum/=2; - if((i+1)%4||bytesPerPixel==3){ - if((i%4)==0)texture.data[i]*=tintr; - if((i%4)==1)texture.data[i]*=tintg; - if((i%4)==2)texture.data[i]*=tintb; - array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255); - tempnum++; - } - } - } - else return 0; - return 1; -} //***************> ResizeGLScene() <******/ @@ -464,7 +445,7 @@ void Game::LoadingScreen() } } -void Game::FadeLoadingScreen(float howmuch) +void FadeLoadingScreen(float howmuch) { static float loadprogress; @@ -549,8 +530,6 @@ void Game::InitGame() LOGFUNC; - autocam=0; - numchallengelevels=14; accountactive=Account::loadFile(":Data:Users"); @@ -741,22 +720,23 @@ void Game::InitGame() } -void Game::LoadScreenTexture() { +void LoadScreenTexture() { glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - if(!screentexture) - glGenTextures( 1, &screentexture ); + if(!Game::screentexture) + glGenTextures( 1, &Game::screentexture ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glEnable(GL_TEXTURE_2D); - glBindTexture( GL_TEXTURE_2D, screentexture); + glBindTexture( GL_TEXTURE_2D, Game::screentexture); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0); } +//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h void Game::LoadStuff() { static float temptexdetail; @@ -795,8 +775,6 @@ void Game::LoadStuff() viewdistdetail=2; viewdistance=50*megascale*viewdistdetail; - brightness=100; - if(detail==2){ texdetail=1; } @@ -881,8 +859,8 @@ void Game::LoadStuff() LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1); LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1); - rotation=0; - rotation2=0; + yaw=0; + pitch=0; ReSizeGLScene(90,.01); viewer=0; @@ -949,9 +927,6 @@ void Game::LoadStuff() firstload=0; - rabbitcoords=player[0].coords; - rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z); - loadAllAnimations(); //Fix knife stab, too lazy to do it manually XYZ moveamount; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 75d1395..99dab37 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include #include "Game.h" #include "openal_wrapper.h" #include "Settings.h" @@ -119,6 +120,7 @@ extern float damagedealt; extern int maptype; extern int editoractive; extern int editorpathtype; +extern TGAImageRec texture; extern float hostiletime; @@ -139,6 +141,95 @@ extern bool winfreeze; extern bool campaign; + + +void Loadlevel(int which); +void Loadlevel(const char *name); + + + +class CampaignLevel { +private: + int width; + struct Position { int x,y; }; +public: + std::string mapname; + std::string description; + int choosenext; + /* + 0 = Immediately load next level at the end of this one. + 1 = Go back to the world map. + 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated. + */ + //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't. + std::vector nextlevel; + Position location; + CampaignLevel() : width(10) { + choosenext = 1; + location.x = 0; + location.y = 0; + } + int getStartX() { return 30+120+location.x*400/512; } + int getStartY() { return 30+30+(512-location.y)*400/512; } + int getEndX() { return getStartX()+width; } + int getEndY() { return getStartY()+width; } + XYZ getCenter() { + XYZ center; + center.x=getStartX()+width/2; + center.y=getStartY()+width/2; + return center; + } + int getWidth() { return width; } + istream& operator<< (istream& is) { + is.ignore(256,':'); + is.ignore(256,':'); + is.ignore(256,' '); + is >> mapname; + is.ignore(256,':'); + is >> description; + for(int pos = description.find('_');pos!=string::npos;pos = description.find('_',pos)) { + description.replace(pos,1,1,' '); + } + is.ignore(256,':'); + is >> choosenext; + is.ignore(256,':'); + int numnext,next; + is >> numnext; + for(int j=0;j> next; + nextlevel.push_back(next-1); + } + is.ignore(256,':'); + is >> location.x; + is.ignore(256,':'); + is >> location.y; + return is; + } + friend istream& operator>> (istream& is, CampaignLevel& cl) { + return cl << is; + } +}; + +int indemo = 0; +bool won = false; +int entername = 0; +vector campaignlevels; +int whichchoice = 0; +int actuallevel = 0; +bool winhotspot = false; +bool windialogue = false; +bool realthreat = 0; +XYZ cameraloc; +float cameradist = 0; +bool oldattackkey = 0; +int whichlevel = 0; +float musicvolume[4] = {}; +float oldmusicvolume[4] = {}; +int musicselected = 0; + + + static const char *rabbitskin[] = { ":Data:Textures:Fur3.jpg", ":Data:Textures:Fur.jpg", @@ -189,10 +280,9 @@ static console_handler cmd_handlers[] = { -// added utility functions -sf17k ============================================================= +// utility functions -//TODO: this is incorrect but I'm afraid to change it and break something, -//probably causes quirky behavior that I might want to preserve +// TODO: this is slightly incorrect inline float roughDirection(XYZ vec){ Normalise(&vec); float angle=-asin(-vec.x)*180/M_PI; @@ -203,18 +293,14 @@ inline float roughDirection(XYZ vec){ inline float roughDirectionTo(XYZ start, XYZ end){ return roughDirection(end-start); } - -//TODO: gotta be a better way -inline float pitch(XYZ vec){ +inline float pitchOf(XYZ vec){ Normalise(&vec); return -asin(vec.y)*180/M_PI; } inline float pitchTo(XYZ start, XYZ end){ - return pitch(end-start); + return pitchOf(end-start); } - inline float sq(float n) { return n*n; } - inline float stepTowardf(float from, float to, float by){ if(fabs(from-to)to) return from-by; @@ -257,7 +343,47 @@ void playdialogueboxsound(){ emit_sound_at(sound, temppos); } -// end added utility functions ================================================================ +// ================================================================ + +bool AddClothes(const char *fileName, GLubyte *array) { + LOGFUNC; + //Load Image + unsigned char fileNamep[256]; + CopyCStringToPascal(fileName,fileNamep); + bool opened; + opened=upload_image( fileNamep ,1); + + float alphanum; + //Is it valid? + if(opened){ + if(tintr>1)tintr=1; + if(tintg>1)tintg=1; + if(tintb>1)tintb=1; + + if(tintr<0)tintr=0; + if(tintg<0)tintg=0; + if(tintb<0)tintb=0; + + int bytesPerPixel=texture.bpp/8; + + int tempnum=0; + alphanum=255; + for(int i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){ + if(bytesPerPixel==3)alphanum=255; + else if((i+1)%4==0)alphanum=texture.data[i]; + //alphanum/=2; + if((i+1)%4||bytesPerPixel==3){ + if((i%4)==0)texture.data[i]*=tintr; + if((i%4)==1)texture.data[i]*=tintg; + if((i%4)==2)texture.data[i]*=tintb; + array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255); + tempnum++; + } + } + } + else return 0; + return 1; +} @@ -288,7 +414,7 @@ static void ch_save(const char *args){ fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb); fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb); fpackf(tfile, "Bf Bf Bf Bf Bf Bi", player[0].coords.x, player[0].coords.y, player[0].coords.z, - player[0].rotation, player[0].targetrotation, player[0].num_weapons); + player[0].yaw, player[0].targetyaw, player[0].num_weapons); if(player[0].num_weapons>0&&player[0].num_weapons<5) for(int j=0;j1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(snow):Front.jpg", + skybox->load( ":Data:Textures:Skybox(snow):Front.jpg", ":Data:Textures:Skybox(snow):Left.jpg", ":Data:Textures:Skybox(snow):Back.jpg", ":Data:Textures:Skybox(snow):Right.jpg", @@ -1333,7 +1459,7 @@ void Game::Setenvironment(int which) temptexdetail=texdetail; if(texdetail>1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(sand):Front.jpg", + skybox->load( ":Data:Textures:Skybox(sand):Front.jpg", ":Data:Textures:Skybox(sand):Left.jpg", ":Data:Textures:Skybox(sand):Back.jpg", ":Data:Textures:Skybox(sand):Right.jpg", @@ -1370,7 +1496,7 @@ void Game::Setenvironment(int which) temptexdetail=texdetail; if(texdetail>1)texdetail=4; - skybox.load( ":Data:Textures:Skybox(grass):Front.jpg", + skybox->load( ":Data:Textures:Skybox(grass):Front.jpg", ":Data:Textures:Skybox(grass):Left.jpg", ":Data:Textures:Skybox(grass):Back.jpg", ":Data:Textures:Skybox(grass):Right.jpg", @@ -1388,7 +1514,56 @@ void Game::Setenvironment(int which) texdetail=temptexdetail; } -void Game::Loadlevel(int which) { +void LoadCampaign() { + if(!accountactive) + return; + ifstream ipstream(ConvertFileName((":Data:Campaigns:"+accountactive->getCurrentCampaign()+".txt").c_str())); + ipstream.ignore(256,':'); + int numlevels; + ipstream >> numlevels; + campaignlevels.clear(); + for(int i=0;i> cl; + campaignlevels.push_back(cl); + } + ipstream.close(); + + ifstream test(ConvertFileName((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str())); + if(test.good()) { + LoadTexture((":Data:Textures:"+accountactive->getCurrentCampaign()+":World.png").c_str(),&Mainmenuitems[7],0,0); + } else { + LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); + } + + if(accountactive->getCampaignChoicesMade()==0) { + accountactive->setCampaignScore(0); + accountactive->resetFasttime(); + } +} + +vector ListCampaigns() { + DIR *campaigns = opendir(ConvertFileName(":Data:Campaigns")); + struct dirent *campaign = NULL; + if(!campaigns) { + perror("Problem while loading campaigns"); + cerr << "campaign folder was : " << ConvertFileName(":Data:Campaigns") << endl; + exit(EXIT_FAILURE); + } + vector campaignNames; + while ((campaign = readdir(campaigns)) != NULL) { + string name(campaign->d_name); + if(name.length()<5) + continue; + if(!name.compare(name.length()-4,4,".txt")) { + campaignNames.push_back(name.substr(0,name.length()-4)); + } + } + closedir(campaigns); + return campaignNames; +} + +void Loadlevel(int which) { stealthloading=0; whichlevel=which; @@ -1403,7 +1578,7 @@ void Game::Loadlevel(int which) { Loadlevel("mapsave"); } -void Game::Loadlevel(const char *name) { +void Loadlevel(const char *name) { int templength; float lamefloat; static const char *pfx = ":Data:Maps:"; @@ -1474,11 +1649,6 @@ void Game::Loadlevel(const char *name) { if(accountactive) difficulty=accountactive->getDifficulty(); - if(difficulty!=2) - minimap=1; - else - minimap=0; - numhotspots=0; currenthotspot=-1; bonustime=1; @@ -1578,7 +1748,7 @@ void Game::Loadlevel(const char *name) { skyboxlightb=skyboxb; } if(!stealthloading) - funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons); + funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].yaw,&player[0].targetyaw, &player[0].num_weapons); if(stealthloading) funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons); player[0].originalcoords=player[0].coords; @@ -1619,7 +1789,7 @@ void Game::Loadlevel(const char *name) { funpackf(tfile, "Bi", &dialoguetype[k]); for(int l=0;l<10;l++){ funpackf(tfile, "Bf Bf Bf", &participantlocation[k][l].x, &participantlocation[k][l].y, &participantlocation[k][l].z); - funpackf(tfile, "Bf", &participantrotation[k][l]); + funpackf(tfile, "Bf", &participantyaw[k][l]); } for(int l=0;l=12) - funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation); + funpackf(tfile, "Bf",&player[i-howmanyremoved].yaw); else - player[i-howmanyremoved].rotation=0; - player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation; + player[i-howmanyremoved].yaw=0; + player[i-howmanyremoved].targetyaw=player[i-howmanyremoved].yaw; if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){ removeanother=1; howmanyremoved++; @@ -1848,7 +2018,7 @@ void Game::Loadlevel(const char *name) { int j=objects.numobjects; objects.numobjects=0; for(int i=0;itutorialmaxtime){ tutorialstage++; tutorialsuccess=0; @@ -2142,7 +2312,7 @@ void Game::doTutorial(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords; + if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -2373,7 +2543,7 @@ void Game::doTutorial(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords; + if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -2460,7 +2630,7 @@ void Game::doTutorial(){ } } -void Game::doDebugKeys(){ +void doDebugKeys(){ float headprop,bodyprop,armprop,legprop; if(debugmode){ if(Input::isKeyPressed(SDLK_h)){ @@ -2536,8 +2706,8 @@ void Game::doDebugKeys(){ closest=i; } } - player[closest].rotation+=multiplier*50; - player[closest].targetrotation=player[closest].rotation; + player[closest].yaw+=multiplier*50; + player[closest].targetyaw=player[closest].yaw; } @@ -2690,7 +2860,7 @@ void Game::doDebugKeys(){ if(player[closest].skeleton.free) flatvelocity2=headjoint.velocity; if(!player[closest].skeleton.free) - flatfacing2=DoRotation(DoRotation(DoRotation(headjoint.position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].rotation,0)*player[closest].scale+player[closest].coords; + flatfacing2=DoRotation(DoRotation(DoRotation(headjoint.position,0,0,player[closest].tilt),player[closest].tilt2,0,0),0,player[closest].yaw,0)*player[closest].scale+player[closest].coords; if(player[closest].skeleton.free) flatfacing2=headjoint.position*player[closest].scale+player[closest].coords; flatvelocity2.x+=(float)(abs(Random()%100)-50)/10; @@ -2742,7 +2912,7 @@ void Game::doDebugKeys(){ for(int i=0;iterrain.getHeight(player[k].coords.x,player[k].coords.z)-.1) player[k].coords.y=terrain.getHeight(player[k].coords.x,player[k].coords.z); - if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){ + if(player[k].SphereCheck(&lowpoint, 1.3, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i])!=-1){ flatfacing=lowpoint-player[k].coords; player[k].coords=lowpoint; player[k].coords.y-=1.3; @@ -3401,19 +3571,19 @@ void Game::doAerialAcrobatics(){ player[k].jumpkeydown){ lowpointtarget=lowpoint+DoRotation(player[k].facing,0,-90,0)*1.5; XYZ tempcoords1=lowpoint; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpleftanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0) pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; if(lowpointtarget.z<0) - player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0) numwallflipped++; } @@ -3421,52 +3591,52 @@ void Game::doAerialAcrobatics(){ { lowpoint=tempcoords1; lowpointtarget=lowpoint+DoRotation(player[k].facing,0,90,0)*1.5; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumprightanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } else { lowpoint=tempcoords1; lowpointtarget=lowpoint+player[k].facing*2; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpbackanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } else { lowpoint=tempcoords1; lowpointtarget=lowpoint-player[k].facing*2; - whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheck(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1&&fabs(objects.model[i].facenormals[whichhit].y)<.3){ player[k].setAnimation(walljumpfrontanim); emit_sound_at(movewhooshsound, player[k].coords); if(k==0)pause_sound(whooshsound); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; - if(lowpointtarget.z<0)player[k].rotation=180-player[k].rotation; - player[k].rotation+=180; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; + if(lowpointtarget.z<0)player[k].yaw=180-player[k].yaw; + player[k].yaw+=180; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; if(k==0)numwallflipped++; } } @@ -3479,7 +3649,7 @@ void Game::doAerialAcrobatics(){ lowpoint2=player[k].coords; lowpoint=player[k].coords; lowpoint.y+=2; - if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.rotation[i])!=-1){ + if(objects.model[i].LineCheck(&lowpoint,&lowpoint2,&colpoint,&objects.position[i],&objects.yaw[i])!=-1){ player[k].coords=colpoint; player[k].collide=1; tempcollide=1; @@ -3527,7 +3697,7 @@ void Game::doAerialAcrobatics(){ lowpoint=player[k].coords; lowpoint.y+=1.35; if(objects.type[i]!=rocktype) - if(player[k].SphereCheck(&lowpoint,1.33,&colpoint,&objects.position[i],&objects.rotation[i],&objects.model[i])!=-1){ + if(player[k].SphereCheck(&lowpoint,1.33,&colpoint,&objects.position[i],&objects.yaw[i],&objects.model[i])!=-1){ if(player[k].targetanimation!=jumpupanim&& player[k].targetanimation!=jumpdownanim&& player[k].onterrain) @@ -3543,14 +3713,14 @@ void Game::doAerialAcrobatics(){ player[k].targetanimation==jumpupanim|| player[k].targetanimation==jumpdownanim)){ lowpoint=player[k].coords; - objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.rotation[i]); + objects.model[i].SphereCheckPossible(&lowpoint, 1.5, &objects.position[i], &objects.yaw[i]); lowpoint=player[k].coords; lowpoint.y+=.05; facing=0; facing.z=-1; - facing=DoRotation(facing,0,player[k].targetrotation+180,0); + facing=DoRotation(facing,0,player[k].targetyaw+180,0); lowpointtarget=lowpoint+facing*1.4; - whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(whichhit!=-1){ lowpoint=player[k].coords; lowpoint.y+=.1; @@ -3579,7 +3749,7 @@ void Game::doAerialAcrobatics(){ lowpointtarget6.y+=45/13; lowpointtarget6+=facing*.6; lowpointtarget7.y+=90/13; - whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.rotation[i]); + whichhit=objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget,&colpoint,&objects.position[i],&objects.yaw[i]); if(objects.friction[i]>.5) if(whichhit!=-1){ if(whichhit!=-1&&player[k].targetanimation!=jumpupanim&&player[k].targetanimation!=jumpdownanim) @@ -3587,28 +3757,28 @@ void Game::doAerialAcrobatics(){ if(checkcollide(lowpoint7,lowpointtarget7)==-1) if(checkcollide(lowpoint6,lowpointtarget6)==-1) if( objects.model[i].LineCheckPossible(&lowpoint2,&lowpointtarget2, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint3,&lowpointtarget3, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint4,&lowpointtarget4, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1&& + &colpoint,&objects.position[i],&objects.yaw[i])!=-1&& objects.model[i].LineCheckPossible(&lowpoint5,&lowpointtarget5, - &colpoint,&objects.position[i],&objects.rotation[i])!=-1) + &colpoint,&objects.position[i],&objects.yaw[i])!=-1) for(int j=0;j<45;j++){ lowpoint=player[k].coords; lowpoint.y+=(float)j/13; lowpointtarget=lowpoint+facing*1.4; if(objects.model[i].LineCheckPossible(&lowpoint,&lowpointtarget, - &colpoint2,&objects.position[i],&objects.rotation[i])==-1){ + &colpoint2,&objects.position[i],&objects.yaw[i])==-1){ if(j<=6||j<=25&&player[k].targetanimation==jumpdownanim) break; if(player[k].targetanimation==jumpupanim||player[k].targetanimation==jumpdownanim){ - lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0); + lowpoint=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[k],0); lowpoint=player[k].coords; lowpoint.y+=(float)j/13; lowpointtarget=lowpoint+facing*1.3; flatfacing=player[k].coords; - player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[k],0)*.01; + player[k].coords=colpoint-DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[k],0)*.01; player[k].coords.y=lowpointtarget.y-.07; player[k].currentoffset=(flatfacing-player[k].coords)/player[k].scale; @@ -3619,12 +3789,12 @@ void Game::doAerialAcrobatics(){ } emit_sound_at(jumpsound, player[k].coords, 128.); - lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.rotation[i],0); - player[k].rotation=-asin(0-lowpointtarget.x)*180/M_PI; + lowpointtarget=DoRotation(objects.model[i].facenormals[whichhit],0,objects.yaw[i],0); + player[k].yaw=-asin(0-lowpointtarget.x)*180/M_PI; if(lowpointtarget.z<0) - player[k].rotation=180-player[k].rotation; - player[k].targetrotation=player[k].rotation; - player[k].lowrotation=player[k].rotation; + player[k].yaw=180-player[k].yaw; + player[k].targetyaw=player[k].yaw; + player[k].lowyaw=player[k].yaw; //player[k].velocity=lowpointtarget*.03; player[k].velocity=0; @@ -3685,7 +3855,7 @@ void Game::doAerialAcrobatics(){ } } -void Game::doAttacks(){ +void doAttacks(){ static XYZ relative; static int randattack; static bool playerrealattackkeydown=0; @@ -3747,19 +3917,19 @@ void Game::doAttacks(){ player[i].targetanimation==staffspinhitanim) if(findDistancefast(&player[k].coords,&player[i].coords)<6.5&&!player[i].skeleton.free){ player[k].setAnimation(dodgebackanim); - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); } } if(player[k].targetanimation!=dodgebackanim){ if(k==0)numflipped++; player[k].setAnimation(backhandspringanim); - player[k].targetrotation=-rotation+180; + player[k].targetyaw=-yaw+180; if(player[k].leftkeydown) - player[k].targetrotation-=45; + player[k].targetyaw-=45; if(player[k].rightkeydown) - player[k].targetrotation+=45; - player[k].rotation=player[k].targetrotation; + player[k].targetyaw+=45; + player[k].yaw=player[k].targetyaw; player[k].jumppower-=2; } } @@ -3995,9 +4165,9 @@ void Game::doAttacks(){ player[k].targetframe=player[i].targetframe; player[k].target=player[i].target; player[k].velocity=0; - player[k].targetrotation=player[i].rotation; - player[k].rotation=player[i].rotation; - player[i].targetrotation=player[i].rotation; + player[k].targetyaw=player[i].yaw; + player[k].yaw=player[i].yaw; + player[i].targetyaw=player[i].yaw; } } if(animation[player[k].targetanimation].attack==normalattack&& @@ -4007,7 +4177,7 @@ void Game::doAttacks(){ player[k].targetframe=0; player[k].target=0; - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); player[k].lastattack3=player[k].lastattack2; player[k].lastattack2=player[k].lastattack; @@ -4016,7 +4186,7 @@ void Game::doAttacks(){ if(player[k].targetanimation==knifefollowanim&& player[k].victim==&player[i]){ oldattackkey=1; - player[k].targetrotation=roughDirectionTo(player[k].coords,player[i].coords); + player[k].targetyaw=roughDirectionTo(player[k].coords,player[i].coords); player[k].targettilt2=pitchTo(player[k].coords,player[i].coords); player[k].victim=&player[i]; player[k].hasvictim=1; @@ -4037,10 +4207,10 @@ void Game::doAttacks(){ player[k].velocity=0; player[k].oldcoords=player[k].coords; player[i].coords=player[k].coords; - player[i].targetrotation=player[k].targetrotation; - player[i].rotation=player[k].targetrotation; - player[k].rotation=player[k].targetrotation; - player[i].rotation=player[k].targetrotation; + player[i].targetyaw=player[k].targetyaw; + player[i].yaw=player[k].targetyaw; + player[k].yaw=player[k].targetyaw; + player[i].yaw=player[k].targetyaw; } } } @@ -4148,11 +4318,11 @@ void Game::doAttacks(){ player[i].getJointFor(neck).position)/2* player[i].scale; } - player[k].targetrotation=roughDirectionTo(player[k].coords,targetpoint); + player[k].targetyaw=roughDirectionTo(player[k].coords,targetpoint); player[k].targettilt2=pitchTo(player[k].coords,targetpoint); if(player[k].targetanimation==crouchstabanim||player[k].targetanimation==swordgroundstabanim){ - player[k].targetrotation+=(float)(abs(Random()%100)-50)/4; + player[k].targetyaw+=(float)(abs(Random()%100)-50)/4; } if(player[k].targetanimation==staffgroundsmashanim) @@ -4163,7 +4333,7 @@ void Game::doAttacks(){ player[k].lastattack=player[k].targetanimation; if(player[k].targetanimation==swordgroundstabanim){ - player[k].targetrotation+=30; + player[k].targetyaw+=30; } } } @@ -4219,7 +4389,7 @@ void Game::doAttacks(){ } } -void Game::doPlayerCollisions(){ +void doPlayerCollisions(){ static XYZ rotatetarget; static float collisionradius; if(numplayers>1) @@ -4290,7 +4460,7 @@ void Game::doPlayerCollisions(){ player[0].coords.y=player[l].coords.y; player[l].velocity=player[0].velocity; player[l].skeleton.free=0; - player[l].rotation=0; + player[l].yaw=0; player[l].RagDoll(0); player[l].DoDamage(20); camerashake+=.3; @@ -4420,7 +4590,7 @@ void Game::doPlayerCollisions(){ } } -void Game::doAI(int i){ +void doAI(int i){ static bool connected; if(player[i].aitype!=playercontrolled&&indialogue==-1){ player[i].jumpclimb=0; @@ -4524,8 +4694,8 @@ void Game::doAI(int i){ } player[i].losupdatedelay-=multiplier; - player[i].targetrotation=roughDirectionTo(player[i].coords,pathpoint[player[i].targetpathfindpoint]); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,pathpoint[player[i].targetpathfindpoint]); + player[i].lookyaw=player[i].targetyaw; //reached target point if(findDistancefastflat(&player[i].coords,&pathpoint[player[i].targetpathfindpoint])<.6){ @@ -4557,7 +4727,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8 && !player[i].jumpkeydown && player[i].collided<.8) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); if(player[i].collided<1||player[i].targetanimation!=jumpupanim) player[i].jumpkeydown=0; @@ -4588,9 +4758,9 @@ void Game::doAI(int i){ if(normaldotproduct(player[i].facing,player[j].coords-player[i].coords)>0) if(player[j].coords.y1&&player[i].howactive==typeactive&&player[i].pausetime<=0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[i].waypoints[player[i].waypoint]); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[i].waypoints[player[i].waypoint]); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; if(findDistancefastflat(&player[i].coords,&player[i].waypoints[player[i].waypoint])<1){ @@ -4648,7 +4818,7 @@ void Game::doAI(int i){ if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4657,9 +4827,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist0) if((-1==checkcollide( - DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)* player[i].scale+player[i].coords, - DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)* + DoRotation(player[j].getJointFor(head).position,0,player[j].yaw,0)* player[j].scale+player[j].coords)&& !player[j].isWallJump())|| (player[j].targetanimation==hanganim&& @@ -4789,7 +4959,7 @@ void Game::doAI(int i){ if(j==-1){ player[i].velocity=0; player[i].setAnimation(player[i].getStop()); - player[i].targetrotation+=180; + player[i].targetyaw+=180; player[i].stunned=.5; //player[i].aitype=passivetype; player[i].aitype=pathfindtype; @@ -4806,8 +4976,8 @@ void Game::doAI(int i){ } //check out last seen location if(player[i].aiupdatedelay<0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[i].lastseen); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[i].lastseen); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -4827,7 +4997,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ - if(!player[i].avoidsomething)player[i].targetrotation+=90*(player[i].whichdirection*2-1); + if(!player[i].avoidsomething)player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4835,8 +5005,8 @@ void Game::doAI(int i){ rightpos = player[i].coords-DoRotation(player[i].facing,0,90,0); leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); - if(leftdist0) if((checkcollide( - DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)* + DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)* player[i].scale+player[i].coords, - DoRotation(player[0].getJointFor(head).position,0,player[0].rotation,0)* + DoRotation(player[0].getJointFor(head).position,0,player[0].yaw,0)* player[0].scale+player[0].coords)==-1)|| (player[0].targetanimation==hanganim&&normaldotproduct( player[0].facing,player[i].coords-player[0].coords)<0)){ @@ -4954,8 +5124,8 @@ void Game::doAI(int i){ //seek out ally if(player[i].ally>0){ - player[i].targetrotation=roughDirectionTo(player[i].coords,player[player[i].ally].coords); - player[i].lookrotation=player[i].targetrotation; + player[i].targetyaw=roughDirectionTo(player[i].coords,player[player[i].ally].coords); + player[i].lookyaw=player[i].targetyaw; player[i].aiupdatedelay=.05; player[i].forwardkeydown=1; @@ -4972,7 +5142,7 @@ void Game::doAI(int i){ if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -4981,9 +5151,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist.8&&!player[i].jumpkeydown&&player[i].collided<.8){ if(!player[i].avoidsomething) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); else{ XYZ leftpos,rightpos; float leftdist,rightdist; @@ -5059,9 +5229,9 @@ void Game::doAI(int i){ leftdist = findDistancefast(&leftpos, &player[i].avoidwhere); rightdist = findDistancefast(&rightpos, &player[i].avoidwhere); if(leftdist5&&(player[0].weaponactive==-1||player[i].weaponactive!=-1)) @@ -5246,7 +5416,7 @@ void Game::doAI(int i){ player[i].throwkeydown=0; if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8) - player[i].targetrotation+=90*(player[i].whichdirection*2-1); + player[i].targetyaw+=90*(player[i].whichdirection*2-1); //attack!!! if(Random()%2==0||player[i].weaponactive!=-1||player[i].creature==wolftype) player[i].attackkeydown=1; @@ -5355,7 +5525,7 @@ void Game::doAI(int i){ player[i].pause&&player[i].damage>player[i].superpermanentdamage){ if(player[i].pause) player[i].lastseentime=1; - player[i].targetrotation=player[i].rotation; + player[i].targetyaw=player[i].yaw; player[i].forwardkeydown=0; player[i].leftkeydown=0; player[i].backkeydown=0; @@ -5371,15 +5541,15 @@ void Game::doAI(int i){ facing=0; facing.z=-1; - XYZ flatfacing=DoRotation(facing,0,player[i].rotation+180,0); + XYZ flatfacing=DoRotation(facing,0,player[i].yaw+180,0); facing=flatfacing; if(player[i].aitype==attacktypecutoff){ - player[i].targetheadrotation=180-roughDirectionTo(player[i].coords,player[0].coords); - player[i].targetheadrotation2=pitchTo(player[i].coords,player[0].coords); + player[i].targetheadyaw=180-roughDirectionTo(player[i].coords,player[0].coords); + player[i].targetheadpitch=pitchTo(player[i].coords,player[0].coords); }else if(player[i].howactive>=typesleeping){ - player[i].targetheadrotation=player[i].targetrotation; - player[i].targetheadrotation2=0; + player[i].targetheadyaw=player[i].targetyaw; + player[i].targetheadpitch=0; }else{ if(player[i].interestdelay<=0){ player[i].interestdelay=.7+(float)(abs(Random()%100))/100; @@ -5389,8 +5559,8 @@ void Game::doAI(int i){ player[i].headtarget.y+=(float)(abs(Random()%200)-100)/300; player[i].headtarget+=player[i].facing*1.5; } - player[i].targetheadrotation=180-roughDirectionTo(player[i].coords,player[i].headtarget); - player[i].targetheadrotation2=pitchTo(player[i].coords,player[i].headtarget); + player[i].targetheadyaw=180-roughDirectionTo(player[i].coords,player[i].headtarget); + player[i].targetheadpitch=pitchTo(player[i].coords,player[i].headtarget); } } } @@ -5613,7 +5783,7 @@ void Game::LoadMenu(){ } } -void Game::MenuTick(){ +void MenuTick(){ //menu buttons selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight); @@ -5995,6 +6165,7 @@ void Game::MenuTick(){ displayselected=0; } entername=0; + LoadMenu(); } displayblinkdelay-=multiplier; @@ -6096,7 +6267,6 @@ void Game::Tick(){ LoadMenu(); } //escape key pressed - //TODO: there must be code somewhere else that handles clicking the Back button, merge it with this if(Input::isKeyPressed(SDLK_ESCAPE)&& (gameon||mainmenu==0||(mainmenu>=3&&mainmenu!=8&&!(mainmenu==7&&entername)))) { selected=-1; @@ -6193,7 +6363,6 @@ void Game::Tick(){ if(console&&!Input::isKeyDown(SDLK_LMETA)) { inputText(consoletext[0],&consoleselected,&consolechars[0]); if(!waiting) { - archiveselected=0; if(consolechars[0]>0) { consoletext[0][consolechars[0]]='\0'; cmd_dispatch(consoletext[0]); @@ -6250,10 +6419,11 @@ void Game::Tick(){ - //TODO: what is this test? if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){ //dialogues + static float talkdelay = 0; + if(indialogue!=-1) talkdelay=1; talkdelay-=multiplier; @@ -6297,8 +6467,8 @@ void Game::Tick(){ whichdialogue=i; for(int j=0;j0.5) if( Input::isKeyPressed(SDLK_1)|| Input::isKeyPressed(SDLK_2)|| @@ -6611,10 +6781,10 @@ void Game::Tick(){ dialoguetime+=multiplier; - hawkrotation+=multiplier*25; + hawkyaw+=multiplier*25; realhawkcoords=0; realhawkcoords.x=25; - realhawkcoords=DoRotation(realhawkcoords,0,hawkrotation,0)+hawkcoords; + realhawkcoords=DoRotation(realhawkcoords,0,hawkyaw,0)+hawkcoords; hawkcalldelay-=multiplier/2; if(hawkcalldelay<=0){ @@ -6670,9 +6840,9 @@ void Game::Tick(){ //? for(int i=0;i1.5&& !player[j].skeleton.free&& - -1==checkcollide(DoRotation(player[j].getJointFor(head).position,0,player[j].rotation,0)*player[j].scale+player[j].coords,DoRotation(player[i].getJointFor(head).position,0,player[i].rotation,0)*player[i].scale+player[i].coords)){ + -1==checkcollide(DoRotation(player[j].getJointFor(head).position,0,player[j].yaw,0)*player[j].scale+player[j].coords,DoRotation(player[i].getJointFor(head).position,0,player[i].yaw,0)*player[i].scale+player[i].coords)){ if(!player[i].isFlip()){ player[i].throwtogglekeydown=1; player[i].victim=&player[j]; player[i].setAnimation(knifethrowanim); - player[i].targetrotation=roughDirectionTo(player[i].coords,player[j].coords); + player[i].targetyaw=roughDirectionTo(player[i].coords,player[j].coords); player[i].targettilt2=pitchTo(player[i].coords,player[j].coords); } if(player[i].isFlip()){ @@ -7048,7 +7218,7 @@ void Game::Tick(){ player[i].victim=&player[j]; XYZ aim; weapons[player[i].weaponids[0]].owner=-1; - aim=player[i].victim->coords+DoRotation(player[i].victim->getJointFor(abdomen).position,0,player[i].victim->rotation,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].getJointFor(righthand).position,0,player[i].rotation,0)*player[i].scale); + aim=player[i].victim->coords+DoRotation(player[i].victim->getJointFor(abdomen).position,0,player[i].victim->yaw,0)*player[i].victim->scale+player[i].victim->velocity*findDistance(&player[i].victim->coords,&player[i].coords)/50-(player[i].coords+DoRotation(player[i].getJointFor(righthand).position,0,player[i].yaw,0)*player[i].scale); Normalise(&aim); aim=DoRotation(aim,(float)abs(Random()%30)-15,(float)abs(Random()%30)-15,0); @@ -7156,7 +7326,7 @@ void Game::Tick(){ absflatfacing=0; absflatfacing.z=-1; - absflatfacing=DoRotation(absflatfacing,0,-rotation,0); + absflatfacing=DoRotation(absflatfacing,0,-yaw,0); } else absflatfacing=flatfacing; @@ -7272,7 +7442,7 @@ void Game::Tick(){ if(player[i].forwardkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7305,7 +7475,7 @@ void Game::Tick(){ if (player[i].rightkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7324,15 +7494,15 @@ void Game::Tick(){ if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){ player[i].velocity+=DoRotation(absflatfacing*5*multiplier,0,-90,0); } - player[i].targetrotation-=90; - if(player[i].forwardkeydown)player[i].targetrotation+=45; - if(player[i].backkeydown)player[i].targetrotation-=45; + player[i].targetyaw-=90; + if(player[i].forwardkeydown)player[i].targetyaw+=45; + if(player[i].backkeydown)player[i].targetyaw-=45; movekey=1; } if ( player[i].leftkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7351,15 +7521,15 @@ void Game::Tick(){ if(player[i].targetanimation==jumpupanim||player[i].targetanimation==jumpdownanim||player[i].isFlip()){ player[i].velocity-=DoRotation(absflatfacing*5*multiplier,0,-90,0); } - player[i].targetrotation+=90; - if(player[i].forwardkeydown)player[i].targetrotation-=45; - if(player[i].backkeydown)player[i].targetrotation+=45; + player[i].targetyaw+=90; + if(player[i].forwardkeydown)player[i].targetyaw-=45; + if(player[i].backkeydown)player[i].targetyaw+=45; movekey=1; } if(player[i].backkeydown){ if(player[i].isIdle()|| (player[i].isStop()&& - player[i].targetrotation==player[i].rotation)|| + player[i].targetyaw==player[i].yaw)|| (player[i].isLanding()&& player[i].targetframe>0&& !player[i].jumpkeydown)|| @@ -7390,7 +7560,7 @@ void Game::Tick(){ player[i].grabdelay=1; } if ( !player[i].leftkeydown&&!player[i].rightkeydown) - player[i].targetrotation+=180; + player[i].targetyaw+=180; movekey=1; } if((player[i].jumpkeydown&&!player[i].jumpclimb)||player[i].jumpstart){ @@ -7404,14 +7574,14 @@ void Game::Tick(){ player[i].targetanimation!=wolfrunninganim)||i!=0)){ player[i].jumpstart=0; player[i].setAnimation(jumpupanim); - player[i].rotation=player[i].targetrotation; + player[i].yaw=player[i].targetyaw; player[i].transspeed=20; player[i].FootLand(0,1); player[i].FootLand(1,1); facing=0; facing.z=-1; - flatfacing=DoRotation(facing,0,player[i].targetrotation+180,0); + flatfacing=DoRotation(facing,0,player[i].targetyaw+180,0); if(movekey)player[i].velocity=flatfacing*player[i].speed*45*player[i].scale; if(!movekey)player[i].velocity=0; @@ -7494,20 +7664,20 @@ void Game::Tick(){ } } if(player[i].targetanimation==rollanim) - player[i].targetrotation=oldtargetrotation; + player[i].targetyaw=oldtargetyaw; } //Rotation for(int k=0;k180){ - if(player[k].rotation>player[k].targetrotation) - player[k].rotation-=360; + if(fabs(player[k].yaw-player[k].targetyaw)>180){ + if(player[k].yaw>player[k].targetyaw) + player[k].yaw-=360; else - player[k].rotation+=360; + player[k].yaw+=360; } //stop to turn in right direction - if(fabs(player[k].rotation-player[k].targetrotation)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)) + if(fabs(player[k].yaw-player[k].targetyaw)>90&&(player[k].isRun()||player[k].targetanimation==walkanim)) player[k].setAnimation(player[k].getStop()); if(player[k].targetanimation==backhandspringanim||player[k].targetanimation==dodgebackanim) @@ -7528,7 +7698,7 @@ void Game::Tick(){ } if(player[k].isRun()) - player[k].targettilt=(player[k].rotation-player[k].targetrotation)/4; + player[k].targettilt=(player[k].yaw-player[k].targetyaw)/4; player[k].tilt=stepTowardf(player[k].tilt,player[k].targettilt,multiplier*150); player[k].grabdelay-=multiplier; @@ -7604,7 +7774,7 @@ void Game::Tick(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords; + if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -7616,7 +7786,7 @@ void Game::Tick(){ if(Random()%2==0){ if(!player[1].skeleton.free)temp2=(player[1].coords-player[1].oldcoords)/multiplier/2;//velocity/2; if(player[1].skeleton.free)temp2=player[1].skeleton.joints[i].velocity*player[1].scale/2; - if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].rotation,0)*player[1].scale+player[1].coords; + if(!player[1].skeleton.free)temp=DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position,0,0,player[1].tilt),player[1].tilt2,0,0),0,player[1].yaw,0)*player[1].scale+player[1].coords; if(player[1].skeleton.free)temp=player[1].skeleton.joints[i].position*player[1].scale+player[1].coords; Sprite::MakeSprite(breathsprite, temp,temp2, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1); } @@ -7640,14 +7810,14 @@ void Game::Tick(){ upvector=0; upvector.z=-1; - upvector=DoRotation(upvector,-rotation2+90,0,0); - upvector=DoRotation(upvector,0,0-rotation,0); + upvector=DoRotation(upvector,-pitch+90,0,0); + upvector=DoRotation(upvector,0,0-yaw,0); facing=0; facing.z=-1; - facing=DoRotation(facing,-rotation2,0,0); - facing=DoRotation(facing,0,0-rotation,0); + facing=DoRotation(facing,-pitch,0,0); + facing=DoRotation(facing,0,0-yaw,0); static float ori[6]; @@ -7671,18 +7841,18 @@ void Game::Tick(){ void Game::TickOnce(){ if(mainmenu) - rotation+=multiplier*5; + yaw+=multiplier*5; else if(directing||indialogue==-1) { - rotation+=deltah*.7; + yaw+=deltah*.7; if(!invertmouse) - rotation2+=deltav*.7; + pitch+=deltav*.7; if(invertmouse) - rotation2-=deltav*.7; - if(rotation2>90) - rotation2=90; - if(rotation2<-70) - rotation2=-70; + pitch-=deltav*.7; + if(pitch>90) + pitch=90; + if(pitch<-70) + pitch=-70; } } @@ -7698,6 +7868,7 @@ void Game::TickOnceAfter(){ static float cameraspeed; if(!mainmenu){ + static int oldmusictype=musictype; if(environment==snowyenvironment) leveltheme=stream_snowtheme; @@ -7993,8 +8164,8 @@ void Game::TickOnceAfter(){ facing=0; facing.z=-1; - facing=DoRotation(facing,-rotation2,0,0); - facing=DoRotation(facing,0,0-rotation,0); + facing=DoRotation(facing,-pitch,0,0); + facing=DoRotation(facing,0,0-yaw,0); viewerfacing=facing; if(!cameramode){ @@ -8008,7 +8179,7 @@ void Game::TickOnceAfter(){ } target.y+=.1; } - if(player[0].skeleton.free!=2&&!autocam){ + if(player[0].skeleton.free!=2/*&&!autocam*/){ cameraspeed=20; if(findLengthfast(&player[0].velocity)>400){ cameraspeed=20+(findLength(&player[0].velocity)-20)*.96; @@ -8033,13 +8204,13 @@ void Game::TickOnceAfter(){ int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j]; colviewer=viewer; coltarget=cameraloc; - if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col; + if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.yaw[i])!=-1)viewer=col; } if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz]) for(int j=0;j400){ @@ -8075,13 +8248,13 @@ void Game::TickOnceAfter(){ int i=terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j]; colviewer=viewer; coltarget=cameraloc; - if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.rotation[i])!=-1)viewer=col; + if(objects.model[i].LineCheckPossible(&colviewer,&coltarget,&col,&objects.position[i],&objects.yaw[i])!=-1)viewer=col; } if(terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz]) for(int j=0;j.8)camerashake=.8; //if(woozy>10)woozy=10; //woozy+=multiplier; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index ffc13d7..6add2e2 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -183,8 +183,6 @@ bool vertexweird[6] = {0}; TGAImageRec texture; bool debugmode = false; -bool won = false; - bool campaign = false; diff --git a/Source/Objects.cpp b/Source/Objects.cpp index a01fc11..353fa6e 100644 --- a/Source/Objects.cpp +++ b/Source/Objects.cpp @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Objects.h" extern XYZ viewer; extern float viewdistance; -extern float lightambient[3],lightbrightness[3]; extern float fadestart; extern int environment; extern float texscale; @@ -53,7 +52,7 @@ bool Objects::checkcollide(XYZ startpoint,XYZ endpoint,int which){ if(type[i]!=treeleavestype&&type[i]!=treetrunktype&&type[i]!=bushtype&&type[i]!=firetype&&i!=which){ colviewer=startpoint; coltarget=endpoint; - if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&rotation[i])!=-1)return 1; + if(model[i].LineCheck(&colviewer,&coltarget,&colpoint,&position[i],&yaw[i])!=-1)return 1; } } @@ -74,7 +73,7 @@ void Objects::SphereCheckPossible(XYZ *p1,float radius) for(j=0;j1)distance=1; if(distance>0){ - /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,rotation[i],0)*scale[i]+position[i],i)){ + /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,yaw[i],0)*scale[i]+position[i],i)){ occluded[i]+=1; } else occluded[i]=0;*/ @@ -255,7 +254,7 @@ void Objects::Draw() glRotatef((sin(windvar+position[i].x*.3)+.5)*4*.5*(sin(windvar*2+position[i].x*.3)+1)/2,1,0,0); } } - glRotatef(rotation[i],0,1,0); + glRotatef(yaw[i],0,1,0); if(distance>1)distance=1; glColor4f((1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,(1-shadowed[i])/2+.5,distance); if(distance>=1){ @@ -328,7 +327,7 @@ void Objects::Draw() glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 ); for(i=0;i