feat: exit and fullscreen keybinds

This commit is contained in:
newt 2024-08-17 16:49:40 +01:00
parent c4c796f323
commit 9e7c271754
15 changed files with 196 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/export/stage1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

View file

@ -2,16 +2,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dvnohr8gjh56t"
path="res://.godot/imported/PlayerCharacter.png-ab2ae3be5ec39b25693dfd99826d05ab.ctex"
uid="uid://bynsxkfd4t4cn"
path="res://.godot/imported/stage1.png-c3fb8862b9a844ae4f643a865fe729ba.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://PlayerCharacter.png"
dest_files=["res://.godot/imported/PlayerCharacter.png-ab2ae3be5ec39b25693dfd99826d05ab.ctex"]
source_file="res://assets/export/stage1.png"
dest_files=["res://.godot/imported/stage1.png-c3fb8862b9a844ae4f643a865fe729ba.ctex"]
[params]

BIN
assets/stage1.aseprite Normal file

Binary file not shown.

View file

@ -0,0 +1,16 @@
[remap]
importer="aseprite_wizard.plugin.static-texture"
type="AtlasTexture"
uid="uid://fju2p8ssaled"
path="res://.godot/imported/stage1.aseprite-4be92de9d6e8d30b990f34fbdce9c3c1.res"
[deps]
source_file="res://assets/stage1.aseprite"
dest_files=["res://.godot/imported/stage1.aseprite-4be92de9d6e8d30b990f34fbdce9c3c1.res"]
[params]
exclude_layers_pattern=""
only_visible_layers=true

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=4 format=3 uid="uid://bab4ac3s2n0o1"]
[gd_scene load_steps=3 format=3 uid="uid://bab4ac3s2n0o1"]
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_j1bt6"]
normal = Vector2(1, 0)
@ -8,10 +8,6 @@ distance = -184.0
normal = Vector2(-1, 0)
distance = -208.0
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ogsi3"]
normal = Vector2(0, 1)
distance = -240.0
[node name="Borders" type="Node2D"]
[node name="Left" type="StaticBody2D" parent="."]
@ -33,10 +29,3 @@ position = Vector2(0, 72)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Right/Trigger"]
position = Vector2(272, 264)
shape = SubResource("WorldBoundaryShape2D_wodb0")
[node name="Top" type="StaticBody2D" parent="."]
position = Vector2(-40, 0)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Top"]
position = Vector2(272, 240)
shape = SubResource("WorldBoundaryShape2D_ogsi3")

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=37 format=3 uid="uid://cjiuycwqqxaxn"]
[ext_resource type="Script" path="res://player.gd" id="1_oy25y"]
[ext_resource type="Script" path="res://scripts/player.gd" id="1_oy25y"]
[ext_resource type="Texture2D" uid="uid://cownabyc1p26u" path="res://assets/export/playerLayer 3.png" id="2_5c6qp"]
[sub_resource type="AtlasTexture" id="AtlasTexture_unh28"]

64
export_presets.cfg Normal file
View file

@ -0,0 +1,64 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="./claustrophemia.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=0
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
application/export_angle=0
application/export_d3d12=0
application/d3d12_agility_sdk_multiarch=true
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"

View file

@ -1,32 +1,49 @@
[gd_scene load_steps=6 format=3 uid="uid://cei5gjgfoginb"]
[gd_scene load_steps=7 format=3 uid="uid://cei5gjgfoginb"]
[ext_resource type="Script" path="res://stageController.gd" id="1_m1n7w"]
[ext_resource type="PackedScene" uid="uid://cjiuycwqqxaxn" path="res://Player.tscn" id="2_sxo5w"]
[ext_resource type="PackedScene" uid="uid://bab4ac3s2n0o1" path="res://Borders.tscn" id="3_04xvl"]
[ext_resource type="Script" path="res://scripts/stageController.gd" id="1_m1n7w"]
[ext_resource type="Texture2D" uid="uid://bynsxkfd4t4cn" path="res://assets/export/stage1.png" id="2_48003"]
[ext_resource type="PackedScene" uid="uid://cjiuycwqqxaxn" path="res://components/Player.tscn" id="2_sxo5w"]
[ext_resource type="PackedScene" uid="uid://bab4ac3s2n0o1" path="res://components/Borders.tscn" id="3_04xvl"]
[sub_resource type="QuadMesh" id="QuadMesh_seics"]
size = Vector2(480, 64)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_h5wua"]
size = Vector2(480, 66)
size = Vector2(480, 106)
[node name="World" type="Node2D"]
position = Vector2(272, 240)
script = ExtResource("1_m1n7w")
next_stage = "res://levels/level1/stage2.tscn"
[node name="Player" parent="." instance=ExtResource("2_sxo5w")]
position = Vector2(-192, 0)
[node name="Background" type="Sprite2D" parent="."]
position = Vector2(-32, -64)
texture = ExtResource("2_48003")
[node name="Borders" parent="." instance=ExtResource("3_04xvl")]
position = Vector2(-272, -240)
[node name="Player" parent="." instance=ExtResource("2_sxo5w")]
position = Vector2(-240, -16)
[node name="Floor" type="StaticBody2D" parent="."]
[node name="MeshInstance2D" type="MeshInstance2D" parent="Floor"]
position = Vector2(-32, 88)
position = Vector2(-32, 68)
scale = Vector2(1, 1.625)
mesh = SubResource("QuadMesh_seics")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Floor"]
position = Vector2(-32, 89)
position = Vector2(-32, 69)
shape = SubResource("RectangleShape2D_h5wua")
[node name="Ceiling" type="StaticBody2D" parent="."]
[node name="MeshInstance2D" type="MeshInstance2D" parent="Ceiling"]
position = Vector2(-32, -192)
scale = Vector2(1, 1.625)
mesh = SubResource("QuadMesh_seics")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ceiling"]
position = Vector2(-32, -192)
shape = SubResource("RectangleShape2D_h5wua")

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cnpspjqlc7b52"]
[ext_resource type="Script" path="res://stageController.gd" id="1_0rodf"]
[ext_resource type="Script" path="res://scripts/stageController.gd" id="1_0rodf"]
[node name="World" type="Node2D"]
script = ExtResource("1_0rodf")

View file

@ -1,38 +0,0 @@
extends CharacterBody2D
@export var SPEED = 300
@export var GRAVITY = 30
@export var JUMP_FORCE = 500
@onready var animated_sprite = $AnimatedSprite2D;
var jumping = false;
func _ready():
animated_sprite.play("idle")
func _physics_process(delta):
if !is_on_floor():
velocity.y += GRAVITY
if velocity.y > 1000:
velocity.y = 1000
if jumping && is_on_floor():
jumping = false
if Input.is_action_just_pressed("jump") && is_on_floor():
velocity.y = -JUMP_FORCE
jumping = true
animated_sprite.play("jump")
var horizontal_direction = Input.get_axis("move_left", "move_right")
velocity.x = SPEED * horizontal_direction
move_and_slide()
animated_sprite.flip_h = horizontal_direction < 0
if !jumping:
if is_on_floor() && horizontal_direction != 0:
animated_sprite.play("walk")
else:
animated_sprite.play("idle")

View file

@ -14,18 +14,23 @@ config/name="claustrophemia"
config/version="0.0.1"
run/main_scene="res://levels/level1/stage1.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
boot_splash/show_image=false
config/icon="res://icon.svg"
[aseprite]
animation/layers/only_include_visible_layers_by_default=true
import/import_plugin/default_automatic_importer="SpriteFrames"
[autoload]
GlobalKeybinds="*res://scripts/globalKeybinds.gd"
[display]
window/size/viewport_width=480
window/size/viewport_height=360
window/stretch/mode="canvas_items"
window/vsync/vsync_mode=0
[editor]
@ -62,3 +67,13 @@ trigger_completed={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194323,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
toggle_fullscreen={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194342,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
quit={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}

16
scripts/globalKeybinds.gd Normal file
View file

@ -0,0 +1,16 @@
extends Node
var previous_window_mode = -1
func _process(delta: float) -> void:
if Input.is_action_just_pressed("toggle_fullscreen"):
if get_window().mode == Window.MODE_FULLSCREEN:
if previous_window_mode != -1:
get_window().mode = previous_window_mode
else:
get_window().mode = Window.MODE_MAXIMIZED
else:
previous_window_mode = get_window().mode
get_window().mode = Window.MODE_FULLSCREEN
elif Input.is_action_just_pressed("quit"):
get_tree().quit()

51
scripts/player.gd Normal file
View file

@ -0,0 +1,51 @@
extends CharacterBody2D
@export var SPEED = 300
@export var GRAVITY = 30
@export var JUMP_FORCE = 500
@onready var animated_sprite = $AnimatedSprite2D;
var jumping = false;
var facing_right = true;
func _ready():
animated_sprite.play("idle")
func _physics_process(delta):
if is_on_floor():
# allow the player to jump
if jumping:
jumping = false
if Input.is_action_just_pressed("jump"):
velocity.y = -JUMP_FORCE
jumping = true
animated_sprite.play("jump")
else:
# apply gravity
velocity.y += GRAVITY
if velocity.y > 1000:
velocity.y = 1000
# perform horizontal movement
var horizontal_direction = Input.get_axis("move_left", "move_right")
velocity.x = SPEED * horizontal_direction
move_and_slide()
# ensure the player faces the correct direction
if horizontal_direction > 0 && !facing_right:
animated_sprite.flip_h = false
elif horizontal_direction < 0 && facing_right:
animated_sprite.flip_h = true
if horizontal_direction != 0:
facing_right = horizontal_direction > 0
# figure out which animation should be played
# respecting the jump animation above all
if !jumping:
if is_on_floor() && horizontal_direction != 0:
animated_sprite.play("walk")
else:
animated_sprite.play("idle")