-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (44 loc) · 1.24 KB
/
main.py
File metadata and controls
55 lines (44 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## Import library code
from p5 import *
from random import randint
# The mouse_pressed function goes here
def mouse_pressed():
# print('🎯')
if hit_colour == Color("blue").hex:
print("You hit the outer circle, 50 points!")
elif hit_colour == Color("red").hex:
print("You hit the inner circle, 200 points!")
elif hit_colour == Color("yellow").hex:
print("You hit the middle, 500 points!")
else:
print("You missed! No points!")
# The shoot_arrow function goes here
def shoot_arrow():
global hit_colour
arrow_x = randint(100, 300)
arrow_y = randint(100, 300)
hit_colour = get(arrow_x, arrow_y).hex
# print(hit_colour)
fill("brown")
circle(arrow_x, arrow_y, 15)
def setup():
# Set up your game here
size(400, 400)
no_stroke()
def draw():
# Things to do in every frame
fill("cyan")
rect(0, 0, 400, 250)
fill("lightgreen")
rect(0, 250, 400, 150)
fill("brown")
triangle(150, 350, 200, 150, 250, 350)
fill("blue")
circle(200, 200, 170)
fill("red")
circle(200, 200, 110) # Draw the inner circle
fill("yellow")
circle(200, 200, 30) # Draw the middle circle
shoot_arrow()
# Keep this to run your code
run(frame_rate=2)