• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

pygameでテトリス


Commit MetaInfo

Revisiond622fc317431de9728953fef3db6d0213af375e2 (tree)
Time2014-11-01 11:07:35
Authorstone725 <stone_725@outl...>
Commiterstone725

Log Message

On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: game.py

Change Summary

Incremental Difference

--- a/game.py
+++ b/game.py
@@ -15,27 +15,27 @@ screen = pygame.display.set_mode(size)
1515 now_y = 0
1616 a = 0
1717 run = True
18-field = [[1,0,0,0,0,0,0,0,0,1],
19- [1,0,0,0,0,0,0,0,0,1],
20- [1,0,0,0,0,0,0,0,0,1],
21- [1,0,0,0,0,0,0,0,0,1],
22- [1,0,0,0,0,0,0,0,0,1],
23- [1,0,0,0,0,0,0,0,0,1],
24- [1,0,0,0,0,0,0,0,0,1],
25- [1,0,0,0,0,0,0,0,0,1],
26- [1,0,0,0,0,0,0,0,0,1],
27- [1,0,0,0,0,0,0,0,0,1],
28- [1,0,0,0,0,0,0,0,0,1],
29- [1,0,0,0,0,0,0,0,0,1],
30- [1,0,0,0,0,0,0,0,0,1],
31- [1,0,0,0,0,0,0,0,0,1],
32- [1,0,0,0,0,0,0,0,0,1],
33- [1,0,0,0,0,0,0,0,0,1],
34- [1,0,0,0,0,0,0,0,0,1],
35- [1,0,0,0,0,0,0,0,0,1],
36- [1,0,0,0,0,0,0,0,0,1],
37- [1,0,0,0,0,0,0,0,0,1],
38- [1,1,1,1,1,1,1,1,1,1]]
18+field = [[1,0,0,0,0,0,0,0,0,0,0,1],
19+ [1,0,0,0,0,0,0,0,0,0,0,1],
20+ [1,0,0,0,0,0,0,0,0,0,0,1],
21+ [1,0,0,0,0,0,0,0,0,0,0,1],
22+ [1,0,0,0,0,0,0,0,0,0,0,1],
23+ [1,0,0,0,0,0,0,0,0,0,0,1],
24+ [1,0,0,0,0,0,0,0,0,0,0,1],
25+ [1,0,0,0,0,0,0,0,0,0,0,1],
26+ [1,0,0,0,0,0,0,0,0,0,0,1],
27+ [1,0,0,0,0,0,0,0,0,0,0,1],
28+ [1,0,0,0,0,0,0,0,0,0,0,1],
29+ [1,0,0,0,0,0,0,0,0,0,0,1],
30+ [1,0,0,0,0,0,0,0,0,0,0,1],
31+ [1,0,0,0,0,0,0,0,0,0,0,1],
32+ [1,0,0,0,0,0,0,0,0,0,0,1],
33+ [1,0,0,0,0,0,0,0,0,0,0,1],
34+ [1,0,0,0,0,0,0,0,0,0,0,1],
35+ [1,0,0,0,0,0,0,0,0,0,0,1],
36+ [1,0,0,0,0,0,0,0,0,0,0,1],
37+ [1,0,0,0,0,0,0,0,0,0,0,1],
38+ [1,1,1,1,1,1,1,1,1,1,1,1]]
3939
4040 block = [[[[0,0,0,0], # □□□□
4141 [1,0,0,0], # ■□□□
@@ -235,7 +235,9 @@ block = [[[[0,0,0,0], # □□□□
235235 [2,3,3,-1]]]]
236236 e = 0
237237 now_x = 20
238+x_move = 180
238239 count_x = 0
240+font = pygame.font.Font(None, 35)
239241 score = 0
240242 now_block = random.randint(0,6)
241243 not_move = False
@@ -265,29 +267,26 @@ while run:
265267 for y in range(4): #縦
266268 for x in range(4): #横
267269 if block[now_block][e][y][x] == 1:
268- pygame.draw.rect(sc, (255,255,0),Rect(x * 20 + now_x,y * 20 + now_y,20,20))
270+ pygame.draw.rect(sc, (255,255,0),Rect(x * 20 + now_x + x_move,y * 20 + now_y,20,20))
269271 for y in range(21):
270- for x in range(10):
272+ for x in range(12):
271273 if field[y][x] == 1:
272- if y % 20 == 0 or x % 9 == 0:
273- pygame.draw.rect(sc, (255,0,0),Rect(x * 20, y * 20,20,20))
274+ if y == 20 or x % 11 == 0:
275+ pygame.draw.rect(sc, (255,0,0),Rect(x * 20 + x_move, y * 20,20,20))
274276 else:
275- pygame.draw.rect(sc, (255,255,0),Rect(x * 20, y * 20, 20, 20))
277+ pygame.draw.rect(sc, (255,255,0),Rect(x * 20 + x_move, y * 20, 20, 20))
276278 a += 1
277- if a >= rate:
278- for x in range(4):
279+ for x in range(4):
279280 if block[now_block][e][5][x] != -1:
280- if field[now_y / 20 + block[now_block][e][5][x] + 1][now_x / 20 + x] == 1:
281- not_move = True
282- if now_y / 20 + block[now_block][e][5][x] < 3:
281+ for y in range(block[now_block][e][4][x], block[now_block][e][5][x] + 1):
282+ if field[now_y / 20 + y][now_x / 20 + x] == 1:
283+ not_move = True
283284 print "Game Over"
284285 print score
285286 run = False
286- else:
287- score += 1
288- if not_move == False:
289- now_y += 20
290- a -= rate
287+ break
288+ if run == False:
289+ break
291290 key = pygame.key.get_pressed()
292291 if key[K_LEFT]:
293292 if count_x > 0:
@@ -324,12 +323,14 @@ while run:
324323 if block[now_block][e][5][x] != -1:
325324 if field[now_y / 20 + block[now_block][e][5][x] + 1][now_x / 20 + x] == 1:
326325 not_move = True
327- if now_y / 20 + block[now_block][e][5][x] < 3:
326+ if now_y / 20 + block[now_block][e][5][x] < 4:
328327 print "Game Over"
329328 print score
330329 run = False
330+ break
331331 else:
332332 score += 1
333+ break
333334 if not_move == False:
334335 now_y += 20
335336 a -= rate
@@ -345,19 +346,51 @@ while run:
345346 not_move = False
346347 for y in range(19, 0, -1):
347348 can_copy = True
348- for x in range(1,10):
349+ for x in range(1,11):
349350 if field[y][x] == 0:
350351 can_copy = False
351352 if can_copy == True:
352353 score += 10
353- for x in range(1,9):
354+ for x in range(1,11):
354355 field[0][x] = 0
355356 for yy in range(y,0,-1):
356357 field[yy] = copy.copy(field[yy - 1])
358+ y += 1
359+ if a >= rate:
360+ for x in range(4):
361+ if block[now_block][e][5][x] != -1:
362+ if field[now_y / 20 + block[now_block][e][5][x] + 1][now_x / 20 + x] == 1:
363+ not_move = True
364+ if now_y / 20 + block[now_block][e][5][x] < 3:
365+ print "Game Over"
366+ print score
367+ run = False
368+ break
369+ else:
370+ score += 1
371+ break
372+ for x in range(4):
373+ if block[now_block][e][5][x] != -1:
374+ for y in range(block[now_block][e][4][x], block[now_block][e][5][x] + 1):
375+ if field[now_y / 20 + y][now_x / 20 + x] == 1:
376+ not_move = True
377+ print "Game Over"
378+ print score
379+ run = False
380+ break
381+ if run == False:
382+ break
383+
384+ if not_move == False:
385+ now_y += 20
386+ a -= rate
387+ stri = "Score : " + str(score)
388+ string = font.render(stri, True, (255,255,255))
389+ screen.blit(string, (220, 420))
390+
357391 clock.tick(rate)
358392 pygame.display.flip()
359393
360394
361395
362396
363-