Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Go Save The King
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Htoo Aung (kha451)
Go Save The King
Commits
16fe7e12
Commit
16fe7e12
authored
1 month ago
by
Alan
Browse files
Options
Downloads
Patches
Plain Diff
Added base rook movements
parent
16367bd8
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Refactoring game.gd to split up move validation to individual pieces, added...
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.godot/editor/editor_layout.cfg
+2
-2
2 additions, 2 deletions
.godot/editor/editor_layout.cfg
.godot/editor/script_editor_cache.cfg
+5
-5
5 additions, 5 deletions
.godot/editor/script_editor_cache.cfg
scripts/Rook.gd
+17
-9
17 additions, 9 deletions
scripts/Rook.gd
with
24 additions
and
16 deletions
.godot/editor/editor_layout.cfg
+
2
−
2
View file @
16fe7e12
...
...
@@ -27,7 +27,7 @@ dock_5="Inspector,Node,History"
open_scenes
=
PackedStringArray("res://scenes/game.tscn", "res://scenes/explosion.tscn", "res://scenes/Pawn.tscn", "res://scenes/Rook.tscn")
current_scene
=
"res://scenes/Pawn.tscn"
center_split_offset
=
-
288
center_split_offset
=
-
320
selected_default_debugger_tab_idx
=
0
selected_main_editor_idx
=
2
selected_bottom_panel_item
=
0
...
...
@@ -35,7 +35,7 @@ selected_bottom_panel_item=0
[ScriptEditor]
open_scripts
=
["res://scripts/game.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "res://scripts/Rook.gd"]
selected_script
=
"res://scripts/
game
.gd"
selected_script
=
"res://scripts/
Rook
.gd"
open_help
=
[]
script_split_offset
=
70
list_split_offset
=
0
...
...
This diff is collapsed.
Click to expand it.
.godot/editor/script_editor_cache.cfg
+
5
−
5
View file @
16fe7e12
...
...
@@ -7,7 +7,7 @@ state={
"folded_lines":
Array
[int]
(
[]
),
"h_scroll_position":
0,
"row":
122,
"scroll_position":
107
.0,
"scroll_position":
95
.0,
"selection":
false,
"syntax_highlighter":
"GDScript"
}
...
...
@@ -31,7 +31,7 @@ state={
state
=
{
"bookmarks":
PackedInt32Array(),
"breakpoints":
PackedInt32Array(),
"column":
14
,
"column":
0
,
"folded_lines":
Array
[int]
(
[]
),
"h_scroll_position":
0,
"row":
10,
...
...
@@ -45,11 +45,11 @@ state={
state
=
{
"bookmarks":
PackedInt32Array(),
"breakpoints":
PackedInt32Array(),
"column":
0
,
"column":
36
,
"folded_lines":
Array
[int]
(
[]
),
"h_scroll_position":
0,
"row":
16
,
"scroll_position":
6
.0,
"row":
52
,
"scroll_position":
39
.0,
"selection":
false,
"syntax_highlighter":
"GDScript"
}
This diff is collapsed.
Click to expand it.
scripts/Rook.gd
+
17
−
9
View file @
16fe7e12
...
...
@@ -2,19 +2,23 @@ extends Piece
class_name
Rook
enum
Upgrade
{
DIAGONAL_MOVE_ONE
,
}
func
_init
(
is_white
:
bool
,
position
:
Vector2
):
super
.
_init
(
is_white
,
position
)
func
get_valid_moves
(
board_state
:
Array
,
pos
:
Vector2
)
->
Array
[
Vector2
]:
var
valid_moves
=
[]
var
valid_moves
:
Array
[
Vector2
]
=
[]
var
x
=
pos
.
x
var
y
=
pos
.
y
# Check moves to the right
for
i
in
range
(
x
+
1
,
8
):
if
board_state
[
i
][
y
]
==
0
:
if
board_state
[
i
][
y
]
==
null
:
valid_moves
.
append
(
Vector2
(
i
,
y
))
elif
board_state
[
i
][
y
]
.
is_white
!=
is_white
:
elif
board_state
[
i
][
y
]
!=
null
and
not
board_state
[
i
][
y
]
.
is_white
:
valid_moves
.
append
(
Vector2
(
i
,
y
))
break
else
:
...
...
@@ -22,9 +26,9 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
# Check moves to the left
for
i
in
range
(
x
-
1
,
-
1
,
-
1
):
if
board_state
[
i
][
y
]
==
0
:
if
board_state
[
i
][
y
]
==
null
:
valid_moves
.
append
(
Vector2
(
i
,
y
))
elif
board_state
[
i
][
y
]
.
is_white
!=
is_white
:
elif
board_state
[
i
][
y
]
!=
null
and
not
board_state
[
i
][
y
]
.
is_white
:
valid_moves
.
append
(
Vector2
(
i
,
y
))
break
else
:
...
...
@@ -32,9 +36,11 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
# Check moves upwards
for
i
in
range
(
y
-
1
,
-
1
,
-
1
):
if
board_state
[
x
][
i
]
==
0
:
# Check if the square is empty
if
board_state
[
x
][
i
]
==
null
:
valid_moves
.
append
(
Vector2
(
x
,
i
))
elif
board_state
[
x
][
i
]
.
is_white
!=
is_white
:
# Check if the square has an enemy piece
elif
board_state
[
x
][
i
]
!=
null
and
not
board_state
[
x
][
i
]
.
is_white
:
valid_moves
.
append
(
Vector2
(
x
,
i
))
break
else
:
...
...
@@ -42,9 +48,11 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]:
# Check moves downwards
for
i
in
range
(
y
+
1
,
8
):
if
board_state
[
x
][
i
]
==
0
:
# Check if the square is empty
if
board_state
[
x
][
i
]
==
null
:
valid_moves
.
append
(
Vector2
(
x
,
i
))
elif
board_state
[
x
][
i
]
.
is_white
!=
is_white
:
# Check if the square has an enemy piece
elif
board_state
[
x
][
i
]
!=
null
and
not
board_state
[
x
][
i
]
.
is_white
:
valid_moves
.
append
(
Vector2
(
x
,
i
))
break
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment