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

Buttons on different screens in Pygame

I am making a program with a start and help menu, as well as other functions. The buttons on the "main menu" work perfectly, but once I enter the Help menu, the buttons I have programmed for screen navigation do not work properly. Please feel free…
JayRoy
  • 105
  • 6
-1
votes
1 answer

Pygame touble when drawing a rectangle

So, I'm randomly generating a "world" and drawing it with pygame. That part worked perfectly fine until I decided to add something above what I already drew. The code is as follows. What each thing is is of no consequence, but DISPLAY is the surface…
André Rocha
  • 123
  • 7
-1
votes
1 answer

Render numpy array on screen in pygame

I'm trying to render a numpy array, that is, its content to a screen in pygame. However, pygame text renderer only supports Unicode. I tried to convert my array to chararray, but it wasn't a solution. Are there any function in numpy that converts an…
Cast Fellow
  • 63
  • 2
  • 11
-1
votes
1 answer

Made a button class in python but cannot add to screen with pygame

import pygame, sys, time, random from pygame.locals import* pygame.init() class Button(object): def __init__(self, x, y): '''x_size, y_size,''' #self.name = name '''self.length = x_size''' '''self.height = y_size''' self.xpos…
Thaej Sooriya
  • 519
  • 1
  • 4
  • 4
-1
votes
1 answer

creating a transparent surface to draw pixels to in pygame

I've created a surface that I've used pixel array to put pixels on, but i want to make the surface transparent but leaving the pixels opaque, I've tried making the surface transparent then drawing the pixels tot he surface but that just makes the…
Ctrl
  • 123
  • 5
-1
votes
1 answer

Pygame surface is too heavy

I'm creating a game that has a lot of high definition images, at 30 FPS, so performance is kind of a big issue to this particular situation. I was checking the memory consumption and realized that a set of images, that has 2~3mb in the hard drive,…
-1
votes
1 answer

Start event when button is clicked with pygame

Hey guys am new to pygame.I have developed a simple game in which the ball bounce each other.It works fine. I have added a ui with buttons with options like new game,loadgame,options. What I need is that when a user click on new game button he must…
-1
votes
1 answer

Repeat the rectangular object in pygame

I am new to pygame app development. In my game a rectangular object rotates in pygame window in a squarely manner. But what I want is to add one more rectangular object and do the same thing. My code import pygame from itertools import…
-1
votes
2 answers

Pygame won't switch to next image

Any ideas as to why it won't change image to IMG_1? Is it because the variable is declared in the main function? from pygame import * from pygame.locals import * import pygame import time import os def main(): while 1: #search for image …
-1
votes
1 answer

Pygame - How can I change palette of parent surface and affect all children?

I have some color cyling of sprites I'm handling in some animations. I break each frame (child) of the animation into a subsurface of a sprite sheet (parent), and I want to color cycle the parent and have the chldren color cycle as a result. Looking…
-2
votes
1 answer

How to customize a map in python3 whith events?

I can't set up changing the pack of blocks for drawing maps in the platformer. In theory, pressing numbers should work. All files are stored in a folder with the appropriate hierarchy. what is the best format to write it in? method, class? I do not…
Alex
  • 3
  • 1
-2
votes
2 answers

Pygame : AttributeError: 'NoneType' object has no attribute 'fill'

So,This was my code,i was coding normally by watching a tutorial but suddenly when i used the fill attribution, an error popped up saying the following : line 15, in display.fill((25, 25, 29)) AttributeError: 'NoneType' object has no attribute…
-2
votes
1 answer

How to make a hole in a pygame surface?

I have 2 different images A and B, B is blit on top of A. I'd like to have (blit I guess) a hole in B that lets me see A through it. Can anyone help me with that? Thanks in advance.
ToeTeo
  • 1
-2
votes
1 answer

type error: projectile takes no arguments pygame

class projectile(object): def int(self,x,y,radius,circle,color,facing): self.x = x self.y = y self.radius=radius self.color=color self.vel=8*facing def draw(win,self): …
-2
votes
1 answer

Pygame - How to blit an image quicker

Typing out screen.blit(surface,(posx,posy)) over and over again for my games is very annoying. Is there a quicker way to do this?!
Glitchd
  • 361
  • 2
  • 12
1 2 3
40
41