Recent Forum Posts
From categories:
page 1123...next »
Garrett (guest) 06 Jan 2017 23:52
in discussion Hidden / Per page discussions » Drawing on the screen

Wonderful tut for game programmers who are new to python!

by Garrett (guest), 06 Jan 2017 23:52
Jakey (guest) 29 Aug 2016 20:13
in discussion Hidden / Per page discussions » Tutorials Basic

I am not getting past first base and it is pathethic. I have installed Python and Pygame on three different PCs and every installation of Python fails to find Pygame. Entering "import pygame" returns "ImportError: DLL load failed: The specified module could not be found." I have consulted a dozen tutorials and none say anymore than just installing these two packages is needed. What am I missing??

by Jakey (guest), 29 Aug 2016 20:13
Chance Watkins (guest) 28 Sep 2015 22:38
in discussion Hidden / Per page discussions » Drawing on the screen

Great tutorial. Thanks for sharing this with us; Jesus Christ Bless! :)

by Chance Watkins (guest), 28 Sep 2015 22:38
Chance Watkins (guest) 08 Sep 2015 23:34
in discussion Hidden / Per page discussions » Tutorials Basic

Great tutorial. Thanks for sharing this with us; Jesus Christ Bless! :)

by Chance Watkins (guest), 08 Sep 2015 23:34
Rivet (guest) 03 Aug 2015 02:01
in discussion Hidden / Per page discussions » Drawing on the screen

This is just explaining a general setup for pygame which is understandable if you're already familiar with python, which this tutorial assumes you are.

Also it's demonstrating an object oriented approach, your few lines of code would be fine but it will quickly become hard to manage the complexity of your game and add to it, meanwhile the object oriented approach has got his framework setup and can easily and quickly add content and features to the game.

by Rivet (guest), 03 Aug 2015 02:01
msid (guest) 19 Jun 2015 19:03
in discussion Hidden / Per page discussions » Tutorials Basic

awesome, got me started in few mins. Would love to see more explanations like adding text , images, controls to the window

by msid (guest), 19 Jun 2015 19:03
november (guest) 24 Dec 2014 01:42
in discussion Hidden / Per page discussions » Drawing on the screen

I agree with you; a lot of what this tutorial has in the script isn't explained. I do like the concept of using a class to have the game in, even though there is no real need for it. It's not like we need to make to games that are exactly the same in one script.

by november (guest), 24 Dec 2014 01:42

Hi, I've just started using Python/Pygame as a hobby. I've gotten the code to draw my Plane.png and move it using the wsad keys, and I mapped the q and e keys to rotate it which it does, but each time it rotates, it 'falls' down the screen to the bottom right and after a few key presses, disappears. I read that this is because when it turns the sprite, it adds padding to resize the image while it is turning. I think that each time it turns, it adds more padding, making it add exponentially for each keypress. I can't figure out how to stop this from happening. Any help for a beginner greatly appreciated! The Colours import is just a file where I keep my pre-defined colours for easier colour filling, and Plane.gif is an inch by inch and a half gif of a black plane with transparent background, and loads no problem, it just flies away when i use the e or q keys

-CODE-

import pygame, sys, time, random
from pygame.locals import *
from Colours import *
from PIL import Image, ImageDraw

class MySprite(pygame.sprite.Sprite):
def init(self):
pygame.sprite.Sprite.init(self)
self.image = pygame.image.load('Plane.gif').convert()
self.rect = self.image.get_rect()
self.x = 0
self.y = 0

def draw(self,surface):

surface.blit(self.image,(self.x,self.y))

def onKeyPress(self):

key = pygame.key.get_pressed()
distance = 5
if key[ord('s')] or key[pygame.K_DOWN]: #down
self.y += distance
elif key[ord('w')] or key[pygame.K_UP]: #up
self.y -= distance
if key[ord('d')] or key[pygame.K_RIGHT]: #right
self.x += distance
elif key[ord('a')] or key[pygame.K_LEFT]: #left
self.x -= distance

rotate = pygame.transform.rotate
if key[ord('e')]:
self.image = rotate(self.image, 10)
elif key[ord('q')]:
self.image = rotate(self.image, -10)

class Event(object):

def init(self):

for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()

pygame.init()

fps = 30
fpsClock = pygame.time.Clock()

size = width,height = 800,600
screen = pygame.display.set_mode(size)
mySprite = MySprite()

while True:

event = Event()
screen.fill(Blue)

mySprite.draw(screen)
mySprite.onKeyPress()

pygame.display.update()

fpsClock.tick(fps)

This is the code, hope you can help, thanks!

Rotating a sprite with pygame by najanaja (guest), 18 Nov 2014 17:11
jilin (guest) 07 Sep 2014 08:43
in discussion Hidden / Per page discussions » Drawing on the screen

It's a good tutorial. I've been reading a little on the pygame documents. Which is long and good. But here, it's what helps me to summarize what I've got till now.

by jilin (guest), 07 Sep 2014 08:43
Dash (guest) 26 Aug 2014 02:03
in discussion Hidden / Per page discussions » Tutorials Basic

When I ran that program, it came up with a message like this:
Traceback (most recent call last):
File "C:/Python27/For new programs for Ken/first pygame.py", line 1, in <module>
import pygame
File "C:\Python27\lib\site-packages\pygame\init.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: %1 is not a valid Win32 application.

by Dash (guest), 26 Aug 2014 02:03
tsh (guest) 06 Aug 2014 20:28
in discussion Hidden / Per page discussions » Drawing on the screen

nice tutorial, short and concise. Thank you.

by tsh (guest), 06 Aug 2014 20:28
Das (guest) 25 Jun 2014 05:46
in discussion Hidden / Per page discussions » Tutorials Basic

I think rather than having

if self.on_init() == None:
self._running = False

something efficient would be

try: self.on_init()
except: self._running = False

by Das (guest), 25 Jun 2014 05:46
Tigglesworth (guest) 02 Jun 2014 17:54
in discussion Hidden / Per page discussions » Drawing on the screen

If you want to load multiple images in a loop, you'll probably want to use a for loop to get the job done. If there's a specific set of different images you want in a specific order, you might want to try something like:

for i in range(number_of_images):
if i == 0:
image1 = pygame.image.load etc etc etc
if i == 1:
image2 = pygame etc etc etc

by Tigglesworth (guest), 02 Jun 2014 17:54
Tigglesworth (guest) 02 Jun 2014 17:51
in discussion Hidden / Per page discussions » Drawing on the screen

Even though this guy is a troll, he's right. This tutorial is really shitty, and not at all newbie-friendly. There's a lot of unnecessary and unexplained code. I remember in the first tutorial, something like "simple" screen rendering or whatever, where there were dozens of different functions and shit, none of which was explained in any coherent way. If you're wondering how to bring up a simple screen, it can be done in a few lines of code, and I'm not sure why this guy is bringing up all this garbage.

import pygame
screen = pygame.display.set_mode((640,400))
while True:
pass

That's literally all it takes.

by Tigglesworth (guest), 02 Jun 2014 17:51
Martyn (guest) 21 Apr 2014 17:00
in discussion Hidden / Per page discussions » Tutorials Basic

def on_init(self):
pygame.init()
self._display_surf = pygame.display.set_mode(self.size, pygame.HWSURFACE)
return self._display_surf

def on_execute(self):
if self.on_init() == None:
self._running = False

'The self._running = True' in on_init is completely redundant, as the class initialises it to True when the App object is instantiated in main anyway.

The above makes far more sense. If self._display_surf does not work, it will set self._running to False and won't execute the While loop in on_execute.

The reason on_init and init are not combined is probably for future code expansion. You might want to do other tasks via other methods before displaying the window. Change the window size, load sprites, etc.

by Martyn (guest), 21 Apr 2014 17:00
Dave (guest) 26 Mar 2014 18:01
in discussion Hidden / Per page discussions » Tutorials Basic

I was thinking that myself, also why have on_init and init? Why not just put everything in init and return false if the display cannot be created.

Dave.

by Dave (guest), 26 Mar 2014 18:01
Nellie (guest) 27 Feb 2014 14:16
in discussion Hidden / Per page discussions » Drawing on the screen

The code works. Wish you could have shown how to loop load different images too.
But cool. thanks.

by Nellie (guest), 27 Feb 2014 14:16
Dylan (guest) 12 Feb 2014 00:16
in discussion Hidden / Per page discussions » Event handling

This is a great tutorial. Really helped, thanks!

by Dylan (guest), 12 Feb 2014 00:16
arun (guest) 27 Jan 2014 03:02
in discussion Hidden / Per page discussions » Tutorials Basic

Hey,
i have a question…
on_init() does not have any return statement to return a value, so what value is being checked in
def on_execute(self):
if self.on_init() == False: ? Thanks for the tutorial too!

by arun (guest), 27 Jan 2014 03:02
George (guest) 19 Oct 2013 15:07
in discussion Hidden / Per page discussions » Drawing on the screen

^^ rabbit

by George (guest), 19 Oct 2013 15:07
page 1123...next »