rric

Inschriften_kreuz_und_quer

Nov 7th, 2023 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.76 KB | None | 0 0
  1. # Spiel mit Darstellung von Text [Mu: Pygame Zero]
  2. # Dokumentation:
  3. # https://pygame-zero.readthedocs.io/en/stable/ptext.html
  4. # https://codewith.mu/en/howto/1.2/pgzero_sounds_images
  5. # Copyright 2023 Roland Richter
  6.  
  7. # Erzeuge ein rechteckiges 900×600 Fenster
  8. WIDTH = 900
  9. HEIGHT = 600
  10.  
  11. botschaft = ""
  12.  
  13. hgfarbe = "#1C39BB"   # Persian blue
  14. textfarbe = "yellow"
  15.  
  16. transparenz = 1.0
  17. winkel = 0
  18.  
  19. def draw():
  20.     # Setze den Hintergrund auf "Persian blue"
  21.     screen.fill(hgfarbe)
  22.  
  23.     # Begrüße alle in der Mitte der Leinwand
  24.     screen.draw.text("Hallo Welt!", center=(WIDTH / 2, 100),
  25.                      color=textfarbe,
  26.                      fontname="rujis_handwriting", fontsize=42)
  27.  
  28.     # Ruji's Handwriting Font v.2.0, OFL (SIL Open Font License) Lizenz
  29.     # https://fontlibrary.org/en/font/ruji-s-handwriting-font-v-2-0
  30.     # ACHTUNG: der Name der Schriftart muss auf kleinbuchstaben geändert werden
  31.     screen.draw.text(botschaft, center=(WIDTH / 2, 200),
  32.                      color=textfarbe,
  33.                      fontname="rujis_handwriting", fontsize=42)
  34.  
  35.     screen.draw.text(botschaft, center=(WIDTH / 2, 300),
  36.                      color=textfarbe,
  37.                      fontname="rujis_handwriting", fontsize=42,
  38.                      shadow=(2,2), scolor="#202020")
  39.  
  40.     screen.draw.text(botschaft, center=(WIDTH / 2, 400),
  41.                      color=textfarbe, alpha=transparenz,
  42.                      fontname="rujis_handwriting", fontsize=42,
  43.                      angle=winkel)
  44.  
  45.  
  46. def update():
  47.     global transparenz, winkel
  48.     if transparenz > 0.0:
  49.         transparenz *= 0.999
  50.     winkel += 1
  51.  
  52.  
  53. def on_key_down(key, mod, unicode):
  54.     print(key)
  55.     global botschaft, hgfarbe, textfarbe, transparenz, winkel
  56.     if key == keys.RETURN:
  57.         botschaft = ""
  58.         textfarbe, hgfarbe = hgfarbe, textfarbe   # vertausche beide Farben
  59.         transparenz = 1.0
  60.         winkel = 0
  61.     elif key == keys.BACKSPACE:
  62.         if len(botschaft) > 0:
  63.             botschaft = botschaft[:-1]
  64.     else:
  65.         botschaft += unicode
  66.  
  67.  
  68. # ----------------------------------------------------------------------
  69. # This program is free software: you can redistribute it and/or modify
  70. # it under the terms of the GNU General Public License as published by
  71. # the Free Software Foundation, either version 3 of the License, or
  72. # (at your option) any later version.
  73. #
  74. # This program is distributed in the hope that it will be useful,
  75. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  76. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  77. # GNU General Public License for more details.
  78. #
  79. # You should have received a copy of the GNU General Public License
  80. # along with this program.  If not, see <https://www.gnu.org/licenses/>.
  81.  
Advertisement
Add Comment
Please, Sign In to add comment