Tim2othy / spacegame

2 stars 1 forks source link

Ship graphics #18

Open lumi-a opened 3 months ago

lumi-a commented 3 months ago

Currently, ships are rendered as a composition of simple geometric shapes.

You once added code that let the ship be rendered from an image, instead:

    # If reviving this code, add `self.load_image('ship_sprite.png')`
    # back to the `Ship.__init__` method.
    def load_image(self, image_path: str):
        #Load and prepare the ship image.
        #param image_path: Path to the ship image file
        self.image = pygame.image.load(image_path).convert_alpha()
        self.image = pygame.transform.scale(self.image, (60, 28))  # Resize 
        self.original_image = self.image  # Store the original image for rotation

    def draw_with_image(self, screen: pygame.Surface, camera_pos: Vector2): 
        ship_relative_pos = self.pos - camera_pos 
        rotated_image = pygame.transform.rotate(self.original_image, self.angle)
        rect = rotated_image.get_rect()
        rect.center = ship_relative_pos
        screen.blit(rotated_image, rect)

I don't know how difficult it'd be to render different sprites for different thruster-activations.

lumi-a commented 3 months ago

Maybe the gfxdraw.textured_polygon()-method could help here. But it's probably better to just compose a few sprites.

Tim2othy commented 3 months ago

I like the sprites from this game https://www.youtube.com/watch?v=qq_Zvg9KlII especially the bullets (lasers in that game). I think it's fairly easy to screenshot that game turn the png s into pixel art and use that as sprites. But I'd wait with that until later, for now I just wanted to try out if it worked.

The ship sprite is a profile view anyway so not usable for our game.

lumi-a commented 3 months ago

Maybe we shouldn't commit copyright-infringement.

OpenGameArt has sprites, though we'd have to look for one with a compatible license. Perhaps this, but I'm not picky.

Tim2othy commented 3 months ago

they would probably be delighted if they know that people are still referencing their game. If we ever plan on selling the game we can find non copyrighted material.