week 4
This commit is contained in:
parent
84e1af69e3
commit
fa90394599
BIN
assets/graphics/player/idle/Player Idle 48x48.png
Normal file
BIN
assets/graphics/player/idle/Player Idle 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
40
assets/graphics/player/idle/Player Idle 48x48.png.import
Normal file
40
assets/graphics/player/idle/Player Idle 48x48.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dyus25iplw8ei"
|
||||||
|
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/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
|
||||||
BIN
assets/graphics/player/jump_fall/player jump 48x48.png
Normal file
BIN
assets/graphics/player/jump_fall/player jump 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1021 B |
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bihghvekq435s"
|
||||||
|
path="res://.godot/imported/player jump 48x48.png-bb6ba8ccf76c9bd3765199af95f48c3c.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/jump_fall/player jump 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/player jump 48x48.png-bb6ba8ccf76c9bd3765199af95f48c3c.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
|
||||||
BIN
assets/graphics/player/running/player run 48x48.png
Normal file
BIN
assets/graphics/player/running/player run 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
40
assets/graphics/player/running/player run 48x48.png.import
Normal file
40
assets/graphics/player/running/player run 48x48.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://3c7ngirfyrkh"
|
||||||
|
path="res://.godot/imported/player run 48x48.png-3529730a2a1b5884902527ab512e774d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/player/running/player run 48x48.png"
|
||||||
|
dest_files=["res://.godot/imported/player run 48x48.png-3529730a2a1b5884902527ab512e774d.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
|
||||||
@ -5,8 +5,11 @@
|
|||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rtl8c"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rtl8c"]
|
||||||
|
|
||||||
[node name="Bullet" type="Area2D" unique_id=1567847193]
|
[node name="Bullet" type="Area2D" unique_id=1567847193]
|
||||||
|
scale = Vector2(1, 0.5)
|
||||||
script = ExtResource("1_mkf8s")
|
script = ExtResource("1_mkf8s")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=492684522]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=492684522]
|
||||||
shape = SubResource("RectangleShape2D_rtl8c")
|
shape = SubResource("RectangleShape2D_rtl8c")
|
||||||
debug_color = Color(0.5263991, 0.42294088, 0.98291093, 0.41960785)
|
debug_color = Color(0.5263991, 0.42294088, 0.98291093, 0.41960785)
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://s0utas3jmhjk" path="res://scenes/player.tscn" id="3_iywne"]
|
[ext_resource type="PackedScene" uid="uid://s0utas3jmhjk" path="res://scenes/player.tscn" id="3_iywne"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bf50mxdma8wq4" path="res://scenes/trigger.tscn" id="3_lbhrr"]
|
[ext_resource type="PackedScene" uid="uid://bf50mxdma8wq4" path="res://scenes/trigger.tscn" id="3_lbhrr"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cp6dv18imsngd" path="res://scenes/bullet.tscn" id="6_p57ef"]
|
[ext_resource type="PackedScene" uid="uid://cp6dv18imsngd" path="res://scenes/bullet.tscn" id="6_p57ef"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bgi18lbutp5ui" path="res://scenes/npc_character.tscn" id="7_u5sy4"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8cj0n"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8cj0n"]
|
||||||
size = Vector2(46, 20)
|
size = Vector2(46, 20)
|
||||||
@ -69,3 +70,6 @@ shape = SubResource("WorldBoundaryShape2D_iywne")
|
|||||||
|
|
||||||
[node name="Bullet" parent="." unique_id=1567847193 instance=ExtResource("6_p57ef")]
|
[node name="Bullet" parent="." unique_id=1567847193 instance=ExtResource("6_p57ef")]
|
||||||
position = Vector2(256, 130)
|
position = Vector2(256, 130)
|
||||||
|
|
||||||
|
[node name="NPCCharacter" parent="." unique_id=832040226 instance=ExtResource("7_u5sy4")]
|
||||||
|
position = Vector2(219, 169)
|
||||||
|
|||||||
12
scenes/npc_character.tscn
Normal file
12
scenes/npc_character.tscn
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bgi18lbutp5ui"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://gutmbv5ff4u4" path="res://scripts/npc_character.gd" id="1_xtrxv"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_aykgk"]
|
||||||
|
|
||||||
|
[node name="NPCCharacter" type="CharacterBody2D" unique_id=832040226]
|
||||||
|
script = ExtResource("1_xtrxv")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2143761871]
|
||||||
|
shape = SubResource("CircleShape2D_aykgk")
|
||||||
|
debug_color = Color(0.79109746, 0.38828364, 0.48745263, 0.41960785)
|
||||||
@ -1,9 +1,182 @@
|
|||||||
[gd_scene format=3 uid="uid://s0utas3jmhjk"]
|
[gd_scene format=3 uid="uid://s0utas3jmhjk"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c17de7vvtri1e" path="res://scripts/player.gd" id="1_3vyb7"]
|
[ext_resource type="Script" uid="uid://c17de7vvtri1e" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bihghvekq435s" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dyus25iplw8ei" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://3c7ngirfyrkh" path="res://assets/graphics/player/running/player run 48x48.png" id="3_qhqgy"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_lnu2h"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_lnu2h"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_dqkch"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(240, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(288, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(384, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3v2ag"]
|
||||||
|
atlas = ExtResource("2_g2els")
|
||||||
|
region = Rect2(432, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a38lo"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
|
||||||
|
atlas = ExtResource("2_dqkch")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(48, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_oprun"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(96, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a8ls1"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(144, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_qfm1y"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(192, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fulsm"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(240, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4r5pv"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(288, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_60mlk"]
|
||||||
|
atlas = ExtResource("3_qhqgy")
|
||||||
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_jej6c"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_i4ail")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"falling",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_qhqgy")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_dqkch")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_qlg0r")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_tuyoq")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fjrip")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_smehm")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_ur7pv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_y4r1p")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_d2wvv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_3v2ag")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"idle",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_a38lo")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4ni07")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"jumping",
|
||||||
|
"speed": 12.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_jej6c")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_f1ej7")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_oprun")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_a8ls1")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_qfm1y")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fulsm")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_4r5pv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_60mlk")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"running",
|
||||||
|
"speed": 12.0
|
||||||
|
}]
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" unique_id=1109630338]
|
[node name="Player" type="CharacterBody2D" unique_id=1109630338]
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(2, 2)
|
||||||
script = ExtResource("1_3vyb7")
|
script = ExtResource("1_3vyb7")
|
||||||
@ -17,4 +190,13 @@ debug_color = Color(0.89751947, 0.22656804, 0.5594576, 0.41960785)
|
|||||||
position = Vector2(23.5, -5)
|
position = Vector2(23.5, -5)
|
||||||
|
|
||||||
[node name="LeftTarget" type="Marker2D" parent="." unique_id=2004390104]
|
[node name="LeftTarget" type="Marker2D" parent="." unique_id=2004390104]
|
||||||
position = Vector2(-23.5, -11)
|
position = Vector2(-23.5, -7.5)
|
||||||
|
|
||||||
|
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=2117483419]
|
||||||
|
texture_filter = 1
|
||||||
|
position = Vector2(1, -6.5)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_jej6c")
|
||||||
|
animation = &"jumping"
|
||||||
|
autoplay = "idle"
|
||||||
|
|
||||||
|
[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"]
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
class_name Bullet extends Area2D
|
class_name Bullet extends Area2D
|
||||||
|
|
||||||
var speed:float=700
|
var speed:float=700
|
||||||
|
signal bulletDamageSignal(body,bullet)
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func setSpeed(value) -> void:
|
||||||
|
speed=value
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
position +=transform.x*speed *delta
|
position +=transform.x*speed *delta
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
|
bulletDamageSignal.emit(body,self)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ var timeAvailable := 10
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
get_window().grab_focus()
|
||||||
add_child(timer)
|
add_child(timer)
|
||||||
timer.wait_time =1
|
timer.wait_time =1
|
||||||
timer.one_shot=false
|
timer.one_shot=false
|
||||||
@ -35,11 +36,8 @@ func _on_trigger(body: Variant,effect,trigger) -> void:
|
|||||||
if body is Crate:
|
if body is Crate:
|
||||||
match effect:
|
match effect:
|
||||||
"destroy":
|
"destroy":
|
||||||
crateTotal -=1
|
|
||||||
if crateTotal <=0:
|
|
||||||
print("you win")
|
|
||||||
levelChangeSignal.emit(currentScene)
|
|
||||||
destroySignal.emit(body)
|
destroySignal.emit(body)
|
||||||
|
|
||||||
"teleport":
|
"teleport":
|
||||||
print("GC teleport an object")
|
print("GC teleport an object")
|
||||||
teleportSignal.emit(body)
|
teleportSignal.emit(body)
|
||||||
@ -59,4 +57,23 @@ func _on_trigger(body: Variant,effect,trigger) -> void:
|
|||||||
func crateUpdate(cratesAmount) ->void:
|
func crateUpdate(cratesAmount) ->void:
|
||||||
crateTotal=cratesAmount
|
crateTotal=cratesAmount
|
||||||
print("GC updated crates: " +str(crateTotal))
|
print("GC updated crates: " +str(crateTotal))
|
||||||
|
if crateTotal <=0:
|
||||||
|
print("you win")
|
||||||
|
levelChangeSignal.emit(currentScene)
|
||||||
|
|
||||||
|
func bulletDamage(body:Node2D,bullet:Bullet) -> void:
|
||||||
|
if body is Crate:
|
||||||
|
# destroy Crate
|
||||||
|
destroySignal.emit(body)
|
||||||
|
destroySignal.emit(bullet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
12
scripts/npc_character.gd
Normal file
12
scripts/npc_character.gd
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class_name NPCCharacter extends CharacterBody2D
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if not is_on_floor():
|
||||||
|
velocity+=get_gravity() * delta
|
||||||
|
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
func knockBack(direction,duration:float=0.2):
|
||||||
|
velocity =direction
|
||||||
|
await get_tree().create_timer(duration).timeout
|
||||||
|
velocity =Vector2.ZERO
|
||||||
1
scripts/npc_character.gd.uid
Normal file
1
scripts/npc_character.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://gutmbv5ff4u4
|
||||||
@ -2,20 +2,44 @@ class_name Player extends CharacterBody2D
|
|||||||
|
|
||||||
@onready var right_target: Marker2D = $RightTarget
|
@onready var right_target: Marker2D = $RightTarget
|
||||||
@onready var left_target: Marker2D = $LeftTarget
|
@onready var left_target: Marker2D = $LeftTarget
|
||||||
|
@onready var player_graphic: AnimatedSprite2D = $PlayerGraphic
|
||||||
|
|
||||||
|
|
||||||
const SPEED = 300.0
|
const SPEED = 300.0
|
||||||
const JUMP_VELOCITY = -400.0
|
const JUMP_VELOCITY = -400.0
|
||||||
const BUMP_POWER=50
|
const BUMP_POWER=50
|
||||||
enum FaceDirection{LEFT, RIGHT}
|
enum FaceDirection{LEFT, RIGHT}
|
||||||
|
var direction
|
||||||
var facing:FaceDirection =FaceDirection.RIGHT
|
var facing:FaceDirection =FaceDirection.RIGHT
|
||||||
|
enum PlayerState{IDLE,RUNNING, JUMPING,FALLING}
|
||||||
|
var current_player_state:PlayerState=PlayerState.IDLE
|
||||||
|
var jumpUP:bool=false
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# Add the gravity.
|
handle_input()
|
||||||
if not is_on_floor():
|
handle_movement(delta)
|
||||||
velocity += get_gravity() * delta
|
handle_state()
|
||||||
|
handle_animation()
|
||||||
|
move_and_slide()
|
||||||
|
handle_collision()
|
||||||
|
|
||||||
|
|
||||||
|
# Get the input direction and handle the movement/deceleration.
|
||||||
|
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
|
|
||||||
|
func handle_input() -> void:
|
||||||
|
direction = Input.get_axis("ui_left", "ui_right")
|
||||||
|
if direction <0:
|
||||||
|
player_graphic.flip_h=true
|
||||||
|
if direction > 0:
|
||||||
|
player_graphic.flip_h=false
|
||||||
|
|
||||||
|
# handle jump
|
||||||
|
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||||
|
velocity.y = JUMP_VELOCITY
|
||||||
|
current_player_state =PlayerState.JUMPING
|
||||||
|
jumpUP=true
|
||||||
|
|
||||||
# handle shoot
|
# handle shoot
|
||||||
if Input.is_action_just_pressed("shoot"):
|
if Input.is_action_just_pressed("shoot"):
|
||||||
print("Player1 wants to shoot")
|
print("Player1 wants to shoot")
|
||||||
@ -27,14 +51,12 @@ func _physics_process(delta: float) -> void:
|
|||||||
FaceDirection.LEFT:
|
FaceDirection.LEFT:
|
||||||
print("shoot to the left")
|
print("shoot to the left")
|
||||||
%SceneManager.makebullet(left_target.global_transform,-700)
|
%SceneManager.makebullet(left_target.global_transform,-700)
|
||||||
|
|
||||||
# Handle jump.
|
func handle_movement(delta) -> void:
|
||||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
# Add the gravity.
|
||||||
velocity.y = JUMP_VELOCITY
|
if not is_on_floor():
|
||||||
|
velocity += get_gravity() * delta
|
||||||
# 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:
|
if direction:
|
||||||
velocity.x = direction * SPEED
|
velocity.x = direction * SPEED
|
||||||
if direction <0:
|
if direction <0:
|
||||||
@ -43,12 +65,50 @@ func _physics_process(delta: float) -> void:
|
|||||||
facing =FaceDirection.RIGHT
|
facing =FaceDirection.RIGHT
|
||||||
else:
|
else:
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
|
|
||||||
|
func handle_state() -> void:
|
||||||
|
match current_player_state:
|
||||||
|
PlayerState.IDLE when velocity.x !=0:
|
||||||
|
# change to running
|
||||||
|
current_player_state=PlayerState.RUNNING
|
||||||
|
PlayerState.RUNNING when velocity.x ==0:
|
||||||
|
current_player_state=PlayerState.IDLE
|
||||||
|
PlayerState.JUMPING when velocity.y==0:
|
||||||
|
current_player_state=PlayerState.FALLING
|
||||||
|
PlayerState.FALLING when is_on_floor():
|
||||||
|
if velocity.x ==0:
|
||||||
|
current_player_state=PlayerState.IDLE
|
||||||
|
else:
|
||||||
|
current_player_state=PlayerState.RUNNING
|
||||||
|
|
||||||
|
func handle_animation() -> void:
|
||||||
|
match current_player_state:
|
||||||
|
PlayerState.IDLE:
|
||||||
|
player_graphic.play("idle")
|
||||||
|
PlayerState.RUNNING:
|
||||||
|
player_graphic.play("running")
|
||||||
|
PlayerState.JUMPING:
|
||||||
|
if jumpUP:
|
||||||
|
player_graphic.play("jumping")
|
||||||
|
PlayerState.FALLING:
|
||||||
|
player_graphic.play("falling")
|
||||||
|
|
||||||
move_and_slide()
|
func handle_collision() ->void:
|
||||||
for i in get_slide_collision_count():
|
for i in get_slide_collision_count():
|
||||||
var c =get_slide_collision(i)
|
var c =get_slide_collision(i)
|
||||||
if c.get_collider() is RigidBody2D:
|
if c.get_collider() is RigidBody2D:
|
||||||
c.get_collider().apply_central_impulse(-c.get_normal()*BUMP_POWER)
|
c.get_collider().apply_central_impulse(-c.get_normal()*BUMP_POWER)
|
||||||
|
if c.get_collider() is NPCCharacter:
|
||||||
|
var myCharacter:NPCCharacter = c.get_collider()
|
||||||
|
var direction = -c.get_normal()*BUMP_POWER
|
||||||
|
myCharacter.knockBack(direction)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_animation_finished() -> void:
|
||||||
|
match current_player_state:
|
||||||
|
PlayerState.JUMPING:
|
||||||
|
jumpUP =false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,10 @@ class_name SceneManager extends Node2D
|
|||||||
@onready var level: Node2D = $"../Level"
|
@onready var level: Node2D = $"../Level"
|
||||||
@onready var crates: Node2D = $"../Crates"
|
@onready var crates: Node2D = $"../Crates"
|
||||||
@onready var game: GameController = $".."
|
@onready var game: GameController = $".."
|
||||||
|
# has the recepies
|
||||||
|
var bullet = preload("res://scenes/bullet.tscn")
|
||||||
|
var bulletArray:Array[Bullet] = []
|
||||||
|
var totalAllowedBullets:int=7
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
@ -47,7 +51,11 @@ func updatesCrates() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func destroy(body)->void:
|
func destroy(body)->void:
|
||||||
|
if body is Bullet:
|
||||||
|
stashBullet(body)
|
||||||
|
return
|
||||||
body.queue_free()
|
body.queue_free()
|
||||||
|
|
||||||
func teleport(body) -> void:
|
func teleport(body) -> void:
|
||||||
if body is Crate:
|
if body is Crate:
|
||||||
var viewport_size = get_viewport().get_visible_rect().size
|
var viewport_size = get_viewport().get_visible_rect().size
|
||||||
@ -58,9 +66,38 @@ func teleport(body) -> void:
|
|||||||
|
|
||||||
func loadLevel(level:String) -> void:
|
func loadLevel(level:String) -> void:
|
||||||
get_tree().call_deferred("change_scene_to_file",level)
|
get_tree().call_deferred("change_scene_to_file",level)
|
||||||
|
|
||||||
|
func stashBullet(bullet:Bullet) -> void:
|
||||||
|
var stashPosition:Vector2 =Vector2(-100,-100)
|
||||||
|
bullet.position=stashPosition
|
||||||
|
bullet.setSpeed(0)
|
||||||
|
bullet.set_process(false)
|
||||||
|
|
||||||
func makeBullet(targetPosition,speed) -> void:
|
|
||||||
|
func bulletFactory()-> Bullet:
|
||||||
|
var myBullet:Bullet
|
||||||
|
# how many bullets have been made?
|
||||||
|
if bulletArray.size() <=totalAllowedBullets:
|
||||||
|
myBullet=bullet.instantiate()
|
||||||
|
if not myBullet.bulletDamageSignal.is_connected(game.bulletDamage):
|
||||||
|
myBullet.bulletDamageSignal.connect(game.bulletDamage)
|
||||||
|
|
||||||
|
game.add_child(myBullet)
|
||||||
|
else:
|
||||||
|
myBullet=bulletArray.pop_back()
|
||||||
|
bulletArray.push_front(myBullet)
|
||||||
|
return myBullet
|
||||||
|
|
||||||
|
|
||||||
|
func makebullet(targetPosition,speed) -> void:
|
||||||
print("make a bullet")
|
print("make a bullet")
|
||||||
|
print("bullets created: "+str(bulletArray.size()))
|
||||||
|
var myBullet:Bullet = bulletFactory()
|
||||||
|
myBullet.transform=targetPosition
|
||||||
|
myBullet.setSpeed(speed)
|
||||||
|
myBullet.set_process(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user