pygame

Online game give the error “(”ConnectionAbortedError: [WinError 10053] "

房东的猫 提交于 2021-02-11 15:25:14
问题 I made a game in python with pygame and socket, my game works perfectly in local server, but when i want to try it with my friend it give me these errors : ("ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine and Traceback (most recent call last File "C:/Users/Zahraa Rached/Desktop/Poké-aim/client.py", line 54, in <module> game = n.send("get") File "C:\Users\Zahraa Rached\Desktop\Poké-aim\network.py", line 25, in send return

Online game give the error “(”ConnectionAbortedError: [WinError 10053] "

戏子无情 提交于 2021-02-11 15:24:14
问题 I made a game in python with pygame and socket, my game works perfectly in local server, but when i want to try it with my friend it give me these errors : ("ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine and Traceback (most recent call last File "C:/Users/Zahraa Rached/Desktop/Poké-aim/client.py", line 54, in <module> game = n.send("get") File "C:\Users\Zahraa Rached\Desktop\Poké-aim\network.py", line 25, in send return

Walls in Pygame

眉间皱痕 提交于 2021-02-11 15:19:44
问题 I am trying to make a simple Pac-Man game in Pygame, but I don't know how to make walls. How I can make check if player hit a wall when it moves? This is the code of main.py : # Imports import pygame import sys import player import room # Colors black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) blue = (0, 255, 0) green = (0, 0, 255) # Global variables S_WIDTH = 800 S_HEIGHT = 800 FPS = 60 # player speed SPEED = 2 WALLS = pygame.sprite.Group() # Initialization pygame.init() screen =

PyGame App NameError: name 'event' is not defined

吃可爱长大的小学妹 提交于 2021-02-11 14:17:39
问题 This is extremely annoying and I don't know why it's happening. Here's the code: import pygame from sys import exit def createWin(x, y): winCreate = True while winCreate: win = pygame.display.set_mode((x, y)) if event.type == pygame.QUIT: pygame.quit() exit() createWin(1000, 1000) I get this error: NameError: name 'event' is not defined 回答1: You should do - for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() Otherwise python will not recognize event ! 来源: https

'Tuple' object is not callable - Python

笑着哭i 提交于 2021-02-11 13:53:18
问题 I'm using pygame and I'm using a function that set the selected position of a text in PyGame : def textPos(YPos , TextSize): TextPosition.center(60,YPos) print("Size : " + TextSize) but when I run the program, I get an error: TextPosition.center(60,YPos) : TypeError : 'Tuple' object is not callable There's a way to solve this problem? 回答1: 'Tuple' object is not callable error means you are treating a data structure as a function and trying to run a method on it. TextPosition.center is a tuple

Pymunk/Chipmunk2d - dynamic bodies colliding with static bodies generating collsion impulses

∥☆過路亽.° 提交于 2021-02-11 12:40:26
问题 simple question, but couldn't find an answer: Can static bodies apply collision impulses to dynamic bodies? here's a little recording of what my code does As you can see, the two dynamic triangles collide with each other, and are stopped by the static line. however, the behavior is not what I want. If I had only one triangle, it would be skidding down the ledge on just one vertex --> the static body does not inflict any sort of torque or counter forces (I'm no physicist) on the triangles.

Pymunk/Chipmunk2d - dynamic bodies colliding with static bodies generating collsion impulses

北城余情 提交于 2021-02-11 12:39:19
问题 simple question, but couldn't find an answer: Can static bodies apply collision impulses to dynamic bodies? here's a little recording of what my code does As you can see, the two dynamic triangles collide with each other, and are stopped by the static line. however, the behavior is not what I want. If I had only one triangle, it would be skidding down the ledge on just one vertex --> the static body does not inflict any sort of torque or counter forces (I'm no physicist) on the triangles.

Changing direction of rotation Pygame

女生的网名这么多〃 提交于 2021-02-11 12:36:17
问题 How would you change the direction of a rotating image/rect in Pygame? Applying positive and negative degree values works but it seems to only be able to rotate one direction throughout my window. Is there a way to ensure a change in direction of rotation? Perhaps change up rotation of a spinning image every 5 seconds, or if able to change the direction of the spin when hitting a X or Y axis. I've added some code below. It seems like switching movement directions is easy with rect.move_ip as

Collisions aren't being detected in pygame

末鹿安然 提交于 2021-02-11 12:19:46
问题 I don't know why but collisions aren't being detected in my game. Its an asteroids style game and I want the bullets to destroy the asteroids, and the game to end when the ship gets hit by one, but they're passing through each other without doing any of that. Here's my code: import pygame from math import sin, cos, pi from random import randint scr_width = 800 scr_height = 600 window = pygame.display.set_mode((scr_width, scr_height)) pygame.display.set_caption("Asteroids") clock = pygame.time

Collisions aren't being detected in pygame

…衆ロ難τιáo~ 提交于 2021-02-11 12:12:06
问题 I don't know why but collisions aren't being detected in my game. Its an asteroids style game and I want the bullets to destroy the asteroids, and the game to end when the ship gets hit by one, but they're passing through each other without doing any of that. Here's my code: import pygame from math import sin, cos, pi from random import randint scr_width = 800 scr_height = 600 window = pygame.display.set_mode((scr_width, scr_height)) pygame.display.set_caption("Asteroids") clock = pygame.time