我目前正在某种作业中编码。 我创建了一个名为Ship的类,并创建了一些方法来使对象类ship能够移动。
class Ship():
def __init__(self):
self.center.x = 400
self.center.y = 300
self.velocity.dx = .25
self.velocity.dy = .25
def advance_down(self):
self.center.y = self.center.y - self.velocity.dy
这是我的代码
def check_keys(self):
"""
This function checks for keys that are being held down.
You will need to put your own method calls in here.
"""
if arcade.key.DOWN in self.held_keys:
self.ship1.advance_down()
前进仅改变位置
def on_key_press(self, key: int, modifiers: int):
"""
Puts the current key in the set of keys that are being held.
You will need to add things here to handle firing the bullet.
"""
if key == arcade.key.DOWN:
self.held_keys.add(key)
这会将当前按下的键添加到self.held_keys集中。 我正在打电话给正子。
def update(self, delta_time):
"""
Update each object in the game.
:param delta_time: tells us how much time has actually elapsed
""
self.ship1.advance_down()
当我运行代码时,我能够很好地显示所有内容,但是一旦按下按键,它什么也没做。 有什么想法吗?