pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
Project Graff

Project Graff - 0.0.7

David Hahn (hahn)

Tags:

Description

Note: currently this runs off pygame 1.8.1.
What you need to do to run the thing:
Go to source link, get the files, and run it. You need numpy, python, and pygame--no py2exe yet for windows, sorry. Numpad moves you, bump into things to initiate combat, Scroll Lock takes pictures. See the readme for more.


What it is:
It's a Roguelike in Python. For now you can call it Project Graff. For short, you can call it PyRL if you want, although Graff is probably easier. And I think PyRL is taken by some other project, but when I made the blog's title I did not know that.

Put simply, it's my attempt at a Roguelike in python with pygame, which started as a project to help me learn python. I'm planning on deviating quite a bit from the roguelike formula later on, but for now I'm concentrating on making the standard-fare roguelike; I'll branch out later when I have the important stuff in.



Stuff to know:
Home page has more info..
Readme has more info.
Comments? Make 'em here or on the blog, I'll see them either way. Blog comments show up in my inbox though--odds are I'll see those a bit quicker if you really need to talk to me.

Changes

Added in a custom building to the town
There is a healing item in the center of that building
Combat formulas have been changed and somewhat randomized
Entity definitions have been reworked into a separate file and streamlined
Monster statistics have been reworked to adjust by level
Multiple monsters have been added
‚??Some creatures are slower and hit harder, etc
Turn system is now in place to give creatures different speeds
Stairs take you to and from the caves
‚??Topleft of the town is the entry point to the caves
‚??Bottomright of the caves is the exit point
The town is now persistent until the game quits; caves are still random
Health and mana are now displayed on the GUI
‚??Health changes to red as you lose it; mana currently does nothing
File structure has been cleaned up: all code files now reside in the ‚??code‚?Ě folder
Graff‚??s display icon is the gelatinous cube until something more appropriate is found

Links

Home Page: http://pyrl.wordpress.com
Source: http://sites.google.com/site/pyrlfiles/
Windows: http://sites.google.com/site/pyrlfiles/

Screenshot


click to view original size

Releases

Project Graff - 0.0.8B - Oct 10, 2009
Project Graff - 0.0.8 - Sep 12, 2009
Project Graff - 0.0.7 - Aug 2, 2009
Project Graff - 0.0.6B - Jul 13, 2009

Pygame.org account Comments

If you wish to leave a comment with your pygame.org account, please sign in first.

October 13, 2009 1:11am - Scott Barlow - nickname: (spectre5)
I decided to try typecasting it instead...This worked...change the first line of your to:
colorValue = int(ImgArray[x,y])

I looked at the value of ImgArray[x,y] and it shows as being o (zero) for the first element (which is correct). But for some reason it is being detected as an array instead of an int. So the typecast seems to make it work. I'm not sure if there will be other similar errors to this or not, I haven't explored around the dungeon area yet...I'll let you know if I find anything else.
October 13, 2009 1:03am - Scott Barlow - nickname: (spectre5)
Gives an assertion error:

assert type(colorValue) == type(1)
AssertionError

I'll try looking into it a little more when I have some more time tomorrow or the next day.
October 13, 2009 12:38am - David Hahn - nickname: (hahn)
Heh, yeah, I just wrote out what numpy shorthands is all. A bit trickier than I was expecting, too...

And now that one is a strange error, as ImgArray[x,y] is definitely an int, and the value from ImgArray2[x,y] is also an int, which means something's getting crossed up somewhere and is trying to hash out the array itself...

I guess you could try replacing that entire block inside those 2 for loops with something more blatant:

colorValue = ImgArray[x,y]
assert type(colorValue) == type(1)
tileFromColor = Colors[colorValue]
assert type(tileFromColor)==type(1)
ImgArray2[x,y] = tileFromColor

Not sure if that'd fix it, but at least it would rule out potential type errors...hopefully. Also, python has assert statements. Shiny.
October 12, 2009 8:37pm - Scott Barlow - nickname: (spectre5)
I wondered around town a bit and everything seems to be OK...however, when I went into the dungeon (top left), I now get this error...

Traceback (most recent call last):
File "Start.py", line 7, in <module>
Play.Main()
File "code/Play.py", line 87, in Main
gameMap.filterKeys(event.key)
File "code/Scene.py", line 183, in filterKeys
self.Player.attemptmove(keypress,self)
File "code/Player.py", line 102, in attemptmove
Scene.Map.CreateDungeon()#[fix] rename to makeDungeon()
File "code/Map.py", line 335, in CreateDungeon
self.maparray = self.PullPixelArrayXY(NewSurf)
File "code/Map.py", line 177, in PullPixelArrayXY
ImgArray2[x,y] = Colors[ImgArray[x,y]]
TypeError: unhashable type: 'array'


Obviously another numpy problem...perhaps I need to look into the 64 bit numpy problem more...
October 12, 2009 8:06pm - Scott Barlow - nickname: (spectre5)
Oh, I just looked at the code and saw, so nevermind :)
Just had to take the longer road. Cool - I'm looking forward to playing around with this a little bit now (when/if I get some free time).
October 12, 2009 8:05pm - Scott Barlow - nickname: (spectre5)
Ahh...and the new version you uploaded seems to have fixed the problem. I guess the problem was with the 64 bit version with your old method. What all did you change to make it work - for my own knowledge :)
October 12, 2009 8:03pm - Scott Barlow - nickname: (spectre5)
No edit, nor delete - these are such simple things to implement too :)

Ok...here is the output I get from that first test (the one posted at 3:10pm):
This hasn't crashed yet has it?
1

So it seems that numpy is working OK.

I DO have a 64 bit processor, and I have python/numpy/pygame/etc all from the ubuntu repos which should all be 64 bit version, as available. Since that code did not crash, I did not run that code from 3:21pm.

I'll try out the new version that you uploaded in a moment...
October 10, 2009 4:36pm - David Hahn - nickname: (hahn)
Alright well either way, I've uploaded a new "version" that will switch the to a different way of calling scale2x if you aren't on 32bit just in case. I'm not going to add another release to this site, but I just reuploaded it on the google sites page. Say if any of that works or not!
October 10, 2009 3:22pm - David Hahn - nickname: (hahn)
...with the spaces instead of dashes, rather. There isn't an edit button here either? :(
October 10, 2009 3:21pm - David Hahn - nickname: (hahn)
Oh, and if that code snippet DOES crash on you, would you like to be a guinea pig and test out this code for me?

import numpy as n
first = n.zeros((72,72),dtype=int)
second = n.ones((144,144),dtype=int)
for x in range(72):
--for y in range(72):
----first[x,y] = second[x,y]
if True:
--print "this is functionally equivalent."

with the dashes instead of spaces. If that doesn't crash, then I can forsee a .8C coming up soon. If not...back to the drawing board.
October 10, 2009 3:10pm - David Hahn - nickname: (hahn)
The Surfarray is basically just a numpy array of integer values--IE a matrix, in terms of how I'm using it.

And yeah, what I wanted to see was if numpy was returning the right shape, and numpy uses obj.shape to return a tuple giving the dimensions of either matrix, which looks right. Had a bit of a brain fart in that it's obj.shape, not obj.size, though.

So I take it it still crashes then? Hrm.

Are you using a 64 bit version/OS or 32 bit? Some quick googling shows me that numpy apparently has issues with the 64 bit, at least in terms of that error.

Also, if you could, try to make a new .py file, and put in these lines into it and run it, and tell me if it gives you the same error:

import numpy as n
first = n.zeros((72,72),dtype=int)
second = n.ones((144,144),dtype=int)
first[:] = second[:72,:72]
print "This hasn't crashed yet has it?"
print first[0,0]

if it the above gives you an error, then that at least narrows it down to a glitch in numpy itself.

Also, if you want, go into code/Text.py and comment out the line that says "self.scale2x()" (in the makeMinimap function), and you'll get a horribly broken minimap, but the offending function that seems to freak out won't be called. I don't think I use the "surf[:] = .." type of command elsewhere, which means that should at least get things running for you.
October 10, 2009 3:35am - Scott Barlow - nickname: (spectre5)
Perhaps I should also mention that I'm running python 2.6 and pygame 1.8.1
October 10, 2009 3:31am - Scott Barlow - nickname: (spectre5)
I wish pygame offered a system on this site to notify you when there are responses to threads you've posted on (or let you subscribe to threads)...It doesn't even give you an email to let you know someone posted a comment on your own project (at least not mine)!

Anyways, I'm not very familiar with using the surfarray, but here is what I get when running your corrected command (looks good):
<type 'array'> <type 'array'> (72, 72) (144, 144)

If I run the first one you posted, it fails...so it seems to fail when trying to access .size for some reason. I.E. with this:
print type(smallgrid), type(self.minimap_surfarray), smallgrid.size, self.minimap_surfarray.size
I get the following error:
print type(smallgrid), type(self.minimap_surfarray), smallgrid.size, self.minimap_surfarray.size
AttributeError: size

I run Linux (Ubuntu 9.04) and my numpy is the latest in the repos (looks like that is 1.2.1).
October 10, 2009 2:18am - David Hahn - nickname: (hahn)
Err, that line should be

print type(smallgrid), type(self.minimap_surfarray), smallgrid.shape, self.minimap_surfarray.shape


D'oh, sorry about that one.
October 10, 2009 2:17am - David Hahn - nickname: (hahn)
Ack, sorry for the late response, but in case if you're seeing this...What versions of numpy et al do you have? Also are you on Windows, Linux, or something else?

That particular line is taking a 70x70 matrix (called smallgrid), and is setting each of its values as the first 70 entires in minimap_surfarray, which I think should work regardless of the case...

If you don't mind/are still here, could you go into /code/Text.py, find the smallgrid[:]=... line (ctrl F it, it only occurs once), and directly before that insert this line:
"
print type(smallgrid), type(self.minimap_surfarray), smallgrid.size, self.minimap_surfarray.size
"

sans the quotes / with proper indenting and tell me what it prints out?

Also I'm just about to upload a newer version with some quick fixes that ends up altering that line in particular (though I don't think it'll fix your issue.. ); let me know if it changes anything.
October 4, 2009 10:22pm - Scott Barlow - nickname: (spectre5)
When I run this, it opens the main screen, but when I press "s" to start the game, I get this:

Traceback (most recent call last):
File "Start.py", line 7, in <module>
Play.Main()
File "code/Play.py", line 49, in Main
gameMap = Scene.Scene()
File "code/Scene.py", line 27, in __init__
self.createTextWindow()
File "code/Scene.py", line 30, in createTextWindow
self.GUI = Text.TextHandler(12,"LiberationSans-Regular.ttf",self.Map.maparray,[(self.Player.worldx,self.Player.worldy,4)])
File "code/Text.py", line 41, in __init__
self.makeMiniMap(maparray,[])
File "code/Text.py", line 98, in makeMiniMap
self.scale2x()
File "code/Text.py", line 123, in scale2x
smallgrid[:] = self.minimap_surfarray[:70,:70]
ValueError: matrices are not aligned for copy
August 4, 2009 3:31pm - David Hahn - nickname: (hahn)
Yeah, sorry about that. I've been meaning to get some form of custom keybinding in the game, it should be in by the next time I update the code.
August 4, 2009 5:48am - benedict carter - nickname: (benedict)
looks good, but cant play (without modification) as im on a laptop and i dont have numpad keys...
spotlight

 
our projects
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
 
recent releases
Sep 29, 2014

Sep 19, 2014

Sep 17, 2014

Sep 9, 2014

Sep 8, 2014

Sep 7, 2014


Sep 5, 2014

Aug 26, 2014

Aug 21, 2014


Aug 18, 2014

... more!
 
for pygame related questions, comments, and suggestions, please see help (lists, irc)