initial
This commit is contained in:
commit
3ea7bfd5dc
122 changed files with 568704 additions and 0 deletions
14
Scene/Pieces/bishop.tscn
Executable file
14
Scene/Pieces/bishop.tscn
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene format=3 uid="uid://dsc2tova7rvx7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="2_bmony"]
|
||||
[ext_resource type="Material" uid="uid://bxg7bjgiqfnru" path="res://Materials/piece_black.tres" id="2_r76xr"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://c67nw3hvqrkev" path="res://Models/bishop.obj" id="3_r76xr"]
|
||||
|
||||
[node name="Bishop" type="Node3D" unique_id=1605941411]
|
||||
script = ExtResource("2_bmony")
|
||||
color = ExtResource("2_r76xr")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=830382749]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
|
||||
material_override = ExtResource("2_r76xr")
|
||||
mesh = ExtResource("3_r76xr")
|
||||
13
Scene/Pieces/king.tscn
Executable file
13
Scene/Pieces/king.tscn
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene format=3 uid="uid://qjo2ij73xlok"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_ycl1t"]
|
||||
[ext_resource type="Material" uid="uid://bxg7bjgiqfnru" path="res://Materials/piece_black.tres" id="2_5ys0t"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://bxtpbpxglphok" path="res://Models/king.obj" id="3_2gso2"]
|
||||
|
||||
[node name="King" type="Node3D" unique_id=1224931075]
|
||||
script = ExtResource("1_ycl1t")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=455294172]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
|
||||
material_override = ExtResource("2_5ys0t")
|
||||
mesh = ExtResource("3_2gso2")
|
||||
12
Scene/Pieces/knight.tscn
Executable file
12
Scene/Pieces/knight.tscn
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene format=3 uid="uid://di3qg1qnmy0p2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_qbtkq"]
|
||||
[ext_resource type="Material" uid="uid://bxg7bjgiqfnru" path="res://Materials/piece_black.tres" id="2_cka4e"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://hnlwpehvi3ok" path="res://Models/kight.obj" id="3_0w1en"]
|
||||
|
||||
[node name="Knight" type="Node3D" unique_id=1333208927]
|
||||
script = ExtResource("1_qbtkq")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=515809374]
|
||||
material_override = ExtResource("2_cka4e")
|
||||
mesh = ExtResource("3_0w1en")
|
||||
10
Scene/Pieces/pawn.tscn
Executable file
10
Scene/Pieces/pawn.tscn
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene format=3 uid="uid://dkl8itq74sajx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_nci4k"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://dn2vs5onakx6i" path="res://Models/pawn.obj" id="3_un5ic"]
|
||||
|
||||
[node name="Pawn" type="Node3D" unique_id=124611093]
|
||||
script = ExtResource("1_nci4k")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=1910024001]
|
||||
mesh = ExtResource("3_un5ic")
|
||||
77
Scene/Pieces/piece.gd
Executable file
77
Scene/Pieces/piece.gd
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
@tool
|
||||
class_name Piece
|
||||
extends Node3D
|
||||
|
||||
@export var piece_res : PieceRes
|
||||
var is_moving : bool = false
|
||||
var target : Vector2
|
||||
var start_pos :Vector3
|
||||
var start_coord: Vector2i
|
||||
var mesh_instance_3d: MeshInstance3D
|
||||
var possible_movements: Array[Vector2i]
|
||||
#@export var color : StandardMaterial3D = preload("uid://brrbuo0i0e5bh") as StandardMaterial3D:
|
||||
#set(material):
|
||||
#color = material
|
||||
#if Engine.is_editor_hint():
|
||||
#mesh.material_override = color
|
||||
#get:
|
||||
#return color
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
for rule in piece_res.rules:
|
||||
rule.ready(self)
|
||||
print(piece_res.material)
|
||||
var mesh_instance = MeshInstance3D.new()
|
||||
mesh_instance.mesh = piece_res.mesh
|
||||
mesh_instance.mesh.surface_set_material(0,piece_res.material)
|
||||
add_child(mesh_instance)
|
||||
mesh_instance_3d = mesh_instance
|
||||
start_coord = to_coord()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if is_moving:
|
||||
#move to target
|
||||
var x_diff = 0
|
||||
var z_diff = 0
|
||||
|
||||
if target.x < start_pos.x:
|
||||
x_diff = -(start_pos.x - target.x)
|
||||
else:
|
||||
x_diff = (target.x - start_pos.x)
|
||||
|
||||
if target.y < start_pos.z:
|
||||
z_diff = -(start_pos.z - target.y)
|
||||
else:
|
||||
z_diff = (target.y - start_pos.z)
|
||||
|
||||
|
||||
global_translate(Vector3(x_diff, 0, z_diff).normalized() * delta * piece_res.movement_speed)
|
||||
if abs(position.x - target.x) < 0.1:
|
||||
position.x = target.x
|
||||
if abs(target.y - position.z) < 0.1:
|
||||
position.z = target.y
|
||||
|
||||
if position.z == target.y and position.x == target.x:
|
||||
is_moving = false
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
func move_to(new_target: Vector2):
|
||||
for moverule_script in piece_res.rules:
|
||||
moverule_script.before_move(self)
|
||||
#if piece_res.piece_type == PieceRes.PieceType.PAWN:
|
||||
#possible_movements = [Vector2i(0,1)]
|
||||
target = new_target * 2
|
||||
start_pos = position
|
||||
is_moving = true
|
||||
pass
|
||||
|
||||
func to_coord() -> Vector2i:
|
||||
return Vector2i(position.x / 2, position.z / 2)
|
||||
|
||||
func die():
|
||||
queue_free()
|
||||
pass
|
||||
1
Scene/Pieces/piece.gd.uid
Executable file
1
Scene/Pieces/piece.gd.uid
Executable file
|
|
@ -0,0 +1 @@
|
|||
uid://c11aaiot3b336
|
||||
6
Scene/Pieces/piece.tscn
Executable file
6
Scene/Pieces/piece.tscn
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://ci6k70kme7egj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_y1oan"]
|
||||
|
||||
[node name="Piece" type="Node3D" unique_id=410020425]
|
||||
script = ExtResource("1_y1oan")
|
||||
12
Scene/Pieces/queen.tscn
Executable file
12
Scene/Pieces/queen.tscn
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene format=3 uid="uid://b5o0e01wkibu7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_gmwly"]
|
||||
[ext_resource type="Material" uid="uid://bxg7bjgiqfnru" path="res://Materials/piece_black.tres" id="2_uipd2"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://cbr1tmaelnbwv" path="res://Models/queen.obj" id="3_18v2x"]
|
||||
|
||||
[node name="Queen" type="Node3D" unique_id=1009873024]
|
||||
script = ExtResource("1_gmwly")
|
||||
color = ExtResource("2_uipd2")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=1534534969]
|
||||
mesh = ExtResource("3_18v2x")
|
||||
12
Scene/Pieces/rook.tscn
Executable file
12
Scene/Pieces/rook.tscn
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene format=3 uid="uid://dxh3jmv61jfp0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c11aaiot3b336" path="res://Scene/Pieces/piece.gd" id="1_4uxm1"]
|
||||
[ext_resource type="Material" uid="uid://bxg7bjgiqfnru" path="res://Materials/piece_black.tres" id="2_kqueb"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://bpi163efm64p2" path="res://Models/rook.obj" id="3_bs0i1"]
|
||||
|
||||
[node name="Rook" type="Node3D" unique_id=699678101]
|
||||
script = ExtResource("1_4uxm1")
|
||||
color = ExtResource("2_kqueb")
|
||||
|
||||
[node name="mesh" type="MeshInstance3D" parent="." unique_id=2043445377]
|
||||
mesh = ExtResource("3_bs0i1")
|
||||
Loading…
Add table
Add a link
Reference in a new issue