big four objects, custom signal, gamecontroller
This commit is contained in:
commit
39a2c3e097
16 files changed
+273
No files matched your search
@@ -0,0 +1,21 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# 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):
|
||||
pass
|
||||
|
||||
|
||||
func _on_trigger_fired(intent, body):
|
||||
print("GC knows trigger fired "+intent)
|
||||
match intent:
|
||||
"destroy":
|
||||
print("destroy this thing")
|
||||
body.queue_free()
|
||||
"powerup":
|
||||
print("power up this thing")
|
||||
@@ -0,0 +1 @@
|
||||
uid://crhflh7kooolf
|
||||
@@ -0,0 +1,33 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
const SPEED = 300.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
|
||||
@export var BUMP_POWER = 100
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# 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()
|
||||
#handle world reactions
|
||||
for i in get_slide_collision_count():
|
||||
var c = get_slide_collision(i)
|
||||
if c.get_collider() is RigidBody2D:
|
||||
c.get_collider().apply_central_impulse(-c.get_normal() * BUMP_POWER)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://kv8w1gwuy3il
|
||||
@@ -0,0 +1,19 @@
|
||||
extends Area2D
|
||||
|
||||
@export var intent = "destroy"
|
||||
|
||||
signal triggerFiredSignal(intent, body)
|
||||
|
||||
# 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):
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
print("trigger fired")
|
||||
triggerFiredSignal.emit(intent, body)
|
||||
@@ -0,0 +1 @@
|
||||
uid://b3ft6s3vbdi4k
|
||||
Reference in new issue
Block a user