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

Pygame create a fresh screen

Basically i have been stuck for hours trying to create a blank template when the user clicks new game. I tell the code to then cancel the while loop and use the Background.fill() function to create a blank screen but it doesn't work. Here is my…
0
votes
2 answers

Pygame: slow performance using pygame.Surface and convert_alpha()

I'm developing a simple tile game that displays a grid image and paints it with successive layers of images. So I have- list_of_image_tiles = { GRASS: pygame.image.load('/grass.png').convert_alpha(), TREES:…
SamChancer
  • 75
  • 5
0
votes
0 answers

pygame LayeredDirty repainting whole screen each time

I recently started playing around with pygame and I wanted to create a tiled field that will highlight the tiles that are moused over. For that end I used DirtySprite and LayeredDirty, so that only the updated tiles would be drawn. However, when I…
Mee
  • 27
  • 1
  • 8
0
votes
1 answer

pygame crashes using Surface.fill with a rect that goes outside its bounds and any nonzero PYGAME_BLEND flag

When I try to use fill with a Surface using both the rect and special_flags arguments, pygame lags for a few seconds, then crashes without notification, if I have named rect dimensions that escape the Surface's area. Here're the results of a test…
Augusta
  • 7,171
  • 5
  • 24
  • 39
0
votes
2 answers

Getting position of user click in pygame

I have a pygame window embedded in a a frame in tkinter. In another frame I have a button which calls the following function when clicked: def setStart(): global start # set start position for event in pygame.event.get(): if event.type ==…
joyalrj22
  • 115
  • 4
  • 12
0
votes
1 answer

Diagonal Sprite Movement in Pygame, Python 3

I'm currently making a game using Pygame, Python 3 and one of the bugs I have in it is they way shots move. The game is a 2D top-down shooter, and the code for the player shooting mechanic is below: (player_rect is the Rect for the player,…
Vladimir Shevyakov
  • 2,511
  • 4
  • 19
  • 40
0
votes
0 answers

Surface Drawing and Transparency

I had a look online at quite a few tutorials but I can't seem to get a translucent red circle to be drawn on a surface. I want this method to be used to highlight a sprite with a translucent red circle: def highlight(self): s =…
Sorade
  • 915
  • 1
  • 14
  • 29
0
votes
1 answer

Keeping transparent pixels through rotozoom in pygame, Python 3

I'm currently making a game in pygame, Python 3 and a part of the code that has been giving me issues is: for counter in range(0, 30): particles = pygame.image.load('particles.png').convert() particles =…
Vladimir Shevyakov
  • 2,511
  • 4
  • 19
  • 40
0
votes
1 answer

Pygame moving individual objects

I am testing to move different objects on the screen but independently from each other, the problem is that when i move one object on top of another the last one disappears although i am bliting each of them constantly on the screen. Why is this…
user4813927
0
votes
2 answers

Pygame display surface error

I have the following problem in pygame.I got pygame surface usingsurf=pygame.display.get_ surface() ,but when I am trying to call surf.fill() It says: None type have no attribute fill
user6012107
  • 65
  • 1
  • 9
0
votes
2 answers

How do I change the color of a button once it is clicked in Pygame?

I have been working on this project, and I have created a selection screen with functions and events so that when the mouse hovers over a button it turns orange. But it being a selection screen, once a button is clicked I want it to stay highlighted…
0
votes
1 answer

Pygame convert surface into sprite

I want to make a game with cards, something like Heartstone, but a lot simplier (coz I am not pro programmer). This is just part of program import pygame class Card: def AdCard(self, AdCard): self.AdCard = AdCard def HpCard(self, HpCard): …
flebas
  • 99
  • 8
0
votes
0 answers

Why my pygame display does not work well?

I am writing game by using pygame in python, but some of the images are not displaying correctly. As is shown in the screenshot below, the health bar shown on the top left is not displaying well. The picture is a png file. Has any one had this issue…
Wang Nick
  • 385
  • 1
  • 6
  • 17
0
votes
1 answer

Pygame Blitting Order and Transparency

Having an issue with blitting order (I think) and transparent bounding boxes showing up during collisions. Link to the code and the issue is here: https://github.com/CastleSeven/flappy-balloon/issues/1 Basically, whenever a collision is about to…
0
votes
1 answer

Returning value when instance "called"

I want a certain function callable on a class. Something similar to: class foo(): def __init__(self): self.img = pygame.Surface((20, 20)) def magicfunction(self): return self.img bar = foo() screen =…
Pixdigit
  • 80
  • 1
  • 11