Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:23:52+00:00 2026-06-07T16:23:52+00:00

I wrote a simple (so I thought) starfield animation for a personal Python project

  • 0

I wrote a simple (so I thought) starfield animation for a personal Python project of mine. Right about the time that the game got to the “playable” stage, I decided to undertake another project; experimentation with a Windows/Ubuntu dual-boot. While the details of the Windows/Ubuntu experiment are a real page-turner, the relevant issue is more one of, “why does this code work fine on Windows XP but causes all manner of crashes on Ubuntu 12.04”?

This code was written for Python 2.7 using Pygame 1.9.

import pygame, random, sys
from pygame import *

pygame.init()

width = 400
height = 400
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)


DISPLAYSURF = pygame.display.set_mode((width, height))

stars = 50
starfield = []

for i in range(stars):
    x = random.randrange(0, width)
    y = random.randrange(0, height)
    starfield.append([x, y])

clock = pygame.time.Clock()
FPS = 60

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
           pygame.quit()
           sys.exit()

DISPLAYSURF.fill(BLACK)

starCounter = 0
for star in starfield:
    starCounter += 1
    x, y = star
    starDraw = pygame.PixelArray(DISPLAYSURF)
    starDraw[x][y] = WHITE
    del starDraw

            #fake parallax scrolling effect
    star[1] += 1
    if starCounter % 3 == 1:
        star[1] += 1

    if starCounter % 5 == 1:
        star[1] += 1

    if star[1] > height:
        star[0] = random.randrange(0, width)
        star[1] = 0

Eventually I solved this by replacing the PixelArray nonsense with surface.set_at(), and removing all the code relevant to instantiating PixelArray objects. But it wasn’t just segfaults (of the Pygame parachute variety), I would get all kinds of weird error messages; something about gcclibrary, something about malloc(), etc etc. Keep in mind I wasn’t using any IDLE or anything like that before; I always run everything from the command line and/or Terminal.

The kind of errors I used to experience don’t necessarily concern me; the fact that Windows would just silence them while Ubuntu was more than happy to point and laugh at them does. Clearly, this must have been the result of PEBKAC, but why on Earth would Windows keep that information from me? And on the flipside of this argument; will coding under Ubuntu forgive a different kind of bad habit? If Windows silences certain kinds of segfaults, does Ubuntu catch a different set of errors, and do I really need to be mindful of all the different goofball errors that every major OS might decide to catch or not catch? I’ve only been at this for about a year, so there’s a lot of information I’m just underexposed to and unaware of.

And I mean, I guess if you want to show me the error of my old code in case I ever feel that creating PixelArray objects is something I need to do in the future, I don’t really mind that either. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:23:56+00:00Added an answer on June 7, 2026 at 4:23 pm

    The code you provided works without crashing on my machine (Ubuntu 11.10, Python 2.7.2). It also works if I comment out the while True block so that the later code (PixelArray etc) runs. Since there is no display loop or anything, nothing much is shown besides a black window popping up briefly, but there are no exceptions of any kind.

    Python under Windows won’t hide segfaults etc, there is something wrong with the Ubuntu setup. I suspect it is one of three things:

    1. The Python installation on your Ubuntu machine is corrupted.
    2. The installation of pygame (or a related library) has been corrupted.
    3. A bit of compiled code has been copied over from Windows and is causing issues when run under Ubuntu (unlikely, as I would expect it to refuse to run completely rather than start running and then raise problems, but I’m throwing it out there just in case).

    If you edit your question to include the full traceback of the errors, somebody may be able to figure out just where things are broken.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple WinForm program in C# that displays the time, updating every
I wrote simple class that on the start it just increase the value of
I wrote a simple function, that makes emacs add matching quotes (so when I
Today, without much thought, I wrote a simple function return to a char* based
I wrote the following jQuery plugin that is basically just a simple notification system
I wrote a simple web server that takes the public link to a google
I just wrote some simple sample code to make sure that I had EclEmma
I am trying to write, what I thought was, a simple jQuery function to
i wrote simple 3 functions to scrape titles , description and keywords of simple
I wrote simple load testing tool for testing performance of Java modules. One problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.