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

How to fit image and rect in pygame?

I just started to learn pygame and there has been a issue of misplaced sprites. I think I don't have a clear idea of relation between image and rect. I got a player with standing and walking animation. standing walking in the code I just used…
pupupyguy
  • 33
  • 4
1
vote
1 answer

can i append a class that draws a surface in list to draw it multiple times and after a surface leaves the screen not draw by removing it from list

I created a class that has a function to draw a surface in screen now i want to append it in a list and draw it multiple times but also delete it from list after it has crossed screen import…
suyog
  • 43
  • 6
1
vote
1 answer

Sprite not being drawn

I am a beginner programmer practicing with Python. I am trying to make a simple game, what I have so far is just adding the character sprite onto the map. What I'm trying to do is when no keys are being pressed, that the character sprite…
1
vote
1 answer

pygame surface isn't visible

I'm currently trying to follow the Introduction to Pygame tutorial and I'm stuck on one step where the speaker makes the surface. His surface is bright red while my surface isn't visible at all. Here's the code: import pygame from sys import…
vgogh
  • 13
  • 2
1
vote
1 answer

I have a problem with the surface of my pygame script, I debug but can't find the answer

So, to start I was developing a game in pygame, and it worked very well until then, but when adding my animations for my characters, the script has an error, a surface problem; "TypeError: Source objects must be a surface". I searched for several…
Mathi'S
  • 19
  • 3
1
vote
1 answer

How does the screen.blit logic woks on pygame?

I am following a tutorial about pygame and I am trying to get an image of a spaceship to appear on the pygame window using "screen.blit" but it doesn't work and I can not understand why. import pygame # initialize the pygame pygame.init() # create…
Yomypoto
  • 11
  • 2
1
vote
1 answer

How to make a collision system in pygame?

How can i make a collision system in the simplest way in pygame, without using classes. I've been trying for a long time and none of the ways works, in my last attempt the code was like this: (Sorry if it's wrongly written, I'm a beginner in all…
1
vote
1 answer

why do I get an error when writing sys.argv[1]

import sys import pygame import random #command line image = sys.argv[1] #loading the image and importing inputImage = pygame.image.load(image) #getting the image's height and width (width,height) = inputImage.get_size() #creating the bigger…
mahoodi
  • 11
  • 1
1
vote
1 answer

Is get_rect a list, and how can I get it's components?

I'm rendering some text on a screen and I want to draw a box behind acting as background. Text is a surface if I know correctly, so you call get_rect() to get it's coordinates, width and height. So when I print(my_text_surface.get_rect()) I get…
1
vote
1 answer

Pygame's Group.remove() function slows down game

In the space invaders project in Python Crash Course, we need to remove the bullets from the group once they are out of the bounds of the screen. This is achieved by for bullet in self.bullets.copy(): if bullet.rect.bottom <= 0: …
1
vote
1 answer

trouble with pygame's colliderect

trying to use pygames collide rect method to detect collision for the x axis of the player. the collisions are not registering at all... which is my problem im trying to mave a square to the right when i hold down the d button, and when i reach the…
1
vote
1 answer

How to blit image in multilayer pygame without blending

I'm trying to create a chessgame using pygame. I got a screen with two layers blitted on it. One being the chessboard and the other one with the figures. In order to update the screen, I'm blitting the layers onto the Screen. First the chessboard,…
Nova
  • 50
  • 8
1
vote
1 answer

Collision triggering incorrectly

I am trying to create a space invaders like game and have created the player and the firing mechanic. However, I am struggling with the asteroids as the collisions seem to be behaving incorrectly. As shown…
Cowman
  • 11
  • 4
1
vote
0 answers

Pygame map not displaying

I'm in the middle of creating a platformer game similar to Mario, I have a level ready and sprites that decorate the level. Right now I am just trying to display the level as grey tiles in my game window with the draw…
kruz_19
  • 11
  • 1
1
vote
1 answer

I can't seem to properly blit surfaces onto screen

So here's my code, I am trying to understand how I can be able to display the surfaces I created onto the main screen which is SCREEN. I drew the maze onto another surface and then I blitted that surface onto the main screen. Then I blitted the…