Whale

extends KinematicBody2D

var velocity = Vector2();
const speed = 30
const dive = 10
const gravity = 0.5
const emersion = 40
const Floor = Vector2(0,-1);

func _physics_process(delta):
if Input.is_action_pressed(«ui_left»):
velocity.x = -speed
elif Input.is_action_pressed(«ui_right»):
velocity.x = speed
else:
velocity.x = 0
if Input.is_action_pressed(«ui_up»):
velocity.y = -emersion
elif Input.is_action_pressed(«ui_down»):
velocity.y = dive

velocity.y += gravity

move_and_slide(velocity, Floor)

Поделиться
Отправить
2019   gamedev   godot
Популярное