From 51803d0406a6ae5539fa6393f084b05a794d4940 Mon Sep 17 00:00:00 2001 From: cormacratledge Date: Mon, 4 May 2026 21:00:45 -0400 Subject: [PATCH] fixed all my bugs and did grenades and animations --- .../player/idle/Player Idle 48x48.png | Bin 0 -> 1853 bytes .../player/idle/Player Idle 48x48.png.import | 40 +++++ .../graphics/player/run/player run 48x48.png | Bin 0 -> 3199 bytes .../player/run/player run 48x48.png.import | 40 +++++ character_body_2d.tscn | 18 -- cube.tscn | 1 - game.tscn | 25 +-- grenade.tscn | 16 ++ project.godot | 7 +- scene/character_body_2d.tscn | 162 ++++++++++++++++++ scripts/grenade.gd | 22 +++ scripts/grenade.gd.uid | 1 + scripts/player_guy.gd | 74 ++++++-- scripts/scenemanager.gd | 8 + 14 files changed, 370 insertions(+), 44 deletions(-) create mode 100644 assets/graphics/player/idle/Player Idle 48x48.png create mode 100644 assets/graphics/player/idle/Player Idle 48x48.png.import create mode 100644 assets/graphics/player/run/player run 48x48.png create mode 100644 assets/graphics/player/run/player run 48x48.png.import delete mode 100644 character_body_2d.tscn create mode 100644 grenade.tscn create mode 100644 scripts/grenade.gd create mode 100644 scripts/grenade.gd.uid diff --git a/assets/graphics/player/idle/Player Idle 48x48.png b/assets/graphics/player/idle/Player Idle 48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..b618511699269f9bd10ff834f6b382e147588ebd GIT binary patch literal 1853 zcma)7_g9k%7X30{KoA&uC&-k*2m(V}iiV98siI(^NQA(IG9>gOk_3>BBH$vuD&Qj0 zI|zutNC=Ul^rDWTh5#RBW5}0Z;id z0D!HW)LQ)TllZ>qrSM6Dh1{@21Fy#v)&T&1WM%eGr^rIaB8?#7EyK6Nbb3T-b(Qi9 z@b#CjK%>(Gp1cawwlgV<%ZmI`{@Js?c9fa+O`30QKn z&+sZ~v0+J1(Lfg1ne4(UQpF`e_K~L-=Dh`*_s2~4yA!0s+1dw}vR;TC2RIxU>xLj{;*R8j77@10XAu$?wdl)rA^c$Yi(opzgK>%z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I}f^1;J3o8h5cn!?`9lkF+or9Q7+-Si%q$0;61#wf7&QFSxyF|M3Bf8SF-} zw7q~81r8G9)Xj-*W}uk0`7EuDyIKrQ0c>mMzy~8L%+QgGNkGQ51&&xQtXbH6{qI$4 zxACe8b3>AO+8KdFPP?c!Qx9gYw!{6GrS z==WVi3O>3E@SB%Kn^*OE3k&fXn!6bYx=$O!|Bp+2x^9*+7ox)Z{G!>$$wvVg>fg~T I)3Fc#A5dKsJ^%m! literal 0 HcmV?d00001 diff --git a/assets/graphics/player/run/player run 48x48.png.import b/assets/graphics/player/run/player run 48x48.png.import new file mode 100644 index 0000000..11e140c --- /dev/null +++ b/assets/graphics/player/run/player run 48x48.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b74hvan7k63nk" +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/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/character_body_2d.tscn b/character_body_2d.tscn deleted file mode 100644 index cba6334..0000000 --- a/character_body_2d.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene format=3 uid="uid://cd5y08qaxwfny"] - -[ext_resource type="Script" uid="uid://f42eg5a0cckl" path="res://scripts/player_guy.gd" id="1_f50pn"] - -[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_80nbo"] - -[node name="CharacterBody2D" type="CharacterBody2D" unique_id=199789825] -script = ExtResource("1_f50pn") -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1058155484] -shape = SubResource("CapsuleShape2D_80nbo") - -[node name="rightcast" type="RayCast2D" parent="." unique_id=1229058621] -target_position = Vector2(55, 0) - -[node name="leftcast" type="RayCast2D" parent="." unique_id=1093993947] -target_position = Vector2(-43, 0) diff --git a/cube.tscn b/cube.tscn index 721546a..b268d9c 100644 --- a/cube.tscn +++ b/cube.tscn @@ -6,7 +6,6 @@ size = Vector2(129, 132) [node name="cube" type="RigidBody2D" unique_id=1851497894 groups=["fragile"]] -position = Vector2(11, 12) script = ExtResource("1_jbd7x") metadata/_edit_group_ = true diff --git a/game.tscn b/game.tscn index 1d73ab7..4f7c249 100644 --- a/game.tscn +++ b/game.tscn @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://d0wbtenf13iol" path="res://cube.tscn" id="3_7jktm"] [ext_resource type="Script" uid="uid://cdxh14mtlvhl6" path="res://scripts/trigger_circle.gd" id="3_feb5d"] [ext_resource type="PackedScene" uid="uid://d4nnj62h6fjcq" path="res://scene/character_body_2d.tscn" id="4_ryrav"] +[ext_resource type="PackedScene" uid="uid://c5mayb1i4ypqm" path="res://grenade.tscn" id="7_eow3j"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_mwb40"] size = Vector2(368.333, 64.236694) @@ -16,10 +17,9 @@ size = Vector2(368.333, 64.236694) radius = 153.83757 [node name="Game" type="Node2D" unique_id=1249397989] -position = Vector2(-101, -18) script = ExtResource("1_fc0e3") -[node name="scene manager" type="Node2D" parent="." unique_id=1165789663] +[node name="SceneManager" type="Node2D" parent="." unique_id=1165789663] unique_name_in_owner = true position = Vector2(661, 24) scale = Vector2(0.97016877, 1.0195743) @@ -34,7 +34,7 @@ metadata/_edit_group_ = true shape = SubResource("RectangleShape2D_mwb40") [node name="left wall" type="StaticBody2D" parent="." unique_id=1287017623] -position = Vector2(250, 402.99994) +position = Vector2(-143, 215) rotation = 1.4884713 script = ExtResource("1_e2o6t") metadata/_edit_group_ = true @@ -43,7 +43,7 @@ metadata/_edit_group_ = true shape = SubResource("RectangleShape2D_mwb40") [node name="right wall" type="StaticBody2D" parent="." unique_id=820553779] -position = Vector2(567, 388.99994) +position = Vector2(-483, 92) rotation = -1.6017642 script = ExtResource("1_e2o6t") metadata/_edit_group_ = true @@ -58,7 +58,7 @@ scale = Vector2(0.86305076, 3.6811934) constant_linear_velocity = Vector2(250, 0) [node name="wall left" type="CollisionShape2D" parent="conveyor" unique_id=482160421] -position = Vector2(231.63736, -442.00055) +position = Vector2(406.85486, -406.34064) rotation = 1.6034058 scale = Vector2(0.9552965, 0.99587345) shape = SubResource("RectangleShape2D_mwb40") @@ -70,9 +70,6 @@ metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="world border" unique_id=1075301728] shape = SubResource("WorldBoundaryShape2D_mwb40") -[node name="CharacterBody2D" parent="." unique_id=44928680 instance=ExtResource("4_ryrav")] -position = Vector2(373, 474.99994) - [node name="Area2D" type="Area2D" parent="." unique_id=733267557] position = Vector2(945, 535) script = ExtResource("3_feb5d") @@ -84,16 +81,22 @@ shape = SubResource("CircleShape2D_e2o6t") [node name="cube container" type="Node2D" parent="." unique_id=22976120] [node name="cube" parent="cube container" unique_id=1851497894 instance=ExtResource("3_7jktm")] -position = Vector2(366.99994, 37.99997) +position = Vector2(429.00003, 372) scale = Vector2(0.97196096, 1.0195743) [node name="cube2" parent="cube container" unique_id=1345370216 instance=ExtResource("3_7jktm")] -position = Vector2(348.99994, -235.00003) +position = Vector2(921, -508.99997) scale = Vector2(0.97196096, 1.0195743) [node name="cube3" parent="cube container" unique_id=321996969 instance=ExtResource("3_7jktm")] -position = Vector2(342.99997, -106.00003) +position = Vector2(978.99994, -294) scale = Vector2(0.97196096, 1.0195743) +[node name="CharacterBody2D" parent="." unique_id=44928680 instance=ExtResource("4_ryrav")] +position = Vector2(263, 481) + +[node name="grenade" parent="." unique_id=1844025628 instance=ExtResource("7_eow3j")] +position = Vector2(-37, 236) + [connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] [connection signal="triggerActiveSignal" from="Area2D" to="." method="on_trigger"] diff --git a/grenade.tscn b/grenade.tscn new file mode 100644 index 0000000..f8dbbfd --- /dev/null +++ b/grenade.tscn @@ -0,0 +1,16 @@ +[gd_scene format=3 uid="uid://c5mayb1i4ypqm"] + +[ext_resource type="Script" uid="uid://wctwda5bor10" path="res://scripts/grenade.gd" id="1_gju2f"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_pu16u"] + +[node name="grenade" type="RigidBody2D" unique_id=1844025628] +contact_monitor = true +max_contacts_reported = 3 +script = ExtResource("1_gju2f") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=953914170] +shape = SubResource("CircleShape2D_pu16u") +debug_color = Color(0.45701438, 0.5945938, 3.85046e-07, 0.41960785) + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/project.godot b/project.godot index accda76..0629f79 100644 --- a/project.godot +++ b/project.godot @@ -25,7 +25,12 @@ folder_colors={ "magic push"={ "deadzone": 0.2, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(449, 17),"global_position":Vector2(458, 65),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(404, 16),"global_position":Vector2(413, 64),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} +chuck={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(227, 2),"global_position":Vector2(236, 50),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } diff --git a/scene/character_body_2d.tscn b/scene/character_body_2d.tscn index ddd95e4..f297f1a 100644 --- a/scene/character_body_2d.tscn +++ b/scene/character_body_2d.tscn @@ -1,12 +1,174 @@ [gd_scene format=3 uid="uid://d4nnj62h6fjcq"] [ext_resource type="Script" uid="uid://f42eg5a0cckl" path="res://scripts/player_guy.gd" id="1_j5628"] +[ext_resource type="Texture2D" uid="uid://p72rbg7thsvi" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_qug0s"] +[ext_resource type="Texture2D" uid="uid://b74hvan7k63nk" path="res://assets/graphics/player/run/player run 48x48.png" id="3_gd05a"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_80nbo"] +[sub_resource type="AtlasTexture" id="AtlasTexture_gd05a"] +atlas = ExtResource("2_qug0s") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_86iwx"] +atlas = ExtResource("2_qug0s") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_318mt"] +atlas = ExtResource("2_qug0s") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_b8c3x"] +atlas = ExtResource("2_qug0s") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ogaei"] +atlas = ExtResource("2_qug0s") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mjxbh"] +atlas = ExtResource("2_qug0s") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pykq2"] +atlas = ExtResource("2_qug0s") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7y57j"] +atlas = ExtResource("2_qug0s") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1hjxj"] +atlas = ExtResource("2_qug0s") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0npi7"] +atlas = ExtResource("2_qug0s") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mu2pl"] +atlas = ExtResource("3_gd05a") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_joior"] +atlas = ExtResource("3_gd05a") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_kvipg"] +atlas = ExtResource("3_gd05a") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wpf5e"] +atlas = ExtResource("3_gd05a") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yb3qs"] +atlas = ExtResource("3_gd05a") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_js44f"] +atlas = ExtResource("3_gd05a") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rs0n8"] +atlas = ExtResource("3_gd05a") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_022hi"] +atlas = ExtResource("3_gd05a") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="SpriteFrames" id="SpriteFrames_mu2pl"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_gd05a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_86iwx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_318mt") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_b8c3x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ogaei") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mjxbh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pykq2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7y57j") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1hjxj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0npi7") +}], +"loop": true, +"name": &"idle", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_mu2pl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_joior") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_kvipg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wpf5e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yb3qs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_js44f") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rs0n8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_022hi") +}], +"loop": true, +"name": &"run", +"speed": 12.0 +}] + [node name="CharacterBody2D" type="CharacterBody2D" unique_id=44928680] +position = Vector2(-33, 19) script = ExtResource("1_j5628") metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=547069058] shape = SubResource("CapsuleShape2D_80nbo") + +[node name="RightCast" type="RayCast2D" parent="." unique_id=1862370013] +target_position = Vector2(34, 1) + +[node name="LeftCast" type="RayCast2D" parent="." unique_id=2108646942] +target_position = Vector2(-39, 1) + +[node name="rightspawn" type="Marker2D" parent="." unique_id=1690283250] +position = Vector2(18, -8) + +[node name="leftspawn" type="Marker2D" parent="." unique_id=1655353827] +position = Vector2(-20, -8) + +[node name="player graphic" type="AnimatedSprite2D" parent="." unique_id=1007399411] +texture_filter = 1 +position = Vector2(2, -26) +scale = Vector2(2.5208335, 2.3541667) +sprite_frames = SubResource("SpriteFrames_mu2pl") +animation = &"run" +autoplay = "idle" diff --git a/scripts/grenade.gd b/scripts/grenade.gd new file mode 100644 index 0000000..ef03bb4 --- /dev/null +++ b/scripts/grenade.gd @@ -0,0 +1,22 @@ +class_name grenade extends RigidBody2D + +var timer = Timer.new() + +func _ready() -> void: + add_child(timer) + + timer.wait_time = 2 + + timer.one_shot = true + timer.connect("timeout", explode) + timer.start() + +func explode()->void: + print("boom boom") + self.queue_free() + +func _on_body_entered(body: Node) -> void: + print("the grenade collision works") + if body.is_in_group("fragile"): + body.queue_free() + explode() diff --git a/scripts/grenade.gd.uid b/scripts/grenade.gd.uid new file mode 100644 index 0000000..96b9f2c --- /dev/null +++ b/scripts/grenade.gd.uid @@ -0,0 +1 @@ +uid://wctwda5bor10 diff --git a/scripts/player_guy.gd b/scripts/player_guy.gd index 0cf230c..694c23f 100644 --- a/scripts/player_guy.gd +++ b/scripts/player_guy.gd @@ -1,51 +1,99 @@ class_name Player extends CharacterBody2D -@onready var rightcast: RayCast2D = $rightcast -@onready var leftcast: RayCast2D = $leftcast - - const SPEED =200.0 -const JUMP_VELOCITY = -300.0 +const JUMP_VELOCITY = -500.0 var direction enum FaceDirection{LEFT, RIGHT} -var facing:FaceDirection = FaceDirection +var facing:FaceDirection = FaceDirection.RIGHT +enum player_state{IDLE,RUNNING} +var current_player_state:player_state = player_state.IDLE +@onready var player_graphic: AnimatedSprite2D = $"player graphic" + +@onready var rightspawn: Marker2D = $rightspawn +@onready var leftspawn: Marker2D = $leftspawn + +@onready var right_cast: RayCast2D = $RightCast +@onready var left_cast: RayCast2D = $LeftCast +var pushTarget +var pushEnabled:bool=false + +func _ready() -> void: + print(right_cast) + func _physics_process(delta: float) -> void: handle_input() handle_movement(delta) + handle_state() + handle_animation() move_and_slide() handle_collisions() func handle_input()->void: + if Input.is_action_just_pressed("chuck"): + print("chuck grenade") + %SceneManager.makeGrenade(rightspawn.global_transform, 1) + if Input.is_action_just_pressed("ui_accept"): velocity.y = JUMP_VELOCITY - if Input.is_action_just_pressed("magic push"): - print ("may the force be with you") + if Input.is_action_just_pressed("magic push") and pushEnabled: + print("I want to shove") + var shoveDirection:int + match facing: + FaceDirection.RIGHT: + shoveDirection = 1 + FaceDirection.LEFT: + shoveDirection = -1 + pushTarget.apply_central_impulse(Vector2(shoveDirection,0)*700) # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. direction = Input.get_axis("ui_left", "ui_right") if direction<0: facing = FaceDirection.LEFT + player_graphic.flip_h = true if direction>0: facing = FaceDirection.RIGHT + player_graphic.flip_h = false func handle_movement(delta)->void: if not is_on_floor(): velocity += get_gravity() * delta # Handle jump. - + if direction: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) - + func handle_collisions()->void: - if rightcast.is_colliding() and facing==FaceDirection.RIGHT: - print("yay") - move_and_slide() + if right_cast.is_colliding() && facing==FaceDirection.RIGHT: + var collider = right_cast.get_collider() + if collider is Node && collider is RigidBody2D: + pushTarget = collider + pushEnabled = true + if left_cast.is_colliding() && facing==FaceDirection.LEFT: + var collider = left_cast.get_collider() + if collider is Node && collider is RigidBody2D: + pushTarget = collider + pushEnabled = true for i in get_slide_collision_count(): var c = get_slide_collision(i) if c.get_collider() is RigidBody2D: #deliver the impact c.get_collider().apply_central_impulse(-c.get_normal() * 100) + +func handle_state()->void: + match current_player_state: + player_state.IDLE when velocity.x !=0: + print("runnnnnn") + current_player_state = player_state.RUNNING + player_state.RUNNING when velocity.x ==0: + current_player_state = player_state.IDLE + +func handle_animation()->void: + match current_player_state: + player_state.IDLE: + player_graphic.play("idle") + player_state.RUNNING: + player_graphic.play("run") diff --git a/scripts/scenemanager.gd b/scripts/scenemanager.gd index 02e67ef..5aa253a 100644 --- a/scripts/scenemanager.gd +++ b/scripts/scenemanager.gd @@ -1,4 +1,6 @@ class_name SM extends Node2D + +var grenade = preload("res://grenade.tscn") @onready var game: Node2D = $".." @onready var cube_container: Node2D = $"../cube container" @@ -23,3 +25,9 @@ func updateCube()->void: _CubeTotal +=1 print ("Number of cubes: "+str(_CubeTotal)) +func makeGrenade(_grenadeposition, _grenadedirection)->void: + print("grenade time") + var myGrenade:grenade = grenade.instantiate() + owner.add_child(myGrenade) + myGrenade.transform = _grenadeposition + myGrenade.apply_central_impulse(Vector2(_grenadedirection, -1)*400)