online multiplayer chess game (note server currently down)
| -rw-r--r-- | Grid.gd | 3 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | icon.png | 3 | ||||
| -rw-r--r-- | icon.png.import | 35 | ||||
| -rw-r--r-- | pieces/Bishop.gd | 2 | ||||
| -rw-r--r-- | pieces/King.gd | 4 | ||||
| -rw-r--r-- | pieces/Knight.gd | 4 | ||||
| -rw-r--r-- | pieces/Pawn.gd | 8 | ||||
| -rw-r--r-- | pieces/Piece.gd | 25 | ||||
| -rw-r--r-- | pieces/Queen.gd | 2 | ||||
| -rw-r--r-- | pieces/Rook.gd | 2 | ||||
| -rw-r--r-- | project.godot | 16 |
12 files changed, 80 insertions, 26 deletions
@@ -23,7 +23,7 @@ var last_clicked onready var piece_sets = walk_dir() -func _ready(): +func _ready(): # TODO: add checkmates Globals.grid = self # tell the globals that this is the grid init_board() # create the tile squares init_matrix() # create the pieces @@ -168,6 +168,7 @@ func square_clicked(position: Vector2): # square clicked if !last_clicked: # last clicked is null, so this is pointless return if check_for_frame(position): # takeable + print("EATING " + last_clicked.shortname + " AT " + str(position)) # print the move last_clicked.take(matrix[position.y][position.x]) # eat turn_over() if check_for_circle(position): # see if theres a circle at the position @@ -1,3 +1,3 @@ - + completly works (real) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..bfc8b43 --- /dev/null +++ b/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:30eb5e527b188040d58cb5b131b180563cddfc002401259e0c115e5ff1fe2541 +size 50142 diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..020623f --- /dev/null +++ b/icon.png.import @@ -0,0 +1,35 @@ +[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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/pieces/Bishop.gd b/pieces/Bishop.gd index e542ebf..8b2f2c1 100644 --- a/pieces/Bishop.gd +++ b/pieces/Bishop.gd @@ -1,5 +1,5 @@ extends Piece -class_name Bishop +class_name Bishop, "res://assets/california/wB.png" func get_moves(): diff --git a/pieces/King.gd b/pieces/King.gd index a5b44d2..c63e6e4 100644 --- a/pieces/King.gd +++ b/pieces/King.gd @@ -1,5 +1,5 @@ extends Piece -class_name King +class_name King, "res://assets/california/wK.png" func get_moves(): @@ -7,6 +7,8 @@ func get_moves(): for i in all_dirs(): var spot = pos_around(i) if is_on_board(spot): + if no_enemys and at_pos(spot): + continue if check_spots_check and Globals.in_check and checkcheck(spot): continue moves.append(spot) diff --git a/pieces/Knight.gd b/pieces/Knight.gd index 477afec..e46651c 100644 --- a/pieces/Knight.gd +++ b/pieces/Knight.gd @@ -1,5 +1,5 @@ -class_name Knight extends Piece +class_name Knight, "res://assets/california/wN.png" func get_moves(): @@ -16,6 +16,8 @@ func get_moves(): var final = [] for i in moves: if is_on_board(i): + if no_enemys and at_pos(i): + continue if check_spots_check and checkcheck(i): continue final.append(i) diff --git a/pieces/Pawn.gd b/pieces/Pawn.gd index 7760913..3e7e8d9 100644 --- a/pieces/Pawn.gd +++ b/pieces/Pawn.gd @@ -1,10 +1,11 @@ extends Piece -class_name Pawn +class_name Pawn, "res://assets/california/wP.png" + +onready var whiteint = 1 if white else -1 func get_moves(): var points = [Vector2.UP, Vector2.UP * 2] - var whiteint = 1 if white else -1 var moves = [] for i in range(len(points)): var point = points[i] @@ -22,7 +23,6 @@ func get_moves(): func get_attacks(): var points = [Vector2.UP + Vector2.RIGHT, Vector2.UP + Vector2.LEFT] - var whiteint = int(white) var moves = [] for i in range(len(points)): var point = points[i] @@ -30,6 +30,8 @@ func get_attacks(): point = pos_around(point) if !is_on_board(point): continue + if check_spots_check and checkcheck(point): + continue if at_pos(point) != null and at_pos(point).white != white: moves.append(point) return moves diff --git a/pieces/Piece.gd b/pieces/Piece.gd index 6cb3185..6c7721b 100644 --- a/pieces/Piece.gd +++ b/pieces/Piece.gd @@ -9,6 +9,7 @@ var sprite var frameon var team = "w" var check_spots_check = true +var no_enemys = false onready var tween = $Tween onready var anim = $AnimationPlayer @@ -76,7 +77,7 @@ func all_dirs(): ] -func traverse(arr = [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]): # TODO: get this system to work with taking pieces +func traverse(arr = [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]): var circle_array = [] for i in arr: var pos = real_position @@ -84,11 +85,12 @@ func traverse(arr = [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT]): # pos += i if !is_on_board(pos): break - if at_pos(pos) != null: # only one black + if at_pos(pos) != null: # only one enemy + if no_enemys: # or none + break circle_array.append(pos) break if check_spots_check and checkcheck(pos): - print(checkcheck(pos)) continue circle_array.append(pos) return circle_array @@ -103,12 +105,16 @@ func get_moves(): # @Override func get_attacks(): # @Override + no_enemys = false var moves = get_moves() # assumes the attacks are same as moves var final = [] for i in moves: if at_pos(i) != null: if at_pos(i).white != white: # attack ze enemie + if check_spots_check and checkcheck(i): + continue final.append(i) + no_enemys = true return final @@ -127,15 +133,16 @@ func create_move_circles(pos): func create_take_circles(spot): # create take circles - spot.set_frame(true) # turn on the little take frame on the piece, to show its takeable + spot.set_frame() # turn on the little take frame on the piece, to show its takeable func set_circle(positions: Array, type := "move"): for pos in positions: var spot = at_pos(pos) # get the piece at the position - if type == "move": # if the type is move + if type == "move": + print(shortname, " can move to ", pos) create_move_circles(pos) # create the move circle - elif type == "take": # if the type is take + elif type == "take": create_take_circles(spot) # if the king is in check, return true @@ -145,12 +152,12 @@ func checkcheck(pos): # moves to position, then checks if your king is in check if Globals.grid.check_in_check(): # if you are still in check Globals.grid.matrix = mat # revert changes on the matrix return true - Globals.grid.matrix = mat # revert changes on the matrix + Globals.grid.matrix = mat return false func is_on_board(vector: Vector2): - if vector.y < 0 or vector.y > 7 or vector.x < 0 or vector.x > 7: + if vector.y < 0 or vector.y > 7 or vector.x < 0 or vector.x > 7: # limit the vector to the board return false return true @@ -165,6 +172,6 @@ func took(): # called when piece is taken anim.play("Take") -func set_frame(value): +func set_frame(value = true): frameon = value frame.visible = value diff --git a/pieces/Queen.gd b/pieces/Queen.gd index 2ce7689..b853fed 100644 --- a/pieces/Queen.gd +++ b/pieces/Queen.gd @@ -1,5 +1,5 @@ extends Piece -class_name Queen +class_name Queen, "res://assets/california/wQ.png" func get_moves(): diff --git a/pieces/Rook.gd b/pieces/Rook.gd index 85eb97b..03d2d40 100644 --- a/pieces/Rook.gd +++ b/pieces/Rook.gd @@ -1,5 +1,5 @@ -class_name Rook extends Piece +class_name Rook, "res://assets/california/wR.png" func get_moves(): diff --git a/project.godot b/project.godot index 223672b..b53f041 100644 --- a/project.godot +++ b/project.godot @@ -50,14 +50,14 @@ _global_script_classes=[ { "path": "res://pieces/Rook.gd" } ] _global_script_class_icons={ -"Bishop": "", +"Bishop": "res://assets/california/wB.png", "Grid": "", -"King": "", -"Knight": "", -"Pawn": "", +"King": "res://assets/california/wK.png", +"Knight": "res://assets/california/wN.png", +"Pawn": "res://assets/california/wP.png", "Piece": "res://assets/california/wP.png", -"Queen": "", -"Rook": "" +"Queen": "res://assets/california/wQ.png", +"Rook": "res://assets/california/wR.png" } [application] @@ -67,7 +67,9 @@ config/description="pog" run/main_scene="res://World.tscn" config/use_custom_user_dir=true config/custom_user_dir_name="chess" -config/icon="res://assets/california/wP.png" +boot_splash/image="res://icon.png" +boot_splash/bg_color=Color( 0.309804, 0.309804, 0.309804, 0.313726 ) +config/icon="res://icon.png" [autoload] |