Here is a small piece of code to make compass (8 dirs) appear in-game when you press 'C'
(Remember to credit Chris for showing easier way to detect compass direction).
First add this line to the end of wl_def.h:
Then in the same file - define the sprites for the compass:
Then in wl_play.c - just add this line under "global variables":
Then scroll down to CheckKeys() in the same file and add this to it
(for example - just before the MLI):
Then open up wl_draw.c and go down to DrawPlayerWeapon()...
Add this line to the beginning of the function:
but you have to add more sprites for the compass if you decide to enable it)
And then in the end of the function this line:
(Remember to credit Chris for showing easier way to detect compass direction).
First add this line to the end of wl_def.h:
- Code:
extern bool compass;
Then in the same file - define the sprites for the compass:
- Code:
SPR_CHAINREADY,SPR_CHAINATK1 ,SPR_CHAINATK2 ,SPR_CHAINATK3,
SPR_CHAINATK4, //Might differ from your code:
//Add these lines:
SPR_DIR_E,SPR_DIR_NE,SPR_DIR_N,SPR_DIR_NW, //Directions E-NW
SPR_DIR_W,SPR_DIR_SW,SPR_DIR_S,SPR_DIR_SE, //Directions W-SE
Then in wl_play.c - just add this line under "global variables":
- Code:
bool compass;
Then scroll down to CheckKeys() in the same file and add this to it
(for example - just before the MLI):
- Code:
//------------------
// Compass
if (Keyboard[sc_C])
{ compass ^= true;
Keyboard[ sc_C ] = false;
return;
}
Then open up wl_draw.c and go down to DrawPlayerWeapon()...
Add this line to the beginning of the function:
- Code:
short compass_dir = ((player->angle*2 + 45) / 90) % 8; //by Chris
// short compass_dir=((player->angle*4+45)/90)%16:
but you have to add more sprites for the compass if you decide to enable it)
And then in the end of the function this line:
- Code:
if(compass) { SimpleScaleShape(viewwidth-100,SPR_DIR_E+compass_dir,(viewheight+64)/2) }; //by Chris