Erik Horton

IT aficionado / hobbyist

Page 2


Python Game Development - Pygame vs. Pyglet: Part 1

Here, you’ll find basic comparisons between Pygame and Pyglet, showing you how to accomplish the same tasks in each. As I learn, more posts on the subject will be made.

 Get a blank window to come up

 Pygame

import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))
if __name__ == "__main__":
while True:
    pygame.display.flip()

Source

 Pyglet

import pyglet
screen = pyglet.window.Window(800,600)

if __name__ == "__main__":
    pyglet.app.run()

Source

 Clear Screen

 Pygame

import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))

if __name__ == "__main__":
    while True:
        screen.fill((0,0,0))
        pygame.display.flip()

Source

 Pyglet

import pyglet
screen = pyglet.window.Window(800,600)

@screen.event
def on_draw():
screen.clear()

if __name__ == "__main__":
    pyglet.app.run()

Source

 Control Frames Per Second (FPS)

 Pygame

Continue reading →


RetroPie: Raspberry Pie Retro Gaming Setup

 What I’m going to show you how to configure

  • Raspberry Pi running the Raspbian OS

  • Boot into emulationstation, a GUI frontend to RetroArch allowing you to select any emulators’ games

  • Use of xboxdrv to use an xbox controller to play with

  • Automount of a windows shared drive where all your ROM’s are stored

 Prerequisites

 Imaging tool

Windows: Win32DiskImager

 Operating system

Raspbian. For this setup, I got: 2012-10-28-wheezy-raspbian.zip.torrent

 Setup

  1. Insert your sd card into your computer. When it mounts, open up My Computer and find what drive letter it mounted as.
  2. Open Win32DiskImager
  3. Click the folder on the right, and select the 2012-10-28-wheezy-raspbian.img file.
  4. Make sure the device is the same drive letter as your sd card.
  5. Finally, click “Write.”
  6. After it finishes, you can close Win32DiskImager, and remove your sd card.

 Pre-Boot

  1. Insert your imaged sd card into your

Continue reading →


Configure Notepad++ to run a python script

 Install python (2.7.4)

  1. Download the python 2.7.4 windows installer from http://www.python.org/download/

  2. Run through the installer using the default settings for everything. It should install python in the folder: C:\Python27. If you’re using a different version of python, just substitute out the version number wherever you see 27.

 Install Notepad++

  1. From http://notepad-plus-plus.org/download, download the Notepad++ installer.

  2. Run through the installer using the default settings for everything.
    Open Notepad++

 Configure Notepad++ to run a python script

  1. Open up a command prompt
  2. Run the following command:

set PATH=%PATH%;C:\Python27

Note: If your version of python was installed in a different location, make sure to substitute out that location with the one in the command.

You can use the following command to make sure the python path was added to the PATH variable:

echo

Continue reading →