Thought I would talk about my selection system this time. My main concern when I made the selection system was that I knew a lot of classes were going to need to access the selected object so I could either maintain a pointer to a selectable object inside the main class of the game or I could have the selectable class maintain static methods. The advantage of the former being that I would be able to run multiple games at the same time, and the latter would give me better code compartmentalization. Since this is a game, I am not expecting users to want to run concurrent games, so I went with the latter.
The selectable class itself is an abstract class from which everything that can be selected extends. The class maintains a static pointer to what is selected and has static methods for getting what is selected and changing it.
In order to interact with the GUI, each selectable has a method to alter the functionality of the ability JPanel on the left of the GUI. Right now there are 8 JButtons that set themselves to invisible every time something is selected and the object takes the JButtons it needs and changes the action handler on them and sets them back to visible. This creates the illusion of new ability boards, without having to create entirely new JButtons every time you click on something.
No comments:
Post a Comment