Compare commits
23 Commits
041f261a0d
...
b7c034d877
| Author | SHA1 | Date | |
|---|---|---|---|
| b7c034d877 | |||
| 4fcd85c936 | |||
| b091bdc143 | |||
| 6dc01326c5 | |||
| 71e7bdf574 | |||
| 74dc378791 | |||
| 1a743214d7 | |||
| 8597840033 | |||
| d50e3f6a51 | |||
| 9149e89865 | |||
| e076952b12 | |||
| 267850a2f6 | |||
| 8bbc41b8f2 | |||
| 46c1063d8d | |||
| 66a0de16bb | |||
| c4df444848 | |||
| 5d0bc33cbf | |||
| 6280c7eb44 | |||
| b00e504c08 | |||
| 6e899d1bbf | |||
| fbcb5af32d | |||
| a7bc6c6349 | |||
| f6cb10fce5 |
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -2,4 +2,5 @@
|
|||
.godot/
|
||||
.import/
|
||||
.mono/
|
||||
addons/
|
||||
addons/
|
||||
android/
|
||||
BIN
assets/Backgrounds/bgmuck.png
Normal file
BIN
assets/Backgrounds/bgmuck.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
35
assets/Backgrounds/bgmuck.png.import
Normal file
35
assets/Backgrounds/bgmuck.png.import
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/bgmuck.png-d4be388271ba394d1ddbac361f6ed992.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Backgrounds/bgmuck.png"
|
||||
dest_files=[ "res://.import/bgmuck.png-d4be388271ba394d1ddbac361f6ed992.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
|
||||
BIN
assets/Music/platformer_level03_loop.ogg
Normal file
BIN
assets/Music/platformer_level03_loop.ogg
Normal file
Binary file not shown.
15
assets/Music/platformer_level03_loop.ogg.import
Normal file
15
assets/Music/platformer_level03_loop.ogg.import
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[remap]
|
||||
|
||||
importer="ogg_vorbis"
|
||||
type="AudioStreamOGGVorbis"
|
||||
path="res://.import/platformer_level03_loop.ogg-eb8ec48736a59637eb7f6b57e14483e5.oggstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Music/platformer_level03_loop.ogg"
|
||||
dest_files=[ "res://.import/platformer_level03_loop.ogg-eb8ec48736a59637eb7f6b57e14483e5.oggstr" ]
|
||||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop_offset=0
|
||||
BIN
assets/Sounds/crappy pew.wav
Normal file
BIN
assets/Sounds/crappy pew.wav
Normal file
Binary file not shown.
23
assets/Sounds/crappy pew.wav.import
Normal file
23
assets/Sounds/crappy pew.wav.import
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamSample"
|
||||
path="res://.import/crappy pew.wav-617183b0efcd1daa3d0b0a4a6f318332.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Sounds/crappy pew.wav"
|
||||
dest_files=[ "res://.import/crappy pew.wav-617183b0efcd1daa3d0b0a4a6f318332.sample" ]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=1
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=0
|
||||
205
export_presets.cfg
Normal file
205
export_presets.cfg
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
[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
|
||||
|
|
@ -10,41 +10,53 @@ config_version=4
|
|||
|
||||
_global_script_classes=[ {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Enemy",
|
||||
"class": "Actor",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/enemy/Enemy-KinematicBody2D.gd"
|
||||
"path": "res://src/actor.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "Movement",
|
||||
"base": "Resource",
|
||||
"class": "FrameSoundEffects",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/playerB/player_move_component.gd"
|
||||
"path": "res://src/playerC/resources/FrameSounds.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "PushdownStateMachine",
|
||||
"class": "MovementComponent",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/pushdown_state_machine.gd"
|
||||
"path": "res://src/movement_component.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "State",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/state.gd"
|
||||
}, {
|
||||
"base": "State",
|
||||
"class": "StateAnimatedActor",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/state_animated_actor.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "StateMachine",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/state_machine.gd"
|
||||
}, {
|
||||
"base": "StateMachine",
|
||||
"class": "StateMachineAnimatedActor",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/state_machine_animated_actor.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "StateModifier",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/state_modifier.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Enemy": "",
|
||||
"Movement": "",
|
||||
"PushdownStateMachine": "",
|
||||
"Actor": "",
|
||||
"FrameSoundEffects": "",
|
||||
"MovementComponent": "",
|
||||
"State": "",
|
||||
"StateAnimatedActor": "",
|
||||
"StateMachine": "",
|
||||
"StateMachineAnimatedActor": "",
|
||||
"StateModifier": ""
|
||||
}
|
||||
|
||||
|
|
@ -81,19 +93,30 @@ common/drop_mouse_on_gui_input_disabled=true
|
|||
|
||||
[input]
|
||||
|
||||
ui_accept={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_left_1={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right_1={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
jump_1={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_left_2={
|
||||
|
|
@ -114,6 +137,7 @@ jump_2={
|
|||
shoot_1={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":77,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
shoot_2={
|
||||
|
|
@ -143,4 +167,5 @@ common/enable_pause_aware_picking=true
|
|||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
|
|
|||
0
script_templates/.gdignore
Normal file
0
script_templates/.gdignore
Normal file
22
script_templates/Actor.gd
Normal file
22
script_templates/Actor.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends %BASE%
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a%INT_TYPE% = 2
|
||||
# var b%STRING_TYPE% = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree.
|
||||
# you do not normally need to define this for Actor
|
||||
# func _ready()%VOID_RETURN%:
|
||||
# pass # Replace with function body.
|
||||
|
||||
|
||||
# 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%FLOAT_TYPE%)%VOID_RETURN%:
|
||||
# pass
|
||||
|
||||
# Attach any number of signals from children nodes here.
|
||||
# It's a good idea to define component signals here then call functions
|
||||
# from other components.
|
||||
42
script_templates/MovementComponent.gd
Normal file
42
script_templates/MovementComponent.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
extends %BASE%
|
||||
|
||||
## 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():
|
||||
|
||||
|
||||
## 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%INT_TYPE% = 2
|
||||
# var b%STRING_TYPE% = "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%FLOAT_TYPE%)%VOID_RETURN%:
|
||||
# pass
|
||||
|
||||
# For Enemy and NPC Actors:
|
||||
# should be called on the frame process.
|
||||
|
||||
# For Player Actors:
|
||||
# Should be called on the input process
|
||||
|
||||
|
||||
84
src/actor.gd
Normal file
84
src/actor.gd
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
class_name Actor
|
||||
extends KinematicBody2D
|
||||
|
||||
#var velocity = Vector2(0,0)
|
||||
#var direction = Vector2(-1,0)
|
||||
|
||||
export(String, "Player", "Enemy", "NPC") var actor_type
|
||||
#export var sprite_facing_right: bool = true
|
||||
export(Array, Resource) var SoundEffects
|
||||
export var debug_actor: bool = false
|
||||
|
||||
|
||||
onready var movement_animations: AnimatedSprite = $AnimatedSprite
|
||||
|
||||
onready var sound_effect_player: AudioStreamPlayer = $SE_Player
|
||||
|
||||
onready var movement_component: MovementComponent = $movement_component
|
||||
|
||||
onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine
|
||||
|
||||
var sound_effects_dict: Dictionary
|
||||
|
||||
##TODO:
|
||||
# Can't seem to implement the ready and process node functions
|
||||
# without causing a double run somehow. Not sure why.
|
||||
# not a huge deal because this is mostly to help with
|
||||
# interfaces for the state machines.
|
||||
|
||||
func _ready() -> void:
|
||||
movement_state_machine.init_animated_actor(self, movement_animations, movement_component)
|
||||
movement_component.attack_function = funcref(self, "attack")
|
||||
# movement_component.player_number = player_number
|
||||
|
||||
# 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:
|
||||
if actor_type == "Player":
|
||||
movement_component.process_input(event)
|
||||
movement_state_machine.process_input(event)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
movement_component.process_physics(delta)
|
||||
movement_state_machine.process_physics(delta)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if actor_type == "NPC" or actor_type == "Enemy":
|
||||
movement_component.process(delta)
|
||||
movement_state_machine.process_frame(delta)
|
||||
# PlayerInfo.player_position = global_position
|
||||
play_sound_frame(movement_animations.animation , movement_animations.frame)
|
||||
|
||||
|
||||
var last_sound_frame_animation: String = ''
|
||||
var last_sound_frame: int = -1
|
||||
func play_sound_frame(animation: String, frame: int ):
|
||||
##DEBUG:
|
||||
#if animation == 'run' and frame == 6:
|
||||
# print("Do the thign! (", animation + str(frame), ")", " (", last_sound_frame_animation + str(last_sound_frame), ")")
|
||||
if animation != last_sound_frame_animation or frame != last_sound_frame:
|
||||
last_sound_frame = frame
|
||||
last_sound_frame_animation = animation
|
||||
var sound_index = animation + str(frame)
|
||||
if sound_effects_dict.has(sound_index):
|
||||
sound_effect_player.stream = sound_effects_dict[sound_index]
|
||||
sound_effect_player.play()
|
||||
print(self.name, " Playing SE: ", sound_index)
|
||||
|
||||
func attack():
|
||||
#print(self.name, ": It's not inheritence, it's funcrefs")
|
||||
if movement_state_machine.current_state.name != 'attack':
|
||||
if($movement_state_machine/attack):
|
||||
movement_state_machine.change_state($movement_state_machine/attack)
|
||||
if ($Hitbox_Component/CollisionShape2D):
|
||||
#print(self.name, ": Found a hitbox")
|
||||
var hit_box = $Hitbox_Component
|
||||
hit_box.set_hitbox(true)
|
||||
26
src/components/GenericReceiver.gd
Normal file
26
src/components/GenericReceiver.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
extends Node
|
||||
|
||||
export(String) var body_entered_function = ""
|
||||
|
||||
var call_function: FuncRef
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if body_entered_function:
|
||||
call_function = funcref(owner, body_entered_function)
|
||||
#call_function.call_func()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
func on_body_entered(sender):
|
||||
print("Receiving call from " + sender.name)
|
||||
if body_entered_function:
|
||||
call_function.call_func(sender)
|
||||
|
||||
6
src/components/GenericReceiver.tscn
Normal file
6
src/components/GenericReceiver.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/components/GenericReceiver.gd" type="Script" id=1]
|
||||
|
||||
[node name="GenericReceiver" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
41
src/components/GenericSender.gd
Normal file
41
src/components/GenericSender.gd
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
extends Area2D
|
||||
|
||||
export(String) var receiver_node_name = ""
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
## Called when the node enters the scene tree for the first time.
|
||||
#func _ready():
|
||||
# pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
##TODO: maybe guarantee type with receiver node type instead of just the name.
|
||||
# The the name helps keep the receiver type generic.
|
||||
|
||||
func _on_GenericSender_body_entered(body):
|
||||
if body.has_node(receiver_node_name):
|
||||
body.get_node(receiver_node_name).on_body_entered(self)
|
||||
|
||||
|
||||
#func _on_Hurtbox_Component_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
|
||||
# #print(area.get_parent().name, "hit", owner.name)
|
||||
## if area.get_parent().has_method("gotcha"):
|
||||
# print(area.get_parent().name, " you can do it.", owner.name)
|
||||
#
|
||||
# if owner.has_method("_on_Hurtbox_area_entered"):
|
||||
# owner.call("_on_Hurtbox_area_entered")
|
||||
# print(area.get_parent().name, " just hit me: ", owner.name)
|
||||
|
||||
|
||||
|
||||
func _on_GenericSender_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
|
||||
if area.get_parent().has_node(receiver_node_name):
|
||||
area.get_parent().get_node(receiver_node_name).on_body_entered(self)
|
||||
|
||||
11
src/components/GenericSender.tscn
Normal file
11
src/components/GenericSender.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/components/GenericSender.gd" type="Script" id=1]
|
||||
|
||||
[node name="GenericSender" type="Area2D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 32768
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[connection signal="area_shape_entered" from="." to="." method="_on_GenericSender_area_shape_entered"]
|
||||
[connection signal="body_entered" from="." to="." method="_on_GenericSender_body_entered"]
|
||||
18
src/components/Hitbox_Component.gd
Normal file
18
src/components/Hitbox_Component.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
extends Area2D
|
||||
|
||||
export(int) var damage_amount = 0
|
||||
|
||||
func set_hitbox(enabled: bool):
|
||||
for child in get_children():
|
||||
if child is CollisionShape2D:
|
||||
child.set_deferred("disabled", !enabled)
|
||||
## TODO: This breaks now I guess because I moved the process functions out to parent class
|
||||
#player_hurtbox.set_deferred("disabled", !enabled) #WTF Apparently this is how to do it
|
||||
|
||||
|
||||
func _on_Hitbox_Component_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
|
||||
var colliding_node = area.get_parent()
|
||||
if colliding_node.has_node("Hurtbox_Component"):
|
||||
colliding_node.get_node("Hurtbox_Component").on_hit(self)
|
||||
else:
|
||||
print(owner.name, ": Attempted to Hit an unready node, no Hurtbox_Component reciever node in ", colliding_node.name)
|
||||
10
src/components/Hitbox_Component.tscn
Normal file
10
src/components/Hitbox_Component.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/components/Hitbox_Component.gd" type="Script" id=1]
|
||||
|
||||
[node name="Hitbox_Component" type="Area2D"]
|
||||
collision_layer = 128
|
||||
collision_mask = 0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[connection signal="area_shape_entered" from="." to="." method="_on_Hitbox_Component_area_shape_entered"]
|
||||
43
src/components/Hurtbox_Component.gd
Normal file
43
src/components/Hurtbox_Component.gd
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
extends Area2D
|
||||
|
||||
export(String) var hurtbox_entered_function = ""
|
||||
|
||||
var call_function: FuncRef
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if hurtbox_entered_function:
|
||||
call_function = funcref(owner, hurtbox_entered_function)
|
||||
|
||||
func set_hittbox(enabled: bool):
|
||||
for child in get_children():
|
||||
if child is CollisionShape2D:
|
||||
child.set_deferred("disabled", !enabled)
|
||||
|
||||
# Switching to a new model that starts with Hitbox
|
||||
func on_hit(sender):
|
||||
print("Received hit from: " + sender.name)
|
||||
if hurtbox_entered_function:
|
||||
call_function.call_func(sender.damage_amount)
|
||||
|
||||
# This one doesn't seem to work
|
||||
#func _on_Hurtbox_Component_body_entered(body):
|
||||
# print(body.name, "hit", owner.name)
|
||||
# if owner.has_method("gotcha"):
|
||||
# print(body.name, " you can do it.", owner.name)
|
||||
|
||||
|
||||
# well this one works.
|
||||
#func _on_Hurtbox_Component_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
|
||||
# #print(area.get_parent().name, "hit", owner.name)
|
||||
## if area.get_parent().has_method("gotcha"):
|
||||
# print(area.get_parent().name, " you can do it.", owner.name)
|
||||
#
|
||||
# if owner.has_method("_on_Hurtbox_area_entered"):
|
||||
# owner.call("_on_Hurtbox_area_entered")
|
||||
# print(area.get_parent().name, " just hit me: ", owner.name)
|
||||
|
|
@ -1,13 +1,6 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=148]
|
||||
extents = Vector2( 11.5, 14.5 )
|
||||
[ext_resource path="res://src/components/Hurtbox_Component.gd" type="Script" id=1]
|
||||
|
||||
[node name="Hurtbox_Component" type="Area2D"]
|
||||
collision_layer = 16
|
||||
collision_mask = 128
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
self_modulate = Color( 1, 0, 0, 1 )
|
||||
position = Vector2( 0, -4 )
|
||||
shape = SubResource( 148 )
|
||||
script = ExtResource( 1 )
|
||||
|
|
|
|||
|
|
@ -1,140 +0,0 @@
|
|||
class_name Enemy extends KinematicBody2D
|
||||
|
||||
enum STATE {IDLE, WANDER, JUMP, FALL, HURT, ATTACK}
|
||||
enum STATE_SECONDARY {NONE, SHOOT}
|
||||
|
||||
#const WALK_FORCE = 600
|
||||
const WALK_MAX_SPEED = (30*2)
|
||||
#const STOP_FORCE = 1300
|
||||
const JUMP_SPEED = 270
|
||||
|
||||
var velocity = Vector2()
|
||||
|
||||
var gravity = 60*9.8
|
||||
var player_state = STATE.IDLE
|
||||
var player_last_state = null
|
||||
var animation_play_finished = true
|
||||
var flip_direction = false
|
||||
|
||||
onready var _animated_sprite = $AnimatedSprite
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Horizontal movement
|
||||
if player_state != STATE.WANDER and $IdleTimeout.time_left == 0:
|
||||
if flip_direction:
|
||||
velocity.x = (1 * WALK_MAX_SPEED)
|
||||
flip_direction = false
|
||||
else:
|
||||
velocity.x = (-1 * WALK_MAX_SPEED)
|
||||
flip_direction = true
|
||||
|
||||
# Vertical movement code. Apply gravity.
|
||||
velocity.y += gravity * delta
|
||||
|
||||
# Move based on the velocity and snap to the ground.
|
||||
#velocity = move_and_slide_with_snap(velocity, Vector2.DOWN, Vector2.UP)
|
||||
velocity = move_and_slide(velocity, Vector2(0, -1))
|
||||
|
||||
# Animate based on last state and velocity
|
||||
if velocity.x > 0 and _animated_sprite.flip_h != true:
|
||||
_animated_sprite.flip_h = true
|
||||
_animated_sprite.offset.x = 0
|
||||
$PlayerDetection.cast_to = Vector2(20,0)
|
||||
if velocity.x < 0 and _animated_sprite.flip_h != false:
|
||||
_animated_sprite.flip_h = false
|
||||
_animated_sprite.offset.x = -18
|
||||
$PlayerDetection.cast_to = Vector2(-20,0)
|
||||
|
||||
# forced state changes like falling an gitting hurt
|
||||
if velocity.y > 0 and player_state != STATE.JUMP and player_state != STATE.FALL:
|
||||
print("STATE_TRANSITION: Fall")
|
||||
player_state = STATE.FALL
|
||||
|
||||
if $PlayerDetection.is_colliding():
|
||||
player_state = STATE.ATTACK
|
||||
player_last_state = null
|
||||
velocity.x = 0
|
||||
|
||||
# Each state should trigger its own animation
|
||||
match player_state:
|
||||
STATE.IDLE:
|
||||
# Transitions
|
||||
if velocity.y == -JUMP_SPEED:
|
||||
print("STATE_TRANSITION: Jump")
|
||||
player_last_state = STATE.IDLE
|
||||
player_state = STATE.JUMP
|
||||
elif velocity.x != 0:
|
||||
print("STATE_TRANSITION: Wander")
|
||||
player_last_state = STATE.IDLE
|
||||
player_state = STATE.WANDER
|
||||
# Animation
|
||||
if player_last_state != STATE.IDLE:
|
||||
_animated_sprite.play("idle")
|
||||
player_last_state = STATE.IDLE
|
||||
$IdleTimeout.start()
|
||||
|
||||
STATE.JUMP:
|
||||
# Transitions
|
||||
if is_on_floor():
|
||||
print("STATE_TRANSITION: Idle")
|
||||
_animated_sprite.play("idle")
|
||||
player_last_state = STATE.JUMP
|
||||
player_state = STATE.IDLE
|
||||
# Animation
|
||||
if player_last_state != STATE.JUMP:
|
||||
_animated_sprite.play("jump")
|
||||
player_last_state = STATE.JUMP
|
||||
|
||||
STATE.FALL:
|
||||
# Transitions
|
||||
if is_on_floor():
|
||||
print("STATE_TRANSITION: Idle")
|
||||
_animated_sprite.play("idle")
|
||||
player_last_state = STATE.FALL
|
||||
player_state = STATE.IDLE
|
||||
# Animation
|
||||
if player_last_state != STATE.FALL:
|
||||
#_animated_sprite.animation = "jump"
|
||||
_animated_sprite.frame = 8
|
||||
_animated_sprite.stop()
|
||||
player_last_state = STATE.FALL
|
||||
|
||||
STATE.WANDER:
|
||||
# print (_animated_sprite.animation ) # apparentl playing doesn't stop when loop is disabled.
|
||||
# Transitions
|
||||
if velocity.y == -JUMP_SPEED:
|
||||
print("STATE_TRANSITION: Jump")
|
||||
player_last_state = STATE.WANDER
|
||||
player_state = STATE.JUMP
|
||||
elif velocity.x == 0:
|
||||
print("STATE_TRANSITION: Idle")
|
||||
player_last_state = STATE.WANDER
|
||||
player_state = STATE.IDLE
|
||||
# Animation
|
||||
if player_last_state != STATE.WANDER:
|
||||
$IdleTimeout.start()
|
||||
_animated_sprite.play("walk")
|
||||
player_last_state = STATE.WANDER
|
||||
if $IdleTimeout.time_left == 0:
|
||||
$IdleTimeout.start()
|
||||
velocity.x = 0
|
||||
player_last_state = STATE.WANDER
|
||||
player_state = STATE.IDLE
|
||||
|
||||
STATE.ATTACK:
|
||||
# Animation
|
||||
if player_last_state != STATE.ATTACK:
|
||||
$IdleTimeout.start()
|
||||
_animated_sprite.play("attack")
|
||||
player_last_state = STATE.ATTACK
|
||||
if $IdleTimeout.time_left == 0:
|
||||
$IdleTimeout.start()
|
||||
velocity.x = 0
|
||||
player_last_state = STATE.ATTACK
|
||||
player_state = STATE.IDLE
|
||||
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
animation_play_finished = true
|
||||
#print($AnimatedSprite.animation," anim over ", $IdleTimeout.time_left, animation_play_finished)
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
[gd_scene load_steps=24 format=2]
|
||||
|
||||
[ext_resource path="res://src/enemy/Enemy-KinematicBody2D.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StreamTexture" id=75]
|
||||
load_path = "res://.import/botEnemy.png-46efd539a38730ff15fb4ddb087329c6.stex"
|
||||
|
||||
[sub_resource type="AtlasTexture" id=76]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=77]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=78]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 48, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=79]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 96, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=80]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 144, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=81]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=82]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 48, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=83]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 96, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=84]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=85]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=86]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 48, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=87]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 96, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=88]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 144, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=89]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=90]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=91]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 48, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=92]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 96, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=93]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 144, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=94]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ) ],
|
||||
"loop": true,
|
||||
"name": "attack",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 81 ), SubResource( 82 ), SubResource( 83 ) ],
|
||||
"loop": true,
|
||||
"name": "death",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 84 ) ],
|
||||
"loop": true,
|
||||
"name": "hurt",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 85 ), SubResource( 86 ), SubResource( 87 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 88 ), SubResource( 89 ), SubResource( 90 ), SubResource( 91 ), SubResource( 92 ), SubResource( 93 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 10.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=74]
|
||||
extents = Vector2( 12, 18.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=95]
|
||||
extents = Vector2( 9, 16.5 )
|
||||
|
||||
[node name="Enemy" type="KinematicBody2D"]
|
||||
collision_layer = 4
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 8, -8 )
|
||||
frames = SubResource( 94 )
|
||||
animation = "idle"
|
||||
playing = true
|
||||
flip_h = true
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
"o_ex_p": "",
|
||||
"o_folder": "res://assets",
|
||||
"o_name": "",
|
||||
"only_visible": true,
|
||||
"op_exp": false,
|
||||
"slice": "",
|
||||
"source": "E:/Godot/Art/botEnemy.aseprite"
|
||||
}
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( -1, -3.5 )
|
||||
shape = SubResource( 74 )
|
||||
|
||||
[node name="IdleTimeout" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
|
||||
[node name="PlayerDetection" type="RayCast2D" parent="."]
|
||||
enabled = true
|
||||
cast_to = Vector2( 20, 0 )
|
||||
collision_mask = 2
|
||||
|
||||
[node name="HurtHitbox" type="Area2D" parent="."]
|
||||
collision_layer = 160
|
||||
collision_mask = 64
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="HurtHitbox"]
|
||||
modulate = Color( 1, 0, 0, 1 )
|
||||
position = Vector2( -1, -3.5 )
|
||||
shape = SubResource( 95 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
||||
|
|
@ -68,7 +68,7 @@ func set_hitbox(enabled: bool):
|
|||
|
||||
func shoot_projectile():
|
||||
var is_shooting = false
|
||||
is_shooting = gun.shoot(direction.x)
|
||||
is_shooting = gun.shoot(transform.x.x)
|
||||
|
||||
|
||||
func _on_Hurtbox_body_entered(body):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=35 format=2]
|
||||
[gd_scene load_steps=34 format=2]
|
||||
|
||||
[ext_resource path="res://src/enemyB/Enemy2-KinematicBody2D.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/enemyB/states/fall.gd" type="Script" id=2]
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
[ext_resource path="res://src/enemyB/states/wander.gd" type="Script" id=6]
|
||||
[ext_resource path="res://src/enemyB/states/idle.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/enemyB/states/attack.gd" type="Script" id=8]
|
||||
[ext_resource path="res://src/playerB/Gun.gd" type="Script" id=9]
|
||||
[ext_resource path="res://src/enemyB/states/hurt.gd" type="Script" id=10]
|
||||
[ext_resource path="res://src/enemyB/enemy_move_component.gd" type="Script" id=11]
|
||||
|
||||
|
|
@ -132,7 +131,7 @@ script = ExtResource( 1 )
|
|||
position = Vector2( 8, -8 )
|
||||
frames = SubResource( 168 )
|
||||
animation = "idle"
|
||||
frame = 1
|
||||
frame = 2
|
||||
playing = true
|
||||
flip_h = true
|
||||
__meta__ = {
|
||||
|
|
@ -224,20 +223,6 @@ self_modulate = Color( 1, 0, 0, 1 )
|
|||
position = Vector2( 0, -1 )
|
||||
shape = SubResource( 148 )
|
||||
|
||||
[node name="Gun" type="Position2D" parent="."]
|
||||
physics_interpolation_mode = 1
|
||||
position = Vector2( 25, -5 )
|
||||
script = ExtResource( 9 )
|
||||
|
||||
[node name="Cooldown" type="Timer" parent="Gun"]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[node name="Line2D" type="Line2D" parent="Gun"]
|
||||
points = PoolVector2Array( -5, 0, 5, 0 )
|
||||
width = 2.0
|
||||
default_color = Color( 1, 0.607843, 0, 1 )
|
||||
|
||||
[node name="PlayerDetection" type="RayCast2D" parent="."]
|
||||
enabled = true
|
||||
cast_to = Vector2( 20, 0 )
|
||||
|
|
|
|||
201
src/enemyC/EnemyC.tscn
Normal file
201
src/enemyC/EnemyC.tscn
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
[gd_scene load_steps=29 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]
|
||||
[ext_resource path="res://src/enemyC/attack.gd" type="Script" id=3]
|
||||
[ext_resource path="res://src/components/Hitbox_Component.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://src/components/GenericSender.tscn" type="PackedScene" id=5]
|
||||
|
||||
[sub_resource type="StreamTexture" id=1]
|
||||
load_path = "res://.import/botEnemy.png-46efd539a38730ff15fb4ddb087329c6.stex"
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 192, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 0, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 48, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 96, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=6]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 144, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=7]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 0, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 48, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 96, 144, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 192, 96, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 0, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 48, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 96, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=14]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 144, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=15]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 192, 0, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=16]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 0, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=17]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 48, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=18]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 96, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=19]
|
||||
atlas = SubResource( 1 )
|
||||
region = Rect2( 144, 48, 48, 48 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=20]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ],
|
||||
"loop": true,
|
||||
"name": "attack",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ],
|
||||
"loop": true,
|
||||
"name": "death",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 10 ) ],
|
||||
"loop": true,
|
||||
"name": "hurt",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 10.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=22]
|
||||
extents = Vector2( 10, 16 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=23]
|
||||
extents = Vector2( 9, 3.5 )
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=24]
|
||||
height = 10.0
|
||||
|
||||
[node name="EnemyC" instance=ExtResource( 1 )]
|
||||
actor_type = "Enemy"
|
||||
|
||||
[node name="AnimatedSprite" parent="." index="0"]
|
||||
position = Vector2( 11, -7 )
|
||||
frames = SubResource( 20 )
|
||||
animation = "idle"
|
||||
frame = 1
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
"o_ex_p": "",
|
||||
"o_folder": "res://assets",
|
||||
"o_name": "",
|
||||
"only_visible": true,
|
||||
"op_exp": false,
|
||||
"slice": "",
|
||||
"source": "E:/Godot/Art/botEnemy.aseprite"
|
||||
}
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="1"]
|
||||
position = Vector2( -0.5, -2 )
|
||||
|
||||
[node name="movement_component" parent="." index="2"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="IdleTimeout" type="Timer" parent="movement_component" index="0"]
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
||||
[node name="idle" parent="movement_state_machine" index="0"]
|
||||
animation_sequence = [ "idle" ]
|
||||
|
||||
[node name="fall" parent="movement_state_machine" index="1"]
|
||||
animation_sequence = [ "idle" ]
|
||||
|
||||
[node name="attack" type="Node" parent="movement_state_machine" index="2"]
|
||||
script = ExtResource( 3 )
|
||||
debug_state = true
|
||||
timeout_seconds = 2.0
|
||||
animation_sequence = [ "attack" ]
|
||||
fall_node = NodePath("../fall")
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="move" parent="movement_state_machine" index="3"]
|
||||
animation_sequence = [ "walk" ]
|
||||
|
||||
[node name="CollisionShape2D" parent="Hurtbox_Component" index="0"]
|
||||
position = Vector2( -1, -2 )
|
||||
shape = SubResource( 22 )
|
||||
|
||||
[node name="EdgeDetection" type="RayCast2D" parent="." index="6"]
|
||||
modulate = Color( 0.054902, 1, 0, 1 )
|
||||
show_behind_parent = true
|
||||
position = Vector2( 15, 3 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 17 )
|
||||
collide_with_areas = true
|
||||
|
||||
[node name="PlayerDetection" type="RayCast2D" parent="." index="7"]
|
||||
enabled = true
|
||||
cast_to = Vector2( 21, 0 )
|
||||
collision_mask = 2
|
||||
|
||||
[node name="Hitbox_Component" parent="." index="8" instance=ExtResource( 4 )]
|
||||
damage_amount = 10
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="0"]
|
||||
modulate = Color( 1, 0.596078, 0.121569, 1 )
|
||||
position = Vector2( 18, -8.5 )
|
||||
shape = SubResource( 23 )
|
||||
disabled = true
|
||||
|
||||
[node name="GenericSender" parent="." index="9" instance=ExtResource( 5 )]
|
||||
receiver_node_name = "GenericReceiver"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GenericSender" index="0"]
|
||||
position = Vector2( 48, 0 )
|
||||
shape = SubResource( 24 )
|
||||
42
src/enemyC/attack.gd
Normal file
42
src/enemyC/attack.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
# parent.set_hurtbox(true)
|
||||
if state_timeout:
|
||||
state_timeout.start()
|
||||
move_component.velocity.x = 0
|
||||
if debug_state:
|
||||
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
|
||||
|
||||
func process_frame(_delta: float) -> State:
|
||||
if move_component.wants_shoot() == false and state_timeout.time_left == 0:
|
||||
return idle_state
|
||||
|
||||
# if animations.frame > 1:
|
||||
# parent.set_hitbox(true)
|
||||
# else:
|
||||
# parent.set_hitbox(false)
|
||||
|
||||
|
||||
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))
|
||||
|
||||
move_actor_as_desired(delta)
|
||||
|
||||
if !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
45
src/enemyC/enemyC_movement_component.gd
Normal file
45
src/enemyC/enemyC_movement_component.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
extends MovementComponent
|
||||
|
||||
onready var idle_timeout = $IdleTimeout
|
||||
onready var edge_detector:RayCast2D = $"../EdgeDetection"
|
||||
onready var player_detector:RayCast2D = $"../PlayerDetection"
|
||||
|
||||
var flip_flop = false
|
||||
var wants_to_attack = false
|
||||
|
||||
func process_physics(delta):
|
||||
if current_movement_state == "move" and edge_detector.is_colliding() == false:
|
||||
#print(owner.name, "uh oh gonna fall!")
|
||||
stop()
|
||||
return
|
||||
if player_detector.is_colliding():
|
||||
#print(owner.name, " wants to attack")
|
||||
stop()
|
||||
wants_to_attack = true
|
||||
if attack_function.is_valid():
|
||||
attack_function.call_func()
|
||||
return
|
||||
else:
|
||||
wants_to_attack = false
|
||||
|
||||
func process(delta):
|
||||
if current_movement_state == "idle" and idle_timeout.time_left == 0:
|
||||
if debug_component:
|
||||
print ("Time to move!")
|
||||
if flip_flop:
|
||||
flip_flop = false
|
||||
go_right()
|
||||
idle_timeout.start()
|
||||
else:
|
||||
flip_flop = true
|
||||
go_left()
|
||||
idle_timeout.start()
|
||||
if current_movement_state == "move" and idle_timeout.time_left == 0:
|
||||
if debug_component:
|
||||
print("Time to stop.")
|
||||
idle_timeout.start()
|
||||
stop()
|
||||
return
|
||||
|
||||
func wants_shoot() -> bool:
|
||||
return wants_to_attack
|
||||
45
src/enemyC/states/idle.gd
Normal file
45
src/enemyC/states/idle.gd
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
extends "res://src/templates/Actor/states/idle.gd"
|
||||
|
||||
|
||||
var debugTimeTracker := 0.0
|
||||
|
||||
export (NodePath) var wander_node
|
||||
export (NodePath) var attack_node
|
||||
|
||||
onready var wander_state: State = get_node(wander_node)
|
||||
onready var attack_state: State = get_node(attack_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.set_hurtbox(true)
|
||||
parent.velocity.x = 0
|
||||
state_timeout.start()
|
||||
|
||||
func process_frame(_delta: float) -> State:# if get_jump() and parent.is_on_floor():
|
||||
# return jump_state
|
||||
|
||||
if state_timeout.time_left == 0:
|
||||
return wander_state
|
||||
|
||||
# move_component.wants_jump()
|
||||
move_component.get_movement_direction()
|
||||
|
||||
# if Input.is_action_just_pressed('dash'):
|
||||
# return dash_state
|
||||
return null
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
debugTimeTracker += delta
|
||||
if debugTimeTracker > 2:
|
||||
debugTimeTracker = 0.0
|
||||
print("DEBUG TRANSFORM:", parent.transform)
|
||||
|
||||
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 !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
58
src/enemyC/states/wander.gd
Normal file
58
src/enemyC/states/wander.gd
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var attack_node
|
||||
export (NodePath) var fall_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
onready var attack_state: State = get_node(attack_node)
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
|
||||
var flip_flop = false
|
||||
|
||||
func enter(state_modifiers: Array = []) -> void:
|
||||
.enter()
|
||||
parent.set_hurtbox(true)
|
||||
state_timeout.start()
|
||||
if flip_flop:
|
||||
flip_flop = false
|
||||
move_component.desired_movement_vector.x = 1.0
|
||||
else:
|
||||
flip_flop = true
|
||||
move_component.desired_movement_vector.x = -1.0
|
||||
|
||||
func process_frame(_delta: float) -> State:
|
||||
|
||||
# if parent.player_detection.is_colliding():
|
||||
# return attack_state
|
||||
|
||||
if state_timeout.time_left == 0:
|
||||
return idle_state
|
||||
|
||||
# if move_component.wants_jump() and parent.is_on_floor():
|
||||
# return jump_state
|
||||
#
|
||||
# move_component.get_movement_direction()
|
||||
return null
|
||||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
|
||||
parent.velocity.y += gravity * delta
|
||||
|
||||
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
|
||||
if parent.velocity.x == 0.0:
|
||||
return idle_state
|
||||
else:
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
parent.transform.x.x = parent.direction.x
|
||||
|
||||
if !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
64
src/movement_component.gd
Normal file
64
src/movement_component.gd
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
class_name MovementComponent
|
||||
extends Node
|
||||
|
||||
## Movement component
|
||||
# attempts to interact with movement of the scene root without knowing what
|
||||
# it is. It can be perhaps a static body or kinematicbody
|
||||
# it doesn't actually move a node, that's what the state machine does
|
||||
# but it does keep track of velocity
|
||||
# I can't give it an actor node or a direct reference.
|
||||
# It can use a number of detection components to help inform decisions.
|
||||
|
||||
export var debug_component: bool = false
|
||||
|
||||
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
||||
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)
|
||||
|
||||
#Can't use floats here, switched to constants.
|
||||
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
|
||||
|
||||
var attack_function: FuncRef
|
||||
|
||||
const UP = -1.0
|
||||
const DOWN = 1.0
|
||||
const LEFT = -1.0
|
||||
const RIGHT = 1.0
|
||||
|
||||
func process_physics(delta):
|
||||
pass
|
||||
|
||||
func process(delta):
|
||||
pass
|
||||
|
||||
func process_input(event: InputEvent):
|
||||
pass
|
||||
|
||||
# A Series of helper functions
|
||||
func go_up():
|
||||
desired_movement_vector.y = UP
|
||||
func go_down():
|
||||
desired_movement_vector.y = DOWN
|
||||
func go_left():
|
||||
desired_movement_vector.x = LEFT
|
||||
func go_right():
|
||||
desired_movement_vector.x = RIGHT
|
||||
func stop():
|
||||
desired_movement_vector = Vector2(0,0)
|
||||
|
||||
# Return the desired direction of movement for the character
|
||||
# in the range [-1, 1], where positive values indicate a desire
|
||||
# to move to the right and negative values to the left.
|
||||
func get_movement_direction() -> float:
|
||||
return desired_movement_vector.x
|
||||
|
||||
# Return a boolean indicating if the character wants to jump
|
||||
func wants_jump() -> bool:
|
||||
return false
|
||||
|
||||
# Return a boolean indicating if the character wants to attack
|
||||
func wants_shoot() -> bool:
|
||||
return false
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2(0,0)
|
||||
var direction = Vector2(0,0)
|
||||
|
||||
export var player_number: int = 1
|
||||
|
||||
onready var movement_animations: AnimatedSprite = $AnimatedSprite
|
||||
|
||||
onready var movement_state_machine: Node = $Controllers/state_machine
|
||||
|
||||
onready var player_move_component = $Controllers/move_component
|
||||
|
||||
onready var player_hurtbox = $Hurtbox/CollisionShape2D
|
||||
|
||||
onready var gun = $Gun
|
||||
|
||||
func _ready() -> void:
|
||||
movement_state_machine.init(self, movement_animations, player_move_component)
|
||||
player_move_component.player_number = player_number
|
||||
|
||||
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))
|
||||
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
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
movement_state_machine.process_frame(delta)
|
||||
PlayerInfo.player_position = global_position
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
if movement_animations.frames.get_animation_loop(movement_animations.animation) == false:
|
||||
movement_state_machine.current_state.animation_index += 1
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
print("Ouch.",area)
|
||||
movement_state_machine.change_state($Controllers/state_machine/hurt)
|
||||
|
||||
func set_hurtbox(enabled: bool):
|
||||
#player_hurtbox.disabled = enabled #nope
|
||||
player_hurtbox.set_deferred("disabled", !enabled) #WTF Apparently this is how to do it
|
||||
#$Hurtbox.monitoring = enabled #nope
|
||||
#$Hurtbox.set_deferred("monitoring", enabled) #works
|
||||
#$Hurtbox.monitoring = false #nope
|
||||
#$Hurtbox.set_monitoring(enabled) # Nope
|
||||
|
||||
func shoot_projectile():
|
||||
var is_shooting = false
|
||||
is_shooting = gun.shoot(direction.x)
|
||||
|
||||
#func _ready():
|
||||
# # Static types are necessary here to avoid warnings.
|
||||
# var camera: Camera2D = $Camera2D
|
||||
# camera.custom_viewport = $"../.."
|
||||
# yield(get_tree(), "idle_frame")
|
||||
# camera.make_current()
|
||||
|
||||
#
|
||||
#func _physics_process(delta):
|
||||
# # Horizontal movement
|
||||
# velocity.x = (Input.get_axis("ui_left", "ui_right") * WALK_MAX_SPEED)
|
||||
#
|
||||
# # Vertical movement code. Apply gravity.
|
||||
# velocity.y += gravity * delta
|
||||
#
|
||||
# # Move based on the velocity and snap to the ground.
|
||||
# #velocity = move_and_slide_with_snap(velocity, Vector2.DOWN, Vector2.UP)
|
||||
# velocity = move_and_slide(velocity, Vector2(0, -1))
|
||||
#
|
||||
# # Check for jumping. is_on_floor() must be called after movement code.
|
||||
# # Apply Jump velocity
|
||||
# if is_on_floor() and Input.is_action_just_pressed("ui_accept"):
|
||||
# velocity.y = -JUMP_SPEED
|
||||
#
|
||||
# # Animate based on last state and velocity
|
||||
# if velocity.x > 0 and _animated_sprite.flip_h != true:
|
||||
# _animated_sprite.flip_h = true
|
||||
# if velocity.x < 0 and _animated_sprite.flip_h != false:
|
||||
# _animated_sprite.flip_h = false
|
||||
#
|
||||
# # forced state changes like falling an gitting hurt
|
||||
# if velocity.y > 0 and player_state != STATE.JUMP and player_state != STATE.FALL:
|
||||
# print("STATE_TRANSITION: Fall")
|
||||
# player_state = STATE.FALL
|
||||
#
|
||||
#
|
||||
# # Each state should trigger its own animation
|
||||
# match player_state:
|
||||
# STATE.IDLE:
|
||||
# # Transitions
|
||||
# if velocity.y == -JUMP_SPEED:
|
||||
# print("STATE_TRANSITION: Jump")
|
||||
# player_last_state = STATE.IDLE
|
||||
# player_state = STATE.JUMP
|
||||
# elif velocity.x != 0:
|
||||
# print("STATE_TRANSITION: Run")
|
||||
# player_last_state = STATE.IDLE
|
||||
# player_state = STATE.RUN
|
||||
# # Animation
|
||||
# if player_last_state != STATE.IDLE:
|
||||
# $IdleTimeout.start()
|
||||
# _animated_sprite.play("idle")
|
||||
# player_last_state = STATE.IDLE
|
||||
# if $IdleTimeout.time_left == 0 and _animated_sprite.animation != 'blink':
|
||||
# _animated_sprite.play("blink")
|
||||
# animation_play_finished = false
|
||||
# if $IdleTimeout.time_left == 0 and animation_play_finished == true:
|
||||
# $IdleTimeout.start()
|
||||
# _animated_sprite.play("idle")
|
||||
# print("blink over")
|
||||
#
|
||||
# STATE.JUMP:
|
||||
# # Transitions
|
||||
# if is_on_floor():
|
||||
# print("STATE_TRANSITION: Idle")
|
||||
# _animated_sprite.play("idle")
|
||||
# player_last_state = STATE.JUMP
|
||||
# player_state = STATE.IDLE
|
||||
# # Animation
|
||||
# if player_last_state != STATE.JUMP:
|
||||
# _animated_sprite.play("jump")
|
||||
# player_last_state = STATE.JUMP
|
||||
#
|
||||
# STATE.FALL:
|
||||
# # Transitions
|
||||
# if is_on_floor():
|
||||
# print("STATE_TRANSITION: Idle")
|
||||
# _animated_sprite.play("idle")
|
||||
# player_last_state = STATE.FALL
|
||||
# player_state = STATE.IDLE
|
||||
# # Animation
|
||||
# if player_last_state != STATE.FALL:
|
||||
# _animated_sprite.animation = "jump"
|
||||
# _animated_sprite.frame = 8
|
||||
# _animated_sprite.stop()
|
||||
# player_last_state = STATE.FALL
|
||||
#
|
||||
# STATE.RUN:
|
||||
# # print (_animated_sprite.animation ) # apparentl playing doesn't stop when loop is disabled.
|
||||
# # Transitions
|
||||
# if velocity.y == -JUMP_SPEED:
|
||||
# print("STATE_TRANSITION: Jump")
|
||||
# _animated_sprite.play("jump")
|
||||
# player_last_state = STATE.RUN
|
||||
# player_state = STATE.JUMP
|
||||
# elif velocity.x == 0:
|
||||
# print("STATE_TRANSITION: Idle")
|
||||
# _animated_sprite.play("idle")
|
||||
# player_last_state = STATE.RUN
|
||||
# player_state = STATE.IDLE
|
||||
# # Animation
|
||||
# if player_last_state == STATE.IDLE:
|
||||
# _animated_sprite.play("step")
|
||||
# animation_play_finished = false
|
||||
# player_last_state = STATE.RUN
|
||||
# elif animation_play_finished == true:
|
||||
# _animated_sprite.play("run")
|
||||
# animation_play_finished = false
|
||||
#
|
||||
#
|
||||
#func _on_AnimatedSprite_animation_finished():
|
||||
# animation_play_finished = true
|
||||
# print($AnimatedSprite.animation," anim over ", $IdleTimeout.time_left, animation_play_finished)
|
||||
|
||||
|
||||
|
|
@ -1,512 +0,0 @@
|
|||
[gd_scene load_steps=86 format=2]
|
||||
|
||||
[ext_resource path="res://src/playerB/Player-KinematicBody2D.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/playerB/states/idle.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/state_machine.gd" type="Script" id=3]
|
||||
[ext_resource path="res://src/playerB/states/fall.gd" type="Script" id=4]
|
||||
[ext_resource path="res://src/playerB/states/move.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/playerB/player_move_component.gd" type="Script" id=6]
|
||||
[ext_resource path="res://src/playerB/states/jump.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/playerB/states/hurt.gd" type="Script" id=8]
|
||||
[ext_resource path="res://src/playerB/Gun.gd" type="Script" id=9]
|
||||
[ext_resource path="res://src/playerB/states/fire.gd" type="Script" id=10]
|
||||
|
||||
[sub_resource type="StreamTexture" id=75]
|
||||
load_path = "res://.import/MegaMan.png-dc2c293e5a0f5d183ee961942ac90e4a.stex"
|
||||
|
||||
[sub_resource type="AtlasTexture" id=76]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=77]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=78]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=79]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=80]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=81]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=82]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=83]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=84]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=85]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=86]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=87]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=88]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=89]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=90]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=91]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=92]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=93]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=94]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=95]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=96]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=97]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=98]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=99]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=100]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=101]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=102]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=103]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=104]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 320, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=105]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=106]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=107]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=108]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=109]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=110]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=111]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=112]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=113]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=114]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=115]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=116]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=117]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=118]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=119]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=120]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=121]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=122]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=123]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=124]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 192, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=125]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=126]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=127]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=128]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=129]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 320, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=130]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 384, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=131]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 448, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=132]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=133]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=134]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 384, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=135]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=136]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 448, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=137]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 512, 64, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=138]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 0, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=139]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=140]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=141]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=142]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 128, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=143]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 64, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=144]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 128, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=145]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 192, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=146]
|
||||
atlas = SubResource( 75 )
|
||||
region = Rect2( 256, 256, 64, 64 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=147]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 76 ), SubResource( 77 ), SubResource( 78 ) ],
|
||||
"loop": true,
|
||||
"name": "blink",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 79 ), SubResource( 80 ), SubResource( 81 ), SubResource( 82 ) ],
|
||||
"loop": true,
|
||||
"name": "climb",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 83 ), SubResource( 84 ) ],
|
||||
"loop": true,
|
||||
"name": "climb_end",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 85 ) ],
|
||||
"loop": true,
|
||||
"name": "climb_fire",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 86 ), SubResource( 87 ), SubResource( 88 ), SubResource( 86 ) ],
|
||||
"loop": true,
|
||||
"name": "fire",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 89 ), SubResource( 90 ), SubResource( 89 ), SubResource( 91 ), SubResource( 92 ) ],
|
||||
"loop": true,
|
||||
"name": "hit",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 76 ), SubResource( 77 ), SubResource( 78 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 93 ), SubResource( 94 ), SubResource( 95 ), SubResource( 96 ), SubResource( 97 ), SubResource( 98 ), SubResource( 98 ), SubResource( 97 ), SubResource( 96 ), SubResource( 95 ), SubResource( 94 ), SubResource( 93 ) ],
|
||||
"loop": true,
|
||||
"name": "jump",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 99 ), SubResource( 100 ), SubResource( 101 ), SubResource( 102 ), SubResource( 103 ), SubResource( 104 ) ],
|
||||
"loop": true,
|
||||
"name": "jump_fire",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 105 ), SubResource( 106 ), SubResource( 105 ), SubResource( 76 ), SubResource( 107 ) ],
|
||||
"loop": true,
|
||||
"name": "look",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 93 ), SubResource( 108 ), SubResource( 109 ), SubResource( 110 ), SubResource( 111 ), SubResource( 112 ), SubResource( 113 ), SubResource( 114 ), SubResource( 115 ), SubResource( 116 ) ],
|
||||
"loop": true,
|
||||
"name": "run",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 99 ), SubResource( 117 ), SubResource( 118 ), SubResource( 119 ), SubResource( 120 ), SubResource( 121 ), SubResource( 122 ), SubResource( 123 ), SubResource( 124 ), SubResource( 125 ) ],
|
||||
"loop": true,
|
||||
"name": "run_fire",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 126 ), SubResource( 127 ), SubResource( 126 ), SubResource( 128 ) ],
|
||||
"loop": true,
|
||||
"name": "slide",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 129 ), SubResource( 130 ), SubResource( 131 ) ],
|
||||
"loop": true,
|
||||
"name": "slide_hit",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 132 ) ],
|
||||
"loop": false,
|
||||
"name": "step",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 133 ) ],
|
||||
"loop": true,
|
||||
"name": "stepfire",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 134 ), SubResource( 135 ), SubResource( 136 ), SubResource( 135 ) ],
|
||||
"loop": true,
|
||||
"name": "stun",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 137 ), SubResource( 138 ), SubResource( 139 ), SubResource( 140 ), SubResource( 141 ), SubResource( 142 ) ],
|
||||
"loop": true,
|
||||
"name": "teleport",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [ SubResource( 143 ), SubResource( 144 ), SubResource( 145 ), SubResource( 146 ) ],
|
||||
"loop": true,
|
||||
"name": "throw",
|
||||
"speed": 10.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=74]
|
||||
extents = Vector2( 14, 18.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=148]
|
||||
extents = Vector2( 11.5, 14.5 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 147 )
|
||||
animation = "idle"
|
||||
frame = 20
|
||||
playing = true
|
||||
flip_h = true
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
"o_ex_p": "",
|
||||
"o_folder": "res://assets",
|
||||
"o_name": "",
|
||||
"only_visible": true,
|
||||
"op_exp": false,
|
||||
"slice": "",
|
||||
"source": "E:/Godot/Art/MegaMan.aseprite"
|
||||
}
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, -3.5 )
|
||||
shape = SubResource( 74 )
|
||||
|
||||
[node name="Controllers" type="Node" parent="."]
|
||||
|
||||
[node name="state_machine" type="Node" parent="Controllers"]
|
||||
script = ExtResource( 3 )
|
||||
starting_state = NodePath("idle")
|
||||
|
||||
[node name="idle" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 2 )
|
||||
animation_name = "idle"
|
||||
move_speed = 90.0
|
||||
jump_node = NodePath("../jump")
|
||||
fall_node = NodePath("../fall")
|
||||
move_node = NodePath("../move")
|
||||
fire_node = NodePath("../fire")
|
||||
|
||||
[node name="jump" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 7 )
|
||||
animation_name = "jump"
|
||||
move_speed = 90.0
|
||||
idle_node = NodePath("../idle")
|
||||
fall_node = NodePath("../fall")
|
||||
move_node = NodePath("../move")
|
||||
jump_force = 270.0
|
||||
|
||||
[node name="move" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 5 )
|
||||
move_speed = 90.0
|
||||
animation_sequence = [ "step", "run" ]
|
||||
jump_node = NodePath("../jump")
|
||||
fall_node = NodePath("../fall")
|
||||
idle_node = NodePath("../idle")
|
||||
dash_node = NodePath(".")
|
||||
|
||||
[node name="fall" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 4 )
|
||||
animation_name = "jump"
|
||||
move_speed = 90.0
|
||||
idle_node = NodePath("../idle")
|
||||
move_node = NodePath("../move")
|
||||
|
||||
[node name="hurt" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 8 )
|
||||
animation_name = "hit"
|
||||
move_speed = -25.0
|
||||
timeout_seconds = 1.0
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="fire" type="Node" parent="Controllers/state_machine"]
|
||||
script = ExtResource( 10 )
|
||||
animation_name = "fire"
|
||||
timeout_seconds = 1.0
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="move_component" type="Node" parent="Controllers"]
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="Hurtbox" type="Area2D" parent="."]
|
||||
collision_layer = 16
|
||||
collision_mask = 128
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
|
||||
self_modulate = Color( 1, 0, 0, 1 )
|
||||
position = Vector2( 0, -4 )
|
||||
shape = SubResource( 148 )
|
||||
|
||||
[node name="Gun" type="Position2D" parent="."]
|
||||
physics_interpolation_mode = 1
|
||||
position = Vector2( 25, -5 )
|
||||
script = ExtResource( 9 )
|
||||
|
||||
[node name="Cooldown" type="Timer" parent="Gun"]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[node name="Line2D" type="Line2D" parent="Gun"]
|
||||
points = PoolVector2Array( -5, 0, 5, 0 )
|
||||
width = 2.0
|
||||
default_color = Color( 1, 0.607843, 0, 1 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# You could also declare a class_name for the move state
|
||||
# so you don't have to reference the script directly
|
||||
extends 'res://src/state_machine/states/move.gd'
|
||||
|
||||
@export
|
||||
var move_state: State
|
||||
|
||||
@export
|
||||
var time_to_dash := 0.5
|
||||
|
||||
var dash_timer := 0.0
|
||||
var direction := 1.0
|
||||
|
||||
func enter() -> void:
|
||||
super()
|
||||
dash_timer = time_to_dash
|
||||
|
||||
# Simple check for which direction to dash towards
|
||||
if animations.flip_h:
|
||||
direction = -1
|
||||
else:
|
||||
direction = 1
|
||||
|
||||
# Just to be safe, disable any other inputs
|
||||
func process_input(event: InputEvent) -> State:
|
||||
return null
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
dash_timer -= delta
|
||||
if dash_timer <= 0.0:
|
||||
# Fall back on the default input implementation to
|
||||
# determine where to go next
|
||||
if super.get_movement_input() != 0.0:
|
||||
return move_state
|
||||
return idle_state
|
||||
|
||||
# At this point, run 'process_physics' in the move script as written
|
||||
return super(delta)
|
||||
|
||||
# Override movement inputs
|
||||
func get_movement_input() -> float:
|
||||
return direction
|
||||
|
||||
func get_jump() -> bool:
|
||||
return false
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var move_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
onready var move_state: State = get_node(move_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
animations.frame = 6
|
||||
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
move_component.get_movement_direction()
|
||||
return null
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
parent.velocity.y += gravity * delta
|
||||
|
||||
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
|
||||
# if parent.velocity.x != 0.0:
|
||||
# parent.direction.x = parent.velocity.x
|
||||
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
|
||||
if parent.is_on_floor():
|
||||
if parent.velocity.x == 0:
|
||||
return move_state
|
||||
return idle_state
|
||||
return null
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
var can_fire = true
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.set_hurtbox(false)
|
||||
state_timeout.start()
|
||||
can_fire = true
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
# if move_component.get_movement_direction() != 0.0:
|
||||
# return move_state
|
||||
|
||||
# move_component.wants_jump()
|
||||
move_component.get_movement_direction()
|
||||
|
||||
# if Input.is_action_just_pressed('dash'):
|
||||
# return dash_state
|
||||
return null
|
||||
|
||||
func process_frame(delta: float) -> State:
|
||||
if state_timeout.time_left == 0:
|
||||
return idle_state
|
||||
return null
|
||||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
|
||||
if can_fire: # trying to do this in the physics because irrecular behavior
|
||||
parent.shoot_projectile()
|
||||
can_fire = false
|
||||
|
||||
parent.velocity.y += gravity * delta
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
|
||||
# if move_component.flipped_sprite == true:
|
||||
# animations.flip_h = parent.direction.x > 0
|
||||
# else:
|
||||
# animations.flip_h = parent.direction.x < 0
|
||||
|
||||
|
||||
return null
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.velocity.x = 0
|
||||
parent.set_hurtbox(false)
|
||||
#TODO: Error check if timer was actually instanced
|
||||
state_timeout.start()
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
# move_component.wants_jump()
|
||||
move_component.get_movement_direction()
|
||||
|
||||
return null
|
||||
|
||||
|
||||
func process_frame(delta: float) -> State:
|
||||
if state_timeout.time_left == 0:
|
||||
return idle_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))
|
||||
if (parent.direction.x > 0):
|
||||
parent.velocity.x = 1 * move_speed
|
||||
else:
|
||||
parent.velocity.x = -1 * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
|
||||
return null
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var jump_node
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var move_node
|
||||
export (NodePath) var fire_node
|
||||
|
||||
onready var jump_state: State = get_node(jump_node)
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var move_state: State = get_node(move_node)
|
||||
onready var fire_state: State = get_node(fire_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.set_hurtbox(true)
|
||||
parent.velocity.x = 0
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
# if get_jump() and parent.is_on_floor():
|
||||
# return jump_state
|
||||
|
||||
if move_component.wants_jump() and parent.is_on_floor():
|
||||
return jump_state
|
||||
# if move_component.get_movement_direction() != 0.0:
|
||||
# return move_state
|
||||
if move_component.wants_shoot():
|
||||
return fire_state
|
||||
|
||||
# move_component.wants_jump()
|
||||
move_component.get_movement_direction()
|
||||
|
||||
# if Input.is_action_just_pressed('dash'):
|
||||
# return dash_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))
|
||||
|
||||
if parent.velocity.x != 0.0:
|
||||
return move_state
|
||||
|
||||
if !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var move_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var move_state: State = get_node(move_node)
|
||||
|
||||
|
||||
export var jump_force: float = 900.0
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.velocity.y = -jump_force
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
move_component.get_movement_direction()
|
||||
return null
|
||||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
parent.velocity.y += gravity * delta
|
||||
|
||||
if parent.velocity.y > 0:
|
||||
return fall_state
|
||||
|
||||
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
|
||||
if parent.is_on_floor():
|
||||
if parent.velocity.x == 0:
|
||||
return move_state
|
||||
return idle_state
|
||||
|
||||
return null
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
extends State
|
||||
|
||||
export (NodePath) var jump_node
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var dash_node
|
||||
|
||||
onready var jump_state: State = get_node(jump_node)
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
onready var dash_state: State = get_node(dash_node)
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
if move_component.wants_jump() and parent.is_on_floor():
|
||||
return jump_state
|
||||
|
||||
move_component.get_movement_direction()
|
||||
|
||||
return null
|
||||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
# if move_component.wants_jump() and parent.is_on_floor():
|
||||
# return jump_state
|
||||
|
||||
parent.velocity.y += gravity * delta
|
||||
|
||||
# var movement = move_component.get_movement_direction() * move_speed
|
||||
#
|
||||
# # only detecting input not actual movement
|
||||
# if movement == 0:
|
||||
# return idle_state
|
||||
|
||||
# parent.velocity.x = movement
|
||||
# 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 parent.velocity.x == 0.0:
|
||||
return idle_state
|
||||
else:
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
|
||||
|
||||
# Another approach of changing state based on actual achieved velocity
|
||||
# if parent.velocity.x == 0:
|
||||
# return idle_state
|
||||
|
||||
if !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
extends Position2D
|
||||
# Represents a weapon that spawns and shoots bullets.
|
||||
# The Cooldown timer controls the cooldown duration between shots.
|
||||
|
||||
|
||||
const BULLET_VELOCITY = 350
|
||||
const Bullet = preload("res://src/Projectile.tscn")
|
||||
|
||||
#onready var sound_shoot = $Shoot
|
||||
onready var timer = $Cooldown
|
||||
onready var offset_position = Vector2(transform.origin.x, transform.origin.y)
|
||||
|
||||
# This method is only called by Player.gd.
|
||||
func shoot(direction = 1):
|
||||
#self.set_position(Vector2(position.x * direction, position.y))
|
||||
#transform.x = transform.x * direction
|
||||
#Transform2D.FLIP_Y
|
||||
#transform.origin.x = transform.origin.x * direction
|
||||
# if direction < 0:
|
||||
# var t = Transform2D()
|
||||
# # Translation
|
||||
# t.origin = Vector2(position.x * -1, position.y)
|
||||
# transform = t
|
||||
# elif direction > 0:
|
||||
# var t = Transform2D()
|
||||
# # Translation
|
||||
# t.origin = Vector2(position.x, position.y)
|
||||
# transform = t
|
||||
|
||||
print("Fire Debug: ", direction, " Gun position: ", position, transform.origin)
|
||||
# position.x = position.x * direction #shifting position before fire was unreliable
|
||||
if not timer.is_stopped():
|
||||
return false
|
||||
var bullet = Bullet.instance()
|
||||
# if (direction > 0):
|
||||
# bullet.global_position = global_position
|
||||
# else:
|
||||
# bullet.global_position = global_position - Vector2(position.x * 2, 0)
|
||||
bullet.global_position = global_position
|
||||
bullet.linear_velocity = Vector2(direction * BULLET_VELOCITY, 0)
|
||||
|
||||
bullet.set_as_toplevel(true)
|
||||
add_child(bullet)
|
||||
# sound_shoot.play()
|
||||
timer.start()
|
||||
return true
|
||||
|
|
@ -1,66 +1,41 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2(0,0)
|
||||
var direction = Vector2(0,0)
|
||||
extends Actor
|
||||
|
||||
export var player_number: int = 1
|
||||
|
||||
export var sprite_facing_right: bool = true
|
||||
|
||||
onready var movement_animations: AnimatedSprite = $AnimatedSprite
|
||||
|
||||
onready var movement_state_machine: Node = $Controllers/state_machine
|
||||
|
||||
onready var player_move_component = $Controllers/move_component
|
||||
|
||||
onready var player_hurtbox = $Hurtbox_Component/CollisionShape2D
|
||||
|
||||
onready var gun = $Gun
|
||||
|
||||
func _ready() -> void:
|
||||
movement_state_machine.init(self, movement_animations, player_move_component)
|
||||
player_move_component.player_number = player_number
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
movement_state_machine.process_input(event)
|
||||
#var sound_effects = preload("res://src/playerC/resources/sound_effects.tres")
|
||||
|
||||
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))
|
||||
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
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
movement_state_machine.process_frame(delta)
|
||||
PlayerInfo.player_position = global_position
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
if movement_animations.frames.get_animation_loop(movement_animations.animation) == false:
|
||||
movement_state_machine.current_state.animation_index += 1
|
||||
##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
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
print("Ouch.",area)
|
||||
movement_state_machine.change_state($Controllers/state_machine/hurt)
|
||||
func _on_Hurtbox_area_entered():
|
||||
#print("Ouch.",area)
|
||||
movement_state_machine.change_state($movement_state_machine/hurt)
|
||||
|
||||
func set_hurtbox(enabled: bool):
|
||||
#player_hurtbox.disabled = enabled #nope
|
||||
player_hurtbox.set_deferred("disabled", !enabled) #WTF Apparently this is how to do it
|
||||
#$Hurtbox.monitoring = enabled #nope
|
||||
#$Hurtbox.set_deferred("monitoring", enabled) #works
|
||||
#$Hurtbox.monitoring = false #nope
|
||||
#$Hurtbox.set_monitoring(enabled) # Nope
|
||||
pass
|
||||
## TODO: This breaks now I guess because I moved the process functions out to parent class
|
||||
#player_hurtbox.set_deferred("disabled", !enabled) #WTF Apparently this is how to do it
|
||||
|
||||
func shoot_projectile():
|
||||
var is_shooting = false
|
||||
is_shooting = gun.shoot(direction.x)
|
||||
print("Direction: ", transform.x.x)
|
||||
is_shooting = gun.shoot(int(transform.x.x))
|
||||
|
||||
#func play_sound():
|
||||
# sound_effects.stream = "res://assets/Sounds/crappy pew.wav"
|
||||
|
||||
func gotcha(damage):
|
||||
print("oh! You got me for ", damage)
|
||||
|
||||
func heylookatme(sender):
|
||||
print("does it work!")
|
||||
|
|
|
|||
|
|
@ -1,18 +1,26 @@
|
|||
[gd_scene load_steps=88 format=2]
|
||||
[gd_scene load_steps=92 format=2]
|
||||
|
||||
[ext_resource path="res://src/playerC/Player-KinematicBody2D.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/playerC/states/idle.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/state_machine.gd" type="Script" id=3]
|
||||
[ext_resource path="res://assets/Sounds/crappy pew.wav" type="AudioStream" id=3]
|
||||
[ext_resource path="res://src/playerC/states/fall.gd" type="Script" id=4]
|
||||
[ext_resource path="res://src/playerC/states/move.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/playerB/player_move_component.gd" type="Script" id=6]
|
||||
[ext_resource path="res://src/playerC/player_move_component.gd" type="Script" id=6]
|
||||
[ext_resource path="res://src/playerC/states/jump.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/playerC/states/hurt.gd" type="Script" id=8]
|
||||
[ext_resource path="res://src/playerC/Gun.gd" type="Script" id=9]
|
||||
[ext_resource path="res://src/Gun.gd" type="Script" id=9]
|
||||
[ext_resource path="res://src/playerC/states/fire.gd" type="Script" id=10]
|
||||
[ext_resource path="res://src/playerC/states/none.gd" type="Script" id=11]
|
||||
[ext_resource path="res://src/playerC/resources/FrameSounds.gd" type="Script" id=11]
|
||||
[ext_resource path="res://src/components/Hurtbox_Component.tscn" type="PackedScene" id=12]
|
||||
[ext_resource path="res://src/state_modifier.gd" type="Script" id=13]
|
||||
[ext_resource path="res://src/playerC/sm.gd" type="Script" id=14]
|
||||
[ext_resource path="res://src/components/GenericReceiver.tscn" type="PackedScene" id=15]
|
||||
|
||||
[sub_resource type="Resource" id=148]
|
||||
script = ExtResource( 11 )
|
||||
animation_name = "run"
|
||||
frame_number = 6
|
||||
sound = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="StreamTexture" id=75]
|
||||
load_path = "res://.import/MegaMan.png-dc2c293e5a0f5d183ee961942ac90e4a.stex"
|
||||
|
|
@ -407,9 +415,14 @@ animations = [ {
|
|||
[sub_resource type="RectangleShape2D" id=74]
|
||||
extents = Vector2( 14, 18.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=149]
|
||||
extents = Vector2( 10.5, 16.5 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 1 )
|
||||
actor_type = "Player"
|
||||
SoundEffects = [ SubResource( 148 ) ]
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 147 )
|
||||
|
|
@ -433,18 +446,15 @@ __meta__ = {
|
|||
position = Vector2( 0, -3.5 )
|
||||
shape = SubResource( 74 )
|
||||
|
||||
[node name="Controllers" type="Node" parent="."]
|
||||
|
||||
[node name="move_component" type="Node" parent="Controllers"]
|
||||
[node name="movement_component" type="Node" parent="."]
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="state_machine" type="Node" parent="Controllers"]
|
||||
script = ExtResource( 3 )
|
||||
[node name="movement_state_machine" type="Node" parent="."]
|
||||
script = ExtResource( 14 )
|
||||
starting_state = NodePath("idle")
|
||||
|
||||
[node name="idle" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="idle" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 2 )
|
||||
animation_name = "idle"
|
||||
move_speed = 90.0
|
||||
animation_sequence = [ "idle" ]
|
||||
jump_node = NodePath("../jump")
|
||||
|
|
@ -452,9 +462,8 @@ fall_node = NodePath("../fall")
|
|||
move_node = NodePath("../move")
|
||||
fire_node = NodePath("../fire")
|
||||
|
||||
[node name="jump" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="jump" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 7 )
|
||||
animation_name = "jump"
|
||||
move_speed = 90.0
|
||||
animation_sequence = [ "jump" ]
|
||||
idle_node = NodePath("../idle")
|
||||
|
|
@ -462,7 +471,7 @@ fall_node = NodePath("../fall")
|
|||
move_node = NodePath("../move")
|
||||
jump_force = 270.0
|
||||
|
||||
[node name="move" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="move" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 5 )
|
||||
move_speed = 90.0
|
||||
animation_sequence = [ "step", "run" ]
|
||||
|
|
@ -471,25 +480,22 @@ fall_node = NodePath("../fall")
|
|||
idle_node = NodePath("../idle")
|
||||
dash_node = NodePath(".")
|
||||
|
||||
[node name="fall" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="fall" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 4 )
|
||||
animation_name = "jump"
|
||||
move_speed = 90.0
|
||||
animation_sequence = [ "jump" ]
|
||||
idle_node = NodePath("../idle")
|
||||
move_node = NodePath("../move")
|
||||
|
||||
[node name="hurt" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="hurt" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 8 )
|
||||
animation_name = "hit"
|
||||
move_speed = -25.0
|
||||
timeout_seconds = 1.0
|
||||
move_speed = -25.0
|
||||
animation_sequence = [ "hit" ]
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="fire" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="fire" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 10 )
|
||||
animation_name = "fire"
|
||||
timeout_seconds = 1.0
|
||||
animation_sequence = [ "fire" ]
|
||||
jump_node = NodePath("../jump")
|
||||
|
|
@ -497,19 +503,22 @@ idle_node = NodePath("../idle")
|
|||
fall_node = NodePath("../fall")
|
||||
move_node = NodePath("../move")
|
||||
|
||||
[node name="attack" type="Node" parent="Controllers/state_machine"]
|
||||
[node name="attack" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 13 )
|
||||
animation_name = "_fire"
|
||||
timeout_seconds = 2.0
|
||||
animation_suffix = true
|
||||
|
||||
[node name="AttackStateMachine" type="Node" parent="Controllers"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="none" type="Node" parent="Controllers/AttackStateMachine"]
|
||||
script = ExtResource( 11 )
|
||||
|
||||
[node name="Hurtbox_Component" parent="." instance=ExtResource( 12 )]
|
||||
collision_layer = 32768
|
||||
collision_mask = 128
|
||||
monitoring = false
|
||||
hurtbox_entered_function = "gotcha"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox_Component"]
|
||||
modulate = Color( 1, 0, 0, 1 )
|
||||
position = Vector2( 0.5, -3.5 )
|
||||
shape = SubResource( 149 )
|
||||
|
||||
[node name="Gun" type="Position2D" parent="."]
|
||||
physics_interpolation_mode = 1
|
||||
|
|
@ -525,4 +534,7 @@ points = PoolVector2Array( -5, 0, 5, 0 )
|
|||
width = 2.0
|
||||
default_color = Color( 1, 0.607843, 0, 1 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
||||
[node name="SE_Player" type="AudioStreamPlayer" parent="."]
|
||||
|
||||
[node name="GenericReceiver" parent="." instance=ExtResource( 15 )]
|
||||
body_entered_function = "heylookatme"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
class_name Movement
|
||||
extends Node
|
||||
extends MovementComponent
|
||||
|
||||
export var flipped_sprite: bool = true
|
||||
## Deprecated
|
||||
#export var flipped_sprite: bool = true
|
||||
|
||||
export var player_number: int = 1
|
||||
|
||||
var desired_movement_vector: Vector2
|
||||
|
||||
# Return the desired direction of movement for the character
|
||||
# in the range [-1, 1], where positive values indicate a desire
|
||||
# to move to the right and negative values to the left.
|
||||
9
src/playerC/resources/FrameSounds.gd
Normal file
9
src/playerC/resources/FrameSounds.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class_name FrameSoundEffects
|
||||
extends Resource
|
||||
|
||||
#export(Array, Array, AudioStreamSample) var sound_effects
|
||||
|
||||
export (String) var animation_name
|
||||
export(int) var frame_number
|
||||
export (AudioStreamSample) var sound
|
||||
|
||||
8
src/playerC/resources/TestFrameSounds.tres
Normal file
8
src/playerC/resources/TestFrameSounds.tres
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/playerC/resources/FrameSounds.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
animation_name = ""
|
||||
frame_number = 0
|
||||
3
src/playerC/resources/new_audiostreamsample.tres
Normal file
3
src/playerC/resources/new_audiostreamsample.tres
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[gd_resource type="AudioStreamSample" format=2]
|
||||
|
||||
[resource]
|
||||
14
src/playerC/resources/sound_effects.tres
Normal file
14
src/playerC/resources/sound_effects.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Resource
|
||||
|
||||
var sounds = {
|
||||
\"pew\": preload(\"res://assets/Sounds/crappy pew.wav\") # for firing maybe
|
||||
}
|
||||
|
||||
|
||||
"
|
||||
|
||||
[resource]
|
||||
script = SubResource( 1 )
|
||||
2
src/playerC/sm.gd
Normal file
2
src/playerC/sm.gd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
extends StateMachineAnimatedActor
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# You could also declare a class_name for the move state
|
||||
# so you don't have to reference the script directly
|
||||
extends 'res://src/state_machine/states/move.gd'
|
||||
|
||||
@export
|
||||
var move_state: State
|
||||
|
||||
@export
|
||||
var time_to_dash := 0.5
|
||||
|
||||
var dash_timer := 0.0
|
||||
var direction := 1.0
|
||||
|
||||
func enter() -> void:
|
||||
super()
|
||||
dash_timer = time_to_dash
|
||||
|
||||
# Simple check for which direction to dash towards
|
||||
if animations.flip_h:
|
||||
direction = -1
|
||||
else:
|
||||
direction = 1
|
||||
|
||||
# Just to be safe, disable any other inputs
|
||||
func process_input(event: InputEvent) -> State:
|
||||
return null
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
dash_timer -= delta
|
||||
if dash_timer <= 0.0:
|
||||
# Fall back on the default input implementation to
|
||||
# determine where to go next
|
||||
if super.get_movement_input() != 0.0:
|
||||
return move_state
|
||||
return idle_state
|
||||
|
||||
# At this point, run 'process_physics' in the move script as written
|
||||
return super(delta)
|
||||
|
||||
# Override movement inputs
|
||||
func get_movement_input() -> float:
|
||||
return direction
|
||||
|
||||
func get_jump() -> bool:
|
||||
return false
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var move_node
|
||||
|
|
@ -16,27 +16,25 @@ func process_input(_event: InputEvent) -> State:
|
|||
return null
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
parent.velocity.y += gravity * delta
|
||||
move_component.velocity.y += gravity * delta
|
||||
|
||||
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
move_component.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
# if parent.velocity.x != 0.0:
|
||||
# parent.direction.x = parent.velocity.x
|
||||
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
if move_component.get_movement_direction() != 0.0:
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
# if move_component.flipped_sprite == false:
|
||||
# #parent.scale.x = parent.direction.x * -1
|
||||
# parent.transform.x.x = parent.direction.x * -1 # -1
|
||||
# else:
|
||||
# #parent.scale.x = parent.direction.x
|
||||
# parent.transform.x.x = parent.direction.x # 1
|
||||
|
||||
if parent.is_on_floor():
|
||||
if parent.velocity.x == 0:
|
||||
if move_component.velocity.x != 0:
|
||||
return move_state
|
||||
return idle_state
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var jump_node
|
||||
export (NodePath) var idle_node
|
||||
|
|
@ -20,6 +20,10 @@ func enter() -> void:
|
|||
if modifier_stack_ref.has($"../attack") == false:
|
||||
$"../attack".enter()
|
||||
modifier_stack_ref.push_front($"../attack")
|
||||
##TODO: Hacky, don't do it this way.
|
||||
#parent.sound_effect_player.play()
|
||||
|
||||
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
if move_component.wants_jump() and parent.is_on_floor():
|
||||
|
|
@ -43,12 +47,12 @@ func process_physics(delta: float) -> State:
|
|||
parent.shoot_projectile()
|
||||
can_fire = false
|
||||
|
||||
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))
|
||||
move_component.velocity.y += gravity * delta
|
||||
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 = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
if parent.velocity.x != 0.0:
|
||||
if move_component.velocity.x != 0.0:
|
||||
return move_state
|
||||
|
||||
if !parent.is_on_floor():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ onready var idle_state: State = get_node(idle_node)
|
|||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.velocity.x = 0
|
||||
parent.set_hurtbox(false)
|
||||
move_component.velocity.x = 0
|
||||
#parent.set_hurtbox(false)
|
||||
#TODO: Error check if timer was actually instanced
|
||||
state_timeout.start()
|
||||
|
||||
|
|
@ -25,12 +25,13 @@ func process_frame(delta: float) -> State:
|
|||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
parent.velocity.y += gravity * delta
|
||||
move_component.velocity.y += gravity * delta
|
||||
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
if (parent.direction.x > 0):
|
||||
parent.velocity.x = 1 * move_speed
|
||||
else:
|
||||
parent.velocity.x = -1 * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
move_component.velocity = parent.transform.x * move_speed
|
||||
# if (parent.direction.x > 0):
|
||||
# parent.velocity.x = 1 * move_speed
|
||||
# else:
|
||||
# parent.velocity.x = -1 * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
var debugTimeTracker := 0.0
|
||||
|
||||
export (NodePath) var jump_node
|
||||
export (NodePath) var fall_node
|
||||
|
|
@ -13,7 +15,7 @@ onready var fire_state: State = get_node(fire_node)
|
|||
func enter() -> void:
|
||||
.enter()
|
||||
parent.set_hurtbox(true)
|
||||
parent.velocity.x = 0
|
||||
move_component.velocity.x = 0
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
# if get_jump() and parent.is_on_floor():
|
||||
|
|
@ -35,12 +37,18 @@ func process_input(_event: InputEvent) -> 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))
|
||||
if debug_state:
|
||||
debugTimeTracker += delta
|
||||
if debugTimeTracker > 2:
|
||||
debugTimeTracker = 0.0
|
||||
print(owner.name, " DEBUG TRANSFORM:", parent.transform)
|
||||
|
||||
if parent.velocity.x != 0.0:
|
||||
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 * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
if move_component.velocity.x != 0.0:
|
||||
return move_state
|
||||
|
||||
if !parent.is_on_floor():
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
export (NodePath) var fall_node
|
||||
|
|
@ -13,7 +13,7 @@ export var jump_force: float = 900.0
|
|||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
parent.velocity.y = -jump_force
|
||||
move_component.velocity.y = -jump_force
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
move_component.get_movement_direction()
|
||||
|
|
@ -21,26 +21,26 @@ func process_input(_event: InputEvent) -> State:
|
|||
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
parent.velocity.y += gravity * delta
|
||||
move_component.velocity.y += gravity * delta
|
||||
|
||||
if parent.velocity.y > 0:
|
||||
if move_component.velocity.y > 0:
|
||||
return fall_state
|
||||
|
||||
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||
move_component.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
if move_component.get_movement_direction() != 0.0:
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
# if move_component.flipped_sprite == false:
|
||||
# #parent.scale.x = parent.direction.x * -1
|
||||
# parent.transform.x.x = parent.direction.x * -1 # -1
|
||||
# else:
|
||||
# #parent.scale.x = parent.direction.x
|
||||
# parent.transform.x.x = parent.direction.x # 1
|
||||
|
||||
if parent.is_on_floor():
|
||||
if parent.velocity.x == 0:
|
||||
if move_component.velocity.x == 0:
|
||||
return move_state
|
||||
return idle_state
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
extends State
|
||||
extends StateAnimatedActor
|
||||
|
||||
var debugTimeTracker := 0.0
|
||||
|
||||
export (NodePath) var jump_node
|
||||
export (NodePath) var fall_node
|
||||
|
|
@ -22,8 +24,13 @@ func process_input(_event: InputEvent) -> State:
|
|||
func process_physics(delta: float) -> State:
|
||||
# if move_component.wants_jump() and parent.is_on_floor():
|
||||
# return jump_state
|
||||
if debug_state:
|
||||
debugTimeTracker += delta
|
||||
if debugTimeTracker > 2:
|
||||
debugTimeTracker = 0.0
|
||||
print("DEBUG TRANSFORM:", parent.transform)
|
||||
|
||||
parent.velocity.y += gravity * delta
|
||||
move_component.velocity.y += gravity * delta
|
||||
|
||||
# var movement = move_component.get_movement_direction() * move_speed
|
||||
#
|
||||
|
|
@ -34,22 +41,28 @@ func process_physics(delta: float) -> State:
|
|||
# parent.velocity.x = movement
|
||||
# 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))
|
||||
move_component.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
if parent.velocity.x == 0.0:
|
||||
if move_component.velocity.x == 0.0:
|
||||
return idle_state
|
||||
else:
|
||||
if parent.velocity.x > 0:
|
||||
parent.direction.x = 1
|
||||
elif parent.velocity.x < 0:
|
||||
parent.direction.x = -1
|
||||
|
||||
|
||||
if move_component.flipped_sprite == true:
|
||||
animations.flip_h = parent.direction.x > 0
|
||||
else:
|
||||
animations.flip_h = parent.direction.x < 0
|
||||
if move_component.get_movement_direction() != 0.0:
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
# if move_component.flipped_sprite == true:
|
||||
# animations.flip_h = parent.direction.x > 0
|
||||
# else:
|
||||
# animations.flip_h = parent.direction.x < 0
|
||||
# Attempting to flip based on scale instead of sprite flip so that
|
||||
# all children nodes get flipped as well:
|
||||
# if move_component.flipped_sprite == false:
|
||||
# #parent.scale.x = parent.direction.x * -1
|
||||
# parent.transform.x.x = parent.direction.x * -1 # -1
|
||||
# else:
|
||||
# #parent.scale.x = parent.direction.x
|
||||
# parent.transform.x.x = parent.direction.x # 1
|
||||
|
||||
|
||||
|
||||
# Another approach of changing state based on actual achieved velocity
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
extends State
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
class_name PushdownStateMachine extends Node
|
||||
|
||||
export (NodePath) var starting_state
|
||||
|
||||
var current_state: State
|
||||
var state_stack = []
|
||||
|
||||
# Initialize the state machine by giving each child state a reference to the
|
||||
# parent object it belongs to and enter the default starting_state.
|
||||
func init(parent: KinematicBody2D, animations: AnimatedSprite, move_component) -> void:
|
||||
for child in get_children():
|
||||
child.parent = parent
|
||||
child.animations = animations
|
||||
child.move_component = move_component
|
||||
|
||||
# Initialize to the default state
|
||||
change_state(get_node(starting_state))
|
||||
|
||||
# Change to the new state by first calling any exit logic on the current state.
|
||||
func change_state(new_state: State) -> void:
|
||||
if current_state:
|
||||
current_state.exit()
|
||||
|
||||
current_state = new_state
|
||||
current_state.enter()
|
||||
|
||||
func push_state(new_state: State) -> void:
|
||||
state_stack.push_front(new_state)
|
||||
|
||||
|
||||
# Pass through functions for the Player to call,
|
||||
# handling state changes as needed.
|
||||
func process_physics(delta: float) -> void:
|
||||
var new_state = current_state.process_physics(delta)
|
||||
if new_state:
|
||||
change_state(new_state)
|
||||
|
||||
func process_input(event: InputEvent) -> void:
|
||||
var new_state = current_state.process_input(event)
|
||||
if new_state:
|
||||
change_state(new_state)
|
||||
|
||||
func process_frame(delta: float) -> void:
|
||||
var new_state = current_state.process_frame(delta)
|
||||
if new_state:
|
||||
change_state(new_state)
|
||||
78
src/state.gd
78
src/state.gd
|
|
@ -1,77 +1,26 @@
|
|||
class_name State
|
||||
extends Node
|
||||
## Animation and movement state class
|
||||
##
|
||||
## A state intended to control the movement and animation
|
||||
## functions of a KinimaticBody2D node. Initialized with a
|
||||
## player, movement node, and kinematicbody2d
|
||||
## I think if we also had modifier states that transfered along with the enter and entrance of nodes, that would be helpful.
|
||||
##
|
||||
## @WIP
|
||||
|
||||
# export (NodePath) var jump_node
|
||||
|
||||
# onready var jump_state: State = get_node(jump_node)
|
||||
|
||||
export var animation_name: String
|
||||
export var move_speed: float = 60
|
||||
export var debug_state: bool = false
|
||||
export var timeout_seconds: float = 0.0
|
||||
|
||||
export(Array, String) var animation_sequence
|
||||
# this just wouldn't work well. Maybe I can try a resource
|
||||
# export(Array, NodePath) var transition_state_nodes
|
||||
|
||||
#TODO: I think these two variables accidentally serve the same purpose
|
||||
# I think one was intended to be a string of the current animation name.
|
||||
var animation_index: int = 0
|
||||
var current_animation_sequence: int = 0
|
||||
var animation_suffix: String = '';
|
||||
signal state_entered()
|
||||
signal state_exited()
|
||||
signal frame_reached(state_name, animation_name, frame_number)
|
||||
export(Dictionary) var emitter_frame_subscriptions
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
var modifier_stack_ref: Array # Well this didn't work
|
||||
|
||||
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
var animations: AnimatedSprite
|
||||
var move_component: Node
|
||||
var parent: KinematicBody2D
|
||||
|
||||
#var animation_sequence_timer: Timer
|
||||
|
||||
var state_timeout: Timer
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
# Only add timout node if timer value was specified.
|
||||
if(timeout_seconds > 0.0):
|
||||
state_timeout = Timer.new()
|
||||
state_timeout.wait_time = timeout_seconds
|
||||
state_timeout.one_shot = true
|
||||
state_timeout.autostart = false
|
||||
add_child(state_timeout)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
# Reset animation suffix in case there isn't one
|
||||
animation_suffix = ''
|
||||
print(parent.name, " entering State: ", self.name)
|
||||
#modifier_stack_ref = state_modifiers
|
||||
if modifier_stack_ref.empty() == false:
|
||||
if modifier_stack_ref[-1].animation_name != '':
|
||||
if modifier_stack_ref[-1].animation_suffix:
|
||||
if animation_sequence.size() > 0:
|
||||
animation_index = 0
|
||||
current_animation_sequence = 0
|
||||
# Guess I don't need this one anymore
|
||||
#if animations.frames.get_animation_names().has(animation_sequence[animation_index] + modifier_stack_ref[-1].animation_name):
|
||||
if animations.frames.has_animation(animation_sequence[animation_index] + modifier_stack_ref[-1].animation_name):
|
||||
animation_suffix = modifier_stack_ref[-1].animation_name
|
||||
else:
|
||||
animations.play(modifier_stack_ref[-1].animation_name)
|
||||
return
|
||||
if animation_sequence.size() > 0:
|
||||
animation_index = 0
|
||||
current_animation_sequence = 0
|
||||
animations.play(animation_sequence[animation_index] + animation_suffix)
|
||||
return
|
||||
pass
|
||||
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
|
@ -80,13 +29,6 @@ func process_input(_event: InputEvent) -> State:
|
|||
return null
|
||||
|
||||
func process_frame(_delta: float) -> State:
|
||||
if animation_sequence.size() > 0 and current_animation_sequence != animation_index:
|
||||
if animation_index >= animation_sequence.size():
|
||||
animation_index = 0
|
||||
##TODO: Add a safety check here.
|
||||
animations.play(animation_sequence[animation_index] + animation_suffix)
|
||||
print("An animation sequence: ", animations.animation , animation_index)
|
||||
current_animation_sequence = animation_index
|
||||
return null
|
||||
|
||||
func process_physics(_delta: float) -> State:
|
||||
|
|
|
|||
118
src/state_animated_actor.gd
Normal file
118
src/state_animated_actor.gd
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
class_name StateAnimatedActor
|
||||
extends State
|
||||
## Animation and movement state class
|
||||
##
|
||||
## A state intended to control the movement and animation
|
||||
## functions of a KinimaticBody2D node. Initialized with a
|
||||
## player, movement node, and kinematicbody2d
|
||||
## I think if we also had modifier states that transfered along with the enter and entrance of nodes, that would be helpful.
|
||||
##
|
||||
## @WIP
|
||||
|
||||
# export (NodePath) var jump_node
|
||||
|
||||
# onready var jump_state: State = get_node(jump_node)
|
||||
|
||||
## Deprecated
|
||||
# export var animation_name: String
|
||||
|
||||
export var move_speed: float = 60
|
||||
|
||||
export(Array, String) var animation_sequence
|
||||
# this just wouldn't work well. Maybe I can try a resource
|
||||
# export(Array, NodePath) var transition_state_nodes
|
||||
|
||||
#TODO: I think these two variables accidentally serve the same purpose
|
||||
# I think one was intended to be a string of the current animation name.
|
||||
var animation_index: int = 0
|
||||
var current_animation_sequence: int = 0
|
||||
var animation_suffix: String = '';
|
||||
|
||||
|
||||
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
var animations: AnimatedSprite
|
||||
var move_component: MovementComponent
|
||||
var parent: KinematicBody2D
|
||||
|
||||
#var animation_sequence_timer: Timer
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
##TODO: this bit me in the butt. Should add a safety or something.
|
||||
# Only add timout node if timer value was specified.
|
||||
if(timeout_seconds > 0.0):
|
||||
state_timeout = Timer.new()
|
||||
state_timeout.wait_time = timeout_seconds
|
||||
state_timeout.one_shot = true
|
||||
state_timeout.autostart = false
|
||||
add_child(state_timeout)
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
# animations.connect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
||||
# Reset animation suffix in case there isn't one
|
||||
animation_suffix = ''
|
||||
if debug_state:
|
||||
print(parent.name, " entering State: ", self.name)
|
||||
move_component.current_movement_state = self.name
|
||||
emit_signal("state_entered")
|
||||
#modifier_stack_ref = state_modifiers
|
||||
if modifier_stack_ref.empty() == false:
|
||||
if modifier_stack_ref[-1].animation_name != '':
|
||||
if modifier_stack_ref[-1].animation_suffix:
|
||||
if animation_sequence.size() > 0:
|
||||
animation_index = 0
|
||||
current_animation_sequence = 0
|
||||
# Guess I don't need this one anymore
|
||||
#if animations.frames.get_animation_names().has(animation_sequence[animation_index] + modifier_stack_ref[-1].animation_name):
|
||||
if animations.frames.has_animation(animation_sequence[animation_index] + modifier_stack_ref[-1].animation_name):
|
||||
animation_suffix = modifier_stack_ref[-1].animation_name
|
||||
else:
|
||||
animations.play(modifier_stack_ref[-1].animation_name)
|
||||
return
|
||||
if animation_sequence.size() > 0:
|
||||
animation_index = 0
|
||||
current_animation_sequence = 0
|
||||
animations.play(animation_sequence[animation_index] + animation_suffix)
|
||||
return
|
||||
|
||||
func exit() -> void:
|
||||
emit_signal("state_exited")
|
||||
# animations.disconnect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
||||
return
|
||||
|
||||
func process_input(_event: InputEvent) -> State:
|
||||
return null
|
||||
|
||||
func process_frame(_delta: float) -> State:
|
||||
if animation_sequence.size() > 0 and current_animation_sequence != animation_index:
|
||||
if animation_index >= animation_sequence.size():
|
||||
animation_index = 0
|
||||
##TODO: Add a safety check here.
|
||||
animations.play(animation_sequence[animation_index] + animation_suffix)
|
||||
print("An animation sequence: ", animations.animation , animation_index)
|
||||
current_animation_sequence = animation_index
|
||||
|
||||
# Singal based frame call.
|
||||
if emitter_frame_subscriptions.has(animations.frame):
|
||||
if emitter_frame_subscriptions[animations.frame] == animations.animation:
|
||||
emit_signal("frame_reached", self.name, animations.animation, animations.frame)
|
||||
|
||||
return null
|
||||
|
||||
func process_physics(_delta: float) -> State:
|
||||
move_actor_as_desired(_delta)
|
||||
return null
|
||||
|
||||
#func _on_AnimatedSprite_animation_finished():
|
||||
# if animations.frames.get_animation_loop(animations.animation) == false:
|
||||
# animation_index += 1
|
||||
|
||||
func move_actor_as_desired(delta: float):
|
||||
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 * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
|
|
@ -1,20 +1,21 @@
|
|||
class_name StateMachine extends Node
|
||||
|
||||
export (NodePath) var starting_state
|
||||
export var debug_state_machine: bool = false
|
||||
|
||||
var current_state: State
|
||||
var state_modifiers: Array
|
||||
|
||||
# Initialize the state machine by giving each child state a reference to the
|
||||
# parent object it belongs to and enter the default starting_state.
|
||||
func init(parent: KinematicBody2D, animations: AnimatedSprite, move_component) -> void:
|
||||
func init() -> void:
|
||||
for child in get_children():
|
||||
if child is State:
|
||||
print("Initializing State Node for ", parent.name, ": ", child.name)
|
||||
child.parent = parent
|
||||
child.animations = animations
|
||||
child.move_component = move_component
|
||||
if debug_state_machine:
|
||||
print("Initializing State Node: ", child.name)
|
||||
child.modifier_stack_ref = state_modifiers
|
||||
if debug_state_machine:
|
||||
child.debug_state = true
|
||||
|
||||
# Initialize to the default state
|
||||
change_state(get_node(starting_state))
|
||||
|
|
@ -26,7 +27,7 @@ func change_state(new_state: State) -> void:
|
|||
|
||||
current_state = new_state
|
||||
current_state.enter()
|
||||
if(state_modifiers.size() > 0):
|
||||
if(state_modifiers.size() > 0 and debug_state_machine):
|
||||
print("Active Modifiers:")
|
||||
for mods in state_modifiers:
|
||||
print(mods.name)
|
||||
|
|
@ -44,19 +45,6 @@ func process_input(event: InputEvent) -> void:
|
|||
change_state(new_state)
|
||||
|
||||
func process_frame(delta: float) -> void:
|
||||
# Check the state modifiers for timeouts, and maybe more conditions later
|
||||
# If the modifier is no longer valid, pop it from the stack.
|
||||
# We could iterate through a whole list of states but I'm not sure i want
|
||||
# states to be that complex.
|
||||
if state_modifiers.empty() == false:
|
||||
if state_modifiers[-1].state_timeout.time_left == 0:
|
||||
print("Pop State Modifier: ", state_modifiers[-1].name)
|
||||
state_modifiers.pop_back()
|
||||
# Reset animation suffix
|
||||
current_state.animation_suffix = ''
|
||||
var current_frame = current_state.animations.frame
|
||||
current_state.animations.play(current_state.animation_sequence[current_state.animation_index])
|
||||
current_state.animations.frame = current_frame;
|
||||
var new_state = current_state.process_frame(delta)
|
||||
if new_state:
|
||||
change_state(new_state)
|
||||
|
|
|
|||
50
src/state_machine_animated_actor.gd
Normal file
50
src/state_machine_animated_actor.gd
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
class_name StateMachineAnimatedActor extends StateMachine
|
||||
|
||||
# Initialize the state machine by giving each child state a reference to the
|
||||
# parent object it belongs to and enter the default starting_state.
|
||||
func init_animated_actor(parent: KinematicBody2D, animations: AnimatedSprite, move_component: MovementComponent) -> void:
|
||||
animations.connect("animation_finished", self, "_on_AnimatedSprite_animation_finished")
|
||||
for child in get_children():
|
||||
if child is StateAnimatedActor:
|
||||
if debug_state_machine:
|
||||
print("Initializing State Node for ", parent.name, ": ", child.name)
|
||||
child.parent = parent
|
||||
child.animations = animations
|
||||
child.move_component = move_component
|
||||
child.modifier_stack_ref = state_modifiers
|
||||
if debug_state_machine:
|
||||
child.debug_state = true
|
||||
|
||||
# Initialize to the default state
|
||||
change_state(get_node(starting_state))
|
||||
|
||||
|
||||
func process_frame(delta: float) -> void:
|
||||
# Check the state modifiers for timeouts, and maybe more conditions later
|
||||
# If the modifier is no longer valid, pop it from the stack.
|
||||
# We could iterate through a whole list of states but I'm not sure i want
|
||||
# states to be that complex.
|
||||
if state_modifiers.empty() == false:
|
||||
if state_modifiers[-1].state_timeout.time_left == 0:
|
||||
if debug_state_machine:
|
||||
print("Pop State Modifier: ", state_modifiers[-1].name)
|
||||
state_modifiers.pop_back()
|
||||
# Reset animation suffix
|
||||
current_state.animation_suffix = ''
|
||||
var current_frame = current_state.animations.frame
|
||||
current_state.animations.play(current_state.animation_sequence[current_state.animation_index])
|
||||
current_state.animations.frame = current_frame;
|
||||
var new_state = current_state.process_frame(delta)
|
||||
if new_state:
|
||||
change_state(new_state)
|
||||
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
if current_state.animations.frames.get_animation_loop(
|
||||
current_state.animations.animation) == false:
|
||||
if current_state.animation_sequence.size() > 0:
|
||||
current_state.animation_index += 1
|
||||
|
||||
|
||||
|
||||
|
||||
59
src/templates/Actor/ActorTemplate.gd
Normal file
59
src/templates/Actor/ActorTemplate.gd
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
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
|
||||
|
||||
|
||||
|
||||
106
src/templates/Actor/ActorTemplate.tscn
Normal file
106
src/templates/Actor/ActorTemplate.tscn
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
[gd_scene load_steps=18 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]
|
||||
[ext_resource path="res://src/templates/Actor/states/fall.gd" type="Script" id=3]
|
||||
[ext_resource path="res://src/templates/Actor/states/idle.gd" type="Script" id=4]
|
||||
[ext_resource path="res://src/movement_component.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/templates/Actor/resources/Smiley.png" type="Texture" id=6]
|
||||
[ext_resource path="res://src/templates/Actor/states/move.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/actor.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=76]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 0, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=77]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 32, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=78]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 64, 0, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=79]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 0, 32, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=80]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 32, 32, 32, 32 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=81]
|
||||
atlas = ExtResource( 6 )
|
||||
region = Rect2( 64, 32, 32, 32 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=75]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 76 ), SubResource( 77 ), SubResource( 78 ), SubResource( 79 ), SubResource( 80 ), SubResource( 81 ) ],
|
||||
"loop": true,
|
||||
"name": "default",
|
||||
"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"]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 75 )
|
||||
frame = 4
|
||||
playing = true
|
||||
flip_h = true
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
"o_ex_p": "",
|
||||
"o_folder": "res://assets",
|
||||
"o_name": "",
|
||||
"only_visible": true,
|
||||
"op_exp": false,
|
||||
"slice": "",
|
||||
"source": "E:/Godot/Art/MegaMan.aseprite"
|
||||
}
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, -3.5 )
|
||||
shape = SubResource( 74 )
|
||||
|
||||
[node name="movement_component" type="Node" parent="."]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="movement_state_machine" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
starting_state = NodePath("idle")
|
||||
|
||||
[node name="idle" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 4 )
|
||||
animation_sequence = [ "default" ]
|
||||
fall_node = NodePath("../fall")
|
||||
move_node = NodePath("../move")
|
||||
|
||||
[node name="fall" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 3 )
|
||||
animation_sequence = [ "default" ]
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="move" type="Node" parent="movement_state_machine"]
|
||||
script = ExtResource( 7 )
|
||||
animation_sequence = [ "default" ]
|
||||
fall_node = NodePath("../fall")
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="Hurtbox_Component" parent="." instance=ExtResource( 1 )]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox_Component"]
|
||||
modulate = Color( 1, 0, 0, 1 )
|
||||
position = Vector2( -1, 1 )
|
||||
shape = SubResource( 82 )
|
||||
|
||||
[node name="SE_Player" type="AudioStreamPlayer" parent="."]
|
||||
BIN
src/templates/Actor/resources/Smiley.png
Normal file
BIN
src/templates/Actor/resources/Smiley.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 508 B |
35
src/templates/Actor/resources/Smiley.png.import
Normal file
35
src/templates/Actor/resources/Smiley.png.import
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/Smiley.png-8c81e651641e7afc57c144693e5c2423.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/templates/Actor/resources/Smiley.png"
|
||||
dest_files=[ "res://.import/Smiley.png-8c81e651641e7afc57c144693e5c2423.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
|
||||
19
src/templates/Actor/states/fall.gd
Normal file
19
src/templates/Actor/states/fall.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
#parent.velocity.y += gravity * delta
|
||||
move_component.velocity.y += gravity * delta
|
||||
|
||||
move_component.velocity.x = move_component.desired_movement_vector.x * move_speed
|
||||
move_component.velocity = parent.move_and_slide(move_component.velocity, Vector2(0, -1))
|
||||
|
||||
if move_component.get_movement_direction() != 0.0:
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
if parent.is_on_floor():
|
||||
return idle_state
|
||||
return null
|
||||
30
src/templates/Actor/states/idle.gd
Normal file
30
src/templates/Actor/states/idle.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var move_node
|
||||
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var move_state: State = get_node(move_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
# parent.set_hurtbox(true)
|
||||
move_component.velocity.x = 0
|
||||
if debug_state:
|
||||
print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)
|
||||
|
||||
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))
|
||||
|
||||
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
|
||||
21
src/templates/Actor/states/move.gd
Normal file
21
src/templates/Actor/states/move.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var fall_node
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var idle_state: State = get_node(idle_node)
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
|
||||
move_actor_as_desired(delta)
|
||||
|
||||
if move_component.velocity.x == 0.0:
|
||||
return idle_state
|
||||
|
||||
#Flip the character before tha actual move maybe.
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
if !parent.is_on_floor():
|
||||
return fall_state
|
||||
return null
|
||||
Loading…
Reference in New Issue
Block a user