pygame

Paddle leaves trail when moving (Pygame Pong game) [duplicate]

↘锁芯ラ 提交于 2020-07-03 13:55:15
问题 This question already has answers here : Pygame how to fix 'trailing pixels'? (4 answers) Closed 3 years ago . I have problem with the paddle in my game. Every time I'm trying to move it, paddle leave a "trail". I guess it's because my code don't delete previous paddle with old position. If yes, then how can I delete previous one? Should I use blit() ? Code: import pygame, sys, random from pygame.locals import * pygame.init() gamename = pygame.display.set_caption('Pong') clock = pygame.time

Paddle leaves trail when moving (Pygame Pong game) [duplicate]

两盒软妹~` 提交于 2020-07-03 13:55:09
问题 This question already has answers here : Pygame how to fix 'trailing pixels'? (4 answers) Closed 3 years ago . I have problem with the paddle in my game. Every time I'm trying to move it, paddle leave a "trail". I guess it's because my code don't delete previous paddle with old position. If yes, then how can I delete previous one? Should I use blit() ? Code: import pygame, sys, random from pygame.locals import * pygame.init() gamename = pygame.display.set_caption('Pong') clock = pygame.time

Paddle leaves trail when moving (Pygame Pong game) [duplicate]

天涯浪子 提交于 2020-07-03 13:54:28
问题 This question already has answers here : Pygame how to fix 'trailing pixels'? (4 answers) Closed 3 years ago . I have problem with the paddle in my game. Every time I'm trying to move it, paddle leave a "trail". I guess it's because my code don't delete previous paddle with old position. If yes, then how can I delete previous one? Should I use blit() ? Code: import pygame, sys, random from pygame.locals import * pygame.init() gamename = pygame.display.set_caption('Pong') clock = pygame.time

how to get variable from another class python

只愿长相守 提交于 2020-06-29 09:59:15
问题 how can i get a variable from another class like that white=(255,255,255) class window: def open(a,b,c): displaysurf=pygame.display.set_mode(a) pygame.display.set_caption(b) displaysurf.fill(c) def close(): while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame.display.update() class img(): def show(image,position): pygame.image.load(image) displaysurf.blit(image,position) i want to get the displaysurf variable from window.open() function 回答1: You

Pygame : smooth picture aparition

删除回忆录丶 提交于 2020-06-29 06:54:20
问题 Can someone help me on this ? : I try to make a title that appear smoothly on the user screen : def image(name,x,y,u): screen.blit(name,(x,y)) if u = 1 pygame.display.update() Window == 'main' While windows = 'main': image(background,0,0) image(title, 640, 120) pygame.display.update() But texte appaers suddently and not as I would like... 回答1: You want to use transparency, and pygame uses three different types: There are three types of transparency supported in pygame: colorkeys, surface

SGC GUI and Pygame Widget implementation

风流意气都作罢 提交于 2020-06-29 04:27:08
问题 Hi I am trying to code a simple application with Pygame. I have made various searches and found that best way to get an user input is to use a 3rd Party GUI. I have found Simple Game Code for this aim. Below, you can find my base code, it looks for the images inside same path of script and replaces them in order at screen. But I have no experience with this kind of applications. I am trying to understand from the documentation of SGC: https://github.com/codetricity/sgc/blob/master/example

Pygame lags after drawing full window grid

徘徊边缘 提交于 2020-06-28 09:53:34
问题 I was coded a simple pygame grid window. but pygame window start lag after that. Here is that simple code👇 import pygame import random pygame.init() pygame.font.init() screen_width = 500 screen_height = screen_width screen = pygame.display.set_mode((screen_width,screen_height)) pygame.display.set_caption("Snake GaMe By Akila") def drawGrid(): grid_list = [] blockSize = 25 for x in range(screen_width): for y in range(screen_height): rect = pygame.Rect(x*blockSize, y*blockSize, blockSize,

How do i change the code so that the player stops at the edges rather than wrapping around?

心不动则不痛 提交于 2020-06-28 04:13:11
问题 WIDTH = 800 HEIGHT = 500 background = Actor("background") player = Actor("player") player.x = 200 player.y = 200 def draw(): screen.clear() background.draw() player.draw() def update(): if keyboard.right: player.x = player.x + 4 if keyboard.left: player.x = player.x - 4 if keyboard.down: player.y = player.y + 4 if keyboard.up: player.y = player.y - 4 if player.x > WIDTH: player.x = 0 if player.x < 0: player.x = WIDTH if player.y < 0: player.y = HEIGHT if player.y > HEIGHT: player.y = 0 I want

How to open PYW files on macOS

喜夏-厌秋 提交于 2020-06-27 17:26:10
问题 So, I am extremely new to Python. I just downloaded a file from http://webprojects.eecs.qmul.ac.uk/fa303/pgs/tutorial.html. It is a PYW file. It is a recreation of the game Super Mario Brothers. I have Python 3 and Pygame already installed. The folder is on my desktop, and I am currently trying to figure out how I can run the game for a test. Thank you. 回答1: If you are on Windows, run the command "pythonw (name of PYW file)" from "cmd.exe". PYW files don't need cmd.exe so you can close out of

Add() argument after * must be an iterable, not int Pygame

心不动则不痛 提交于 2020-06-26 04:29:37
问题 Hello I am new to pygame and I am trying to write a shmup game. However I am always having this error: TypeError: add() argument after * must be an iterable, not int self.add(*group) This is the traceback of the error: File "C:/Users/Pygame/game.py", line 195, in player.shoot() File "C:/Users/Pygame/game.py", line 78, in shoot bullet = Bullets(self.rect.center,self.angle) File "C:/Users/Pygame/game.py", line 124, in init super(Bullets,self). init (pos,angle) This is the code I have written so