AggrorJorn Posted February 17, 2010 Share Posted February 17, 2010 File Name: Third person camera - ball game example File Submitter: Aggror File Submitted: 17 Feb 2010 File Updated: 25 Feb 2010 File Category: C/C++ Code When I first used Leadwerks, I was trying to make a ball game like Marble blast I never really finished it, but the third person camera is working plus a small demo level. It contains the source code which people can perhaps use. Please note that this was just a very simple test B) . That means. not the best soundtrack bad textures on my own models you can jump as long as their is collision (which results in climbing up walls)) no camera collision #include "engine.h" int ballCollision = 0 ; void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) { ballCollision = 1; } int main(int argc, char** argv) { Initialize(); //Create a graphics context Graphics(800,600); //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,8.2,-4)); //Create a light TLight light=CreatePointLight(); PositionEntity(light,Vec3(0,10,0)); RotateEntity(light,Vec3(0,45,0)); Collisions(1,1,1); //Create a render buffer TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //load a scene TModel scene=LoadModel("abstract::scene.gmf"); if (!scene) { MessageBoxA(0,"Error","Failed to load mesh.",0); goto exitapp; } EntityType(scene,1); //body TBody ballbody=CreateBodySphere(); SetBodyMass(ballbody,1.5); SetBodyGravityMode(ballbody,-10); PositionEntity(ballbody,Vec3(0,8,0)); EntityType(ballbody,1); SetEntityCallback(ballbody,(byte*)EntityCollisionCallback,ENTITYCALLBACK_COLLISION); //mesh TMesh ballmesh=LoadMesh("abstract::ball_ball1.gmf"); ScaleMesh(ballmesh,Vec3(1,1,1)); PositionEntity(ballmesh,Vec3(0,8,0)); EntityParent(ballmesh,ballbody); EntityType(ballmesh,1); //keyboard variabeles TVec3 camrotation=Vec3(0); TVec3 cam2rotation=Vec3(0); float mx=0; float my=0; float move=0; float strafe=0; float jump=20; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //physics Collisions(1,1,1); DebugPhysics(true); //camera pivots TEntity pivot1=CreatePivot(ballmesh); EntityParent(cam, pivot1); //other variabeles char temp[100]; int result; TVec3 point0; TVec3 point1; //sound TSound sound1 =LoadSound("abstract::ruud.wav"); TSource source1 =CreateSource(sound1,SOURCE_LOOP); PlaySource(source1); SetSourceVolume(source1,0.1); //Main loop while(!KeyHit(KEY_ESCAPE)) { //Pivot mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.Y=camrotation.Y-mx/10.0; camrotation.X=camrotation.X+my/10.0; RotateEntity(pivot1,camrotation, 1); ////Camera looking //mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); //my=Curve(MouseY()-GraphicsHeight()/2,my,6); //MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //cam2rotation.X=cam2rotation.X+my/10.0; //RotateEntity(cam,cam2rotation); //moving the ball move=KeyDown(KEY_W)-KeyDown(KEY_S); strafe=KeyDown(KEY_D)-KeyDown(KEY_A); TVec3 forcemove = Vec3(strafe*10.0,0,move*10.0); forcemove = TFormVector(forcemove,cam,0); AddBodyForce(ballbody,forcemove); //Jumping with the ball if (ballCollision == 1) { if (KeyHit(KEY_SPACE)) { TVec3 forcejump = Vec3(0,390,0); AddBodyForce(ballbody,forcejump,1); } } ballCollision = 0; //Update the world UpdateWorld(); //Render the scene SetBuffer(buffer); RenderWorld(); //Render lighting SetBuffer(BackBuffer()); RenderLights(buffer); //Swap the front and back buffer Flip(); } exitapp: return Terminate(); } Click here to download this file Quote Link to comment Share on other sites More sharing options...
dreamhead Posted February 17, 2010 Share Posted February 17, 2010 hahahah soms good old ball fun B) lol Quote the real world is in my head CPU-Intel® Core2 Quad CPU Q6600 @ 2.40GHz CPU Speed 2.40 GHz RAM 3.5 GB OS Microsoft Windows XP Professional (Build Service Pack 32600) Video Card GeForce 8800 GT Video Card Features- *Video RAM 512.0 MB Video RAM 256 MB 512.0 MB Hardware T&L Yes Pixel Shader version 3.0 Vertex Shader version 3.0 using:leadwerks2.3,2 [ Link to comment Share on other sites More sharing options...
Sooshi Posted February 17, 2010 Share Posted February 17, 2010 thats awsome Aggror, I am playing with the balls B) Quote Working on a major RPG project.......will showcase soon. www.kevintillman1.wix.com/tillmansart Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 17, 2010 Share Posted February 17, 2010 B) Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
VicToMeyeZR Posted February 17, 2010 Share Posted February 17, 2010 I am playing with the balls B) TMFI bro, TMFI Quote AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 18, 2010 Author Share Posted February 18, 2010 TMFI bro, TMFI TMFI? Whats that? don't recognize the slang. When I replay this game I have to say that I'm eager to continue with it again. But I there are other things do at the moment. Would be a fun game to play though. Not to hard to make as well. Quote Link to comment Share on other sites More sharing options...
Rick Posted February 18, 2010 Share Posted February 18, 2010 I'm guessing it means To Much F*&%ing Information Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 18, 2010 Author Share Posted February 18, 2010 I'm guessing it means To Much F*&%ing Information ah! TMI with an extra F. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.