質問編集履歴
1
class Paddleを作成してみましたが表示ができませんでした。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
ブロック崩しの移動するパドルを
|
3
|
+
ブロック崩しの移動するパドルを表示させたいのですがうまくいきません
|
4
|
+
パドルの当たり判定はまだ実装できていません
|
4
5
|
|
5
6
|
|
6
7
|
|
@@ -14,6 +15,8 @@
|
|
14
15
|
SCREEN_WIDTH = 256
|
15
16
|
SCREEN_HEIGHT = 256
|
16
17
|
BUBBLE_MAX_SPEED = 5
|
18
|
+
PADDLE_WIDTH = 60
|
19
|
+
PADDLE_HEIGHT = 30
|
17
20
|
|
18
21
|
|
19
22
|
class Vec2:
|
@@ -68,6 +71,23 @@
|
|
68
71
|
pyxel.circ(self.pos.x, self.pos.y, self.r, self.color)
|
69
72
|
|
70
73
|
|
74
|
+
class Paddle:
|
75
|
+
def __init__(self, x, y):
|
76
|
+
self.x = x
|
77
|
+
self.y = y
|
78
|
+
|
79
|
+
def update(self):
|
80
|
+
if pyxel.btn(pyxel.KEY_LEFT):
|
81
|
+
self.x -= 5
|
82
|
+
if pyxel.btn(pyxel.KEY_RIGHT):
|
83
|
+
self.x += 5
|
84
|
+
self.x = max(self.x, 0)
|
85
|
+
self.x = min(self.x, pyxel.width - self.w)
|
86
|
+
|
87
|
+
def draw(self):
|
88
|
+
pyxel.rect(self.x, self.y, PADDLE_WIDTH, PADDLE_HEIGHT)
|
89
|
+
|
90
|
+
|
71
91
|
class App:
|
72
92
|
def __init__(self):
|
73
93
|
self.life = 3
|
@@ -76,12 +96,14 @@
|
|
76
96
|
pyxel.load("assets/sepack-01edit.pyxres")
|
77
97
|
|
78
98
|
self.myball = Ball()
|
99
|
+
self.mypaddle = Paddle(pyxel.width / 2, pyxel.height - 20)
|
79
100
|
pyxel.run(self.update, self.draw)
|
80
101
|
|
81
102
|
def playse(self, munumber):
|
82
103
|
pyxel.playm(munumber)
|
83
104
|
|
84
105
|
def update(self):
|
106
|
+
self.mypaddle.update()
|
85
107
|
bound, death = self.myball.update()
|
86
108
|
if bound:
|
87
109
|
self.playse(0)
|
@@ -95,6 +117,7 @@
|
|
95
117
|
|
96
118
|
def draw(self):
|
97
119
|
pyxel.cls(0)
|
120
|
+
self.mypaddle.draw()
|
98
121
|
self.myball.draw()
|
99
122
|
pyxel.text(10, 10, "LIFE = " + str(self.life), 7)
|
100
123
|
if self.allball_is_dead:
|