Compare commits

..

24 Commits
0.0003 ... main

Author SHA1 Message Date
e8e0e7af57 Add recommended files to ignore list 2025-02-20 20:41:22 -08:00
807a2924f7 remove export_presets file as recommended by godot 2025-02-20 20:38:14 -08:00
9ef4d1748b Chests now spawn health pickups. Health pickups drop from the sky when spawned until they hit the ground. 2024-07-22 17:38:06 -07:00
2ff08298b7 Fixup for states for player and spider animation. Cleanup useless movement state comments. 2024-07-21 08:55:14 -07:00
48f3e631e6 Spider now tracks player and delays jump. Exit animation modifier works too! 2024-07-14 18:59:32 -07:00
8106474b39 spider stuff. 2024-07-14 10:16:32 -07:00
3e454f5785 Start add of spider enemy. 2024-07-13 12:22:48 -07:00
6aed49924e Platform moves and pushes player. I don't know if it's right but it appears to be working. 2024-07-12 15:28:48 -07:00
7a2842b5ee Platform actor works when not being stood on. 2024-07-12 10:49:54 -07:00
c21818caf3 Start to add platform actor, removed shared collision shape dependency among all actors. Whoops. 2024-07-12 10:07:53 -07:00
592c8dffb1 Ladders! ...janky ones. 2024-07-11 22:23:55 -07:00
6f8a13c8bb Starting to learn to climb ladders. 2024-07-07 18:21:43 -07:00
3f19a92db6 Wind/Conveyor belt physics state modifier implemented. 2024-07-07 17:36:27 -07:00
4125e9351c Momentum can traverse to jump now! Sortof. 2024-07-06 00:53:19 -07:00
761fe8d66c Finally something close to what I'm looking for! 2024-07-05 23:58:30 -07:00
44a32e2e47 Getting there again. Maybe it'll work this time. 2024-07-05 21:51:46 -07:00
195b8f064f Never gonna work is it? 2024-07-05 12:14:01 -07:00
020cae1caf Closer than ever to getting momentum working. 2024-07-04 17:37:23 -07:00
98c92dbeaf Fixup for motion and momentum. 2024-07-04 12:53:07 -07:00
402ce4456f Revert changes to state_animated_actor 2024-07-04 11:33:51 -07:00
0af4a19828 Momentum tinkering. Will probably pull back from previous commits. 2024-07-04 09:57:23 -07:00
20c5240dc2 Trying to get momentum working 2024-07-02 22:41:53 -07:00
7e03daa236 Ice, Flow, nowhere to go. 2024-06-30 14:03:15 -07:00
f35ab3703b Level physics state modifier system added. Now just need to apply it to the actors. 2024-06-30 10:59:43 -07:00
45 changed files with 1206 additions and 546 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
.godot/
.import/
.mono/
*.translation
export_presets.cfg
addons/
android/
build/

View File

@ -13,9 +13,6 @@
[node name="Main" type="Node2D"]
[node name="Level" parent="." instance=ExtResource( 1 )]
__meta__ = {
"_edit_lock_": true
}
[node name="Player" parent="." instance=ExtResource( 14 )]
position = Vector2( 859, 236 )

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 117 KiB

BIN
assets/Spider1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

35
assets/Spider1.png.import Normal file
View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Spider1.png-85cc52177a93c8766bb76a39a26b9d70.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Spider1.png"
dest_files=[ "res://.import/Spider1.png-85cc52177a93c8766bb76a39a26b9d70.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=true
svg/scale=1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,4 +1,4 @@
[gd_resource type="TileSet" load_steps=13 format=2]
[gd_resource type="TileSet" load_steps=15 format=2]
[ext_resource path="res://assets/Tiles/Assets/Assets.png" type="Texture" id=1]
@ -35,6 +35,12 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=12]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=13]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=14]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[resource]
0/name = "Assets.png 0"
0/texture = ExtResource( 1 )
@ -122,5 +128,17 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
"one_way_margin": 1.0,
"shape": SubResource( 12 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 8, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 13 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 14 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0

BIN
assets/elevator.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/elevator.png"
dest_files=[ "res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.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=true
svg/scale=1.0

View File

@ -1,273 +0,0 @@
[preset.0]
name="Android"
platform="Android"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
script_export_mode=1
script_encryption_key=""
[preset.0.options]
custom_template/debug=""
custom_template/release=""
custom_build/use_custom_build=false
custom_build/export_format=0
custom_build/min_sdk=""
custom_build/target_sdk=""
architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
keystore/debug=""
keystore/debug_user=""
keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
one_click_deploy/clear_previous_install=false
version/code=1
version/name="1.0"
package/unique_name="org.godotengine.$genname"
package/name=""
package/signed=true
package/classify_as_game=true
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
graphics/opengl_debug=false
xr_features/xr_mode=0
xr_features/hand_tracking=0
xr_features/hand_tracking_frequency=0
xr_features/passthrough=0
screen/immersive_mode=true
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
user_data_backup/allow=false
command_line/extra_args=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
permissions/custom_permissions=PoolStringArray( )
permissions/access_checkin_properties=false
permissions/access_coarse_location=false
permissions/access_fine_location=false
permissions/access_location_extra_commands=false
permissions/access_mock_location=false
permissions/access_network_state=false
permissions/access_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
permissions/add_voicemail=false
permissions/authenticate_accounts=false
permissions/battery_stats=false
permissions/bind_accessibility_service=false
permissions/bind_appwidget=false
permissions/bind_device_admin=false
permissions/bind_input_method=false
permissions/bind_nfc_service=false
permissions/bind_notification_listener_service=false
permissions/bind_print_service=false
permissions/bind_remoteviews=false
permissions/bind_text_service=false
permissions/bind_vpn_service=false
permissions/bind_wallpaper=false
permissions/bluetooth=false
permissions/bluetooth_admin=false
permissions/bluetooth_privileged=false
permissions/brick=false
permissions/broadcast_package_removed=false
permissions/broadcast_sms=false
permissions/broadcast_sticky=false
permissions/broadcast_wap_push=false
permissions/call_phone=false
permissions/call_privileged=false
permissions/camera=false
permissions/capture_audio_output=false
permissions/capture_secure_video_output=false
permissions/capture_video_output=false
permissions/change_component_enabled_state=false
permissions/change_configuration=false
permissions/change_network_state=false
permissions/change_wifi_multicast_state=false
permissions/change_wifi_state=false
permissions/clear_app_cache=false
permissions/clear_app_user_data=false
permissions/control_location_updates=false
permissions/delete_cache_files=false
permissions/delete_packages=false
permissions/device_power=false
permissions/diagnostic=false
permissions/disable_keyguard=false
permissions/dump=false
permissions/expand_status_bar=false
permissions/factory_test=false
permissions/flashlight=false
permissions/force_back=false
permissions/get_accounts=false
permissions/get_package_size=false
permissions/get_tasks=false
permissions/get_top_activity_info=false
permissions/global_search=false
permissions/hardware_test=false
permissions/inject_events=false
permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=false
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
permissions/manage_app_tokens=false
permissions/manage_documents=false
permissions/manage_external_storage=false
permissions/master_clear=false
permissions/media_content_control=false
permissions/modify_audio_settings=false
permissions/modify_phone_state=false
permissions/mount_format_filesystems=false
permissions/mount_unmount_filesystems=false
permissions/nfc=false
permissions/persistent_activity=false
permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_phone_state=false
permissions/read_profile=false
permissions/read_sms=false
permissions/read_social_stream=false
permissions/read_sync_settings=false
permissions/read_sync_stats=false
permissions/read_user_dictionary=false
permissions/reboot=false
permissions/receive_boot_completed=false
permissions/receive_mms=false
permissions/receive_sms=false
permissions/receive_wap_push=false
permissions/record_audio=false
permissions/reorder_tasks=false
permissions/restart_packages=false
permissions/send_respond_via_message=false
permissions/send_sms=false
permissions/set_activity_watcher=false
permissions/set_alarm=false
permissions/set_always_finish=false
permissions/set_animation_scale=false
permissions/set_debug_app=false
permissions/set_orientation=false
permissions/set_pointer_speed=false
permissions/set_preferred_applications=false
permissions/set_process_limit=false
permissions/set_time=false
permissions/set_time_zone=false
permissions/set_wallpaper=false
permissions/set_wallpaper_hints=false
permissions/signal_persistent_processes=false
permissions/status_bar=false
permissions/subscribed_feeds_read=false
permissions/subscribed_feeds_write=false
permissions/system_alert_window=false
permissions/transmit_ir=false
permissions/uninstall_shortcut=false
permissions/update_device_stats=false
permissions/use_credentials=false
permissions/use_sip=false
permissions/vibrate=false
permissions/wake_lock=false
permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
permissions/write_secure_settings=false
permissions/write_settings=false
permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false
[preset.1]
name="Linux/X11"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/linux/MegaMoves.x86_64"
script_export_mode=1
script_encryption_key=""
[preset.1.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
[preset.2]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="build/windows/MegaMoves.exe"
script_export_mode=1
script_encryption_key=""
[preset.2.options]
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=false
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/modify_resources=true
application/icon=""
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

View File

@ -49,6 +49,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/state_modifier_properties.gd"
}, {
"base": "Node2D",
"class": "Modifier_Receiver",
"language": "GDScript",
"path": "res://src/components/Modifier_Receiver.gd"
}, {
"base": "Node",
"class": "MovementComponent",
"language": "GDScript",
@ -93,6 +98,7 @@ _global_script_class_icons={
"Interactable_Receiver": "",
"Level": "",
"ModifierProperties": "",
"Modifier_Receiver": "",
"MovementComponent": "",
"State": "",
"StateAnimatedActor": "",
@ -215,6 +221,7 @@ dash_1={
2d_physics/layer_6="EnemyHurtbox"
2d_physics/layer_7="PlayerHitbox"
2d_physics/layer_8="EnemyHitbox"
2d_physics/layer_11="Climbable"
[mono]

View File

@ -0,0 +1,112 @@
[gd_scene load_steps=14 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/components/Hitbox_Component.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/Actors/Enemies/Spider/spider_movement_component.gd" type="Script" id=3]
[ext_resource path="res://src/Actors/Enemies/Spider/states/move.gd" type="Script" id=4]
[ext_resource path="res://src/Actors/Enemies/Spider/states/idle.gd" type="Script" id=5]
[sub_resource type="StreamTexture" id=1]
load_path = "res://.import/Spider1.png-85cc52177a93c8766bb76a39a26b9d70.stex"
[sub_resource type="AtlasTexture" id=2]
atlas = SubResource( 1 )
region = Rect2( 0, 26, 20, 26 )
[sub_resource type="AtlasTexture" id=3]
atlas = SubResource( 1 )
region = Rect2( 0, 0, 20, 26 )
[sub_resource type="AtlasTexture" id=4]
atlas = SubResource( 1 )
region = Rect2( 20, 0, 20, 26 )
[sub_resource type="AtlasTexture" id=5]
atlas = SubResource( 1 )
region = Rect2( 40, 0, 20, 26 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 2 ) ],
"loop": false,
"name": "die",
"speed": 10.0
}, {
"frames": [ SubResource( 3 ) ],
"loop": false,
"name": "idle",
"speed": 10.0
}, {
"frames": [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": false,
"name": "jump",
"speed": 10.0
}, {
"frames": [ SubResource( 5 ), SubResource( 4 ), SubResource( 3 ) ],
"loop": false,
"name": "land",
"speed": 10.0
} ]
[sub_resource type="RectangleShape2D" id=7]
extents = Vector2( 10, 12 )
[sub_resource type="CircleShape2D" id=8]
[node name="Spider" instance=ExtResource( 1 )]
actor_type = "Enemy"
[node name="AnimatedSprite" parent="." index="0"]
frames = SubResource( 6 )
animation = "jump"
frame = 2
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets",
"o_name": "",
"only_visible": true,
"op_exp": false,
"slice": "",
"source": "D:/Sync/Assets/Library/Spider1.ase"
}
}
[node name="movement_component" parent="." index="1"]
script = ExtResource( 3 )
[node name="movement_state_machine" parent="." index="2"]
debug_state_machine = true
[node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 5 )
timeout_seconds = 0.5
animation_sequence = [ "idle" ]
[node name="fall" parent="movement_state_machine" index="1"]
animation_sequence = [ "land" ]
[node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 4 )
animation_sequence = [ "jump" ]
jump_force = 200.0
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
position = Vector2( 0, -1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="5"]
position = Vector2( 0, -2 )
shape = SubResource( 7 )
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="." index="6"]
position = Vector2( 0, 1 )
[node name="Hitbox_Component" parent="." index="7" instance=ExtResource( 2 )]
damage_amount = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="0"]
position = Vector2( 0, -1 )
shape = SubResource( 8 )
[connection signal="screen_entered" from="VisibilityNotifier2D" to="movement_component" method="_on_VisibilityNotifier2D_screen_entered"]

View File

@ -0,0 +1,67 @@
extends MovementComponent
## Constants available to you
# UP = -1.0
# DOWN = 1.0
# LEFT = -1.0
# RIGHT = 1.0
# Avalable functions to call
# A Series of helper functions
# go_up():
# go_down():
# go_left():
# go_right():
# stop():
var entered_screen = false
var jump_var = false
var last_player_direction: float
func process(delta):
if entered_screen:
if current_movement_state == "idle":
# Only check the player direction in idle because we don't want to track the player during jump
if owner is Actor:
last_player_direction = sign((owner.global_position.direction_to(PlayerInfo.player_position)).x)
jump_var = true
desired_movement_vector.x = last_player_direction
else:
desired_movement_vector.x = last_player_direction
jump_var = false
return
func wants_jump() -> bool:
return jump_var
## Other needed variables
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state
# current_movement_state:String - The name of the current State
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
# velocity: Vector2 - Current velocity, you can change this at will but state may modify it
# Declare any other member variables here. Examples:
# var a = 2
# var b = "text"
# Called every frame. 'delta' is the elapsed time since the previous frame.
# you do not normally need to define this for Actor
#func process(delta):
# pass
# For Enemy and NPC Actors:
# should be called on the frame process.
# For Player Actors:
# Should be called on the input process
func _on_VisibilityNotifier2D_screen_entered():
entered_screen = true
print("Spider wants to play!!!")

View File

@ -0,0 +1,26 @@
extends "res://src/templates/Actor/states/idle.gd"
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
move_component.velocity.x = 0
state_timeout.start()
func process_physics(delta: float) -> State:
# parent.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
# parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
if state_timeout.time_left == 0:
move_actor_as_desired(delta)
if move_component.velocity.x != 0.0:
return move_state
if !parent.is_on_floor():
return fall_state
return null

View File

@ -0,0 +1,36 @@
extends "res://src/templates/Actor/states/move.gd"
export var jump_force: float = 200.0
var landing_modifier: StateModifier
func _ready():
landing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
landing_modifier.ready( "landing", "land" , landing_modifier.TYPE.EXIT_ANIMATION)
#print("ready! MOD")
func enter() -> void:
.enter()
# Apply initial jump velocity on state enter
move_component.velocity.y = -jump_force
func process_physics(delta: float) -> State:
# if move_component.velocity.y > 0:
# return fall_state
# First allow horizontal movement.
move_actor_as_desired(delta)
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
idle_state.modifier = landing_modifier
return idle_state
return null

View File

@ -0,0 +1,79 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/Actors/Platform/PlatformVMove/states/move.gd" type="Script" id=2]
[ext_resource path="res://src/Actors/Platform/PlatformVMove/states/idle.gd" type="Script" id=3]
[sub_resource type="StreamTexture" id=1]
load_path = "res://.import/elevator.png-acbb9d6b280a7beb809eaa023b52f90b.stex"
[sub_resource type="AtlasTexture" id=2]
atlas = SubResource( 1 )
region = Rect2( 0, 0, 86, 44 )
[sub_resource type="AtlasTexture" id=3]
atlas = SubResource( 1 )
region = Rect2( 86, 0, 86, 44 )
[sub_resource type="AtlasTexture" id=4]
atlas = SubResource( 1 )
region = Rect2( 172, 0, 86, 44 )
[sub_resource type="AtlasTexture" id=5]
atlas = SubResource( 1 )
region = Rect2( 0, 44, 86, 44 )
[sub_resource type="AtlasTexture" id=6]
atlas = SubResource( 1 )
region = Rect2( 86, 44, 86, 44 )
[sub_resource type="AtlasTexture" id=7]
atlas = SubResource( 1 )
region = Rect2( 172, 44, 86, 44 )
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=9]
extents = Vector2( 38, 15.5 )
[node name="PlatformVMove" instance=ExtResource( 1 )]
collision_layer = 0
collision_mask = 2
motion/sync_to_physics = true
actor_type = "Object"
[node name="AnimatedSprite" parent="." index="0"]
frames = SubResource( 8 )
frame = 1
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
"o_ex_p": "",
"o_folder": "res://assets",
"o_name": "",
"only_visible": true,
"op_exp": false,
"slice": "",
"source": "D:/Sync/Assets/Library/elevator.ase"
}
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
position = Vector2( 0, -3.5 )
shape = SubResource( 9 )
[node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 3 )
timeout_seconds = 2.0
move_speed = 0.0
[node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 2 )
timeout_seconds = 1.0
move_speed = 30.0

View File

@ -0,0 +1,26 @@
extends StateAnimatedActor
export (NodePath) var move_node
onready var move_state: State = get_node(move_node)
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
if debug_state:
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
state_timeout.start()
func process_frame(delta):
if state_timeout.time_left == 0:
return move_state
return null
func process_physics(delta: float) -> State:
# parent.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# parent.velocity.x = move_component.desired_movement_vector.x * move_speed
# parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
return null

View File

@ -0,0 +1,55 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: State = get_node(idle_node)
var flip_flop:bool = false
var recoil_velocity = Vector2.ZERO
var max_recoil:float = 8.0
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
if debug_state:
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
state_timeout.start()
func process_physics(delta: float) -> State:
if state_timeout.time_left == 0:
if flip_flop:
move_component.velocity.y = move_speed
flip_flop = false
return idle_state
else:
move_component.velocity.y = move_speed * - 1
flip_flop = true
return idle_state
#move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
#var collision = parent.move_and_collide(move_component.velocity * delta, true, true, true)
# var collision = parent.move_and_collide(Vector2.UP, true, true, true)
#
# if collision and recoil_velocity == Vector2.ZERO:
# print("Get off me!")
# recoil_velocity.y += max_recoil * delta
# if collision and recoil_velocity == Vector2.ZERO:
# print("Get off me!")
# recoil_velocity.y += max_recoil * delta
# else:
# if recoil_velocity.y < max_recoil:
# recoil_velocity.y -= max_recoil * delta
# else:
# recoil_velocity.y += max_recoil * delta
# if recoil_velocity.y < 0:
# recoil_velocity = Vector2.ZERO
#parent.global_translate(move_component.velocity * delta)
parent.position += (move_component.velocity + recoil_velocity) * delta
return null

View File

@ -7,8 +7,16 @@ extends Interactable
onready var sprite: Sprite = $Sprite
const pickup = preload("res://src/Interactables/HealthPickup.tscn")
var opened := false
func trigger_interaction():
# This is something that should maybe be extended for every differant interactible.
# They could inherit from this base class and implement this function.
sprite.frame = 1
if !opened:
var chest_item = pickup.instance()
chest_item.global_position = global_position + Vector2(0,-50)
owner.add_child(chest_item)
opened = true

View File

@ -4,6 +4,22 @@ extends Interactable
onready var health_icon: AnimatedSprite = $AnimatedSprite
onready var drop_raycast: RayCast2D = $RayCast2D
func _ready():
#gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
gravity = 90
# Doesn't get enabled until it drops
monitoring = false
func _physics_process(delta):
if drop_raycast.is_colliding() == false:
var velocity = Vector2(0,0)
position.y += delta * gravity
else:
monitoring = true
func trigger_interaction():
# This is something that should maybe be extended for every differant interactible.
# They could inherit from this base class and implement this function.

View File

@ -8,11 +8,18 @@
radius = 6.0
[node name="HealthPickup" instance=ExtResource( 2 )]
monitoring = false
script = ExtResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
frames = ExtResource( 3 )
frame = 2
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
shape = SubResource( 1 )
[node name="RayCast2D" type="RayCast2D" parent="." index="2"]
enabled = true
cast_to = Vector2( 0, 8 )
collision_mask = 3

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=20 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/Level.gd" type="Script" id=1]
[ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2]
[ext_resource path="res://assets/High Forest/Background/Background.png" type="Texture" id=3]
[ext_resource path="res://assets/High Forest/Assets/Tiles.png" type="Texture" id=4]
@ -219,6 +219,7 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
4/z_index = 0
[node name="Level3" type="Node2D"]
script = ExtResource( 1 )
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
scroll_base_scale = Vector2( 0.4, 1 )
@ -283,12 +284,8 @@ __meta__ = {
"_edit_lock_": true
}
[node name="ActorTemplate" parent="." instance=ExtResource( 1 )]
position = Vector2( 221, 135 )
__meta__ = {
"_edit_lock_": true
}
actor_type = "NPC"
[node name="EnemyC3" parent="." instance=ExtResource( 7 )]
position = Vector2( 796, 89 )
[node name="PlayerStart" type="Position2D" parent="."]
position = Vector2( 89, 103 )

View File

@ -4,7 +4,7 @@ extends KinematicBody2D
#var velocity = Vector2(0,0)
#var direction = Vector2(-1,0)
export(String, "Player", "Enemy", "NPC") var actor_type
export(String, "Player", "Enemy", "NPC", "Object") var actor_type
#export var sprite_facing_right: bool = true
export(Array, Resource) var SoundEffects
export var debug_actor: bool = false

View File

@ -0,0 +1,52 @@
extends Area2D
var modifier_type = 0
export var modifier_name :String = ''
var animation_name: String = '' # Not using this one
var timeout_seconds: float = 0.0 # Not doing timeout based ones yet either.
export var directional_modifier: bool = false
export var move_speed: float = 0.0
export var move_acceleration: float = 0.0
export var move_speed_modifier: float = 0.0
export var move_modifier_move_acceleration: float = 0.0
export var jerk_factor: float = 0
export var gravity_modifier: int = 0
#var state_timeout: Timer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var modifier :StateModifier
#var modifier_properties: ModifierProperties
# Called when the node enters the scene tree for the first time.
func _ready():
modifier = StateModifier.new()
modifier.ready( modifier_name, animation_name , modifier.TYPE.NONE, timeout_seconds)
modifier.modifier_properties = ModifierProperties.new( move_speed,
gravity_modifier,
move_acceleration,
move_speed_modifier,
move_modifier_move_acceleration,
jerk_factor)
print("Debug Direction property shy are you stopid?! ", directional_modifier)
modifier.modifier_properties.directional_modifier = directional_modifier
func _on_Modifier_Component_body_entered(body):
var colliding_node = body
if colliding_node.has_node("Modifier_Receiver"):
colliding_node.get_node("Modifier_Receiver").register_modifier(modifier)
func _on_Modifier_Component_body_exited(body):
var colliding_node = body
if colliding_node.has_node("Modifier_Receiver"):
colliding_node.get_node("Modifier_Receiver").remove_modifier(modifier)

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/components/Modifier_Component.gd" type="Script" id=1]
[node name="Modifier_Component" type="Area2D"]
script = ExtResource( 1 )
[connection signal="body_entered" from="." to="." method="_on_Modifier_Component_body_entered"]
[connection signal="body_exited" from="." to="." method="_on_Modifier_Component_body_exited"]

View File

@ -0,0 +1,53 @@
class_name Modifier_Receiver
extends Node2D
# This may be stupid but we're going to have two kinds of callbacks here.
# It's going to be up to the parent/actor/kinematicbody2d/whatever to know
# what conditions have to be met before being able to call that interactible's
# function.
# This is a nice and generic interface that I might be able to use for
# things like opening doors in a level, opening chests/flipping switches etc.
# This node can keep an array of various interactibles within a level
# and provide several helper functions for managing them perhaps.
export(String) var modifier_parent_callback = ""
export var debug_receiver :bool = false
var call_function: FuncRef
#var interactable_function_callables = []
var modifier_collection = []
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
##NOTE:
## Call function should be implemented as two parameters, one expecting a modifier
## and the other expecting a boolean as to whether its being added
# Called when the node enters the scene tree for the first time.
func _ready():
if modifier_parent_callback:
call_function = funcref(owner, modifier_parent_callback)
else:
print("Warning: No modifier receiver function defined on ", owner.name)
# Switching to a new model that starts with Hitbox
func register_modifier(modifier: StateModifier):
if modifier_collection.has(modifier) == false:
print("New Modifier Registered " + modifier.name)
modifier_collection.append(modifier)
if call_function.is_valid():
call_function.call_func(modifier, true)
func remove_modifier(modifier):
print("Modifier Removal " + modifier.name)
if modifier_collection.has(modifier):
var modifier_index = modifier_collection.rfind(modifier)
if modifier_index != -1:
modifier_collection.remove(modifier_index)
if call_function.is_valid():
call_function.call_func(modifier, false)

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/components/Modifier_Receiver.gd" type="Script" id=1]
[node name="Modifier_Receiver" type="Node2D"]
script = ExtResource( 1 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=33 format=2]
[gd_scene load_steps=34 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/enemyC/enemyC_movement_component.gd" type="Script" id=2]
@ -122,6 +122,9 @@ extents = Vector2( 9, 3.5 )
[sub_resource type="CapsuleShape2D" id=24]
height = 10.0
[sub_resource type="RectangleShape2D" id=25]
extents = Vector2( 10.5, 17.5 )
[node name="EnemyC" instance=ExtResource( 1 )]
script = ExtResource( 6 )
actor_type = "Enemy"
@ -130,7 +133,7 @@ actor_type = "Enemy"
position = Vector2( 11, -7 )
frames = SubResource( 20 )
animation = "idle"
frame = 1
frame = 2
__meta__ = {
"_aseprite_wizard_config_": {
"layer": "",
@ -144,10 +147,7 @@ __meta__ = {
}
}
[node name="CollisionShape2D" parent="." index="1"]
position = Vector2( -0.5, -2 )
[node name="movement_component" parent="." index="2"]
[node name="movement_component" parent="." index="1"]
script = ExtResource( 2 )
[node name="IdleTimeout" type="Timer" parent="movement_component" index="0"]
@ -189,14 +189,14 @@ timeout_seconds = 0.5
move_speed = -5.0
animation_sequence = [ "death" ]
[node name="Hurtbox_Component" parent="." index="4"]
[node name="Hurtbox_Component" parent="." index="3"]
hurtbox_entered_function = "enemyHit"
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
position = Vector2( -1, -2 )
shape = SubResource( 22 )
[node name="EdgeDetection" type="RayCast2D" parent="." index="6"]
[node name="EdgeDetection" type="RayCast2D" parent="." index="5"]
modulate = Color( 0.054902, 1, 0, 1 )
show_behind_parent = true
position = Vector2( 15, 3 )
@ -204,12 +204,12 @@ enabled = true
cast_to = Vector2( 0, 17 )
collide_with_areas = true
[node name="PlayerDetection" type="RayCast2D" parent="." index="7"]
[node name="PlayerDetection" type="RayCast2D" parent="." index="6"]
enabled = true
cast_to = Vector2( 21, 0 )
collision_mask = 2
[node name="Hitbox_Component" parent="." index="8" instance=ExtResource( 4 )]
[node name="Hitbox_Component" parent="." index="7" instance=ExtResource( 4 )]
damage_amount = 10
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="0"]
@ -218,16 +218,20 @@ position = Vector2( 18, -8.5 )
shape = SubResource( 23 )
disabled = true
[node name="GenericSender" parent="." index="9" instance=ExtResource( 5 )]
[node name="GenericSender" parent="." index="8" instance=ExtResource( 5 )]
receiver_node_name = "GenericReceiver"
[node name="CollisionShape2D" type="CollisionShape2D" parent="GenericSender" index="0"]
position = Vector2( 48, 0 )
shape = SubResource( 24 )
[node name="Health_Component" parent="." index="10" instance=ExtResource( 7 )]
[node name="Health_Component" parent="." index="9" instance=ExtResource( 7 )]
max_health = 20
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="10"]
position = Vector2( -0.5, -1.5 )
shape = SubResource( 25 )
[connection signal="frame_reached" from="movement_state_machine/attack" to="." method="_on_attack_frame_reached"]
[connection signal="state_exited" from="movement_state_machine/attack" to="." method="_on_attack_state_exited"]
[connection signal="health_depleted" from="Health_Component" to="." method="_on_Health_Component_health_depleted"]

View File

@ -17,6 +17,11 @@ var current_movement_state:String
# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
var velocity = Vector2(0,0)
var momentum = Vector2(0,0)
var acceleration = Vector2(0,0)
var sim_velocity = Vector2(0,0)
#Can't use floats here, switched to constants.
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
@ -69,3 +74,9 @@ func wants_dash() -> bool:
func wants_roll() -> bool:
return false
func wants_climb() -> bool:
return false
func get_climb_shape_location() -> Vector2:
return Vector2(-1,-1)

View File

@ -27,6 +27,17 @@ func hit_Receiver(damage):
yield( get_tree().create_timer(2 + $movement_state_machine/hurt.timeout_seconds), "timeout")
$Hurtbox_Component.set_hurtbox(true)
func receive_modifier(incomming_modifier :StateModifier, is_adding_modifier_operation: bool):
#var mod :StateModifier
if is_adding_modifier_operation:
print("Player Received modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = incomming_modifier
else:
print("Player Removed modifier:", incomming_modifier.name)
if movement_state_machine.current_state is StateAnimatedActor:
movement_state_machine.current_state.physics_modifier = null
func touch_the_thing(the_thing: Interactable) -> bool:
print("You see! a THING...", the_thing.name)
if the_thing is HealthPickup:

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=126 format=2]
[gd_scene load_steps=127 format=2]
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/playerD/movement_component.gd" type="Script" id=2]
@ -8,6 +8,7 @@
[ext_resource path="res://src/playerD/states/fall.gd" type="Script" id=6]
[ext_resource path="res://src/components/Health_Component.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/playerD/states/jump.gd" type="Script" id=8]
[ext_resource path="res://src/components/Modifier_Receiver.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/playerD/states/attack.gd" type="Script" id=10]
[ext_resource path="res://src/playerD/states/dash.gd" type="Script" id=11]
[ext_resource path="res://src/playerD/states/hurt.gd" type="Script" id=12]
@ -15,37 +16,41 @@
[ext_resource path="res://src/playerD/states/roll.gd" type="Script" id=14]
[ext_resource path="res://src/playerD/states/die.gd" type="Script" id=15]
[ext_resource path="res://src/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16]
[ext_resource path="res://src/playerD/states/climb.gd" type="Script" id=17]
[sub_resource type="RectangleShape2D" id=197]
extents = Vector2( 13, 18.5 )
[sub_resource type="StreamTexture" id=90]
load_path = "res://.import/Mega.png-93dfe0790902b932f7b46f7b23c5d4e7.stex"
[sub_resource type="AtlasTexture" id=91]
atlas = SubResource( 90 )
region = Rect2( 1440, 960, 240, 160 )
region = Rect2( 1680, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=92]
atlas = SubResource( 90 )
region = Rect2( 1680, 960, 240, 160 )
region = Rect2( 1920, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=93]
atlas = SubResource( 90 )
region = Rect2( 1920, 960, 240, 160 )
region = Rect2( 2160, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=94]
atlas = SubResource( 90 )
region = Rect2( 2160, 960, 240, 160 )
region = Rect2( 2400, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=95]
atlas = SubResource( 90 )
region = Rect2( 2400, 960, 240, 160 )
region = Rect2( 0, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=96]
atlas = SubResource( 90 )
region = Rect2( 0, 1120, 240, 160 )
region = Rect2( 240, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=97]
atlas = SubResource( 90 )
region = Rect2( 240, 1120, 240, 160 )
region = Rect2( 1440, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=98]
atlas = SubResource( 90 )
@ -53,31 +58,31 @@ region = Rect2( 480, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=99]
atlas = SubResource( 90 )
region = Rect2( 720, 1120, 240, 160 )
region = Rect2( 480, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=100]
atlas = SubResource( 90 )
region = Rect2( 960, 1120, 240, 160 )
region = Rect2( 720, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=101]
atlas = SubResource( 90 )
region = Rect2( 480, 160, 240, 160 )
region = Rect2( 960, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=102]
atlas = SubResource( 90 )
region = Rect2( 720, 160, 240, 160 )
region = Rect2( 1200, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=103]
atlas = SubResource( 90 )
region = Rect2( 960, 160, 240, 160 )
region = Rect2( 1440, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=104]
atlas = SubResource( 90 )
region = Rect2( 1200, 160, 240, 160 )
region = Rect2( 240, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=105]
atlas = SubResource( 90 )
region = Rect2( 1440, 160, 240, 160 )
region = Rect2( 480, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=106]
atlas = SubResource( 90 )
@ -117,43 +122,43 @@ region = Rect2( 0, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=115]
atlas = SubResource( 90 )
region = Rect2( 240, 1600, 240, 160 )
region = Rect2( 960, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=116]
atlas = SubResource( 90 )
region = Rect2( 480, 1600, 240, 160 )
region = Rect2( 1200, 960, 240, 160 )
[sub_resource type="AtlasTexture" id=117]
atlas = SubResource( 90 )
region = Rect2( 960, 960, 240, 160 )
region = Rect2( 1200, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=118]
atlas = SubResource( 90 )
region = Rect2( 1200, 960, 240, 160 )
region = Rect2( 0, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=119]
atlas = SubResource( 90 )
region = Rect2( 1200, 0, 240, 160 )
region = Rect2( 1440, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=120]
atlas = SubResource( 90 )
region = Rect2( 0, 0, 240, 160 )
region = Rect2( 1680, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=121]
atlas = SubResource( 90 )
region = Rect2( 1440, 0, 240, 160 )
region = Rect2( 1920, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=122]
atlas = SubResource( 90 )
region = Rect2( 1680, 0, 240, 160 )
region = Rect2( 2160, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=123]
atlas = SubResource( 90 )
region = Rect2( 1920, 0, 240, 160 )
region = Rect2( 240, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=124]
atlas = SubResource( 90 )
region = Rect2( 2160, 0, 240, 160 )
region = Rect2( 480, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=125]
atlas = SubResource( 90 )
@ -161,187 +166,187 @@ region = Rect2( 720, 1600, 240, 160 )
[sub_resource type="AtlasTexture" id=126]
atlas = SubResource( 90 )
region = Rect2( 960, 1600, 240, 160 )
region = Rect2( 240, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=127]
atlas = SubResource( 90 )
region = Rect2( 1200, 1600, 240, 160 )
region = Rect2( 1680, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=128]
atlas = SubResource( 90 )
region = Rect2( 240, 160, 240, 160 )
region = Rect2( 1920, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=129]
atlas = SubResource( 90 )
region = Rect2( 1680, 160, 240, 160 )
region = Rect2( 2160, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=130]
atlas = SubResource( 90 )
region = Rect2( 1920, 160, 240, 160 )
region = Rect2( 2400, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=131]
atlas = SubResource( 90 )
region = Rect2( 2160, 160, 240, 160 )
region = Rect2( 0, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=132]
atlas = SubResource( 90 )
region = Rect2( 2400, 160, 240, 160 )
region = Rect2( 240, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=133]
atlas = SubResource( 90 )
region = Rect2( 0, 320, 240, 160 )
region = Rect2( 480, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=134]
atlas = SubResource( 90 )
region = Rect2( 240, 320, 240, 160 )
region = Rect2( 720, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=135]
atlas = SubResource( 90 )
region = Rect2( 480, 320, 240, 160 )
region = Rect2( 960, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=136]
atlas = SubResource( 90 )
region = Rect2( 720, 320, 240, 160 )
region = Rect2( 1200, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=137]
atlas = SubResource( 90 )
region = Rect2( 960, 320, 240, 160 )
region = Rect2( 1680, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=138]
atlas = SubResource( 90 )
region = Rect2( 1200, 320, 240, 160 )
region = Rect2( 1920, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=139]
atlas = SubResource( 90 )
region = Rect2( 1680, 640, 240, 160 )
region = Rect2( 2160, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=140]
atlas = SubResource( 90 )
region = Rect2( 1920, 640, 240, 160 )
region = Rect2( 2400, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=141]
atlas = SubResource( 90 )
region = Rect2( 2160, 640, 240, 160 )
region = Rect2( 0, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=142]
atlas = SubResource( 90 )
region = Rect2( 2400, 640, 240, 160 )
region = Rect2( 240, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=143]
atlas = SubResource( 90 )
region = Rect2( 0, 800, 240, 160 )
region = Rect2( 480, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=144]
atlas = SubResource( 90 )
region = Rect2( 240, 800, 240, 160 )
region = Rect2( 720, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=145]
atlas = SubResource( 90 )
region = Rect2( 480, 800, 240, 160 )
region = Rect2( 960, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=146]
atlas = SubResource( 90 )
region = Rect2( 720, 800, 240, 160 )
region = Rect2( 1200, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=147]
atlas = SubResource( 90 )
region = Rect2( 960, 800, 240, 160 )
region = Rect2( 1440, 800, 240, 160 )
[sub_resource type="AtlasTexture" id=148]
atlas = SubResource( 90 )
region = Rect2( 1200, 800, 240, 160 )
region = Rect2( 1920, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=149]
atlas = SubResource( 90 )
region = Rect2( 1440, 800, 240, 160 )
region = Rect2( 2160, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=150]
atlas = SubResource( 90 )
region = Rect2( 1920, 320, 240, 160 )
region = Rect2( 2400, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=151]
atlas = SubResource( 90 )
region = Rect2( 2160, 320, 240, 160 )
region = Rect2( 0, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=152]
atlas = SubResource( 90 )
region = Rect2( 2400, 320, 240, 160 )
region = Rect2( 240, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=153]
atlas = SubResource( 90 )
region = Rect2( 0, 480, 240, 160 )
region = Rect2( 480, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=154]
atlas = SubResource( 90 )
region = Rect2( 240, 480, 240, 160 )
region = Rect2( 720, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=155]
atlas = SubResource( 90 )
region = Rect2( 480, 480, 240, 160 )
region = Rect2( 960, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=156]
atlas = SubResource( 90 )
region = Rect2( 720, 480, 240, 160 )
region = Rect2( 1200, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=157]
atlas = SubResource( 90 )
region = Rect2( 960, 480, 240, 160 )
region = Rect2( 1440, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=158]
atlas = SubResource( 90 )
region = Rect2( 1200, 480, 240, 160 )
region = Rect2( 1920, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=159]
atlas = SubResource( 90 )
region = Rect2( 1440, 480, 240, 160 )
region = Rect2( 2160, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=160]
atlas = SubResource( 90 )
region = Rect2( 1920, 480, 240, 160 )
region = Rect2( 2400, 480, 240, 160 )
[sub_resource type="AtlasTexture" id=161]
atlas = SubResource( 90 )
region = Rect2( 2160, 480, 240, 160 )
region = Rect2( 0, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=162]
atlas = SubResource( 90 )
region = Rect2( 2400, 480, 240, 160 )
region = Rect2( 240, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=163]
atlas = SubResource( 90 )
region = Rect2( 0, 640, 240, 160 )
region = Rect2( 480, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=164]
atlas = SubResource( 90 )
region = Rect2( 240, 640, 240, 160 )
region = Rect2( 720, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=165]
atlas = SubResource( 90 )
region = Rect2( 480, 640, 240, 160 )
region = Rect2( 960, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=166]
atlas = SubResource( 90 )
region = Rect2( 720, 640, 240, 160 )
region = Rect2( 1200, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=167]
atlas = SubResource( 90 )
region = Rect2( 960, 640, 240, 160 )
region = Rect2( 1440, 640, 240, 160 )
[sub_resource type="AtlasTexture" id=168]
atlas = SubResource( 90 )
region = Rect2( 1200, 640, 240, 160 )
region = Rect2( 2400, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=169]
atlas = SubResource( 90 )
region = Rect2( 1440, 640, 240, 160 )
region = Rect2( 0, 160, 240, 160 )
[sub_resource type="AtlasTexture" id=170]
atlas = SubResource( 90 )
region = Rect2( 2400, 0, 240, 160 )
region = Rect2( 720, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=171]
atlas = SubResource( 90 )
region = Rect2( 0, 160, 240, 160 )
region = Rect2( 960, 1120, 240, 160 )
[sub_resource type="AtlasTexture" id=172]
atlas = SubResource( 90 )
@ -417,119 +422,121 @@ region = Rect2( 0, 1440, 240, 160 )
[sub_resource type="AtlasTexture" id=190]
atlas = SubResource( 90 )
region = Rect2( 240, 1440, 240, 160 )
region = Rect2( 240, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=191]
atlas = SubResource( 90 )
region = Rect2( 480, 1440, 240, 160 )
region = Rect2( 480, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=192]
atlas = SubResource( 90 )
region = Rect2( 240, 0, 240, 160 )
region = Rect2( 720, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=193]
atlas = SubResource( 90 )
region = Rect2( 480, 0, 240, 160 )
region = Rect2( 960, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=194]
atlas = SubResource( 90 )
region = Rect2( 720, 0, 240, 160 )
region = Rect2( 1680, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=195]
atlas = SubResource( 90 )
region = Rect2( 960, 0, 240, 160 )
[sub_resource type="AtlasTexture" id=196]
atlas = SubResource( 90 )
region = Rect2( 1680, 320, 240, 160 )
[sub_resource type="AtlasTexture" id=197]
atlas = SubResource( 90 )
region = Rect2( 1680, 480, 240, 160 )
[sub_resource type="SpriteFrames" id=198]
[sub_resource type="SpriteFrames" id=196]
animations = [ {
"frames": [ SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ), SubResource( 97 ), SubResource( 98 ), SubResource( 99 ), SubResource( 100 ) ],
"frames": [ SubResource( 91 ), SubResource( 92 ), SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ) ],
"loop": true,
"name": "climb",
"speed": 10.0
}, {
"frames": [ SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 103 ), SubResource( 104 ), SubResource( 105 ) ],
"frames": [ SubResource( 97 ) ],
"loop": false,
"name": "climb_step",
"speed": 10.0
}, {
"frames": [ SubResource( 98 ) ],
"loop": false,
"name": "climb_upstep",
"speed": 10.0
}, {
"frames": [ SubResource( 99 ), SubResource( 99 ), SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 103 ), SubResource( 103 ) ],
"loop": false,
"name": "dash",
"speed": 10.0
}, {
"frames": [ SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 114 ), SubResource( 116 ) ],
"frames": [ SubResource( 104 ), SubResource( 105 ), SubResource( 106 ), SubResource( 107 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 112 ), SubResource( 114 ) ],
"loop": false,
"name": "die",
"speed": 10.0
}, {
"frames": [ SubResource( 117 ), SubResource( 118 ) ],
"frames": [ SubResource( 115 ), SubResource( 116 ) ],
"loop": true,
"name": "hurt",
"speed": 4.0
}, {
"frames": [ SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ), SubResource( 123 ), SubResource( 124 ) ],
"frames": [ SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ) ],
"loop": true,
"name": "idle",
"speed": 10.0
}, {
"frames": [ SubResource( 125 ), SubResource( 126 ), SubResource( 127 ) ],
"frames": [ SubResource( 123 ), SubResource( 124 ), SubResource( 125 ) ],
"loop": true,
"name": "idle_shield",
"speed": 10.0
}, {
"frames": [ SubResource( 128 ) ],
"loop": false,
"frames": [ SubResource( 126 ) ],
"loop": true,
"name": "idle_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 129 ), SubResource( 130 ), SubResource( 131 ), SubResource( 132 ), SubResource( 130 ), SubResource( 133 ), SubResource( 134 ), SubResource( 135 ) ],
"frames": [ SubResource( 127 ), SubResource( 128 ), SubResource( 129 ), SubResource( 130 ), SubResource( 128 ), SubResource( 131 ), SubResource( 132 ), SubResource( 133 ) ],
"loop": false,
"name": "jump",
"speed": 10.0
}, {
"frames": [ SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 136 ), SubResource( 137 ), SubResource( 138 ) ],
"frames": [ SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 134 ), SubResource( 135 ), SubResource( 136 ) ],
"loop": false,
"name": "jump_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ), SubResource( 148 ), SubResource( 149 ) ],
"frames": [ SubResource( 137 ), SubResource( 138 ), SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ), SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ), SubResource( 147 ) ],
"loop": false,
"name": "roll",
"speed": 10.0
}, {
"frames": [ SubResource( 150 ), SubResource( 151 ), SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ), SubResource( 158 ), SubResource( 159 ) ],
"frames": [ SubResource( 148 ), SubResource( 149 ), SubResource( 150 ), SubResource( 151 ), SubResource( 152 ), SubResource( 153 ), SubResource( 154 ), SubResource( 155 ), SubResource( 156 ), SubResource( 157 ) ],
"loop": true,
"name": "run",
"speed": 10.0
}, {
"frames": [ SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ), SubResource( 168 ), SubResource( 169 ) ],
"frames": [ SubResource( 158 ), SubResource( 159 ), SubResource( 160 ), SubResource( 161 ), SubResource( 162 ), SubResource( 163 ), SubResource( 164 ), SubResource( 165 ), SubResource( 166 ), SubResource( 167 ) ],
"loop": true,
"name": "run_shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 170 ), SubResource( 171 ), SubResource( 128 ) ],
"frames": [ SubResource( 168 ), SubResource( 169 ), SubResource( 126 ) ],
"loop": false,
"name": "shoot",
"speed": 10.0
}, {
"frames": [ SubResource( 172 ), SubResource( 173 ), SubResource( 174 ), SubResource( 174 ), SubResource( 175 ), SubResource( 176 ), SubResource( 177 ), SubResource( 178 ), SubResource( 178 ), SubResource( 179 ), SubResource( 180 ), SubResource( 181 ), SubResource( 182 ), SubResource( 183 ), SubResource( 184 ), SubResource( 185 ), SubResource( 186 ), SubResource( 187 ), SubResource( 188 ), SubResource( 189 ), SubResource( 190 ), SubResource( 191 ) ],
"frames": [ SubResource( 170 ), SubResource( 171 ), SubResource( 172 ), SubResource( 172 ), SubResource( 173 ), SubResource( 174 ), SubResource( 175 ), SubResource( 176 ), SubResource( 176 ), SubResource( 177 ), SubResource( 178 ), SubResource( 179 ), SubResource( 180 ), SubResource( 181 ), SubResource( 182 ), SubResource( 183 ), SubResource( 184 ), SubResource( 185 ), SubResource( 186 ), SubResource( 187 ), SubResource( 188 ), SubResource( 189 ) ],
"loop": true,
"name": "slash",
"speed": 10.0
}, {
"frames": [ SubResource( 120 ), SubResource( 192 ), SubResource( 193 ), SubResource( 194 ), SubResource( 195 ) ],
"frames": [ SubResource( 118 ), SubResource( 190 ), SubResource( 191 ), SubResource( 192 ), SubResource( 193 ) ],
"loop": false,
"name": "stand",
"speed": 10.0
}, {
"frames": [ SubResource( 196 ) ],
"frames": [ SubResource( 194 ) ],
"loop": false,
"name": "step",
"speed": 10.0
}, {
"frames": [ SubResource( 197 ) ],
"frames": [ SubResource( 195 ) ],
"loop": false,
"name": "step_shoot",
"speed": 10.0
@ -543,9 +550,13 @@ script = ExtResource( 3 )
actor_type = "Player"
player_number = 1
[node name="AnimatedSprite" parent="." index="0"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="0"]
position = Vector2( 0, -3.5 )
shape = SubResource( 197 )
[node name="AnimatedSprite" parent="." index="1"]
position = Vector2( -1, -51 )
frames = SubResource( 198 )
frames = SubResource( 196 )
animation = "idle_shoot"
frame = 0
flip_h = false
@ -569,23 +580,23 @@ interactable_node = NodePath("../Interactable_Receiver")
[node name="idle" parent="movement_state_machine" index="0"]
script = ExtResource( 4 )
move_speed = 1.0
debug_state = true
move_speed = 0.0
animation_sequence = [ "idle" ]
jump_node = NodePath("../jump")
attack_node = NodePath("../attack")
dash_node = NodePath("../dash")
roll_node = NodePath("../roll")
climb_node = NodePath("../climb")
[node name="fall" parent="movement_state_machine" index="1"]
script = ExtResource( 6 )
debug_state = true
move_speed = 90.0
animation_sequence = [ "jump" ]
landing_node = NodePath("")
[node name="move" parent="movement_state_machine" index="2"]
script = ExtResource( 5 )
debug_state = true
move_speed = 90.0
animation_sequence = [ "step", "run" ]
jump_node = NodePath("../jump")
@ -593,8 +604,8 @@ attack_node = NodePath("../attack")
[node name="jump" type="Node" parent="movement_state_machine" index="3"]
script = ExtResource( 8 )
debug_state = true
move_speed = 90.0
move_modifier_move_acceleration = -100.0
animation_sequence = [ "jump" ]
idle_node = NodePath("../idle")
fall_node = NodePath("../fall")
@ -621,9 +632,9 @@ idle_node = NodePath("../idle")
[node name="dash" type="Node" parent="movement_state_machine" index="6"]
script = ExtResource( 11 )
move_speed = 90.0
move_speed_modifier = 160.0
move_modifier_move_acceleration = -160.0
jerk_factor = -190.0
move_speed_modifier = 90.0
move_modifier_move_acceleration = -100.0
jerk_factor = -20.0
animation_sequence = [ "dash" ]
fall_node = NodePath("../fall")
idle_node = NodePath("../idle")
@ -644,6 +655,12 @@ idle_node = NodePath("../idle")
script = ExtResource( 15 )
animation_sequence = [ "die" ]
[node name="climb" type="Node" parent="movement_state_machine" index="9"]
script = ExtResource( 17 )
debug_state = true
animation_sequence = [ "climb_step", "climb", "climb_upstep" ]
idle_node = NodePath("../idle")
[node name="Hurtbox_Component" parent="." index="4"]
collision_layer = 16
collision_mask = 128
@ -675,6 +692,19 @@ default_color = Color( 1, 0.607843, 0, 1 )
script = ExtResource( 16 )
interactable_parent_callback = "touch_the_thing"
[node name="Modifier_Receiver" parent="." index="9" instance=ExtResource( 9 )]
modifier_parent_callback = "receive_modifier"
debug_receiver = true
[node name="Ladder_Detection" type="RayCast2D" parent="." index="10"]
modulate = Color( 0.247059, 0.92549, 0.0313726, 1 )
position = Vector2( 0, 5 )
enabled = true
cast_to = Vector2( 0, 15 )
collision_mask = 1024
collide_with_areas = true
collide_with_bodies = false
[connection signal="do_attack" from="movement_state_machine/attack" to="." method="_on_attack_do_attack"]
[connection signal="frame_reached" from="movement_state_machine/roll" to="." method="_on_roll_frame_reached"]
[connection signal="state_exited" from="movement_state_machine/roll" to="." method="_on_roll_state_exited"]

View File

@ -20,7 +20,15 @@ export var player_number: int = 1
export (NodePath) var interactable_node
onready var interactable_receiver_node: Interactable_Receiver = get_node(interactable_node)
onready var ladder_detection:RayCast2D = $"../Ladder_Detection"
var ladder_collision: RayCast2D
func _ready():
ladder_collision = ladder_detection
# Guess there isn't a hit from inside in 3.5
# Remember to make raycast as tall as needed for the player
#ladder_collision.hit_from_inside = true
func process_physics(delta):
PlayerInfo.player_position = owner.global_position
@ -70,6 +78,40 @@ func wants_roll() -> bool:
else:
return false
func wants_climb() -> bool:
if ladder_detection.is_colliding() and Input.is_action_pressed("ui_up"):
#print("betcha wanna climb though!")
return true
else:
return false
func get_climb_shape_location() -> Vector2:
if ladder_detection.is_colliding():
var point: Vector2 = ladder_collision.get_collision_point()
var shape_id = ladder_collision.get_collider_shape()
var object = ladder_collision.get_collider()
# This works but doesn't get the shapes location.
# if object is Area2D:
# print("You got an area bro!" , object.global_position)
# This appears to get the shapes location!
var area = Physics2DServer.area_get_transform(object)
var areashape = Physics2DServer.area_get_shape_transform(object, shape_id)
var y_dir = Input.get_axis("ui_up" , "ui_down")
#var target = get_collider() # A CollisionObject2D.
#var shape_id = get_collider_shape() # The shape index in the collider.
#var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
#var shape = target.shape_owner_get_owner(owner_id)
#UiManager.debug_text = str(round(point.x)) + ' ' + str(round(point.y)) #( "Mod(" + str(sign(_move_speed_modifier)) + ") Dir(" + str(move_direction) + ") Vel(" + str(sign(current_x_velocity)) + ") Mov(" + str(sign(move_component.desired_movement_vector.x)) +
return Vector2(areashape.origin.x, y_dir)
else:
return Vector2(-1,-1)
## Other needed variables
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state

View File

@ -0,0 +1,51 @@
extends StateAnimatedActor
export (NodePath) var idle_node
onready var idle_state: StateAnimatedActor = get_node(idle_node)
#onready var landing_mod: StateModifier = get_node(landing_node)
var climbing_modifier: StateModifier
func _ready():
climbing_modifier= StateModifier.new()
#add_child(modifier)
#modifier.init_ref()
# climbing_modifier.ready( "landing", "jump" , climbing_modifier.TYPE.EXIT_ANIMATION)
# climbing_modifier.starting_frame = 6
#print("ready! MOD")
func enter() -> void:
.enter()
animations.frame = 5
func process_physics(delta: float) -> State:
# First allow horizontal movement.
#move_actor_as_desired(delta)
# Make wure we still want to climb
var ladder_location = move_component.get_climb_shape_location()
if ladder_location != Vector2(-1,-1):
UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location))
# An attempt to snap to the ladder location
if parent.global_position.x != round(ladder_location.x):
parent.global_translate(Vector2(round((ladder_location.x - parent.global_position.x)),(ladder_location.y * move_speed) * delta))
if ladder_location.y != 0:
animations.play()
else:
# Make sure we hopped the step index
if animation_index > 0:
animations.stop()
else:
return idle_state
#parent.move_local_x()
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
# if parent.is_on_floor():
# #modifier.reference()
# idle_state.modifier = climbing_modifier
# return idle_state
return null

View File

@ -37,7 +37,6 @@ func process_physics(delta: float) -> State:
parent.transform.x.x = move_component.get_movement_direction()
if parent.is_on_floor():
print("DO you even!?: ", landing_modifier.animation_name)
#modifier.reference()
idle_state.modifier = landing_modifier
return idle_state

View File

@ -47,7 +47,7 @@ func process_frame(delta: float) -> State:
func process_physics(delta: float) -> State:
move_component.velocity.y += gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
move_component.velocity = parent.transform.x * move_speed
move_component.velocity.x = parent.transform.x.x * move_speed
# if (parent.direction.x > 0):
# parent.velocity.x = 1 * move_speed
# else:

View File

@ -6,6 +6,7 @@ export (NodePath) var jump_node
export (NodePath) var attack_node
export (NodePath) var dash_node
export (NodePath) var roll_node
export (NodePath) var climb_node
onready var fall_state: State = get_node(fall_node)
onready var move_state: State = get_node(move_node)
@ -13,11 +14,13 @@ onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
onready var dash_state: State = get_node(dash_node)
onready var roll_state: State = get_node(roll_node)
onready var climb_state: State = get_node(climb_node)
func enter() -> void:
.enter()
# parent.set_hurtbox(true)
move_component.velocity.x = 0
#move_component.velocity.x = 0
#move_component.momentum.x *= -1
if debug_state:
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
@ -33,13 +36,15 @@ func process_physics(delta: float) -> State:
if move_component.wants_dash() and parent.is_on_floor():
return dash_state
if move_component.wants_climb():
return climb_state
if move_component.wants_shoot():
return attack_state
move_actor_as_desired(delta)
if move_component.velocity.x != 0.0:
if move_component.desired_movement_vector.x != 0 and move_component.velocity.x != 0:
return move_state
if !parent.is_on_floor():

View File

@ -21,10 +21,6 @@ func enter() -> void:
# if modifier_stack_ref.has(landing_mod):
# print("Jump from Landing Mod at: ", modifier_stack_ref.rfind(landing_mod))
.enter()
if previous_speed_multiplier > 1.0:
speed_multiplier = previous_speed_multiplier
else:
speed_multiplier = 1.0
# Apply initial jump velocity on state enter
move_component.velocity.y = -jump_force

View File

@ -19,12 +19,15 @@ func process_physics(delta: float) -> State:
move_actor_as_desired(delta)
if move_component.velocity.x == 0.0:
return idle_state
# if move_component.velocity.x == 0.0:
# return idle_state
#Flip the character before tha actual move maybe.
if move_component.get_movement_direction() != 0.0:
parent.transform.x.x = move_component.get_movement_direction()
if move_component.desired_movement_vector.x == 0:
return idle_state
if !parent.is_on_floor():
return fall_state

View File

@ -23,9 +23,11 @@ export var move_speed_modifier: float = 0
export var move_modifier_move_acceleration: float = 0
export var jerk_factor: float = 0
var adjusted_move_speed: float
#var adjusted_move_speed: float
var jerk: float
var physics_modifier :StateModifier
##TODO: Deprecate this useless fool!
var speed_multiplier: float = 1.0
@ -166,7 +168,7 @@ func enter() -> void:
update_animation()
# Reset movespeed counters
adjusted_move_speed = move_speed_modifier
#move_component.momentum.x = move_speed_modifier
jerk = 0
return
@ -258,52 +260,194 @@ func process_physics(_delta: float) -> State:
# if animations.frames.get_animation_loop(animations.animation) == false:
# animation_index += 1
func move_actor_as_desired(delta: float, x_direction: float = 0):
# Assuming adjusted_move_speed is set to the mood speed modifier on state entry
# Move speed is the base speed plus the modifier minus the decay adjusted for time
jerk += jerk_factor * delta
adjusted_move_speed += move_modifier_move_acceleration * delta
var new_move_speed = move_speed + (move_acceleration * delta) + adjusted_move_speed + jerk
func move_actor_as_desired(delta: float, x_move_direction_override: float = 0):
var _move_speed = move_speed
var _move_speed_modifier = move_speed_modifier
var _move_modifier_move_acceleration = move_modifier_move_acceleration
var _move_acceleration = move_acceleration
var _jerk_factor = jerk_factor
var _gravity = gravity
# A really crappy normalization to prevent modifying past the base move speed.
if move_speed_modifier > 0 and new_move_speed < move_speed: # positive modifier
#print("nope1")
new_move_speed = move_speed
elif move_speed_modifier < 0 and new_move_speed > move_speed: # negative modifier
#print("nope2")
new_move_speed = move_speed
# else:
# UiManager.debug_text = str(round(adjusted_move_speed)) + "," + str(round(new_move_speed)) + "," + str(round(jerk))
# #print(adjusted_move_speed, ",", new_move_speed, ",", jerk)
if physics_modifier:
#physics_modifier.modifier_properties.jerk_factor
#print(physics_modifier.name)
#UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed))
var mod_props :ModifierProperties = physics_modifier.get_modifier_properties()
if mod_props.move_speed != 0 and mod_props.directional_modifier == false:
_move_speed = mod_props.move_speed
_move_speed_modifier += mod_props.move_speed_modifier
_move_acceleration += mod_props.move_acceleration
_move_modifier_move_acceleration += mod_props.move_modifier_move_acceleration
_jerk_factor += mod_props.jerk_factor
var help_me_not_be_dumb = ''
# Allow us to bump out of halt.
if _move_speed == 0 and move_component.desired_movement_vector.x != 0:
_move_speed = abs(move_component.desired_movement_vector.x)
# Determine or physics movement direction
var current_x_velocity = move_component.velocity.x #move_component.velocity.x
var move_direction = 0.0
# Determine movement direction if we have momentum
if move_component.momentum.x != 0:
if x_move_direction_override == 0:
move_direction = sign(current_x_velocity)
# if move_component.desired_movement_vector.x != 0:
# # set the move direction to the desired direction
# move_direction = move_component.desired_movement_vector.x
# else:
# # Set move direction to the transform direction
# move_direction = parent.transform.x.x
else:
move_direction = x_move_direction_override
else: # No current momentum in place
if x_move_direction_override == 0:
move_direction = move_component.desired_movement_vector.x
else:
move_direction = x_move_direction_override
## TODO: I hate that I have to do this check again.
if physics_modifier:
var mod_props :ModifierProperties = physics_modifier.get_modifier_properties()
if mod_props.move_speed != 0 and mod_props.directional_modifier == true:
# Since move_direction is always positive
if sign(move_direction) == sign(mod_props.move_speed):
_move_speed += mod_props.move_speed
else:
_move_speed -= mod_props.move_speed
if sign(move_direction) == 0:
move_direction = sign(mod_props.move_speed) * -1
#print("doing this? ")
# Determine the maximum move speed
var MAX_SPEED :float = 0
var MIN_SPEED :float = 0
if sign(_move_speed_modifier) == -1: # decreased speed modifier
help_me_not_be_dumb += '-SpeedMod'
# Move speed cannot go below zero with modifier applied
MIN_SPEED = _move_speed + _move_speed_modifier
# Poor man's clamp
if MIN_SPEED < 0:
MIN_SPEED = 0
MAX_SPEED = _move_speed
elif sign(_move_speed_modifier) == +1: # increased speed modifier
help_me_not_be_dumb += '+SpeedMod'
MIN_SPEED = _move_speed
MAX_SPEED = _move_speed + _move_speed_modifier
else: # physics won't apply here
help_me_not_be_dumb += '_Speed' # Neutral Speed
MIN_SPEED = _move_speed
MAX_SPEED = _move_speed
# get the latest aggregate acceleration
# If we have any acceleration applying
if (_move_modifier_move_acceleration + _move_acceleration) != 0:
# The acceleration is differant
# Perhaps it would be better to trigger this on a difference in modifier but they usually go together.
if abs(move_component.acceleration.x) != abs(_move_modifier_move_acceleration + _move_acceleration):
if move_direction:
print("Acceleration changed.", abs(move_component.acceleration.x), "-", (_move_modifier_move_acceleration + _move_acceleration))
move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
# If we're no longer tryingg to move int the direction of our movement and momentum.
if sign(current_x_velocity) != sign(move_component.desired_movement_vector.x) and move_component.momentum.x != 0:
if sign(_move_speed_modifier) == -1 : # decreased speed modifier
# Maybe we can compare the direction of the acceleration
# The direction of the acceleration should usually be positive at this point.
# when the modifier is negative.
if sign(move_direction) == sign(current_x_velocity):
if sign(move_component.acceleration.x) == sign(move_component.momentum.x):
print("Whoh Woah")
# Flip the direction of the acceleration
move_component.acceleration.x *= -1
if (sign(move_component.desired_movement_vector.x) == -1 and
sign(current_x_velocity) == 1) or (sign(move_component.desired_movement_vector.x) == -1 and
sign(current_x_velocity) == -1):
print("be more opposite")
# if sign(_move_speed_modifier) == 1: # increased speed modifier
# print("faster faster.")
elif sign(move_component.desired_movement_vector.x) == sign(current_x_velocity) and move_component.momentum.x != 0:
if sign(move_component.acceleration.x) != sign(move_component.momentum.x) and x_move_direction_override == 0:
print("Step it up!")
# Flip the direction of the acceleration
move_component.acceleration.x *= -1
# Apply momentum and acceleration if a modifer exists
if move_component.momentum.x <= 0 and _move_speed_modifier !=0:
#if we're trying to move but we have no momentum applied currently
#if move_component.desired_movement_vector.x != 0:
if move_direction:
move_component.acceleration.x = _move_modifier_move_acceleration + _move_acceleration
##TODO: I don't know where I should actually set the momentum. :
if sign(_move_speed_modifier) == -1: # decreased speed modifier
move_component.momentum.x = 0
elif sign(_move_speed_modifier) == +1: # increased speed modifier
##TODO: in most cases this should only be applied once. need to find a way to warn against this.
move_component.momentum.x = abs(move_speed_modifier)
print("momentum applied!")
# Reverse the accelerations if we carry over momentum but the modifier no longer applies.
if move_component.momentum.x > 0 and _move_speed_modifier == 0:
if sign(move_component.acceleration.x) == sign(move_component.momentum.x):
print("Whoh Woah your done.")
# Flip the direction of the acceleration
move_component.acceleration.x *= -1
# We're going to adjust our move speed only to the modifier
move_component.momentum.x += move_component.acceleration.x * delta
jerk += _jerk_factor * delta
var new_move_speed :float = 0
if sign(_move_speed_modifier) == -1: # decreased speed modifier
# MIN_SPEED = _move_speed + _move_speed_modifier
# MAX_SPEED = _move_speed
move_component.momentum.x = clamp(move_component.momentum.x, 0, abs(_move_speed_modifier))
# new_move_speed = (_move_speed + _move_speed_modifier ) + (sign(_move_speed_modifier) * -1 * move_component.momentum.x) # + jerk
new_move_speed = MIN_SPEED + (sign(_move_speed_modifier) * -1 * move_component.momentum.x) # + jerk
elif sign(_move_speed_modifier) == +1: # increased speed modifier
# MIN_SPEED = _move_speed
# MAX_SPEED = _move_speed + _move_speed_modifier
move_component.momentum.x = clamp(move_component.momentum.x, 0, _move_speed_modifier )
new_move_speed = _move_speed + move_component.momentum.x # + jerk
else: # physics won't apply here
# move_component.acceleration.x = 0
# move_component.momentum.x = 0
# new_move_speed = _move_speed
move_component.momentum.x = clamp(move_component.momentum.x, 0, MIN_SPEED )
new_move_speed = _move_speed + move_component.momentum.x # + jerk
#new_move_speed = clamp(new_move_speed, MIN_SPEED, MAX_SPEED)
var sim_move_speed = (MIN_SPEED + (sign(_move_speed_modifier) * -1 * move_component.momentum.x))
# if move_component.momentum.x != 0:
if true:
UiManager.debug_text = ( "Mod(" + str(sign(_move_speed_modifier)) + ") Dir(" + str(move_direction) + ") Vel(" + str(sign(current_x_velocity)) + ") Mov(" + str(sign(move_component.desired_movement_vector.x)) +
")\nNS:" + str(round(sim_move_speed)) + #" Z:" + str(sign(_move_speed_modifier) * -1 * move_component.momentum.x) +
"\nS:" + str(round(_move_speed + _move_speed_modifier)) + ",M" + str(round(move_component.momentum.x)) +
",A" + str(round(move_component.acceleration.x)) +
"\nVel:" + str(round(move_component.velocity.x)) + "Min:" + str(round(MIN_SPEED)) + ",Max:" + str(round(MAX_SPEED))
) # str(round(jerk))
move_component.sim_velocity.x = move_direction * sim_move_speed
#print(adjusted_move_speed, ",", new_move_speed, ",", jerk)
#print(new_move_speed, " ", adjusted_move_speed)
move_component.velocity.y += gravity * delta
move_component.velocity.y += _gravity * delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
#print(speed_multiplier)
if (x_direction != 0):
move_component.velocity.x = x_direction * new_move_speed
else:
move_component.velocity.x = move_component.desired_movement_vector.x * new_move_speed
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
# var new_speed = move_speed * speed_multiplier
# if speed_multiplier > 1.0:
# speed_multiplier -= delta * speed_multiplier
# #speed_decay_rate += delta * speed_decay_rate
#
# elif speed_multiplier < 1.0:
# speed_multiplier += delta * speed_multiplier
# #speed_decay_rate += delta * speed_decay_rate
#
# # Deadzone
# if speed_multiplier < 1.1 and speed_multiplier > 0.9:
# speed_multiplier = 1.0
## if (new_speed > move_speed):
## print("Go Faster Booooy! ", move_speed)
# move_component.velocity.y += gravity * delta
# #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
# move_component.velocity.x = move_component.desired_movement_vector.x * new_speed
# move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
# move_component.velocity.x = move_component.desired_movement_vector.x * _move_speed
move_component.velocity.x = move_direction * new_move_speed
#move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2.UP)
var snap = Vector2.DOWN * 8
if move_component.velocity.y < -8:
snap = Vector2.ZERO
move_component.velocity = parent.move_and_slide_with_snap(move_component.velocity, snap , Vector2.UP, true)

View File

@ -1,5 +1,7 @@
class_name StateMachineAnimatedActor extends StateMachine
#var physics_modifier : StateModifier
func change_state(new_state: State) -> void:
if new_state.state_ready == false:
# Don't transition to unready state
@ -12,6 +14,9 @@ func change_state(new_state: State) -> void:
if current_state.modifier: # Current state has a modifier
new_state.transfer_modifiers(current_state.modifier)
current_state.modifier = null
if current_state.physics_modifier: # Current state has a physics modifier
new_state.physics_modifier = current_state.physics_modifier
current_state.physics_modifier = null
current_state = new_state
current_state.enter()

View File

@ -84,14 +84,17 @@ func merge_modifier(merging_mod: ModifierProperties):
func get_modifier_properties() -> ModifierProperties:
#( p_move_speed:float, p_gravity:int , p_move_acceleration , p_move_speed_modifier:float,
# p_move_modifier_move_acceleration:float, p_jerk_factor: float):
return ModifierProperties.new( modifier_properties.move_speed,
var mp = ModifierProperties.new( modifier_properties.move_speed,
modifier_properties.gravity,
modifier_properties.move_acceleration,
modifier_properties.move_speed_modifier,
modifier_properties.move_modifier_move_acceleration,
modifier_properties.jerk_factor)
mp.directional_modifier = modifier_properties.directional_modifier
return mp
func ready(modifier_name:String, anim_name:String = '', type = TYPE.NONE, timeout : float = 0, parent:Node = null, function_name : String = "") -> Timer:
name = modifier_name
# If somebody forgot to specify the type
if anim_name != '' and type == TYPE.NONE:
modifier_type = TYPE.REPLACE_ANIMATION

View File

@ -12,6 +12,10 @@ var jerk_factor: float = 0
var gravity:int = 0
# Bad name. Just means that it is intended to apply in a certain direction
# (Positive or negative) not an offset of the existing values.
var directional_modifier: bool = false
func _init( p_move_speed:float, p_gravity:int , p_move_acceleration , p_move_speed_modifier:float,
p_move_modifier_move_acceleration:float, p_jerk_factor: float):

View File

@ -1,59 +0,0 @@
extends Actor
onready var actor_hurtbox = $Hurtbox_Component/CollisionShape2D
#var sound_effects = preload("res://src/playerC/resources/sound_effects.tres")
func _ready() -> void:
movement_state_machine.init_animated_actor(self, movement_animations, movement_component)
# Experimenting with sound based resources I did this and it worked
#sound_effect_player.stream = sound_effects.sounds["pew"]
#print(sounds.sounds["pew"])
#sound_effects.play()
# Trying something new with a custom resourse.
for i in SoundEffects:
sound_effects_dict[i.animation_name + str(i.frame_number)] = i.sound
print (sound_effects_dict)
func _unhandled_input(event: InputEvent) -> void:
movement_state_machine.process_input(event)
func _physics_process(delta: float) -> void:
movement_state_machine.process_physics(delta)
# #TODO: So much hack
# if direction.x != 0:
# gun.set_scale( Vector2(direction.x,1))
# Commented out to try parent transforms instead
# if direction.x < 0:
# var t = Transform2D()
# # Translation
# t.origin = Vector2(gun.offset_position.x * -1, gun.offset_position.y)
# gun.transform = t
# elif direction.x > 0:
# var t = Transform2D()
# # Translation
# t.origin = Vector2(gun.offset_position.x, gun.offset_position.y)
# gun.transform = t
# Attempting a Kinematic2D level scale for flip operations instead.
#self.transform
#self.scale.x = -1
func _process(delta: float) -> void:
movement_component.process(delta)
movement_state_machine.process_frame(delta)
play_sound_frame(movement_animations.animation , movement_animations.frame)
##TODO: I don't like player class having do do this.
## Figure out how to programatically signal subscribe
#func _on_AnimatedSprite_animation_finished():
# if movement_animations.frames.get_animation_loop(movement_animations.animation) == false:
# movement_state_machine.current_state.animation_index += 1

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://src/components/Hurtbox_Component.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/state_machine_animated_actor.gd" type="Script" id=2]
@ -41,9 +41,6 @@ animations = [ {
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=74]
extents = Vector2( 14, 18.5 )
[sub_resource type="CircleShape2D" id=82]
[node name="ActorTemplate" type="KinematicBody2D"]
@ -52,7 +49,7 @@ script = ExtResource( 8 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 75 )
frame = 4
frame = 3
playing = true
flip_h = true
__meta__ = {
@ -68,10 +65,6 @@ __meta__ = {
}
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -3.5 )
shape = SubResource( 74 )
[node name="movement_component" type="Node" parent="."]
script = ExtResource( 5 )