Toggle Navigation
Hatchery
Eggs
moving F
__init__.py
Users
Badges
Login
Register
__init__.py
raw
Content
import display as dp import buttons import audio import mch22 import random as r print("dit is niet in de display") channel_id = audio.play('/apps/python/floris_mch2022_test_project/sound.mp3', volume=100) y = 160 x = 130 y0 = 160 x0 = 130 score_0 = 0 eerdere_score = 0 dp.drawFill(dp.WHITE) channel_id = audio.play('/apps/myapp/doom.mp3', volume=150) dp.drawText(10, 10, "Moving F", dp.BLACK, "roboto_regular18") dp.drawText(1, 20, "____________________________", dp.BLACK, "roboto_regular18", 2, 2) dp.drawText(15,30,"score", dp.CYAN, "roboto_regular18") dp.flush() def move_if_match(): global y, x, y0, x0, score_0, eerdere_score if y0 == y and x0 == x : channel_id = audio.play('/apps/python/floris_mch2022_test_project/bliep.mp3', volume=100) dp.drawText(y0, x0,"0", dp.WHITE, "roboto_regular18") y0 = r.randrange(10,300,10) x0 = r.randrange(70,210,10) dp.drawText(y0, x0,"0", dp.RED, "roboto_regular18") dp.drawText(70 ,30 ,str(eerdere_score), dp.WHITE, "roboto_regular18") score_0 = score_0 + 1 dp.drawText(70 ,30 ,str(score_0), dp.BLACK, "roboto_regular18") eerdere_score = score_0 dp.flush() print("0 gedropt bij ({},{})".format(x0,y0)) def NaarBoven(pressed): global x, y, y0, x0 if pressed: if x < 70 : return dp.drawText(y, x, "F", dp.WHITE, "roboto_regular18") x = x - 10 move_if_match() dp.drawText(y, x, "F", dp.BLUE, "roboto_regular18") print("Naar beneden ({},{})".format(x,y)) dp.flush() def NaarBeneden(pressed): global x, y, y0, x0 if pressed: if x > 210 : return dp.drawText(y, x, "F", dp.WHITE, "roboto_regular18") x = x + 10 move_if_match() dp.drawText(y, x, "F", dp.BLUE, "roboto_regular18") print("Naar beneden ({},{})".format(x,y)) dp.flush() def NaarRechts(pressed): global x, y, y0, x0 if pressed: if y > 300 : return dp.drawText(y, x, "F", dp.WHITE, "roboto_regular18") y = y + 10 move_if_match() dp.drawText(y, x, "F", dp.BLUE, "roboto_regular18") print("Naar beneden ({},{})".format(x,y)) dp.flush() def NaarLinks(pressed): global x, y, y0, x0 if pressed: if y < 10 : return dp.drawText(y, x, "F", dp.WHITE, "roboto_regular18") y = y - 10 move_if_match() dp.drawText(y, x, "F", dp.BLUE, "roboto_regular18") print("Naar beneden ({},{})".format(x,y)) dp.flush() def terug_naar_spawn(pressed): global x, y, y0, x0 if pressed: dp.drawText(y, x, "F", dp.WHITE, "roboto_regular18") print("je bent terug gegaan naar spawn") y = 160 x = 130 move_if_match() dp.drawText(y, x, "F", dp.BLUE, "roboto_regular18") if y0 == y and x0 == x : dp.drawText(y0, x0,"0", dp.WHITE, "roboto_regular18") dp.flush() def uit(pressed): if pressed: mch22.exit_python() buttons.attach(buttons.BTN_HOME, uit) buttons.attach(buttons.BTN_UP, NaarBoven) buttons.attach(buttons.BTN_DOWN, NaarBeneden) buttons.attach(buttons.BTN_RIGHT, NaarRechts) buttons.attach(buttons.BTN_LEFT, NaarLinks) buttons.attach(buttons.BTN_PRESS, terug_naar_spawn) move_if_match()