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 / 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
@horstjens
horstjens / vpython_catcher001.py
Created August 24, 2023 07:03
lara_max_alexander
import vpython as vp
import random
class Game:
fps = 30 # frames per second
dt = 1/fps # delta time in seconds
board_size = 10
player_speed = 2
max_balls = 3
gravity = -0.2
import random
from dice2 import diceroll
class Monster:
def __init__(self, name):
self.name = name
self.hp = 10
self.attack = 0.7
self.defense = 0.5
import random
# dice - simulate dungeon & dragons dice to generate random values
def diceroll(dicestring):
"""
lower d for dice rolls without re-roll
1d6 -> rolls one six-sided die
@horstjens
horstjens / roguelike1.py
Last active August 4, 2023 09:26
toni_artur
# roguelike
import os
import random
def dice(dicestring):
"""
1d6 -> random integer between 1 and 6
2d6 -> random integer between 2 and 12
1d20+5 -> random integer between 6 and 26
import random
# dice - simulate dungeon & dragons dice to generate random values
def dice(dicestring):
"""
1d6 -> random integer between 1 and 6
2d6 -> random integer between 2 and 12
1d20+5 -> random integer between 6 and 26
"""