Question

Hello i'm new to slick (and lwjgl) and was wondering if its best to stick to one class or multiple when I used straight java I used multiple classes but wasn't shoure about slick

Was it helpful?

Solution

Please do use multiple classes. Classes keep things organized, and it is easier to document. Also, you can use an ArrayList to have a lot of class instantiated and use them later on. The most important thing about multiple classes is that it is organized. It is hard to use only one class for a game, because there will be a lot of code, and you need to try to pack together everything. Use multiple classes!

OTHER TIPS

Java is an object-oriented language for a reason, and classes are there to help you. Using multiple classes will allow you to break down the game logic and view it as the interactions between objects of different classes, limiting complexity and making the game easier to understand. I'm not sure what kind of game you're writing, but for example, you could have a Player class, of which the active player is a member, tracking things such as health or lives, position on screen, et cetera. The player object could then interact with objects of class Monster, Wall, Door, Chest, so on and so forth.

Using classes allows you to reuse code and avoid repeating yourself, manage the complexity of the project, and encapsulate logic. When you're working in Java, an object-oriented language, it'd be wise to try and write code that follows an object-oriented paradigm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top