Skip to content

Commit 8d91b77

Browse files
work on effects :)
1 parent 41d5e61 commit 8d91b77

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/gravity.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def draw(self):
2727
pygame.draw.circle(screen, BLACK, (int(self.position[0]), int(self.position[1])), int(self.radius))
2828
pygame.draw.circle(screen, WHITE, (int(self.position[0]), int(self.position[1])), int(self.radius), width=10)
2929
d = 60 - clock.get_fps()
30-
if d > 2:
30+
if d > 7.5:
3131
self.radius += d*1.5
3232
else:
33-
self.radius += 2
33+
self.radius += 5
3434

35-
if self.radius > 2250:
35+
if self.radius > 2210:
3636
self.do_wipe = False
3737
self.radius = 0
3838

@@ -47,7 +47,7 @@ def __init__(self, x, y, size=1, vx=0, vy=0):
4747
self.mass = size # Mass is proportional to size
4848
color = pmma.ColorConverter()
4949
self.color = color.generate_random_color(format=pmma.Constants.RGB)
50-
self.explosion_size = random.randint(100, 250)
50+
self.explosion_size = random.randint(250, 750)
5151

5252
def move(self):
5353
self.x += self.vx
@@ -62,13 +62,13 @@ def move(self):
6262
def draw(self, screen):
6363
pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), self.size)
6464

65-
def attract(self, other, G=0.5):
65+
def attract(self, other, G=1):
6666
# Calculate distance and direction
6767
dx = other.x - self.x
6868
dy = other.y - self.y
6969
distance = math.sqrt(dx**2 + dy**2)
7070

71-
if distance > 0 and distance < 1920: # Limit the interaction range
71+
if distance > 0: # Limit the interaction range
7272
force = G * (self.mass * other.mass) / distance**2
7373
fx = force * (dx / distance)
7474
fy = force * (dy / distance)
@@ -132,13 +132,13 @@ def combine(self, other):
132132
p1.move()
133133
p1.draw(screen)
134134

135-
if p1.mass > 100:
135+
if p1.mass > p1.explosion_size:
136136
particles.remove(p1)
137137
# Explosion logic
138138
num_new_particles = int(p1.explosion_size / 3) # Number of smaller particles
139139
for _ in range(num_new_particles):
140140
angle = random.uniform(0, 2 * math.pi) # Random angle for direction
141-
speed = random.uniform(1, 3) # Speed of the smaller particles
141+
speed = random.uniform(5, 7) # Speed of the smaller particles
142142
new_vx = math.cos(angle) * speed
143143
new_vy = math.sin(angle) * speed
144144
particles.append(Particle(p1.x + 20 * math.cos(angle), p1.y + 20 * math.sin(angle), size=random.randint(1, 5), vx=new_vx, vy=new_vy))

0 commit comments

Comments
 (0)