Skip to content

Instantly share code, notes, and snippets.

💭
teaching python/pygame to children

Horst JENS horstjens

💭
teaching python/pygame to children
View GitHub Profile
View battleship_7.py
import random
class Ship:
'''all ships are part of the boat class'''
number = 1
def __init__(self, player, length):
'''chooses random location & direction for ship for a given length'''
# print('ship size: ', length, sep='')
View battleship_7.py
import random
class Ship:
'''all ships are part of the boat class'''
number = 1
def __init__(self, player, length):
'''chooses random location & direction for ship for a given length'''
# print('ship size: ', length, sep='')
@horstjens
horstjens / ThePythonGameBook_TicTacToe
Last active May 1, 2020
ThePythonGameBook-TicTacToe code files
View ThePythonGameBook_TicTacToe
first file to make sure all files in this gist have this name
see http://ThePythonGameBook.com:en:python:tictactoe
@horstjens
horstjens / oneliner.py
Last active Apr 20, 2020
ThePythonGameBook, tictactoe step 002
View oneliner.py
print("[ ] [ ] [ ]\n" * 3) # all in one-line
View coin1.py
"""
Sprite Collect Coins with Background
Simple program to show basic sprite usage.
Artwork from http://kenney.nl
If Python and Arcade are installed, this example can be run from the command line with:
python -m arcade.examples.sprite_collect_coins_background
"""
@horstjens
horstjens / flatten_the_curve_01.py
Last active Mar 19, 2020
Blog Artikel spielend-programmieren
View flatten_the_curve_01.py
import random
# TODO: include Sandwich's graphic https://imgur.com/SCrUgqq ?
class Person:
"""a person has a location, can change this location, and can be healthy,
infected or immune. If location is shared with an infected person, all
healthy persons at this location become infected.
@horstjens
horstjens / liste.txt
Created May 22, 2019
get list out of file ( as choices arguments for easygui.choicebox )
View liste.txt
vanilla
strawberry
apple
apricot
banana
@horstjens
horstjens / tree2.py
Created Nov 7, 2018
recursive tree with turtle graphic
View tree2.py
import turtle
import random
#rekursive tree
def branch(length=50, angle=30, factor=0.5, stops=2):
if length < 5:
return
turtle.fd(length)
turtle.left(angle)
@horstjens
horstjens / cannon1.py
Created Oct 10, 2018 — forked from PaulPolaschek/cannon1.py
artillery game with python turtle
View cannon1.py
import turtle
import random
peter=turtle.Turtle()
peter.pencolor("blue")
peter.pensize(3)
peter.fillcolor("red")
franz=turtle.Turtle()
franz.pencolor("yellow")
@horstjens
horstjens / vector_template.py
Last active Sep 27, 2018
pygame vector template game
View vector_template.py
# -*- coding: utf-8 -*-
"""003_static_blit_pretty_template.py"""
import pygame
import random
def make_text(msg="pygame is cool", fontcolor=(255, 0, 255), fontsize=42, font=None):
"""returns pygame surface with text. You still need to blit the surface."""
myfont = pygame.font.SysFont(font, fontsize)
You can’t perform that action at this time.