Reorganizing thing in a more coherent fashion

This commit is contained in:
2024-01-19 09:12:37 -08:00
parent 88f1cec190
commit 630670d5b1
43 changed files with 3748 additions and 1511 deletions
-12
View File
@@ -1,12 +0,0 @@
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
@@ -1,19 +0,0 @@
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)
-31
View File
@@ -1,31 +0,0 @@
extends CanvasLayer
var mainScene
# 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_lv0():
get_tree().change_scene_to_file( "res://scenes/main.tscn" )
func _on_play_lv1():
get_tree().change_scene_to_file( "res://scenes/main1.tscn" )
#$".".hide()
#var w = get_node("/root/World");
#
#if !w:
#get_tree().change_scene_to_file( "res://scenes/main.tscn" )
#else:
#w.load_level()
#w.player_spawn()
#w.show()
-31
View File
@@ -1,31 +0,0 @@
extends CanvasLayer
var mainScene
# 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_lv0():
get_tree().change_scene_to_file( "res://scenes/main.tscn" )
func _on_play_lv1():
get_tree().change_scene_to_file( "res://scenes/main1.tscn" )
#$".".hide()
#var w = get_node("/root/World");
#
#if !w:
#get_tree().change_scene_to_file( "res://scenes/main.tscn" )
#else:
#w.load_level()
#w.player_spawn()
#w.show()
-22
View File
@@ -1,22 +0,0 @@
extends CanvasLayer
var start = preload("res://scenes/UI/Start.tscn").instantiate()
# 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():
#$".".hide()
#get_tree().get_root().add_child( start )
get_tree().change_scene_to_file("res://scenes/UI/Start.tscn")
-31
View File
@@ -1,31 +0,0 @@
extends CanvasLayer
var mainScene
# 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():
#$".".hide()
#var w = get_node("/root/World");
#
#if !w:
get_tree().change_scene_to_file( "res://scenes/Start.tscn" )
#else:
#w.player_spawn()
#w.show()
func _on_label_2_button_up():
get_tree().change_scene_to_file("res://scenes/UI/Start.tscn")
-103
View File
@@ -1,103 +0,0 @@
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
var direction: int = 1
var paused: bool = false
var asp: AudioStreamPlayer
var switch_gravity_sound = preload("res://audio/switch_gravity.wav")
var win = preload("res://scenes/UI/Win.tscn").instantiate()
var end = preload("res://scenes/UI/End.tscn").instantiate()
#var level_n: int = 1
var pDasher
## 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/Start.tscn")
func player_win():
#level_n += 1
#load_level()
#$"." .hide()
#get_tree().get_root().add_child( win )
get_tree().change_scene_to_file("res://scenes/UI/Win.tscn")
func player_spawn():
pDasher.position = Vector2(0,0 )
#func load_level():
##if level_n == null:
##level_n = 0
#level = Levels[level_n]
func _ready():
#load_level()
asp = $AudioStreamPlayer
#load player and level
get_node("/root/World").add_child( player.instantiate() )
#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 )
pDasher = get_node("/root/World/pDasher")
player_spawn()
## 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):
pDasher
pDasher.switch_direction()
func _on_checkpoint_body_entered(body):
body.direction = 0;
$Timer.start()
func _on_timeout():
player_win()
+4 -3
View File
@@ -1,9 +1,10 @@
extends Area2D
@export var type: String
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
-76
View File
@@ -1,76 +0,0 @@
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
@@ -1,16 +0,0 @@
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")