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 skew an image

I started work on my own version of Super Mario Kart in python, just as a small project for myself. So far I've managed to transform an image to look like the player is moving over a pseudo-3D track. However, there is no perspective at all, which…
George Willcox
  • 677
  • 12
  • 30
0
votes
1 answer

How to clean up python tkinter windows / pygame windows?

I'm having some issues when running my code inside Spyder3 IPython console. Now I did some digging on this and come to the conclusion that either I have graphical issues regarding drivers or X11 forwarding or whatsoever. Or I simply have an…
HackXIt
  • 422
  • 5
  • 17
0
votes
0 answers

Open AI gym and pygame: pygame.error: display Surface quit

I get the common pygame.error: display Surface quit in my _render function as seen below. The gym environment runs, but then crashes after about 10 secs. I am new to pygame so it would help if the error was explained. I have checked here and here,…
luii
  • 319
  • 3
  • 5
  • 16
0
votes
2 answers

How to iterate through a pygame 3d surfarray and change the individual color of the pixels if they're less than a specific value?

I'm trying to iterate a pygame 3d surfarray, more specifically pygame.surfarray.array3d("your image"). I'm receiving video captured from my webcam then converting them into a 3d array, then displaying it onto my window with this code. def…
0
votes
2 answers

How do I convert a surface(image) into another surface in pygame?

How do I convert an image to another image in pygame without using sprite class? Also how can I remove the previous image after I convert it to another one?
Katrina
  • 111
  • 2
  • 2
  • 10
0
votes
1 answer

argument 1 must be pygame.Surface, not str

I have a ton of irrelevant code, so I am going to try to skip to just the important bits after commenting out the unimportant tidbits I am left with: import pygame from pygame.locals import * from characters import Character class Game(object): …
0
votes
1 answer

'pygame.Surface' object has no attribute 'color'

So, my problem is that I'm trying to draw a rectangle but I keep on getting an error saying that 'pygame.Surface' object has no attribute 'color'. Can someone help me? Full Error Message Traceback (most recent call last): File "main.py", line 64, in…
user7332411
0
votes
1 answer

Howto set alpha to canvas in pygame with SRCALPHA mode?

I make a class to manipulate images, have "surface" variable with a pygame surface in SRCALPHA mode. Howto set an additional alpha?. My code is: #!/usr/bin/env python # -*- coding: utf-8 -*- import pygame from pygame.locals import * from OpenGL.GL…
e-info128
  • 3,727
  • 10
  • 40
  • 57
0
votes
0 answers

Pygame, sprite doesn't appear or even move

I write this code because I want to move a sprite using the key arrow. Nothing special I suppose. I spent a lot of time searching for tutorials that show and move a simple picture. Below is my code: The first part is quite standard, import libraries…
Ziru93
  • 71
  • 1
  • 2
  • 6
0
votes
2 answers

How to make my player loop around the level instead of hit the wall?

How could I make the player loop around to the other side (similar to how Pacman would move from one side of the map to the other)? also, I would like to add some sound effects for when I shoot bullets, but I have found it rather difficult to find…
0
votes
1 answer

How to move Sprite image with cursor movement in pygame?

Now below what i did is simply created a sprite as shown.. futher to do something interesting,thought of threading i added a thread which will check the cursor position, hence update global x & y resulting in change of sprite position that is…
0
votes
1 answer

Wrong colors in pygame after setting SDL_VIDEODRIVER to "dummy"

I'm using PyGame to manipulate and draw images. For example, this is an image I create using draw.rect: I need to run my code on AWS, so I followed the instructions to let pygame run on a headless server, and added os.environ["SDL_VIDEODRIVER"] =…
0
votes
1 answer

Pygame pixel array gives weird colors and freezes immidiately

I am trying to scroll a world map horizontally using numpy.roll() on a pixels2d object in pygame. This is the picture I am using, but in .bmp: This is what I get: I tried changing the axis of np.roll(), but it didn't seem to affect the result…
Lupilum
  • 363
  • 2
  • 11
0
votes
1 answer

Two Surfaces not bliting pygame

I'm trying to render some font onto my Pygame screen but it never shows up. I think I have everything set-up right and my programs not throwing any errors so I'm not sure what's wrong. This is the code I'm using to try and create the…
Pecans
  • 153
  • 1
  • 12
0
votes
0 answers

Accessing two webcams using multiprocessing in python to display on pygame surface simultaneously

I'm working on my academic project. I've to display outputs from two webcams onto the screen simultaneously without lag. For that, I'm using pygame surface(because it is SDL) and multiprocessing in python. Using multiprocessing we can only able to…