aboutsummaryrefslogtreecommitdiff
path: root/asteroid.py
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2023-07-30 14:30:26 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2023-07-30 14:30:26 +0530
commit28d7cee3ed843e4cb183ebe53f7a508d4df6d3de (patch)
tree589bef284d4016724d0c3946f8596bddeca7f051 /asteroid.py
parentbf8050124434b5b3c5bb1ba1eb64496e7df59355 (diff)
add asteroids
Diffstat (limited to 'asteroid.py')
-rw-r--r--asteroid.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/asteroid.py b/asteroid.py
new file mode 100644
index 0000000..1735c8b
--- /dev/null
+++ b/asteroid.py
@@ -0,0 +1,17 @@
+import pygame
+import random
+
+class Asteroid:
+ def __init__(self):
+ self.x = random.randint(80, 800) # Random x position within the screen width
+ self.y = 60 # Starting y position at the top
+ self.speed_y = random.randint(1, 3) # Random downward speed
+
+ # Load asteroid image
+ self.asteroid_image = pygame.image.load('res/asteroid.png')
+
+ def move_down(self):
+ self.y += self.speed_y
+
+ def draw(self, screen):
+ screen.blit(self.asteroid_image, (self.x, self.y))