
项目目录
>>>小游戏详细要求:
? ? ? ?1. 程序开始时,一个小球( led 小灯)从屏幕上方移动到屏幕中间
????????2.当按钮 A 按下时,小球向右移动,碰到屏幕边缘停止
????????3.当按钮 B 按下时,小球向左移动,碰到屏幕边缘停止
? ? ? ? 4.如果小球已经处于屏幕最右边,此时按下按钮 A,给出箭头提示按按钮 B,因为小球无法再往右移动
? ? ? ? 5.如果小球已经处于屏幕最左边,此时按下按钮 A,给出箭头提示按按钮 B,因为小球无法再往左移动
? ? ? ? 6.如果小球正向右移动,此时按下按钮 B,小球向左移动如果小球正向左移动,此时按下按钮 A,小球向右移动
项目方案及实施
????????1.利用循环(for、while)
????????2.利用选择语句(if ...else(else可省略))
for i in range(2):
led.plot(2, i)
basic.pause(500)
led.unplot(2, i)
temp = game.create_sprite(2, 2)
while True:
if input.button_is_pressed(Button.A):
temp.turn(Direction.LEFT, 180)
for i in range(4):
temp.move(1)
basic.pause(500)
if input.button_is_pressed(Button.B):
temp.turn(Direction.RIGHT, -180)
for j in range(4):
temp.move(1)
basic.pause(500)
temp.is_touching_edge()
if temp.is_touching_edge():
if led.point(4, 2):
if input.button_is_pressed(Button.A):
print(basic.show_arrow(ArrowNames.EAST))
if led.point(0, 2):
if input.button_is_pressed(Button.B):
print(basic.show_arrow(ArrowNames.WEST))
|