Python Forum
Recommended game IDE on Ubuntu 18.04
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recommended game IDE on Ubuntu 18.04
#3
pip install pygame
works but when I try to run some basic code that uses the pygame module I get this error

ModuleNotFoundError: No Module Named 'pygame' on line 2

I am using Spyder (Python 3.6) on Ubuntu 18.04

Here is the code I'm trying to run
# Pygame template - skeleton for a new pygame project
import pygame
import random

WIDTH = 360
HEIGHT = 480
FPS = 30

# define colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

# initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()

# Game loop
running = True
while running:
    # keep loop running at the right speed
    clock.tick(FPS)
    # Process input (events)
    for event in pygame.event.get():
        # check for closing window
        if event.type == pygame.QUIT:
            running = False

    # Update

    # Draw / render
    screen.fill(BLACK)
    # *after* drawing everything, flip the display
    pygame.display.flip()

pygame.quit()
Reply


Messages In This Thread
Recommended game IDE on Ubuntu 18.04 - by GarDebs - Apr-30-2019, 06:22 PM
RE: Recommended game IDE on Ubuntu 18.04 - by GarDebs - May-05-2019, 10:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020