Now... what I'm asking for is maybe some of you can take a look at how I did what I did and suggest if I could implement it better. I'm asking because I don't think it's good programming practice to just develop haphazardly as long as your program works. I think that there's still a right way to do things, is what I'm saying. Here's my code:

(1) I've seen some tutorials such as this that put the entire physics world into another class. Is that really recommendable? If so, how do I tweak my current code to turn it into that?

(2) Are button names for all gamepads standard? asking because I don't know if it's correct that I use ".equals("X Axis")", ".equals("Y Axis")" and ".equals("Button 0")" to detect inputs from the left analog stick and A-button respectively.

(3) I'm pretty sure I'm not implementing collision detection quite right at all (see createCollisionListener()). Seems like a brute-force way to go about the logic - with the use of getUserData()/setUserData() - which I'll have to revisit.

That's all I can think of now. If anyone has the time and patience to take a look at the code, thanks in advance!

I think one of the first mistakes a lot of programmers make is trying to be perfect on the first go. What we should really be doing is trying to see how much of our ideas we can actually get working. To put it shortly...

Does the code I have work? Yes. Move on.

Other than that, you'll pull yourself into a very difficult programming practice called re-factoring, followed by the nasty one of over-optimizing. This is very counter-intuitive to game making. Just like being asked to wash a car, but spending an entire day to get out one tiny spot.

#1

If the size of your game is small, you might not need to worry about it too much. Splitting up classes is great practice regardless, but you really have to plan it out before you start to code. Decide which areas you want to split up from the other areas, then code toward it. Doing it now will cause you to re-factor early.

#2

No actually. The bindings are not all universal because each controller uses different mappings. Since it is for your own reference, my suggestion is to write down the names that will be easy for you to remember in the future.

#3

Each game is different and requires different attention to detail. If the collision detection you have is "working", I'd suggest just leaving it as is and moving on to the next portion. Looking over the code, I don't see anything wrong with your implementation. The only way I'd change it is if the character object isn't behaving exactly like you want it. If it is good enough, just leave it and continue on.

There are methods for collision detection strung about Java-Gaming. If you are unsure about it, then you might want to try looking it up.

Other than that, it looks like you are on the right track. Depending on your seriousness for perfection, you might want to look into libraries people have to boost your physics (like Box2D for instance). Best of luck.

I think one of the first mistakes a lot of programmers make is trying to be perfect on the first go. What we should really be doing is trying to see how much of our ideas we can actually get working. To put it shortly...

Does the code I have work? Yes. Move on.

Well, the thing is, that I've known how to program in Java for over a decade already. It's just that I haven't used it significantly after graduating and that I'm new to using it for game development. So considering that, I feel like I should focus on good programming practices more than a total newbie.

Other than that, you'll pull yourself into a very difficult programming practice called re-factoring, followed by the nasty one of over-optimizing. This is very counter-intuitive to game making. Just like being asked to wash a car, but spending an entire day to get out one tiny spot.

Oh, I wasn't aware of those. To be honest, all I was thinking was: "Did I create all the classes I need to create instead of dumping all the logic into one class?" and "Is there a more elegant way of handling the logic that I did?"

If the size of your game is small, you might not need to worry about it too much. Splitting up classes is great practice regardless, but you really have to plan it out before you start to code. Decide which areas you want to split up from the other areas, then code toward it. Doing it now will cause you to re-factor early.

Yeah I agree, which is why I thought to ask about it now, while I'm very early in development and have very little to show for rather than down the road.

No actually. The bindings are not all universal because each controller uses different mappings. Since it is for your own reference, my suggestion is to write down the names that will be easy for you to remember in the future.

How do programmers usually code to handle the different button names from one gamepad to another?

Each game is different and requires different attention to detail. If the collision detection you have is "working", I'd suggest just leaving it as is and moving on to the next portion. Looking over the code, I don't see anything wrong with your implementation. The only way I'd change it is if the character object isn't behaving exactly like you want it. If it is good enough, just leave it and continue on.

There are methods for collision detection strung about Java-Gaming. If you are unsure about it, then you might want to try looking it up.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org