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
@horstjens
horstjens / spacebattle2.py
Created December 16, 2023 10:46
spacebattle2
import vpython as vp
import random
class Game:
beams = []
scene=vp.canvas(title="Space fight")
# xyz
#vp.arrow(axis=vp.vector(1,0,0), color=vp.color.red)
@horstjens
horstjens / spacebattle1.py
Last active December 9, 2023 10:58
space battle (vpython)
import vpython as vp
# xyz
#vp.arrow(axis=vp.vector(1,0,0), color=vp.color.red)
vp.text(pos=vp.vector(1.5,0,0), text="x",
color=vp.color.red, height=0.1)
#vp.arrow(axis=vp.vector(0,1,0), color=vp.color.green)
vp.text(pos=vp.vector(0,1.5,0), text="y",
color=vp.color.green, height=0.1)
#vp.arrow(axis=vp.vector(0,0,1), color=vp.color.blue)
@horstjens
horstjens / viergewinnt4.py
Last active December 23, 2023 09:43
viergewinnt pysimplegui
import random
import PySimpleGUI as sg
spieler = 1
summe = 0
rows = 6 # max. 26
cols = 7 # max. 26
gewinnt = 4
@horstjens
horstjens / viergewinnt2.py
Last active November 25, 2023 09:19
vier gewinnt
import random
spieler = 1
summe = 0
rows = 6 # max. 25
cols = 17 # max. 25
gewinnt = 5
spielzug = 0
#feld = [
# [0,0,0,0,0,0,0],
# [0,0,0,0,0,0,0],
@horstjens
horstjens / wallsurfer1.py
Created October 29, 2023 07:54
vo wallsurfer
# gist.github.com/horstjens
import vpython as vp
import random
class Game:
scene = vp.canvas(width=1200, height=650, title="wall surfer")
dt = 0.1
xlimit = 20
@horstjens
horstjens / drunk_turtle_race7.py
Created October 28, 2023 14:15
drunk turtle race
import turtle
import random
w,h = 1200,750
turtle.setup(w,h)
colors = ["blue","red","green","yellow"]
goals = []
stable = []
y = h//2
# gist.github.com/horstjens
import vpython as vp
import random
class Game:
dt = 0.1
xlimit = 20
ylimit = 10
@horstjens
horstjens / astar.py
Last active September 15, 2023 09:00 — forked from ryancollingwood/astar.py
# Credit for this: Nicholas Swift
# as found at https://medium.com/@nicholas.w.swift/easy-a-star-pathfinding-7e6689c7f7b2
from warnings import warn
import heapq
class Node:
"""
A node class for A* Pathfinding
"""
@horstjens
horstjens / vpballs.py
Created August 25, 2023 09:51
vp balls
import random
import vpython as vp
class Game:
size = 20
class Ball(vp.sphere):
def __init__(self):
p = vp.vector(random.uniform(0, Game.size),
random.uniform(0, Game.size),
import vpython as vp
import random
class Game:
player1 = None
player2 = None
fps = 30 # frames per second
dt = 1/fps # delta time in seconds
board_size = 10
player_speed = 2