Added level 1, base-level to abstract from, and level-controller

This commit is contained in:
Nathan Anderson 2022-08-05 17:15:17 -06:00
parent c95b9f9928
commit 77386f7af6
42 changed files with 985 additions and 531 deletions

Binary file not shown.

BIN
assets/music_icon.xcf Normal file

Binary file not shown.

BIN
assets/play.xcf Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/shaders/Blinds.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Blinds.png-2bd8a9f6eba63f8eb0695083fdf9397c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/shaders/Blinds.png"
dest_files=[ "res://.import/Blinds.png-2bd8a9f6eba63f8eb0695083fdf9397c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
assets/ui/music-hover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/music-hover.png-41e3fb39d172b3252aeeef3a9bab17af.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/music-hover.png"
dest_files=[ "res://.import/music-hover.png-41e3fb39d172b3252aeeef3a9bab17af.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui/pause-hover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/pause-hover.png-e4ea4eb67c068bc5d056965d6f087be0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/pause-hover.png"
dest_files=[ "res://.import/pause-hover.png-e4ea4eb67c068bc5d056965d6f087be0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui/pause.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/pause.png-1ae561f3bc81500c9be2d9dbcefe44ff.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/pause.png"
dest_files=[ "res://.import/pause.png-1ae561f3bc81500c9be2d9dbcefe44ff.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

35
assets/ui/play.png.import Normal file
View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/play.png-d5c85744be54e3dde1ca5bb32a24f02f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/play.png"
dest_files=[ "res://.import/play.png-d5c85744be54e3dde1ca5bb32a24f02f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui/pointer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/pointer.png-133392f260ecc87b51a28d66b4343076.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/pointer.png"
dest_files=[ "res://.import/pointer.png-133392f260ecc87b51a28d66b4343076.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui/pointer_hand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/pointer_hand.png-1004d662901565d110a8c0d58ec1da71.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/pointer_hand.png"
dest_files=[ "res://.import/pointer_hand.png-1004d662901565d110a8c0d58ec1da71.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
assets/ui_elements.xcf Normal file

Binary file not shown.

View File

@ -9,6 +9,16 @@
config_version=4 config_version=4
_global_script_classes=[ { _global_script_classes=[ {
"base": "Node2D",
"class": "BaseLevel",
"language": "GDScript",
"path": "res://scripts/base_level.gd"
}, {
"base": "Node2D",
"class": "GUI",
"language": "GDScript",
"path": "res://scripts/UI.gd"
}, {
"base": "KinematicBody2D", "base": "KinematicBody2D",
"class": "Neighbor", "class": "Neighbor",
"language": "GDScript", "language": "GDScript",
@ -25,6 +35,8 @@ _global_script_classes=[ {
"path": "res://scripts/trolley.gd" "path": "res://scripts/trolley.gd"
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"BaseLevel": "",
"GUI": "",
"Neighbor": "", "Neighbor": "",
"Player": "", "Player": "",
"Trolley": "" "Trolley": ""
@ -33,7 +45,7 @@ _global_script_class_icons={
[application] [application]
config/name="roger" config/name="roger"
run/main_scene="res://scenes/stage.tscn" run/main_scene="res://scenes/level_controller.tscn"
[display] [display]

View File

@ -243,4 +243,6 @@ scale = Vector2( 5, 5 )
tile_set = SubResource( 2 ) tile_set = SubResource( 2 )
cell_size = Vector2( 16, 16 ) cell_size = Vector2( 16, 16 )
show_collision = true show_collision = true
collision_layer = 4
collision_mask = 0
format = 1 format = 1

View File

@ -1,47 +0,0 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/fonts/8-BIT WONDER.TTF" type="DynamicFontData" id=1]
[ext_resource path="res://scripts/UI.gd" type="Script" id=2]
[ext_resource path="res://assets/ui/music-enabled.png" type="Texture" id=3]
[sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 1 )
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
[node name="GUI" type="Node2D"]
script = ExtResource( 2 )
[node name="MarginContainer" type="MarginContainer" parent="."]
margin_left = 20.0
margin_top = 20.0
margin_right = 1279.0
margin_bottom = 257.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
margin_right = 1259.0
margin_bottom = 237.0
[node name="TimeLabel" type="RichTextLabel" parent="MarginContainer/HBoxContainer"]
margin_right = 1227.0
margin_bottom = 237.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 2 )
text = "Time fdsafdsafdsa"
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
margin_left = 1231.0
margin_right = 1259.0
margin_bottom = 237.0
[node name="ToolButton" type="ToolButton" parent="MarginContainer/HBoxContainer/VBoxContainer"]
margin_right = 28.0
margin_bottom = 24.0
toggle_mode = true
icon = ExtResource( 3 )
[node name="GameTimer" type="Timer" parent="."]
[connection signal="toggled" from="MarginContainer/HBoxContainer/VBoxContainer/ToolButton" to="." method="_on_ToolButton_toggled"]

139
scenes/base_level.tscn Normal file
View File

@ -0,0 +1,139 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://Y2Mate.is - Won't You Be My Neighbor [8 Bit Tribute to Mr. Rogers] - 8 Bit Universe-8f3BEcQp1Q4-48k-1659646018463.mp3" type="AudioStream" id=1]
[ext_resource path="res://scenes/clouds.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/TileMap.tscn" type="PackedScene" id=3]
[ext_resource path="res://scripts/base_level.gd" type="Script" id=4]
[ext_resource path="res://scenes/trolley.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/neighbor.tscn" type="PackedScene" id=7]
[ext_resource path="res://scenes/house.tscn" type="PackedScene" id=8]
[ext_resource path="res://assets/fonts/8-BIT WONDER.TTF" type="DynamicFontData" id=9]
[sub_resource type="DynamicFont" id=1]
size = 40
font_data = ExtResource( 9 )
[sub_resource type="DynamicFont" id=3]
size = 40
[sub_resource type="Theme" id=2]
default_font = SubResource( 3 )
RichTextLabel/fonts/normal_font = SubResource( 1 )
[node name="BaseLevel" type="Node2D"]
script = ExtResource( 4 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 1 )
pitch_scale = 0.75
[node name="TileMap" parent="." instance=ExtResource( 3 )]
collision_mask = 7
[node name="YSort" type="YSort" parent="."]
[node name="Player" parent="YSort" instance=ExtResource( 6 )]
position = Vector2( 619.221, 307.07 )
[node name="Trolley" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 629.977, 650.649 )
[node name="House1" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 1066, 540 )
[node name="Neighbor1" parent="YSort" instance=ExtResource( 7 )]
position = Vector2( 131, 429 )
[node name="Clouds" parent="." instance=ExtResource( 2 )]
position = Vector2( -0.17392, 0.152588 )
[node name="CameraBounds" type="Node2D" parent="."]
[node name="Left" type="Node2D" parent="CameraBounds"]
position = Vector2( -521, 432 )
[node name="Top" type="Node2D" parent="CameraBounds"]
position = Vector2( 594, -189 )
[node name="Right" type="Node2D" parent="CameraBounds"]
position = Vector2( 1757, 455 )
[node name="Bottom" type="Node2D" parent="CameraBounds"]
position = Vector2( 655, 1037 )
[node name="TrolleyLocations" type="Node2D" parent="."]
[node name="TrolleyStart" type="Node2D" parent="TrolleyLocations"]
position = Vector2( 72, 91 )
[node name="TrolleyEnd" type="Node2D" parent="TrolleyLocations"]
position = Vector2( 1258, 154 )
[node name="Panel" type="Panel" parent="."]
visible = false
margin_left = -2.0
margin_top = -6.0
margin_right = 1361.0
margin_bottom = 1054.0
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Control" type="Control" parent="Panel/VBoxContainer"]
margin_right = 1363.0
margin_bottom = 279.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="EndGameTitle" type="RichTextLabel" parent="Panel/VBoxContainer"]
margin_left = 181.0
margin_top = 283.0
margin_right = 1181.0
margin_bottom = 324.0
rect_min_size = Vector2( 1000, 0 )
size_flags_horizontal = 4
size_flags_vertical = 4
theme = SubResource( 2 )
text = "This is the text"
fit_content_height = true
[node name="Control3" type="Control" parent="Panel/VBoxContainer"]
margin_top = 328.0
margin_right = 1363.0
margin_bottom = 390.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 0.22
[node name="EndGameBody" type="RichTextLabel" parent="Panel/VBoxContainer"]
margin_left = 181.0
margin_top = 394.0
margin_right = 1181.0
margin_bottom = 435.0
rect_min_size = Vector2( 1000, 0 )
size_flags_horizontal = 4
size_flags_vertical = 4
theme = SubResource( 2 )
text = "This is the text"
fit_content_height = true
[node name="Control2" type="Control" parent="Panel/VBoxContainer"]
margin_top = 439.0
margin_right = 1363.0
margin_bottom = 1060.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 2.22
[node name="DisplayTimer" type="Timer" parent="."]
one_shot = true
autostart = true
[connection signal="left_wih_rogers" from="YSort/Trolley" to="." method="_on_Trolley_left_wih_rogers"]
[connection signal="rogers_entered_trolley" from="YSort/Trolley" to="." method="_on_Trolley_rogers_entered_trolley"]
[connection signal="rogers_left_trolley" from="YSort/Trolley" to="." method="_on_Trolley_rogers_left_trolley"]
[connection signal="timeout" from="DisplayTimer" to="." method="_on_DisplayTimer_timeout"]

20
scenes/clouds.tscn Normal file
View File

@ -0,0 +1,20 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scripts/Clouds.gd" type="Script" id=3]
[node name="Clouds" type="Node2D"]
position = Vector2( -2.43112, -0.845276 )
scale = Vector2( 10, 10 )
script = ExtResource( 3 )
[node name="RightBorder" type="Node2D" parent="."]
position = Vector2( 127.8, 47.0604 )
[node name="LeftBorder" type="Node2D" parent="."]
position = Vector2( 0.0503082, 46.0223 )
[node name="TopBorder" type="Node2D" parent="."]
position = Vector2( 62.236, 0.33577 )
[node name="BottomBorder" type="Node2D" parent="."]
position = Vector2( 61.0313, 94.858 )

36
scenes/game-screen.tscn Normal file
View File

@ -0,0 +1,36 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/fonts/8-BIT WONDER.TTF" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1]
size = 30
font_data = ExtResource( 1 )
[sub_resource type="Theme" id=2]
RichTextLabel/fonts/normal_font = SubResource( 1 )
[node name="Panel" type="Panel"]
margin_left = -31.0
margin_top = -245.0
margin_right = 1332.0
margin_bottom = 815.0
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 1299.0
margin_bottom = 992.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 1299.0
margin_bottom = 992.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/HBoxContainer"]
margin_right = 1299.0
margin_bottom = 992.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 2 )
text = "This is the text"

99
scenes/gui.tscn Normal file
View File

@ -0,0 +1,99 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://assets/ui/play.png" type="Texture" id=1]
[ext_resource path="res://scripts/UI.gd" type="Script" id=2]
[ext_resource path="res://assets/ui/music-enabled.png" type="Texture" id=3]
[ext_resource path="res://assets/fonts/ice_pixel-7.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://assets/ui/pause.png" type="Texture" id=5]
[ext_resource path="res://assets/ui/pause-hover.png" type="Texture" id=6]
[ext_resource path="res://assets/ui/music-disabled.png" type="Texture" id=7]
[ext_resource path="res://assets/ui/music-hover.png" type="Texture" id=8]
[sub_resource type="DynamicFont" id=8]
size = 60
outline_size = 1
outline_color = Color( 0.203125, 0.203125, 0.203125, 1 )
use_mipmaps = true
font_data = ExtResource( 4 )
[sub_resource type="DynamicFont" id=1]
size = 45
font_data = ExtResource( 4 )
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
RichTextLabel/fonts/normal_font = SubResource( 8 )
[node name="GUI" type="Node2D"]
script = ExtResource( 2 )
[node name="MarginContainer" type="MarginContainer" parent="."]
margin_left = 25.0
margin_top = 25.0
margin_right = 1255.0
margin_bottom = 100.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
margin_right = 1230.0
margin_bottom = 75.0
[node name="TimeLabel" type="RichTextLabel" parent="MarginContainer/HBoxContainer"]
margin_right = 305.0
margin_bottom = 75.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 2 )
text = "Time:"
[node name="NeighborLabel" type="RichTextLabel" parent="MarginContainer/HBoxContainer"]
margin_left = 309.0
margin_right = 920.0
margin_bottom = 75.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 2.0
theme = SubResource( 2 )
text = "Neighbors Left: 6"
[node name="GridContainer" type="GridContainer" parent="MarginContainer/HBoxContainer"]
margin_left = 924.0
margin_right = 1230.0
margin_bottom = 75.0
size_flags_horizontal = 3
columns = 3
[node name="PauseButton" type="TextureButton" parent="MarginContainer/HBoxContainer/GridContainer"]
margin_right = 100.0
margin_bottom = 75.0
focus_mode = 1
size_flags_horizontal = 3
size_flags_vertical = 3
toggle_mode = true
texture_normal = ExtResource( 5 )
texture_pressed = ExtResource( 1 )
texture_hover = ExtResource( 6 )
expand = true
stretch_mode = 4
[node name="MusicButton" type="TextureButton" parent="MarginContainer/HBoxContainer/GridContainer"]
margin_left = 104.0
margin_right = 204.0
margin_bottom = 75.0
size_flags_horizontal = 3
toggle_mode = true
texture_normal = ExtResource( 3 )
texture_pressed = ExtResource( 7 )
texture_hover = ExtResource( 8 )
expand = true
stretch_mode = 4
[node name="GameTimer" type="Timer" parent="."]
one_shot = true
[connection signal="mouse_entered" from="MarginContainer/HBoxContainer/GridContainer/PauseButton" to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="MarginContainer/HBoxContainer/GridContainer/PauseButton" to="." method="_on_mouse_exited"]
[connection signal="toggled" from="MarginContainer/HBoxContainer/GridContainer/PauseButton" to="." method="_on_PauseButton_toggled"]
[connection signal="mouse_entered" from="MarginContainer/HBoxContainer/GridContainer/MusicButton" to="." method="_on_mouse_entered"]
[connection signal="mouse_exited" from="MarginContainer/HBoxContainer/GridContainer/MusicButton" to="." method="_on_mouse_exited"]
[connection signal="toggled" from="MarginContainer/HBoxContainer/GridContainer/MusicButton" to="." method="_on_MusicButton_toggled"]
[connection signal="timeout" from="GameTimer" to="." method="_on_GameTimer_timeout"]

101
scenes/level1.tscn Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7
scenes/level3.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scenes/base_level.tscn" type="PackedScene" id=1]
[node name="Level1" type="Node2D"]
[node name="BaseLevel" parent="." instance=ExtResource( 1 )]

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scripts/level_controller.gd" type="Script" id=1]
[node name="Master" type="Node2D"]
script = ExtResource( 1 )
[node name="EndTimer" type="Timer" parent="."]
one_shot = true
[connection signal="timeout" from="EndTimer" to="." method="_on_EndTimer_timeout"]

View File

@ -11,11 +11,7 @@
[ext_resource path="res://scripts/player.gd" type="Script" id=9] [ext_resource path="res://scripts/player.gd" type="Script" id=9]
[ext_resource path="res://assets/mrRogers.png" type="Texture" id=10] [ext_resource path="res://assets/mrRogers.png" type="Texture" id=10]
[ext_resource path="res://assets/chevron_pointer.png" type="Texture" id=11] [ext_resource path="res://assets/chevron_pointer.png" type="Texture" id=11]
[ext_resource path="res://scenes/UI.tscn" type="PackedScene" id=12] [ext_resource path="res://scenes/gui.tscn" type="PackedScene" id=12]
[sub_resource type="CapsuleShape2D" id=2]
radius = 13.0
height = 10.0001
[sub_resource type="SpriteFrames" id=1] [sub_resource type="SpriteFrames" id=1]
animations = [ { animations = [ {
@ -30,17 +26,16 @@ animations = [ {
"speed": 8.0 "speed": 8.0
} ] } ]
[sub_resource type="CapsuleShape2D" id=2]
radius = 13.0
height = 10.0001
[node name="Player" type="KinematicBody2D"] [node name="Player" type="KinematicBody2D"]
collision_mask = 7 collision_mask = 7
script = ExtResource( 9 ) script = ExtResource( 9 )
ACCELERATION = 2000 ACCELERATION = 2000
FRICTION = 2500 FRICTION = 2500
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, 4 )
rotation = 1.5708
shape = SubResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] [node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 2, -25 ) position = Vector2( 2, -25 )
scale = Vector2( 5, 5 ) scale = Vector2( 5, 5 )
@ -48,6 +43,11 @@ frames = SubResource( 1 )
animation = "idle" animation = "idle"
playing = true playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, 4 )
rotation = 1.5708
shape = SubResource( 2 )
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
current = true current = true

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,11 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/trolley-lg.png" type="Texture" id=1] [ext_resource path="res://assets/trolley-lg.png" type="Texture" id=1]
[ext_resource path="res://scripts/trolley.gd" type="Script" id=2] [ext_resource path="res://scripts/trolley.gd" type="Script" id=2]
[sub_resource type="CircleShape2D" id=4]
radius = 172.29
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 38, 10 ) extents = Vector2( 38, 10 )
@ -13,6 +16,12 @@ extents = Vector2( 44.5, 8.25 )
collision_layer = 4 collision_layer = 4
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="TrolleySurroundingArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="TrolleySurroundingArea"]
position = Vector2( 0, -45 )
shape = SubResource( 4 )
[node name="TrolleySeatArea" type="Area2D" parent="."] [node name="TrolleySeatArea" type="Area2D" parent="."]
collision_layer = 0 collision_layer = 0
@ -34,5 +43,5 @@ polygon = PoolVector2Array( 172, -5, 198, 106, 150, 106, 122, 127, 74, 109, 46,
position = Vector2( 0, -2.25 ) position = Vector2( 0, -2.25 )
shape = SubResource( 3 ) shape = SubResource( 3 )
[connection signal="body_shape_exited" from="TrolleySurroundingArea" to="." method="_on_TrolleySurroundingArea_body_exited"]
[connection signal="body_entered" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_entered"] [connection signal="body_entered" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_entered"]
[connection signal="body_exited" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_exited"]

View File

@ -1,42 +1,39 @@
extends Node2D extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
onready var cloud1 = $Sprite
onready var cloud2 = $Sprite2
onready var cloud3 = $Sprite3
onready var cloud4 = $Sprite4
onready var topBorder = $TopBorder onready var topBorder = $TopBorder
onready var bottomBorder = $BottomBorder onready var bottomBorder = $BottomBorder
onready var leftBorder = $LeftBorder onready var leftBorder = $LeftBorder
onready var rightBorder = $RightBorder onready var rightBorder = $RightBorder
export var NUM_CLOUDS = 12
var clouds = [] var clouds = []
var speeds = []
var rng = RandomNumberGenerator.new() var rng = RandomNumberGenerator.new()
var xSpeed = 0
# 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(): func _ready():
for num in range(NUM_CLOUDS):
var cloud_image_path = "res://assets/cloud%s.png" % (num % 4 + 1)
var new_cloud_sprite = Sprite.new()
new_cloud_sprite.texture = load(cloud_image_path)
add_child(new_cloud_sprite)
clouds.append(new_cloud_sprite)
var rand_speed = rng.randf_range(0.5,2)
speeds.append(rand_speed)
rng.randomize() rng.randomize()
xSpeed = rng.randf_range(0.5,2)
clouds = [cloud1, cloud2, cloud3, cloud4]
_start_position() _start_position()
# 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): func _process(delta):
print(xSpeed) var index := 0
for cloud in clouds: for cloud in clouds:
if cloud.global_position.x + xSpeed < rightBorder.global_position.x: if cloud.global_position.x + speeds[index] < rightBorder.global_position.x:
cloud.global_position.x = cloud.global_position.x + xSpeed cloud.global_position.x = cloud.global_position.x + speeds[index]
else: else:
cloud.global_position.x = leftBorder.global_position.x cloud.global_position.x = leftBorder.global_position.x
cloud.global_position.y = rng.randi_range(topBorder.global_position.y, bottomBorder.global_position.y)
index += 1
func _start_position(): func _start_position():
rng.randomize() rng.randomize()

View File

@ -1,16 +0,0 @@
extends Sprite
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# 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):
# pass

View File

@ -1,18 +1,52 @@
extends Node2D extends Node2D
class_name GUI
signal toggle_music(music_off)
onready var time_label := $MarginContainer/HBoxContainer/TimeLabel onready var time_label := $MarginContainer/HBoxContainer/TimeLabel
onready var neighbor_label := $MarginContainer/HBoxContainer/NeighborLabel
onready var game_timer := $GameTimer onready var game_timer := $GameTimer
onready var music_button := $MarginContainer/HBoxContainer/VBoxContainer/MusicButton
onready var pause_button := $MarginContainer/HBoxContainer/GridContainer/PauseButton
var arrow = preload("res://assets/ui/pointer.png")
var hand = preload("res://assets/ui/pointer_hand.png")
#var music_enabled_texture = preload("res://assets/ui/music-enabled.png")
#var music_disabled_texture = preload("res://assets/ui/music-disabled.png")
#var pause_texture = preload("res://assets/ui/pause.png")
#var play_texture = preload("res://assets/ui/play.png")
func start_timer(seconds: int) -> void: func start_timer(seconds: int) -> void:
game_timer.start(seconds) game_timer.start(seconds)
func set_neighbor_count(neighbors_left: int) -> void:
neighbor_label.text = "Neighbors left: %s" % neighbors_left
func set_game_label(content: String) -> void:
neighbor_label.text = content
func _ready() -> void: func _ready() -> void:
start_timer(60) Input.set_custom_mouse_cursor(arrow)
# Input.set_custom_mouse_cursor(beam, Input.CURSOR_IBEAM)
# start_timer(60)
func _process(delta: float) -> void: func _process(delta: float) -> void:
var time = int(game_timer.get_time_left()) var time = int(game_timer.get_time_left())
time_label.text = "Time %s" % time time_label.text = "Time: %s" % time
func _on_PauseButton_toggled(button_pressed: bool) -> void:
print('TODO nothing happens...')
func _on_MusicButton_toggled(button_pressed: bool) -> void:
emit_signal("toggle_music", !button_pressed)
func _on_mouse_entered() -> void:
Input.set_custom_mouse_cursor(hand)
func _on_mouse_exited() -> void:
Input.set_custom_mouse_cursor(arrow)
func _on_ToolButton_toggled(button_pressed: bool) -> void: func _on_GameTimer_timeout() -> void:
print(button_pressed) pass # Replace with function body.

97
scripts/base_level.gd Normal file
View File

@ -0,0 +1,97 @@
extends Node2D
class_name BaseLevel
var helped_neighbors := []
var total_neighbors := 0
var playback_position: float
var level_num := 1
var last_level := false
export var SECONDS_TO_COMPLETE := 10
signal game_complete(is_win)
onready var trolley = $YSort/Trolley as Trolley
onready var player = $YSort/Player as Player
onready var bounds = $CameraBounds
onready var audio_player = $AudioStreamPlayer
onready var gui = $YSort/Player/GUI as GUI
onready var trolley_locations = $TrolleyLocations
onready var end_game_panel = $Panel
onready var end_game_label_title = $Panel/VBoxContainer/EndGameTitle
onready var end_game_label_body = $Panel/VBoxContainer/EndGameBody
onready var display_timer = $DisplayTimer
func display_start(this_level_num: int, is_last_level: bool = false) -> void:
last_level = is_last_level
level_num = this_level_num
end_game_label_title.text = 'Land of make believe'
end_game_label_body.text = '1 %s' % level_num
end_game_panel.visible = true
func _process(delta: float) -> void:
if end_game_panel.visible:
end_game_panel.rect_global_position = player.camera.get_camera_screen_center() - Vector2(get_viewport().get_visible_rect().size.x / 2, get_viewport().get_visible_rect().size.y / 2)
func _on_neighbor_found_home(id: int) -> void:
helped_neighbors.append(id)
gui.set_neighbor_count(total_neighbors - len(helped_neighbors))
if len(helped_neighbors) == total_neighbors:
trolley.set_trolley_open(true)
gui.set_game_label("Get to the Trolley!")
player.follower = trolley
func _on_toggle_music(music_off: bool) -> void:
if music_off:
playback_position = audio_player.get_playback_position()
audio_player.stop()
else:
audio_player.play(playback_position)
func _on_Trolley_rogers_entered_trolley() -> void:
player.follower = null
trolley.move_to_leave()
func _on_Trolley_rogers_left_trolley() -> void:
gui.start_timer(SECONDS_TO_COMPLETE)
trolley.move_to_end(trolley_locations.get_node("TrolleyEnd").global_position, SECONDS_TO_COMPLETE)
func _on_GameTimer_timeout() -> void:
trolley.move_to_leave()
func _on_Trolley_left_wih_rogers(has_rogers) -> void:
if has_rogers:
if last_level:
end_game_label_title.text = 'You are very neighborly'
end_game_label_body.text = 'You saved all the neighbors in the land of make believe'
emit_signal("game_complete", true)
else:
end_game_label_title.text = 'You win'
end_game_label_body.text = 'Proceeding to level %s' % (level_num + 1)
emit_signal("game_complete", true)
else:
end_game_label_title.text = 'Oh no'
end_game_label_body.text = 'You were left in the land of make-believe'
emit_signal("game_complete", false)
end_game_panel.visible = true
# Sets up the level start
func _on_DisplayTimer_timeout() -> void:
end_game_panel.visible = false
if trolley != null:
trolley.global_position = Vector2(bounds.get_node("Left").global_position.x - 20, trolley_locations.get_node("TrolleyStart").global_position.y)
if player != null:
player.global_position = trolley.get_node("TrolleySeatArea/SeatAreaShape").global_position
for node in get_node("YSort").get_children():
if 'Neighbor' in node.name:
var err = node.connect("found_home", self, "_on_neighbor_found_home")
total_neighbors += 1
print('Level loaded with %s neighbors' % total_neighbors)
gui.set_neighbor_count(total_neighbors)
player.set_camera_bounds(bounds.get_node("Top").global_position.y, bounds.get_node("Bottom").global_position.y, bounds.get_node("Left").global_position.x, bounds.get_node("Right").global_position.x)
var err = gui.connect("toggle_music", self, "_on_toggle_music")
err = gui.get_node("GameTimer").connect("timeout", self, "_on_GameTimer_timeout")
trolley.move_to_start(get_node("TrolleyLocations/TrolleyStart").global_position)

View File

@ -0,0 +1,36 @@
extends Node2D
var level_path := "res://scenes/level{num}.tscn"
var level1 = preload("res://scenes/level1.tscn")
var current_level_num = 1
var current_level : Node
var max_levels = 3
var level_win := false
onready var end_timer := $EndTimer
func _ready() -> void:
current_level = level1.instance()
add_child(current_level)
var err = current_level.get_child(0).connect("game_complete", self, "_on_level_complete")
func _on_level_complete(is_win: bool) -> void:
print('Level complete')
level_win = is_win
end_timer.start(2)
func _on_EndTimer_timeout() -> void:
if level_win and current_level_num < max_levels:
current_level_num += 1
var new_level_path = level_path.format({"num": current_level_num})
var next_level = load(new_level_path).instance()
add_child(next_level)
current_level.queue_free()
current_level = next_level
var current_base_level = current_level.get_node("BaseLevel") as BaseLevel
current_base_level.display_start(current_level_num)
var err = current_base_level.connect("game_complete", self, "_on_level_complete")

View File

@ -95,7 +95,6 @@ func _idle_state(delta: float) -> void:
func _go_home_state(delta: float) -> void: func _go_home_state(delta: float) -> void:
_move_neighbor(house_direction, true) _move_neighbor(house_direction, true)
# print((house_position - global_position).length())
if ((house_position - global_position).length() < 30): if ((house_position - global_position).length() < 30):
emit_signal("found_home", id) emit_signal("found_home", id)
queue_free() queue_free()

View File

@ -13,12 +13,22 @@ var leader := self
onready var sprite := $AnimatedSprite onready var sprite := $AnimatedSprite
onready var chevron_sprite := $ChevronSprite onready var chevron_sprite := $ChevronSprite
onready var camera := $Camera2D
onready var gui := $GUI
enum State { enum State {
MOVE, MOVE,
IDLE IDLE
} }
func set_camera_bounds(up: int, down: int, left: int, right: int):
camera.set_limit(MARGIN_TOP, up)
camera.set_limit(MARGIN_BOTTOM, down)
camera.set_limit(MARGIN_LEFT, left)
camera.set_limit(MARGIN_RIGHT, right)
func _process(delta: float) -> void:
gui.global_position = camera.get_camera_screen_center() - Vector2(get_viewport().get_visible_rect().size.x / 2, get_viewport().get_visible_rect().size.y / 2) # Get Height)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
match state: match state:
@ -28,6 +38,8 @@ func _physics_process(delta: float) -> void:
_idle_state(delta) _idle_state(delta)
chevron_sprite.visible = follower != null chevron_sprite.visible = follower != null
if follower != null: if follower != null:
if follower.name == "Trolley":
chevron_sprite.set_modulate(Color(0,0.9,0))
chevron_sprite.rotation_degrees = rad2deg((follower.house_position - global_position).angle()) - 90 chevron_sprite.rotation_degrees = rad2deg((follower.house_position - global_position).angle()) - 90
func _move_state(delta: float) -> void: func _move_state(delta: float) -> void:
@ -58,11 +70,3 @@ func _idle_state(delta: float) -> void:
state = State.MOVE state = State.MOVE
else: else:
sprite.set_animation("idle") sprite.set_animation("idle")
# if Input.is_action_pressed("ui_up"):
# speed.y -= ACCELERATION
# elif Input.is_action_pressed("ui_right"):
# print("right")
# elif Input.is_action_pressed("ui_left"):
# print("left")
# elif Input.is_action_pressed("ui_down"):
# print("down")

View File

@ -17,7 +17,6 @@ func _on_rogers_left_trolley() -> void:
pass pass
func _on_neighbor_found_home(id: int) -> void: func _on_neighbor_found_home(id: int) -> void:
print('You helped a neighbor')
helped_neighbors.append(id) helped_neighbors.append(id)
if len(helped_neighbors) == total_neighbors: if len(helped_neighbors) == total_neighbors:
trolley.set_trolley_open(true) trolley.set_trolley_open(true)

View File

@ -3,38 +3,114 @@ extends KinematicBody2D
class_name Trolley class_name Trolley
signal rogers_left_trolley() signal rogers_left_trolley()
signal rogers_entered_trolley()
signal left_wih_rogers(has_rogers)
export var TIME = 60
onready var trolley_closed_shape = $TrolleyClosedShape onready var trolley_closed_shape = $TrolleyClosedShape
export var MAX_VELOCITY = .3 export var MAX_VELOCITY = 8
var velocity := Vector2.ZERO var velocity := Vector2.ZERO
var state = State.STOPPED
var has_roger := false var has_roger := false
var destination := Vector2.ZERO
var house_position : Vector2
var arrival_time: int
var en_route_length: float
func _ready() -> void: enum State {
set_trolley_open(true) MOVE_TO_START,
STOPPED,
EN_ROUTE,
LEAVING
}
func set_trolley_open(trolley_open: bool) -> void:
trolley_closed_shape.set_deferred("disabled", trolley_open)
func move_to_start(start_pos: Vector2) -> void:
state = State.MOVE_TO_START
destination = start_pos
velocity = Vector2(MAX_VELOCITY, 0)
set_trolley_open(false)
func move_to_end(end_pos: Vector2, seconds_to_exit) -> void:
state = State.EN_ROUTE
destination = end_pos
velocity = Vector2.ZERO
arrival_time = seconds_to_exit
set_trolley_open(false)
en_route_length = destination.x - global_position.x
func move_to_leave() -> void:
if state != State.LEAVING:
set_trolley_open(false)
emit_signal("left_wih_rogers", has_roger)
state = State.LEAVING
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
velocity.x = move_toward(velocity.x, MAX_VELOCITY, delta if not has_roger else delta * 10) match state:
State.MOVE_TO_START:
_decelerate_to_start(delta)
State.STOPPED:
_stop(delta)
State.EN_ROUTE:
_en_route(delta)
State.LEAVING:
_leaving(delta)
# For the player indicator to show where the trolley is, update 'house_position' to current position
house_position = global_position
func _decelerate_to_start(delta: float) -> void:
var length_to_start := destination.x - global_position.x - 100
velocity.x = min(move_toward(velocity.x, length_to_start, delta * 10), MAX_VELOCITY)
var collision := move_and_collide(velocity)
if collision:
var collider = collision.get_collider()
if collider.get_class() == "KinematicBody2D":
collider.move_and_collide(velocity * 2)
if global_position.x >= destination.x:
set_trolley_open(true)
state = State.STOPPED
func _stop(delta: float) -> void:
pass
func _en_route(delta: float) -> void:
velocity.x = en_route_length / arrival_time * delta
var collision := move_and_collide(velocity) var collision := move_and_collide(velocity)
if collision: if collision:
var collider = collision.get_collider() var collider = collision.get_collider()
if collider.get_class() == "KinematicBody2D": if collider.get_class() == "KinematicBody2D":
if has_roger: if has_roger:
MAX_VELOCITY = 10 return
collider.move_and_collide(velocity * 3) collider.move_and_collide(velocity * 3)
if global_position.x >= destination.x:
set_trolley_open(false)
state = State.LEAVING
func _leaving(delta: float) -> void:
velocity.x = min(move_toward(velocity.x, (destination.x + 200), delta * 10), MAX_VELOCITY)
var collision := move_and_collide(velocity)
if collision:
var collider = collision.get_collider()
if collider.get_class() == "KinematicBody2D":
collider.move_and_collide(velocity * 3)
# if global_position.x >= destination.x:
# set_trolley_open(true)
# state = State.STOPPED
func set_trolley_open(trolley_open: bool) -> void:
trolley_closed_shape.set_deferred("disabled", trolley_open)
func _on_TrolleySeatArea_body_entered(body: Node) -> void: func _on_TrolleySeatArea_body_entered(body: Node) -> void:
if body is Player: if body is Player and state != State.STOPPED and state != State.MOVE_TO_START:
has_roger = true has_roger = true
print('closing trolley')
trolley_closed_shape.set_deferred("disabled", false) trolley_closed_shape.set_deferred("disabled", false)
emit_signal("rogers_entered_trolley")
func _on_TrolleySurroundingArea_body_exited(body_rid: RID, body: Node, body_shape_index: int, local_shape_index: int) -> void:
func _on_TrolleySeatArea_body_exited(body: Node) -> void:
if body is Player: if body is Player:
has_roger = false
emit_signal("rogers_left_trolley") emit_signal("rogers_left_trolley")