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

Using pygame.Surface.blit inside class

I can call my class only one time. My code is: class fish: def __init__(self, x, y, image, speed): self.x = x self.y = y self.image = image self.speed = speed def be(self): screen.blit(self.image,…
knowledge
  • 383
  • 3
  • 15
0
votes
1 answer

How do I add 'Rect's or text to a sprite in Pygame?

I'm trying to recreate a slide puzzle and I need to print to text to previously drawn rectangular sprites. This is how I set them up: class Tile(Entity): def __init__(self,x,y): self.image = pygame.Surface((TILE_SIZE-1,TILE_SIZE-1)) …
Alexdr5398
  • 51
  • 1
  • 6
0
votes
2 answers

Pygame 3D Cube translate,move

i have make the follow 3D cube , i need to make a translate function to move this cube for example with key up to move to axis x, with cube y to move in axis y,and right in axis z, i search to find a translate function but it's for 2D here but my…
TLSK
  • 275
  • 1
  • 6
  • 25
0
votes
2 answers

How to add lines to a Surface

The lines won't show up on the screen for some reason. Here's what I've tried class Grid(Sprite): def __init__(self): self.grid = pygame.Surface(size) self.grid.set_colorkey((0,0,0)) def draw(self): # DRAW TILE LINES…
Alexdr5398
  • 51
  • 1
  • 6
0
votes
1 answer

PyGame, How to blit a level that is inside a list

i want to blit a level to my game, that is inside a list of strings. i know i should loop through the list, but still couldn't figure it out. level = [ "BB BB" "BB BB BB BB BB" "BB …
Nobody
  • 605
  • 1
  • 7
  • 9
0
votes
1 answer

Generating a new surface with a filled square and text string in pygame

I am creating a class which shall return me a surface with a square and the text as displayed below: The square (currently) shows the user's colour for the game and text is player name. I'll blit these surfaces on the screen after calculating the…
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
-1
votes
0 answers

How do I make it so my pygame program is completely visible on different screen sizes?

So, I created a program with pygame on my monitor which is 1920*1080, but when I tried to run it on my laptop which is about 1283 pixels wide X 577 pixels high according to a website. Anyways the point is that I want to make it so my program will…
-1
votes
1 answer

How do i deepcopy a list containing Class objects which reference images in Pygame?

I'm trying to re-write a chess game with some improvements and am having problems since i added sprites. In the original game i drew black or white circles with initials to represent the pieces. These were meant to be temporary and were enough to…
AndyM
  • 1
  • 3
-1
votes
1 answer

how to save or add an image to a python project

In the book python crash course page 244 adding or saving an image to the project is unclear? I've tried every code it is still telling there is no such file in the working directory.. so i'm seeking for other instructions?
-1
votes
1 answer

Side Scrolling Pygame Problme

I was trying to make a side scroller game with pygame ( i am quite new to pygame ) and my game works quite fine but once it turns fast it just gets a weird kind of glitch for a few seconds and it happens occasionally i think its some kind of…
Maybe Lindow
  • 183
  • 1
  • 1
  • 7
-1
votes
1 answer

Why are the trees not displaying?

I want to add the tree sprite to the sprite group named tree_group I expect the distance of the trees spawning is calculated like this: if 800 - (tree.x + TREE_HEIGHT) > Tree.get_distance(score): tree_group.draw(tree) For some reason, the trees are…
user13391131
-1
votes
0 answers

Pygame- enemies

I've got a trouble building up my first Pygame; The thing is that I want to create different enemies, but I don't want them to appear at the same time on the screen; I've succeeded in creating the enemies, but they're to many at once; How can I…
Tamri
  • 1
-1
votes
1 answer

Text box render on top of main code in pygame?

I have implemented text box code to my simulation but now it is not rendering the main code, or rendering on top of my main code so nothing is displayed but the box :( Here is my text box code : def textbox(font20): input_box =…
user14632337
-1
votes
1 answer

Why is my Pygame Collision always colliding?

I have been trying to use Pygame collision, but nothing I have tried has works. Now I have ended up with this: player_collison_box = player.get_rect() hole_collision_box = hole.get_rect() if player_collison_box.colliderect(hole_collision_box): …
-1
votes
1 answer

Pygame module (I can't import the rect class)

import #pygame from PYGAME.locals import * from RECT import * pygame.init() #Make Screen screen = pygame.display.set_mode((640,240)) #Defining the colors BLACK = (0,0,0) GRAY = (127,127,127) WHITE = (255,255,255) RED = (255, 0, 0) GREEN = (0,…