Python Forum
[pygame] Inventory items not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[pygame] Inventory items not working
#13
To be honest it is better to start over properly than to try to morph bad code into good. It takes more work than just rewriting it from scratch. And the people helping you are getting burnt out. However that does not help at all if you rewrite more spaghetti code the second time. I have thrown out a lot of code when i first started while learning how to structure the code. So my suggestion would be to read tutorials and follow along with tutorials. Do each section and post back. Even if you understand the concept in the tutorial and it works, post back. Because tutorials cna give you bad coding structure. We will easily be able to fine tune your skills if we can work with 20 or less lines of pygame code relating to each segment of gaming, than dealing with an entire program. Then when you understand each section you can put them all together to make an RPG game. You would have more responses as more people tend to respond with 20 lines of code, you would have better responses as people can work with you in 20 lines of code where 1K is too much to deal with. It would be faster for your understanding of the concept.

The easiest what to get help on forums is to reduce your problem to 20 lines or less. And yes this can be done with pygame. The idea is you take out the issue of your program, and recreate it in a small environment of 20 lines or less (the goal). It should only be enough code to produce the issue. Sometimes it might go up to 50 lines, but it should never go above 100. And your goal should be 20. So every time you have an issue, you create a whole new program based around that issue. you minimize the code as much as possible to give to the forums. You keep minimizing the code until the issue is impossible to address without that code. Then submit it to the forum. The more work you put into reducing the code to 20 lines, the better the responses are and the more there are of them. Try it. How many responses do you get from generic questions about a for loop that has 5-10 lines of code. From how many different people. They will keep responding if you still have problems. As a person asking questions on forums you have to do the work of making it easy to answer your question.

In pygame terms, it should have no resources for the person to require to run the code (unless the issue is with the resource). So
image = pygame.image.load(PATH)
would convert to

image = pygame.Surface([50,50])
Where the size (50,50) would be the size of whatever image it replaced.

And you only need a max of 2 surfaces ever. And that is only if you are having an issue with collision. All other images in your program can be ignored. You dont need fancy backgrounds. you dont need walls or makes sure the player leaves the screen, etc. You dont need all that in the mini example you post to the forums. You only need to illustrate your problem.
Recommended Tutorials:
Reply


Messages In This Thread
[pygame] Inventory items not working - by SheeppOSU - May-12-2019, 12:36 AM
RE: [pygame] Inventory items not working - by metulburr - May-27-2019, 11:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding an inventory and a combat system to a text based adventure game detkitten 2 6,975 Dec-17-2019, 03:40 AM
Last Post: detkitten
  [pygame] Inventory problems. Weapons equipped to wrong slot SheeppOSU 6 4,110 May-07-2019, 02:46 AM
Last Post: SheeppOSU
  [pygame] Blitting armor and weapons with inventory SheeppOSU 3 2,950 Apr-29-2019, 02:31 AM
Last Post: SheeppOSU
  [pygame] Equiping inventory slots with invisible buttons SheeppOSU 6 4,827 Apr-26-2019, 08:45 PM
Last Post: SheeppOSU
  [pyGame] Key Event not Working !... JamieVanCadsand 7 20,868 Sep-29-2017, 08:59 PM
Last Post: Mekire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020