Ok (sorry for the double post, attaching download to this one)
I have gone through your code and changed and altered it to get it running as best I could without spending too much time(im a little strapped for that lately lol)..
I have included in the download the media that I used, as it is kind of position dependant, as you have gravity, you need to make sure you spawn the player in just above the ground or he falls through it. (its about 7mb with media in a zip-FPSC level which is what you were using I think - i removed some of the textures to make it smaller lol)
Its working, you can run around the level and jump, you can fire the gun, but only 1 clip as your reload code is a little broken.
I have gone through and added comments through your code in all the places where I changed something, to explain why I changed it and to what.
Basically, your minimap isnt working(camera usage related), reloading isnt working(variable usage related, couldnt trace it in time i had), the rest seems to be working.
Your code wasnt really messy at all, and it was quite easy for me to undersatnd what was doing what.
Ill also post the actual 2 code files in code tags here to save the download if you dont want to(I recomend you do though as the media I used will demonstrate how it works, as I said, using different media will mean that you need to alter the spawn in position of your player.)
Attachment contains : Compiled .EXE file, media, main.cpp and variables.h.
Main.cpp :
// Include DarkGDK, Sparky's Collision and Mask Object
#include "DarkGDK.h"
#include "SC_Collision.h"
#include "Variables.h"
/////Movement Vectors
int g_rtimer = 0;
int g_stimer = 0;
int g_vtimer = 0;
double g_vx = 0.0f;
double g_vy = 0.0f;
double g_vz = 0.0f;
double g_x = 0.0f;
double g_oldy = 0.0f;
double g_y = 0.0f; // this variable was missing a definition
double g_z = 0;
double g_ox = 0.0f;
double g_oy = 0.0f;
double g_oz = 0.0f;
double g_ax = 0.0f;
double g_ay = 0.0f;
double g_az = 0.0f;
double g_newx = 0.0f;
double g_newy = 0.0f;
double g_newz = 0.0f;
double g_normx = 0.0f;
double g_normy = 0.0f;
double g_normz = 0.0f;
double g_runon = 3.0f;
double g_radius = 24.5f;
double g_fpsview = 0.0f;
double g_fpsviewy = 0.0f; // this variable was missing a definition
double g_gravity = -0.1f;
double g_slope = 0.5f;
int g_ground = 0;
int g_jumptimer = 0;
/////User-Declared Variables
int g_idle = 1;
int g_thirdperson = 0;
int g_firestate = 0;
int g_moving = 0;
int g_reloadstate = 0;
int g_framecheck = 0;//g_reloadstate+g_firestate; // if you want this variable to stay equal to the other 2, u ned to keep assigning it in the loop
int g_movecheck = 0; // can define it like this : dbKeyState(17)+dbKeyState(30)+dbKeyState(31)+dbKeyState(32);
int g_muzzleflashtoggle = 0;
int g_counter = 10002;
/////Object Number Variables
int g_map = 1;
int g_plrobj = 2;
int g_skysphere = 10;
int g_skytex = 5;
/////G36C Variables
int g_g36c = 8;
int g_g36cflash = 9;
int g_g36cfire = 1;
int g_g36creload = 2;
int g_g36cdryfire = 3;
int g_g36cflashtex = 1;
int g_g36cxhair = 2;
int g_g36choletex = 3;
int g_g36cxhairs = 1;
int g_accg36c = 10;
int g_g36cammo = 30;
int g_maxg36cammo = 500;
int g_g36cammoremain = 0;
int g_clipg36cammo = 30;
void movePlayer(); // sparky's sliding demo player movement function - this is where you copied yours from I assume
// so i stuck this in here to try and get movement working properly.
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 30 fps
dbSyncOn ( );
dbSyncRate (60);
dbSetDisplayMode (800,600,32);
dbRandomize (dbTimer());
dbAutoCamOff();
dbSetDir ("Files");
SC_Start();
MakeLevel();
MakePlayer();
GunG36C();
// IMPORTANT : ADJUST the values added to the object position below to make sure that your player
// spawns into the level just a little above the gruond, and actually inside it
dbPositionObject(g_plrobj, dbObjectPositionX(g_plrobj)+20, dbObjectPositionY(g_plrobj)+4, dbObjectPositionZ(g_plrobj)-4);
// our main loop
while ( LoopGDK ( ) )
{
dbPositionMouse (0,0);
MuzzleUpdate();
movePlayer();
PositionCameraToObject();
//MakeMinimap(); - commented as its logic is broken, try to fix it
GunReloadG36C();
g_framecheck = g_reloadstate + g_firestate;
//g_movecheck = dbKeyState(17)+dbKeyState(30)+dbKeyState(31)+dbKeyState(32);
if(dbKeyState(17) || dbKeyState(30) || dbKeyState(31) ||dbKeyState(32)) g_movecheck = 1; // replaces line above
GunMovementG36C();
dbText (0,0,"FPS : ");
dbText (0,25,"Ammo : ");
dbText (0,50,"Max Ammo : ");
dbText (60,0,dbStr(dbScreenFPS())); // you are creating memory leaks here just so you know
dbText (60,25,dbStr(g_g36cammo)); // dbStr allocates memory, so you need to assign the pointer
dbText (60,50,dbStr(g_maxg36cammo));// you get back from it to a variable of your own so you ca de-allocate it
// not really important at the moment, but something to keep in mind
dbSync ( );
}
// return back to windows
return;
}
void MakeLevel(void) // Load and Render the 3d world and make a textured sky-sphere
{
//////////////////////////////////////////////////////////////////////
/// NOTE : I EDITTED THE PATHS OF YOUR MEDIA, YOU NEED TO CHANGE THEM
// BACK TO WHEREVER YOU HAD THEM ORIGINALLY. I AM SORRY, I DID THIS
// SO THAT I COULD TEST THE PROGRAM WITH MY OWN MEDIA AS YOU DIDNT
// INCLUDE ANY IN YOUR DOWNLOAD
///////////////////////////////////////////////////////////////////////
//dbMakeObjectSphere (g_skysphere,-48000.0f);
//dbLoadImage ("Skytex.jpg",g_skytex);
//dbLoadImage ("backdrop.jpg",g_skytex);
//dbTextureObject (g_skysphere,g_skytex);
dbLoadObject ("levelbank\\testlevel\\universe.dbo",g_map);
SC_SetupComplexObject (g_map,1,2);
//dbPositionObject (g_map,0.0f,0.0f,0.0f);
//dbPositionObject (g_skysphere,0.0f,0.0f,0.0f);
}
void MakePlayer(void) //Makes the actual player collision sphere and hides it
{
dbMakeObjectSphere (g_plrobj,g_radius);
//dbPositionObject (g_plrobj,185.0f,30.0f,-240.0f);
SC_SetupObject (g_plrobj,0,1);
}
void GunG36C(void) //Loads the Properties of the G36C
{
//////////////////////////////////////////////////////////////////////
/// NOTE : I EDITTED THE PATHS OF YOUR MEDIA, YOU NEED TO CHANGE THEM
// BACK TO WHEREVER YOU HAD THEM ORIGINALLY. I AM SORRY, I DID THIS
// SO THAT I COULD TEST THE PROGRAM WITH MY OWN MEDIA AS YOU DIDNT
// INCLUDE ANY IN YOUR DOWNLOAD
///////////////////////////////////////////////////////////////////////
//dbLoadSound ("fire.wav",g_g36cfire);
//dbLoadSound ("reload.wav",g_g36creload);
//dbLoadSound ("dryfire.wav",g_g36cdryfire);
dbLoadObject("HUD.x",g_g36c);
dbLoadImage ("flash94.dds",g_g36cflashtex);
dbLoadImage ("crosshair.dds",g_g36cxhair);
dbLoadImage ("bulletholes.dds",g_g36choletex);
/*int n = 0;
for (n = 1; n < 81; n++)
{
dbMakeObjectPlain (n+=10000,8.0f,8.0f);
dbTextureObject (n+=10000,g_g36choletex);
dbSetObjectTransparency (n+=10000,1);
dbHideObject (n+10000);
}*/
dbMakeObjectPlain (g_g36cflash,12.0f,12.0f);
dbTextureObject (g_g36cflash,g_g36cflashtex);
dbHideObject (g_g36cflash);
dbSetObjectTransparency (g_g36cflash,1);
dbLockObjectOn (g_g36cflash);
dbDisableObjectZDepth (g_g36cflash);
dbLockObjectOn (g_g36c);
dbSetObjectSpeed (g_g36c,55);
dbRotateObject (g_g36c,180.0f,0.0f,180.0f);
dbPositionObject (g_g36c,1.25f,0.0f,0.0f);
dbDisableObjectZDepth (g_g36c);
dbSprite (g_g36cxhairs,dbScreenWidth()/2 - 32,dbScreenHeight()*0.5 - 32,g_g36cxhair);
dbScaleSprite (g_g36cxhairs,50.0f);
}
void MuzzleUpdate(void) //Updates the Muzzleflash
{
dbPositionObject (g_g36cflash,dbObjectPositionX(g_g36c)+3.70f,dbObjectPositionY(g_g36c)-2.5f,dbObjectPositionZ(g_g36c)+25.0f);
dbPointObject (g_g36cflash,dbObjectPositionX(g_g36c),dbObjectPositionY(g_g36c),dbObjectPositionZ(g_g36c));
dbZRotateObject (g_g36cflash,dbRND(10)+20);
}
//////////////////////////////////////////////////////
// REMOVED YOUR MOVEMENT CODE COMPLETELY IM SORRY ITS BROKEN - SEE movePlayer() fun at bottom.
///////////////////////////////////////////////////////
void MovePlayer(void)
{
/*dbYRotateObject (g_plrobj,dbObjectAngleY(g_plrobj)+dbMouseMoveX()*0.33f);
dbXRotateObject (g_plrobj,dbObjectAngleX(g_plrobj)+dbMouseMoveY()*0.33f);
if (dbWrapValue(dbCameraAngleX())>40 && dbWrapValue(dbCameraAngleX())<180)
{
dbXRotateObject (g_plrobj,40.0f);
}
if (dbWrapValue(dbCameraAngleX())>180 && dbWrapValue(dbCameraAngleX())<280)
{
dbXRotateObject (g_plrobj,280.0f);
}
double oldx = dbObjectPositionX(g_plrobj);
double oldz = dbObjectPositionZ(g_plrobj);
float angy = dbObjectAngleY(g_plrobj);
g_vx = 0.0f;
g_vz = 0.0f;
if (g_vy == 0.0f && g_jumptimer == 0);
{
g_vy = g_vy + 10.0*g_gravity;
}
if (dbKeyState(42) == 1)
{
g_runon = 10.0f;
}
else
{
g_runon = 5.0f;
}
if (dbKeyState(46) == 1)
{
g_radius = 15.0f;
}
else
{
g_radius = 24.5f;
}
if (dbKeyState(32) == 1)
{
g_vx = g_vx + dbCOS(angy)*g_runon;
g_vz = g_vz - dbSIN(angy)*g_runon;
}
if (dbKeyState(30) == 1)
{
g_vx = g_vx - dbCOS(angy)*g_runon;
g_vz = g_vz + dbSIN(angy)*g_runon;
}
if (dbKeyState(31) == 1)
{
g_vx = g_vx - dbSIN(angy)*g_runon;
g_vz = g_vz - dbCOS(angy)*g_runon;
}
if (dbKeyState(17) == 1)
{
g_vx = g_vx + dbSIN(angy)*g_runon;
g_vz = g_vz + dbCOS(angy)*g_runon;
}
if (g_ground == 1)
{
if (dbSpaceKey() == 1 && g_jumptimer == 0)
{
g_vy = g_vy + 4.0f;
g_jumptimer = 20;
}
}
g_x = oldx + g_vx;
g_y = g_oldy + g_vy;
g_z = oldz + g_vz;
int collide = SC_SphereCastGroup(1,oldx,g_oldy,oldz,oldx,g_oldy+g_vy,oldz,g_radius,0);
if (collide > 0)
{
float ny = SC_GetCollisionNormalY();
if (dbABS(ny) > g_slope)
{
g_oldy = SC_GetStaticCollisionY();
}
else
{
g_x = g_x - oldx;
g_z = g_z - oldz;
oldx = SC_GetCollisionSlideX();
g_oldy = SC_GetCollisionSlideY();
oldz = SC_GetCollisionSlideZ();
g_x = g_x + oldx;
g_z = g_z + oldz;
}
if (ny > g_slope)
{
g_ground = 1;
g_vy = 0;
}
else
{
g_ground = 0;
if (ny < g_slope)
{
g_vy = g_gravity;
}
if (collide == 0)
{
g_oldy = g_oldy + g_vy;
g_ground = 0;
}
}
if (g_ground == 0 && g_jumptimer > 0)
{
g_jumptimer--;
}
collide = SC_SphereSlideGroup(1,oldx,g_oldy,oldz,g_x,g_oldy,g_z,g_radius,0);
if (collide > 0)
{
g_x = SC_GetCollisionSlideX();
g_oldy = SC_GetCollisionSlideY();
g_z = SC_GetCollisionSlideZ();
g_vx = 0;
g_vy = 0;
}
dbPositionObject (g_plrobj,g_x,g_oldy,g_z);
SC_UpdateObject (g_plrobj);
}
*/
}
void PositionCameraToObject(void)
{
// added a rotate command here so the camera will rotate to folow the object - fixed the positioning
dbPositionCamera( dbObjectPositionX(g_plrobj),dbObjectPositionY(g_plrobj),dbObjectPositionZ(g_plrobj) );
dbRotateCamera( dbObjectAngleX(g_plrobj),dbObjectAngleY(g_plrobj),dbObjectAngleZ(g_plrobj) );
//g_fpsviewy = dbObjectPositionY(g_plrobj)+g_radius;
//dbPositionCamera (dbObjectPositionX(g_plrobj),g_fpsviewy,dbObjectPositionZ(g_plrobj));
//dbSetCameraRange (1,50010);
}
void MakeMinimap(void)
{
// THIS IS BROKEN, YOU WILL NEED TO LOOK AT ALTERNATIVE WAYS OF DOING THIS AS YOUR CAMERA
// MOVEMENT WAS BEING BROKEN BY THIS SWITCHING CAMERA FOR THE MAP, YOU ONLY NEED TO SET THIS UP ONC
// NOT CALL ALL OF IT IN THE MAIN LOOP, SHUOLD HAVE A "MAKEMINIMAP" function and "UPDATEMINIMAP" func.
/*float xstart = g_x;
float ystart = g_oldy + 1500;
float zstart = g_z;
signed int swidth = dbScreenWidth()-150;
signed int sheight = dbScreenHeight()-(dbScreenHeight()-10);
signed int swidth2 = dbScreenWidth()-10;
signed int sheight2 = dbScreenHeight()-(dbScreenHeight()-150);
dbSetCameraRange (2, 1, 48000);
dbPositionCamera (2, xstart,ystart,zstart);
dbRotateCamera (2,90,dbObjectAngleY(g_plrobj),dbObjectAngleZ(g_plrobj));
dbSetCameraView (swidth,sheight,swidth2,sheight2);
dbSetCameraAspect (2,1.0f);*/
}
void GunReloadG36C(void)
{
// YOU RELOAD CODE IS BROKEN AT THE MOMENT.
// I HAVE NOT TRACED THROUGH EXACTLY WHY, BUT I WOULD CHECK AND TRAC ALL USED VARIABLES TO TRY AND
// SEE WHAT IS CAUSING IT TO BREAK THE ROUTINE, THE GUN FIRES, BUT DOESNT RELOAD
/*if (dbKeyState(19) == 1 && g_framecheck == 0)
{
g_idle = 0;
g_moving = 0;
dbPlayObject (g_g36c,91,169);
dbPlaySound (g_g36creload);
g_reloadstate = 1;
}
if (g_g36cammo = 0 && g_maxg36cammo > 1 && g_framecheck == 0)
{
g_idle = 0;
g_moving = 0;
dbPlayObject (g_g36c,91,169);
dbPlaySound (g_g36creload);
g_reloadstate = 1;
}
if (g_g36cammo > g_clipg36cammo)
{
g_g36cammoremain = g_g36cammo - g_clipg36cammo;
g_g36cammo = g_clipg36cammo;
g_maxg36cammo = g_maxg36cammo + g_g36cammoremain;
}
if (dbObjectPlaying(g_g36c) == 0 && g_reloadstate == 1)
{
g_idle = 1;
g_reloadstate = 0;
if (g_maxg36cammo - g_clipg36cammo > 0)
{
g_g36cammo = g_g36cammo + g_clipg36cammo;
g_maxg36cammo = g_maxg36cammo - g_clipg36cammo;
}
else
{
g_g36cammo = g_maxg36cammo;
g_maxg36cammo = 0;
}
}*/
}
void GunMovementG36C(void)
{
// THIS FUNC DOES WHAT ITS MENT TO KIND OF, ITS COLLISION ISNT WORKING PROPERLY SO YOU NEED TO CHJECL THAT
g_muzzleflashtoggle = dbRND(2) - 1;
if (g_movecheck > 0 && g_framecheck == 0)
{
g_idle = 1;
g_moving = 0;
}
else
{
g_moving = 0;
}
if (g_moving = 1)
{
dbLoopObject (g_g36c,51,73);
}
if (dbObjectFrame(g_g36c) > 51 && dbObjectFrame(g_g36c) < 73)
{
if (g_movecheck = 0)
{
if (g_framecheck = 0)
{
dbStopObject(g_g36c);
}
}
}
if (dbObjectPlaying(g_g36c) == 0)
{
g_idle = 1;
}
if (g_idle = 1)
{
dbLoopObject (g_g36c,26,49);
}
if (dbMouseClick() == 1 && g_reloadstate == 0)
{
if (g_g36cammo > 0)
{
g_firestate = 1;
g_idle = 0;
dbLoopObject (g_g36c,76,90);
}
}
if (g_firestate == 1 && dbMouseClick() == 0)
{
g_firestate = 0;
g_idle = 1;
dbStopObject (g_g36c);
}
if (g_firestate == 1 && g_muzzleflashtoggle == 1)
{
dbShowObject (g_g36cflash);
}
else
{
dbHideObject (g_g36cflash);
}
if (g_g36cammo == 0)
{
g_firestate = 0;
}
if (dbMouseClick() == 1 && dbSoundPlaying(g_g36cfire) == 0 && g_reloadstate == 0 && g_g36cammo > 0)
{
dbPlaySound (g_g36cfire);
g_g36cammo-=1;
g_ox = dbCameraPositionX()-dbRND(g_accg36c);
g_oy = dbCameraPositionY()+dbRND(g_accg36c);
g_oz = dbCameraPositionZ();
dbMoveCamera (2000.0f);
g_ax = dbCameraPositionX()-dbRND(g_accg36c);
g_ay = dbCameraPositionY()+dbRND(g_accg36c);
g_az = dbCameraPositionZ();
dbMoveCamera (-2000.0f);
int collide = SC_RayCast(1,g_ox,g_oy,g_oz,g_ax,g_ay,g_az,0);
if (collide > 0)
{
g_newx = SC_GetStaticCollisionX();
g_newy = SC_GetStaticCollisionY();
g_newz = SC_GetStaticCollisionZ();
g_normx = SC_GetCollisionNormalX();
g_normy = SC_GetCollisionNormalY();
g_normz = SC_GetCollisionNormalZ();
dbPositionObject (g_counter,g_newx+g_normx*0.1f,g_newy+g_normy*0.1f,g_newz+g_normz*0.1f);
dbPointObject (g_counter,g_newx+g_normx,g_newy+g_normy,g_newz+g_newz);
dbShowObject (g_counter);
g_counter+=1;
if (g_counter > 10080)
{
g_counter = 10002;
}
}
}
}
// THIS IS THE MOVEMENT CODE FROM THE SPARKYS SLIDING DEMO, I PLACED IT HERE INSTAED OF USING YOUR CODE, WHICH WASNT WORKING
// IM NOT SURE WHYm, BUT I THINK YOU MAY HAVE MUCKED UP SOME OF THE LOOPS IN YOUR OWN MOVEMENT FUNC.
void movePlayer()
{
//rotate player with mouse
dbYRotateObject( 2,dbObjectAngleY(g_plrobj) + dbMouseMoveX()/3.0f );
dbXRotateObject( 2,dbObjectAngleX(g_plrobj) + dbMouseMoveY()/3.0f );
float oldx = dbObjectPositionX(g_plrobj);
float oldy = dbObjectPositionY(g_plrobj);
float oldz = dbObjectPositionZ(g_plrobj);
//apply gravity, and user changes to movement
float angy = dbObjectAngleY(g_plrobj);
g_vx = 0;
g_vz = 0;
//if player is jumping or falling then apply 'normal' gravity
//if not attempt to keep the player stuck to the floor
if ( g_vy == 0 && g_jumptimer == 0 ) g_vy = g_vy + 10.0 * g_gravity;
else g_vy = g_vy + g_gravity;
if (dbKeyState(32) == 1 ) { g_vx = g_vx + dbCos(angy); g_vz = g_vz - dbSin(angy); }
if (dbKeyState(30) == 1 ) { g_vx = g_vx - dbCos(angy); g_vz = g_vz + dbSin(angy); }
if (dbKeyState(31) == 1 ) { g_vx = g_vx - dbSin(angy); g_vz = g_vz - dbCos(angy); }
if (dbKeyState(17) == 1 ) { g_vx = g_vx + dbSin(angy); g_vz = g_vz + dbCos(angy); }
//only jump if on ground, and a certain time after last jump
if ( g_ground == 1 )
{
if ( dbSpaceKey() == 1 && g_jumptimer == 0 )
{
g_vy = g_vy + 3.0f;
g_jumptimer = 20;
}
}
//this would be the player's final position without collision
float x = oldx + g_vx;
float y = oldy + g_vy;
float z = oldz + g_vz;
//first handle gravity - seperated from horizontal movement
//to achieve a more realistic effect
//Method: simple - cast a sphere vertically down, if it hits the level then
// position the object there (sticky collision) then move
// on to horizontal movement
// more complex - if we were to only use the simple method the player would be
// allowed to climb almost vertical slopes. Alternative is to
// get the normalY direction to work out how flat the gorund
// below the player is, 0-slope# is flatter, slope#-1 is steeper.
// if it's flat, use sticky collision, if it's steep slide the
// player down the slope. Changing slope# determines how steep the
// player can climb. NOTE: this also effects stairs.
int collide = SC_SphereCastGroup( 1, oldx,oldy,oldz, oldx,oldy+g_vy,oldz, g_radius,0 );
if ( collide > 0 )
{
//how flat is this ground
float ny = SC_GetCollisionNormalY();
if ( dbAbs(ny) > g_slope )
{
//FLAT, stick
oldy = SC_GetStaticCollisionY();
}
else
{
//STEEP, slide
x = x - oldx; z = z - oldz;
oldx = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
oldz = SC_GetCollisionSlideZ();
x = x + oldx; z = z + oldz;
}
//ny#<0 means the player has hit a ceiling rather than a floor
if ( ny > g_slope )
{
//only on ground if standing on flat ground
g_ground = 1;
g_vy = 0;
}
else
{
g_ground = 0;
//if player has hit a flat ceiling then stop vy# movement
if ( ny < -g_slope ) g_vy = g_gravity;
}
}
else
{
//nothing below player, not on ground, add vertical speed to player
oldy = oldy + g_vy;
g_ground = 0;
}
//jumptimer will decrease only when player is back on ground
//creates a pause between two successive jumps
if ( g_ground == 1 && g_jumptimer > 0 ) g_jumptimer--;
//handle horizontal movement as sliding
//player only collides with group 1 (level) objs and moves freely through others
collide = SC_SphereSlideGroup( 1, oldx,oldy,oldz, x,oldy,z, g_radius,0 );
if ( collide > 0 )
{
//if hit, reposition player, halt movement vector
x = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
z = SC_GetCollisionSlideZ();
g_vx = 0;
g_vz = 0;
//possible code for giving the player a jumping help up stairs...
//might be useful if slope# is set very high but stairs are still required
//dy = oldy - SC_GetStaticCollisionY()
//if ( dy < slope && dy > 0 && ground == 1 ) vy = 0.5;
}
//position the player
dbPositionObject( g_plrobj,x,oldy,z );
SC_UpdateObject( g_plrobj );
}
Variables.h :
/////Movement Vectors
#pragma once
// keyboard scancode defines - added these to help, makes iteasier to use
// dbKeyState(Key_A) instead of dbKeyState(30) - makes it easier to see what is going on
#define Key_Escape 1
#define Key_A 30
#define Key_B 48
#define Key_C 46
#define Key_D 32
#define Key_E 18
#define Key_F 33
#define Key_G 34
#define Key_H 35
#define Key_I 23
#define Key_J 36
#define Key_K 37
#define Key_L 38
#define Key_M 50
#define Key_N 49
#define Key_O 24
#define Key_P 25
#define Key_Q 16
#define Key_R 19
#define Key_S 31
#define Key_T 20
#define Key_U 22
#define Key_V 47
#define Key_W 17
#define Key_X 45
#define Key_Y 21
#define Key_Z 44
#define Key_F1 59
#define Key_F2 60
#define Key_F3 61
#define Key_F4 62
#define Key_F5 63
#define Key_F6 64
#define Key_F7 65
#define Key_F8 66
#define Key_F9 67
#define Key_F10 68
#define Key_LeftSingleQuote 41
#define Key_1 2
#define Key_2 3
#define Key_3 4
#define Key_4 5
#define Key_5 6
#define Key_6 7
#define Key_7 8
#define Key_8 9
#define Key_9 10
#define Key_0 11
#define Key_Minus 12
#define Key_Equal 13
#define Key_BackSpace 14
#define Key_Tab 15
#define Key_LeftBracket 26
#define Key_RightBracket 27
#define Key_BackSlash 43
#define Key_Enter 28
#define Key_Caps 58
#define Key_LShift 42
#define Key_RShift 54
#define Key_SemiColon 39
#define Key_SingleQuote 40
#define Key_Comma 51
#define Key_Period 52
#define Key_ForwardSlash 53
#define Key_LWinKey 219
#define Key_LAlt 56
#define Key_RAlt 184
#define Key_RWinKey 220
#define Key_WinMenu 221
#define Key_LCntl 29
#define Key_RCntl 157
#define Key_PrintScreen 183
#define Key_ScrollLock 70
//#define Key_Pause 197
#define Key_Break 197
#define Key_Ins 210
#define Key_Del 211
#define Key_Home 199
#define Key_End 207
#define Key_PgUp 201
#define Key_PgDn 209
#define Key_UpArrow 200
#define Key_DownArrow 208
#define Key_LeftArrow 203
#define Key_RightArrow 205
#define Key_NumLock 69
#define Key_NumForwardSlash 181
#define Key_NumStar 55
#define Key_NumMinus 74
#define Key_NumPlus 78
#define Key_NumEnter 156
#define Key_NumPeriod 83
#define Key_Num1 79
#define Key_Num2 80
#define Key_Num3 81
#define Key_Num4 75
#define Key_Num5 76
#define Key_Num6 77
#define Key_Num7 71
#define Key_Num8 72
#define Key_Num9 73
#define Key_Num0 82
#define Key_SpaceBar 57
// There is no real need to have these variables declared as externs here if you are not planning
// on accessing them outside of the main program.
// Also, when you declare an extern, you do it in the way I have here... extern decleration in the header,
// variable definition in the code file.
extern int g_rtimer;
extern int g_stimer;
extern int g_vtimer;
extern double g_vx;
extern double g_vy;
extern double g_vz;
extern double g_x;
extern double g_y;
extern double g_oldy;
extern double g_z;
extern double g_ox;
extern double g_oy;
extern double g_oz;
extern double g_ax;
extern double g_ay;
extern double g_az;
extern double g_newx;
extern double g_newy;
extern double g_newz;
extern double g_normx;
extern double g_normy;
extern double g_normz;
extern double g_runon;
extern double g_radius;
extern double g_fpsviewy;
extern double g_gravity;
extern double g_slope;
extern int g_ground;
extern int g_jumptimer;
/////User-Declared Variables
extern int g_idle;
extern int g_thirdperson;
extern int g_firestate;
extern int g_moving;
extern int g_reloadstate;
extern int g_framecheck;
extern int g_movecheck;
extern int g_muzzleflashtoggle;
extern int g_counter;
/////Object Number Variables
extern int g_map;
extern int g_plrobj;
extern int g_skysphere;
extern int g_skytex;
/////G36C Variables
extern int g_g36c;
extern int g_g36cflash;
extern int g_g36cfire;
extern int g_g36creload;
extern int g_g36cdryfire;
extern int g_g36cflashtex;
extern int g_g36cxhair;
extern int g_g36choletex;
extern int g_g36cxhairs;
extern int g_accg36c;
extern int g_g36cammo;
extern int g_maxg36cammo;
extern int g_g36cammoremain;
extern int g_clipg36cammo;
void MakeLevel(void);
void MakePlayer(void);
void GunG36C(void);
void MuzzleUpdate(void);
void MovePlayer(void);
void PositionCameraToObject(void);
void MakeMinimap(void);
void GunReloadG36C(void);
void GunMovementG36C(void);
Hope this helps you. If something I have done to your code doesnt make sense, please ask, I only changed code logic where it was needed to get it running, the rest is left how you wrote it, some of it is ok, and some will need to be redone, ive commented about that too.
If it ain't broke.... DONT FIX IT !!!