Exceptions, everywhere

I have another problem now. im trying to implement the input system inside the class that creates the cube but when I start the applications it trows a nullpointer exception.

My second question for today is then: is there a way of setting inputs in separate classes or am I forced to fill the Main like an egg? Thanks in advance, Imma go and take a nap now

:stuck_out_tongue:

For your first question, post your code and the exception, so we may help you.

For your second question, you should split your game logic in AppStates and each AppState handles it’s own Input Mapping.

I’m allergic to appstates and I just create an interface ‘KeyInput’, of which every class that might take keys implements. The interface defines a method ‘inputKey(String key, boolean pressed)’. In main I usually just keep a reference to an KeyInput object, or a list of them so all the things that are currently taking input are in the list. AppStates are probably better.

And in the future, don’t bother to even mention an exception without a stack trace. It’s no more useful than “it didn’t work” on the scale of useful information. Always include a stack trace. Always always.

AppStates is kinda useful because it is easily accessed using StateManager from anywhere, I am abusing this in my code because I am still working on getting better understanding of what should be where.

It reminds me with JNDI in JavaEE,

But app states are a bazillion times easier… + actual lifecycle.

and it works as expected :joy:

Thanks a whole lot to each and every one of you, I messed around a little bit with AppStates and I managed to solve my input problem and even store materials separately from the Main class.

Time to conquer new horizons now. To physics!