-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocal Mutiny.py
More file actions
129 lines (109 loc) · 3.7 KB
/
Local Mutiny.py
File metadata and controls
129 lines (109 loc) · 3.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import sys, math, pygame, random, time
canvas_x = 1400
canvas_y = 800
screen = pygame.display.set_mode((canvas_x, canvas_y))
screen.fill((0, 0, 0))
pygame.init()
pygame.display.set_caption('Mutiny')
pygame.mouse.set_visible(0)
game_start = 0
#Test Box (TB)
TB_x = canvas_x/2
TB_y = canvas_y/2
TB_size = 60
TB_yV = 0
#position
P1_x = canvas_x/4
P1_y = canvas_y/4
P2_x = 3*canvas_x/4
P2_y = 3*canvas_y/4
#velocity
P1_xV = 0
P1_yV = 0
P2_xV = 0
P2_yV = 0
#acceleration
P1_xA = 0
P1_yA = 0
P2_xA = 0
P2_yA = 0
mouse_pos = pygame.mouse.get_pos()
def hitbox(x_pos, y_pos, size):
if mouse_pos[0] < x_pos + size and mouse_pos[0] > x_pos and mouse_pos[1] > y_pos and mouse_pos[1] < y_pos + size:
return True
def TB_hitbox():
if mouse_pos[0] < TB_x + TB_size and mouse_pos[0] > TB_x and mouse_pos[1] > TB_y and mouse_pos[1] < TB_y + TB_size:
return True
#functions
def text_objects(text, font):
textSurface = font.render(text, True, (0, 0, 0))
return textSurface, textSurface.get_rect()
def message_display(text, position, size):
smallText = pygame.font.Font('C:/windows/fonts/times.ttf',size)
TextSurf, TextRect = text_objects(text, smallText)
TextRect.center = position
screen.blit(TextSurf, TextRect)
def clear():
# for windows
if os.name == 'nt':
_ = os.system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = os.system('clear')
def announce_player(player_number, time):
print("player " + player_number + "s turn")
time.sleep(time)
clear() ##do the thing and say whose turn it is
def loop_legality():
pygame.display.flip()
screen.fill((255, 255, 255))
for event in pygame.event.get():
if event.type == pygame.QUIT: # makes the loop mortal
start = 0
sys.exit()
def movement():
if paused == 0:
P1_x += P1_xV
P1_y += P1_yV
P2_x += P2_xV
P2_y += P2_yV
P1_xV += P1_xA
P1_yV += P1_yA
P2_xV += P2_xA
P2_yV += P2_yA
P1_xA = P1_xA*0.85
P1_yA = P1_yA*0.85
P2_xA = P2_xA*0.85
P2_yA = P2_yA*0.85
start = 1
while start == 1: #bigger loop that will contain everything, an embedded while loop will be the game
loop_legality()
mouse_pos = pygame.mouse.get_pos()
message_display("made by Jonny B. and Jake N.",(125, 750),15)
mouse1 = pygame.mouse.get_pressed()[0]
mouse2 = pygame.mouse.get_pressed()[2]
mouse3 = pygame.mouse.get_pressed()[1]
screen.blit(pygame.image.load(r'mutiny assets\play_button.png'), (canvas_x/2 - 125, canvas_y/2 - 75))
if mouse_pos[0] > canvas_x/2 - 125 and mouse_pos[0] < canvas_x/2 + 125 and mouse_pos[1] > canvas_y/2 - 75 and mouse_pos[1] < canvas_y/2 + 75 and mouse1 == 1:
game_start = 1
screen.blit(pygame.image.load(r'mutiny assets\cursor.png'), (mouse_pos[0], mouse_pos[1]))
while game_start == 1: #game loop
loop_legality()
mouse_pos = pygame.mouse.get_pos()
message_display("made by Jonny B. and Jake N.",(125, 750),15)
mouse1 = pygame.mouse.get_pressed()[0]
mouse2 = pygame.mouse.get_pressed()[2]
mouse3 = pygame.mouse.get_pressed()[1]
pygame.draw.rect(screen, (0, 150, 0), (TB_x, TB_y, TB_size, TB_size))
if TB_hitbox() and mouse1 == 1:
while mouse1 == 1:
loop_legality()
elif mouse1 == 0 or not TB_hitbox():
if TB_y + TB_size < 3*canvas_y/4:
TB_y -= TB_yV
TB_yV -= 0.01
elif TB_y + TB_size > 3*canvas_y/4:
TB_yV = 0
screen.blit(pygame.image.load(r'mutiny assets\cursor.png'), (mouse_pos[0], mouse_pos[1]))