pygame

How can I make my Sprite launch an object towards the mouse position?

筅森魡賤 提交于 2020-02-02 12:03:46
问题 For a school project, I need to finish up the pygame program below by implementing a way of shooting Kunais/Shurikens towards the mouse position, to be able to hit the enemy sprite. import pygame import math import random from pygame.locals import * pygame.init() fenetre = pygame.display.set_mode((640,480), RESIZABLE) pause = False class perso(): def __init__(self,image,x=0,y=0,directionX=1,directionY=1): self.image = pygame.image.load(image).convert_alpha() self.x = x self.y = y self

cx_Freeze help: is there a way to NOT make console open?

拈花ヽ惹草 提交于 2020-02-01 03:31:10
问题 I am trying to convert a python game (made with pygame) into a exe file for windows, and I did using cx_Freeze. No problems there. The thing is that when I launch myGame.exe, it opens the normal Pygame window and a console window(which I do not want). Is there a way to remove the console window? I read most of the documentation, but I saw nothing really (except base, but I don't get what that is). BTW, here is my setup file: import cx_Freeze exe = [cx_Freeze.Executable("myGame.py")] cx_Freeze

在Python中安装第三方库(pygame)的全过程

你离开我真会死。 提交于 2020-01-31 12:00:16
假设我们需要再pycharm中安装第三方库(pygame) 1.在cmd中pip intsall pygame 呢么我们首先需要在windows中进入cmd中,进入你下载的pycharm路径,切换到别的盘不需要像linux中使用cd,而是 直接d: 即可,然后直接使用pip install pygame会自动识别你的python版本并下载对应的pygame版本(个人认为python版本可以下载多个,因为pycharm中可以调整此时需要的版本),此时可能出现pip版本太低,根据提示,输入以下命令更新成最新的pip版本即可。 输入更新pip的命令 (注意此时可能会出现进度条一直不动,我因为这个下载了好几次都无法下载成功,但是偶然间发现出现这种情况情况,只需要一直按下Enter键即可进行更新) 之后下载pygame即可 2.查看pygame是否成功下载以及pip是否成功更新(在pycharm中查看即可) 3.点击上图中的右上角的”+“将下载的安装包pygame进行安装(搜索后点击左下角的install package) 4.此时就可以成功使用python的第三方库了(欧耶) 补充: python第三方库的各个版本:https://www.lfd.uci.edu/~gohlke/pythonlibs/ python中pygame的官网:https://pypi.org/project

Error with installing pygame with pip

◇◆丶佛笑我妖孽 提交于 2020-01-30 10:52:31
问题 The following is the EXACT output when running the command sudo python -m pip install pygame on raspberry pi: Collecting pygame Using cached pygame-1.9.3.tar.gz Complete output from command python setup.py egg_info: WARNING, No "Setup" File Exists, Running "config.py" Using UNIX configuration... Hunting dependencies... SDL : found 1.2.15 FONT : found IMAGE : found MIXER : found PNG : found JPEG : found SCRAP : found PORTMIDI: not found PORTTIME: not found FREETYPE: found 2.5.2 Missing

How to fix character constantly accelerating in both directions after deceleration Pygame?

旧巷老猫 提交于 2020-01-30 08:13:13
问题 I was able to successfully implement acceleration into my Pygame game, but there is a bit of a problem. Problem is: After the character decelerates, the character will start accelerating in one direction, decelerate and start accelerating in another direction, decelerate and start accelerating in opposite direction, repeating those two things endlessly. How would i get this to stop? Heres the code i wrote for acceleration: if move_R == True: accel = PLAYER_ACCEL if move_L == True: accel =

How to fix character constantly accelerating in both directions after deceleration Pygame?

喜夏-厌秋 提交于 2020-01-30 08:12:08
问题 I was able to successfully implement acceleration into my Pygame game, but there is a bit of a problem. Problem is: After the character decelerates, the character will start accelerating in one direction, decelerate and start accelerating in another direction, decelerate and start accelerating in opposite direction, repeating those two things endlessly. How would i get this to stop? Heres the code i wrote for acceleration: if move_R == True: accel = PLAYER_ACCEL if move_L == True: accel =

How can you rotate an image around an off center pivot in Pygame

╄→尐↘猪︶ㄣ 提交于 2020-01-30 07:50:17
问题 I want to rotate an image around a pivot, which is not in the center of the Surface in Pygame. The pivot is the green cross in the image: I know the position of the pivot in the game window. How do I track the image at this point and I rotate it around this point simultaneously. image = pygame.image.load("boomerang64.png") pos = (200, 200) angle = 0 while True: # [...] rotate_rect, rotate_image = ???? # rotate around green cross by angle surf.blit(rotated_image, rotate_rect) angle += 1 # [...

Create a log in system in pygame python3

会有一股神秘感。 提交于 2020-01-30 05:46:10
问题 Trying to get the following python code working. What I am trying to do is, for the password input box, instead of the characters inputted appearing, I want asterisks to appear. I have tried using other variables and displaying them, but it hasn't worked. I have been able to get the correct number of asterisks stored in a variable, but need help with over-writing the text in the password box with the asterisks. The code is: import pygame, pygame.font, pygame.event, pygame.draw, string from

Pygame- make bullet shoot toward cursor direction

自作多情 提交于 2020-01-30 05:45:06
问题 I'm trying to make the bullets in my game shoot toward the direction of my cursor until it hits the window borders. My bullets currently go toward my cursor but stops once it reaches where the cursor was. I noticed that the bullet could reach the border if my cursor were offscreen and so I tried to modify the cursor position used to calculate the movement of my bullet to always be outside of the window via multiplying and adding but I couldn't quite get it working the way I want it to. win =

Pygame- make bullet shoot toward cursor direction

 ̄綄美尐妖づ 提交于 2020-01-30 05:45:05
问题 I'm trying to make the bullets in my game shoot toward the direction of my cursor until it hits the window borders. My bullets currently go toward my cursor but stops once it reaches where the cursor was. I noticed that the bullet could reach the border if my cursor were offscreen and so I tried to modify the cursor position used to calculate the movement of my bullet to always be outside of the window via multiplying and adding but I couldn't quite get it working the way I want it to. win =