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

Display SVG (from string) on Python Pygame

I have an SVG graphic represented in a string svg_string='' I want to display the…
Raj Oberoi
  • 654
  • 1
  • 7
  • 18
4
votes
1 answer

Enemy not staying at original spot

So I been trying make my enemy move at the same spot while my player moves the camera but it's not working, when the screen moves my enemy will slowly move from its original spot but once its out of its original spot it will start glitching. Also…
4
votes
1 answer

Pygame is running slow

I am creating a game called "Survival Island" and have just created the start screen. The pygame lags too much after doing an event (takes time to respond). Here is my source code: #packages import pygame import sys from sys import…
4
votes
2 answers

Pygame - Is it possible to change the background image in relation to time?

I'm using pygame in order to create a sort of animation. What I have in mind is to have a series of background images change in relation to the time that has passed once I initiate the game. I came up with this code to do so: while True: …
4
votes
1 answer

Trying to make sections of sprite change colour, but whole sprite changes instead

I have a few sprites in my game that need specific parts to be able to change colour. My process I am trying to to have a pure white sprite image that is transparent everywhere the colour does not need to be. I am blitting a coloured square on top…
Reaper Lord
  • 43
  • 1
  • 1
  • 6
4
votes
4 answers

Pygame, create grayscale from 2d numpy array

Python 3.4, pygame==1.9.2b8 I want to draw grayscale frame. Now, code below produce blue color, but I want to make color in range (0,255), where 0 - black. 255 -white. How is it possible?! import pygame import numpy as np s = 300 screen =…
weider
  • 93
  • 1
  • 7
4
votes
3 answers

How to draw a transparent image in pygame?

Consider a chess board, i have a transparent image of queen(queen.png) of size 70x70 and i want to display it over a black rectangle. Code: BLACK=(0,0,0) queen = pygame.image.load('queen.png') pygame.draw.rect(DISPLAYSURF, BLACK, (10, 10, 70,…
Saurabh Shrivastava
  • 1,394
  • 4
  • 21
  • 50
4
votes
1 answer

Display PyGame Mask on screen

I am working on some robot vision project where I need to do some object recognition by color. I am currently using masks for this purpose. So far so good, but now I need to tweak certain settings and I would like to actually see how these changes…
wtf8_decode
  • 452
  • 6
  • 19
3
votes
0 answers

Pixelated / bold pygame text when rendered at certain coordinates

I'm working on a game with pygame (Tetris), and I have several texts displayed. They all use the same font, the same size and the same render parameters (except for the text to display). However, some texts appear normally like this : , and some…
Reywaz
  • 45
  • 7
3
votes
1 answer

Can't figure out how to check mask collision between two sprites

I have two different sprites in the same group, variables 'player' and 'ground'. They both are separate classes, with a mask of their surface. This line is in both of their classes. self.mask = pygame.mask.from_surface(self.surface) The images used…
3
votes
1 answer

Rotate a rectangle over waves

I am trying to move a rectangle over the waves,trying to simulate a boat sailing. For that, I rotate the rectangle using the height of the drawn lines and calculating the angle they form with the rectangle. However, for some reason, in some points…
3
votes
1 answer

How do I make an object in pygame rotate

I am making a game, and previously had made it using images and bliting them but I am now remaking it trying to uses object and sprites. I am unsure how I would make my image and rect rotate and I am also unsure how to create a rect that is behind…
3
votes
2 answers

How i can remove the black background on my sprite sheet in pygame

I'm trying to learn how use sprite sheets on pygame , and on my first try my sprite for some reason have a black background , i don't know how i can fix this problem , i alredy put 000 on the color key but when i do this the sprite be all…
Juw
  • 43
  • 6
3
votes
2 answers

Move Character with Vector

I am teaching myself pygame and am looking at making my character able to rotate and then move in the direction they are facing. I can do the rotation but cannot get the character to move in the direction the image is then facing. The code is on…
3
votes
1 answer

How to make entities take damage with color collision in pygame?

How do I make entities take damage with colors? I made a game with enemies shooting blue lasers and I want the player to take damage. And the player shoots a red laser. Upon detecting colors, I want a certain statement to be true. That would lower…
hmood
  • 603
  • 7
  • 25
1
2
3
40 41