import pygame, sys class Player(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = pygame.Surface((100,100)) self.image.fill((255,255,255)) self.rect = self.image.get_rect(center = (screen_w/2, screen_h/2)) def update(self): self.rect.center = pygame.mouse.get_pos() def create_bullet(self): return Bullet(pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1],) class Bullet(pygame.sprite.Sprite): def __init__(self, pos_x, pos_y): super().__init__() self.image = pygame.Surface((50,10)) self.image.fill((255,0,0)) self.rect = self.image.get_rect(center = ((pos_x + 75), pos_y)) def update(self): self.rect.x += 15 if self.rect.x >= screen_w == 100: self.kill() pygame.init clock = pygame.time.Clock() screen_w, screen_h = 1920,1080 screen = pygame.display.set_mode((screen_w, screen_h)) pygame.mouse.set_visible(False) player = Player() player_group = pygame.sprite.Group() player_group.add(player) bullet_group = pygame.sprite.Group() while True : for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: print("key_board input -> Exit") pygame.quit() sys.exit() if event.key == pygame.K_SPACE: bullet_group.add(player.create_bullet()) if event.type == pygame.MOUSEBUTTONDOWN: bullet_group.add(player.create_bullet()) screen.fill((30,30,30)) player_group.draw(screen) bullet_group.draw(screen) player_group.update() bullet_group.update() pygame.display.flip() clock.tick(120) # Was meant to add sprites but Im too sigma