Intial commit

This commit is contained in:
2020-05-15 20:02:56 -04:00
commit ad966789c5
284 changed files with 6546 additions and 0 deletions

View File

@ -0,0 +1,59 @@
extends ColorRect
signal fade_complete
export var fade_on_start : bool = false
export var start_with_fade_in : bool = true
export var fade_time : float = 1
func _ready():
if fade_on_start:
# Fade on start, if enabled
fade(fade_time, start_with_fade_in)
else:
# Retain visibility
if self.visible:
modulate.a = 1
else:
modulate.a = 0
self.show()
var timePassed = 0 #Current amount of time spend displaying te
const CHECK_LENGTH = 0.05 #Interval to check for updates
var timeNeeded = 0 #Time it takes to fade out
var fadeTimer #Timer object
var fading_in = false
func fade(seconds, fade_in = false):
fading_in = fade_in
# Set timer values
timeNeeded = seconds
timePassed = 0
# Create timer if needed
if(!fadeTimer):
fadeTimer = Timer.new()
add_child(fadeTimer)
fadeTimer.connect("timeout", self, "on_fade_timeout")
# Start fader with tick speed of `CHECK_LENGTH`
fadeTimer.start(CHECK_LENGTH)
func on_fade_timeout():
timePassed += CHECK_LENGTH
# Set modulate
if fading_in:
modulate.a = 1 - abs(timePassed/timeNeeded)
else:
modulate.a = abs(timePassed/timeNeeded)
if(timePassed >= timeNeeded):
fadeTimer.stop()
emit_signal("fade_complete")
else:
fadeTimer.start(CHECK_LENGTH)

View File

@ -0,0 +1,7 @@
extends "res://Scripts/Component/StorySpeaker.gd"
func _ready():
start_dialog("intro_science")
func _on_interact():
start_dialog("intro_science_followup")

View File

@ -0,0 +1,59 @@
extends KinematicBody2D
# Environment variables
export var baseGravity : float = 9.8
# Player movment variables
export var maxMoveVelocity : float = 300
export var moveAcceleration : float = 15
export var moveFriction : float = 45
export var jumpVelocity : float = -150
var moveMotion : float = 0 # Player Input ( <- & -> )
var motion : Vector2 = Vector2(0,0) # Player's current velocity
func _physics_process(delta):
# Gravity
motion.y += baseGravity
if is_on_floor():
motion.y = 0
user_input()
# Apply velocity limits
moveMotion = clamp(moveMotion, -maxMoveVelocity, maxMoveVelocity)
# Apply velocity to frame
motion.x = moveMotion
animation_manager(moveMotion)
move_and_slide(motion, Vector2(0,-1))
func user_input():
if(Input.is_action_pressed("ui_left")):
moveMotion -= moveAcceleration
if(Input.is_action_pressed("ui_right")):
moveMotion += moveAcceleration
if(is_on_floor() and Input.is_action_just_pressed("ui_up")):
motion.y = jumpVelocity
if is_on_floor() and (!Input.is_action_pressed("ui_left") and !Input.is_action_pressed("ui_right")):
if moveMotion > 0:
moveMotion = clamp(moveMotion - moveFriction, 0, moveMotion)
elif moveMotion < 0:
moveMotion = clamp(moveMotion + moveFriction, moveMotion, 0)
func animation_manager(motion : float):
if moveMotion > 0:
$AnimationPlayer.playback_speed = abs(motion)/200
$AnimationPlayer.play("RunRight")
elif moveMotion < 0:
$AnimationPlayer.playback_speed = abs(motion)/200
$AnimationPlayer.play("RunLeft")
else:
$AnimationPlayer.playback_speed = 1
$AnimationPlayer.play("Idle")