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 / 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:
@horstjens
horstjens / freesimplegui_matplotlib_simple_plot.py
Last active August 1, 2024 07:52
freesimplegui and matplotlib
#https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Matplotlib_Browser.py
# !/usr/bin/env python
import FreeSimpleGUI as sg
import matplotlib
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import numpy as np
import matplotlib.pyplot as plt
@horstjens
horstjens / freesimplegui_layout1.py
Created July 30, 2024 07:29
freesimplegui_layout
import FreeSimpleGUI as sg
import FreeSimpleGUI as sg
# Define the window's contents
c_left = sg.Column(layout=[
[sg.Text("erste Zeile links1")],
[sg.Text("beginn links2")],
[sg.Text("links3")],
@horstjens
horstjens / pokemonfight001.py
Last active July 25, 2024 06:37
pokemonfight
# battle between 2 pokemons
import random
class Pokemon:
def __init__(self, name):
self.name = name
self.hp_full = 100
self.hp = 100
@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
@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 /