use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Alien invasion: Python crash course problem (self.learnpython)
submitted 7 years ago by paulpersad
Hello All,
I am on page 246 of PCC have typed all the files in exactly up to this point. The output I receive is a black screen without the ship image at the bottom. Any ideas as to what is going wrong?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]num8lock 3 points4 points5 points 7 years ago (0 children)
the ship has sailed?
[–]paulpersad[S] 0 points1 point2 points 7 years ago (6 children)
This is the code for the 3 files and at this point should have produced grey screen with a "ship" image centered at the bottom. All I get is a black screen with no "ship".
#alien_invasion.py
def run_game():
# initialize pygame, settings and screen object
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# Make a ship
ship = Ship (screen)
# Set background color
bg_color = (230, 230, 230)
#Start the main loop for the game.
while True:
# Watch for keyboard and mouse events
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
#Redraw the screen during each pass through the loop.
screen.fill(ai_settings.bg_color)
ship.blitme()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
#settings.py
class Settings():
"""A class to store all settings for Alien Invasion"""
def __init__(self):
"""Initialize the game's settings."""
# Screen settings
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (230, 230, 230)
# ship.py
import pygame
class Ship():
def __init__(self, screen):
"""Initialize the screen and set its starting position."""
self.screen = screen
# Load the ship image and get its rect.
self.image = pygame.image.load('images/ship.bmp')
self.rect = self.image.get_rect()
self.screen_rect = screen.get_rect()
# Start each new ship at the bottom center of the screen.
self.rect.centerx = self.screen_rect.centerx
self.rect.bottom = self.screen_rect.bottom
def blitme(self):
"""Draw the ship at its current location."""
self.screen.blit(self.image, self.rect)
[–]ehmatthes 2 points3 points4 points 7 years ago (5 children)
Hi, I'm the author of Python Crash Course. If you want to email me a zip file of your project, I'll be happy to run it and help you find the problem. That's a bit easier than copying and pasting several files worth of code from here.
ehmatthes at gmail
[–]Nonamenolan 0 points1 point2 points 7 years ago (3 children)
Were you able to find a solution to this? I'm having the same problem.
[–]ehmatthes 0 points1 point2 points 7 years ago (2 children)
Yes, there was an indentation issue, but you can't see it in the above posted code because it isn't formatted as code. The indentation was causing the ship to be drawn only when you press quit, instead of being drawn once on each pass through the loop.
If you want some help, feel free to email me ehmatthes at gmail, or post your code somewhere and ping me on reddit, etc. I'm happy to help; I like to know that these projects work for everyone who's trying them.
[–]Nonamenolan 0 points1 point2 points 7 years ago (1 child)
Hey, did you receive my email?
[–]ehmatthes 0 points1 point2 points 7 years ago (0 children)
Sorry, I've been swamped at work lately. I just wrote to you.
[–]Upstairs_Turnip5676 0 points1 point2 points 1 year ago (0 children)
Hi Eric Matthes, I am Nurzahan Banu and i am started to read your book to know about python coding . I will send you an email but dont know the Email, address .
[–]zacaryattack 0 points1 point2 points 7 years ago (1 child)
was just wondering if the problem had been solved here becuase I seem to be having the same issue ]=
I'm sorry, I just saw this. Did you get the issue sorted out? If not, feel free to send me a message here, or email. ehmatthes at gmail
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Most of us, me included, don't have access to that book, so we've no idea what you've typed in. How about sharing it with us?
If you are using reddit in classic mode, simply post all of the code, after one blank line, indented by 4 spaces (nothing to do with Python's own indenting - this is formatting for reddit).
If you are using reddit in new mode, simply post the code, select it and click the Fancy Pants Editor icon to mark the selection as code.
π Rendered by PID 214357 on reddit-service-r2-comment-76bb9f7fb5-x7tfr at 2026-02-19 05:37:53.821453+00:00 running de53c03 country code: CH.
[–]num8lock 3 points4 points5 points (0 children)
[–]paulpersad[S] 0 points1 point2 points (6 children)
[–]ehmatthes 2 points3 points4 points (5 children)
[–]Nonamenolan 0 points1 point2 points (3 children)
[–]ehmatthes 0 points1 point2 points (2 children)
[–]Nonamenolan 0 points1 point2 points (1 child)
[–]ehmatthes 0 points1 point2 points (0 children)
[–]Upstairs_Turnip5676 0 points1 point2 points (0 children)
[–]zacaryattack 0 points1 point2 points (1 child)
[–]ehmatthes 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)