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 / Please Correct My Code

Author
Message
James Bond
22
Years of Service
User Offline
Joined: 20th Jul 2004
Location:
Posted: 26th Jul 2004 17:28
after reading the help files and tutorials i was some how able to create a fine camera but still there are some problems with my camera .... it works ok when i press my backarrow key + left/right arrow keys combination ...... but when i press forwardarrow key with the combination of left or right key the camera dont go with the car .... please correct this cute code of mine for me
CODE:
sync on
sync rate 30
hide mouse
for x = 1 to 10
make object cube x,100
position object x,rnd(2000),0,rnd(2000)
next x
load object "c:\cube.x",1
do
if rightkey()=1
y=wrapvalue(y+5)
angley#=wrapvalue(angley#+5.0)
xrotate camera 0
yrotate camera angley#
zrotate camera 0
endif
if leftkey()=1
y=wrapvalue(y-5)
angley#=wrapvalue(angley#-5.0)
xrotate camera 0.0
yrotate camera angley#
zrotate camera 0.0
endif
if upkey()=1
move camera 10.0
move object 1,10
endif
if downkey()=1
move object 1,-10
move camera -10.0
endif
yrotate object 1,y
sync
loop
Kendor
23
Years of Service
User Offline
Joined: 31st Jan 2003
Location: Malta
Posted: 27th Jul 2004 02:34
Problems:

#1: you have two object with the same number, when you load the cube object 1 is already taken.

#2. When you press the right or left key, its the object that has to rotate not the camera.

#3. In this case, a bit of trigonometry helps! Using Sin/Cos so that the camera moves in a circle around the object. This should work:




Hope that helps!


1 + 1 is not 2, is 10

Login to post a reply

Server time is: 2026-07-27 01:02:15
Your offset time is: 2026-07-27 01:02:15