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 / 01_operatoren.py
Last active January 4, 2016 15:59
python3 Schulung
100 + 1
100 – 1
100 / 7
100 / 7.0
100 % 7
100 * 4
100 ** 2
100 ** 0.5
(100+1) * 2
100 + 1 * 2
@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 / turtlecannon1.py
Last active July 11, 2016 09:01
turtle cannonball
import math
import turtle as t
p1 = t.Turtle()
p1.left(70)
p1.speed=9
p1.dx = math.cos(p1.heading()*math.pi/180)*p1.speed
p1.dy = math.sin(p1.heading()*math.pi/180)*p1.speed
for step in range(100):
x = p1.xcor()
y = p1.ycor()
@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 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:'
@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 / textrogue002.py
Last active August 8, 2016 08:04
python3 textrouge, slightly improved: hitpoints for player, statues as foes. still without functions
# legend: #=rock .=floor f=food $=gold
DUNGEON = '''
###############################################
#.....fff.#..............#f#.$#.....#.......#$#
#....S....#..............###....###.#.....#.#.#
#....S.S..f.....$...f.........##$......f..#...#
###############################################
''' # add more lines to the dungeon!
PLAYER = '@'
PROMPT = 'Type your command or ? and press Enter:'
import turtle
import random
def baum(laenge=50, winkel=30, minimum=5):
if laenge < minimum:
return
turtle.fd(laenge)
turtle.left(winkel)
turtle.fd(laenge/2)
baum(laenge/2, winkel, minimum)