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.

DarkBASIC Discussion / Function! ERRor

Author
Message
James Bond
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location:
Posted: 15th Aug 2004 16:32
`---------
`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# < yPos#+camHeight then yCamPos#=yPos#+camHeight

`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camHeight,zPos#

endfunction

`---------
`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)

`work out the height of the character
xPos#=object position x(1)
zPos#=object position z(1)
yPos#=get ground height(1,xPos#,zPos#)

`update the objects position
position object 1,xPos#,yPos#,zPos#

`update the camera
chase_cam(1)

`update the screen
sync
loop


RUNTIME ERRORrogram ran into a function declaration



How to fix this error??
hyrichter
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 16th Aug 2004 01:15
Put your function AFTER your main loop.



Dark WEDNESDAY
21
Years of Service
User Offline
Joined: 23rd May 2004
Location: Hertfordshire, UK
Posted: 16th Aug 2004 04:54
Hey 'james bond', you are posting way too much, i know this is a help forum but your just using people to make your game for you. on this page alone you have about 6 threads...In a thread i've seen other users realise this. This is ment to be an educational hobby, all you're doing is taking the knowledge of others and putting your name tag on it.

I'm with stupid...oh wait, i am stupid!
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Aug 2004 05:15
He asked a legitimate question.

"eureka" - Archimedes
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 16th Aug 2004 05:40
To make life easier you might want to consider putting all of your functions in a separate .dba file. Then you just just put #include "myfunctions.dba" or whatever it's called near the top of your main module. Even better, organize all your functions into different categories and have a whole bunch of include files (I'm using around 7-8 right now and it works fine).

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!

Login to post a reply

Server time is: 2025-05-25 10:56:14
Your offset time is: 2025-05-25 10:56:14