Skip to content

Commit 4448c0a

Browse files
committed
obstacle-race: 床座標を変数化
1 parent 1ceb122 commit 4448c0a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

11-obstacle-race/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pyxel
1717

1818
TRANSPARENT_COLOR = 2
19+
FLOOR_YI = 10
1920

2021
_height = 0
2122
player = None
@@ -28,11 +29,11 @@ def is_colliding(y, is_falling):
2829
y2 = (pyxel.ceil(y) + 7) // 8
2930

3031
for yi in range(y1, y2 + 1):
31-
if yi >= 10:
32+
if yi >= FLOOR_YI:
3233
return True
3334

3435
if is_falling and y % 8 == 1:
35-
if y2 >= 10:
36+
if y2 >= FLOOR_YI:
3637
return True
3738
return False
3839

@@ -84,7 +85,7 @@ def update(self):
8485
if not self.space_pressed: # スペースが新たに押された
8586
self.space_pressed = True
8687
# 地面にいるか、空中で1回目のジャンプができるか
87-
if self.dy == 10 and not self.is_falling:
88+
if self.dy == FLOOR_YI and not self.is_falling:
8889
# 地面からのジャンプ
8990
self.dy = -8
9091
self.jump_count = 1
@@ -111,7 +112,7 @@ def update(self):
111112
self.is_falling = self.y > last_y
112113

113114
# 地面に着いたらジャンプカウントをリセット
114-
if self.dy == 10 and not self.is_falling:
115+
if self.dy == FLOOR_YI and not self.is_falling:
115116
self.jump_count = 0
116117

117118
if self.y >= _height:

0 commit comments

Comments
 (0)