pygame

Pygame TypeError: update() takes 1 positional argument but 2 were given

佐手、 提交于 2021-01-28 06:08:56
问题 After analyzing my code for about 2-3 hours, I looked up the following links that were similar to my problem, which are provided below. But after recognizing what their issue was, I figured my must be the same, unfortunately that's not the case. I'll provide the code where I believe the issue lies, if you need to see more, i'll be more than happy to comply. Thank you. Hyperlinks... TypeError: __init__() takes 4 positional arguments but 5 were given takes 1 positional argument but 2 were given

Problem when using keyboard commands in pygame

£可爱£侵袭症+ 提交于 2021-01-28 05:49:59
问题 While doing some game programming, I ran into a problem with the keyboard commands. In my code, I have a food bar and a money bank variable named money_bar . The food bar in my game would increase when I press a key, say f , in my game, and also the game deduct say $10 from my money_bar when I press f . The food bar shows the current amount of food I have, which is supposed to decrease every second. However, it appears that none of my keyboard commands in the event() are working. May I know

Play animation upon collision with enemy

て烟熏妆下的殇ゞ 提交于 2021-01-28 05:31:08
问题 so I have loaded the images into pygame: Explosion = [pygame.image.load('Explosion1.png'), pygame.image.load('Explosion2.png'), pygame.image.load('Explosion3.png'), pygame.image.load('Explosion4.png'), pygame.image.load('Explosion5.png'), pygame.image.load('Explosion6.png'), pygame.image.load('Explosion7.png'), pygame.image.load('Explosion8.png'), pygame.image.load('Explosion9.png'), pygame.image.load('Explosion10.png')] and I would like, when the bullet, which is a separate class, makes a

How do I hide a specific point in pygame?

不想你离开。 提交于 2021-01-28 05:30:19
问题 I would like to make it so that in this code, after you draw a new line, then the old one will disappear after 2 seconds, and during these 2 seconds, you cannot draw any more lines. I am confused as to why my code right now is not working. Basically, I am trying to use tick and a variable to tell me when 2 seconds have elapsed, but for some reason, it does do anything. from pygame import * init() size = width, height = 650, 650 screen = display.set_mode(size) WHITE = (255,255,255) BLACK = (0,

how to drop a bomb in character position in a pygame game

北战南征 提交于 2021-01-28 05:27:18
问题 I'm making a pygame game where a character is currently moving around on a screen and can buy items from a shop. I want the character to be able to drop the bombs that he buys from the shop in the location of the player (I need to fix this). I'm attaching my whole code along with some screen shots. Any help is appreciated, thank you. import pygame pygame.font.init() width = 900 height = 600 screen = pygame.display.set_mode([width, height]) walkRight = [pygame.image.load('R1.png'), pygame

Image does not remain on screen after executing for loop in pygame

北战南征 提交于 2021-01-28 05:26:49
问题 I have been trying to modify the code from this Tutorial so that after a bullet strikes an enemy the player.png image is shown at position x = 60 and y = 48 . But the image does not remain fixed , it just appears and disappears. I don't know exactly where the wrong or missing element is in the code but I suspect that one of the causes is some misuse of my part of the for loop within the draw_reaction function. My player.png image My MWE code: import pygame import random # Define some colors

Double-click the keyboard in pygame, not double-click

我的未来我决定 提交于 2021-01-28 05:26:21
问题 I want to use pygame to make a double-click function that detects the right arrow of the keyboard. For example, double-clicking the right arrow jogging becomes fast running, but I am a novice. I do n’t know how to write this function. I have found a lot of documentation and how should I write it. 回答1: I hacked together this example during my last boring meeting. The comments in the code explain what's going on. import pygame class Actor(pygame.sprite.Sprite): def __init__(self, image, pos):

Time Delay and keeping track of the of # of click

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 05:13:22
问题 I' am trying to make a program using pygame. The program involves two tiles that switch colours and turn back into their original color once the two tiles have been clicked and after a 1-second delay. My problem is that whenever I tried to implement the pygame.time.delay , it delays the whole system and also affects the scoring mechanism of the program. I tried solving this problem by writing the codes found in handle_color_change and update methods in the game class Any suggestions to fix

Pygame player sprite not appearing

我是研究僧i 提交于 2021-01-28 05:02:55
问题 I've been working on this project for school computing class, and can't make the player sprite appear, can anybody help? When I run the main game loop, everything appears correctly besides the player sprite. It is supposed to move around the screen as a result of arrow inputs and be affected by gravity. The code also works when I remove the image and use just a object class and a rectangle. import os import random import pygame #start pygame pygame.init() #set up display pygame.display.set

How to make your sprite jump in pygame

跟風遠走 提交于 2021-01-28 03:32:19
问题 Currently i have made a platform game and can move my character left and right. He starts on the ground. Any ideas on how to make him jump because i can't figure it out? At the moment my player sprite will just continuously move up if i hold down the up key or just move up and stay up if i press it. I wanted a way from him to fall back down. Thanks class Player(pygame.sprite.Sprite): def __init__(self,x,y,width = 65, height = 35): pygame.sprite.Sprite.__init__(self) self.x = x self.y = y self