How would I do this? I want the mouse to be able to rotate around then object on the Y axis only, so the mouse cant make it move up or in or out on left and right around my sphere (object 1)
Current code:
#include "DarkGDK.h"
#include "DarkPhysics.h"
#include "DarkAI.h"
#include "DarkLights.h"
#include "ShaderData.h"
#pragma comment ( lib, "DarkPhysics.lib" )
#pragma comment ( lib, "DarkAI.lib" )
#pragma comment ( lib, "DarkLights.lib" )
#pragma comment ( lib, "ShaderData.lib" )
void DarkGDK ( void ) {
//Settings
dbSyncOn();
dbPhyStart();
dbPhySetGravity(0,-200,0);
dbSyncRate(60);
dbBackdropOn();
dbPositionCamera(0,0,-10,30);
//Player
dbMakeObjectSphere(1,40);
dbPositionObject(1,0,100,0);
//Other Objects
dbLoadObject("C:\\Users\\Brett\\Desktop\\Coding Modelling\\Models\\Block.x",2);
dbRotateObject(2,0,0,-90);
dbScaleObject(2,3000,3000,3000);
//Setting up physics
dbPhyMakeRigidBodyDynamicSphere(1);
dbPhyMakeRigidBodyStaticMesh(2);
//Camera
dbRotateCamera(0,-45,-45,0);
//Loop
while( LoopGDK ( ) ) {
//Declare player position as x,y,z
float x = dbObjectPositionX(1);
float y = dbObjectPositionY(1);
float z = dbObjectPositionZ(1);
//Raycast
dbPhyRayCastAllShapes(x,y,z,0,-1,0);
float coly = dbPhyGetRayCastDistance();
//Movement
//Upkey
if (dbKeyState(200) == 1) {
dbPhyAddRigidBodyForce(1,0,0,3,2);
}
//Downkey
if (dbKeyState(208) == 1) {
dbPhyAddRigidBodyForce(1,0,0,-3,2);
}
//Rightkey
if (dbKeyState(205) == 1) {
dbPhyAddRigidBodyForce(1,3,0,0,2);
}
//Leftkey
if (dbKeyState(203) == 1) {
dbPhyAddRigidBodyForce(1,-3,0,3,2);
}
//Jumping
//Spacebar
if (dbKeyState(57)) {
if ((coly > 10) && (coly < 25))
{
dbPhyAddRigidBodyForce(1,0,50,0,2);
}
}
//Position camera to player
dbPositionCamera(0,x,y-75,z-75);
//Display x,y,z
dbInk(RGB(250,0,160),RGB(250,0,160));
dbText(0,0,dbStr((int)x));
dbText(0,10,dbStr((int)y));
dbText(0,20,dbStr((int)z));
dbText(0,30,dbStr((int)coly));
//Update Screen and Physics
dbPhyUpdate();
dbSync();
}
}
Always program as if the person maintaining your program is a psychopath that knows where you live