import machine import Random import Oled SCREEENWIDTH = 128 SCREEENHEIGHT = 32 GROUND = SCREEENHEIGHT oled = Oled.Oled(SCREEENWIDTH, SCREEENHEIGHT) oled.erase() robj = Random.Random() class GameHandler: jumpButton = None gravity = 0.0 player = None enemies = [] score = 0 def __init__(self): self.jumpButton = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP) global GROUND self.player = GameObject(5, GROUND - 15, 10, 15) self.enemies = [] self.score = 0 self.gravity = GROUND / 30
import machine import Random import Oled oled = Oled.Oled() oled.erase() robj = Random.Random() delay = 0.5 screenWidth = 128 screenHeight = 32 drawButton = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP) eraseButton = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_UP) def drawSquare(x, y, size): oled.rectangle(int(x), int(y), int(size)) def drawCircle(x, y, radius): oled.circle(int(x), int(y), int(radius)) def drawShape(x, y, size): shape = robj.randRange(1) if shape == 0: drawCircle(x, y, size/1.5) elif shape == 1: