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

How to fill in colour between the grid in my snake application

I am having this problem where I can draw a grid for my snake but I cant fill in the colour between it.It seems like the problem is that because the grid on the surface overrides the actual colour of the background but I dont know how to fix this,…
user14530934
3
votes
2 answers

How to get the correct dimensions for a pygame rectangle created from an image

I have created an image's rectangle of a sprite using the command, pygame.image.get_rect(). When locating coordinates of key points on the rectangle such as bottomleft by drawing dots, I see that the rectangle's dimensions are completely different…
3
votes
2 answers

How to update an py made exe file from my pc to people I have sent it to?

What I mean is that I have a py file which I have converted to an exe file. So I wanted to know in case I decide to update the py file then how do I make it if I have sent it to someone the same changes occur in his file as well whether the exe or…
HAT1412
  • 53
  • 1
  • 5
3
votes
2 answers

How do I rotate a sprite towards the mouse and move it?

I'm confused by the fact that in my code the sprite's coordinates don't seem to change where it is. Putting (200, 200) would be the same as putting (900, 100000). So basically i cannot coordinate the sprite in a designated position. Can you…
BetterNot
  • 119
  • 7
3
votes
1 answer

How do I convert an OpenCV image (BGR and BGRA) to a pygame.Surface object?

I created images from OpenCV/opencv-python (numpy.array) and I want to convert them to a pygame.Surface object: def cvImageToSurface(cv2Image): pygameSurface = # ? create from "cvImage" return pygameSurface surface =…
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
3
votes
1 answer

PyGame Negative Color / Surface

I'm creating a game with PyGame. There I want to create negative effect, where all screen becomes negative. This is quite easy for simple shapes like rects: (and use rect instead of pygame.draw.rect) # set negative to 1 to activate effect negative =…
Somebody
  • 115
  • 6
3
votes
1 answer

Python Pygame Trasparency showing as black

I am trying to blit an image with transparencies on top of a Surface with the rest of the map. ( This is the second layer. ) When I blit it, it shows with the transparency as black. Is there a way to fix this. I included the code related to…
Some Goose
  • 43
  • 3
3
votes
1 answer

Transparent background not disappearing when displayed on pygame window

I am creating a car game and have come across a problem. I've added a car image with a transparent background into my code but the car appears on the screen with the transparent background visible. I want to make the background to disappear. This is…
3
votes
1 answer

Random Brick Color -> TypeError: 'pygame.Color' object is not callable

so this is my first time as a registered user here, so please bear with me if I was searching wrong, but with the tags [python] or [pygame] I could not find an answer to this question of a random color. So my problem is the following: The Game In…
twentyfour
  • 31
  • 1
3
votes
1 answer

Overloading pygame.Surface in order to dynamically augment the size of the surface

I am trying to build an application that requires the user to draw something. To do so, I create a canvas (a pygame.Surface object) on which the drawing are registered, and then I blit it onto the window. I'd like the canvas to be infinite, so that…
jthulhu
  • 7,223
  • 2
  • 16
  • 33
3
votes
2 answers

Why doesn't pygame continue through the loop?

I am making a game, and when I want to go through the loop normally, it doesn't work. it goes through the loop, but for some reason, it backtracks, rather than starting over. When I add a continue statement, the button just disappears. Why isn't the…
10 Rep
  • 2,217
  • 7
  • 19
  • 33
3
votes
1 answer

Why is my platform game in PyGame suddenly so slow?

So I have a platform game I made in PyGame that all works, so I am now trying to make it a bit more colourful. So the code that I changed used to be: def draw(self, screen): """ Draw everything on this level. """ # Draw the background …
mabski
  • 153
  • 1
  • 2
  • 11
3
votes
1 answer

Pygame returning locking error during blitting

I am trying to make a 2D game in pygame, and have a camera class that has a surface attribute, and each time the cameras get updated their surface is updated. All graphics are blitted to game.worldSurface, and then the main camera take a picture of…
Paletech35
  • 320
  • 1
  • 2
  • 10
3
votes
1 answer

How do I scale a PyGame image (Surface) with respect to its center?

I am fairly new to pygame and am working on my first game. (So sorry if I'm asking a stupid question) I am trying to get the title of the game to slowly increase and decrease in size like a sort of breathing effect in order to make the home screen…
Brooksay
  • 41
  • 5
3
votes
1 answer

How to Display Sprites in Pygame?

This is just a quick question regarding sprites in PyGame, I have my image loaded as in the code below, and I'm just wondering how to display the sprite in PyGame like drawing a rectangle or circle. I don't want to have it behave in anyway. I think…
Bill 9098
  • 41
  • 3
1 2
3
40 41