started tracking progress with git

This commit is contained in:
2024-01-18 11:52:02 -08:00
commit 6e10f75e31
52 changed files with 3051 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
func _ready():
#$pDasher.body_entered.connect(OnBodyEntered)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
+19
View File
@@ -0,0 +1,19 @@
extends CanvasLayer
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
_draw()
pass
func _draw():
var width = 5
var color = Color(0, 1, 0)
var start = Vector2(0,0)
var end = Vector2(100,100)
$Line2D.draw_line(start, end, color, width)
+20
View File
@@ -0,0 +1,20 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
#$CenterContainer/VBoxContainer/Button05.button_up.connect( _on_quit )
#$CenterContainer/VBoxContainer/Button01.button_up.connect( _on_play )
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_quit():
get_tree().quit()
func _on_play():
get_tree().change_scene_to_file("res://scenes/main.tscn")
+20
View File
@@ -0,0 +1,20 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
#$CenterContainer/VBoxContainer/Button05.button_up.connect( _on_quit )
#$CenterContainer/VBoxContainer/Button01.button_up.connect( _on_play )
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_quit():
get_tree().quit()
func load_start_menu():
get_tree().change_scene_to_file("res://scenes/UI/Start.tscn")
+83
View File
@@ -0,0 +1,83 @@
extends Node2D
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var gravity_vector = ProjectSettings.get_setting("physics/2d/default_gravity_vector")
var player = load("res://scenes/pDasher.tscn")
var level = load("res://scenes/levels/level_1.tscn")
var direction: int = 1
var paused: bool = false
var asp: AudioStreamPlayer
var switch_gravity_sound = preload("res://audio/switch_gravity.wav")
## WORLD METHODS
func switch_gravity():
gravity_vector = gravity_vector.rotated(deg_to_rad(180))
func switch_direction():
print("changing")
direction *= -1
## NAVIGATION
func player_fail():
get_tree().change_scene_to_file("res://scenes/UI/End.tscn")
func player_win():
get_tree().change_scene_to_file("res://scenes/UI/Win.tscn")
func _ready():
asp = $AudioStreamPlayer
#load player and level
get_node("/root/World").add_child( player.instantiate() ) #absolute way...
get_node("/root/World").add_child( level.instantiate() ) #relative way meaning <ME> or whatever node this script is attached to.
# manage signals connections
var abysses = $Level/Abysses.get_children()
for abyss in abysses:
abyss.body_entered.connect( _on_abyss_body_entered )
var gravity_switches = $Level/Switches/Gravity.get_children()
for gswitch in gravity_switches:
gswitch.body_entered.connect( _on_gswitch_body_entered )
var direction_switches = $Level/Switches/Direction.get_children()
for dswitch in direction_switches:
dswitch.body_entered.connect( _on_dswitch_body_entered )
var checkpoints = $Level/Checkpoints.get_children()
for checkpoint in checkpoints:
#print( checkpoint )
checkpoint.body_entered.connect( _on_checkpoint_body_entered )
## MAIN
#func _process(delta):
#pass
##SIGNAL HANDLING
func _on_abyss_body_entered(body):
#check that body is player
player_fail()
#print( str(body) + " se fue pal hoyo" )
func _on_gswitch_body_entered(body):
#check type of switch
#body.get_node("AnimationPlayer").spin()
asp.stream = switch_gravity_sound
asp.play()
switch_gravity()
func _on_dswitch_body_entered(body):
var dasher = get_node("/root/World/pDasher")
dasher.switch_direction()
func _on_checkpoint_body_entered(body):
body.direction = 0;
$Timer.start()
func _on_timeout():
player_win()
+10
View File
@@ -0,0 +1,10 @@
extends Area2D
@export var type: String
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
+76
View File
@@ -0,0 +1,76 @@
extends CharacterBody2D
const SPEED = 300
const JUMP_VELOCITY = -400.0
const ANGULAR_ACCELERATION = 7.5;
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var direction: int
var World: Node2D
var ap: AnimationPlayer
var asp: AudioStreamPlayer
var jumping: bool = false
var lives: int = 3
var jump_sound = preload("res://audio/jump.wav")
var land_sound = preload("res://audio/land.wav")
var fall_sound = preload("res://audio/fall.wav")
var switch_direction_sound = preload("res://audio/switch_direction.wav")
func switch_direction():
velocity.x *= -1
direction *= -1
asp.stream = switch_direction_sound
asp.play()
func _ready():
ap = $AnimationPlayer;
asp = $AudioStreamPlayer;
World = get_node("/root/World") ## why did get_world("World") didn't work?
direction = World.direction ## maybe should be getting initial direction from level
func _physics_process(delta):
if Input.is_action_just_pressed("debug"):
switch_direction()
#if direction != World.direction:
#swap_direction()
# Add the gravity.
self.up_direction = -World.gravity_vector;
$CollisionShape2D.skew = lerp( $CollisionShape2D.skew, (.001) * self.velocity.x * sin(World.gravity_vector.angle()) , delta * ANGULAR_ACCELERATION )
self.rotation = lerp( self.rotation , -World.gravity_vector.angle() + (.5*PI) , delta * ANGULAR_ACCELERATION ) ;
if not is_on_floor():
velocity.y += gravity * (sin(World.gravity_vector.angle())) * delta
velocity.x += gravity * (cos(World.gravity_vector.angle())) * delta
else:
# Handle jump.
if jumping:
jumping = false
ap.play("land")
asp.stream = land_sound
asp.play()
if Input.is_action_just_pressed("jump") and is_on_floor():
#velocity.x = JUMP_VELOCITY * cos(jump_vector.angle())
jumping = true
ap.play("jump")
asp.stream = jump_sound
asp.play()
velocity.y = JUMP_VELOCITY * sin(World.gravity_vector.angle())
if direction != 0:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
func _on_fall():
asp.stream = fall_sound
asp.play()
+16
View File
@@ -0,0 +1,16 @@
extends Area2D
@export var type: String
var w: Node
# Called when the node enters the scene tree for the first time.
func _ready():
w = get_node("/root/World")
# print(w)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func spin():
$AnimationPlayer.play("spin")