Skip to content

Commit ed3c0ed

Browse files
committed
Saving so I can fix bug; I can either drag a piece or get the coord. of board, but not BOTH
1 parent 1cce6e1 commit ed3c0ed

File tree

3 files changed

+48
-38
lines changed

3 files changed

+48
-38
lines changed

Board.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
from position_of_mouse import find_position
66

77
class Scatter_Text_widget(FloatLayout):
8-
def on_mouse_pos(self, pos):
9-
#This function gets the position of the mouse, in chessboard labels
10-
position = find_position()
11-
pos_chess = position.chess_position(pos)
12-
print(pos_chess)
138

149

15-
Window.bind(mouse_pos = on_mouse_pos)
16-
10+
def on_touch_down(self, touch):
11+
position = find_position()
12+
pos_chess = position.chess_position(touch.pos)
13+
print(pos_chess)
1714

15+
def on_touch_up(self, touch):
16+
position = find_position()
17+
pos_chess = position.chess_position(touch.pos)
18+
print(pos_chess)
1819

1920
#Builds the App
2021
class window(App):

main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ def setup():
2929
'''
3030
TODO LIST
3131
32-
FIX THE SPACING OF THE BUTTONS
3332
34-
2.5 CODE A DRAGGING SYSTEM AND A TOUCH-BASED SYSTEM
33+
MAKE THE BUTTONS have a 'hard landing' IN EACH SQUARE AFTER THEY PLAYED
34+
MAKE THE LABELS DISSAPEAR WHEN CAPTURED
35+
36+
37+
38+
39+
40+
41+
42+
43+
2.5 CODE A TOUCH-BASED SYSTEM
3544
2.75 MAKE THE DRAGGING SYSTEM HAVE THE PIECES MOVE A LAYER UP FROM THE BOARD
3645
3. CODE ALL OF THE MOVES FOR THE PIECES (HARD; MAKE CODE STILL NEAT)
3746
4. CREATE A SYSTEM OF TURN-BASED GAMEPLAY (MEDIUM; NEED TO KEEP CODE CLEAN)

window.kv

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#######################################################################################################
66

77
<Scatter_Text_widget>
8+
89
canvas.before:
910
#Makes a rectangle around the window, and fills that with the .PNG of the Chessbaord
1011
Rectangle:
1112
pos: self.pos
1213
size: self.size
1314
source: 'Pictures\chessboard.png'
14-
1515
FloatLayout:
1616

1717
Scatter:
@@ -33,7 +33,7 @@
3333

3434
size_hint: None, None
3535
size: 100,100
36-
pos: 720,0
36+
pos: 717.5,0
3737

3838
Label:
3939
id: "Right White Rook"
@@ -48,7 +48,7 @@
4848

4949
size_hint: None, None
5050
size: 100,100
51-
pos: 100,0
51+
pos: 102.5,0
5252

5353
Label:
5454
id: "Left White Knight"
@@ -62,7 +62,7 @@
6262
Scatter:
6363
size_hint: None, None
6464
size: 100,100
65-
pos: 600,0
65+
pos: 615,0
6666

6767
Label:
6868
id: "Right White Knight"
@@ -76,7 +76,7 @@
7676
Scatter:
7777
size_hint: None, None
7878
size: 100,100
79-
pos: 200,0
79+
pos: 205,0
8080

8181
Label:
8282
id: "Left White Bishop"
@@ -89,7 +89,7 @@
8989

9090
Scatter:
9191
size_hint: None, None
92-
pos: 500,0
92+
pos: 512.5,0
9393
size: 100,100
9494

9595
Label:
@@ -105,7 +105,7 @@
105105
Scatter:
106106
size_hint: None, None
107107
size: 100,100
108-
pos: 400,0
108+
pos: 410,0
109109

110110
Label:
111111
id: "White King"
@@ -119,7 +119,7 @@
119119
Scatter:
120120
size_hint: None, None
121121
size: 100,100
122-
pos: 300,0
122+
pos: 307.5,0
123123

124124
Label:
125125
id: "White Queen"
@@ -148,7 +148,7 @@
148148
Scatter:
149149
size_hint: None, None
150150
size: 100,100
151-
pos: 100,100
151+
pos: 102.5,100
152152

153153
Label:
154154
id: "White Pawn2"
@@ -162,7 +162,7 @@
162162
Scatter:
163163
size_hint: None, None
164164
size: 100,100
165-
pos: 200,100
165+
pos: 205,100
166166

167167

168168
Label:
@@ -177,7 +177,7 @@
177177
Scatter:
178178
size_hint: None, None
179179
size: 100,100
180-
pos: 300,100
180+
pos: 307.5,100
181181

182182
Label:
183183
id: "White Pawn4"
@@ -191,7 +191,7 @@
191191
Scatter:
192192
size_hint: None, None
193193
size: 100,100
194-
pos: 400,100
194+
pos: 410,100
195195

196196
Label:
197197
id: "White Pawn5"
@@ -205,7 +205,7 @@
205205
Scatter:
206206
size_hint: None, None
207207
size: 100,100
208-
pos: 500,100
208+
pos: 512.5,100
209209

210210
Label:
211211
id: "White Pawn6"
@@ -219,7 +219,7 @@
219219
Scatter:
220220
size_hint: None, None
221221
size: 100,100
222-
pos: 600,100
222+
pos: 615,100
223223

224224
Label:
225225
id: "White Pawn7"
@@ -233,7 +233,7 @@
233233
Scatter:
234234
size_hint: None, None
235235
size: 100,100
236-
pos: 700,100
236+
pos: 717.5,100
237237

238238
Label:
239239
id: "White Pawn8"
@@ -266,7 +266,7 @@
266266
Scatter:
267267
size_hint: None, None
268268
size: 100,100
269-
pos: 700,700
269+
pos: 717.5,700
270270

271271
Label:
272272
id: "Right Black Rook"
@@ -280,7 +280,7 @@
280280
Scatter:
281281
size_hint: None, None
282282
size: 100,100
283-
pos: 100,700
283+
pos: 102.5,700
284284

285285
Label:
286286
id: "Left Black Knight"
@@ -294,7 +294,7 @@
294294
Scatter:
295295
size_hint: None, None
296296
size: 100,100
297-
pos:600,700
297+
pos:615,700
298298

299299
Label:
300300
id: "Right Black Knight"
@@ -308,7 +308,7 @@
308308
Scatter:
309309
size_hint: None, None
310310
size: 100,100
311-
pos: 200,700
311+
pos: 205,700
312312

313313
Label:
314314
id: "Left Black Bishop"
@@ -322,7 +322,7 @@
322322
Scatter:
323323
size_hint: None, None
324324
size: 100,100
325-
pos: 500,700
325+
pos: 512.5,700
326326

327327
Label:
328328
id: "Right Black Bishop"
@@ -336,7 +336,7 @@
336336
Scatter:
337337
size_hint: None, None
338338
size: 100,100
339-
pos: 400,700
339+
pos: 410,700
340340

341341
Label:
342342
id: "Black King"
@@ -350,7 +350,7 @@
350350
Scatter:
351351
size_hint: None, None
352352
size: 100,100
353-
pos: 309,700
353+
pos: 307.5,700
354354

355355
Label:
356356
id: "Black Queen"
@@ -382,7 +382,7 @@
382382
size_hint: None, None
383383
size: 100,100
384384

385-
pos: 100,600
385+
pos: 102.5,600
386386

387387
Label:
388388
id: "Black Pawn2"
@@ -396,7 +396,7 @@
396396
Scatter:
397397
size_hint: None, None
398398
size: 100,100
399-
pos: 200,600
399+
pos: 205,600
400400

401401
Label:
402402
id: "Black Pawn3"
@@ -410,7 +410,7 @@
410410
Scatter:
411411
size_hint: None, None
412412
size: 100,100
413-
pos: 300,600
413+
pos: 307.5,600
414414

415415
Label:
416416
id: "Black Pawn4"
@@ -424,7 +424,7 @@
424424
Scatter:
425425
size_hint: None, None
426426
size: 100,100
427-
pos: 400,600
427+
pos: 410,600
428428

429429
Label:
430430
id: "Black Pawn5"
@@ -438,7 +438,7 @@
438438
Scatter:
439439
size_hint: None, None
440440
size: 100,100
441-
pos: 500,600
441+
pos: 512.5,600
442442

443443
Label:
444444
id: "Black Pawn6"
@@ -451,7 +451,7 @@
451451

452452
Scatter:
453453
size_hint: None, None
454-
pos: 600,600
454+
pos: 615,600
455455
size: 100,100
456456

457457
Label:
@@ -466,7 +466,7 @@
466466
Scatter:
467467
size_hint: None, None
468468
size: 100,100
469-
pos: 700,600
469+
pos: 717.5,600
470470

471471
Label:
472472
id: "Black Pawn8"

0 commit comments

Comments
 (0)