CodeBase - Lecon 3
Return to the CodeBase listing
Category: Complete Applications
Version: 1.0
Information
Uploaded: 1st Mar 2005 00:28
Modified: 1st Jan 1970 01:00
Author: Anonymous Coder
Summary
` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `--------------------------- `Limit Rush `Lesson 03 `--------------------------- `http://www.binarymoon.co.uk `Ben aka Mop `--------------------------- `-------- `INCLUDES `-------- `include the MatEdit LoadMatrix files #include "LoadMatrix.dba" `------ `ARRAYS `------ `declare the MatEdit variables Dim BigMatrix(600,600,1) Dim StartLoc_X(1): Dim StartLoc_Z(1):Dim Info(2) Dim TArrayX(1): Dim TArrayZ(1): Dim FKey(10,1) Dim ColData(100): Dim ZoneData(100): Dim Tiles(500,500) Dim OverTexture$(100): Dim OverName$(20): Dim ReplaceTex(100) Dim MOffsetX(25): Dim MOffsetY(25) Dim MWire(20): Dim MGhost(20): Dim Lock(20) Dim MatX#(20): Dim MatY#(20): Dim MatZ#(20) Dim MatWidth#(20): Dim MatHeight#(20) Dim TilesX(20): Dim TilesZ(20) Dim MatHi#(20): Dim MatLo#(20) `---------- `Initialize Variables `---------- ArenaXYZ_SF = 15000 LightXZ_SF# = .46 LightY_SF# = .55 `set up the program sync on sync rate 40 hide mouse autocam off `load the matrix LoadMatrix("map",1) `temporary load level info load object "media/arena.x",100 load object "media/arena_light.x",101 `scale the arena scale object 100, ArenaXYZ_SF, ArenaXYZ_SF, ArenaXYZ_SF scale object 101, ArenaXYZ_SF*LightXZ_SF#, ArenaXYZ_SF*LightY_SF#, ArenaXYZ_SF*LightXZ_SF# `position arena position object 100,247,189,247 position object 101,247,189,247 `add mip-mapping set matrix texture 1,2,1 set object texture 100,0,1 set object texture 101,2,1 `set fake light properties set object 101,1,1,0,1,0,0,1 ghost object on 101 `set fog properties fog on fog distance 2000 fog color RGB(128,0,0) `set ambient light amount set ambient light 10 `colour main light color light 0,RGB(0,0,160) `make a light make light 1 set point light 1,250,200,250 color light 1,RGB(255,255,100) `make a temporary player object make object cube 1,5 position object 1,250,1,250 `--------- `MAIN LOOP `--------- main: do yAng# = object angle y(1) `the following is temporary. There will be more but it will made later `get keyboard input for movement if upkey()=1 then move object 1, 4 if downkey()=1 then move object 1, -4 if leftkey()=1 then yrotate object 1, wrapvalue(yAng# - 4) if rightkey()=1 then yrotate object 1, wrapvalue(yAng# + 4) `sort out the camera height xPos#= object position x(1) zPos#= object position z(1) yPos#= get ground height(1,xPos#,zPos#) `update the objexts position position object 1, xPos#,yPos#,zPos# `update chase camera chase_cam(1) `display camera object postition text 5,5, "X Position = " + str$(xPos#) text 5,25, "Y Position = " + str$(yPos#) text 5,45, "Z Position = " + str$(zPos#) `update the screen sync loop `============= `chase cam `============= function chase_cam(id) `work out the angle of the object being chased yAng#= wrapvalue(object angle y(id)+180) `grab the objects current position xPos# = object position x(id) yPos# = object position y(id) zPos# = object position z(id) `other variables camDist = 15 camHeight = 5 `work out new position xCamPos# = newxvalue(xPos#,yAng#,camDist) zCamPos# = newzvalue(zPos#,yAng#,camDist) `work out camera height yCamPos# = get ground height (1,xCamPos#,zCamPos#)+camHeight if yCamPos# < yPos#+camHeight then yCamPos# = yPos#+camHeight `update camera position position camera xCamPos#,yCamPos#+camHeight,zCamPos# point camera xPos#, yPos#+camHeight, zPos# endfunction
Full Description
` This code was downloaded from The Game Creators<br /> ` It is reproduced here with full permission<br /> ` http://www.thegamecreators.com<br /> <br /> `---------------------------<br /> `Limit Rush<br /> `Lesson 03<br /> `---------------------------<br /> `http://www.binarymoon.co.uk<br /> `Ben aka Mop<br /> `---------------------------<br /> <br /> `--------<br /> `INCLUDES<br /> `--------<br /> `include the MatEdit LoadMatrix files<br /> #include "LoadMatrix.dba"<br /> <br /> `------<br /> `ARRAYS<br /> `------<br /> `declare the MatEdit variables<br /> Dim BigMatrix(600,600,1)<br /> Dim StartLoc_X(1): Dim StartLoc_Z(1):Dim Info(2)<br /> Dim TArrayX(1): Dim TArrayZ(1): Dim FKey(10,1)<br /> Dim ColData(100): Dim ZoneData(100): Dim Tiles(500,500)<br /> Dim OverTexture$(100): Dim OverName$(20): Dim ReplaceTex(100)<br /> Dim MOffsetX(25): Dim MOffsetY(25)<br /> Dim MWire(20): Dim MGhost(20): Dim Lock(20)<br /> Dim MatX#(20): Dim MatY#(20): Dim MatZ#(20)<br /> Dim MatWidth#(20): Dim MatHeight#(20)<br /> Dim TilesX(20): Dim TilesZ(20)<br /> Dim MatHi#(20): Dim MatLo#(20)<br /> <br /> <br /> `----------<br /> `Initialize Variables<br /> `----------<br /> ArenaXYZ_SF = 15000<br /> LightXZ_SF# = .46<br /> LightY_SF# = .55<br /> <br /> <br /> <br /> `set up the program<br /> sync on<br /> sync rate 40<br /> hide mouse<br /> autocam off<br /> <br /> `load the matrix<br /> LoadMatrix("map",1)<br /> <br /> `temporary load level info<br /> load object "media/arena.x",100<br /> load object "media/arena_light.x",101<br /> <br /> `scale the arena<br /> scale object 100, ArenaXYZ_SF, ArenaXYZ_SF, ArenaXYZ_SF<br /> scale object 101, ArenaXYZ_SF*LightXZ_SF#, ArenaXYZ_SF*LightY_SF#, ArenaXYZ_SF*LightXZ_SF#<br /> <br /> `position arena<br /> position object 100,247,189,247<br /> position object 101,247,189,247<br /> <br /> <br /> `add mip-mapping<br /> set matrix texture 1,2,1<br /> set object texture 100,0,1<br /> set object texture 101,2,1<br /> <br /> `set fake light properties<br /> set object 101,1,1,0,1,0,0,1<br /> ghost object on 101<br /> <br /> `set fog properties<br /> fog on<br /> fog distance 2000<br /> fog color RGB(128,0,0)<br /> <br /> `set ambient light amount<br /> set ambient light 10<br /> <br /> `colour main light<br /> color light 0,RGB(0,0,160)<br /> <br /> `make a light<br /> make light 1<br /> set point light 1,250,200,250<br /> color light 1,RGB(255,255,100)<br /> <br /> `make a temporary player object<br /> make object cube 1,5<br /> position object 1,250,1,250<br /> <br /> <br /> `---------<br /> `MAIN LOOP<br /> `---------<br /> main:<br /> do<br /> <br /> yAng# = object angle y(1)<br /> <br /> `the following is temporary. There will be more but it will made later<br /> `get keyboard input for movement<br /> if upkey()=1 then move object 1, 4<br /> if downkey()=1 then move object 1, -4<br /> if leftkey()=1 then yrotate object 1, wrapvalue(yAng# - 4)<br /> if rightkey()=1 then yrotate object 1, wrapvalue(yAng# + 4)<br /> <br /> `sort out the camera height<br /> xPos#= object position x(1)<br /> zPos#= object position z(1)<br /> yPos#= get ground height(1,xPos#,zPos#)<br /> <br /> `update the objexts position<br /> position object 1, xPos#,yPos#,zPos#<br /> <br /> `update chase camera<br /> chase_cam(1)<br /> <br /> <br /> `display camera object postition<br /> text 5,5, "X Position = " + str$(xPos#)<br /> text 5,25, "Y Position = " + str$(yPos#)<br /> text 5,45, "Z Position = " + str$(zPos#)<br /> <br /> `update the screen<br /> sync<br /> loop<br /> <br /> <br /> `=============<br /> `chase cam<br /> `=============<br /> function chase_cam(id)<br /> <br /> `work out the angle of the object being chased<br /> yAng#= wrapvalue(object angle y(id)+180)<br /> <br /> <br /> `grab the objects current position<br /> xPos# = object position x(id)<br /> yPos# = object position y(id)<br /> zPos# = object position z(id)<br /> <br /> `other variables<br /> camDist = 15<br /> camHeight = 5<br /> <br /> `work out new position<br /> xCamPos# = newxvalue(xPos#,yAng#,camDist)<br /> zCamPos# = newzvalue(zPos#,yAng#,camDist)<br /> <br /> `work out camera height<br /> yCamPos# = get ground height (1,xCamPos#,zCamPos#)+camHeight<br /> if yCamPos# < yPos#+camHeight then yCamPos# = yPos#+camHeight<br /> <br /> `update camera position<br /> position camera xCamPos#,yCamPos#+camHeight,zCamPos#<br /> point camera xPos#, yPos#+camHeight, zPos#<br /> <br /> <br /> <br /> endfunction
Comments
No comments yet.