r/pythonhelp • • Aug 08 '20

Pygame help

Hi there,

Hope everyone is doing well, for my A level Comp Sci project i have decided to make a "Logic Gate Simulator", where it will displays pictures of logic gates and I cant seem to add a AND gate on this screen, when i run the code, a picture of the AND gate appears and then it goes to the menu. I dont want that to happen i want it to display the image in the logic gates section.

I dont know if i posted this on the right subreddit or not but if anyone can please help me it will be greatly appreciated.

For the menu i found some code and tweaked it to fit my project.

I want the AND logic Gate to appear here, but i cant seem to find a solution and how to make it appear

I want make an AND gate appear when i click on logic gates.

This is my menu

3 Upvotes

2 comments sorted by

1

u/WhenRedditFlies Aug 09 '20

By far the best way to go about this is to split everything up into functions, even plotting and gate function. Then you can go ctrl f (find) and see exactly where your function calls are, and see why it why not they are triggering.

It also makes the code much easier to read (for the write-up and people marking) and maintain (good for future you!), which is never a bad thing.

Edit: you seem to have done that (how did I miss 4 spaces of indentation?), I guess make sure you've put it in the right function.

1

u/Test_Drive_Fan Aug 09 '20

my main menu is split into functions, however the screens inside the mainmenu (when i press logic gates for example) are just chilling inside the mainmenu function, and simply i dont want to touch the code too much as i will probably just not make it run.

https://shrib.com/#Test_Fan_Code- this is my code, it will be appreciated if you can maybe see where i have gone wrong. I am kind of a programming noob. :/