kandi X-RAY | pygame-platformer Summary
kandi X-RAY | pygame-platformer Summary
pygame-platformer
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Main loop
- Calculate the offset of the hero
- Blit a message on the surface
- Draw the game
- Process the game
- Check world boundaries
- Check if the given level falls on the sprite
- Kill the game
- Update the hero
- Set the current image
- Move the rect to the given blocks
- Move and process the rectangle
- Reverse the view
- Load an image
pygame-platformer Key Features
pygame-platformer Examples and Code Snippets
Community Discussions
Trending Discussions on pygame-platformer
QUESTION
Im making a platformer in python using pygame, but i am stuck on the collision, jumping and gravity logic, i figured out the collision logic but not the gravity and jumping. So im asking someone to make a example for my code, because im stuck on this for about 3 weeks now.
Project File: https://github.com/1NilusNilus/Pygame-Platformer
Code:
...ANSWER
Answered 2020-Aug-24 at 21:40Adding the gravity logic is straight forward. Gravity is acceleration so it increases the vertical velocity toward the ground. In a pygame screen, positive Y is down, so gravity increases the Y velocity. For the jump, you just set the Y velocity to a negative number (up) and let gravity do the rest.
Only a few changes are needed:
In the Player class:
QUESTION
I following this tutorial and I have added class Opponent()
to class Platform()
as shown here. Next I have been trying to add groupcollide_and_loop_for to the complete code so that the opponent is removed when hit by the bullet. I have been looking at this question about using groupcollide within class Opponent()
itself. I tried several ways to call groupcollide
inside def main
in while not done
but I didn't get any results or any errors, it just didn't work.
groupcollide_and_loop_for:
...ANSWER
Answered 2020-Feb-19 at 23:57I used print()
to see position for opponent
and bullet
. And I found that opponent
never change position.
After digging in code I found you create two opponents.
- in
main()
you createopponent
which is not added toactive_sprite_list
so it doesn't move and it isn't displayed but you use it to check collision - in
Level_01()
you createopponent
which is added toactive_sprite_list
so it moves and it is displayed on screen but you don't use it to check collision.
Because you check collision with opponent
which never move so it never collide with bullet.
In main()
you have to remove
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pygame-platformer
You can use pygame-platformer like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page