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
1
vote
1 answer

How can I draw a list to the screen in pygame?

I'm writing a program that calculates some pixel stuff in an OpenGL shader. With that calculation, I get a list containing every pixel that needs to be written to the screen. Is there a way I can draw all of this data at once rather than iterating…
Matthew
  • 101
  • 2
  • 8
1
vote
1 answer

Pygame very low fps when drawing large image

I am writing some kind of image viewer in which the user can use a camera to pan/zoom on the images. The user needs to be able to zoom a lot to see details on high resolution images. When the images are small relative to the size of the application…
1
vote
0 answers

How i do to use multiple subsurfaces using Pygame

i'm trying to use subsurfaces of Pygame to draw multiple cartesian plans, each one with your shapes inside your space. At first, i call display method on init self.screen = pygame.display.set_mode((width, height)) self.screen.fill(Colors.WHITE) I…
1
vote
1 answer

AttributeError: 'pygame.mask.Mask' object has no attribute 'rect'

I am trying to get pixel perfect collision but I keep running into this error: Traceback (most recent call last): File "D:\Projects\games\venv\lib\site-packages\pygame\sprite.py", line 1528, in collide_circle xdistance = left.rect.centerx -…
RoSy8264
  • 49
  • 1
  • 8
1
vote
1 answer

How do I draw an object on the screen inside of a sprite class?

So I'm trying to draw a rectangle with another rectangle on top, using Sprites. I made a class for the player and did some basic setup, but when I tried to blit the second rectangle on top, it didn't work. I did some testing and found out that I…
Fleres
  • 13
  • 3
1
vote
1 answer

Pygame .rotate is making a surface grow rather than rotate

I'm trying to make a program generate graphs and I'm trying to make the square rotate just for something later on, but the squares are growing rather than rotating even though I'm using pygame.transform.rotate(). import pygame, json from…
1
vote
1 answer

How to fill shape white

Description Hi, I am trying to make objects to take damage and I want to add a cool effect. Problem When I type this command: player.img.fill((255, 255, 255)) I get this: and I want to get this: Thanks!
Pydude
  • 149
  • 13
1
vote
1 answer

How do I start a pygame app in maximized mode on Linux?

Before I start, this is not a duplicate of How do you start Pygame window maximized? I am on Linux which the win32gui and win32con libraries do not run on. What I'm trying to do as stated by the title is maximize my pygame window when it is run. I…
1
vote
1 answer

pygame window showing nothing on run

I am trying to make a game with pygame, but whenever I run my game, nothing shows up until I close the window, then stuff appears for a second. I don't know what is going on but I think is has to do with my display.update. Here is my code: import…
limegradient
  • 66
  • 10
1
vote
1 answer

is it possible to move an object diagonally in pygame?

im a beginner in python, and i just started to learn pygame. im making a drawing that draws a spirograph and moves the circles away from the center by each color group. What i mean is, since there are 7 colors, and each color has 5 circles, i want…
Ven
  • 31
  • 5
1
vote
1 answer

How can i give my image an initial position before it starts moving with the mouse?

I'm working on this pygame game and i'm just getting started but got a bit confused because i want the image to move in the x-axis along with the mouse but when i run the program i want the image to show up at the center or the 'floor' but appears…
ronny
  • 41
  • 7
1
vote
1 answer

weird collision detection when blitting on a surface other than the main screen

When I shoot a missile when i click with the mouse and it collides with one of the blocks, I want the block and the missile to be removed. However, I want to put shape on a transparent surface to move it easily, and this is where the problem is,…
1
vote
1 answer

Deleting a Pixel From a Pygame Surface

I am trying to create a pixel-art making program using pygame (yes, I know there are better packages to use). The way that I am drawing pixels is via surface.set_at(). I need to know how to completely delete a pixel from a pygame surface, so that I…
1
vote
1 answer

How can I integrate a Line Chart Viewer in PyGame?

I have an AI for a game in Pygame and I want to create a chart to follow the evolution. I need only the Gen on X-axis and Points on the Y-axis. I have tried this but I don't know how to make it fit on the surface in the game, and not pop out as an…
1
vote
2 answers

TypeError: changespeed() takes 2 positional arguments but 3 were given

Basically I'm trying to make a simple game where the player is able to move both the cursor and the sprite left and right. But when I run the code when 'elif play == 4' is actice and I press on the elft arrow key I get the error, "TypeError:…
user15401554