Start git tracking

This commit is contained in:
CactiChameleon9 2022-03-03 20:08:47 +00:00
commit be0275a03e
46 changed files with 1793 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
android/
.import/

7
default_env.tres Normal file
View File

@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

200
export_presets.cfg Normal file
View File

@ -0,0 +1,200 @@
[preset.0]
name="Android"
platform="Android"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
graphics/32_bits_framebuffer=true
xr_features/xr_mode=0
xr_features/degrees_of_freedom=0
xr_features/hand_tracking=0
xr_features/focus_awareness=false
one_click_deploy/clear_previous_install=false
custom_template/debug=""
custom_template/release=""
custom_template/use_custom_build=false
command_line/extra_args=""
version/code=1
version/name="1.0"
package/unique_name="org.godotengine.$genname"
package/name=""
package/signed=true
screen/immersive_mode=true
screen/orientation=0
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
screen/opengl_debug=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
keystore/debug=""
keystore/debug_user=""
keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
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/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

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

34
icon.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

42
project.godot Normal file
View File

@ -0,0 +1,42 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "Node2D",
"class": "Unit",
"language": "GDScript",
"path": "res://src/classes/Unit.gd"
} ]
_global_script_class_icons={
"Unit": ""
}
[application]
config/name="Pokemon TRPG"
run/main_scene="res://src/scenes/battles/TestingBattle.tscn"
config/icon="res://icon.png"
[display]
window/size/width=480
window/size/height=270
window/size/test_width=1366
window/size/test_height=768
window/dpi/allow_hidpi=true
window/stretch/mode="viewport"
window/stretch/aspect="keep"
[rendering]
2d/snapping/use_gpu_pixel_snap=true
batching/precision/uv_contract=true
environment/default_environment="res://default_env.tres"
quality/2d/use_pixel_snap=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/TEST-ANIMATION.png-ea871a29c89a5731e8893159b9c1a03f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/TEST-ANIMATION.png"
dest_files=[ "res://.import/TEST-ANIMATION.png-ea871a29c89a5731e8893159b9c1a03f.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
src/assets/cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/cursor.png-9d7c9d63b9411128a55125c981c34d3c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/cursor.png"
dest_files=[ "res://.import/cursor.png-9d7c9d63b9411128a55125c981c34d3c.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,10 @@
[gd_resource type="Theme" load_steps=3 format=2]
[ext_resource path="res://src/assets/title-font.ttf" type="DynamicFontData" id=1]
[sub_resource type="DynamicFont" id=1]
size = 30
font_data = ExtResource( 1 )
[resource]
default_font = SubResource( 1 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Air.png-e8152f6774cc94ec505bb80b8c5611a5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/isometric_tileset/Air.png"
dest_files=[ "res://.import/Air.png-e8152f6774cc94ec505bb80b8c5611a5.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/FlowerGrass.png-d25863b4131607e845f7d89a59d13ac7.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/isometric_tileset/FlowerGrass.png"
dest_files=[ "res://.import/FlowerGrass.png-d25863b4131607e845f7d89a59d13ac7.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Grass.png-c28057ad458592467133a23ddfc7ee83.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/isometric_tileset/Grass.png"
dest_files=[ "res://.import/Grass.png-c28057ad458592467133a23ddfc7ee83.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Lava.png-2de605bcaa3b288ae6bc7593fac315f6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/isometric_tileset/Lava.png"
dest_files=[ "res://.import/Lava.png-2de605bcaa3b288ae6bc7593fac315f6.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Water.png-e0f4e3638d3c56e3c9c306de8de68885.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/isometric_tileset/Water.png"
dest_files=[ "res://.import/Water.png-e0f4e3638d3c56e3c9c306de8de68885.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,79 @@
[gd_resource type="TileSet" load_steps=6 format=2]
[ext_resource path="res://src/assets/isometric_tileset/Water.png" type="Texture" id=1]
[ext_resource path="res://src/assets/isometric_tileset/Lava.png" type="Texture" id=2]
[ext_resource path="res://src/assets/isometric_tileset/Air.png" type="Texture" id=3]
[ext_resource path="res://src/assets/isometric_tileset/Grass.png" type="Texture" id=11]
[ext_resource path="res://src/assets/isometric_tileset/FlowerGrass.png" type="Texture" id=21]
[resource]
1/name = "Grass"
1/texture = ExtResource( 11 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 0, 0, 32, 32 )
1/tile_mode = 0
1/occluder_offset = Vector2( 16, 16 )
1/navigation_offset = Vector2( 16, 16 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "Water.png 2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 0, 0, 32, 32 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0
3/name = "FlowerGrass.png 3"
3/texture = ExtResource( 21 )
3/tex_offset = Vector2( 0, 0 )
3/modulate = Color( 1, 1, 1, 1 )
3/region = Rect2( 0, 0, 32, 33 )
3/tile_mode = 0
3/occluder_offset = Vector2( 0, 0 )
3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape_one_way = false
3/shape_one_way_margin = 0.0
3/shapes = [ ]
3/z_index = 0
4/name = "Lava.png 4"
4/texture = ExtResource( 2 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 1, 1, 1, 1 )
4/region = Rect2( 0, 0, 32, 32 )
4/tile_mode = 0
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape_one_way = false
4/shape_one_way_margin = 0.0
4/shapes = [ ]
4/z_index = 0
5/name = "Air.png 5"
5/texture = ExtResource( 3 )
5/tex_offset = Vector2( 0, 0 )
5/modulate = Color( 1, 1, 1, 1 )
5/region = Rect2( 0, 0, 32, 32 )
5/tile_mode = 0
5/occluder_offset = Vector2( 0, 0 )
5/navigation_offset = Vector2( 0, 0 )
5/shape_offset = Vector2( 0, 0 )
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape_one_way = false
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/cat-thing-v2.png-b61f1beab52b097a8b832290516e8f1c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/assets/mons/cat-thing-v2.png"
dest_files=[ "res://.import/cat-thing-v2.png-b61f1beab52b097a8b832290516e8f1c.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
src/assets/shadow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

View File

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

BIN
src/assets/title-font.ttf Normal file

Binary file not shown.

100
src/classes/Unit.gd Normal file
View File

@ -0,0 +1,100 @@
tool
extends Node2D
class_name Unit
export var unit_type : String
export var max_health : int = 10
export var health : int = 10
export var movement_distance : int = 10
export var height : int = 0
export var water_walk : bool = false
export var air_walk : bool = false
export var lava_walk : bool = false
export var is_behind : bool = false
export var sprite : Texture setget set_sprite
var _target_position : Vector2
var movement_points : int = 0
var attack_points : int = 0
var _has_sent_turn_completed : bool = true
signal turn_completed
onready var Grid = get_node("../Grid")
func start_turn():
attack_points = 0
movement_points = movement_distance
_has_sent_turn_completed = false
func set_sprite(value: Texture) -> void:
sprite = value
var _sprite = $Sprite
# Setter functions are called during the node's `_init()` callback, before they entered the
# tree. At that point in time, the `_sprite` variable is `null`. If so, we have to wait to
# update the sprite's properties.
if not _sprite:
# The yield keyword allows us to wait until the unit node's `_ready()` callback ended.
yield(self, "ready")
_sprite.texture = value
func _ready() -> void:
#registers itself on the grid and snaps to a tile
yield(get_tree().create_timer(.01),"timeout")
position = Grid.register_new_unit(self)
z_index = height * 10 + 5
if not is_behind:
z_index = 100
func move(movement : Vector2):
if movement_points != 0: #checks if the unit has had its turn yet
var potential_movement = Grid.move_request(movement, self) #asks the grid if it can move
if potential_movement: #if not null, and therefore the grid returned a new position
_target_position = potential_movement[0]
var _target_height = potential_movement[1]
#take away the movement points depending on which radius zone the unit is in
#tries radius 0, then 1, the 2, etc. until the unit is in that radius and takes it away
for i in range(movement_points, -1, -1):
var area_around = Grid.get_around_coordinate(Grid.position_to_coordinates(position, height), i)
if not area_around.has(Grid.position_to_coordinates(_target_position, _target_height)):
movement_points = movement_points - i - 1
print(movement_points)
break
#change the z_index
height = potential_movement[1]
z_index = height
if (potential_movement[2] == false): #not behind
z_index = 100
func attack(): #TODO
if attack_points == 0:
#change animation to attacking
#make attacked change to hurt animation
#somehow change health values
#maybe using an attacked method??
attack_points = 0
func _physics_process(delta: float) -> void:
if _target_position: #TODO figure out better movement system (pathfinding)
position.x = move_toward(position.x, _target_position.x, 800 * delta)
position.y = move_toward(position.y, _target_position.y, 800 * delta)
attack_points = false
if attack_points == 0 && movement_points == 0 && not _has_sent_turn_completed:
emit_signal("turn_completed")
_has_sent_turn_completed = true

2
src/nodes/units/Foe.gd Normal file
View File

@ -0,0 +1,2 @@
tool
extends Unit

134
src/nodes/units/Foe.tscn Normal file
View File

@ -0,0 +1,134 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://src/assets/shadow.png" type="Texture" id=1]
[ext_resource path="res://src/nodes/units/Foe.gd" type="Script" id=2]
[sub_resource type="Animation" id=1]
resource_name = "Attack back"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15, 14, 13 ]
}
[sub_resource type="Animation" id=2]
resource_name = "Attack front"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11, 10, 9 ]
}
[sub_resource type="Animation" id=3]
resource_name = "Attacted"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 16, 17, 18, 19, 18, 17 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Attacted back"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 20, 21, 22, 23, 22, 21 ]
}
[sub_resource type="Animation" id=5]
length = 0.8
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 2, 1 ]
}
[sub_resource type="Animation" id=6]
resource_name = "Idle back"
length = 0.8
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7, 6, 5 ]
}
[node name="Foe" type="Node2D" groups=[
"foes",
]]
script = ExtResource( 2 )
unit_type = "Foe"
movement_distance = 0
[node name="Shadow" type="Sprite" parent="."]
position = Vector2( 2.5, -8.5 )
scale = Vector2( 1.28125, 0.90625 )
texture = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 2, -12 )
hframes = 4
vframes = 6
frame = 12
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
anims/Attacted = SubResource( 3 )
"anims/Attacted back" = SubResource( 4 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )

View File

@ -0,0 +1,2 @@
tool
extends Unit

133
src/nodes/units/Friend.tscn Normal file
View File

@ -0,0 +1,133 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://src/assets/shadow.png" type="Texture" id=2]
[ext_resource path="res://src/nodes/units/Friend.gd" type="Script" id=3]
[sub_resource type="Animation" id=1]
resource_name = "Attack back"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 12, 13, 14, 15, 14, 13 ]
}
[sub_resource type="Animation" id=2]
resource_name = "Attack front"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 8, 9, 10, 11, 10, 9 ]
}
[sub_resource type="Animation" id=3]
resource_name = "Attacted"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 16, 17, 18, 19, 18, 17 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Attacted back"
length = 0.8
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 20, 21, 22, 23, 22, 21 ]
}
[sub_resource type="Animation" id=5]
length = 0.8
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 2, 1 ]
}
[sub_resource type="Animation" id=6]
resource_name = "Idle back"
length = 0.8
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 4, 5, 6, 7, 6, 5 ]
}
[node name="Friend" type="Node2D" groups=[
"friends",
]]
z_index = 100
script = ExtResource( 3 )
unit_type = "Friend"
[node name="Shadow" type="Sprite" parent="."]
position = Vector2( 2.5, -8.5 )
scale = Vector2( 1.28125, 0.90625 )
texture = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 2, -12 )
hframes = 4
vframes = 6
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Idle"
"anims/Attack back" = SubResource( 1 )
"anims/Attack front" = SubResource( 2 )
anims/Attacted = SubResource( 3 )
"anims/Attacted back" = SubResource( 4 )
anims/Idle = SubResource( 5 )
"anims/Idle back" = SubResource( 6 )

View File

@ -0,0 +1,51 @@
extends Node
export var battle_turns : int = 10
var _turn_number : int = 1
var _unit_turns_completed : int = 0
var _unit_count : int = 0
signal part_of_turn_done
func _ready() -> void:
_start_battle()
func _start_battle():
for i in battle_turns:
#yield here means that it waits until the fucntion is completed
yield(_start_unit_turns("friends"), "completed")
yield(_start_unit_turns("foes"), "completed")
_turn_number = _turn_number + 1
func _add_unit_turns_completed():
#this function is called by the signal turn completed
_unit_turns_completed = _unit_turns_completed + 1
func _start_unit_turns(unit_group_name : String):
var unit_array = get_tree().get_nodes_in_group(unit_group_name)
_unit_count = unit_array.size()
#connects the signal turn completed to the _add_unit_turns_completed method
for i in _unit_count:
unit_array[i].connect("turn_completed", self, "_add_unit_turns_completed")
#start the turn for all nodes in the specified group
get_tree().call_group(unit_group_name, "start_turn")
#wait until the number of turn_completed signals recieved is equal to the unit count
yield(self, "part_of_turn_done")
#reset for next part of turn
_unit_count = 0
_unit_turns_completed = 0
for i in _unit_count:
unit_array[i].disconnect("turn_completed", self, "_add_unit_turns_completed")
func _process(delta: float) -> void:
#wait until the number of turn_completed signals recieved is equal to the unit count
if _unit_turns_completed >= _unit_count:
emit_signal("part_of_turn_done")

View File

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

111
src/nodes/world/Cursor.gd Normal file
View File

@ -0,0 +1,111 @@
extends Node2D
tool #allow rendering of selection box in the editor
onready var Grid = get_node("../Grid")
#currently selected item
var _currently_selecting = null
#current tile being hovered over
var _tile := Vector2.ZERO setget set_tile
var _height = 0
#this controls the cursors position
func set_tile(new_tile: Vector2) -> void:
#this does all the moving checks, and returns null if invalid
var target_position = Grid.move_cursor_request(new_tile, _height)
#if null isn't returned then the cursor can be moved and tile set
if target_position:
position = target_position[0]
_tile = new_tile
_height = target_position[1]
z_index = _height
if (target_position[2] == false): #not behind
z_index = z_index + 20
#starts a timer so that the movement is "staggered" - limit on speed
$Timer.start()
#this draws a 32x16 diamond in the center of the cursor
func _draw() -> void:
var selection_color = Color.lightblue
var selection_thickness = 2.0
#I don't know how to draw use draw_polygon - hence lines
draw_line(Vector2(-16,0), Vector2(0,8), selection_color, selection_thickness)
draw_line(Vector2(16,0), Vector2(0,8), selection_color, selection_thickness)
draw_line(Vector2(-16,0), Vector2(0,-8), selection_color, selection_thickness)
draw_line(Vector2(16,0), Vector2(0,-8), selection_color, selection_thickness)
#this function I mainly took from a GDQuest tutorial - but with a few modifications
#it detects inputs for movement moves the cursor based off that
#it also handles clicks/enter logic for moving units
func _unhandled_input(event: InputEvent) -> void:
#if the mouse is moved then change the selected tile (and therefore position) of the cursor
if event is InputEventMouseMotion:
self._tile = Grid.position_to_coordinates(event.position, 0)
#if a left click/enter acton occurs then run the selection and movement logic
#this bit of code resets the current selection after a move or if the selection was invalid
# therefore requireing 2 successful selections to make a move (1st player, 2nd space)
elif (event is InputEventMouseButton and event.pressed == false and
event.button_index == BUTTON_LEFT or event.is_action_pressed("ui_accept")):
#asks the selected node to to move the now selected tile if something has already been selected
if _currently_selecting:
var _currently_selecting_name = Grid.grid[_currently_selecting.x][_currently_selecting.y][0]
get_node(("../" + _currently_selecting_name)).move(_tile - _currently_selecting)
_currently_selecting = null
Grid.remove_selection()
#therefore, if nothing is currently selected, then we need to select what we have clicked on
elif Grid.grid[_tile.x][_tile.y]:
_currently_selecting = _tile
var _currently_selecting_name = Grid.grid[_currently_selecting.x][_currently_selecting.y][0]
if get_node("../" + _currently_selecting_name).movement_points != 0:
Grid.display_selection(_tile, get_node("../" + _currently_selecting_name))
else:
_currently_selecting = null
#if there was no unit under the cursor then do nothing (and reset to no selection)
else:
_currently_selecting = null
get_tree().set_input_as_handled()
#this adds the ability to undo the selection of a unit through right click or esc
elif (event is InputEventMouseButton and event.pressed == false and
event.button_index == BUTTON_RIGHT or event.is_action_pressed("ui_cancel")):
_currently_selecting = null
get_tree().set_input_as_handled()
# The code below is for the cursor's movement.
# The following lines make some preliminary checks to see whether the cursor should move or not
# if the user presses an arrow key.
var should_move := event.is_pressed()
# If the player is pressing the key in this frame, we allow the cursor to move. If they keep the
# keypress down, we only want to move after the cooldown timer stops.
if event.is_echo():
should_move = should_move and $Timer.is_stopped()
# And if the cursor shouldn't move, we prevent it from doing so.
if not should_move:
return
# Here, we update the cursor's current tile based on the input direction. See the set_tile()
# function below to see what changes that triggers.
if event.is_action("ui_right"):
self.tile += Vector2.RIGHT
elif event.is_action("ui_up"):
self.tile += Vector2.UP
elif event.is_action("ui_left"):
self.tile += Vector2.LEFT
elif event.is_action("ui_down"):
self.tile += Vector2.DOWN

View File

@ -0,0 +1,36 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://src/assets/cursor.png" type="Texture" id=1]
[ext_resource path="res://src/nodes/world/Cursor.gd" type="Script" id=2]
[sub_resource type="Animation" id=1]
resource_name = "hover"
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5, 1 ),
"transitions": PoolRealArray( 0.499999, 2.37841, 2.46229 ),
"update": 0,
"values": [ Vector2( 8, -7 ), Vector2( 14, -16 ), Vector2( 8, -7 ) ]
}
[node name="Cursor" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 7, -8 )
rotation = 4.71239
z_index = 100
texture = ExtResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "hover"
anims/hover = SubResource( 1 )
[node name="Timer" type="Timer" parent="."]
wait_time = 0.1

289
src/nodes/world/Grid.gd Normal file
View File

@ -0,0 +1,289 @@
extends Node
#maximum size needed for current resolution
const GRID_SIZE = Vector2(46 + 10,32 + 10)
#found these through trial and error
#these are actually the tile-size/2 (kinda)
const X_MATRIX = Vector2(16,8)
const Y_MATRIX = Vector2(-16,8)
#1/(Xx)(Yy)-(Yx)(Xy)
const INVERSE_MATRIX_MULTIPLIER = 1.0/((X_MATRIX.x*Y_MATRIX.y)-(Y_MATRIX.x*X_MATRIX.y))
#{ Xx Yx } to { Yy -Yx }
#{ Xy Yy } to { -Xy Xx }
const INVERSE_X_MATRIX = Vector2(Y_MATRIX.y,-X_MATRIX.y)
const INVERSE_Y_MATRIX = Vector2(-Y_MATRIX.x,X_MATRIX.x)
const EMPTY_TILE = [-1]
const GROUND_TILE = [0,1]
const WATER_TILE = [2]
const AIR_TILE = [5]
const LAVA_TILE = [4]
const OBSTACLE_TILE = []
#setget works here because the value is gotten after the object has been
# initalised (not before), so that the GRID_SIZE actually has values
onready var grid = _create_grid(GRID_SIZE.x, GRID_SIZE.y, true)
onready var TERRAIN_GRID = _create_grid(GRID_SIZE.x, GRID_SIZE.y)
func _create_grid (x, y, unpopulated : bool = false) -> Vector2:
var out = []
#creates an array with the range from 0 to x-1 (total being x)
# with a second array inside each with the range 0 to y-1 (total being y)
for _i in range(x):
var col = []
col.resize(y)
out.append(col)
if unpopulated:
return out
#populates the grid with the ids of the tilesets and the heights
#the +1, +2 etc is so that the raised piece is set to the actual position is represents
#this overrides only if the new tile wasn't empty - so the top tile and correct height are set
for i in range (GRID_SIZE.x):
for j in range (GRID_SIZE.y):
out[i][j] = [get_node("../TileMap0").get_cell(i,j), 0]
for i in range (GRID_SIZE.x):
for j in range (GRID_SIZE.y):
if get_node("../TileMap1").get_cell(i,j) != EMPTY_TILE[0]:
out[i+1][j+1] = [get_node("../TileMap1").get_cell(i,j), 1]
for i in range (GRID_SIZE.x):
for j in range (GRID_SIZE.y):
if get_node("../TileMap2").get_cell(i,j) != EMPTY_TILE[0]:
out[i+2][j+2] = [get_node("../TileMap2").get_cell(i,j), 2]
for i in range (GRID_SIZE.x):
for j in range (GRID_SIZE.y):
if get_node("../TileMap3").get_cell(i,j) != EMPTY_TILE[0]:
out[i+3][j+3] = [get_node("../TileMap3").get_cell(i,j), 3]
return out
func register_new_unit (unit : Unit) -> Vector2:
#turn the position into coordinates
var current_coordinates = position_to_coordinates(unit.position, unit.height)
#add the name (which must be unique due to godot) to the grid
grid[current_coordinates.x][current_coordinates.y] = [unit.name, unit.height]
#snaps the unit to the correct tile
return coordinates_to_position(current_coordinates, unit.height)
func move_request (movement_coordinates : Vector2, unit : Unit): #TODO 3D
# recieve a movement request, DONE
# check its valid, MOSTLY DONE (HAPPY PATH!!!)
# height difference check needed... somehow TODO
# change check existing tile check TODO
# check moving across water
# change the 2d array, DONE
# send signals out to refresh position CHANGED/DONE
# now just returns the value for the unit to move
var current_coordinates = _find_grid_coordinates(unit.name)
var target_coordinates = current_coordinates + movement_coordinates
var target_co_height = TERRAIN_GRID[target_coordinates.x][target_coordinates.y][1]
var area_around = get_around_coordinate(current_coordinates, unit.movement_points)
var area_moveable = _filter_moveable_spaces(area_around, unit.water_walk, unit.air_walk, unit.lava_walk)
if not area_moveable.has(target_coordinates):
return null
#check if an another unit is in that space
if grid[target_coordinates.x][target_coordinates.y] != null:
return null
#check if its totally behind(invalid) or partially behind(changes z_index)
#this slightly overlaps the filtering code, but not by much
var behind = false
if (get_tile_behind_state(target_coordinates) == "d"):
return null
elif(get_tile_behind_state(target_coordinates) == "p"):
behind = true
#update where that unit is on the grid
_move_unit_in_grid(current_coordinates, target_coordinates)
#return a value which is moved too
return [coordinates_to_position(target_coordinates, target_co_height), target_co_height, behind]
func move_cursor_request (target_coordinates : Vector2, height : int): #TODO 3D - no clue what to do with the cursor
#Check if its moving outside the grid
if (not _is_in_grid(target_coordinates)):
return null
var behind = false
if (get_tile_behind_state(target_coordinates) == "d"):
return null
elif(get_tile_behind_state(target_coordinates) == "p"):
behind = true
height = TERRAIN_GRID[target_coordinates.x][target_coordinates.y][1]
#Return a value which is moved too
#The tile_size/2 is because nodes are in the center of a tile
return [coordinates_to_position(target_coordinates, height), height, behind]
func _find_grid_coordinates (name : String):
for x in GRID_SIZE.x:
for y in GRID_SIZE.y:
if grid[x][y]:
if grid[x][y][0] == name:
return Vector2(x,y)
return null
func _move_unit_in_grid (from : Vector2, to : Vector2): #TODO 3D
#this is a simple method that moves one value to another place on the grid
var value = grid[from.x][from.y]
grid[from.x][from.y] = null
grid[to.x][to.y] = value
func coordinates_to_position (coordinates : Vector2, height: int) -> Vector2:
var out = Vector2(0,-240) #the position of the ../TileMap 0,0
out += (coordinates.x) * X_MATRIX #add the x
out += (coordinates.y) * Y_MATRIX #add the y
out.y = out.y - height * 16
return out
func position_to_coordinates (node_position : Vector2, height : int) -> Vector2:
#reverse matrix.... fun
var out = node_position - Vector2(0,-240)
var tmp_x = out.x
out.x = INVERSE_X_MATRIX.x*INVERSE_MATRIX_MULTIPLIER*out.x + INVERSE_Y_MATRIX.x*INVERSE_MATRIX_MULTIPLIER*out.y
out.y = INVERSE_X_MATRIX.y*INVERSE_MATRIX_MULTIPLIER*tmp_x + INVERSE_Y_MATRIX.y*INVERSE_MATRIX_MULTIPLIER*out.y
#round the decimal places. Not sure why the minus one - but its needed
#each addition in height reduces each coordinate by one, so that needs to be
# added back
out.x = round(out.x) + height
out.y = round(out.y) + height
return out
func _is_in_grid (coordinates : Vector2) -> bool:
if (coordinates.x >= GRID_SIZE.x or
coordinates.y >= GRID_SIZE.y or
coordinates.x < 0 or
coordinates.y < 0):
return false
return true
func get_tile_behind_state (coordinates : Vector2) -> String:
#checking if tiles are directly behind
#the plus 1 and plus 2 mean that its a height difference of 2 or 3 required respectively
if (TERRAIN_GRID[coordinates.x + 1][coordinates.y + 1][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] or
TERRAIN_GRID[coordinates.x + 2][coordinates.y + 2][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 1 or
TERRAIN_GRID[coordinates.x + 3][coordinates.y + 3][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 2):
return "d" #directly
#checking if tiles are partially covered
elif(TERRAIN_GRID[coordinates.x][coordinates.y + 1][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] or
TERRAIN_GRID[coordinates.x + 1][coordinates.y][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] or
TERRAIN_GRID[coordinates.x + 2][coordinates.y + 1][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 1 or
TERRAIN_GRID[coordinates.x + 1][coordinates.y + 2][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 1 or
TERRAIN_GRID[coordinates.x + 3][coordinates.y + 2][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 2 or
TERRAIN_GRID[coordinates.x + 2][coordinates.y + 3][1] > TERRAIN_GRID[coordinates.x][coordinates.y][1] + 2):
return "p" #partially
else:
return "n" #no
func get_around_coordinate(coordinate : Vector2, movement_distance : int):
#found https://godotengine.org/qa/64496/how-to-get-a-random-tile-in-a-radious
#disclude the tile being stood on
movement_distance = movement_distance + 1
#gets the rectangle bounding the circle
var radius_vec = Vector2(movement_distance, movement_distance)
var min_pos = (coordinate - radius_vec).floor()
var max_pos = (coordinate + radius_vec).ceil()
#convert the mins/maxs to integers so we can use range for loop
var min_x = int(min_pos.x)
var max_x = int(max_pos.x)
var min_y = int(min_pos.y)
var max_y = int(max_pos.y)
var positions = []
#gathers all the points that are within the radius
for y in range(min_y, max_y):
for x in range(min_x, max_x):
var tile_pos = Vector2(x, y)
if tile_pos.distance_to(coordinate) < movement_distance:
positions.append(tile_pos)
return positions
func _filter_moveable_spaces(positions_array, water_walk : bool = false, air_walk : bool = false, lava_walk : bool = false):
#this uses happy path to filter out the invalid move spaces
var new_pos_array = []
for i in positions_array.size():
var tile_type = TERRAIN_GRID[positions_array[i].x][positions_array[i].y][0]
if (get_tile_behind_state(positions_array[i]) == "d"):
continue
if (EMPTY_TILE.has(tile_type) or OBSTACLE_TILE.has(tile_type)):
continue
if (WATER_TILE.has(tile_type) and not water_walk):
continue
if (AIR_TILE.has(tile_type) and not air_walk):
continue
if (LAVA_TILE.has(tile_type) and not lava_walk):
continue
new_pos_array.append(positions_array[i])
return new_pos_array
func display_selection(coordinate : Vector2, unit : Unit):
var movement_amount = unit.movement_points
print("hi")
for i in range (movement_amount, -1, -1):
var area_around = get_around_coordinate(coordinate, i)
var area_around_smaller = get_around_coordinate(coordinate, i -1)
if i == 1:
area_around_smaller = []
for j in area_around_smaller.size():
if area_around.has(area_around_smaller[j]):
area_around.remove(area_around.find(area_around_smaller[j]))
var area_moveable = _filter_moveable_spaces(area_around, unit.water_walk, unit.air_walk, unit.lava_walk)
$SelectionAreaController.create_selection_from_array(area_moveable, i)
func remove_selection():
$SelectionAreaController.emit_signal("remove_selection")
#func get_around_coordinate(coordinate : Vector2, movement_distance : int):
# #this generates the list of coordinates that a unit can move too
# #the radius + radius (either side) + 1 (the center)
# var positions_array = []
# for i in movement_distance + movement_distance + 1:
# for j in movement_distance + movement_distance + 1:
# positions_array.append(coordinate - Vector2(movement_distance, movement_distance) + Vector2(i,j))
#
# return positions_array

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/nodes/world/Grid.gd" type="Script" id=1]
[ext_resource path="res://src/nodes/world/SelectionAreaController.tscn" type="PackedScene" id=2]
[node name="Grid" type="Node"]
script = ExtResource( 1 )
[node name="SelectionAreaController" parent="." instance=ExtResource( 2 )]

View File

@ -0,0 +1,87 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/assets/global_theme.tres" type="Theme" id=1]
[sub_resource type="Animation" id=1]
resource_name = "Loading"
length = 2.0
step = 0.5
tracks/0/type = "value"
tracks/0/path = NodePath("Label:text")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5, 1, 1.5 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ "Loading", "Loading.", "Loading..", "Loading..." ]
}
tracks/1/type = "method"
tracks/1/path = NodePath(".")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 2 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "queue_free"
} ]
}
[node name="LoadingScreen" type="CanvasLayer"]
[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 1 )
color = Color( 0.258824, 0.643137, 0.34902, 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -240.0
margin_top = -52.0
margin_right = 240.0
margin_bottom = -19.0
theme = ExtResource( 1 )
text = "Loading"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Loading"
anims/Loading = SubResource( 1 )
[node name="Timers" type="Node" parent="."]
[node name="Timer" type="Timer" parent="Timers"]
wait_time = 0.5
one_shot = true
autostart = true
[node name="Timer2" type="Timer" parent="Timers"]
one_shot = true
autostart = true
[node name="Timer3" type="Timer" parent="Timers"]
wait_time = 1.5
one_shot = true
autostart = true
[node name="Timer4" type="Timer" parent="Timers"]
wait_time = 2.0
one_shot = true
autostart = true

View File

@ -0,0 +1,25 @@
extends Node2D
tool #allow rendering of selection box in the editor
const RED = Color("#ac3232")
const ORANGE = Color("#df7126")
const YELLOW = Color("#fbf236")
const GREEN = Color("99e550")
const TURQ = Color("#37946e")
const BLUE = Color("#5b6ee1")
const PURPLE = Color("#76428a")
const PINK = Color("#d77bba")
var selection_colors = [RED, ORANGE, YELLOW, GREEN, TURQ, BLUE, PURPLE, PINK]
var selection_color_index = 0
func _draw() -> void:
if selection_color_index >= len(selection_colors):
selection_color_index -= len(selection_colors)
var selection_thickness = 2.0
var selection_shape = PoolVector2Array([Vector2(-16,0), Vector2(0,8), Vector2(16, 0), Vector2(0, -8)])
draw_colored_polygon(selection_shape, selection_colors[selection_color_index])

View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/nodes/world/SelectionArea.gd" type="Script" id=1]
[node name="SelectionArea" type="Node2D"]
modulate = Color( 1, 1, 1, 0.843137 )
z_index = 5
script = ExtResource( 1 )

View File

@ -0,0 +1,34 @@
extends Node
signal remove_selection
var SELECTION_AREA = preload("res://src/nodes/world/SelectionArea.tscn")
onready var Grid = get_parent()
func create_selection_from_array(coordinates, color_index : int):
for i in coordinates.size():
create_selection(coordinates[i], color_index)
func create_selection(coordinate : Vector2, color_index : int):
var instanced_selection_area = SELECTION_AREA.instance()
connect("remove_selection", instanced_selection_area, "queue_free")
instanced_selection_area.position = Grid.coordinates_to_position(coordinate, Grid.TERRAIN_GRID[coordinate.x][coordinate.y][1])
if (Grid.get_tile_behind_state(coordinate) == "p"):
instanced_selection_area.z_index = Grid.TERRAIN_GRID[coordinate.x][coordinate.y][1]
instanced_selection_area.selection_color_index = color_index
add_child(instanced_selection_area)
#func _ready() -> void:
# yield(get_tree().create_timer(0.1), "timeout")
# create_selection(Vector2(29,18))
# create_selection(Vector2(29,19))
# yield(get_tree().create_timer(10), "timeout")
# emit_signal("remove_selection")
# print("destroyed")

View File

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

View File

@ -0,0 +1,80 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://src/assets/isometric_tileset/isometric_tileset.tres" type="TileSet" id=1]
[ext_resource path="res://src/nodes/units/Friend.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/nodes/world/Cursor.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/nodes/world/Grid.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/nodes/world/LoadingScreen.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/assets/TEST-ANIMATION.png" type="Texture" id=6]
[ext_resource path="res://icon.png" type="Texture" id=7]
[ext_resource path="res://src/nodes/world/BattleController.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/nodes/units/Foe.tscn" type="PackedScene" id=9]
[node name="TestingBattle" type="Node2D"]
[node name="TileMap0" type="TileMap" parent="."]
position = Vector2( 0, -248 )
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( 655381, 1, 0, 655382, 1, 0, 655383, 1, 0, 655384, 1, 0, 655385, 1, 0, 655386, 1, 0, 720916, 1, 0, 720917, 1, 0, 720918, 1, 0, 720919, 1, 0, 720920, 1, 0, 720921, 1, 0, 720922, 1, 0, 720923, 1, 0, 720924, 1, 0, 720925, 1, 0, 720926, 1, 0, 720927, 1, 0, 786452, 1, 0, 786453, 1, 0, 786454, 4, 0, 786455, 1, 0, 786456, 1, 0, 786457, 1, 0, 786458, 1, 0, 786459, 1, 0, 786460, 1, 0, 786461, 1, 0, 786462, 1, 0, 786463, 1, 0, 786464, 1, 0, 786465, 1, 0, 851986, 1, 0, 851987, 1, 0, 851988, 1, 0, 851989, 4, 0, 851990, 4, 0, 851991, 4, 0, 851992, 1, 0, 851993, 1, 0, 851994, 1, 0, 851995, 2, 0, 851996, 2, 0, 851997, 1, 0, 851998, 1, 0, 851999, 1, 0, 852000, 1, 0, 852001, 1, 0, 852002, 1, 0, 917522, 1, 0, 917523, 1, 0, 917524, 4, 0, 917525, 4, 0, 917526, 4, 0, 917527, 4, 0, 917528, 1, 0, 917529, 1, 0, 917530, 2, 0, 917531, 2, 0, 917532, 2, 0, 917533, 2, 0, 917534, 2, 0, 917535, 2, 0, 917536, 2, 0, 917537, 1, 0, 917538, 1, 0, 917539, 1, 0, 917540, 1, 0, 983058, 1, 0, 983059, 1, 0, 983060, 4, 0, 983061, 4, 0, 983062, 4, 0, 983063, 4, 0, 983064, 1, 0, 983065, 1, 0, 983066, 2, 0, 983067, 2, 0, 983068, 2, 0, 983069, 2, 0, 983070, 2, 0, 983071, 2, 0, 983072, 2, 0, 983073, 2, 0, 983074, 1, 0, 983075, 1, 0, 983076, 1, 0, 983077, 1, 0, 1048594, 1, 0, 1048595, 1, 0, 1048596, 1, 0, 1048597, 4, 0, 1048598, 4, 0, 1048599, 1, 0, 1048600, 1, 0, 1048601, 2, 0, 1048602, 2, 0, 1048603, 2, 0, 1048604, 2, 0, 1048605, 2, 0, 1048606, 2, 0, 1048607, 2, 0, 1048608, 2, 0, 1048609, 2, 0, 1048610, 2, 0, 1048611, 1, 0, 1048612, 1, 0, 1048613, 1, 0, 1048614, 1, 0, 1114131, 1, 0, 1114132, 1, 0, 1114133, 1, 0, 1114134, 1, 0, 1114135, 1, 0, 1114136, 1, 0, 1114137, 2, 0, 1114138, 2, 0, 1114139, 2, 0, 1114140, 2, 0, 1114141, 2, 0, 1114142, 2, 0, 1114143, 2, 0, 1114144, 2, 0, 1114145, 2, 0, 1114146, 1, 0, 1114147, 1, 0, 1114148, 5, 0, 1114149, 1, 0, 1114150, 1, 0, 1179667, 1, 0, 1179668, 1, 0, 1179669, 1, 0, 1179670, 1, 0, 1179671, 1, 0, 1179672, 1, 0, 1179673, 2, 0, 1179674, 2, 0, 1179675, 2, 0, 1179676, 2, 0, 1179677, 2, 0, 1179678, 2, 0, 1179679, 2, 0, 1179680, 2, 0, 1179681, 2, 0, 1179682, 1, 0, 1179683, 5, 0, 1179684, 1, 0, 1179685, 5, 0, 1179686, 1, 0, 1179687, 1, 0, 1245204, 1, 0, 1245205, 1, 0, 1245206, 1, 0, 1245207, 1, 0, 1245208, 1, 0, 1245209, 1, 0, 1245210, 2, 0, 1245211, 2, 0, 1245212, 2, 0, 1245213, 2, 0, 1245214, 2, 0, 1245215, 2, 0, 1245216, 2, 0, 1245217, 2, 0, 1245218, 1, 0, 1245219, 1, 0, 1245220, 5, 0, 1245221, 1, 0, 1245222, 5, 0, 1245223, 1, 0, 1310741, 1, 0, 1310742, 1, 0, 1310743, 1, 0, 1310744, 3, 0, 1310745, 3, 0, 1310746, 2, 0, 1310747, 2, 0, 1310748, 2, 0, 1310749, 2, 0, 1310750, 2, 0, 1310751, 2, 0, 1310752, 2, 0, 1310753, 2, 0, 1310754, 1, 0, 1310755, 5, 0, 1310756, 1, 0, 1310757, 5, 0, 1310758, 1, 0, 1310759, 1, 0, 1376278, 1, 0, 1376279, 1, 0, 1376280, 3, 0, 1376281, 3, 0, 1376282, 1, 0, 1376283, 2, 0, 1376284, 2, 0, 1376285, 2, 0, 1376286, 2, 0, 1376287, 2, 0, 1376288, 2, 0, 1376289, 2, 0, 1376290, 1, 0, 1376291, 1, 0, 1376292, 5, 0, 1376293, 1, 0, 1376294, 1, 0, 1376295, 1, 0, 1441815, 1, 0, 1441816, 1, 0, 1441817, 3, 0, 1441818, 3, 0, 1441819, 1, 0, 1441820, 2, 0, 1441821, 2, 0, 1441822, 2, 0, 1441823, 2, 0, 1441824, 2, 0, 1441825, 1, 0, 1441826, 1, 0, 1441827, 5, 0, 1441828, 1, 0, 1441829, 1, 0, 1441830, 1, 0, 1507352, 1, 0, 1507353, 1, 0, 1507354, 3, 0, 1507355, 1, 0, 1507356, 1, 0, 1507357, 2, 0, 1507358, 2, 0, 1507359, 2, 0, 1507360, 1, 0, 1507361, 1, 0, 1507362, 1, 0, 1507363, 1, 0, 1507364, 1, 0, 1507365, 1, 0, 1572889, 1, 0, 1572890, 1, 0, 1572891, 1, 0, 1572892, 1, 0, 1572893, 1, 0, 1572894, 1, 0, 1572895, 1, 0, 1572896, 1, 0, 1572897, 1, 0, 1572898, 1, 0, 1572899, 1, 0, 1572900, 1, 0, 1638426, 1, 0, 1638427, 1, 0, 1638428, 1, 0, 1638429, 1, 0, 1638430, 1, 0, 1638431, 1, 0, 1638432, 1, 0, 1638433, 1, 0, 1638434, 1, 0, 1638435, 1, 0, 1703963, 1, 0, 1703964, 1, 0, 1703965, 1, 0, 1703966, 1, 0, 1703967, 1, 0, 1703968, 1, 0, 1703969, 1, 0, 1769501, 1, 0, 1769502, 1, 0 )
[node name="TileMap1" type="TileMap" parent="."]
position = Vector2( 0, -248 )
z_index = 1
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( 983067, 1, 0, 1048603, 1, 0, 1048604, 1, 0, 1048605, 1, 0, 1048606, 1, 0, 1114139, 1, 0, 1114140, 1, 0, 1114141, 1, 0, 1114142, 1, 0, 1179676, 1, 0, 1179677, 1, 0, 1179678, 1, 0, 1245212, 1, 0 )
[node name="TileMap2" type="TileMap" parent="."]
position = Vector2( 0, -248 )
z_index = 2
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( 983068, 1, 0, 983069, 1, 0 )
[node name="TileMap3" type="TileMap" parent="."]
position = Vector2( 0, -248 )
z_index = 3
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( 917531, 1, 0 )
[node name="Friend" parent="." instance=ExtResource( 2 )]
position = Vector2( 160, 165 )
movement_distance = 7
water_walk = true
air_walk = true
lava_walk = true
sprite = ExtResource( 6 )
[node name="Cursor" parent="." instance=ExtResource( 3 )]
position = Vector2( 112, 136 )
[node name="Friend2" parent="." instance=ExtResource( 2 )]
position = Vector2( 256, 193 )
movement_distance = 3
water_walk = true
air_walk = true
lava_walk = true
sprite = ExtResource( 6 )
[node name="Foe" parent="." instance=ExtResource( 9 )]
position = Vector2( 74, 87 )
movement_distance = 10
sprite = ExtResource( 7 )
[node name="Grid" parent="." instance=ExtResource( 4 )]
[node name="BattleController" parent="." instance=ExtResource( 8 )]
[node name="LoadingScreen" parent="." instance=ExtResource( 5 )]
scale = Vector2( 0.001, 0.001 )
transform = Transform2D( 0.001, 0, 0, 0.001, 0, 0 )