pygame

How to move a no frame pygame windows when user click on it?

时光毁灭记忆、已成空白 提交于 2020-06-12 07:28:49
问题 i would create a pygame window that haven't frame but that move move when the user click on it and move the mouse. So I try this script but when I click on the windows, '0' printed but not '1' But something is wrong in my script # coding : utf-8 import pygame from pygame.locals import * from random import randint from os import environ from math import sqrt pygame.init() max_fps = 250 clock = pygame.time.Clock() window_size_x, window_size_x = 720, 360 infos = pygame.display.Info() environ[

Pygame point image towards mouse

点点圈 提交于 2020-06-11 12:51:48
问题 I am trying to get this image 'spaceship' to point towards my mouse on screen, proving to be quite difficult so I would appreciate any help :O Also, would appreciate it if you could help with moving an image towards the cursor, i'm guessing that would be quite similar to rotating towards it.. Heres my code: import sys, pygame, math; from pygame.locals import *; spaceship = ('spaceship.png') mouse_c = ('crosshair.png') backg = ('background.jpg') pygame.init() screen = pygame.display.set_mode(

Error when installing PyGame on Mac (Catalina) [duplicate]

为君一笑 提交于 2020-06-06 06:40:27
问题 This question already has answers here : pygame installation issue in mac os (4 answers) Closed 4 months ago . I have been trying to install PyGame onto my Mac on Catalina and can't figure out how to. The error message I get is: SystemExit: error: command 'gcc' failed with exit status 1. Is is something to do with about python not being setup right? I have already tried many different ways to install the package but whenever I run setup.py it gives me the error message. Is there somewhere I

pygame.error “couldn't open image.png” only in command prompt

主宰稳场 提交于 2020-06-05 01:40:09
问题 I've got a very simple python program I wrote to learn pygame, and among other things I use an image. When I run the program with PyCharm, or when I run it by double-clicking on the file, it works fine. However, if I try to run it through the command prompt, I get the following error: C:\Users\julix>C:\Users\julix\Documents\test\pygame_tutorial.py pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "C:\Users\julix

pygame.error “couldn't open image.png” only in command prompt

邮差的信 提交于 2020-06-05 01:38:12
问题 I've got a very simple python program I wrote to learn pygame, and among other things I use an image. When I run the program with PyCharm, or when I run it by double-clicking on the file, it works fine. However, if I try to run it through the command prompt, I get the following error: C:\Users\julix>C:\Users\julix\Documents\test\pygame_tutorial.py pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "C:\Users\julix

How do I chain the movement of a snake's body?

我的梦境 提交于 2020-06-04 07:16:54
问题 I want to implement a snake game. The snake meanders through the playground. Every time when the snake eats some food, then length of the snake increase by one element. The elements of the snakes body follow its head like a chain. snake_x, snake_y = WIDTH//2, HEIGHT//2 body = [] move_x, move_y = (1, 0) food_x, food_y = new_food(body) run = True while run: for event in pygame.event.get(): if event.type == pygame.QUIT: run = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT:

How do I chain the movement of a snake's body?

蹲街弑〆低调 提交于 2020-06-04 07:14:54
问题 I want to implement a snake game. The snake meanders through the playground. Every time when the snake eats some food, then length of the snake increase by one element. The elements of the snakes body follow its head like a chain. snake_x, snake_y = WIDTH//2, HEIGHT//2 body = [] move_x, move_y = (1, 0) food_x, food_y = new_food(body) run = True while run: for event in pygame.event.get(): if event.type == pygame.QUIT: run = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT:

Pygame Movement of Flag and Character With Walls

六眼飞鱼酱① 提交于 2020-05-31 04:03:43
问题 I am making a capture the flag type game. From the code below, I have the fundamentals set up. However, I don't know how I stop the flag from moving when the character hits a wall. Can anyone help me with this? As you can see if you run the code, the flag is effectively picked up by the character and carried but the flag will not stop if the character hits a wall. I want the flag to stay on the right side of the character as well. Thanks for any help. (CODE HAS BEEN UPDATED SINCE ORIGINAL

Pygame Movement of Flag and Character With Walls

冷暖自知 提交于 2020-05-31 04:03:02
问题 I am making a capture the flag type game. From the code below, I have the fundamentals set up. However, I don't know how I stop the flag from moving when the character hits a wall. Can anyone help me with this? As you can see if you run the code, the flag is effectively picked up by the character and carried but the flag will not stop if the character hits a wall. I want the flag to stay on the right side of the character as well. Thanks for any help. (CODE HAS BEEN UPDATED SINCE ORIGINAL

How to make a sprite rotate to face the mouse? [duplicate]

ぃ、小莉子 提交于 2020-05-31 03:06:07
问题 This question already has answers here : How do I make my player rotate towards mouse position? (1 answer) How to rotate a triangle to a certain angle in pygame? (1 answer) How do I rotate an image around its center using Pygame? (4 answers) Closed 11 days ago . After several hours of complete utter chaos, I still haven't found a solution to rotating a sprite to face the mouse position. I've implemented several examples from other post, the links are below, but none of them seem to be