Skip to content

Commit e62dee2

Browse files
committed
Have one file for buttons and the board. Am working on modularizing the code.
1 parent b36e0ab commit e62dee2

File tree

6 files changed

+136
-3
lines changed

6 files changed

+136
-3
lines changed

Board.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
from kivy.app import App
1+
22
from kivy.uix.screenmanager import Screen
33
from kivy.config import Config
44
from kivy.core.window import Window
5+
from kivy.factory import Factory
6+
from kivy.uix.gridlayout import GridLayout
7+
from kivy.lang import Builder
8+
from kivy.uix.button import Button
9+
from kivy.app import App
10+
from kivy.uix.gridlayout import GridLayout
11+
12+
513

614

715
class main_window(Screen):
816
pass
917

18+
1019
class filename(App):
1120
def build(self):
21+
app = App.get_running_app()
1222
return main_window()
1323

1424

1525

1626
if __name__ == "__main__":
17-
width_of_board = 800
27+
width_of_board = 820
1828
height_of_board = 800
29+
1930
#Set the Hight and Width of the App
2031
Config.set('graphics', 'width', str(width_of_board))
2132
Config.set('graphics', 'height', str(height_of_board))
2233

2334
#Make the App non-resizable
2435
Config.set('graphics', 'resizable', '0')
2536
Config.write()
37+
2638
#Make the top windows bar go away
27-
#Window.borderless = True
39+
Window.borderless = True
2840
filename().run()

black_Bishop.png

1.23 KB
Loading

filename.kv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# File name: Board.py
2+
# include force pieces.kv
23

34
<main_window>
5+
id: main_window
46
canvas.before:
57
Rectangle:
68
pos: self.pos

main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from kivy.app import App
2+
3+
4+
5+
6+
7+
'''
8+
TODO LIST
9+
10+
1. FIGURE OUT CODE ARCHITECTURE (HARD)
11+
2. DISPLAY THE PIECES AND MAKE IT LOOK SEEMLESS (easy when code arch. is finished)
12+
2.5 CODE A DRAGGING SYSTEM AND A TOUCH-BASED SYSTEM
13+
2.75 MAKE THE DRAGGING SYSTEM HAVE THE PIECES MOVE A LAYER UP FROM THE BOARD
14+
3. CODE ALL OF THE MOVES FOR THE PIECES (HARD; MAKE CODE STILL NEAT)
15+
4. CREATE A SYSTEM OF TURN-BASED GAMEPLAY (MEDIUM; NEED TO KEEP CODE CLEAN)
16+
5. CREATE A SYSTEM TO SHOW THE USER WHERE TO PLACE: AND A CHECK-BASED SYSTEM
17+
6. CREATE A SYSTEM FOR KILLING OTHER PIECES
18+
19+
DONE;
20+
THE GAMEPLAY SHOULD BE BASICALLY DONE
21+
22+
'''

pieces.kv

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# File name: pieces.py
2+
3+
<white_pieces>
4+
5+
#ALL OF THE 'REGULAR' PIECES:
6+
7+
Button:
8+
id: "Left White Rook"
9+
text: "Left White Rook"
10+
pos: 0,0
11+
Button:
12+
id: "Right White Rook"
13+
text: "Right White Rook"
14+
pos: 720,0
15+
Button:
16+
id: "Left White Knight"
17+
text: "Left White Knight"
18+
pos: 100,0
19+
Button:
20+
id: "Right White Knight"
21+
text: "Right White Knight"
22+
pos: 620,0
23+
Button:
24+
id: "Left White Bishop"
25+
text: "Left White Bishop"
26+
pos: 200,300
27+
background_normal: 'black_Bishop.png'
28+
background_down: 'black_Bishop.png'
29+
on_press: root.yes()
30+
on_release: root.no()
31+
Button:
32+
id: "Right White Bishop"
33+
text: "Right White Bishop"
34+
pos: 520,0
35+
background_color: 0,0,0,0
36+
Button:
37+
id: "White King"
38+
text: "White King"
39+
pos: 300,0
40+
Button:
41+
id: "White Queen"
42+
text: "White Queen"
43+
pos: 410, 0
44+
#ALL OF THE PAWNS:
45+
46+
Button:
47+
id: "Pawn1"
48+
text: "Pawn1"
49+
pos: 20,100
50+
Button:
51+
id: "Pawn2"
52+
text: "Pawn2"
53+
pos: 120,100
54+
Button:
55+
id: "Pawn3"
56+
text: "Pawn3"
57+
pos: 220,100
58+
Button:
59+
id: "Pawn4"
60+
text: "Pawn4"
61+
pos: 320,100
62+
Button:
63+
id: "Pawn5"
64+
text: "Pawn5"
65+
pos: 420,100
66+
Button:
67+
id: "Pawn6"
68+
text: "Pawn6"
69+
pos: 520,100
70+
Button:
71+
id: "Pawn7"
72+
text: "Pawn7"
73+
pos: 620,100
74+
75+
Button:
76+
id: "Pawn8"
77+
text: "Pawn8"
78+
pos: 720,100

pieces.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from kivy.uix.button import Button
2+
from kivy.app import App
3+
from kivy.uix.gridlayout import GridLayout
4+
from kivy.uix.behaviors import ButtonBehavior
5+
from kivy.uix.image import Image
6+
7+
8+
9+
class white_pieces(Button, Image):
10+
def yes(self):
11+
print("CLICK")
12+
def no(self):
13+
print("NOPE")
14+
15+
class pieces(App):
16+
def build(self):
17+
return white_pieces()
18+
19+
pieces().run()

0 commit comments

Comments
 (0)