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 / conway001.py
Created January 18, 2025 10:40
conway game of life
# conways game of life
# see https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
startfield="""
...X............
.......XXX.....X
...............X
...............X
................
@horstjens
horstjens / schulnoten.py
Created January 16, 2025 15:55
turtle line diagram
import turtle
# diagramme mit turtle grafik
# französisch-Noten
noten = [2,2,1,5,5,4,2,3,1,1]
# Liniengrafik
WIDTH = 1200
HEIGHT = 800
import pygame
import random
import math
class Game:
W, H = 1500, 751
FPS = 60
scrollspeed = -2
@horstjens
horstjens / shooter4.py
Created November 11, 2024 17:23
pygame shooter
import pygame
import random
import math
class Game:
W, H = 1500, 751
FPS = 60
scrollspeed = -2
@horstjens
horstjens / pygame_shooter3.py
Last active November 4, 2024 17:56
pygame shooter
import pygame
import random
class Game:
W, H = 1500, 751
FPS = 60
scrollspeed = -2
stargroup = pygame.sprite.Group()
@horstjens
horstjens / cookie_clicker002.py
Created October 15, 2024 14:46
cookie_clicker
@horstjens
horstjens / asteroid16.py
Last active October 21, 2024 16:54
asteroid16
import pygame
import random
import os.path
W, H = 1280, 720
class TextSprite(pygame.sprite.DirtySprite):
def __init__(self, pos, color, textsize, text, age_max, anchor="center" ):
@horstjens
horstjens / pixel_pos_problem.py
Created October 14, 2024 09:49
vpython label pixel_pos problem
import vpython as vp
import random
#import math
# description: a world with vertical cylinders (axis = vp.vec(0,0,1), base of all cylinders is at world position z=0
# the base of the cylinder has a location label (white text)
# the top of each cylinder has a value label (green text)
# problem: finding out pixel_pos of location labels (at the base of a cylinder) and the value labels( at the top of a cylinder)
# the pixel pos is not the world coordinates, but the coordinate in pixels
@horstjens
horstjens / turtle_chaser_01.py
Created October 10, 2024 12:35
turtle chaser 01
import turtle
# turtle bounces from screen edge
#w, h = 600,400
#turtle.setup(w*2, h*2)
screen = turtle.Screen()
screen.setup(1.0, 0.9)
w, h = screen.window_width()/2, screen.window_height()/2
@horstjens
horstjens / asteroids14.py
Last active October 7, 2024 16:42
asteroids14
import pygame
import random
import os.path
# done: ufo more pretty, triangular windows
# done: ufo change colors
# TODO: impact on asteroid changes speed of asteroid
# TODO: asteroid shall change color to indicate loosing hitpoints
W, H = 1280, 720