Archive for September, 2010

Some blog cleaning…

Still wrapping my head around the whole WordPress blog thing:  I’d got hundreds of ‘spam users’ signed up on the blog, and finally found a plugin that will go through a user confirmation process. And honestly, there’s really no reason (that I’m aware of) to be a ‘user’ of this blog anyway, since there’s no actions you can perform, and you don’t need to be a user to post a comment or get the RSS feed. So anyway, all users have been deleted.

I wasn’t able to go through the entire list and see if each one was actually a valid user.  So if you were a user and you still want to be, just register again, and I can approve you.

Basic Pygame Program

Whenever I begin a new Pygame application, I always start with a ‘basic program’ to begin things. Saves me from having to re-type all the simple stuff. Obviously a Pygame program can get far more complex than this, but everything has to start somewhere. Thought I’d post it up for reference.

"""
default.py
www.akeric.com - 2010-09-07
Default, base, initial setup for a pygame program.
In this case, black background, white circle follows mouse position, and
framerate is shown in the title-bar.
"""

#-------------------------------------------------------------------------------
# Imports & Inits
import sys
import pygame
from pygame.locals import *
pygame.init()

#-------------------------------------------------------------------------------
# Constants
VERSION = '1.0'
WIDTH = 512
HEIGHT = 512
FRAMERATE = 60

#-------------------------------------------------------------------------------
# Screen Setup
screen = pygame.display.set_mode((WIDTH, HEIGHT))
bgCol = Color('black')
clock = pygame.time.Clock()
moduleName = __file__.split('\\')[-1]

#-------------------------------------------------------------------------------
# Define helper functions, classes, etc...
def spam():
    pos = pygame.mouse.get_pos()
    pygame.draw.circle(screen, Color('white'), pos, 32)

#-------------------------------------------------------------------------------
# Main Program
def main():
    print "Running Python version: %s"%sys.version
    print "Running PyGame version: %s"%pygame.ver
    print "Running %s version: %s"%(moduleName, VERSION)
    looping = True

    # Main Loop-----------------------
    while looping:
        # Maintain our framerate, set caption, clear background:
        clock.tick(FRAMERATE)
        pygame.display.set_caption("%s - FPS: %.2f" %(moduleName,clock.get_fps()) )
        screen.fill(bgCol)

        # Detect for events-----------
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                looping = False
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    looping = False

        # Do stuff!-------------------
        spam()

        # Update our display:---------
        pygame.display.flip()

#-------------------------------------------------------------------------------
# Execution from shell\icon:
if __name__ == "__main__":
    # Make running from IDE work better:
    sys.exit(main())