Skip to content

Instantly share code, notes, and snippets.

View horstjens's full-sized avatar
💭
teaching python/pygame to children

Horst JENS horstjens

💭
teaching python/pygame to children
View GitHub Profile
import random
# dice - simulate dungeon & dragons dice to generate random values
def dice(dicestring):
"""
1d6 -> random integer between 1 and 6
2d6 -> random integer between 2 and 12
1d20+5 -> random integer between 6 and 26
"""
@horstjens
horstjens / gui1.py
Last active July 14, 2023 10:43
konstantins_magic_duel
import PySimpleGUI as sg
import random
from PIL import Image
from io import BytesIO
import pathlib
class Game:
tile_size = 80
#image_size = 72*2 # ? # replaced by .size attribute of each monster
@horstjens
horstjens / rogue2.py
Created June 20, 2023 15:01
rogue2_brothers
#rogue2.py
import PySimpleGUI as sg
import random
herox = 20
heroy = 10
level_1 = """
########################################
#......................................#
#......................................#
import random
words = [
"teacher",
"classroom",
"window",
"door",
"tree",
"light",
"table",
import random
import time
import PySimpleGUI as sg
import datetime
#https://github.com/dwyl/english-words/tree/master
with open("german.txt") as myfile:
wörter = [wort.strip() for wort in myfile.readlines()]
#print(wörter)
@horstjens
horstjens / fujojo_tipptrainer1.py
Created June 17, 2023 11:58
fujojo_tipptrainer
import random
import PySimpleGUI as sg
import matplotlib.pyplot as plt
import matplotlib
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(
figure, canvas)
figure_canvas_agg.draw()
import random
import time
zahl1 = random.randint(1,15)
zahl2 = random.randint(1,15)
startzeit = time.time()
while True:
print(f"Wieviel ist {zahl1*zahl2} / {zahl2} ?")
antwort = input(">>>")
import os
import time
text_schlüssel = """
"""
text_türe = """
"""
# duell.py
import random
# 2 kämpfer kämpfen gegeneinander
monsternamen = ["Dragomir", "Haudrauf", "King Kong",
"Godzilla", "Mister Bean"]
waffen = ["Schwert", "Speer", "Axt", "Keule", "Schlagring"]
rüstungen = ["Helm", "Schild", "Stiefel", "Lederjacke",
@horstjens
horstjens / tipptrainer_sighan.py
Created May 20, 2023 14:52
pysimplegui tipptrainer german
import random
import time
import PySimpleGUI as sg
with open("german.txt") as myfile:
wörter = [wort.strip() for wort in myfile.readlines()]
#print(wörter)
layout = [
[sg.Text("mein Wort:"), sg.Text("abc", key="text1",