Fix the scalings of horses and barriers.
This commit is contained in:
+15
-14
@@ -59,12 +59,12 @@ class Horse(GameObject):
|
|||||||
self.vacceleration = 0
|
self.vacceleration = 0
|
||||||
self.stopped = False
|
self.stopped = False
|
||||||
self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # Random color for the mark
|
self.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # Random color for the mark
|
||||||
self.ribbon_fill = GameObject("images/Ribbon_fill.png", self.x, self.y, (-13, -26))
|
self.ribbon_fill = GameObject("images/Ribbon_fill.png", self.x, self.y, (16, -1))
|
||||||
self.ribbon_fill.recolor(self.color)
|
self.ribbon_fill.recolor(self.color)
|
||||||
self.ribbon_out = GameObject("images/Ribbon_out.png", self.x, self.y, (-13, -26))
|
self.ribbon_out = GameObject("images/Ribbon_out.png", self.x, self.y, (14, -2))
|
||||||
self.set_children(self.ribbon_fill)
|
self.set_children(self.ribbon_fill)
|
||||||
self.set_children(self.ribbon_out)
|
self.set_children(self.ribbon_out)
|
||||||
self.set_size(75, 75) # Set the size of the horse
|
# self.set_size(75, 75) # Set the size of the horse
|
||||||
def apply_vspeed(self):
|
def apply_vspeed(self):
|
||||||
pos = self.get_position()
|
pos = self.get_position()
|
||||||
self.set_position(pos[0], pos[1] + self.vspeed) # Apply vertical speed to position
|
self.set_position(pos[0], pos[1] + self.vspeed) # Apply vertical speed to position
|
||||||
@@ -97,26 +97,27 @@ class Background(GameObject):
|
|||||||
class Barrier(GameObject):
|
class Barrier(GameObject):
|
||||||
def __init__(self, image_path, x, y):
|
def __init__(self, image_path, x, y):
|
||||||
super().__init__(image_path, x, y) # Initialize barrier
|
super().__init__(image_path, x, y) # Initialize barrier
|
||||||
|
self.scale_by(5)
|
||||||
|
|
||||||
class UI:
|
class UI:
|
||||||
children = [] # List of child objects
|
horses = [] # List of child objects
|
||||||
horizontal_offset = 25 # Horizontal spacing between marks
|
horizontal_offset = 25 # Horizontal spacing between marks
|
||||||
vertical_offset = -25 # Vertical spacing between marks
|
vertical_offset = -25 # Vertical spacing between marks
|
||||||
mark_size = 25 # Size of the marks
|
mark_size = 25 # Size of the marks
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.children = [] # Initialize children list
|
self.horses = [] # Initialize children list
|
||||||
def add_children(self, children):
|
def add_horses(self, children):
|
||||||
new_children = [child for child in children if child not in self.children] # Add new children
|
new_horses = [child for child in children if child not in self.horses] # Add new children
|
||||||
self.children.extend(new_children)
|
self.horses.extend(new_horses)
|
||||||
def draw_marks(self, screen):
|
def draw_marks(self, screen):
|
||||||
active_marks = [] # List of active horses
|
active_marks = [] # List of active horses
|
||||||
unactive_marks = [] # List of inactive horses
|
unactive_marks = [] # List of inactive horses
|
||||||
for i in range(len(self.children)):
|
for i in range(len(self.horses)):
|
||||||
if isinstance(self.children[i], Horse):
|
if isinstance(self.horses[i], Horse):
|
||||||
if (self.children[i].stopped == False):
|
if (self.horses[i].stopped == False):
|
||||||
active_marks.append(self.children[i]) # Add active horses
|
active_marks.append(self.horses[i]) # Add active horses
|
||||||
else:
|
else:
|
||||||
unactive_marks.append(self.children[i]) # Add inactive horses
|
unactive_marks.append(self.horses[i]) # Add inactive horses
|
||||||
|
|
||||||
width = 10 # Number of marks per row
|
width = 10 # Number of marks per row
|
||||||
active_marks_section_pos = (0 - self.mark_size, 600 - self.mark_size) # Starting position for active marks
|
active_marks_section_pos = (0 - self.mark_size, 600 - self.mark_size) # Starting position for active marks
|
||||||
@@ -124,7 +125,7 @@ class UI:
|
|||||||
ya = active_marks_section_pos[1]
|
ya = active_marks_section_pos[1]
|
||||||
for i in range(len(active_marks)):
|
for i in range(len(active_marks)):
|
||||||
xa += self.horizontal_offset
|
xa += self.horizontal_offset
|
||||||
pygame.draw.rect(screen, self.children[i].color, (xa, ya, self.mark_size, self.mark_size)) # Draw active marks
|
pygame.draw.rect(screen, self.horses[i].color, (xa, ya, self.mark_size, self.mark_size)) # Draw active marks
|
||||||
if xa >= width * (self.mark_size - 3): # Move to the next row if the row is full
|
if xa >= width * (self.mark_size - 3): # Move to the next row if the row is full
|
||||||
ya += self.vertical_offset
|
ya += self.vertical_offset
|
||||||
xa = active_marks_section_pos[0]
|
xa = active_marks_section_pos[0]
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -28,7 +28,7 @@ gameobjects.extend(barriers) # Add barriers to game objects
|
|||||||
|
|
||||||
spawner = Spawner("images/Barrier.png") # Initialize spawner
|
spawner = Spawner("images/Barrier.png") # Initialize spawner
|
||||||
|
|
||||||
UI.add_children(horses) # Add horses to UI
|
UI.add_horses(horses) # Add horses to UI
|
||||||
while True:
|
while True:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT: # Handle window close event
|
if event.type == pygame.QUIT: # Handle window close event
|
||||||
|
|||||||
Reference in New Issue
Block a user