Learning Ubuntu #0001

January 15, 2012 1 comment

Hello everybody!

My name is Nick and I’m a good friend of the Defenestrator. I am a Christian. You can see my blogs at http://www.cowboycomputers.TK or http://cowboynicka.blogspot.com. Today I’m going to talk about Ubuntu.
This first tutorial is quite simple. It’s about installation. You will first need to download a disk image from http://www.ubuntu.com and you will need to burn it to a disk.

ESTIMATED TIME TO COMPLETE: 45 minutes without updates

Insert your Ubuntu install disc and force the CD drive to boot first.

If you already have Windows, select install alongside Windows and resize partitions to complete this.

Follow the prompts to the end as shown in this video. Reboot. It’s as easy as that!


Python Tipsss and Tricksss #00003

Hey all!


Yes, yes, I know it’s been a while since I posted. I am sorry about that. I will try to be more diligent from now on :). Today, we’ll start my series on making a platforming game. The end result will hopefully be something close to the commercial games of Minecraft or Terraria.


We’ll start out with our basic Wall class. This is just a basic class that stores x and y coordinates, but it brings forth some important concepts. Let’s look at it now:


class Wall(pygame.sprite.Sprite):

def __init__(self, x, y, image, game, colorkey, *groups):


pygame.sprite.Sprite.__init__(self, groups)

self.image, self.rect = basics.load_image(image, colorkey, x, y, game)

self.x = self.rect.x

self.y = self.rect.y

self.w = self.rect.w

self.h = self.rect.h


As you can see, this is a very basic class. However, it’s a very good starting point for those new to Pygame.

On line one, we define a class. For those familiar with Python, this will be easy to understand. But for those among us who are not so snake-savvy, let’s go through this line:

  1. It starts with the class statement. This will be the case for ANY python class that you create.
  2. We then specify the name of the class. Again, any python class will have this feature.
  3. Next, there is the words pygame.sprite.Sprite in parentheses. This indicates that the Wall class inherits the pygame.sprite.Sprite class. If you are not familiar with inheritance, google it. For more info on pygame.sprite.Sprite, see the documentation at http://pygame.org/docs/ref/sprite.html.

Then, we define the __init__ method. You can easily see the syntax for functions in Python, but just to be kind, here it is in easy-to-read format:

def <function name>(<parameter>, <parameter>, …)

Now, in this particular function, you will notice that the last parameter has an asterisk (*) before it. This means that any arguments after this point will be considered part of the groups list. For more on python lists, google ‘python list’. These are very versatile data structures, and a key part of the Python language.

I should also mention that __init__ is the python equivalent of New or Wall{} in other languages. It is simply the subroutine for creating a new object. To make a new wall, you would use w = Wall(<parameters>). Also, all subs in a class will have their first parameter as self. This is similar to Me in VB or this in C++. It references back to the instance of the object. DO NOT count this when calling the sub. Just skip it.

The first line of __init__ calls the Sprite initialization routine to get some basic variables into it. This can be ignored for now, but you should learn more about this when you can. For you C++oders or Javaguys out there, this is kind of like super().

Now, we load the image and rectangle using my basics library. Here are the functions used:


def rectFromImage(img, x, y):

“”” Creates a sprite rectangle from the given image at the given location. “””

rect = img.get_rect() # Create a rectangle with the size of the image.

rect = rect.move([x, y]) # Move the rectagle into position.

return rect



def load_image(name, colorkey, x, y, game):

“”” Loads a image into memory. “””

fullname = os.path.join(‘data’, game, name) # Get the full path of the image.



img = image.load(fullname) # Load the image.

except error, message:

print ‘Cannot load image:’, fullname # Print an error message.

raise SystemExit, message # Exit the game.


img = img.convert() # Convert the image into a proper format.


if colorkey is not None: # If a color key has been given…

if colorkey is -1: # If we have been told to autodetect the colorkey…

colorkey = img.get_at((0,0)) # Automatically set the colorkey.

img.set_colorkey(colorkey, RLEACCEL) # Set the colorkey.


return img, rectFromImage(img, x, y)


All these do is simply load the image and get its rectangle.

The next lines in __init__ will declare its private instance variables. Unlike most languages, this is done in __init__, not in the class definition itself.


That’s all for today. If you have any questions, feel free to comment!

Adding / Deleting Controls at Run Time in VB

November 30, 2011 2 comments
Flow of data in a typical parser

Image via Wikipedia

Hello all, and welcome to my first official VB Wednesday! *doot-da-doo*

Today, I’ll discuss how to add and remove controls (buttons and picture boxes) on a form during runtime in VB.

Read more…

Python Tuesdays – The kickoff!

November 29, 2011 2 comments

Hello all!

Today is the first of the Python Tuesdays!  Today, I’m going to talk about a missile aiming system using python and pygame. I’ll assume that you have already installed both.

Read more…

My Projects

November 26, 2011 3 comments
Pics of The Mechanic

The Mechanic

Hello again!

Today, I’m going to tell you all about my current projects.

Read more…

Defenestration Coding is Alive!

November 26, 2011 1 comment


The Defenestrator has returned!  I will now be posting at least once a week, probably with three columns: Python Tuesdays, VB Wednesdays, and Friday Funnies!  My good friend, Nick, may be posting periodically on Ubuntu as well.  As for today, I will be doing a make-up post for all of the time I’ve been gone, describing some of my current projects.  Also, there is a Defenestration Coding logo in the works!

Until today, ciao! 😀


November 26, 2011 3 comments
Sierpiński triangle made as an IFS with 500, 5...

Image via Wikipedia

Here are some awesome sites that deserve recognition:

Read more…

Categories: Blog Tags: , ,