bullets playeranimations issue 4 scenemanager issue3 tilemaplayer issue5

This commit is contained in:
OddlyTimbot 2024-09-16 21:06:36 -04:00
parent 887bdfbed3
commit 56da77cd2d
21 changed files with 570 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dj70wmrhdo67v"
path="res://.godot/imported/Terrain (32x32).png-9865738cd415cdc1d530801f96959643.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/environment/Terrain (32x32).png"
dest_files=["res://.godot/imported/Terrain (32x32).png-9865738cd415cdc1d530801f96959643.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://i5fka3gxosi"
path="res://.godot/imported/crate.png-b286bd97caa3cbc59746f2db7de46191.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/objects/crate.png"
dest_files=["res://.godot/imported/crate.png-b286bd97caa3cbc59746f2db7de46191.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bh5r6fry672a4"
path="res://.godot/imported/pixel_bullet.png-a3a9722872bd6e22bf814eab1fd8d87d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/pixel_bullet.png"
dest_files=["res://.godot/imported/pixel_bullet.png-a3a9722872bd6e22bf814eab1fd8d87d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pdvgf3y1lquv"
path="res://.godot/imported/Player Idle 48x48.png-9f43f14976963a2821a06ddf8579a76a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/idle/Player Idle 48x48.png"
dest_files=["res://.godot/imported/Player Idle 48x48.png-9f43f14976963a2821a06ddf8579a76a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d0kfe5ms2vjbr"
path="res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/jump/player jump 48x48.png"
dest_files=["res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cvh48exhs1ir1"
path="res://.godot/imported/player run 48x48.png-6d66612d48bfa4c8721495ba557ab7c6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/run/player run 48x48.png"
dest_files=["res://.godot/imported/player run 48x48.png-6d66612d48bfa4c8721495ba557ab7c6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -15,6 +15,20 @@ run/main_scene="res://scenes/game.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"
[display]
window/size/viewport_width=320
window/size/viewport_height=180
window/size/window_width_override=960
window/size/window_height_override=540
window/stretch/mode="viewport"
[file_customization]
folder_colors={
"res://assets/graphics/": "red"
}
[input]
Shove={

View File

@ -1,16 +1,23 @@
[gd_scene load_steps=3 format=3 uid="uid://dkf3cij6wexnr"]
[gd_scene load_steps=4 format=3 uid="uid://dkf3cij6wexnr"]
[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_u02r5"]
[ext_resource type="Texture2D" uid="uid://bh5r6fry672a4" path="res://assets/graphics/pixel_bullet.png" id="2_veygi"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5agw0"]
size = Vector2(12, 4)
[node name="Area2D" type="Area2D"]
script = ExtResource("1_u02r5")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_5agw0")
debug_color = Color(0.209612, 0.626644, 0.380971, 0.42)
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(-3, -2)
rotation = 3.14794
scale = Vector2(0.09375, 0.09375)
texture = ExtResource("2_veygi")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,10 +1,18 @@
[gd_scene load_steps=2 format=3 uid="uid://0j0320rcnxo7"]
[gd_scene load_steps=3 format=3 uid="uid://0j0320rcnxo7"]
[ext_resource type="Texture2D" uid="uid://i5fka3gxosi" path="res://assets/graphics/objects/crate.png" id="1_7fkgs"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3vc5e"]
[node name="RigidBody2D" type="RigidBody2D"]
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(0, 1.5)
scale = Vector2(0.0757143, 0.0735714)
texture = ExtResource("1_7fkgs")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_3vc5e")
debug_color = Color(0.838874, 0.379869, 0.162504, 0.42)

View File

@ -1,39 +1,107 @@
[gd_scene load_steps=6 format=3 uid="uid://diss5ty7548p3"]
[gd_scene load_steps=10 format=4 uid="uid://diss5ty7548p3"]
[ext_resource type="PackedScene" uid="uid://0j0320rcnxo7" path="res://scenes/crate.tscn" id="1_8ekmb"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_mpwqj"]
[ext_resource type="PackedScene" uid="uid://dbgc24hrbtvxm" path="res://scenes/player.tscn" id="2_dlxtb"]
[ext_resource type="Texture2D" uid="uid://dj70wmrhdo67v" path="res://assets/graphics/environment/Terrain (32x32).png" id="2_o4xfa"]
[ext_resource type="PackedScene" uid="uid://csewven6s5npw" path="res://scenes/trigger.tscn" id="3_t3xge"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_8ejyg"]
texture = ExtResource("2_o4xfa")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
1:0/0 = 0
2:0/0 = 0
4:0/0 = 0
6:0/0 = 0
7:0/0 = 0
9:0/0 = 0
10:0/0 = 0
12:0/0 = 0
13:0/0 = 0
15:0/0 = 0
0:1/0 = 0
1:1/0 = 0
2:1/0 = 0
4:1/0 = 0
6:1/0 = 0
7:1/0 = 0
9:1/0 = 0
10:1/0 = 0
12:1/0 = 0
13:1/0 = 0
15:1/0 = 0
16:1/0 = 0
0:2/0 = 0
1:2/0 = 0
2:2/0 = 0
4:2/0 = 0
6:3/0 = 0
7:3/0 = 0
9:3/0 = 0
10:3/0 = 0
12:3/0 = 0
13:3/0 = 0
15:3/0 = 0
16:3/0 = 0
0:4/0 = 0
1:4/0 = 0
2:4/0 = 0
4:4/0 = 0
6:4/0 = 0
7:4/0 = 0
9:4/0 = 0
10:4/0 = 0
12:4/0 = 0
13:4/0 = 0
15:4/0 = 0
16:4/0 = 0
[sub_resource type="TileSet" id="TileSet_cs2mx"]
tile_size = Vector2i(32, 32)
sources/0 = SubResource("TileSetAtlasSource_8ejyg")
[sub_resource type="RectangleShape2D" id="RectangleShape2D_byea1"]
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_nl2iw"]
[node name="World" type="Node2D"]
[node name="SceneManager" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("1_mpwqj")
[node name="TileMapLayer" type="TileMapLayer" parent="."]
tile_map_data = PackedByteArray("AAASAAwAAAAAAAAAAAATAAwAAAABAAAAAAAUAAwAAAACAAAAAAAQAAwAAAAEAAQAAAAPAA4AAAAEAAQAAAANAA8AAAAEAAQAAAA=")
tile_set = SubResource("TileSet_cs2mx")
[node name="Platform" type="StaticBody2D" parent="."]
position = Vector2(537, 386)
position = Vector2(528, 395)
scale = Vector2(1.48, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"]
shape = SubResource("RectangleShape2D_byea1")
[node name="Platform4" type="StaticBody2D" parent="."]
position = Vector2(494, 449)
position = Vector2(496, 459)
scale = Vector2(1.4, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform4"]
shape = SubResource("RectangleShape2D_byea1")
[node name="Platform5" type="StaticBody2D" parent="."]
position = Vector2(452, 489)
position = Vector2(432, 491)
scale = Vector2(1.44, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform5"]
shape = SubResource("RectangleShape2D_byea1")
[node name="Platform2" type="StaticBody2D" parent="."]
position = Vector2(623, 386)
scale = Vector2(3.16, 1)
position = Vector2(624, 395)
scale = Vector2(4.68, 1)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform2"]
@ -55,14 +123,22 @@ metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"]
shape = SubResource("WorldBoundaryShape2D_nl2iw")
[node name="CharacterBody2D" parent="." instance=ExtResource("2_dlxtb")]
[node name="CharacterBody2D" parent="." groups=["player"] instance=ExtResource("2_dlxtb")]
position = Vector2(650, 362)
[node name="Camera2D" type="Camera2D" parent="CharacterBody2D"]
[node name="Area2D" parent="." instance=ExtResource("3_t3xge")]
position = Vector2(739, 500)
[node name="RigidBody2D" parent="." groups=["pushables"] instance=ExtResource("1_8ekmb")]
position = Vector2(605, 327)
[node name="RigidBody2D3" parent="." groups=["pushables"] instance=ExtResource("1_8ekmb")]
position = Vector2(648, 268)
[node name="RigidBody2D2" parent="." groups=["pushables"] instance=ExtResource("1_8ekmb")]
position = Vector2(718, 331)
[node name="BoxTrapTarget" type="Node2D" parent="."]
position = Vector2(693, 306)

View File

@ -1,6 +1,174 @@
[gd_scene load_steps=3 format=3 uid="uid://dbgc24hrbtvxm"]
[gd_scene load_steps=28 format=3 uid="uid://dbgc24hrbtvxm"]
[ext_resource type="Script" path="res://scripts/player.gd" id="1_5qpif"]
[ext_resource type="Texture2D" uid="uid://pdvgf3y1lquv" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_vcmr0"]
[ext_resource type="Texture2D" uid="uid://cvh48exhs1ir1" path="res://assets/graphics/player/run/player run 48x48.png" id="3_a03rx"]
[ext_resource type="Texture2D" uid="uid://d0kfe5ms2vjbr" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_mvdmt"]
[sub_resource type="AtlasTexture" id="AtlasTexture_etdvv"]
atlas = ExtResource("2_vcmr0")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_aj5ep"]
atlas = ExtResource("2_vcmr0")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qxp7n"]
atlas = ExtResource("2_vcmr0")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_8ypci"]
atlas = ExtResource("2_vcmr0")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_r8hvl"]
atlas = ExtResource("2_vcmr0")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_esrko"]
atlas = ExtResource("2_vcmr0")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_y2vr2"]
atlas = ExtResource("2_vcmr0")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_yd3xy"]
atlas = ExtResource("2_vcmr0")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_essvh"]
atlas = ExtResource("2_vcmr0")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_4c8ee"]
atlas = ExtResource("2_vcmr0")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_5ryb4"]
atlas = ExtResource("3_mvdmt")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ie0y6"]
atlas = ExtResource("3_mvdmt")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_vdfmb"]
atlas = ExtResource("3_mvdmt")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qxesk"]
atlas = ExtResource("3_a03rx")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ardbr"]
atlas = ExtResource("3_a03rx")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_yhaaq"]
atlas = ExtResource("3_a03rx")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_jjfaw"]
atlas = ExtResource("3_a03rx")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_snon0"]
atlas = ExtResource("3_a03rx")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_14kp5"]
atlas = ExtResource("3_a03rx")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_76poi"]
atlas = ExtResource("3_a03rx")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_rnnye"]
atlas = ExtResource("3_a03rx")
region = Rect2(336, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_wlxdo"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_etdvv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aj5ep")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qxp7n")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8ypci")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r8hvl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_esrko")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y2vr2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yd3xy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_essvh")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4c8ee")
}],
"loop": true,
"name": &"idle",
"speed": 15.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_5ryb4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ie0y6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vdfmb")
}],
"loop": false,
"name": &"jump",
"speed": 9.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qxesk")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ardbr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yhaaq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jjfaw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_snon0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_14kp5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_76poi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rnnye")
}],
"loop": true,
"name": &"run",
"speed": 15.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_mcosy"]
@ -8,6 +176,13 @@
script = ExtResource("1_5qpif")
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -7)
sprite_frames = SubResource("SpriteFrames_wlxdo")
animation = &"jump"
autoplay = "idle"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_mcosy")
debug_color = Color(0.826895, 0.282133, 0.703752, 0.42)

View File

@ -1,10 +1,15 @@
extends Area2D
@onready var bulletsprite: Sprite2D = $Sprite2D
var speed := 700
signal hit(bullet, body)
func setSpeed(speedVal):
speed = speedVal
if speedVal < 0:
bulletsprite.flip_h = true
else:
bulletsprite.flip_h = false
func _physics_process(delta: float) -> void:
position += transform.x * speed * delta

View File

@ -13,6 +13,7 @@ var pushRightEnabled = false
@onready var left_ray: RayCast2D = $LeftRay
@onready var marker_right: Node2D = $MarkerRight
@onready var marker_left: Node2D = $MarkerLeft
@onready var playerSprite: AnimatedSprite2D = $AnimatedSprite2D
var pushTarget
@ -39,31 +40,40 @@ func _physics_process(delta: float) -> void:
pushRightEnabled=false
if Input.is_action_just_pressed("shoot"):
print("I will shoot")
var mybullet = bullet.instantiate()
if faceLeft:
print("shoot left")
mybullet.setSpeed(-700)
mybullet.transform = marker_left.global_transform
# mybullet.setSpeed(-700)
#mybullet.transform = marker_left.global_transform
%SceneManager.placeBullet(-700, marker_left.global_transform)
else:
print("shoot right")
mybullet.transform = marker_right.global_transform
owner.add_child(mybullet)
#mybullet.transform = marker_right.global_transform
%SceneManager.placeBullet(700, marker_right.global_transform)
# 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 <0:
faceLeft = true
playerSprite.flip_h = true
if direction >0:
faceLeft = false
playerSprite.flip_h = false
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if is_on_floor():
if direction == 0:
playerSprite.play("idle")
else:
playerSprite.play("run")
else:
playerSprite.play("jump")
move_and_slide()
for i in get_slide_collision_count():

View File

@ -0,0 +1,49 @@
extends Node
var crate = preload("res://scenes/crate.tscn")
var bullet = preload("res://scenes/bullet.tscn")
var bulletPool:Array = []
# crate stuff
var cratePool:Array = []
@onready var box_trap_target: Node2D = $"../BoxTrapTarget"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#pool all the crates
for obj in owner.get_children():
if obj.is_in_group("pushables"):
cratePool.push_back(obj)
print("Total crates on screen : "+str(cratePool.size() ) )
func boxTrap():
print("Trigger a box trap!")
var myCrate = crateFactory()
myCrate.transform = box_trap_target.transform
owner.add_child(myCrate)
func bulletFactory():
# makes bullets!!
var myBullet
print("total bullets in play : "+str(bulletPool.size() ))
if bulletPool.size() > 3:
myBullet = bulletPool.pop_front()
else:
myBullet = bullet.instantiate()
owner.add_child(myBullet)
#or....recycles bullets
return myBullet
func placeBullet(speed, markerpos):
print("SceneManager: make a bullet")
var myBullet = bulletFactory()
bulletPool.push_back(myBullet)
print("Total bullets in play: "+str(bulletPool.size() ) )
# set the speed of bullet
myBullet.setSpeed(speed)
# set the position of the bullet
myBullet.transform = markerpos
# make the bullet visible by adding it
func crateFactory():
var myCrate = crate.instantiate()
myCrate.add_to_group("pushables")
return myCrate

View File

@ -13,6 +13,9 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void:
print("Trigger is fired")
if body.is_in_group("player"):
print("player entered the trap")
%SceneManager.boxTrap()
func _on_body_exited(body: Node2D) -> void: