View previous topic :: View next topic |
Author |
Message |
Chad
Joined: 13 Jun 2004 Posts: 152
|
Posted: Tue Mar 22, 2005 11:21 pm Post subject: Keeping the camera on board |
|
|
Ok, this might be a simple question for you advanced programmers out there, but how do I keep thh camera on board the model? Lets say my model is level, and here's my code for that..
level = LoadMesh("sub2.3ds")
ScaleMesh level,.7,.7,.7
RotateEntity level,-90,0,0
PositionEntity level,0,-2.5,0
And I want a transparent cube around my model so the player can't fall off the ship into the sea
Another question is how to set up physics for the speeds and stuff, so say I want to have the boat in Ahead Standard, which will move at 3 units a second, how can I program this so then it's the model and the camera is unaffected and stays on the model? (another reason for asking the above question)
Thanks,
Chad |
|
Back to top |
|
|
Deamon
Joined: 30 Apr 2002 Posts: 2302 Location: Germany
|
Posted: Wed Mar 23, 2005 1:55 am Post subject: Re: Keeping the camera on board |
|
|
Chad wrote: | Ok, this might be a simple question for you advanced programmers out there, but how do I keep thh camera on board the model? |
EntityParent yourCamerName,yourModelName <-- Now the camera will be always positioned relative to your model.
Quote: |
And I want a transparent cube around my model so the player can't fall off the ship into the sea
|
Well, click on help(that's what it is for) scroll down to "3D Category" to Global: then click on collision. There you will finde enough examples.
Quote: |
Another question is how to set up physics for the speeds and stuff, so say I want to have the boat in Ahead Standard, which will move at 3 units a second, how can I program this so then it's the model and the camera is unaffected and stays on the model? (another reason for asking the above question)
|
; Vehicle controlls
Function StearSub()
;Turn sub
If KeyDown(f_point)
ty#=ty#+.1 ; Turn right
Else If KeyDown(point)
ty#=ty#-.1 ; Turn left
Else If KeyDown(m)
ty#=0 ; Rudder midship
End If
;Set speed
If KeyDown(2)
mz#=0 ; All stop
Else If KeyDown(3)
mz#=.4 ; All ahead full
Else If KeyDown(4)
mz#=.8 ; All ahead full
Else If KeyDown(5)
mz#=mz#+8 ; All ahead full
End If
;ty#=ty#+1
;RotateEntity U31,tx,ty,tz
;TurnEntity U31,tx,1,tz
End Function
; Function to move the vehicle
Function MoveSub()
MoveEntity U31,mx,my,mz
TurnEntity U31,tx,ty,tz
End Function
You have to write a game loop like this for example:
;------------ Main loop
Global FPS#=50
Include "Functions.bb"
Repeat
ProcessInput()
UpdateOcean()
MoveSub()
; FPS calculation and syncronization
oldTime#=MilliSecs()
UpdateWorld
RenderWorld
newTime#=MilliSecs()
elapsedTime#=newTime#-oldTime#
sstring$=FPS-elapsedTime
While elapsedTime < FPS
newTime#=MilliSecs()
elapsedTime#=newTime#-oldTime#
Wend
If h=5 Then
sstring1$=sstring$
h%=0
End If
Text 0,0,sstring1$
h%=h+1
Flip
Until KeyHit(1)
I syncronize the game to a curtain FPS count. It updates once in a curtain time. In this way my sub moves steadily only a curtain distance in a curtain time. If you don't want to syncronize your game to a curtain fps then you must extend your function that moves the vehicle, so that it takes in account the speed setting and the time that passed since the last update.
Deamon |
|
Back to top |
|
|
Chad
Joined: 13 Jun 2004 Posts: 152
|
Posted: Fri Mar 25, 2005 8:04 pm Post subject: |
|
|
Thanks deamon, but I'm still having some probs.. I'll play around with it some though tonight and see what i can come up with.
;one of the big problems is when I run the program it says 'Function can only appear once' and yadada it drives me insane sometimes |
|
Back to top |
|
|
Deamon
Joined: 30 Apr 2002 Posts: 2302 Location: Germany
|
Posted: Fri Mar 25, 2005 10:58 pm Post subject: |
|
|
Chad wrote: |
;one of the big problems is when I run the program it says 'Function can only appear once'
|
Hmm, never encountered this problem. Show me you code. Have you splited your code up in several files ?
What ?
Deamon |
|
Back to top |
|
|
Chad
Joined: 13 Jun 2004 Posts: 152
|
Posted: Sat Mar 26, 2005 11:09 pm Post subject: |
|
|
Ok, I've gotten rid of all the errors, however the buttons do not work.
Looking at the functions I can't see what the problem is.
BTW, yadada means the same as etc, I was just being lazy. |
|
Back to top |
|
|
Deamon
Joined: 30 Apr 2002 Posts: 2302 Location: Germany
|
Posted: Sun Mar 27, 2005 4:43 am Post subject: |
|
|
Chad wrote: | Ok, I've gotten rid of all the errors, however the buttons do not work.
Looking at the functions I can't see what the problem is. |
Whitch buttons ?
Deamon |
|
Back to top |
|
|
Chad
Joined: 13 Jun 2004 Posts: 152
|
Posted: Mon Mar 28, 2005 12:12 am Post subject: |
|
|
The buttons for stearing and speed settings for the sub. |
|
Back to top |
|
|
Deamon
Joined: 30 Apr 2002 Posts: 2302 Location: Germany
|
Posted: Mon Mar 28, 2005 5:44 am Post subject: |
|
|
Will you sort it out or do you need help ?
Deamon |
|
Back to top |
|
|
Chad
Joined: 13 Jun 2004 Posts: 152
|
Posted: Wed Mar 30, 2005 5:09 am Post subject: |
|
|
I'm going to try to sort it out..
I'll let you know if I need help |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|