feat: basic main menu to load dust 2 on singleplayer
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Papaya-Shooter"
|
config/name="Papaya-Shooter"
|
||||||
run/main_scene="res://scenes/dust2_level/dust2_level.tscn"
|
run/main_scene="res://ui/main_menu/main_menu.tscn"
|
||||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
# ==========================================
|
||||||
|
# BACKGROUND: 3D DIORAMA (Sliding Player)
|
||||||
|
# ==========================================
|
||||||
|
var right_panel = SubViewportContainer.new()
|
||||||
|
right_panel.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||||
|
right_panel.stretch = true
|
||||||
|
right_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
add_child(right_panel)
|
||||||
|
|
||||||
|
var viewport = SubViewport.new()
|
||||||
|
viewport.own_world_3d = true
|
||||||
|
right_panel.add_child(viewport)
|
||||||
|
|
||||||
|
_build_3d_diorama(viewport)
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# FOREGROUND: UI (Title and Buttons)
|
||||||
|
# ==========================================
|
||||||
|
var ui_vbox = VBoxContainer.new()
|
||||||
|
ui_vbox.add_theme_constant_override("separation", 30)
|
||||||
|
ui_vbox.set_anchor_and_offset(SIDE_LEFT, 0.0, 50)
|
||||||
|
ui_vbox.set_anchor_and_offset(SIDE_TOP, 0.0, 50)
|
||||||
|
ui_vbox.set_anchor_and_offset(SIDE_RIGHT, 0.0, 600)
|
||||||
|
ui_vbox.set_anchor_and_offset(SIDE_BOTTOM, 1.0, -50)
|
||||||
|
add_child(ui_vbox)
|
||||||
|
|
||||||
|
# Title
|
||||||
|
var title = Label.new()
|
||||||
|
title.text = "Papaya Shooter"
|
||||||
|
title.add_theme_font_size_override("font_size", 72)
|
||||||
|
title.add_theme_color_override("font_color", Color(1, 0.6, 0.2)) # Papaya orange
|
||||||
|
title.add_theme_color_override("font_outline_color", Color(0, 0, 0))
|
||||||
|
title.add_theme_constant_override("outline_size", 12)
|
||||||
|
ui_vbox.add_child(title)
|
||||||
|
|
||||||
|
# Spacer
|
||||||
|
var spacer = Control.new()
|
||||||
|
spacer.custom_minimum_size = Vector2(0, 40)
|
||||||
|
ui_vbox.add_child(spacer)
|
||||||
|
|
||||||
|
# Buttons
|
||||||
|
_add_button(ui_vbox, "Singleplayer", _on_singleplayer_pressed)
|
||||||
|
_add_button(ui_vbox, "Multiplayer", _on_multiplayer_pressed)
|
||||||
|
_add_button(ui_vbox, "Settings", _on_settings_pressed)
|
||||||
|
_add_button(ui_vbox, "Exit Game", _on_exit_pressed)
|
||||||
|
|
||||||
|
func _add_button(parent: VBoxContainer, text: String, callback: Callable) -> void:
|
||||||
|
var btn = Button.new()
|
||||||
|
btn.text = text
|
||||||
|
btn.add_theme_font_size_override("font_size", 32)
|
||||||
|
btn.custom_minimum_size = Vector2(300, 60)
|
||||||
|
btn.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||||
|
btn.pressed.connect(callback)
|
||||||
|
parent.add_child(btn)
|
||||||
|
|
||||||
|
func _on_singleplayer_pressed() -> void:
|
||||||
|
get_tree().change_scene_to_file("res://scenes/dust2_level/dust2_level.tscn")
|
||||||
|
|
||||||
|
func _on_multiplayer_pressed() -> void:
|
||||||
|
print("Multiplayer not implemented yet.")
|
||||||
|
|
||||||
|
func _on_settings_pressed() -> void:
|
||||||
|
print("Settings not implemented yet.")
|
||||||
|
|
||||||
|
func _on_exit_pressed() -> void:
|
||||||
|
get_tree().quit()
|
||||||
|
|
||||||
|
# ==========================================
|
||||||
|
# 3D DIORAMA BUILDER
|
||||||
|
# ==========================================
|
||||||
|
func _build_3d_diorama(viewport: SubViewport) -> void:
|
||||||
|
var world = Node3D.new()
|
||||||
|
viewport.add_child(world)
|
||||||
|
|
||||||
|
# Lighting and Env
|
||||||
|
var env = WorldEnvironment.new()
|
||||||
|
var environment = Environment.new()
|
||||||
|
environment.background_mode = Environment.BG_COLOR
|
||||||
|
environment.background_color = Color(0.1, 0.15, 0.2) # Dark stylish background
|
||||||
|
environment.tonemap_mode = Environment.TONE_MAPPER_ACES
|
||||||
|
env.environment = environment
|
||||||
|
world.add_child(env)
|
||||||
|
|
||||||
|
var sun = DirectionalLight3D.new()
|
||||||
|
sun.rotation_degrees = Vector3(-45, 45, 0)
|
||||||
|
sun.light_color = Color(1.0, 0.9, 0.8)
|
||||||
|
sun.light_energy = 1.5
|
||||||
|
sun.shadow_enabled = true
|
||||||
|
world.add_child(sun)
|
||||||
|
|
||||||
|
var fill = DirectionalLight3D.new()
|
||||||
|
fill.rotation_degrees = Vector3(-30, -135, 0)
|
||||||
|
fill.light_color = Color(0.5, 0.6, 1.0)
|
||||||
|
fill.light_energy = 0.5
|
||||||
|
world.add_child(fill)
|
||||||
|
|
||||||
|
# Floor
|
||||||
|
var floor_mesh = MeshInstance3D.new()
|
||||||
|
floor_mesh.mesh = PlaneMesh.new()
|
||||||
|
floor_mesh.mesh.size = Vector2(20, 20)
|
||||||
|
var floor_mat = StandardMaterial3D.new()
|
||||||
|
floor_mat.albedo_color = Color(0.2, 0.2, 0.2)
|
||||||
|
floor_mesh.mesh.surface_set_material(0, floor_mat)
|
||||||
|
world.add_child(floor_mesh)
|
||||||
|
|
||||||
|
# Player Model (Sliding Pose)
|
||||||
|
var player_model = Node3D.new()
|
||||||
|
player_model.position = Vector3(0, 0.5, 0) # Lowered for slide
|
||||||
|
world.add_child(player_model)
|
||||||
|
|
||||||
|
var body_mat = StandardMaterial3D.new()
|
||||||
|
body_mat.albedo_color = Color(0.3, 0.6, 0.9)
|
||||||
|
|
||||||
|
# Torso (Capsule tilted back)
|
||||||
|
var torso = MeshInstance3D.new()
|
||||||
|
var t_mesh = CapsuleMesh.new()
|
||||||
|
t_mesh.radius = 0.4
|
||||||
|
t_mesh.height = 1.2
|
||||||
|
t_mesh.material = body_mat
|
||||||
|
torso.mesh = t_mesh
|
||||||
|
torso.rotation_degrees.x = -60 # Tilted back
|
||||||
|
torso.position = Vector3(0, 0.4, 0)
|
||||||
|
player_model.add_child(torso)
|
||||||
|
|
||||||
|
# Legs (Sticking forward)
|
||||||
|
var legs = MeshInstance3D.new()
|
||||||
|
var l_mesh = BoxMesh.new()
|
||||||
|
l_mesh.size = Vector3(0.6, 0.4, 1.2)
|
||||||
|
l_mesh.material = body_mat
|
||||||
|
legs.mesh = l_mesh
|
||||||
|
legs.position = Vector3(0, -0.2, 0.6)
|
||||||
|
player_model.add_child(legs)
|
||||||
|
|
||||||
|
# Arm holding shotgun
|
||||||
|
var arm = Node3D.new()
|
||||||
|
arm.position = Vector3(0.5, 0.6, 0.2)
|
||||||
|
player_model.add_child(arm)
|
||||||
|
|
||||||
|
var arm_mesh = MeshInstance3D.new()
|
||||||
|
var a_mesh = BoxMesh.new()
|
||||||
|
a_mesh.size = Vector3(0.2, 0.2, 0.8)
|
||||||
|
a_mesh.material = body_mat
|
||||||
|
arm_mesh.mesh = a_mesh
|
||||||
|
arm_mesh.position = Vector3(0, 0, 0.3)
|
||||||
|
arm.add_child(arm_mesh)
|
||||||
|
|
||||||
|
# Shotgun
|
||||||
|
var shotgun_script = load("res://weapons/double_barrel_shotgun.gd")
|
||||||
|
if shotgun_script:
|
||||||
|
var shotgun = shotgun_script.new()
|
||||||
|
arm_mesh.add_child(shotgun)
|
||||||
|
shotgun.position = Vector3(0, -0.1, 0.4)
|
||||||
|
shotgun.rotation_degrees = Vector3(0, 0, 0)
|
||||||
|
shotgun.set_process(false)
|
||||||
|
shotgun.set_physics_process(false)
|
||||||
|
if shotgun.has_method("set_process_input"):
|
||||||
|
shotgun.set_process_input(false)
|
||||||
|
|
||||||
|
# Camera
|
||||||
|
var camera = Camera3D.new()
|
||||||
|
world.add_child(camera)
|
||||||
|
camera.position = Vector3(3, 1.5, 4)
|
||||||
|
camera.look_at(Vector3(0, 0.5, 0))
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dflvxkquwjl42
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://b0x123456789"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://ui/main_menu/main_menu.gd" id="1_1a2b3"]
|
||||||
|
|
||||||
|
[node name="MainMenu" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_1a2b3")
|
||||||
Reference in New Issue
Block a user