adding buggy hover, teleport

This commit is contained in:
Darius 2025-02-10 11:30:11 -05:00
parent 542251725c
commit 7c292f7cec
7 changed files with 179 additions and 11 deletions

View File

@ -62,3 +62,13 @@ shoot={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":122,"location":0,"echo":false,"script":null)
]
}
hover={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":72,"key_label":0,"unicode":104,"location":0,"echo":false,"script":null)
]
}
teleport={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
]
}

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=4 uid="uid://dcmyx5g6dksl8"]
[gd_scene load_steps=24 format=4 uid="uid://dcmyx5g6dksl8"]
[ext_resource type="PackedScene" uid="uid://d1ej2kiy7jcpv" path="res://scenes/crate.tscn" id="1_uivx3"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="3_2qbah"]
@ -10,7 +10,8 @@
[ext_resource type="Script" path="res://scripts/scenemanager.gd" id="6_n2kp0"]
[ext_resource type="Texture2D" uid="uid://btdvc25chjgd" path="res://assets/graphics/terrains/Terrain (32x32).png" id="7_v20os"]
[ext_resource type="PackedScene" uid="uid://ix6oxq0kduyx" path="res://scenes/coin.tscn" id="10_nxy68"]
[ext_resource type="PackedScene" uid="uid://clitp4u6pd426" path="res://scenes/badguy.tscn" id="11_dbqj0"]
[ext_resource type="Script" path="res://scripts/badguy.gd" id="11_k2u02"]
[ext_resource type="Texture2D" uid="uid://ds7phwfwavsqj" path="res://assets/graphics/enemies/slime_green.png" id="12_u2djp"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_3ut3v"]
texture = ExtResource("7_v20os")
@ -381,6 +382,45 @@ distance = -181.0
[sub_resource type="CircleShape2D" id="CircleShape2D_mfh1j"]
[sub_resource type="AtlasTexture" id="AtlasTexture_s1yph"]
atlas = ExtResource("12_u2djp")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_ft2a6"]
atlas = ExtResource("12_u2djp")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_gg3ce"]
atlas = ExtResource("12_u2djp")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_dlo6y"]
atlas = ExtResource("12_u2djp")
region = Rect2(72, 24, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_dgoyr"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_s1yph")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ft2a6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gg3ce")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dlo6y")
}],
"loop": true,
"name": &"idle",
"speed": 12.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_i8bk0"]
size = Vector2(15, 18)
[node name="Game" type="Node2D"]
[node name="SceneManager" type="Node" parent="."]
@ -429,8 +469,8 @@ shape = SubResource("WorldBoundaryShape2D_bqh70")
[node name="CharacterBody2D" parent="." instance=ExtResource("3_8h5jv")]
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(359, 141)
scale = Vector2(5, 5)
position = Vector2(43, -53)
scale = Vector2(2.5, 2.5)
script = ExtResource("3_2qbah")
metadata/_edit_group_ = true
@ -480,8 +520,35 @@ position = Vector2(400, 40)
[node name="enemies" type="Node2D" parent="."]
[node name="Area2D3" parent="enemies" instance=ExtResource("11_dbqj0")]
[node name="Area2D3" type="Area2D" parent="enemies" groups=["enemies"]]
position = Vector2(369, 55)
script = ExtResource("11_k2u02")
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="enemies/Area2D3"]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_dgoyr")
animation = &"idle"
frame_progress = 0.764829
[node name="CollisionShape2D" type="CollisionShape2D" parent="enemies/Area2D3"]
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_i8bk0")
[node name="RightRay" type="RayCast2D" parent="enemies/Area2D3"]
target_position = Vector2(14, 0)
[node name="LeftRay" type="RayCast2D" parent="enemies/Area2D3"]
target_position = Vector2(-14, 0)
[node name="RightFloorRay" type="RayCast2D" parent="enemies/Area2D3"]
position = Vector2(9, 0)
target_position = Vector2(0, 18)
[node name="LeftFloorRay" type="RayCast2D" parent="enemies/Area2D3"]
position = Vector2(-9, 0)
target_position = Vector2(0, 18)
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
[connection signal="body_entered" from="enemies/Area2D3" to="enemies/Area2D3" method="_on_body_entered"]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=4 uid="uid://d383o6j0l3d2m"]
[gd_scene load_steps=23 format=4 uid="uid://d383o6j0l3d2m"]
[ext_resource type="Script" path="res://scripts/scenemanager.gd" id="1_g37ru"]
[ext_resource type="Texture2D" uid="uid://jlbx6yvcmten" path="res://assets/graphics/terrains/backgrounds/forestbackground.png" id="2_ehg0h"]
@ -9,6 +9,8 @@
[ext_resource type="Script" path="res://scripts/trigger.gd" id="7_2y6a6"]
[ext_resource type="PackedScene" uid="uid://ix6oxq0kduyx" path="res://scenes/coin.tscn" id="9_fv1rd"]
[ext_resource type="PackedScene" uid="uid://d1ej2kiy7jcpv" path="res://scenes/crate.tscn" id="9_sys65"]
[ext_resource type="Script" path="res://scripts/badguy.gd" id="10_5rofm"]
[ext_resource type="Texture2D" uid="uid://ds7phwfwavsqj" path="res://assets/graphics/enemies/slime_green.png" id="11_1pe1f"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_3ut3v"]
texture = ExtResource("5_p6mo5")
@ -379,6 +381,45 @@ distance = -181.0
[sub_resource type="CircleShape2D" id="CircleShape2D_mfh1j"]
[sub_resource type="AtlasTexture" id="AtlasTexture_s1yph"]
atlas = ExtResource("11_1pe1f")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_ft2a6"]
atlas = ExtResource("11_1pe1f")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_gg3ce"]
atlas = ExtResource("11_1pe1f")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_dlo6y"]
atlas = ExtResource("11_1pe1f")
region = Rect2(72, 24, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_8wjrh"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_s1yph")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ft2a6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gg3ce")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dlo6y")
}],
"loop": true,
"name": &"idle",
"speed": 12.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_060tc"]
size = Vector2(15, 18)
[node name="Game" type="Node2D"]
[node name="SceneManager" type="Node" parent="."]
@ -473,5 +514,36 @@ position = Vector2(370, 40)
[node name="Area2D2" parent="coins" instance=ExtResource("9_fv1rd")]
position = Vector2(400, 40)
[node name="enemies" type="Node2D" parent="."]
[node name="Area2D3" type="Area2D" parent="enemies" groups=["enemies"]]
position = Vector2(369, 55)
script = ExtResource("10_5rofm")
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="enemies/Area2D3"]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_8wjrh")
animation = &"idle"
[node name="CollisionShape2D" type="CollisionShape2D" parent="enemies/Area2D3"]
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_060tc")
[node name="RightRay" type="RayCast2D" parent="enemies/Area2D3"]
target_position = Vector2(14, 0)
[node name="LeftRay" type="RayCast2D" parent="enemies/Area2D3"]
target_position = Vector2(-14, 0)
[node name="RightFloorRay" type="RayCast2D" parent="enemies/Area2D3"]
position = Vector2(9, 0)
target_position = Vector2(0, 18)
[node name="LeftFloorRay" type="RayCast2D" parent="enemies/Area2D3"]
position = Vector2(-9, 0)
target_position = Vector2(0, 18)
[connection signal="areaTrigger" from="Area2D" to="." method="_on_trigger"]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]
[connection signal="body_entered" from="enemies/Area2D3" to="enemies/Area2D3" method="_on_body_entered"]

View File

@ -14,13 +14,14 @@ var pushRightEnabled = false
var pushLeftEnabled = false
@export var PUSH_FORCE = 700
@onready var animation: AnimatedSprite2D = $AnimatedSprite2D
@onready var teleportZone: Area2D = $"../Area2D"
# Bullet Attack Variables
@onready var right_target: Node2D = $RightTarget
@onready var left_target: Node2D = $LeftTarget
var isJumping = false
var safeTeleport = false
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
@ -32,13 +33,29 @@ func _physics_process(delta: float) -> void:
velocity.y = JUMP_VELOCITY
animation.play("jump")
isJumping = true
# Hover
if not is_on_floor() and Input.is_action_pressed("hover"):
velocity.x = 0
velocity.y = 0
# Shove Attack
if Input.is_action_just_pressed("shove"):
if pushRightEnabled && faceLeft == false:
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 2)
if pushLeftEnabled && faceLeft == true:
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 2)
# Teleport
if Input.is_action_just_pressed("teleport"):
while not safeTeleport:
teleportZone.position = Vector2(position.x+randf_range(-300,300),position.y+randf_range(-300,300))
if teleportZone.has_overlapping_bodies():
safeTeleport = false
else:
safeTeleport = true
safeTeleport= false
position = Vector2(teleportZone.position.x,teleportZone.position.y)
# Handle Shooting
if Input.is_action_just_pressed("shoot"):
#print("I want to shoot")

View File

@ -3,6 +3,7 @@ extends Node
@onready var coins: Node2D = $"../coins"
@onready var enemies: Node2D = $"../enemies"
var bullet = preload("res://scenes/bullet.tscn")
var bulletArray:Array = []
var bulletsMadeTotal :=0
@ -23,7 +24,6 @@ func _ready() -> void:
if obj.is_in_group("collectibles"):
totalCoins +=1
obj.coinCollected.connect(Gamecontroller.coinCollected)
var totalEnemies = 0
for obj in enemies.get_children():
if obj.is_in_group("enemies"):

View File

@ -1,4 +1,5 @@
extends Area2D
@onready var character: CharacterBody2D = $"../CharacterBody2D"
@export var effect = "alert"
signal areaTrigger(effect, Object)
@ -14,4 +15,5 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void:
print("Something in the trigger.")
print(character.position)
areaTrigger.emit(effect, body)