import gamebuino_meta as gb
btnState = [ False ] * 8
def isDown( btn ):
return btnState[btn]
def chkButtons():
for i in range(8):
if gb.buttons.pressed( i ):
if btnState[i] == False:
btnState[i] = True
if gb.buttons.released( i ):
if btnState[i]:
btnState[i] = False
x = 0
y = 0
w = 8
h = 8
while True:
gb.waitForUpdate()
gb.display.clear()
chkButtons()
xx = 0
yy = 0
if isDown( gb.buttons.LEFT ):
xx = -1
if isDown( gb.buttons.RIGHT ):
xx = 1
if isDown( gb.buttons.UP ):
yy = -1
if isDown( gb.buttons.DOWN ):
yy = 1
if ((x + xx) >= 0) & ((x + xx) <= 80 - w ):
x = x + xx
if ((y + yy) >= 0) & ((y + yy) <= 64 - h ):
y = y + yy
gb.display.setColor( gb.color.YELLOW )
gb.display.fillRect(x,y,w,h)
if gb.collide.rectRect( x, y, w, h, 20, 12, 40, 40):
gb.display.setColor( gb.color.RED )
else:
gb.display.setColor( gb.color.GRAY )
gb.display.drawRect( 20, 12 , 40, 40 )
gb.display.setColor( gb.color.WHITE )
gb.display.print("Move: D-PAD")
collide.pointRect(int pointX, int pointY, int rectX, int rectY, int rectW, int rectH)
collide.circleCircle(int centerX1, int centerY1, int r1, int centerX2, int centerY2, int r2)
collide.pointCircle(int pointX, int pointY, int centerX, int centerY, int r)