New answers tagged

1

Try this: import os myPath = os.path.join(os.getcwd(),'filename.zip') f = open(myPath, 'rb') It gets the current working directory and joins the file name.


0

I'm a beginer in pygame and python so i'm having some troubles hahahahah. I figured ou what my problem was. Pygame does not reognize two keys being pressed or released at the same time. So for example, when i press the down button, and the right button the program states that self.down_is_down = True and self.right_is_down = True so the player gain a ...


0

If you remove the part bellow, maybe it can work. I do this in the JavaScript game and worked, try it: if event.type == pygame.KEYUP: if event.key == pygame.K_LEFT: self.left_is_down = False if self.right_is_down: self.speed_x = self.velocity else: self.speed_x = 0 if event.key == pygame.K_RIGHT: ...


0

You could do it as you did above (get the distance to the line and if it's less than some number, they are colliding), or you could see if the player's position is a point on the line. If so, they are colliding. The downside of doing it this way is you have to do intra-frame collision checking (ie if the players speed is 2 pixels, you could miss an ...


0

I figured it out. Since lines can be seen as equations, you can detect if the player(or whatever)'s rise is equal(or similar) to the rise of the line. To convert a line to a segment, just make pygame check to see if the player is colliding with a rect that's two corners are the start and end points of the line. Make sure the rect has a positive side though, ...



Top 50 recent answers are included