1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-10-16 06:17:31 +00:00

Implement many post-jam details

- Do not kick to the main menu after reaching the goal
- Display the current player in yellow on the scoreboard
- Add a new leafpile on the sand islands
- Add timer and speedometer
This commit is contained in:
Steffo 2023-01-14 22:31:02 +01:00
parent d839cb02d3
commit 23747addd1
Signed by: steffo
GPG key ID: 2A24051445686895
16 changed files with 238 additions and 136 deletions

View file

@ -2,5 +2,3 @@ extends Node
var player: Player
var username: String
var time: float = 0
var should_upload: bool = false

View file

@ -49,4 +49,4 @@ static func delete_children(node):
static func log_line(obj: Node, msg: String):
var time = Time.get_time_dict_from_system()
var time_str = "%02d:%02d:%02d" % [time.hour, time.minute, time.second]
print("@%s [%s]: %s" % [time_str, obj.name, msg])

View file

@ -23,13 +23,14 @@ var current_scene: Node = null:
current_scene.queue_free()
current_scene = new_scene
add_child(current_scene)
move_child(current_scene, 0)
## Change the current scene to the Island.
func move_to_island():
print("Starting game...")
emit_signal("moving_to_island")
current_scene = load("res://island/Island.tscn").instantiate()
current_scene = preload("res://island/Island.tscn").instantiate()
emit_signal("moved_to_island")
## Change the current scene to the main menu.
@ -37,7 +38,7 @@ func move_to_menu():
print("Going to the menu...")
emit_signal("moving_to_menu")
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
current_scene = load("res://menu/Menu.tscn").instantiate()
current_scene = preload("res://menu/Menu.tscn").instantiate()
current_scene.connect("play_pressed", move_to_island)
emit_signal("moved_to_menu")

View file

@ -1,6 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://cj86x6gplsbrb"]
[gd_scene load_steps=3 format=3 uid="uid://cj86x6gplsbrb"]
[ext_resource type="Script" path="res://base/BaseScene.gd" id="1_n2o7j"]
[ext_resource type="PackedScene" path="res://menu/ScoreboardContainer.tscn" id="2_tjx6n"]
[node name="BaseScene" type="Node"]
script = ExtResource("1_n2o7j")
[node name="ScoreboardContainer" parent="." instance=ExtResource("2_tjx6n")]

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=18 format=3 uid="uid://bg88gc1w1gw5m"]
[ext_resource type="PackedScene" path="res://island/sinking/Sea.tscn" id="1_e0hpm"]
[ext_resource type="PackedScene" uid="uid://dh5blytk6vmdu" path="res://island/sinking/Sea.tscn" id="1_e0hpm"]
[ext_resource type="PackedScene" uid="uid://bbp47va0yygpw" path="res://player/Player.tscn" id="3_5378m"]
[ext_resource type="PackedScene" uid="uid://cyuqnp5bfan4y" path="res://island/IslandMesh.tscn" id="3_g5ug0"]
[ext_resource type="PackedScene" uid="uid://tahdk48hqxis" path="res://island/HillMesh.tscn" id="4_5ll24"]
@ -37,9 +37,6 @@ sky = SubResource("Sky_j6hso")
[node name="Island" type="Node3D"]
[node name="Player" parent="." instance=ExtResource("3_5378m")]
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 3.896, 2.08165e-12)
[node name="Sea" parent="." instance=ExtResource("1_e0hpm")]
metadata/_edit_lock_ = true
@ -47,6 +44,9 @@ metadata/_edit_lock_ = true
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 20, 0, -4)
metadata/_edit_lock_ = true
[node name="Player" parent="." instance=ExtResource("3_5378m")]
transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 3.896, 2.08165e-12)
[node name="World" type="Node3D" parent="."]
[node name="Environment" type="WorldEnvironment" parent="World"]
@ -235,6 +235,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 3, 59)
[node name="Leafpile19" parent="CropTiles" instance=ExtResource("9_472aa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 3, 60)
[node name="Leafpile22" parent="CropTiles" instance=ExtResource("9_472aa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -26, 1, 33)
[node name="Produce" type="Node3D" parent="."]
metadata/_edit_lock_ = true

View file

@ -1,5 +1,5 @@
extends Node3D
class_name Temple
var score: int = 0
var time: float = 0.0
@ -10,13 +10,13 @@ var is_exploded: bool = false
@export var explode_at: int = 150
@export var explosion_scene: PackedScene = preload("res://island/FunnyExplosion.tscn")
@onready var player: Player = Singletons.player
@onready var prayer_area: Area3D = $PrayerArea
@onready var pineglasses: MeshInstance3D = $Pineglasses
@onready var pineglasses_sound: AudioStreamPlayer3D = $Pineglasses/Growth
func try_to_collect_fruit():
var player = Singletons.player
if prayer_area.overlaps_body(player):
if player.collected_fruit > 0:
if not pineglasses_sound.playing:
@ -49,11 +49,7 @@ func try_to_explode():
func win():
print("YOU WIN!")
print("Time: ", time)
Singletons.should_upload = true
Singletons.time = time
$"/root/BaseScene".move_to_menu()
# get_tree().change_scene_to_file("res://base/BaseScene.tscn")
$"/root/BaseScene/ScoreboardContainer".upload_score(time)
queue_free()

View file

@ -2,73 +2,6 @@ extends Control
signal play_pressed()
var scores_downloaded := false
var scores := [] as Array[Array]
var score_scene := preload("res://menu/score.tscn")
var is_uploading := false
func _ready() -> void:
if Singletons.should_upload:
# do request...
_upload_score()
_fetch_scores()
func _upload_score():
Singletons.should_upload = false
var url = "https://arcade.steffo.eu/score/?board=ld52&player=%s" % Singletons.username
var httpreq = HTTPRequest.new()
add_child(httpreq)
httpreq.connect("request_completed", func(result, response_code, headers, body):
var json = JSON.parse_string(body.get_string_from_utf8())
# { score, rank }
print(json)
self.is_uploading = false
_fetch_scores(true)
httpreq.queue_free()
)
self.is_uploading = true
httpreq.request(url, [
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer pineapples-everywhere"
], true, HTTPClient.METHOD_PUT, str(Singletons.time))
_fetch_scores(true)
func _fetch_scores(open_after: bool = false):
const url = "https://arcade.steffo.eu/board/?board=ld52&offset=0&size=50"
var httpreq = HTTPRequest.new()
add_child(httpreq)
httpreq.connect("request_completed", func(result, response_code, headers, body):
var json = JSON.parse_string(body.get_string_from_utf8())
self.scores = (json as Array).map(func(element): return [element.name, element.score])
for child in $ScoreboardContainer/Panel/VBoxContainer/ScrollContainer/ScoresVBox.get_children():
child.queue_free()
for score in self.scores:
var score_sc = score_scene.instantiate()
score_sc.get_node("HBoxContainer/Name").text = score[0]
score_sc.get_node("HBoxContainer/Score").text = "%0.3f s" % score[1]
$ScoreboardContainer/Panel/VBoxContainer/ScrollContainer/ScoresVBox.add_child(score_sc)
self.scores_downloaded = true
%ScoresButton.disabled = false
print(self.scores)
if open_after:
$ScoreboardContainer.show_scores()
httpreq.queue_free()
)
httpreq.request(url)
func play():
print("Player ", Singletons.username, " started playing!")
@ -78,3 +11,13 @@ func play():
func _on_name_input_text_changed():
Singletons.username = $Content/Inputs/NameInput.text
%PlayButton.disabled = false
func _on_fetched_scores():
$Content/Buttons/HBoxContainer/ScoresButton.disabled = false
$Content/Buttons/HBoxContainer/ScoresButton.connect("pressed", $"/root/BaseScene/ScoreboardContainer".show_scores)
func _ready():
$"/root/BaseScene/ScoreboardContainer".connect("fetched_scores", _on_fetched_scores)
$"/root/BaseScene/ScoreboardContainer".fetch_scores(false)

View file

@ -1,9 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://bufi0wh54u5x5"]
[gd_scene load_steps=4 format=3 uid="uid://bufi0wh54u5x5"]
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_mkxnc"]
[ext_resource type="Script" path="res://menu/Menu.gd" id="2_6amk3"]
[ext_resource type="Texture2D" uid="uid://bxyximtgui1ux" path="res://assets/grass_menu_tile.png" id="2_q14jx"]
[ext_resource type="PackedScene" uid="uid://tmxndy6x0u3l" path="res://menu/ScoreboardContainer.tscn" id="4_6ss1l"]
[node name="Menu" type="Control"]
texture_filter = 1
@ -88,7 +87,6 @@ disabled = true
text = "Play"
[node name="ScoresButton" type="Button" parent="Content/Buttons/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(52, 2.08165e-12)
layout_mode = 2
size_flags_horizontal = 4
@ -103,9 +101,5 @@ size_flags_vertical = 1
text = "Ludum Dare 52 - Harvest"
horizontal_alignment = 1
[node name="ScoreboardContainer" parent="." instance=ExtResource("4_6ss1l")]
layout_mode = 1
[connection signal="text_changed" from="Content/Inputs/NameInput" to="." method="_on_name_input_text_changed"]
[connection signal="pressed" from="Content/Buttons/HBoxContainer/PlayButton" to="." method="play"]
[connection signal="pressed" from="Content/Buttons/HBoxContainer/ScoresButton" to="ScoreboardContainer" method="show_scores"]

28
menu/ScoreBox.gd Normal file
View file

@ -0,0 +1,28 @@
extends MarginContainer
class_name ScoreBox
@onready var name_label: Label = $HBoxContainer/Name
@onready var score_label: Label = $HBoxContainer/Score
var username: String:
get:
return username
set(value):
username = value
name_label.text = value
if value == Singletons.username:
name_label.add_theme_color_override("font_color", Color.YELLOW)
score_label.add_theme_color_override("font_color", Color.YELLOW)
else:
name_label.remove_theme_color_override("font_color")
score_label.remove_theme_color_override("font_color")
var score: float:
get:
return score
set(value):
score = value
score_label.text = "%0.3f s" % value

View file

@ -1,24 +1,22 @@
[gd_scene format=3 uid="uid://b7h36f4ai0qmq"]
[gd_scene load_steps=2 format=3 uid="uid://b7h36f4ai0qmq"]
[node name="MarginContainer" type="MarginContainer"]
[ext_resource type="Script" path="res://menu/ScoreBox.gd" id="1_exul7"]
[node name="ScoreBox" type="MarginContainer"]
theme_override_constants/margin_left = 5
theme_override_constants/margin_right = 5
script = ExtResource("1_exul7")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
offset_left = 5.0
offset_right = 115.0
offset_bottom = 26.0
layout_mode = 2
alignment = 1
[node name="Name" type="Label" parent="HBoxContainer"]
offset_right = 46.0
offset_bottom = 26.0
layout_mode = 2
size_flags_horizontal = 2
text = "Steffo"
[node name="Score" type="Label" parent="HBoxContainer"]
offset_left = 50.0
offset_right = 110.0
offset_bottom = 26.0
layout_mode = 2
size_flags_horizontal = 10
text = "1512.50"

View file

@ -1,9 +1,76 @@
extends Control
var scores_downloaded := false
var scores := [] as Array[Array]
var score_scene := preload("res://menu/ScoreBox.tscn")
var is_uploading := false
var prev_mouse_mode: Input.MouseMode = Input.MOUSE_MODE_VISIBLE
signal fetched_scores()
func upload_score(score: float):
var url = "https://arcade.steffo.eu/score/?board=ld52&player=%s" % Singletons.username
var httpreq = HTTPRequest.new()
add_child(httpreq)
httpreq.connect("request_completed", func(_result, _response_code, _headers, body):
var json = JSON.parse_string(body.get_string_from_utf8())
# { score, rank }
print(json)
self.is_uploading = false
httpreq.queue_free()
await get_tree().create_timer(1.75).timeout
fetch_scores(true)
)
self.is_uploading = true
httpreq.request(url, [
"Content-Type: application/json",
"Accept: application/json",
"Authorization: Bearer pineapples-everywhere"
], true, HTTPClient.METHOD_PUT, str(score))
func fetch_scores(open_after: bool = false):
const url = "https://arcade.steffo.eu/board/?board=ld52&offset=0&size=10"
var httpreq = HTTPRequest.new()
add_child(httpreq)
httpreq.connect("request_completed", func(_result, _response_code, _headers, body):
var json = JSON.parse_string(body.get_string_from_utf8())
self.scores = (json as Array).map(func(element): return [element.name, element.score])
for child in $Panel/VBoxContainer/ScrollContainer/ScoresVBox.get_children():
child.queue_free()
for score in self.scores:
var score_sc: ScoreBox = score_scene.instantiate()
$Panel/VBoxContainer/ScrollContainer/ScoresVBox.add_child(score_sc)
score_sc.username = score[0]
score_sc.score = score[1]
self.scores_downloaded = true
emit_signal("fetched_scores")
if open_after:
show_scores()
httpreq.queue_free()
)
httpreq.request(url)
func show_scores():
print("Displaying scores...")
prev_mouse_mode = Input.mouse_mode as Input.MouseMode
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
visible = true
func hide_scores():
print("Hiding scores...")
Input.set_mouse_mode(prev_mouse_mode)
visible = false

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://tmxndy6x0u3l"]
[gd_scene load_steps=6 format=3]
[ext_resource type="PackedScene" uid="uid://b7h36f4ai0qmq" path="res://menu/score.tscn" id="1_a00v5"]
[ext_resource type="PackedScene" uid="uid://b7h36f4ai0qmq" path="res://menu/ScoreBox.tscn" id="1_a00v5"]
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_pm2j4"]
[ext_resource type="Script" path="res://menu/ScoreboardContainer.gd" id="1_rc765"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uie3v"]
@ -12,16 +13,21 @@ shadow_color = Color(0, 0, 0, 0.431373)
[node name="ScoreboardContainer" type="Control"]
visible = false
z_as_relative = false
texture_filter = 1
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource("1_pm2j4")
script = ExtResource("1_rc765")
[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
@ -29,7 +35,7 @@ grow_vertical = 2
color = Color(0, 0, 0, 0.635294)
[node name="Panel" type="Panel" parent="."]
anchors_preset = 8
layout_mode = 0
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
@ -43,33 +49,37 @@ grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_uie3v")
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Authors" type="Label" parent="Panel/VBoxContainer"]
layout_mode = 2
text = "Scores"
label_settings = SubResource("LabelSettings_xmwgs")
horizontal_alignment = 1
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="ScoresVBox" type="VBoxContainer" parent="Panel/VBoxContainer/ScrollContainer"]
offset_right = 120.0
offset_bottom = 26.0
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
[node name="score" parent="Panel/VBoxContainer/ScrollContainer/ScoresVBox" instance=ExtResource("1_a00v5")]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="Panel/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_bottom = 2
[node name="closebtn" type="Button" parent="Panel/VBoxContainer/MarginContainer"]
custom_minimum_size = Vector2(52, 2.08165e-12)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_font_sizes/font_size = 0

View file

@ -9,6 +9,7 @@ var noiseRot := Vector3.ZERO
var noiseCount := 0
@export var noiseAmp := 10.0
@export var noiseFreq := 100.0
@onready var camera = $Viewport/CameraViewportContainer/GameViewport/Camera
var mouseRot := Vector2.ZERO
@ -23,3 +24,7 @@ func _ready() -> void:
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
mouseRot = event.relative
func _physics_process(_delta):
camera.global_transform = global_transform

View file

@ -22,8 +22,12 @@ const AIR_ACCELERATE = 100 # Hu/39.97
@onready var active_weapon: BaseWeapon:
get: return OnHand.active_weapon
@onready var ammo_label = $HUD/AmmoLabel
@onready var fruit_label = $HUD/PineappleLabel
@onready var ammo_label: Label = $HUD/AmmoLabel
@onready var fruit_label: Label = $HUD/PineappleLabel
@onready var speed_label: Label = $HUD/SpeedLabel
@onready var timer_label: Label = $HUD/TimerLabel
@onready var temple: Temple = $"/root/BaseScene/Island/Temple"
var collected_fruit: int = 0:
get:
@ -96,7 +100,7 @@ func _physics_process(delta):
if active_weapon and active_weapon.ammoType != BaseWeapon.AmmoType.NONE:
ammo_label.show()
if active_weapon is PeaShooter:
ammo_label.text = "%d seeds left" % active_weapon.remaining
ammo_label.text = "%d seeds" % active_weapon.remaining
else:
ammo_label.hide()
@ -126,7 +130,11 @@ func _air_accelerate(wish_dir: Vector3, wish_speed: float, airaccelerate: float,
func _process(_delta: float) -> void:
self.camera.global_transform = self.head.global_transform
speed_label.text = "%0.2f km/h" % velocity.length()
if temple != null:
timer_label.text = "%0.3f s" % temple.time
else:
timer_label.text = ""
func _input(event):

View file

@ -79,7 +79,7 @@ grow_horizontal = 2
grow_vertical = 2
[node name="CameraViewportContainer" type="SubViewportContainer" parent="Head/Viewport"]
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
@ -118,7 +118,7 @@ theme = SubResource("Theme_smyke")
[node name="SubViewportContainer" type="SubViewportContainer" parent="HUD"]
show_behind_parent = true
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
@ -147,40 +147,75 @@ scale = Vector2(1.65, 1)
metadata/_edit_lock_ = true
[node name="PineappleLabel" type="Label" parent="HUD"]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_top = -26.0
offset_right = 106.0
offset_bottom = -8.0
grow_vertical = 0
theme = ExtResource("4_d7ru6")
theme_override_font_sizes/font_size = 16
text = "0 harvested"
vertical_alignment = 2
[node name="AmmoLabel" type="Label" parent="HUD"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -103.0
offset_top = -26.0
offset_right = -8.0
offset_bottom = -8.0
offset_left = -102.0
offset_top = -22.0
offset_right = -4.0
offset_bottom = -4.0
grow_horizontal = 0
grow_vertical = 0
theme = ExtResource("4_d7ru6")
theme_override_font_sizes/font_size = 16
text = "8888 seeds left"
text = "0 harvested"
horizontal_alignment = 2
vertical_alignment = 2
[node name="AmmoLabel" type="Label" parent="HUD"]
layout_mode = 0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -99.0
offset_top = -34.0
offset_right = -4.0
offset_bottom = -16.0
grow_horizontal = 0
grow_vertical = 0
theme = ExtResource("4_d7ru6")
theme_override_font_sizes/font_size = 16
text = "8888 seeds"
horizontal_alignment = 2
vertical_alignment = 2
[node name="TimerLabel" type="Label" parent="HUD"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = -34.0
offset_right = 99.0
offset_bottom = -16.0
grow_vertical = 0
theme = ExtResource("4_d7ru6")
theme_override_font_sizes/font_size = 16
text = "0.000 s"
vertical_alignment = 2
[node name="SpeedLabel" type="Label" parent="HUD"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 4.0
offset_top = -22.0
offset_right = 99.0
offset_bottom = -4.0
grow_vertical = 0
theme = ExtResource("4_d7ru6")
theme_override_font_sizes/font_size = 16
text = "5.00 km/h"
vertical_alignment = 2
[node name="Crosshair" type="ColorRect" parent="HUD"]
material = SubResource("ShaderMaterial_2p6rt")
anchors_preset = 15
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2

View file

@ -44,10 +44,20 @@ _global_script_classes=[{
"language": &"GDScript",
"path": "res://player/PlayerInputData.gd"
}, {
"base": "MarginContainer",
"class": &"ScoreBox",
"language": &"GDScript",
"path": "res://menu/ScoreBox.gd"
}, {
"base": "Area3D",
"class": &"SinkArea",
"language": &"GDScript",
"path": "res://island/sinking/SinkArea.gd"
}, {
"base": "Node3D",
"class": &"Temple",
"language": &"GDScript",
"path": "res://island/Temple.gd"
}]
_global_script_class_icons={
"BaseScene": "",
@ -57,16 +67,19 @@ _global_script_class_icons={
"PeaShooter": "",
"Player": "",
"PlayerInputData": "",
"SinkArea": ""
"ScoreBox": "",
"SinkArea": "",
"Temple": ""
}
[application]
config/name="Pineapple Surf"
config/description="A bunnyhopping, retro-looking, first person seed shooters"
config/description="A bunnyhopping, retro-looking, first person seed shooter"
run/main_scene="res://base/BaseScene.tscn"
config/features=PackedStringArray("4.0", "GL Compatibility")
boot_splash/bg_color=Color(0.231373, 0.490196, 0.309804, 1)
boot_splash/image="res://assets/pineglasses.png"
config/icon="res://assets/pineglasses.png"
[autoload]