forked from namankr1/SimPhy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame2.py
59 lines (51 loc) · 1.87 KB
/
game2.py
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
import pygame
import sys
import inputbox
from Button import Button
from animation2 import animation2
import errorScreen
from endScreen import endScreen
from constants import *
from pygame.locals import *
def startGame2(DISPLAY_SURF):
print ("INSIDE GAME2.py")
btn_start = pygame.image.load('Images/buttons/start.png')
clock = pygame.time.Clock()
background=pygame.image.load('Images/game2/1.png')
run = True
while run:
DISPLAY_SURF.blit(background,SCREEN_TOPLEFT)
mouse = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
elif event.type == pygame.MOUSEBUTTONDOWN:
if rect_start.collidepoint(mouse):
countInputs = 1;
mass = inputbox.ask(DISPLAY_SURF, "Mass, M",countInputs)
mass = float (mass)
if mass <= 0 :
errorScreen.errorScreen(DISPLAY_SURF,"Mass must be Positve")
countInputs = countInputs + 5;
initial_velocity = inputbox.ask(DISPLAY_SURF, "Coeff. of Friction, u",countInputs)
initial_velocity = float (initial_velocity)
if initial_velocity > 1 :
errorScreen.errorScreen(DISPLAY_SURF,"Invalid coeff. of friction")
if initial_velocity < 0 :
errorScreen.errorScreen(DISPLAY_SURF,"Invalid coeff. of friction")
countInputs = countInputs + 5;
force = inputbox.ask(DISPLAY_SURF, "Force, F",countInputs)
force = float (force)
final_velocity = initial_velocity * force
weight = mass * 9.8
if ( weight > final_velocity):
font = pygame.font.Font(None, 36)
text = font.render("The block will fall down.", 1, (10, 10, 10))
animation2(DISPLAY_SURF,'down',text)
else:
res = pygame.image.load('Images/game2/5.png')
DISPLAY_SURF.blit(res,SCREEN_TOPLEFT)
endScreen(DISPLAY_SURF,":)")
rect_start = DISPLAY_SURF.blit(btn_start ,(220,303))
pygame.display.update()
clock.tick(60)