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 / many_turtles.py
Last active July 23, 2024 07:16
100_turtles
import turtle
import random
W, H = 2000, 1000
turtle.setup(W,H)
screen = turtle.Screen()
screen.setworldcoordinates(0,0,W,H)
screen.tracer(0)
# create turtles
for i in range(50):
t = turtle.Turtle()
@horstjens
horstjens / asteroid001.py
Last active July 5, 2024 09:03
pygame_asteroid_game
# friction, acceleartion and drifting
import pygame
import random
W, H = 1280, 720
class TextSprite(pygame.sprite.DirtySprite):
def __init__(self, pos, color, textsize, text, age_max ):
self.dirty = True
@horstjens
horstjens / linus_platformgame001.py
Last active June 18, 2024 15:17
pygame platformer for Linus
import pygame
import os
# Example file showing a circle moving on screen
W,H = 1280, 720
FPS = 60
APS = 4 # animations per second
# pygame setup
pygame.init()
@horstjens
horstjens / linusrogue001.py
Last active May 22, 2024 15:28
linus rogue
import random
import vpython as vp
class Game:
scene = vp.canvas(width=1024,
height=600,
title="linus rogue")
fps = 30
dt = 1/fps
import vpython as vp
vp.arrow(axis=vp.vec(1,0,0),
color=vp.color.red)
vp.arrow(axis=vp.vec(0,1,0),
color=vp.color.green)
vp.arrow(axis=vp.vec(0,0,1),
color=vp.color.blue)
vp.label(text="x", pos=vp.vec(1.1,0,0))
vp.label(text="y", pos=vp.vec(0,1.1,0))
@horstjens
horstjens / linus7.py
Last active May 13, 2024 15:45
linus
import vpython as vp
# z ziel
# $ stacheln für schalter 4
# 4 schalter für stacheln $
# % stacheln für schalter 5
# 5 schalter für stacheln %
# & stacheln für schalter 6
# 6 schalter für stachelen &
# / versenkbare Türe für Schalter 7
# 7 schalter für Türe /
@horstjens
horstjens / turtlerace1.py
Last active March 13, 2024 07:26
wiesberggasse
import turtle
import random
breite = 1200
höhe = 800
turtle.setup(breite,höhe)
turtle.speed(0)
stall = [turtle.Turtle(),
turtle.Turtle(),
@horstjens
horstjens / pygame003.py
Created January 13, 2024 11:01
pygame starter example: moving a circle, changing the colors
# Example file showing a circle moving on screen
import pygame
# pygame setup
pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
dt = 0
@horstjens
horstjens / babyturtles1.py
Created January 6, 2024 19:50
babyturtles
import turtle
import random
class Salat(turtle.Turtle):
salatliste = []
def __init__(self):
super().__init__()
self.hideturtle()
@horstjens
horstjens / sternschnuppe1.py
Created January 6, 2024 08:00
sternschnuppe
import turtle
import random
class Stern(turtle.Turtle):
sternenliste = []
löschen = False # muss man einen Stern löschen?
def __init__(self, pos, startfarbe=(1,1,0), endfarbe=(1,1,1)):
super().__init__()
self.hideturtle()