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
0 answers

Pygame blitting to a display from a different python file module

I'm programming a tower defence game in pygame. I want to split my code into 3 different python files and run them as modules. I want one file to contain the code needed for the menu screen, another for the main game loop and another file to…
omnistat
  • 63
  • 5
2
votes
1 answer

Pygame: Couldn't open file. Same directory

I loaded 150 .tif images to a glob module and am currently unable to load them. I'm very new to programming so I imagine it's a dumb mistake I'm missing but I cant seem to figure it out. The is the code: import pygame, glob types=…
Delly
  • 123
  • 1
  • 10
2
votes
3 answers

How do I flip an image horizontally in pygame?

This is in pygame. How do I flip an image (lets say an image of a pig looking to the right) to look to the left when I press the left arrow key, and stay like that even if I don't press any keys or if I press the up and down arrow keys. Then how do…
Katrina
  • 111
  • 2
  • 2
  • 10
2
votes
1 answer

How many surfaces is reasonable?

How many instances of pygame.Surface is it reasonable to use simultaneously? More precisely, how costly is it to: Hold a surface in memory? Blit a surface onto another? Consequently, how many surfaces can be kept in a list (or any other…
Right leg
  • 16,080
  • 7
  • 48
  • 81
2
votes
1 answer

How do i draw a line and change colors in pygame?

I am trying to make a draw program in pygame for a school project. In this module, i am intending for the user to press down on the mouse and draw a line on the surface. If a person presses down on a rect, the color that the person selected is the…
programmer
  • 21
  • 3
2
votes
1 answer

Will Pygame blit sprites with a rect outside the display

I'm currently working on a space exploration game in 2D top view. I have quite a few planets and since the map span is much greater than the display I end up with a lot of planet sprites lying outside the display area. At the moment I assume Pygame…
Sorade
  • 915
  • 1
  • 14
  • 29
2
votes
1 answer

Do indexed Surfaces support palettes with alpha values (other than 255)?

When I call myIndexedSurface.get_palette(), it returns a list of 32-bit RGBA values. I figured that because there is an alpha value included, I might be able to set and use palette indices with transparency effects, too. These surfaces could then be…
Augusta
  • 7,171
  • 5
  • 24
  • 39
2
votes
0 answers

Sprite Group will not blit

Once again i'm working on a school project and I'm having a hard time with something i feel should be pretty easy.. I have the code working; its not crashing but its also not blitting. I have created a first person shooter style game using Sprites…
drummerboy
  • 85
  • 6
2
votes
1 answer

Get the pixels which are colliding with the Surface

Right now, I have a collision detection in pygame which checks if two rctangles overlap or not...what I am trying to do is check the transparency of a the surface and if the alpha value is less then 10, stop player from walking into it.. Currently,…
ahk
  • 59
  • 10
1
vote
1 answer

Is there any way to symplify this blit process?

it's my first time making a game in pygame and i'm starting with the main title screen, just now i realised that there's going to be a lot of buttons to press, and i wonder if there's a way around having to write the blit method for every image file…
1
vote
2 answers

Can't seem to move an object in Pygame

Whenever I attempt to move the yellow spaceship in my Pygame tutorial, it moves slightly but then goes back to its initial position. I'm following a tutorial, and can't seem to find the error. Can someone help me? def draw_window(red,yellow): …
Joe biden
  • 13
  • 3
1
vote
1 answer

AttributeError: 'pygame.Rect' object has no attribute 'origin'

class Rectangle: def __init__(self, image, alpha, origin, x, y): self.image = image if alpha: self.surface = pygame.image.load(image).convert_alpha() else: self.surface = pygame.image.load(image).convert() …
Jibhong
  • 13
  • 4
1
vote
0 answers

Can't get gigantic ball to normal size in PyGame

I am trying to make a clone copy of a tiktok rock, paper, scissors filter (link provided) but for some reason the first ball always seems to be gigantic compared to the rest, and it's also outside of the frame. This is not a consistent problem, but…
DiWaso
  • 19
  • 1
1
vote
1 answer

How to get the right position while resizing a sprite group in pygame?

My sprites are 16x16 pixels. I want to scale them, so they're appearing bigger in the game, but when I try to do this, the positions of the sprites are totally messed up. I've sawn many examples for doing so with just one image, but I'll need to do…
Jax
  • 11
  • 3
1
vote
1 answer

How can I use a sprite class argument in Pygame as a keyword argument in pygame.Surface.get_rect()?

I'm trying to create a sprite class that I can assign its size, color, coordinates, and group to. Here's how it looks like: import pygame, sys from pygame.locals import * RED = (255,0,0) class MapObject(pygame.sprite.Sprite): def…