[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Creating surfaces
- To: Pygame Mailing List <pygame-users@xxxxxxxx>
- Subject: [pygame] Creating surfaces
- From: éæå <onpon4@xxxxxxxxx>
- Date: Mon, 14 Jun 2010 19:44:35 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 14 Jun 2010 19:44:54 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=3PwZYrwnYT6zzW0cs68OkyLdlMT5/FlU35+Y/4Q0DM8=; b=sDJoxmyOmisHJwd/V+HsMp2+K4amG3+i7KwpDbOUvodu8AviaLGA4R/tFoluP42uHS gYsT+V1zHHdcZnv+IlTPZYbKQSMQ7Amlb9iJSIsv/QdLyHGSMAmBVAdhoAr1f9JjYjby Ir0X6o7qyBqO/5gbNhIOmmYfEcX6dwW8CfbX8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=h96J+pCDppuw3dt1hSC77seSbLaZgbEjk2ZlSBv1zsHfN23JSj+orR5sjvKjvMggOi eGkdVuzxRWRSXcVBHHSvCk64vRoRo2+ewk0YTz4AhGQmKlKjywxzwzdHsdVrPnmMlRTd FHzvA/fs6cM+AHEb3aW6IdPtsH8c6K5UDZYIE=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
This is my first game in Pygame, so I understand if this is something stupid that I'm overlooking.
In my class named Player, I have the following lines (lines 93-99) in the __init__ method which is intended to dynamically create the image used for the player object:
self.sprite = pygame.Surface(size[0]+gunsize[0],max(size[1],gunsize[1])).convert()
pygame.draw.rect(self.sprite, color, ((0,0),size))
pygame.draw.polygon(self.sprite, color, \
[(size[0],(size[1]//2)-(gunsize[1]//2)), \
(size[0],(size[1]//2)+(gunsize[1]//2)), \
(size[0]+gunsize[0],size[1]//2)])
pygame.transform.flip(self.sprite, flip, 0)
To test if this works, I created an instance of class Player to display on the screen here (lines 54-55):
self.p1 = Player(0,0,(100,100),lncolor,0,(8,64),(16,8))
self.sprites.append(self.p1)
The line giving me trouble right now is the first one I listed above:
self.sprite =
pygame.Surface(size[0]+gunsize[0],max(size[1],gunsize[1])).convert()
Which results in the following output:
Traceback (most recent call last):
File "C:\Users\Jaychant\Documents\Games\senso.py", line 111, in <module>
game = Game((640,480), (0,0,0), (0,200,0))
File "C:\Users\Jaychant\Documents\Games\senso.py", line 54, in __init__
self.p1 = Player(0,0,(100,100),lncolor,0,(8,64),(16,8))
File "C:\Users\Jaychant\Documents\Games\senso.py", line 93, in __init__
self.sprite = pygame.Surface(size[0]+gunsize[0],max(size[1],gunsize[1])).convert()
ValueError: size needs to be (int width, int height)
Here is what the important variables end up being:
size: (8,64)
gunsize: (16,8)
What I gather from this is that I'm not specifying an integer where I should be. But I've checked the arguments; The first becomes 8+16=24, while the second becomes 64.
Can anyone see what's wrong? Am I misinterpreting the error?
I have attached the entire file to this Email, in case it is needed.
Cheers,
onpon4
Attachment:
senso.py
Description: Binary data