Skip to content

Amend seeds to ensure each can run #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions lib/tasks/project_components/dont_collide_dont_pop_example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,65 @@

# The draw_obstacle function goes here
def draw_obstacles():

global level

seed(12345678)

if frame_count % height == height - 1 and level < 5:
level += 1
print('You reached level', level)

for i in range(6 + level):
ob_x = randint(0, height)
ob_y = randint(0, height) + (frame_count * level)
ob_y %= height # wrap around
text('🌵', ob_x, ob_y)


# The draw_player function goes here
def draw_player():

global score, level

player_y = int(height * 0.8)

no_fill()
#ellipse(mouse_x, player_y, 10, 10) # draw collision point
#ellipse(mouse_x, player_y + 40, 10, 10)
#ellipse(mouse_x - 12, player_y + 20, 10, 10)
#ellipse(mouse_x + 12, player_y + 20, 10, 10)

collide = get(mouse_x, player_y)
collide2 = get(mouse_x - 12, player_y + 20)
collide3 = get(mouse_x + 12, player_y + 20)
collide4 = get(mouse_x, player_y + 40)

if mouse_x < width: # off the left of the screen
collide2 = safe

if mouse_x > width: # off the right of the screen
collide3 = safe

if collide == safe and collide2 == safe and collide3 == safe and collide4 == safe:
text('🎈', mouse_x, player_y)
score += level
else:
text('💥', mouse_x, player_y)
level = 0


def setup():
# Setup your animation here
text_size(40)
text_align(CENTER, TOP) # position around the centre, top
size(400, 400)


def draw():
# Things to do in every frame
global score, safe, level
safe = Color(200, 150, 0)

if level > 0:
background(safe)
background(safe)
fill(255)
text('Score: ' + str(score), width/2, 20)
draw_obstacles()
draw_player()

run()
23 changes: 23 additions & 0 deletions lib/tasks/project_components/make_a_face_starter/grid.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from p5 import *

def grid():
push_matrix()
stroke(200)
Expand All @@ -12,3 +14,24 @@ def grid():
show_coord(x, y)

pop_matrix()

def show_coord(x, y):
if x == width:
x_align = RIGHT
elif x == 0:
x_align = LEFT
else:
x_align = CENTER

if y == height:
y_align = BASELINE
elif y == 0:
y_align = TOP
else:
y_align = CENTER

push_matrix()
fill(100)
text_align(x_align, y_align)
text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y)
pop_matrix()
14 changes: 6 additions & 8 deletions lib/tasks/project_components/target_practice_starter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
def setup():
# Setup your game here
size(400, 400) # width and height
frame_rate(2)


def draw():
# Things to do in every frame
sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206
grass = color(149, 212, 122)
wood = color(145, 96, 51)
outer = color(0, 120, 180)
sky = Color(92, 204, 206) # Red = 92, Green = 204, Blue = 206
grass = Color(149, 212, 122)
wood = Color(145, 96, 51)
outer = Color(0, 120, 180)



# Keep this to run your code
run()
run(frame_rate=2)