-1

In the book python crash course page 244 adding or saving an image to the project is unclear?

I've tried every code it is still telling there is no such file in the working directory.. so i'm seeking for other instructions?

  • 2
    What's the code you're using, and what's the exact output of the error message you're using, and are you sure the images you're trying to open are in the path you're indicating? – Laassairi Abdellah May 06 '23 at 19:54
  • I'm the author of Python Crash Course. It looks like you're using the first edition of the book, which went out of print in 2019. That edition is far out of date at this point, and you should not try to do the projects from that edition. The [third edition](https://ehmatthes.github.io/pcc_3e/) came out in January of this year, and is fully up to date. – japhyr May 07 '23 at 16:11
  • I just figured it out.. the mistake was with misspelling.. but whats thedifference between the first edition and the third edition of this book – Henos Zeru May 14 '23 at 07:27

1 Answers1

0

Are you adding an image for the ship? If so, check the codes below, especially the comments contain signs **

import pygame

class Ship:
    """A class to manage the ship."""

    def __init__(self, ai_game):
        """Initialize the ship and set its starting position."""
        self.screen = ai_game.screen
        self.screen_rect = ai_game.screen.get_rect()

        # Load the ship image and get its rect.
        # **If this location doesn't work, change it to the absolute address.**
        # **The full adress like '/Users/your_username/Downloads/star'**
        self.image = pygame.image.load('images/ship.bmp')
        self.rect = self.image.get_rect()

        # Start each new ship at the bottom center of the screen.
        self.rect.midbottom = self.screen_rect.midbottom

    def blitme(self):
        """Draw the ship at its current location."""
        self.screen.blit(self.image, self.rect)
Hongbo
  • 5
  • 8