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
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
@horstjens
horstjens / tictacto.py
Created August 19, 2024 09:23
tictactoe
# tic tac toe spiel für 2 spieler, eingabekontrolle
# sieg ermittlung
# Horst JENS, 2024 08
def gewonnen():
feld = spielfeld.replace("-+-+-\n","")
feld = feld.replace("|","")
feld = feld.replace("\n","")
print(feld)
# 012
@horstjens
horstjens / freesimplegui_pokemon_matplotlib.py
Last active August 2, 2024 07:02
freesimplegui_pokemongui
import FreeSimpleGUI as sg
import random
import matplotlib
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
#import numpy as np
import matplotlib.pyplot as plt
# format mini language https://docs.python.org/3/library/string.html#formatspec
class Pokemon: