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
2
votes
1 answer

Unable to detect multiple Rect Collisions in Pygame

I'm been working on a simple Pygame project that involves simulating motion sensor lights in open areas, and have created multiple instances of delivery riders, smokers and civilians. When users are within a certain distance, the lights on the…
Marcus Ng
  • 23
  • 3
2
votes
2 answers

How to load colorful emojis in pygame?

I want to use Pygame's freetype module to load a colorful emoji via its unicode. Unfortunately I only get a monochrome image with the outline of the emoji: Minimal, Reproducible Example: import pygame import pygame.freetype pygame.init() window =…
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
2
votes
1 answer

How to get the scaled output with the same ratio

I'm trying to make a game using pygame but I came up with an issue of people getting annoyed of the resolution they're working with, and can't resize window without stretching it. Here is an example picture of what I'm trying to achieve. here's…
AidanGamin
  • 67
  • 1
  • 7
2
votes
1 answer

Dark borders in cv2.blur

I have this code on python that I use as a Bloom effect on my game, but I've noticed that it has this weird black shadow around the particles The effect looks like this ^ as you can see, there is some shadows on the particles, on white background…
Nath
  • 69
  • 6
2
votes
1 answer

Collisions using masks between two images only working at a certain point

I am trying to check a collision between one static, and one moving image. The static image is a balloon and the moving image is a gun. I've tried to create a function that gets the rect of the gun (using get_rect), checks if one of the (7) balloons…
krmogi
  • 2,588
  • 1
  • 10
  • 26
2
votes
0 answers

Particles are lagging when they get near to the bottom of the display

The code creates surfaces when the mouse button is clicked. A rectangle is drawn on every surface. When they appear, the falling process should look like something similar to gravity. They fall down and they're rotating. The problem So the problem…
Levi
  • 51
  • 5
2
votes
1 answer

Transparency problem displaying text with Pygame

enter image description hereI would like to display transparent text on a surface that is sized based on the length of the text. The problem is that the text has a black background even though "None" is specified as the background in the "render"…
RobertoZ
  • 23
  • 3
2
votes
1 answer

How do you load all images at a time in pygame?

I'm trying to load all these images at once. Their all in the same directory so is there a way to load them all at once without being this repetitive? bg = pygame.image.load('Desktop/Files/Dungeon Minigame/background.png') f_zombie =…
Zelda
  • 39
  • 4
2
votes
1 answer

Getting rotated rect of rotated image in Pygame

I have a problem about pygame rect. The rect isn't like what I want. I saw I can do this with sprite class. But I don't want use sprites. I didn't understand differences of Sprite Rect and Image Rect. I want to get rect like this But I am getting…
Arda Yılmaz
  • 149
  • 1
  • 9
2
votes
2 answers

What is the difference between pygame sprite and surface?

Check the official documents as follows: Surface objects are objects that represent a rectangular 2D image. The Sprite class is intended to be used as a base class for the different types of objects in the game. They all have image and rect…
wang John
  • 21
  • 1
  • 4
2
votes
1 answer

In pygame how can i create a data struct that keeps track of resizing events and the coordinates of objects?

I'm looking to keep my mouse events in sync with my objects after resizing the screen. I'm told I need to create a data structure to keep track of: Resizing events New coordinates to match the resize How can I accomplish this using simple…
2
votes
1 answer

How to draw a chessboard with Pygame and move the pieces on the board?

I've been trying different ways how to get my chess pieces to drag and drop I've found ways, but the problem is that I'm using a dictionary to load my images via pygame.image.load. I've created a dictionary for my images like this: IMAGES = {} def…
Axhul
  • 157
  • 10
2
votes
1 answer

Pygame set_alpha not working with attempted background fading

I've been trying to create a short code to use for a project that can fade in and from black, but for some reason only the function that fades in is working while the fade out function is being skipped more or less. By giving them parameters I…
2
votes
3 answers

Pygame switching from fullscreen to normal does not work

im currently trying to have a setting to switch from windowed mode and fullscreen. But after getting into fullscreen and trying to go back, the game bugs really weird and sticks to the topleft corner Btw: display_width = 1280 display_height = 720 …
user14074797
2
votes
1 answer

How to save pygame scene as jpeg?

I need to do the following. I loaded an obj model using OBJFileLoader and rendered it to a window. How can I save the rendered scene as a picture? Is it possible to do this without even showing the window?
SomVolodya
  • 23
  • 3