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

can't blit a surface with its lines on display

I'm trying to draw a line on a surface that I then blit on the display. When I'm doing so, only the surface appeares while the line is not drawned. The code I wrote is import pygame as pg import numpy as np pg.init() # Define constants for the…
mcali
  • 13
  • 4
1
vote
2 answers

How do I create an extendable bar sprite in PyGame?

I want to use the following asset in my game: It has specific pixelated borders and corners. So I want it to scale "extending" the inner part of the asset by repeating it until it matches the desired size. So I can render something like this: This…
kokoko
  • 2,705
  • 3
  • 17
  • 28
1
vote
2 answers

Trying to make a rect appear on screen without using the "blit" function

I am trying to make a certain oject, in this case a platform appear on screen as a floating rect without havving to use blit. I have created a class for the platform but it just doesn't appear on screen. I have seen online other people's code…
pghost33
  • 11
  • 1
1
vote
1 answer

PyGame colliders don't scale with window

I should point out that I'm a beginner with PyGame. I have made a program that displays some simple graphics on the screen using PyGame. It blits every graphic on a dummy surface and the dummy surface gets scaled and blit to a 'real' surface that…
Tele
  • 57
  • 8
1
vote
1 answer

Pygame sprite group won't draw because of error: Source objects must be a suface

im having a problem with my 2D Platformer game and when trying to display sprite group, an error message appears saying: Pygame: TypeError: Source objects must be a surface, The problem seems to be around the coins sprite group when trying to draw…
1
vote
1 answer

Selectively reset the color of the surface after blitting PyGame

I have two green surfaces s1 = Surface((100, 100)) s2 = Surface((100, 100)) s1.fill((0, 255, 0)) s2.fill((0, 255, 0)) Then i blit them on main surface with beautiful background screen.blit(image.load("ocean.png").convert_alpha(), (0,…
upcast
  • 59
  • 4
1
vote
1 answer

How to assign a pygame_gui Button to a specific surface

I'm currently working on a project based on pygame. It is the first time I'm attempting a project like this. I choose to try the pygmae_gui library in order to (who wold have guessed) implement a GUI to the project. I successfully added some buttons…
1
vote
1 answer

pygame maintain a points position around a rotated image

In pygame I have an image object of a frigate at 0 degrees of rotation. On it i have turrets, i need to calculate their new position if the frigate rotates by say 90 degrees. After rotating the image like so, rotatedFrigate =…
Murchie85
  • 815
  • 2
  • 12
  • 27
1
vote
1 answer

Pygame Memory Card with list of images

I'm trying to build a memory card game using pygame where I list the cards that are a match: # Load the images image1 = pygame.image.load("1.png") image2 = pygame.image.load("2.png") image3 = pygame.image.load("3.png") image4 =…
Darlene
  • 55
  • 5
1
vote
1 answer

Creating a matrix over an image

I decided to set the background image as the game board so that I wouldn't have to draw it every frame. The problem I am having now though it trying to create a matrix over this image in which the game pieces align where I want them. Not sure if I…
1
vote
0 answers

Using pygame and font.render, how do I make sure the text doesn't go across a certain boundary but instead move down?

tutorialText = tutorialFont.render("""A sliding puzzle is a type of game where a player must rearrange a set of pieces to complete an image by sliding the pieces into the empty space. This game is a variation of a sliding…
1
vote
1 answer

Surface.fill() is not clearing the display

I want to start my main game loop with surface.fill(WHITE) to repaint my display white, but every surface from the last frame still appears. To demonstrate, the following example blits a red surface on a green surface. The blit is created by an…
Owen Meyer
  • 21
  • 5
1
vote
1 answer

How do you clip a circle (or any non-Rect) from an image in pygame?

I am using Pygame and have an image. I can clip a rectangle from it: image = pygame.transform.scale(pygame.image.load('example.png'), (32, 32)) handle_surface = image.copy() handle_surface.set_clip(pygame.Rect(0, 0, 32, 16)) clipped_image =…
Anonymous
  • 738
  • 4
  • 14
  • 36
1
vote
1 answer

How to reposition player's image while keeping the same rect?

I'm making a platform game and I got player standing and walking animations. I used tempbottom and tempcenterx to keep the player's position so he doesn't flash backwards or forwards when start walking. But I want to keep the standing rect while…
pupupyguy
  • 33
  • 4
1
vote
1 answer

Import a player icon and replace a block

Im new to python and im currently making a simple pygame but I can not grasp the concept of sprites. I want to replace the moving block with a player icon that I created. Do I need to make a group just for one object or is there a way just to add…
mane004
  • 11
  • 2