On 6/9/06, Michael Sullivan <[EMAIL PROTECTED]> wrote: > My name is Michael Sullivan. I am a 26 year-old college student in > Oklahoma. My wife and I have a small (three PCs) computer network that > we operate out of our home. We have our own domain (as one could tell > by examining my email address) I have novice-level experience with VB, > C/C++, Java, and PHP, but I'm just starting out with Python. > > Here's the situation: My wife likes to play the game Chuzzle, found at > Yahoo Games. We use primarily Linux, however Chuzzle is written as an > ActiveX control, which only works on Windows. I have not been able to > get Internet Explorer to work correctly through Wine, so I determined to > write a Chuzzle-like game (with many of my own enhancements) for Linux. > I've been playing around with some Pygame examples lately, and thought > that I'd try writing the game in Python (I've been meaning to learn > Python for years, but just never got around to it.) Today I started on > writing the game. I've decided (at least for now) to call my version, > LinePuzzle. For those of you unfamiliar with Chuzzle, here's the basic > concept: There are individual pieces of different colors arranged on a > grid. The pieces can be moved on a line either vertically or > horizontally. The object of the game is to position three similarly > colored pieces ajacent to each other. At this point the three pieces > will disappear, and the pieces above them will fall to take their place. > As the levels progress, locks are added so that the player cannot move a > locked piece either horizontally or vertically. The game is over when > no more pieces can be removed. > > I started my script by creating a class called LinePuzzlePiece which > represents a single coloured piece. I wanted a random colour chosen > from a list to be assigned to the piece, and then to prove that I had it > set up correctly, I wanted to call a method that would print out the > color of the piece. Here is my code: > > #!/usr/bin/env python > > import random > import time > import math > > class LinePuzzlePiece: > """This class defines a single playing piece for LinePuzzle""" > def __init__(self): > seed(time) > index = int(math.floor(uniform(1, 10))) colorlist = ["red", > "blue", "green" "yellow", "purple"] self.color = colorlist[index] > > def printcolor(): > print self.color > > mypiece = LinePuzzlePiece > mypiece.printcolor > 1. try mypiece.printcolor() instead.
2. I'm cc-ing the pygame user group. I suggest that future questions related to pygame be sent over to that group instead. They are just as friendly as the folks on the tutor list. André > > I saved the script and made it chmod +x. However, when I run it, I get > this: > > [EMAIL PROTECTED] ~ $ ./linepuzzle.py > [EMAIL PROTECTED] ~ $ > > Now, I'm no expert, but I really think something should have been > printed, if even a blank line. What am I doing wrong here? Why is > nothing printing? Is my printcolor method even being called > successfully? > -Michael Sullivan- > > > > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
