Aim Trainer game

I’m taking a small break with the Zelda game for now because it’s making me a little burnt out and it’s becoming slightly repetitive so I decided to start something new. I will go back to it though.

the ‘Target” class:

class Target:
    MAX_SIZE = 30
    GROWTH_RATE = 0.2
    COLOR = "red"
    SECOND_COLOR = "white"
    
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.size = 0
        self.grow = True
        
    def update(self):
        '''Udpates the target's size when it grows or shrinks'''
        if self.size + self.GROWTH_RATE >=self.MAX_SIZE:
            self.grow = False
            
        if self.grow:
            self.size += self.GROWTH_RATE
        else:
            self.size -= self.GROWTH_RATE
            
    def draw(self, win):
        '''draws a circle on the screen'''
        pygame.draw.circle(win, self.COLOR, (self.x, self.y), self.size)
        pygame.draw.circle(win, self.SECOND_COLOR, (self.x, self.y), self.size * 0.8)
        pygame.draw.circle(win, self.COLOR, (self.x, self.y), self.size * 0.6)
        pygame.draw.circle(win, self.SECOND_COLOR, (self.x, self.y), self.size * 0.4)

This creates the target. The target will and stop at a certain size and then shrink down to zero.

The update() function updates the size when the target grows and shrinks.

the draw() function creates the circles for the target. There are four circles because if we drew one it would just be on big circle growing and shrinking on the screen.

The “Main” loop

# Main Loop
def main():
    run = True
    
    while run:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
                break
            
    pygame.quit()

This is the main loop of the program. All it does right now is that it allows you to quit the program.

You’re probably wondering why there isn’t much to this. The reason is 1. It’s career day so that made me loose time and 2. I wanted to make a post of the simple stuff I had for now before I added anything that would be long and tedious.

Author: Zende_

From PA. EHS 2025. Does computer programming and such. That's really it.

Leave a Reply

Your email address will not be published. Required fields are marked *