Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lerne einiges über Koordinaten, Farbnamen und Farbcodes
- # Copyright 2023 Roland Richter [Mu: Pygame Zero]
- # Erzeuge ein rechteckiges Fenster der Größe 800×500
- WIDTH = 800
- HEIGHT = 500
- # Eine Position im Fenster kannst du mit (x, y)-Koordinaten angeben:
- # x ... horizontaler Wert, von links nach rechts (wie in Mathe)
- # y ... vertikaler Wert, von oben nach unten (anders als in Mathe!)
- # In Python beginnt man _nicht_ mit 1, sondern mit 0 zu zählen:
- # x ... Werte von 0 bis WIDTH-1
- # y ... Werte von 0 bis HEIGHT-1
- # Position (0, 0) ist also die linke obere Ecke des Fensters.
- # ÄNDERE den Code so, dass die Eckpunkte die korrekten Werte haben.
- # ↓---------↓---------↓---------↓---------↓---------↓---------↓
- links_oben = (1, 1)
- rechts_oben = (WIDTH - 1, 1)
- links_unten = (WIDTH - 1, HEIGHT - 1)
- rechts_unten = (1, HEIGHT + 1)
- # ↑---------↑---------↑---------↑---------↑---------↑---------↑
- # In Python nennt man einen Ausdruck wie (800, 500) auch ein "Tuple".
- # ÄNDERE den Code so, dass 'mitte' genau die Mitte des Fensters ist.
- # ↓---------↓---------↓---------↓---------↓---------↓---------↓
- mitte = (800, 500)
- # ↑---------↑---------↑---------↑---------↑---------↑---------↑
- # Farben kannst du entweder mit Namen wie "white", "orange" etc.
- # oder mit sogenannten HEX-Codes angeben. Meine Lieblings-Seite,
- # um solche Codes zu finden, ist https://latexcolor.com/
- # ÄNDERE den Code so, dass alle Farbnamen richtig sind.
- # ↓---------↓---------↓---------↓---------↓---------↓---------↓
- schwarz = "blakc"
- mikado_yellow = "FFC40C"
- ocean_boat_blue = "#07B"
- # ↑---------↑---------↑---------↑---------↑---------↑---------↑
- # HALT! Änderungen unter dieser Zeile sind verboten!
- # ↑---------↑---------↑---------↑---------↑---------↑---------↑
- def fail_string(name, val, exp):
- return "\n " + name + " ist " + str(val) + "\n sollte aber " + str(exp) + " sein"
- assert links_oben == (0, 0), fail_string("links_oben", links_oben, (0, 0))
- assert rechts_oben == (WIDTH - 1, 0), fail_string(
- "rechts_oben", rechts_oben, (WIDTH - 1, 0)
- )
- assert links_unten == (0, HEIGHT - 1), fail_string(
- "links_unten", links_unten, (0, HEIGHT - 1)
- )
- assert rechts_unten == (WIDTH - 1, HEIGHT - 1), fail_string(
- "rechts_unten", rechts_unten, (WIDTH - 1, HEIGHT - 1)
- )
- assert mitte == (WIDTH // 2, HEIGHT // 2), fail_string(
- "mitte", mitte, (WIDTH // 2, HEIGHT // 2)
- )
- assert schwarz == "black", fail_string("schwarz", schwarz, "black")
- assert mikado_yellow == "#FFC40C", fail_string(
- "mikado_yellow", mikado_yellow, "#FFC40C"
- )
- assert ocean_boat_blue == "#0077BE", fail_string(
- "ocean_boat_blue", ocean_boat_blue, "#0077BE"
- )
- def draw():
- screen.fill(ocean_boat_blue)
- screen.draw.text(
- "Du hast es geschafft! Bravo!", center=mitte, color=mikado_yellow, fontsize=48
- )
- def update():
- pass
- # ----------------------------------------------------------------------
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement