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

Pygame.display.update() not updating on every iteration of while loop

I'm creating a checkers game using PyGame and I'm having problems with the screen updating after each player makes their move. Essentially, I'm using a matrix called "board" which is the underlying data structure for all positions on the screen.…
Chloe P
  • 21
  • 2
2
votes
1 answer

descriptor 'get_at' for 'pygame.Surface' objects doesn't apply to a 'tuple' object

I'm creating a program and am attempting to draw a rectangle at the cursor's position if the pixel at the cursor's position isn't already black. if pygame.Surface.get_at(pygame.mouse.get_pos()) != (0,0,0,255): pygame.draw.rect(win, (0,0,0), (x,…
notgriffin
  • 23
  • 3
2
votes
2 answers

Is it possible to create popups in pygame that can be deleted/messed around with without effecting what is displaying on the main screen

Basically what I want is when you mouse over a unit or item in my game for it to display some basic stats about the item/unit (ideally where the mouse is) like if you hover over the start button on windows it displays a little box that says…
Data Man
  • 33
  • 4
2
votes
1 answer

Ship moves up and left faster than down and right when rotating in pygame

I am working on a simple game. I created a pygame sprite which and tested it by making it move forward and rotating at a consistent speed. However, it seams to be moving left and up (where sin and cos are negative) quicker than right and down (where…
CircuitSacul
  • 1,594
  • 12
  • 32
2
votes
1 answer

Why my pygame game with a tiled map is lagging?

I just started pygame and I started coding a little game, but when I put the code for the tiled map my game lagged! I don't understand why so I ask you. my code: import pygame from player import Player from level import Level clock =…
Nat' code
  • 55
  • 6
2
votes
1 answer

How do I focus light or how do I only draw certain circular parts of the window in pygame?

For this, if you're familiar with it, think the dark mode in the boo levels in Super Mario Maker 2. I'm trying to create a circular spotlight around the character that will also make anything within the circles range visible (eg part of the floor…
2
votes
1 answer

Text will not appear on the screen in pygame

This is the code i have used to try add text to the screen font = pygame.font.Font('freesansbold.ttf', 20) TextX = 700 TextY = 100 def showText(x,y): text = font.render("random text", True, (255,0,0)) screen.blit(text, (x,y)) # Game…
Cavan
  • 23
  • 4
2
votes
1 answer

Python list not returning correct value of complex object

I am writing a platformer game using python 3.6.9 & the pygame library. I'm trying to create all of the game objects, then put them all in a list in order to blit them all to the screen in a for x in gameObjectList loop. Each of the game objects in…
Aidan N
  • 21
  • 2
2
votes
1 answer

Pygame: Text losing anti-aliasing when blitting to SRCALPHA surface

I recently changed the way my pygame game handles menus. Any text I'm rendering is blit to a surface called guiSurface before it is blit to the display (screen). The problem is that this causes the text to appear aliased, whereas blitting it…
redfoxofdeath
  • 61
  • 1
  • 7
2
votes
1 answer

Using a function closes pygame window

The following is the String class. Using the draw function from this class in my main loop immediately closes the game without any errors and as long i dont include it, the game runs fine. It does give me the following warning. Warning (from…
user12291970
2
votes
1 answer

What does the parameter DestSurface in Pygame.transform.scale mean and how do I use it?

The documentation for the pygame.transform.scale method is as follows. scale(Surface, (width, height), DestSurface = None) -> Surface` Resizes the Surface to a new resolution. This is a fast scale operation that does not sample the results. An…
JJoa7
  • 23
  • 4
2
votes
3 answers

Pygame not returning events while embedded in PyQt

I'm testing out an application and the UI uses PyQt4 with Pygame embedded into it. It uses a timer to "update" itself so to speak and in the timerEvent function Pygame attempts to retrieve all detected events. Issue is, Pygame isn't detecting any…
Edgecase
  • 673
  • 1
  • 7
  • 23
2
votes
2 answers

Lag when win.blit() background pygame

I'm having trouble with the framerate in my game. I've set it to 60 but it only goes to ~25fps. This was not an issue before displaying the background (was fine with only win.fill(WHITE)). Here is enough of the code to reproduce: import os,…
2
votes
1 answer

So I'm having trouble animating a character and I'm new to python. I keep getting this error and I don't understand it

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "C:\Users\\OneDrive\Documents\Turtle\turtletest.py", line 52, in draw `win.blit(char, (self.x,self.y))` TypeError:…
Sinfro
  • 23
  • 4
2
votes
1 answer

Pygame window fails to open from inside python script

I am trying to open a pygame surface on a Windows 10 PC. Following, are the steps needed to open a 800 by 600 window. The surface opens and displays correctly when invoked from a python shell as follows: Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019,…