From ca9b417f37aa2837e14babeec479fe45bb0ec6c4 Mon Sep 17 00:00:00 2001 From: Emil Shanaty Date: Fri, 21 Mar 2025 03:34:49 +0300 Subject: [PATCH] Fix the scalings of horses and barriers. --- gameobjects.py | 29 +++++++++++++++-------------- images/Ribbon_fill.png | Bin 1176 -> 1024 bytes images/Ribbon_out.png | Bin 1239 -> 1090 bytes main.py | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gameobjects.py b/gameobjects.py index 45fb86b..6a35292 100644 --- a/gameobjects.py +++ b/gameobjects.py @@ -59,12 +59,12 @@ class Horse(GameObject): self.vacceleration = 0 self.stopped = False 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_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_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): pos = self.get_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): def __init__(self, image_path, x, y): super().__init__(image_path, x, y) # Initialize barrier + self.scale_by(5) class UI: - children = [] # List of child objects + horses = [] # List of child objects horizontal_offset = 25 # Horizontal spacing between marks vertical_offset = -25 # Vertical spacing between marks mark_size = 25 # Size of the marks def __init__(self): - self.children = [] # Initialize children list - def add_children(self, children): - new_children = [child for child in children if child not in self.children] # Add new children - self.children.extend(new_children) + self.horses = [] # Initialize children list + def add_horses(self, children): + new_horses = [child for child in children if child not in self.horses] # Add new children + self.horses.extend(new_horses) def draw_marks(self, screen): active_marks = [] # List of active horses unactive_marks = [] # List of inactive horses - for i in range(len(self.children)): - if isinstance(self.children[i], Horse): - if (self.children[i].stopped == False): - active_marks.append(self.children[i]) # Add active horses + for i in range(len(self.horses)): + if isinstance(self.horses[i], Horse): + if (self.horses[i].stopped == False): + active_marks.append(self.horses[i]) # Add active horses 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 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] for i in range(len(active_marks)): 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 ya += self.vertical_offset xa = active_marks_section_pos[0] diff --git a/images/Ribbon_fill.png b/images/Ribbon_fill.png index 531b34029e1058074fc25a5183b2e9b638c9a5df..874719237642aba7164515680251a659f6c50291 100644 GIT binary patch delta 302 zcmV+}0nz@L34jP8iBL{Q4GJ0x0000DNk~Le0000J0000f2nGNE0N1e+2azEt3cmmV z4!;371ydxkQ@H|v0NzPNK~zXf?UYLrg)j&NXT1NNc`GcO0QtCl_DU1zB2Wp@U}hHo zNizN`!=?(9PIzz3B#}x;Y>J#r$PX>(2Q3XJ-fu22s4=m zqZ4KCnFd9=r~4tRf)J`f6GxJlE-LX@mB>lYkES;j)E;OLS4GgCVKX`6o^m>?#Db;+ z*kP;5ini&>7Ed`IKvux8up-Pv$Yf3>twaFu12^5c3s$ERLtq#Hn(gAGU?wo5!cQBi~IAOi#6LB<^uv)^tE z-pN$YSmx>C7*Y}U_SQka!v+E@7iRqb|GYqP($-Dh!j;!q_m(R&DW3J=$*h(Ent=%p z`02)-D4O^DX8qkL?caCLES)Cc-QSb2e+pBb_P%tMYF+;Sem}*PZ=`2_@ISR*;-K8h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?WM#H`F;(K}f(>RIv9eGAR}mWbr!t*Kwrf6TYl ze5+Q8@xJD&Rri>ESf~G*zyAAKw)aWL(!NIApP-t2bJ;5{f&RkE4{0^CSG5YIzrA&! z`uYFjF4hfhz3&rduKLgPqcA${!?bkY$o0Rt6g?kOb89ZJ6T-G@yGywpx3ErCk diff --git a/main.py b/main.py index 4871aca..d2bae17 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,7 @@ gameobjects.extend(barriers) # Add barriers to game objects 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: for event in pygame.event.get(): if event.type == pygame.QUIT: # Handle window close event