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

How to make the "screen" variable accessible to all scripts in python/pygame

I am making my own UI in python 2 and pygame. I have my main script that creates the "screen" variable for the rendering surface in pygame. How could I go about letting other python scripts access - and render on - the surface of another script?
MezuCobalt
  • 60
  • 1
  • 2
  • 11
0
votes
1 answer

Moving a sprite with pygame

this is the code for my Character class: right = [2, 0] class Character(pygame.sprite.Sprite): def __init__(self): super(Character, self).__init__() self.image = pygame.image.load("character_n.png").convert() …
Ferduun
  • 137
  • 13
0
votes
1 answer

Multiprocessing queue: pygame surface died

I want to use multiprocessing to separate two tasks in pygame: Pulling an image from a webcam and showing the image on a screen. The reason I want to do this, is because I want to have fancy image processing I want to separate the web cam polling…
JoeyD
  • 277
  • 3
  • 14
0
votes
1 answer

How to get the rect() of a dynamic circle

I am trying to get the rect of the circle in the draw method but Pygame gives an error everytime I call the get_rect() method on my Alien instance. I want a dynamic circle surface for collision detection because my code generates different random…
tushortz
  • 3,697
  • 2
  • 18
  • 31
0
votes
1 answer

Slowly turning a rectangle in pygame

I have some code: mouseX, mouseY = pygame.mouse.get_pos() angle = math.degrees(math.atan2(mouseY - self.rect.centery, mouseX - self.rect.centerx)) rotated = pygame.transform.rotate(self.rect, -angle) self.rect = lol.get_rect() How should I…
Ignas Kiela
  • 171
  • 3
  • 11
0
votes
1 answer

How to use Python multiprocessing to prepare images for pygame

I'm making a slideshow app with that oh-so-naught-ies pan and zoom effect. I'm using pygame. The main display is therefore realtime 30fps+, and I don't want it stuttering when it has to load a new image - this takes it over 1/30th of a second. So I…
0
votes
1 answer

Pygame's arc to be used as a sprite

I am trying to use the pygame.draw.arc() as a sprite, but its not displaying on the screen. I can achieve the same effect by writing same code in the main loop, but once I try to create a sprite, the effect is not being displayed. (One part in the…
ansrivas
  • 597
  • 2
  • 9
  • 14
0
votes
1 answer

Get HSV values of pixels on surface in pygame

I set my webcam in pygame to use HSV color space. But pygame.Surface.get_at only returns the RGB-color values. Is there a method for reading the HSV values of pixels in pygame? If not, what is the recommended way of converting all pixels colors to…
zelyev
  • 13
  • 2
0
votes
2 answers

TypeError: must be pygame.Surface, not None

i'm working with camera, with pygame, i wrote this code: import pygame.camera import pygame.image pygame.camera.init() list_webCam = pygame.camera.list_cameras() webcam = pygame.camera.Camera(list_webCam[0],(640,480)) webcam.start() img =…
Fulvio Denza
  • 67
  • 1
  • 2
  • 11
0
votes
1 answer

Set constant translucency for background

I am trying to put in a background image for my game and I need that at certain opacity. I have used the method set_alpha() of surface to control its translucency. However, this is creating a fade-in effect with the initial background at the set…
BrownBeast
  • 21
  • 1
  • 9
0
votes
2 answers

How can i change the position of a Surface(Game Window) with respect to computer Screen in PyGame?

I want to change the position of Game window with respect to Computer Screen. But couldn't find anything in Documentation. Please Help me.
Sainath Batthala
  • 591
  • 4
  • 10
0
votes
1 answer

Moving image with pygame

I am new to pygame. I was just trying to move an image with pygame but it fails my code is import pygame from pygame.locals import* img = pygame.image.load('tank.jpg') white = (255, 64, 64) w = 640 h = 480 screen = pygame.display.set_mode((w,…
user3830347
  • 1
  • 1
  • 1
  • 4
0
votes
3 answers

Making image move straight with pygame

I have to move the rectangular object straight through the pygame window. I have tried some code with pygame. The code is import pygame from itertools import cycle pygame.init() screen = pygame.display.set_mode((300, 300)) s_r =…
user3830347
  • 1
  • 1
  • 1
  • 4
0
votes
2 answers

I am having trouble creating moving platforms in pygames. I am getting an error, can anyone help me out please?

So I have just started to learn how to program and I have been trying to create this small game with moving platforms. I can get regular walls/platforms to work but I can't seem to figure out how to get these moving ones to work. I keep getting a…
0
votes
1 answer

Pygame AttributeError no attribute 'display'

I'm trying to learn Python and Pygame by making a 2D tile-based platformer. Right now I'm stuck on the "tile-based" part. This is my code: import pygame, sys from pygame.locals import * #Just defining some variables windowWidth = 640 windowHeight =…
DementedDr
  • 177
  • 2
  • 15