-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjects.py
More file actions
44 lines (37 loc) · 1.01 KB
/
Objects.py
File metadata and controls
44 lines (37 loc) · 1.01 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
import pygame
from math import sin, cos, pi, atan2, sqrt
import setting as s
class Objects:
mass = 0 # 최댓값 1000
x = 0
y = 0
velx = 0
vely = 0
shape_type = None
def update (self) -> None:
self.x += self.velx
self.y += self.vely
angle = atan2(self.vely,self.velx)
vel = sqrt(self.velx**2 + self.vely**2)
if (vel - s.FRICTION) < 0:
vel = 0
else:
vel -= s.FRICTION
self.velx = vel * cos(angle)
self.vely = vel * sin(angle)
def view (self) -> None:
pass
class Circles(Objects):
def __init__(self,screen,radius,mass,x,y):
self.screen = screen
self.radius = radius
self.mass = mass
self.x = x
self.y = y
self.velx = 0
self.vely = 0
self.shape_type = "Circle"
def update(self):
return super().update()
def view(self):
pygame.draw.circle(self.screen,(250-self.mass/4,0,0),(self.x,self.y),self.radius)