Implement some sprites and start on game logic scripts.

This commit is contained in:
Fries 2024-05-04 17:22:01 -07:00
parent 86a9ee6d8c
commit 6fcf653c97
11 changed files with 169 additions and 21 deletions

View file

@ -1,16 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://cij4p7ni0rujg"]
[ext_resource type="Script" path="res://Scripts/Bird/movement.gd" id="1_4imb2"]
[ext_resource type="Texture2D" uid="uid://cfotdween4etw" path="res://icon.svg" id="1_rcshh"]
[ext_resource type="Texture2D" uid="uid://bi1187py7cioc" path="res://Sprites/yellowbird-midflap.png" id="2_iq7mf"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5ukl2"]
size = Vector2(102, 128)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_g0iqt"]
radius = 12.0
height = 24.0
[node name="Bird" type="CharacterBody2D"]
script = ExtResource("1_4imb2")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_rcshh")
texture_filter = 1
texture = ExtResource("2_iq7mf")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_5ukl2")
shape = SubResource("CapsuleShape2D_g0iqt")

View file

@ -1,13 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://c0tpkr1ghv33o"]
[gd_scene load_steps=4 format=3 uid="uid://c0tpkr1ghv33o"]
[ext_resource type="PackedScene" uid="uid://cij4p7ni0rujg" path="res://Scenes/bird.tscn" id="1_f1cub"]
[ext_resource type="Script" path="res://Scripts/game_manager.gd" id="1_vfafo"]
[ext_resource type="PackedScene" uid="uid://k6su505fjc6g" path="res://Scenes/pipes.tscn" id="2_ypsty"]
[node name="FlappyBird" type="Node2D"]
[node name="GameManager" type="Node" parent="."]
script = ExtResource("1_vfafo")
Pipes = ExtResource("2_ypsty")
[node name="Bird" parent="." instance=ExtResource("1_f1cub")]
unique_name_in_owner = true
scale = Vector2(2, 2)
[node name="Camera2D" type="Camera2D" parent="."]
[node name="Pipes" parent="." instance=ExtResource("2_ypsty")]
position = Vector2(376, 0)

17
Scenes/pipe.tscn Normal file
View file

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://b6apltgrsllm7"]
[ext_resource type="Texture2D" uid="uid://btfaucx6uga8a" path="res://Sprites/pipe-green.png" id="1_7wb7t"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rkgml"]
size = Vector2(47, 318)
[node name="Pipe" type="Area2D"]
position = Vector2(0, -555)
[node name="Icon" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_7wb7t")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-0.5, 1)
shape = SubResource("RectangleShape2D_rkgml")

View file

@ -1,19 +1,26 @@
[gd_scene load_steps=2 format=3 uid="uid://k6su505fjc6g"]
[gd_scene load_steps=4 format=3 uid="uid://k6su505fjc6g"]
[ext_resource type="Texture2D" uid="uid://cfotdween4etw" path="res://icon.svg" id="1_xgxmx"]
[ext_resource type="Script" path="res://Scripts/Pipes/movement.gd" id="1_1x6r3"]
[ext_resource type="PackedScene" uid="uid://b6apltgrsllm7" path="res://Scenes/pipe.tscn" id="2_5fcp1"]
[ext_resource type="Script" path="res://Scripts/Pipes/pipe_offset_generator.gd" id="3_yr1uv"]
[node name="Pipes" type="Node2D"]
script = ExtResource("1_1x6r3")
move_speed = 250
[node name="Pipe" type="AnimatableBody2D" parent="."]
position = Vector2(0, -515)
scale = Vector2(0.5, 5.65)
[node name="Pipe" parent="." instance=ExtResource("2_5fcp1")]
position = Vector2(-1, -406)
rotation = -3.14159
scale = Vector2(2, 2)
[node name="Icon" type="Sprite2D" parent="Pipe"]
texture = ExtResource("1_xgxmx")
[node name="Pipe2" parent="." instance=ExtResource("2_5fcp1")]
position = Vector2(0, 391)
scale = Vector2(2, 2)
[node name="Pipe2" type="AnimatableBody2D" parent="."]
position = Vector2(0, 384)
scale = Vector2(0.5, 5.65)
[node name="PipeOffsetsGenerator" type="Node" parent="." node_paths=PackedStringArray("Pipe1", "Pipe2")]
script = ExtResource("3_yr1uv")
Pipe1 = NodePath("../Pipe")
Pipe2 = NodePath("../Pipe2")
[node name="Icon" type="Sprite2D" parent="Pipe2"]
texture = ExtResource("1_xgxmx")
[connection signal="body_entered" from="Pipe" to="." method="_on_pipe_body_entered"]
[connection signal="body_entered" from="Pipe2" to="." method="_on_pipe_body_entered"]

18
Scripts/Pipes/movement.gd Normal file
View file

@ -0,0 +1,18 @@
extends Node2D
@export var move_speed: int
signal pipe_collision
# 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):
global_translate(Vector2.LEFT * move_speed * delta)
pass
func _on_pipe_body_entered(_body):
pipe_collision.emit()

View file

@ -0,0 +1,8 @@
extends Node
@export var Pipe1 : Node2D
@export var Pipe2 : Node2D
func _ready():
print("pipe")

24
Scripts/game_manager.gd Normal file
View file

@ -0,0 +1,24 @@
extends Node
var score : int
@onready var Bird = %Bird
@export var Pipes : PackedScene
const START_POSITION : int = 500
# Called when the node enters the scene tree for the first time.
func _ready():
var instance : Node2D = Pipes.instantiate()
instance.connect("pipe_collision", _on_pipes_pipe_collision)
instance.position.x = START_POSITION
add_child(instance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func increment_score():
score += 1
func _on_pipes_pipe_collision():
print("hello")

BIN
Sprites/pipe-green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://btfaucx6uga8a"
path="res://.godot/imported/pipe-green.png-578c1a55d04b8dec4b7bf3a5f9e18dbf.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/pipe-green.png"
dest_files=["res://.godot/imported/pipe-green.png-578c1a55d04b8dec4b7bf3a5f9e18dbf.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: 425 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bi1187py7cioc"
path="res://.godot/imported/yellowbird-midflap.png-0e81172432ac4ec18941c9075e4e9fcc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/yellowbird-midflap.png"
dest_files=["res://.godot/imported/yellowbird-midflap.png-0e81172432ac4ec18941c9075e4e9fcc.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