Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2011, 05:24 AM   PM User | #1
nickwow100
New to the CF scene

 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
nickwow100 is an unknown quantity at this point
Exclamation how to stop an animation and get user input

This is my first game and was wondering how I should get a user input to stop the program from running through, down at the bottom. When I run the bottom part of the program it goes so fast I can barely see it. After where the first pygame.display.update() is where my problem occurs.
[CODE]
bif="back.jpg"
mif="cursor.png"
tif="title.jpg"
rif="redrion.png"
lif="MainLogo.png"
btlgrdif="battleground.jpg"
gcif="greycoat.png"
bcif="bluecoat.png"
blt1if="bullet 1.png"
blt2if="bullet 2.png"
infoif="info.jpg"
unionvicif="unionvic.png"

import pygame, sys
from pygame.locals import *

pygame.init()
screen=pygame.display.set_mode((1152,648),0,32)
backround=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(mif).convert_alpha()
title=pygame.image.load(tif).convert()
redrion=pygame.image.load(rif).convert()
logo=pygame.image.load(lif).convert()
btlgrd=pygame.image.load(btlgrdif).convert()
greyct=pygame.image.load(gcif).convert()
bluect=pygame.image.load(bcif).convert()
bulet1=pygame.image.load(blt1if).convert()
bulet2=pygame.image.load(blt2if).convert()
info=pygame.image.load(infoif).convert()
unionvic=pygame.image.load(unionvicif).convert()

a=120
b=1050
color2=(115,160,5)
color1=(0,0,0)
pos1=(500,150)
pos2=(1000,150)
color=(26,63,99)
rectangle=(40,30,400,600)

while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.blit(backround, (0,0))
screen.blit(title, (500,130))
screen.blit(redrion, (950,600))
screen.blit(logo, (1120,620))
screen.lock()
pygame.draw.rect(screen, color, rectangle)
pygame.draw.line(screen, color1, pos1, pos2, 10)
screen.unlock()


x,y = pygame.mouse.get_pos()
x -= mouse_c.get_width()/2
y -= mouse_c.get_height()/2

screen.blit(mouse_c, (x,y))


pygame.display.update()

for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_g:
screen.blit(btlgrd, (0,0))
screen.blit(bluect, (30,441))
screen.blit(greyct, (1042,441))
screen.blit(bulet1, (a,502))
screen.blit(bulet2, (b,502))
a+=1
b-=1
if a>1050:
a=120
if b<120:
b=1050
screen.lock()
if event.key == K_r:
screen.blit(unionvic, (400,100))
if event.key == K_q:
screen.lock()
screen.unlock()

pygame.display.update()
[CODE]
nickwow100 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45 AM.


Advertisement
Log in to turn off these ads.