Questions tagged [pygame-surface]

pygame object for representing images. Use this tag only if you are using the pygame library and not if you have a question about programming a game in python in general.

The most important part of pygame is the surface. Just think of a surface as a blank piece of paper. You can do a lot of things with a surface – you can draw lines on it, fill parts of it with color, copy images to and from it, and set or read individual pixel colors on it. A surface can be any size (within reason) and you can have as many of them as you like (again, within reason). One surface is special – the one you create with pygame.display.set_mode(). This ‘display surface’ represents the screen; whatever you do to it will appear on the user’s screen. You can only have one of these – that’s an SDL limitation, not a pygame one.

Home Page: http://www.pygame.org/docs/ref/surface.html

609 questions
0
votes
2 answers

Pygame: AttributeError: 'pygame.Surface' object has no attribute 'display'

Code: import pygame, sys, os from pygame.locals import * red = (255,0,0) pygame.init() window = pygame.display.set_mode((1000,600)) pygame.display.set_caption('Slither.eat - The Snake Game') screen =…
0
votes
1 answer

why does my pygame war code show up with an error

import random from time import sleep import…
0
votes
1 answer

How to program a collision

I want to code a collision. I have 2 classes and if they collide one of them should undraw for 1 second #Laden der Pygame Bibliothek import pygame import time import random #Initialisierung der Pygame Bibliothek pygame.init() # Spiel-Fenster…
user13118131
0
votes
1 answer

[Pygame]: Move surface towards position

Is there an algorithm to change a set of coordinates to make it move towards another set of coordinates? Like, if I have ax,ay=(20,30) a #fonctions import pygame, sys from pygame.locals import * pygame.init() fpsClock =…
0
votes
1 answer

Using class functions and handling data externally - PyGame

Just a small question. I have a class that does something and handles strings. I have an active class that has a button which when pressed closes the screen and deactivates the class at the same time. I would like the class to return the strings it…
JayRoy
  • 105
  • 6
0
votes
1 answer

Why does my game made with Pygame suddenly lag for a few seconds?

I made a little space invaders game with pygame, I noticed that the game lags for a few seconds periodically. I do not know what the problem is. I am a beginner. Can you tell me why this happens? Is there any fix to this? Also, why does everything…
Mush-A
  • 435
  • 3
  • 11
0
votes
0 answers

Image could not be opened through Pygame's Image.load()

My pygame program does not seems to load images. I tried image.load() by directly entering the image path as well by joining directories. I tried the code on Sublime Text as well as IDLE. File Source:…
0
votes
1 answer

Is there a way to delete Pygame Surfaces? Or any way to remove them from memory to increase performance?

I blit surfaces in my pygame file but the problem is they just stay there. My (hopefully temporary) solution was to just move them far off the window when they aren't in use (i.e. (-5000,0) ), but this decreases performance every time I blit a new…
Scott
  • 105
  • 1
  • 8
0
votes
0 answers

Is there away to solve this pygame platform problem?

I am currently working on a small project, which is a platform type game. I had designed the platform sets, in which the player has the ability to jump on the platform and stay on it and can jump of it. However when the player decides to jump off…
0
votes
0 answers

Pygame draw a surface within a circle

I've been trying to figure out how to draw a texture within a circle with no luck. For example, I have a red colored polygon that I drew on a surface called surf using pg.draw.polygon. Now I want to crop that surface into a circle (see images…
GSR
  • 49
  • 3
0
votes
1 answer

How do I stop a sprite from moving once it is killed

I am trying to make a game in pygame for a com sci project. The layout is extremely similar to Galaga or any other top down shooter type arcade game. The problem I have right now is that once a sprite is killed, the sprite still moves. I want to…
0
votes
1 answer

Pygame screen output not displaying

I'm working on a game project with Pygame. I'm only just beginning to work on the project and I'm kind of stuck. I have made three files each containing code to perform different functions. The first file - "alien_apocalypse.py"contains the class…
Jon Fillip
  • 101
  • 3
  • 10
0
votes
1 answer

Create a lightning in pygame

I'm trying to create a lightning in my app. I did this so far import pygame import random as rd import copy pygame.init() color = 250,250,250 starting_point =0,0 ending_point = 400,400 a = [[400,0]] depth = rd.randrange(50,80) for i in…
aranour
  • 13
  • 4
0
votes
1 answer

How can I change this surface image to the image I want in pygame?

# Memory V2 # The second version contains the complete tile grid and the black panel on the right, there is score in the black panel. All 8 pairs of two tiles are covered by question mark when the game starts . Each time the game is played, the…
0
votes
1 answer

Cant add images to pygame

I tried making a simple game, but every time I try to run the code I get an error in the images location. Python can't find it. I tried putting the images in the desktop, or even using "import os", but neither work. How can I make Python identify…