Python%20games update 1

Page 1

198

ALLES OP EEN RIJ

Coderingen per project Hier vind je de complete Python-codering voor elk project in dit boek, behalve voor de hacks en tweaks. Werken je projecten niet goed, controleer je scripts dan zorgvuldig aan de hand van de coderingen hieronder. Schiet het fruit (blz. 48) from random import randint appel = Actor('apple') def draw(): screen.clear() appel.draw() def plaats_appel(): appel.x = randint(10, 800) appel.y = randint(10, 600) def on_mouse_down(pos): if appel.collidepoint(pos): print('Goed schot!') plaats_appel() else: print('Je hebt gemist!') exit() plaats_appel()

Muntenverzamelaar (blz. 58) from random import randint WIDTH = 400 HEIGHT = 400 score = 0 game_over = False vos = Actor('fox') vos.pos = 100, 100 munt = Actor('coin') munt.pos = 200, 200


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.