-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodechart.py
More file actions
47 lines (47 loc) · 1.41 KB
/
codechart.py
File metadata and controls
47 lines (47 loc) · 1.41 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
import pygame
from pygame.locals import *
'''
Purpose:
- Function checks whether small icon page was clicked or not
- Function displays larger version page whenever the player clicks on a small icon page
Parameter:
screen: the window that the game in played on
icon: the small icon that is clicked on by the player
chart: the large page that is drawn by the function
Return:
- Draws the large, readable page on the screen
'''
def clicked(screen,icon, chart):
c_sides = icon.get_sides()
left = c_sides[0]
right = c_sides[1]
top = c_sides[2]
bottom = c_sides[3]
if pygame.mouse.get_pressed()[0]:
x,y = pygame.mouse.get_pos()
if x>=left and x<right and y>=top and y<=bottom:
chart.draw(screen)
'''
Purpose:
- Function checks whether the player has clicked to leave the game or not
Parameter:
screen: the window that the game in played on
icon: the icon that is clicked on by the player
Return:
True, False
- Whether the player has clicked to leave the game or not
'''
def clicked_leave(screen,icon):
c_sides = icon.get_sides()
left = c_sides[0]
right = c_sides[1]
top = c_sides[2]
bottom = c_sides[3]
if pygame.mouse.get_pressed()[0]:
x,y = pygame.mouse.get_pos()
if x>=left and x<right and y>=top and y<=bottom:
return False
else:
return True
else:
return True