From 98712be08b57c9b2987441962ff9d99e2eb8a4fc Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 27 Oct 2023 18:47:54 +0200 Subject: [PATCH] Updated Player Movement - movement is now smoother (includes friction and acceleration) - diagonal movement now possible - export settings for optimal build creation --- .DS_Store | Bin 6148 -> 6148 bytes assets/.DS_Store | Bin 6148 -> 6148 bytes assets/art/.DS_Store | Bin 6148 -> 6148 bytes export_presets.cfg | 164 +++++++++++++++++++++++++++++++++++++++++++ scripts/player.gd | 49 +++++++++---- 5 files changed, 199 insertions(+), 14 deletions(-) create mode 100644 export_presets.cfg diff --git a/.DS_Store b/.DS_Store index c32883842752acf742ff9e4a68f0123bb24f31f0..534ef96998e6bd3f513eb31777009c8ab78f4b78 100644 GIT binary patch literal 6148 zcmeHK-AcnS6i(b<<`8zFu*-nA1NX<6cvI$l0V{f;GFv;eSevnS_F@crtuN%0_&lDI zWJ0Zar6Mk;oP5biPRsX=Bs+ur=wvuO*t0MY;SIzw z2j?PqCM3?BS9!jbALPpv-)?WvTbbfv*(6^MQjSS{hS@^5}p@mH>c72up)L))JV*HCh@|g)jp~RVtuLrMkqRDjnin zud_6!3ROCxy7-{_%T!k=RDK=a&*gGLErq5v3K#{l3KZ0^j`#o3=k)vnOcg=|%={6MGML6F I@T&^E0vkDx(f|Me delta 91 zcmZoMXfc=|#>CJzu~2NHo}wrt0|NsP3otO0Fcha0C+8&P=jTi;RA*$Ie1TPFvj~SU q%f<#D=FRLJ{2V}Cn*}+(Gf(Ch(d7hbJOIQDlWlmUH^+!9VFm#Emlc=* diff --git a/assets/.DS_Store b/assets/.DS_Store index b287e1bed3a020b4378ecb6be52e612f862812c8..8f6e52fb351bcc05874836cf665bcb40f163ac57 100644 GIT binary patch delta 24 gcmZoMXfc>z$H*|zUVdZZGWN;3BJ7*FIezj30AOtgj{pDw delta 26 icmZoMXfc>z$H+L*UY?P0W8yOQ$$BDeo4GlD@&f>7?FW(o diff --git a/assets/art/.DS_Store b/assets/art/.DS_Store index 1d9d01f091e5ec7f7a6f596117bba5228a33d9cc..3c30893ad7fa047b83d55ccae704832986a704e8 100644 GIT binary patch delta 20 bcmZoMXffEZkdfWcL`T8U*mUy>#uzaGLB9ps delta 20 bcmZoMXffEZkdfWeSVzIw&|>on#uzaGLMR2~ diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..e7f5114 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,164 @@ +[preset.0] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="../teamprojekt23_v0.1.0.exe" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=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="0.1.0.0" +application/product_version="0.1.0.0" +application/company_name="Teamprojekt23" +application/product_name="Teamprojekt23" +application/file_description="" +application/copyright="" +application/trademarks="" +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}'" + +[preset.1] + +name="macOS" +platform="macOS" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="../teamprojekt23_v0.1.0.dmg" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.1.options] + +export/distribution_type=1 +binary_format/architecture="universal" +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +application/icon="" +application/icon_interpolation=4 +application/bundle_identifier="com.teamprojekt23.teamprojekt23" +application/signature="" +application/app_category="Games" +application/short_version="1.0" +application/version="1.0" +application/copyright="" +application/copyright_localized={} +application/min_macos_version="10.12" +display/high_res=true +xcode/platform_build="14C18" +xcode/sdk_version="13.1" +xcode/sdk_build="22C55" +xcode/sdk_name="macosx13.1" +xcode/xcode_version="1420" +xcode/xcode_build="14C18" +codesign/codesign=3 +codesign/installer_identity="" +codesign/apple_team_id="" +codesign/identity="" +codesign/entitlements/custom_file="" +codesign/entitlements/allow_jit_code_execution=false +codesign/entitlements/allow_unsigned_executable_memory=false +codesign/entitlements/allow_dyld_environment_variables=false +codesign/entitlements/disable_library_validation=false +codesign/entitlements/audio_input=false +codesign/entitlements/camera=false +codesign/entitlements/location=false +codesign/entitlements/address_book=false +codesign/entitlements/calendars=false +codesign/entitlements/photos_library=false +codesign/entitlements/apple_events=false +codesign/entitlements/debugging=false +codesign/entitlements/app_sandbox/enabled=false +codesign/entitlements/app_sandbox/network_server=false +codesign/entitlements/app_sandbox/network_client=false +codesign/entitlements/app_sandbox/device_usb=false +codesign/entitlements/app_sandbox/device_bluetooth=false +codesign/entitlements/app_sandbox/files_downloads=0 +codesign/entitlements/app_sandbox/files_pictures=0 +codesign/entitlements/app_sandbox/files_music=0 +codesign/entitlements/app_sandbox/files_movies=0 +codesign/entitlements/app_sandbox/helper_executables=[] +codesign/custom_options=PackedStringArray() +notarization/notarization=0 +privacy/microphone_usage_description="" +privacy/microphone_usage_description_localized={} +privacy/camera_usage_description="" +privacy/camera_usage_description_localized={} +privacy/location_usage_description="" +privacy/location_usage_description_localized={} +privacy/address_book_usage_description="" +privacy/address_book_usage_description_localized={} +privacy/calendar_usage_description="" +privacy/calendar_usage_description_localized={} +privacy/photos_library_usage_description="" +privacy/photos_library_usage_description_localized={} +privacy/desktop_folder_usage_description="" +privacy/desktop_folder_usage_description_localized={} +privacy/documents_folder_usage_description="" +privacy/documents_folder_usage_description_localized={} +privacy/downloads_folder_usage_description="" +privacy/downloads_folder_usage_description_localized={} +privacy/network_volumes_usage_description="" +privacy/network_volumes_usage_description_localized={} +privacy/removable_volumes_usage_description="" +privacy/removable_volumes_usage_description_localized={} +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="#!/usr/bin/env bash +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/scripts/player.gd b/scripts/player.gd index 268c1b4..b6a6de5 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,47 +1,68 @@ extends CharacterBody2D -# Movement speed of the player -const speed = 100 +# max Movement Speed of the player +const maxSpeed = 200 +const acceleration = 1000 +const friction = 1500 # direction of the player var current_direcition = "none" +# input by player +var input = Vector2.ZERO + +# get Input by player +func get_input(): + input.x = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left")) + input.y = int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up")) + return input.normalized() + # gives pyhsics properties to the player func _physics_process(delta): player_movement(delta) # Player movement with arrow keys func player_movement(delta): + + # smoother player movement + input = get_input() + + # no input by the player + if input == Vector2.ZERO: + if velocity.length() > (friction * delta): + # slowly decreases speed when the player sopts moving + velocity -= velocity.normalized() * (friction * delta) + else: # Player stops + velocity = Vector2.ZERO + + else: # input by the player + velocity += (input * acceleration * delta) + velocity = velocity.limit_length(maxSpeed) + # Movement to the right when pressing the right arrow key if Input.is_action_pressed("ui_right"): current_direcition = "right" play_animation(1) - velocity.x = speed - velocity.y = 0 + # Movement to the left when pressing the left arrow key elif Input.is_action_pressed("ui_left"): current_direcition = "left" play_animation(1) - velocity.x = -speed - velocity.y = 0 + # Move up when pressing the up arrow key elif Input.is_action_pressed("ui_down"): current_direcition = "down" play_animation(1) - velocity.x = 0 - velocity.y = speed + # Move down when pressing the down arrow key elif Input.is_action_pressed("ui_up"): current_direcition = "up" play_animation(1) - velocity.x = 0 - velocity.y = -speed + # when now key is pressed (idle mode) else: play_animation(0) - velocity.x = 0 - velocity.y = 0 - + # built in - collision between player and ground move_and_slide() @@ -65,7 +86,7 @@ func play_animation(movement): animation.play("running_left") else: animation.play("idle_left") - + # player is walking up if direction == "up": #animation.flip_h = false