Questions tagged as 'pygame'

1
answer

Detect and destroy colliding objects

This is the code: import pygame,sys from pygame.locals import * from random import randint ancho = 1280 alto = 720 class Snake(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.Image...
asked by 03.01.2018 / 22:42
1
answer

AtributeError in Pygame

In the process of executing this Pygame code, the following error appears on my terminal regardless of the corrections made to the code: AttributeError: 'naveEspacial' object has no attribute 'dibujar' How can I correct my code of this erro...
asked by 08.02.2016 / 14:06
1
answer

Black screen when running Pygame

Previously to ask this question it is worth noting that I have consulted several sources looking for some answer to my problem. None of them seems to have served. Despite trying to solve my problem on my own, rereading the code, the error still...
asked by 01.02.2016 / 14:07
1
answer

Set range of values for random.randrange ()

I have a problem in Pygame when trying to get random values within a range with random.randrange , this is my code: import random import pygame WIDTH = 800 HEIGHT = 600 RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) WH...
asked by 25.01.2017 / 00:43
0
answers

Random map with Python3 pygame module

I'm creating a Roguelike style game with the pygame module. The problem I have is that I do not know how to continue the code, the maps are drawn in a txt file with characters (# = door,. = Empty, 1 = wall and p = character) I only managed to pu...
asked by 30.09.2018 / 00:15
1
answer

I can not get the character to be drawn on the screen

I'm trying to make my character ( imag_1 ) draw on the screen but I can not get it. This is my code: import pygame from pygame.locals import K_LEFT, K_UP, K_RIGHT, K_DOWN import os import sys # Variables imag_1 = pygame.image.load('prue...
asked by 11.05.2018 / 05:24
1
answer

Is it possible to do a delay in python without stopping the program?

Hello today I asked myself if it would be possible to do a delay in the background or something so that the program does not stop. Is it possible? I would like to have a rectangle moved to a position x every 2 seconds and after another 2 seco...
asked by 02.03.2018 / 22:56
1
answer

I create a list from another one but the changes in one affect me both ... What do I do wrong?

I am a pithon enthusiast and self-taught and I find myself with the following problem: In a method I create a list from another one where I have to make some changes within a loop, to each cycle I want the second created list to be copied from t...
asked by 24.02.2017 / 18:29
0
answers

Background image is constantly loaded in Python

Good morning, I have a game in python to which I assign a background that I want to be changed by another when I reach a number of points, the problem is that when the background is changed it is constantly loaded and the framerate is lowered, i...
asked by 21.12.2018 / 19:55
1
answer

K_UP is not defined

I have a problem with the following lines: keys = pygame.key.get_pressed() if keys[K_LEFT]: When I run the code it gives me an error that says: File "HardGame1.1.0.py", line 49, in <module> if evento_tecla[K_UP]: NameError: nam...
asked by 14.02.2018 / 02:02