[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Re: need help



could some one please make a VERY SHORT GAME, using the code i have as a background and character. All I want to happen is for the character to move left right up or down on the screen when the appropitate button is pushed, via the up down left and right keys. Also, PLEASE PLEASE PLEASE break it down step by step and exlplain to me EVERRRRRRRRRYYYYYTTTTHHHHIIIINNNNGGGG that is happening. EXSPECIALLY KEYS AND VALUES!!! Please explain this very clearly for this is my first day of using pygame, although i have been using python for some time now. I am very confused with pygame. I intend to use this example to make games using this example. Here is the code:
well charnel637, you win the prize for "flaming AOL post" on the pygame mailing list. strangely, i'm in a silly enough mood to send you an answer. from here i suggest taking a look through the examples that come with pygame (or with the pygame-docs package if using the windows binaries, http://pygame.org/ftp/pygame-docs-1.5.5.exe )



##here is the start of your code..

import os, pygame
screen=pygame.display.set_mode((800, 600))
background=pygame.image.load('C:\\WINDOWS\\Desktop\\background.bmp').convert()

screen.blit(background, (0,0))
player=pygame.image.load('C:\\WINDOWS\\Desktop\\player.png').convert()


##here is what you need to finish..

pygame.display.update()
position = player.get_rect().move(300, 200)

#game needs to run in a loop that runs forever
while 1:
move = 0

#we need to get the input from windows and keyboard
for e in pygame.event.get():
if e.type==pygame.QUIT: raise SystemExit
elif e.type==pygame.KEYDOWN:
if e.key == pygame.K_ESCAPE: raise SystemExit
elif e.key == pygame.K_LEFT: move -= 5
elif e.key == pygame.K_RIGHT: move = 5

#first we 'erase' the old player
screen.blit(background, position, position)

#now we 'move' the player position
position.left += move

#now we 'draw' the player
screen.blit(player, position)

#now we update the entire screen buffer
pygame.display.update()

#that's it, end of program


now go read some of the pygame tuturials for more information
http://pygame.org/docs/tut/MoveIt.html
http://pygame.org/docs/tut/ChimpLineByLine.html
http://pygame.org/docs/tut/newbieguide.html



--- Begin Message ---
>From owner-pygame-users@seul.org  Wed Feb  5 21:31:05 2003
Return-Path: <owner-pygame-users@seul.org>
Delivered-To: pygame-users@seul.org
Received: from imo-r04.mx.aol.com (imo-r04.mx.aol.com [152.163.225.100])
	by moria.seul.org (Postfix) with ESMTP id 5DD9733E4B
	for <pygame-users@seul.org>; Wed,  5 Feb 2003 21:31:05 -0500 (EST)
Received: from Charnel637@aol.com
	by imo-r04.mx.aol.com (mail_out_v34.21.) id c.84.93182c1 (17079)
	 for <pygame-users@seul.org>; Wed, 5 Feb 2003 21:30:54 -0500 (EST)
From: Charnel637@aol.com
Message-ID: <84.93182c1.2b7322de@aol.com>
Date: Wed, 5 Feb 2003 21:30:54 EST
Subject: need help
To: pygame-users@seul.org
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="part1_84.93182c1.2b7322de_boundary"
X-Mailer: AOL 8.0 for Windows US sub 234


--part1_84.93182c1.2b7322de_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

could some one please make a VERY SHORT GAME, using the code i have as a 
background and character. All I want to happen is for the character to move 
left right up or down on the screen when the appropitate button is pushed, 
via the up down left and right keys. Also, PLEASE PLEASE PLEASE break it down 
step by step and exlplain to me EVERRRRRRRRRYYYYYTTTTHHHHIIIINNNNGGGG that is 
happening. EXSPECIALLY KEYS AND VALUES!!! Please explain this very clearly 
for this is my first day of using pygame, although i have been using python 
for some time now. I am very confused with pygame. I intend to use this 
example to make games using this example. Here is the code:

import os, pygame
screen=pygame.display.set_mode((800, 600))
background=pygame.image.load('C:\\WINDOWS\\Desktop\\background.bmp').convert()

screen.blit(background, (0,0))
player=pygame.image.load('C:\\WINDOWS\\Desktop\\player.png').convert()


Thnx.

--part1_84.93182c1.2b7322de_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=
=3D"Arial" LANG=3D"0">could some one please make a VERY SHORT GAME, using th=
e code i have as a background and character. All I want to happen is for the=
 character to move left right up or down on the screen when the appropitate=20=
button is pushed, via the up down left and right keys. Also, PLEASE PLEASE P=
LEASE break it down step by step and exlplain to me EVERRRRRRRRRYYYYYTTTTHHH=
HIIIINNNNGGGG that is happening. EXSPECIALLY KEYS AND VALUES!!! Please expla=
in this very clearly for this is my first day of using pygame, although i ha=
ve been using python for some time now. I am very confused with pygame. I in=
tend to use this example to make games using this example. Here is the code:=
<BR>
<BR>
import os, pygame<BR>
screen=3Dpygame.display.set_mode((800, 600))<BR>
background=3Dpygame.image.load('C:\\WINDOWS\\Desktop\\background.bmp').conve=
rt()<BR>
screen.blit(background, (0,0))<BR>
player=3Dpygame.image.load('C:\\WINDOWS\\Desktop\\player.png').convert()<BR>
<BR>
<BR>
Thnx.</FONT></HTML>

--part1_84.93182c1.2b7322de_boundary--



--- End Message ---