pygame

Python Config Parser can't find section?

左心房为你撑大大i 提交于 2020-01-24 23:39:47
问题 I'm trying to use ConfigParser to read a .cfg file for my pygame game. I can't get it to function for some reason. The code looks like this: import ConfigParser def main(): config = ConfigParser.ConfigParser() config.read('options.cfg') print config.sections() Screen_width = config.getint('graphics','width') Screen_height = config.getint('graphics','height') The main method in this file is called in the launcher for the game. I've tested that out and that works perfectly. When I run this code

Installing pygame through pip error

被刻印的时光 ゝ 提交于 2020-01-24 22:46:05
问题 I'm trying to install pygame to work with python through pip, however when I use the command pip install pygame, it begins working and seems alright until it throws an error. This is the output I get, I'm not sure if i'm doing it correctly or what, I'm new to pip so I'm just not sure. Any help would be appreciated! C:\Users\Matthew>pip install pygame Collecting pygame Using cached pygame-1.9.2.tar.gz Complete output from command python setup.py egg_info: WARNING, No "Setup" File Exists,

I am trying to delete an object in my game when it of the screen but “del ObjecName” doesn't work

瘦欲@ 提交于 2020-01-24 21:46:50
问题 I am fairly new to classes so I apologise if my problem is something very basic. I want to delete the Enemy when it goes off the screen. I searched this online and found a similar Stackoverflow page which I understood I need to do something like del Enemy however It doesn't seem to work. I have def __del__(self): print("object deleted") method in my Enemy class so it should output that it has been deleted. Here is my function in which I try to delete the object: def enemy_actions(enemies,

I received a name error when trying to call a method

泪湿孤枕 提交于 2020-01-24 19:25:31
问题 I have the following function which controls the spawning of the enemies and what they do. At the end of it I create multiple enemies using the same constructor. However, when in the main loop I call the method of those objects I get a name error . My function: #cretating and manipulating enemies def enemy_actions(enemies): free_lanes = 0 free_lane_positions = [] new_enemies_lanes = [] #going through all lanes for i in lanes: lane_taken = i[1] if not lane_taken: #counting how many free lanes

Adding collision to maze walls

痞子三分冷 提交于 2020-01-24 10:57:10
问题 Can someone please help me adding collision points to my sprites. I had a past code where I layered a bitmap over images but the same code does not integrate well for physically drawing lines rather than detecting where the black/grey is on an image import random import pygame pygame.init() WHITE = (255,255,255) GREY = (20,20,20) BLACK = (0,0,0) PURPLE = (100,0,100) RED = (255,0,0) size = (701,701) screen = pygame.display.set_mode(size) pygame.display.set_caption("Maze Generator") done =

Python pygame writing text in sprite [closed]

主宰稳场 提交于 2020-01-24 02:13:07
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am making a game where you shall shoot down diffrent boxes with diffrent nummber and text on and was wondring if you can write text as a sprite 回答1: First off I feel like you haven't done your research, but are just song for free code. However I will answer your question, don't

Python pygame writing text in sprite [closed]

╄→尐↘猪︶ㄣ 提交于 2020-01-24 02:13:05
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am making a game where you shall shoot down diffrent boxes with diffrent nummber and text on and was wondring if you can write text as a sprite 回答1: First off I feel like you haven't done your research, but are just song for free code. However I will answer your question, don't

Pygame. How do I resize a surface and keep all objects within proportionate to the new window size?

一笑奈何 提交于 2020-01-23 08:07:28
问题 If I set a pygame window to resizable and then click and drag on the border of the window the window will get larger but nothing blit onto the surface will get larger with it. (Which is understandable) How would I make it so that when I resize a window all blit objects resize with it and fill the window properly? For example: Say I have a window of 200 x 200 and I blit a button at window_width/2 and window_height/2. The button would be in the center of the window at 100 x 100. Now if I resize

Having problems with making an .exe with cx_freeze with python and pygame, including additional files

旧城冷巷雨未停 提交于 2020-01-23 03:56:06
问题 I'm having trouble creating an .exe file with cx_Freeze. I'm trying to use this Pygame game which needs some .png's, .gif's and .ogg's to run. I have tried to compile a simple Python only (no pygame or additional files) using the commmand line and a setup.py, but neither worked and I'm a bit out of my death. I have installed cx_Freeze and checked it worked with ''import cx_freeze' in the IDLE not throwing an error. I'm using Python 3.3 on Windows 7 with the correct versions of pygame and cx

What's the difference between the .width and .w attribute of a Pygame Rect object?

孤者浪人 提交于 2020-01-23 03:21:13
问题 The official pygame documentation states that there are several virtual attributes which can be used to move and align a pygame.Rect instance: Until now I used myRect.w respectively myRect.h to determine the width or height of an pygame.Rect object. But to complete this graphic I came across the .width and .height attributes . The interesting thing is that both attributes seem to provide us the same date , as you can see in following code listing: >>> myRect = pygame.Rect((10, 20), (200,100))