Skip to content

Instantly share code, notes, and snippets.

teaching python/pygame to children

Horst JENS horstjens

teaching python/pygame to children
View GitHub Profile
horstjens /
Created Feb 18, 2021
Vektorprojektion auf anderen Vektor
import vpython as v
scene1 = v.canvas(title="auftrieb",
center=v.vector(0, 0, 0),
background=v.vector(0.4, .4, 0.4),
scene1.autoscale = False
ground = = v.vector(0,0,0), size=v.vector(10,0,10), color=v.vector(0.1,0.1,0.9), opacity=0.2)
# requriements:
# sudo pip3 install vpython
# sudo pip3 install pygame
import vpython as v
import random
import pygame
#except ModuleNotFoundError:
# print("I could not import pygame - joystick support is disabled. Try to (re)install pygame")
import vpython as v
xpointer = v.arrow(
pos = v.vector(0,0,0),
axis= v.vector(1,0,0),
shaftwidth = 0.1,
ypointer = v.arrow(
pos = v.vector(0,0,0),
horstjens /
Created Dec 19, 2020
cardgame peter emile
#import PySimpleGUI as sg
import pysimplegui as sg
import random
class Monster:
def __init__(self, name, hp): = name
self.hp = hp
# from
import vpython as vp
#GlowScript 3.0 VPython
vp.scene.caption = """
In GlowScript programs:
To rotate "camera", drag with right button or Ctrl-drag.
To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.
On a two-button mouse, middle is left + right.
To pan left/right and up/down, Shift-drag.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate.
horstjens /
Last active Dec 20, 2020
haus design mit psimplegui Canvas für Lukas
import PySimpleGUI as sg
import numpy # for arange
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib
class Data:
# ---- edit by Horst a lot ---
def weeks_left_calc(year_born=None, current_year=2020 ):
Returns years, weeks, days or None,None,None:
If input is correct, returns:
years: the number of years you have to live to 90 years old in digits.
weeks: the number of weeks you have to live to 90 years old in digits.
days: the number of days you have to live to 90 years old in digits.
If input is not correct, returns:
import pysimplegui as sg
def main():
layout = [ [sg.Text('Control Panel. Click Abort to exit.')]]
layout += [[sg.Column([[GraphicButton(png_names[i+j*5], png_names[i+j*5] , png_images[i+j*5]) for i in range(2)] for j in range(7)], scrollable=True, size=(400,400))]]
window = sg.Window('Control Panel', layout, font='any 15', finalize=True, location = (2200,200))
while True: # ---===--- The event loop --- #
from vpython import *
import math
scene.title = "VPython: Draw a rotating cube"
scene.range = 2
scene.autocenter = True
print("Drag with right mousebutton to rotate view.")
print("Drag up+down with middle mousebutton to zoom.")
# magic card game
# each player has a wizard with hitpoints
# the wizards battle against each other until only the sole survivor is victor
# each wizard gets some random cards from a stack, forming his card-deck
# (every wizard can only see his own card-deck)
# type of cards:
# direct-damage (like Flame Bolt), directly damages one enemy figure
# summoning: summons a monster that fights for the wizard
# buffs: improves friendly figures
# nerfs: nerfs enemy figures