I gave up on Strafing. Now I hit a problem. The A and D keys rotate me left and right. My mouse ALSO rotates (I don't know why I did that). The problem is that once I let go of pressing the A or D key I just zoom right back to where my mouse was facing. Heres my code:
Main
#include "Include.h"
#include "Windows.h"
#include "Movement.h"
#include "Terrain.h"
#include "Physics.h"
#include "MouseMove.h"
void DarkGDK ( void )
{
dbMakeObjectBox ( 1, 50 , 50, 50 );
SetupWindows();
SetupTerrain();
dbSyncOn ();
dbSyncRate ( 60 );
while ( LoopGDK ( ) )
{
SetupMouseMove ();
SetupMovement();
dbSync ();
}
return;
}
MouseMove.h
#pragma once
#include "DarkGDK.h"
void SetupMouseMove ( void );
Movement.h
#pragma once
#include "DarkGDK.h"
void SetupMovement ( void );
MouseMove.cpp
#include "MouseMove.h"
float MCameraAngleX = dbCameraAngleX();
float MCameraAngleY = dbCameraAngleY();
void SetupMouseMove ( void )
{
dbHideMouse();
dbPositionMouse ( dbScreenWidth()/2 , dbScreenHeight()/2 );
MCameraAngleX = dbWrapValue (MCameraAngleX + dbMouseMoveY() * 0.2f);
MCameraAngleY = dbWrapValue (MCameraAngleY + dbMouseMoveX() * 0.2f);
dbXRotateCamera( MCameraAngleX );
dbYRotateCamera( MCameraAngleY );
}
Movement.cpp
#include "Movement.h"
float Camera = 0.00f;
void SetupMovement ( void )
{
if (dbKeyState (17) == 1) // W
{
dbMoveCamera (2.0f);
}
if (dbKeyState (30) == 1) // A
{
dbYRotateCamera (Camera=Camera-2.0f);
}
if (dbKeyState (31) == 1) // S
{
dbMoveCamera (-2.0f);
}
if (dbKeyState (32) == 1) // D
{
dbYRotateCamera (Camera=Camera+2.0f);
}
}
I know what the problem is, I just don't know how to fix it.
LOL