Skip to content

Commit d73559f

Browse files
authored
Merge pull request #37 from /issues/36-Rake_task_for_all_projects_on_python_path
Issues/36 rake task for all projects on python path
2 parents c573f85 + ff1399d commit d73559f

File tree

44 files changed

+1447
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1447
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/python3
2+
3+
from p5 import *
4+
from random import randint, seed
5+
6+
# Include global variables here
7+
8+
9+
def setup():
10+
# Put code to run once here
11+
12+
13+
def draw():
14+
# Put code to run every frame here
15+
16+
17+
# Keep this to run your code
18+
run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NAME: "Don't Collide!"
2+
IDENTIFIER: "dont-collide-starter"
3+
COMPONENTS:
4+
- name: "main"
5+
extension: "py"
6+
location: "main.py"
7+
index: 0
8+
default: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/python3
2+
3+
from p5 import *
4+
from random import randint, seed
5+
6+
level = 1
7+
score = 0
8+
9+
def safe_player():
10+
11+
global player_y
12+
13+
# Face
14+
fill(200, 134, 145)
15+
ellipse(mouse_x, player_y, 60, 60)
16+
17+
# Eyes
18+
fill(178, 200, 145)
19+
ellipse(mouse_x - 10, player_y - 10, 20, 20)
20+
ellipse(mouse_x + 10, player_y - 10, 20, 20)
21+
fill(0)
22+
ellipse(mouse_x - 10, player_y - 10, 10, 10)
23+
ellipse(mouse_x + 10, player_y - 10, 10, 10)
24+
fill(255)
25+
ellipse(mouse_x - 12, player_y - 12, 5, 5)
26+
ellipse(mouse_x + 12, player_y - 12, 5, 5)
27+
28+
# Mouth
29+
fill(0)
30+
ellipse(mouse_x, player_y + 10, 15, 10)
31+
fill(200, 134, 145)
32+
ellipse(mouse_x, player_y + 5, 10, 10)
33+
34+
def crashed_player():
35+
36+
global player_y
37+
38+
# Face
39+
fill(178, 200, 145)
40+
ellipse(mouse_x, player_y, 60, 60)
41+
42+
# Eyes
43+
fill(149, 161, 195)
44+
ellipse(mouse_x - 10, player_y - 10, 20, 20)
45+
ellipse(mouse_x + 10, player_y - 10, 20, 20)
46+
fill(0)
47+
ellipse(mouse_x - 10, player_y - 10, 10, 10)
48+
ellipse(mouse_x + 10, player_y - 10, 10, 10)
49+
fill(255)
50+
ellipse(mouse_x - 12, player_y - 12, 5, 5)
51+
ellipse(mouse_x + 12, player_y - 12, 5, 5)
52+
53+
# Mouth
54+
fill(0)
55+
ellipse(mouse_x, player_y + 15, 15, 10)
56+
fill(178, 200, 145)
57+
ellipse(mouse_x, player_y + 20, 10, 10)
58+
59+
def draw_player():
60+
61+
global player_y, safe, score, level
62+
63+
player_y = int(height * 0.8)
64+
65+
collide = get(mouse_x, player_y)
66+
collide2 = get(mouse_x, player_y + 30)
67+
collide3 = get(mouse_x + 30, player_y)
68+
collide4 = get(mouse_x, player_y - 30)
69+
70+
if mouse_x < width: # off the left of the screen
71+
collide2 = safe
72+
73+
if mouse_x > width: # off the right of the screen
74+
collide3 = safe
75+
76+
#print(collide, collide2, collide3, collide4)
77+
78+
if collide == safe and collide2 == safe and collide3 == safe and collide4 == safe:
79+
safe_player()
80+
score += level
81+
else: # Collided
82+
crashed_player()
83+
level = 0
84+
85+
def draw_obstacles():
86+
87+
global level
88+
89+
seed(41143644)
90+
91+
if frame_count & height == height - 1 and level < 5:
92+
level += 1
93+
print('You reached level', level)
94+
95+
for i in range(9 + level):
96+
ob_x = randint(0, width)
97+
ob_y = randint(0, height) + frame_count
98+
ob_y %= height
99+
text('🦠', ob_x, ob_y)
100+
101+
def setup():
102+
# Put code to run once here
103+
size(400, 400) # width and height
104+
no_stroke()
105+
text_size(40)
106+
text_align(CENTER, TOP)
107+
108+
def draw():
109+
# Put code to run every frame here
110+
global safe, score, level
111+
112+
safe = Color(149, 161, 195)
113+
114+
if level > 0:
115+
background(safe)
116+
fill(145, 134, 126)
117+
text('Score: ' + str(score), width/2, 20)
118+
draw_obstacles()
119+
draw_player()
120+
121+
# Keep this to run your code
122+
run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NAME: "Don't Collide: Avoid the Germs"
2+
IDENTIFIER: "avoid-germs-example"
3+
COMPONENTS:
4+
- name: "main"
5+
extension: "py"
6+
location: "main.py"
7+
index: 0
8+
default: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/python3
2+
3+
# Import library code
4+
from p5 import *
5+
from random import randint, seed
6+
7+
level = 1
8+
score = 0
9+
10+
# The draw_obstacle function goes here
11+
def draw_obstacles():
12+
13+
global level
14+
15+
seed(123456789)
16+
17+
if frame_count % width == width - 1 and level < 10:
18+
level += 1
19+
print('You reached level', level)
20+
21+
for i in range(6 + level):
22+
ob_x = randint(0, width) - (frame_count * level)
23+
ob_y = randint(0, height)
24+
ob_x %= width # wrap around
25+
text('💩', ob_x, ob_y)
26+
27+
# The draw_player function goes here
28+
def draw_player():
29+
30+
global score, level
31+
32+
player_x = int(width * 0.2)
33+
player_y = mouse_y
34+
35+
collide = get(player_x + 50, player_y + 15)
36+
collide2 = get(player_x + 50, player_y - 15)
37+
collide3 = get(player_x, player_y + 15)
38+
collide4 = get(player_x, player_y - 15)
39+
collide5 = get(player_x - 50, player_y + 15)
40+
collide6 = get(player_x - 50, player_y - 15)
41+
42+
if player_y > height - 18: # Off the bottom of the screen
43+
collide = safe
44+
collide3 = safe
45+
collide5 = safe
46+
47+
elif player_y < 18: # Off the top of the screen
48+
collide2 = safe
49+
collide4 = safe
50+
collide6 = safe
51+
52+
if collide == safe and collide2 == safe and collide3 == safe and collide4 == safe:
53+
image(car, player_x, player_y, 100, 31)
54+
score += level
55+
else:
56+
text('💥', player_x, player_y)
57+
level = 0
58+
59+
60+
def setup():
61+
# Setup your animation here
62+
global car
63+
64+
size(400, 400)
65+
car = load_image('car.png')
66+
image_mode(CENTER)
67+
68+
69+
def draw():
70+
# Things to do in every frame
71+
global score, safe, level
72+
safe = Color(128)
73+
74+
if level > 0:
75+
background(safe)
76+
fill(255)
77+
text_size(16)
78+
text_align(RIGHT, TOP)
79+
text('Score', width * 0.45, 10, width * 0.5, 20)
80+
text(str(score), width * 0.45, 25, width * 0.5, 20)
81+
text_size(20)
82+
text_align(CENTER, TOP) # position around the centre, top
83+
draw_obstacles()
84+
draw_player()
85+
86+
run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NAME: "Don't Collide: Clean Car"
2+
IDENTIFIER: "clean-car-example"
3+
COMPONENTS:
4+
- name: "main"
5+
extension: "py"
6+
location: "main.py"
7+
index: 0
8+
default: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/python3
2+
3+
# Import library code
4+
from p5 import *
5+
from random import randint, seed
6+
7+
level = 1
8+
score = 0
9+
lives = 3
10+
invun = 0
11+
12+
# The draw_obstacle function goes here
13+
def draw_obstacles():
14+
15+
global level
16+
17+
seed(random_seed)
18+
19+
if frame_count % height == height - 1 and level < 8:
20+
level += 1
21+
print('You reached level', level)
22+
23+
for i in range(6 + level):
24+
ob_x = randint(0, width)
25+
ob_y = randint(0, height) + (frame_count * level)
26+
ob_y %= height # wrap around
27+
push_matrix()
28+
translate(ob_x, ob_y)
29+
rotate(degrees(randint(1, 359)+frame_count / 1000))
30+
image(rock, 0, 0, randint(18,24), randint(18,24))
31+
pop_matrix()
32+
33+
34+
# The draw_player function goes here
35+
def draw_player():
36+
37+
global score, level, lives, invun
38+
39+
player_y = int(height * 0.8)
40+
player_x = mouse_x
41+
42+
collide = get(player_x, player_y)
43+
collide2 = get(player_x - 18, player_y + 17)
44+
collide3 = get(player_x + 18, player_y + 17)
45+
collide4 = get(player_x, player_y + 25)
46+
47+
if player_x < width: # off the left of the screen
48+
collide2 = safe
49+
50+
if player_x > width: # off the right of the screen
51+
collide3 = safe
52+
53+
if (collide == safe and collide2 == safe and collide3 == safe and collide4 == safe) or invun > 0:
54+
if lives == 0 and frame_count % 12 == 0:
55+
tint(200, 0, 0)
56+
57+
image(rocket, player_x, player_y + 25, 64, 64)
58+
score += level
59+
invun -= 1
60+
no_tint()
61+
62+
if invun > 0:
63+
stroke(220)
64+
fill(220, 220, 220, 60)
65+
ellipse(player_x, player_y + 18, 47, 47)
66+
67+
elif lives > 0:
68+
lives -= 1
69+
invun = 50
70+
tint(200, 0, 0)
71+
image(rocket, player_x, player_y + 25, 64, 64)
72+
no_tint()
73+
score += level
74+
else:
75+
text('💥', player_x + 10, player_y + 5)
76+
level = 0
77+
78+
79+
def display_score():
80+
global level
81+
82+
fill(255)
83+
text_size(16)
84+
text_align(RIGHT, TOP)
85+
text('Score', width * 0.45, 10, width * 0.5, 20)
86+
text(str(score), width * 0.45, 25, width * 0.5, 20)
87+
88+
if score > 10000:
89+
level = 0
90+
print('🎉🎉 You win! 🎉🎉')
91+
92+
93+
def display_lives():
94+
fill(255)
95+
text_size(16)
96+
text_align(LEFT, TOP)
97+
text('Lives', width * 0.05, 10, 30, 20)
98+
99+
for i in range(lives):
100+
image(rocket, width * 0.05 + i * 25, 40, 20, 20)
101+
102+
103+
def setup():
104+
# Setup your animation here
105+
global rocket, rock, random_seed
106+
107+
text_size(40)
108+
text_align(CENTER, TOP) # position around the centre, top
109+
size(400, 400)
110+
111+
rocket = load_image('rocket.png')
112+
rock = load_image('moon.png')
113+
random_seed = randint(0, 1000000)
114+
115+
def draw():
116+
# Things to do in every frame
117+
global score, safe, level
118+
safe = Color(0)
119+
120+
if level > 0:
121+
background(safe)
122+
fill(255)
123+
image_mode(CENTER)
124+
draw_obstacles()
125+
draw_player()
126+
display_score()
127+
display_lives()
128+
129+
run()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
NAME: "Don't Collide: Dodge Asteroids"
2+
IDENTIFIER: "dodge-asteroids-example"
3+
COMPONENTS:
4+
- name: "main"
5+
extension: "py"
6+
location: "main.py"
7+
index: 0
8+
default: true

0 commit comments

Comments
 (0)