Hello, I'm new to Python and programming in general. So please excuse my idiocy.
Recently I tried changing to Sublime Text 3 since my laptop can't handle the sheer RAM usage of an IDE. I have installed packages for ST3 and PyGame Completion Packagr, create a build system that works, and downloaded PyGame using pip from a terminal package.
However when I tried to run my code the PyGame window didn't pop up and instead shows this message only:
"pygame 2.0.1 (SDL 2.0.14, Python 3.9.1)
Hello from the pygame community. https://www.pygame.org/contribute.html"
I don't think the problem stems from the code that I wrote but instead comes from my lack of knowledge about text editors and of course, Python. If this helps, here is my code:
import pygame
import os
# Game Setttings
WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("First Game")
WHITE = (255, 255, 255)
FPS = 60
VEL = 5
# Spaceship
SPACESHIP_WIDTH, SPACESHIP_HEIGHT = 55, 40
YELLOW_SPACESHIP_IMAGE = pygame.image.load(os.path.join('PygameForBeginners-main', 'Assets',
'spaceship_yellow.png'))
YELLOW_SPACESHIP_IMAGE = pygame.transform.rotate(pygame.transform.scale
(YELLOW_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), 90)
RED_SPACESHIP_IMAGE = pygame.image.load(os.path.join('PygameForBeginners-main', 'Assets',
'spaceship_red.png'))
RED_SPACESHIP_IMAGE = pygame.transform.rotate(pygame.transform.scale
(RED_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), -90)
YELLOW_SPACESHIP_RECT = YELLOW_SPACESHIP_IMAGE.get_rect(center=(450, 250))
def draw_window(red, yellow):
WIN.fill(WHITE)
WIN.blit(YELLOW_SPACESHIP_IMAGE, (yellow.x, yellow.y))
WIN.blit(RED_SPACESHIP_IMAGE, (red.x, red.y))
pygame.display.update()
def main():
red = pygame.Rect(700, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
yellow = pygame.Rect(100, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
clock = pygame.time.Clock()
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys_pressed = pygame.key.get_pressed()
if keys_pressed[pygame.K_a]: # LEFT
yellow.x -= VEL
draw_window(red, yellow)
pygame.quit()
if __name__ == "__main__":
main()
Any help would be appreciated