-
Posts
295 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by DigitalHax
-
-
This is my code so far.
#include "engine.h"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd )
{
Initialize() ;
RegisterAbstractPath("F:/Leadwerks Engine SDK/Leadwerks Engine SDK");
SetAppTitle( "MyGame-Debug" );
//Create a graphics context
Graphics(1280,720);
//Create a world
if (!CreateWorld()) {
MessageBoxA(0,"Error","Failed to create world.",0);
goto exitapp;
}
//Create a camera
TEntity cam=CreateCamera();
CameraClearColor(cam,Vec4(0,0,1,1));
PositionEntity(cam,Vec3(0,2,-10));
Collisions(1,2,true);
//Load a model
TEntity scene=LoadScene("abstract::tunnels.sbx");
PositionEntity(scene,Vec3(3.8,-2.5,0));
if (scene==0) {
MessageBoxA(0,"Error","Failed to load model.",0);
goto exitapp;
}
EntityType(scene,2);
//Create a light
TLight light=CreatePointLight();
PositionEntity(light,Vec3(0,5,0));
//Create a render buffer
TBuffer buffer=CreateBuffer(1280,720,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
TController player=CreateController(1.8,0.4,0.5,45.01);
EntityType(player,1);
SetBodyDamping(player,0.0);
SetWorldGravity(Vec3(0,-20,0));
SetBodyMass(player,1);
PositionEntity(player,Vec3(0,1,0));
float move=0.0;
float strafe=0.0;
TVec3 camrotation=Vec3(0);
float mx=0;
float my=0;
HideMouse();
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
//Main loop
while(!KeyHit(KEY_ESCAPE)) {
//Camera looking
mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
my=Curve(MouseY()-GraphicsHeight()/2,my,6);
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
camrotation.X=camrotation.X+my/10.0;
camrotation.Y=camrotation.Y-mx/10.0;
RotateEntity(cam,camrotation);
//Player movement
move=(KeyDown(KEY_W)-KeyDown(KEY_S))*2.0;
strafe=(KeyDown(KEY_D)-KeyDown(KEY_A))*2.0;
//Jumping
float jump=0.0;
if (KeyHit(KEY_SPACE)) {
if (!ControllerAirborne(player)) {
jump=4.0;
}
}
//Run
if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) {
if (!ControllerAirborne(player)) {
move*=2.0;
strafe*=2.0;
}
}
//Set controller input
UpdateController(player,camrotation.Y,move,strafe,jump,40);
//Update the world
UpdateWorld();
//Position the camera
TVec3 playerpos=EntityPosition(player);
TVec3 camerapos=EntityPosition(cam);
camerapos.Y=Curve(playerpos.Y+1.75*0.5,camerapos.Y,2.0);
camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z);
PositionEntity(cam,camerapos);
//Render the scene
SetBuffer(buffer);
RenderWorld();
//Render lighting
SetBuffer(BackBuffer());
RenderLights(buffer);
//Swap the front and back buffer
Flip();
}
exitapp:
return Terminate();
-
Well i created the character controller originally just following the tutorial, it worked fine and had mass and collisions,but it loaded a model instead of a map, so when i loaded a map instead, the map would be there, then you would just fall through it. even if you set it to spawn on top of it, it would still not collide with you in any way.
-
This works to load it, but the scene doesn't collide with the player. I set the entity type and set the collisions, but it still doesn't collide with the player.
-
Works like a charm thanks. Oh and before I forget, how would you. Load a map, (.sbx) instead of a model?
-
Hello. I am looking at the character controller function with the leadwerks engine, and I got it all set up, but the camera height was too low. Which brings me to another point. How come in the tutorial for character controllers, it uses a map, scene.gmf, which does not come in the zip! Can someone help me with this? I am a bit of a noob to C++. Thanks in advance.
-
Thanks i got it working finally It was having trouble accesing the leadwerks sdk CPP folder, but i copied the mathlib header and engine header now it is fine. Thanks again.
-
Hello. I am fairly new to the leadwerks engine. And upon my setup of a C++ project, on the first build it came up with the error,
"MyProject.cpp(2): fatal error C1083: Cannot open include file: 'engine.h': No such file or directory"
I did notice a few things different when i was setting up the project properties, extra parameters, etc, but i dismissed them because i am running 2010 version. I am sure i did everything right. Can someone help me solve this bug?
How to change character controller height
in General Discussion
Posted
Well I am trying to load the tunnels.sbx demo map, which is mostly models.