import pygame import gamebox camera = gamebox.Camera(400, 400) character = gamebox.from_color(200, 200, 'blue', 15, 15) blocks = [ gamebox.from_color(180, 300, 'brown', 320, 20), gamebox.from_color(200, 180, 'darkgreen', 20, 140), gamebox.from_color(80, 260, 'black', 20, 80), gamebox.from_color(280, 290, 'black', 20, 80) ] coins = [ gamebox.from_color(230, 240, 'yellow', 20, 20) ] def tick(keys): camera.clear('darkgray') if pygame.K_LEFT in keys: character.x -= 5 # move left if pygame.K_RIGHT in keys: character.x += 5 # move right if pygame.K_SPACE in keys: character.speedy = -10 # make character jump # (change the number and see how high it jump) character.speedy += 1 # set gravity character.move_speed() # move at current speed for block in blocks: character.move_to_stop_overlapping(block) # update speed of character, move character for thing in coins: if thing.touches(character): coins.remove(thing) # if that coin has been touched (collected), # remove it from the list of coins items_on_screen = blocks + coins for item in items_on_screen: camera.draw(item) camera.draw(character) camera.display() gamebox.timer_loop(30, tick)