-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbase.py
46 lines (31 loc) · 748 Bytes
/
base.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
import pygame, sys, math
pygame.init()
FPS = 300 # frames per second setting
fpsClock = pygame.time.Clock()
# set up the window
screen = pygame.display.set_mode((400, 300), 0, 32)
pygame.display.set_caption('Projectile Motion')
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
delta_t = 0.01
m = 1
fx = 0
fy = 0
x = 0
y = 150
vx = 10
vy = 0
while True:
screen.fill(BLACK)
vx = vx + (fx / m) * delta_t
vy = vy + (fy / m) * delta_t
x = x + vx * delta_t
y = y + vy * delta_t
pygame.draw.circle(screen, WHITE, (int(x), int(y)), 5)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)
pygame.quit()