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 / fantasynames.py
Last active November 24, 2015 09:36
fantasy name generator from Crhistoph, a bit improved
#Fantasynamengenerator (python3)
"""generates fantasy names"""
def namensgenerator(namen):
"""im docstring in triple-quotes beschreibt man was die funktion tut"""
namensliste = []
output = ""
while len(namensliste) < anzahl:
neuername = (random.choice(namen[0]))+(random.choice(namen[1]))
if neuername not in namensliste:
@horstjens
horstjens / caesarchiffre1.py
Last active November 10, 2015 07:37
caesars chiffre 1
# Caesar Cipher
# from Al Sweigarts invent with python book https://inventwithpython.com/chapter14.html
MAX_KEY_SIZE = 26
def getMode():
while True:
print('Do you wish to encrypt or decrypt a message?')
mode = input().lower()
if mode in 'encrypt e decrypt d'.split():
import random
# legende: # Fels . Boden T Troll ! trap
dungeon = """
###############################################
#......................bbb.....#.....#........#
#.............................................#
#.............................................#
###############################################
"""
@horstjens
horstjens / tictactoe.py
Created December 15, 2015 06:39
tictactoe in python for 2 players
"""tictactoe game for 2 players
from blogpost: http://thebillington.co.uk/blog/posts/writing-a-tic-tac-toe-game-in-python by BILLY REBECCHI,
slightly improved by Horst JENS"""
from __future__ import print_function
choices = []
for x in range (0, 9) :
choices.append(str(x + 1))
@horstjens
horstjens / Dornbirn Python Seminar Unterlagen.md
Last active April 1, 2016 22:10
Seminarunterlagen für Python-Seminar in Dornbirn am 31-3-2016
Links und Unterlagen zum Seminar "Unterrichten mit Python"
# python
http://python.org - download
offizielle Dokumentation der Module (z.B. turtle modul) -> Documentaion -> Library Reference -> Modul aussuchen,
z.B. turtle Modul:
https://docs.python.org/3/library/turtle.html
## Tutorials für Python:
@horstjens
horstjens / textrougue.py
Last active July 18, 2016 09:21
python3 text rougue with food clock in 62 lines without functions
# legend: #=rock .=floor f=food T=treasure
dungeon = """
###############################################
#.....fff.#..............#f#.T#.....#.......#T#
#.........#..............###....###.#.....#.#.#
#.........f.....T...f.........##T......f..#...#
###############################################
""" # add more line to the dungeon!
player, msg = "@", "welcome @, move with w,a,s,d"
px, py, dx, dy = 1, 1, 0, 0
@horstjens
horstjens / textrogue2.py
Created July 18, 2016 09:22
python3 textrogue2: extend version of textrogue with statues as foes and hitpoints for the player
# legend: #=rock .=floor f=food T=treasure
dungeon = """
###############################################
#.....fff.#..............#f#.T#.....#.......#T#
#..S......#..............###....###.#.....#.#.#
#..SS.....f.....T...f.........##T......f..#...#
###############################################
""" # add more line to the dungeon!
player, msg = "@", "welcome @, move with w,a,s,d"
px, py, dx, dy, php = 1, 1, 0, 0, 10 # position, movement
@horstjens
horstjens / textrouge3.py
Created July 18, 2016 21:09
textrogue3 with jumping and statues dishing out randomized damage
import random
# legend: #=rock .=floor f=food T=treasure
dungeon = """
###############################################
#.....fff.#..............#f#.T#.....#.......#T#
#..S......#..............###....###.#.....#.#.#
#..SS.....f.....T...f.........##T......f..#...#
###############################################
""" # add more line to the dungeon!
player, msg = "@", "welcome @, move with w,a,s,d"
@horstjens
horstjens / textrouge001.py
Last active August 8, 2016 08:04
textrogue1, more pythonic version, 75 lines, without functions. player can move, find food, find gold and eat
# legend: #=rock .=floor f=food $=gold
DUNGEON = '''
###############################################
#.....fff.#..............#f#.$#.....#.......#$#
#.........#..............###....###.#.....#.#.#
#.........f.....$...f.........##$......f..#...#
###############################################
''' # add more lines to the dungeon!
PLAYER = '@'
PROMPT = 'Type your command or ? and press Enter:'
@horstjens
horstjens / textrouge001.py
Last active July 19, 2016 12:51
textrogue1, more pythonic version, 75 lines, without functions. player can move, find food, find gold and eat
# legend: #=rock .=floor f=food $=gold
DUNGEON = '''
###############################################
#.....fff.#..............#f#.$#.....#.......#$#
#.........#..............###....###.#.....#.#.#
#.........f.....$...f.........##$......f..#...#
###############################################
''' # add more lines to the dungeon!
PLAYER = '@'
PROMPT = 'Type your command or ? and press Enter:'