Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
teaching python/pygame to children

Horst JENS horstjens

💭
teaching python/pygame to children
View GitHub Profile
@horstjens
horstjens / auftrieb.py
Created Feb 18, 2021
Vektorprojektion auf anderen Vektor
View auftrieb.py
import vpython as v
scene1 = v.canvas(title="auftrieb",
width=800,
height=600,
center=v.vector(0, 0, 0),
background=v.vector(0.4, .4, 0.4),
)
scene1.autoscale = False
ground = v.box(pos = v.vector(0,0,0), size=v.vector(10,0,10), color=v.vector(0.1,0.1,0.9), opacity=0.2)
View doppeldecker.py
# 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")
View peter_emile_vball1_reflect.py
import vpython as v
xpointer = v.arrow(
pos = v.vector(0,0,0),
axis= v.vector(1,0,0),
shaftwidth = 0.1,
color=v.color.yellow,
)
ypointer = v.arrow(
pos = v.vector(0,0,0),
@horstjens
horstjens / gui_test2.py
Created Dec 19, 2020
cardgame peter emile
View gui_test2.py
#import PySimpleGUI as sg
import pysimplegui as sg
import random
class Monster:
def __init__(self, name, hp):
self.name = name
self.hp = hp
View dualstar1.py
# from https://www.glowscript.org/#/user/GlowScriptDemos/folder/Examples/program/BinaryStar-VPython/edit
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
horstjens / lukas_architekt2.py
Last active Dec 20, 2020
haus design mit psimplegui Canvas für Lukas
View lukas_architekt2.py
import PySimpleGUI as sg
import numpy # for arange
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib
#sg.popup_get_text()
class Data:
View dennis_year_to_90_calculator.py
# ---- 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:
View simpletest1.py
import pysimplegui as sg
def main():
sg.ChangeLookAndFeel('GreenTan')
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 --- #
View vtest1.py
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.")
View cardgame_peter_emile.py
# 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