ALOT
This commit is contained in:
commit
4f0ed45ab5
18 files changed
+281
No files matched your search
@@ -0,0 +1 @@
|
||||
class_name Crate extends RigidBody2D
|
||||
@@ -0,0 +1 @@
|
||||
uid://1f7oldcrygg1
|
||||
@@ -0,0 +1,39 @@
|
||||
extends Node2D
|
||||
|
||||
var numberOfCrates = 2
|
||||
var timer = Timer.new()
|
||||
var timeAvailable = 5
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
add_child(timer)
|
||||
# time based on seconds
|
||||
timer.wait_time = 1
|
||||
# count to 1 and stuff, false means keep clock running
|
||||
timer.one_shot = false
|
||||
timer.connect("timeout", countdown)
|
||||
timer.start()
|
||||
|
||||
func countdown() -> void:
|
||||
# Reduce time left
|
||||
timeAvailable -= 1
|
||||
if timeAvailable <= 0 and numberOfCrates > 0:
|
||||
print("LOSER")
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_trigger(body: Variant, trigger: Variant) -> void:
|
||||
print("Game controller knows trigger fired")
|
||||
body.queue_free()
|
||||
numberOfCrates -= 1
|
||||
if numberOfCrates == 0:
|
||||
print("WINNER!")
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func crateTotal(howMany):
|
||||
numberOfCrates = howMany
|
||||
print("GC knows crates: "+str(numberOfCrates))
|
||||
@@ -0,0 +1 @@
|
||||
uid://cvrssvw6p8myl
|
||||
@@ -0,0 +1,32 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 300.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var direction := Input.get_axis("ui_left", "ui_right")
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
#a loop
|
||||
for i in get_slide_collision_count():
|
||||
var c = get_slide_collision(i)
|
||||
#is this bonkable? reverse normal
|
||||
if c.get_collider() is RigidBody2D:
|
||||
c.get_collider().apply_central_impulse(-c.get_normal() * 100)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cq2vf132xjtli
|
||||
@@ -0,0 +1,22 @@
|
||||
extends Node2D
|
||||
# hold control and drag + drop
|
||||
@onready var game: Node2D = $".."
|
||||
@onready var crates: Node2D = $"../Crates"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
buildLevel()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func buildLevel() -> void:
|
||||
# Tell GC how many crates
|
||||
var totalCrates = 0
|
||||
# check if any crates in scene
|
||||
if crates:
|
||||
for obj in crates.get_children():
|
||||
if obj is Crate:
|
||||
totalCrates += 1
|
||||
game.crateTotal(totalCrates)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bfh1ec3bb5oki
|
||||
@@ -0,0 +1,16 @@
|
||||
extends Area2D
|
||||
signal areaTriggerSignal(body, trigger)
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print("Trigger is ready")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
print("YEAHHHHH TRIGGERED")
|
||||
areaTriggerSignal.emit(body, self)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bwyucgbes44rd
|
||||
Reference in new issue
Block a user