Pygame is a portable Python package for video games, built on SDL.
2
votes
1answer
53 views
Any tips on speeding up this sandbox game?
I am working on an app: a virtual sandbox of sorts, a lot like the powder game.
The problem is, when working with an app, you must deal with hardware limitations. Don't get me wrong, the speed isn't ...
0
votes
0answers
11 views
Why is this error being thrown? (Python 3, Pygame) [migrated]
In my game, pertinent code found here, and also at the end of this post, this error is being thrown when evaluating:
Traceback (most recent call last):
File ...
4
votes
2answers
109 views
How can I shorten this paint program?
I am currently in a challenge with my buddy to see who can code a simple paint program in the least lines. The only requirement, is that the program must include an eraser. How can I possibly shorten ...
1
vote
3answers
161 views
How to make this SimCity clone more efficient?
I am doing my best to keep this code clean and fast, but as I add more to the game, it seems to get harder to maintain a frame-rate higher than 200!
The game is essentially a SimCity clone. I ...
1
vote
0answers
84 views
How can I make this SimCity clone faster?
I am working on a SimCity clone, and I am noticing a drop in frame rate as I add more objects to my map, now this is expected, but, when I fill the whole screen, the game maintains about 300 fps.
...
1
vote
1answer
116 views
Basic Pong game in Pygame
I have just wrote this Pong game in Pygame:
import pygame
import sys
import math
class Ball(object):
def __init__(self, x, y, width, height, vx, vy, colour):
self.x = x
self.y = ...
0
votes
1answer
49 views
Pygame using a dict to store objects instead of an array?
In my pygame game, I build a level by adding a bunch platform objects to an array called instancelist. Then pygame tests for each instance in instancelist and blits it's sprite over it's rect ...
0
votes
1answer
80 views
Pygame snap mouse to grid?
The game I am working with is a block game. It generates terrain and then allows you to freely mine and place blocks as you wish (sound familiar Cx) BUT! there is a problem. I have a code that snaps ...
3
votes
1answer
86 views
Making a Pygame game faster?
In my game, there is a terrain generator subsequently resulting in many instances. I have implemented this code:
for b in blocklist:
if b.rect.left>=0:
if b.rect.right<=640:
...
2
votes
1answer
112 views
Object Composition
So I have this Pygame 3.3.2 code of 2 classes. I tried to make it as simpler as possible, but ofcourse to show the problems I have with thedesign.
import pygame
import sys
class MainWindow(object):
...
1
vote
1answer
77 views
Text class: is this good?
Failing to get a solution to my problem from other people, I got tired of waiting and wrote this (rather rushed) Text class to deal with the text problems I've been having in Pygame. I wanted the text ...
6
votes
1answer
928 views
What about my Pong game?
Just looking for some pointers on how I could improve the code. This is my first game ever and python is my first language so it's bit messy but I'll be happy to explain stuff if needed. I'm kinda ...
1
vote
2answers
80 views
In this script what can I turn into funtions and how can I go about doing it?
I have just made a simple script which spawns an alien that chases the player, but I want to move as much of the script into funtions so as to minimize the amount of code, to make it run better when ...
2
votes
1answer
1k views
Text-based adventure RPG inventory code
I am trying to make a text-based RPG in Python and Pygame. I need a way to manage my inventory slots. Currently, I have no way to find out what is currently equipped. I can only overwrite it, even ...
1
vote
1answer
204 views
GUI system in PyGame
I'm making a GUI system in Python for game development with PyGame. Right now I have a button that changes colors when you hover and click on it. My question is, is this code well designed or can it ...
2
votes
1answer
3k views
Snake game — made with Python
I wrote a simple Python snake game, it's about 250 lines of code. Can someone give me some advice on how to refactor/make it better?
game.py
# game.py - 3/22/2013
import pygame, sys, os
from ...
2
votes
2answers
151 views
Pong game in Python
I'm writing a pong game in Python and I created classes for the game objects.
The top level class is Object, and Ball and Paddle inherit from it. And ComputerPaddle is a child class of Paddle.
# ...
8
votes
1answer
769 views
A small Bejeweled-like game in Pygame
I would really appreciate a review of my first game. It is a Bejeweled-like game written in Python with Pygame:
import pygame, random, time, sys
from pygame.locals import *
pygame.init()
NUM_SHAPES ...