Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Player movement errors

Author
Message
LLX
21
Years of Service
User Offline
Joined: 17th Feb 2003
Location:
Posted: 6th Mar 2003 07:00
im following the tutorials and have run int oa glitch, after modify the code to work for my set up i'm getting movement errors

rem --------
rem INCLUDES
rem --------
rem include the MatEdit LoadMatrix files
#include "LoadMatrix.dba"

rem ------
rem ARRAYS
rem ------
rem declare the MatEdit variables
Dim BigMatrix(600,600,1)
Dim StartLoc_X(1): Dim StartLoc_Z(1)im 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)

rem set up the program
sync on
sync rate 40
hide mouse

rem load the matrix
LoadMatrix("BASIC1",1)

`set light properties
set ambient light 50
color ambient light RGB(255,255,255)

rem set cameral draw range
set camera range 1,53000
pitch camera down 60

autocam off

rem temp turbuckles
make object cube 1, 2100
position object 1, 50000, 6300, 53000
SET OBJECT COLLISION TO BOXES 1

`--------------
`player loading
`--------------
`make a temporary player object
make object cube 2, 5
position object 2, 2500, 7000, 2500
SET OBJECT COLLISION TO BOXES 2
friction#(1)=0.97
moveDist#(1)=0.065
xSpeed#(1)=0
zSpeed#(1)=0

rem player array
dim xSpeed#(4)
dim zSpeed#(4)
dim friction#(4)
dim moveDist#(4)

`---------
`MAIN LOOP
`---------
main:
do

`get keyboard input for movement
if upkey()=1 then forward=1 else forward=0
if downkey()=1 then backward=1 else backward=0
if leftkey()=1 then left=1 else left=0
if rightkey()=1 then right=1 else right=0

`update the player
move_player(2,forward,backward,left,right)

`update the camera
chase_cam(2)

text 10,10,str$(screen fps())

`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=3

`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#
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 6th Mar 2003 14:05
Your code didnt post right. Use the code button.

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!
LLX
21
Years of Service
User Offline
Joined: 17th Feb 2003
Location:
Posted: 7th Mar 2003 08:11
actually i did

trying again


LLX
21
Years of Service
User Offline
Joined: 17th Feb 2003
Location:
Posted: 8th Mar 2003 04:41
darndest thing, all i di was change the object numbers...

LLX
21
Years of Service
User Offline
Joined: 17th Feb 2003
Location:
Posted: 8th Mar 2003 04:59
ie turnbucke to 101 and player to 1 and it fixed everthing....oddest thing...

Login to post a reply

Server time is: 2024-09-19 23:00:13
Your offset time is: 2024-09-19 23:00:13