1 GRAVITY = 10;
2 TERMINAL_VELOCITY = 300;
3 vertical_speed = 0;
4
5 public void fall(){
6 this.vertical_speed = this.vertical_speed + GRAVITY;
7 if(this.vertical_speed > TERMINAL_VELOCITY){
8 this.vertical_speed = TERMINAL_VELOCITY;
9 }
10 this.y = this.y - this.vertical_speed;
11}
1const GRAVITY = 10;
2const TERMINAL_VELOCITY = 300;
3
4object Player
5{
6 int vertical_speed = 0;
7 int vertical_position;
8
9 function fall ()
10 {
11 this.vertical_speed = this.vertical_speed + GRAVITY;
12 if (this.vertical_speed > TERMINAL_VELOCITY)
13 {
14 this.vertical_speed = TERMINAL_VELOCITY;
15 }
16 this.vertical_position = this.vertical_position - this.vertical_speed;
17 }
18}