I’ve been working on a game for myself about driving and operating tanks. Currently, I’m trying to implement a system whereby if you click on a component in the vehicle, for example, a gunsight or viewport, you run a function/method found in the class that has been instantiated. The instantiated class also has a method that creates the object inside the game world, but doesn’t handle collision. I have created the code needed for mouse picking,
I have divided the program up into three halves, the main program, a class library, and a utility library.
This is a pastebin of all the relevant code from my main program:
hastebin.com/fatogogepa.py
And this is a pastebin for my class inside the class library:
hastebin.com/wadaloheba.py
The utility library doesn’t contain anything related to this code yet apart from the displayScreenText function, which works.
What I’d like help with is for someone to explain how to get the displayMessage function to be executed when selecting the picked object - if I can work out this, then I can apply it to anything I want, I just need to know how to call the class’s method from the picked object.