Showing posts with label game quit no request event. Show all posts
Showing posts with label game quit no request event. Show all posts

Saturday, April 26, 2014

Help with a Pygame game?







I am making a fishing game in Pygame. However, I keep getting an error: The screen and background loads, but the rest doesn't. Here is the code (Please do not publish this I am actually doing it as a pay for request):

# PyFishing
# Version: Alpha
# (c) 2010
# By Gio Di Russo

try:
import os, sys
import pygame
from pygame.locals import *
except ImportError, err:
print "couldn't load module. %s" % (err)
sys.exit(2)
salmoncaught = 0
class Rod(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = pygame.image.load('Rod.bmp')
self.reeling = 0
def update(self):
pos = pygame.mouse.get_pos()
self.rect.midtop = pos
def reel(self, target):
if not self.reeling:
self.reeling = 1
hitbox = self.rect.inflate(0, 0)
return hitbox.colliderect(target.rect)
def unreel(self):
self.reeling = 0
class Salmon(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load('Fishshadow.bmp')
self.caught = 0
def update(self):
if self.caught:
salmoncaught + 1
self.contents.clear()
else:
self.swim()
def swim(self):
self.caught = 0
def reeled(self):
if not self.caught:
self.caught = 1
class Finish_Button(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = pygame.image.load('Finish.bmp')
self.area = screen.get_rect()
self.pushed = 0
def update(self):
if self.pushed:
if pygame.font:
font = pygame.font.Font(None, 36)
text = font.render("You caught:", salmoncaught, "salmon", 1, (10, 10, 10))
textpos = text.get_rect(centerx=background.get_width()/2)
background.blit(text, textpos)
def push(self):
self.pushed = 1
pygame.init()
screen = pygame.display.set_mode((500, 500))
pygame.display.set_caption('PyFishing by Gio Di Russo')
pygame.mouse.set_visible(0)
background = pygame.image.load('Background1.bmp')
screen.blit(background, (0, 0))
pygame.display.flip()
Rod = Rod()
Salmon = Salmon()
Finish_Button = Finish_Button()
allsprites = pygame.sprite.RenderPlain ((Salmon, Rod, Finish_Button))
clock = pygame.time.Clock()
while 1:
clock.tick(60)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
elif event.type == MOUSEBUTTONDOWN:
if Rod.reel(Salmon):
Salmon.reeled()
elif Rod.reel(Finish_Button):
Finish_Button.push()
elif event.type == MOUSEBUTTONUP:
Rod.unreel()
allsprites.update()
screen.blit(background, (0, 0))
allsprites.draw(screen)
pygame.display.flip()

And here is the error message IDLE gives me (on IDLE, not as a Pop-Up):

Traceback (most recent call last):
File "C:\Documents and Settings\Gio\My Documents\Python Programs\2D and 3D games\PyFishing.py", line 67, in <module>
Rod = Rod()
File "C:\Documents and Settings\Gio\My Documents\Python Programs\2D and 3D games\PyFishing.py", line 17, in __init__
self.image, self.rect = pygame.image.load('Rod.bmp')
TypeError: 'pygame.Surface' object is not iterable

NOTE: I cannot pass this error because it makes the images load incorecctly!!
I didnt show the indents becuase I already know they're correct.
I fixed the first problem but now theres another:
message:

Traceback (most recent call last):
File "C:\Documents and Settings\Gio\My Documents\Python Programs\2D and 3D games\PyFishing.py", line 66, in <module>
screen.blit(background, (0, 0))
TypeError: argument 1 must be pygame.Surface, not tuple

I didn't change the background lines in any way from the code listed above.

Also, this is wierd, becuase it works on other people's games.



Answer
The line Rod = Rod() is giving you trouble because Rod (with a capital R) is the name of a class. You can't have an instance variable with the same name as the class name.
rod = Rod() would work, because rod (lowercase r) is a different identifier than Rod (uppercase)

Also, the pygame,image.load() method returns only one object, a surface. I don't think you can extract both the image surface and the rect at the same time.

Try this:

self.image = pygame.image.load("Rod.bmp")
self.rect = self.image.get_rect()

I have a simple clean sprite example available here
http://www.aharrisbooks.net/pythonGame/ch06/basicSprite.py

Please see my web site for many more details. I also have free links to the video of my online class on game programming in Python.

PS When posting Python code in the future, please submit the actual code to a site like pastebin.com and provide a link. The indentation in Python is too important, and frankly, I never believe anybody that the indentation is right. (even myself.) If you want people to run your code and check it, provide a properly indented version. I can't check to be sure my answer is correct because I'm not going to take the 20 minutes to get the indentation right.

Hope this helps.....

Why did people deactivate their Facebook account?

Q. Is there any particular reason or incident that influence you to deactivate/delete your account? Do you feel some pressure to continue to use Facebook?
Do you feel Facebook invades your privacy? What kind of stress you face when using Facebook? Are they the reasons of deactivating Facebook account?


Answer
Reasons people deactivate:
- Excessive game requests
- Exam revision
- Game addiction
- They realise their lives have been taken over my facebook
- They want to figure out who their real friends are i.e. those that take the effort to contact them not via facebook
- They want to quit stalking people

Reasons people delete;
- They find something better
- They don't want the world to know their business anymore
- They're sick of facebook

I do feel pressure to continue to use facebook, in a way I feel that if I didn't have facebook I wouldn't really have much contact with friends or know about social events or even the news!




Powered by Yahoo! Answers

Read More... “Help with a Pygame game?”  »»

Tuesday, November 5, 2013

Why did people deactivate their Facebook account?

game quit no request event
 on ... win in life never quits no matter the ferocity of the attacks or the
game quit no request event image




Mahbubul


Is there any particular reason or incident that influence you to deactivate/delete your account? Do you feel some pressure to continue to use Facebook?
Do you feel Facebook invades your privacy? What kind of stress you face when using Facebook? Are they the reasons of deactivating Facebook account?



Answer
Reasons people deactivate:
- Excessive game requests
- Exam revision
- Game addiction
- They realise their lives have been taken over my facebook
- They want to figure out who their real friends are i.e. those that take the effort to contact them not via facebook
- They want to quit stalking people

Reasons people delete;
- They find something better
- They don't want the world to know their business anymore
- They're sick of facebook

I do feel pressure to continue to use facebook, in a way I feel that if I didn't have facebook I wouldn't really have much contact with friends or know about social events or even the news!

Is it true that Lupul is a big party guy?




Canes12


I've heard this and seen the alcohol bill in May, but that was once. Is he a known, regular party guy, clubbing always drinking and such or is it rare? Does he smoke, cause I know it wouldn't be too good for his career. And is he known for constantly sleeping around like Paul Bisonnette is, or is he one of the "good guys". He looks more like one of the "good guys" to me, for some reason.
I'm doing a project and this information is relevant. Thanks.



Answer
Lupul is a very social guy, he always goes to other sporting events (espically baseball and basketball games), and he often goes to dinner frequently with Kessel/Bozak off ice. Yes, he likes to consume alchol, but I wouldn't say he's anywhere near an alcholic nor is he a crazy wild guy off the ice, just a regular person.

If you want to know someone who has a horrendous reputation for drinking it's Jeff Carter- His partying lifestyle has gotten so bad that every coach in the NHL he has played for has requested that he quit consuming alochol. Also, the reason he got traded to Columbus was because his off ice drinking habits were effecting his on ice play and the team.

Lupul is just a fun loving guy, but he knows his limits as well.




Powered by Yahoo! Answers

Read More... “Why did people deactivate their Facebook account?”  »»
Camera Info by - ryanita Edited By Autocar