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

Pygame Sprite transparency collision

I would like to create physics body around the physical paths of the texture (cutting out alpha channel). How to do it in pygame? Is it going to be effective? player_idle = pygame.image.load('data\img\player\idle\idle-1.png')
mikazz
  • 159
  • 1
  • 11
2
votes
1 answer

Image position not updating / updates slower while moving mouse

(trying to make a whack-a-mole game)Whenever I move the mouse, the position of the image of the mole seems to move 3-5x slower than when I'm not moving the mouse, and I'm not sure what's causing it since the position should update based on how much…
qwerty_99
  • 640
  • 5
  • 20
2
votes
1 answer

Render pygame sprites with pyopengl

On my game, I am using pygame for rendering the sprites, however that work is done on the CPU side and, for performance issues how to draw those sprites using pyopengl? I started learning opengl in c++ those days and is it similar to python?
Simple coder
  • 151
  • 1
  • 11
2
votes
2 answers

Improve performance while executing pygame?

My pygame is running way too slow. Without using class oop it was running perfectly but now using oop its very slow. I have tested putting that separate class file in main file also but the result was same. import pygame from snake import…
2
votes
1 answer

pygame.surface.get_at((x, y)) not returning correct pixel data

I have a simple program which allows the user to draw white pixels in a black box. when the user clicks the blue button I want my program to go through all the pixels in the draw box and add the pixel data to an array for later use in another…
Aguy
  • 169
  • 11
2
votes
1 answer

Pygame surface with alpha not blitting transparency

I'm trying to make a user interface thing transparent in my game when the mouse isn't hovering over it. But for some reason, when I set the alpha value of the image for it to become transparent, nothing happens. Here is some runnable code for it…
lakam99
  • 575
  • 4
  • 9
  • 24
2
votes
1 answer

How do I get the Mouse Position on a Pygame Scaled Surface?

The game I'm making blits everything onto a pygame.surface which is then scaled to the size of the user's display, maintaining aspect ratio, before the surface is then blitted to the main screen. The problem I'm having now, is that when I query the…
Jayce
  • 539
  • 6
  • 21
2
votes
1 answer

How to save object using pygame.Surfaces to file using pickle

If I have created my own class which has some attributes that are pygame.Surfaces and I would like to save this object to a file, how can I do this as an error occurs when I try. The class which I have created is an object which is essentially the…
Ofsouzap
  • 23
  • 1
  • 4
2
votes
1 answer

Fastest way to create and populate an 8-bit surface programatically with pygame

I need to create a 8-bit surface programmatically from an a list array. This is a constraint I have. So far, I got it working with this solution: width = int(4) height = int(4) image_data_raw = ['\xf1', '\xf1', '\xf1', '\xf1', '\xf1',…
gmmo
  • 2,577
  • 3
  • 30
  • 56
2
votes
2 answers

PyGame pygame.sprite.collide_mask detects no collision?

I am trying to build a simple version of Flappy Bird. To detect collisions between my circle(Flappy Bird) and my rectangles(Pipes) I was using pygame.sprite.collide_rect() but I wanted a better way of handling collisions. But using mask collision…
2
votes
1 answer

Pygame - locking the scroll of a surface area to a limited amount

I'm playing with pygame and I'm making a memory game. In my memory game I need to have a small Menu on the middle-bottom of the screen and the player list on top of the screen. The game manager will output the message in the upper left corner of the…
MarcoBubi
  • 55
  • 1
  • 5
2
votes
1 answer

How image capturing with Pygame actually works?

My goal is to set up a webcam with Raspberry Pi to be active during a certain time (let's say 2 minutes). During this time I should be able to capture a still image at any time and save that image to a folder. I chose to work with pygame. My project…
Fatmajk
  • 1,770
  • 1
  • 13
  • 22
2
votes
2 answers

What Does The antialias mean in this Font render code for pygame mean?

class Score(pygame.Surface): pygame.font.Font.render(Text, antialias, color, Background) I am trying to make a code that will implement a Text file that gets on to my pygame surface. I want It to show up on the top right hand corner of the…
cranberry
  • 73
  • 2
  • 7
2
votes
2 answers

How do you make the string appear after hitting the return key

I am creating a flashcard game for my kid. Its about Dinos. I am having trouble making "Congrats, You got it right" appear on the screen. I have moved my code all over the place but no luck. Can someone please help me out. To be clear, What I want…
zootechdrum
  • 111
  • 1
  • 8
2
votes
1 answer

How do I center a surface (subsurface) around a rectangle? (scaled sprite hitbox / collision rect)

Currently I have working code which will cycle through a spritesheet, adding each cell/image (9 in total) as a subsurface into a list. As the game updates, I am setting the Player image as the current cell in which the code has indexed by.…
Will Smith
  • 37
  • 1
  • 7