Godot 3.0 - GDScript Introduction

Channel:
Subscribers:
161
Published on ● Video Link: https://www.youtube.com/watch?v=XpM5G0VdH_Y



Duration: 26:37
1,239 views
27


Godot Download: https://godotengine.org/download
Godot API: http://docs.godotengine.org/en/stable/classes/index.html

Note: This video is intended for people who already know how to program in at least one language, and is meant to introduce the concepts that differentiate GDScript from other languages.

GDScript is the language used for makings scripts in the Godot engine. The other build of the engine however uses C# if you're already familiar with that language. This video will introduce you to the basic structure and some of the more commonly used methods.

Code:
extends Node2D

signal landed

export var msg = "hi" #9.0

const GRAVITY = 200

onready var hp = 0
onready var spd = 200
onready var input
onready var mov = [Vector2(-spd, 0), Vector2(spd, 0)]
onready var grounded = false

func _ready():
print(msg)
define_input()
set_process(true)
pass

func _process(delta):
for x in range(2): #0: up
if(Input.is_action_pressed(input[x])):
position += mov[x] * delta#position = position + move[x]
elif(false):
pass
else:
pass
if(!grounded):
position.y += GRAVITY * delta

func define_input():
input = ["ui_left", "ui_right"]

func _on_Area2D_area_entered(area):
if(area.is_in_group("Platform")):
grounded = true
emit_signal("landed")

func _on_Area2D_area_exited( area ):
if(area.is_in_group("Platform")):
grounded = false