View Single Post
Old 03-16-07, 02:18 PM   #13
Deamon
Commodore
 
Join Date: Apr 2002
Location: Germany
Posts: 642
Downloads: 5
Uploads: 0


Default

Quote:
Originally Posted by Chad
Ok.. let me try this then..

Const n/s = 0.03(1000 Millisec())

rudderspin = n/s
LOL,

It's pointless to define a constant and apply Millisec() on it cose a constant is being defined only one time but we need to update the turn rate each frame so:

Code:
 Const n/s = 0.03
 
rudderspin = n/s * (1000 Millisec())
rudderspin = n/s * (1000 Millisec()) Have of course to be placed within the game loop!!!

And n/s was just an example. Give it an explicite name that is self exaplaining, like:

Const rudderTurnCoefficient = 0.03

or

Const rudderTurnCoef = 0.03

The turn coefficient appears to me way to low though. Your value meant the rudder will turn 0.03 ° per second. So it will take 22.222221 minutes before the rudder will turn to 40° lol

Take maybe 2° or 3° else experiment till you get the desired effect.

BTW: The whole point of constants is that they are defined only one time and cannot be changed again.

Quote:
If keyhit() And Rudder < (-40 : rudderspin) Turn entity 0,-0.03,0 : rudderspin
If Keyhit() And Rudder > (40 : rudderspin) Turn Entity 0,0.03,0 :rudderspin
Again make it a habit to not use numerical values in functions, so:

Code:
If keyhit() And Rudder < (-40 : rudderspin) Turn entity 0, -rudderspin, 0
If Keyhit() And Rudder > (40 : rudderspin) Turn Entity 0, rudderspin, 0
Generaly when you code gets longer and more complex and you start to use the same falue in numerical form on many different places of your code you will have to finde and change each entry when you suddenly want to alter this value. This is not only combersome but you might overlook to change a value somewhere and have suddenly a bug and don't know why. So always use variables or constants instead. Becose when you want to change the general value you just need to change it in this variable or constant.

When you have made a software that makes many calculations that use that current taxrate and the taxrate gets changed by the government then you would have to change each taxrate entry throughtout the whole code. But when you have used a constant for the taxrate instead a numerical value then all you have to do is to change the declaration of that constant and recompile.

And when you have 2 If's from which only one can be true in this pass then use If and ElseIf and not If If. Cose when the first If is true then the second one don't even need to be checked, otherwise you waste speed. So:

Code:
If keyhit() And Rudder < (-40 : rudderspin) Turn entity 0, -rudderspin, 0
ElseIf Keyhit() And Rudder > (40 : rudderspin) Turn Entity 0, rudderspin, 0
Deamon is offline   Reply With Quote