Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Requesting code review on my game (so far) to see if I implemented it correctly  (Read 267 times)
0 Members and 1 Guest are viewing this topic.
Offline heisenbergman

JGO Coder


Medals: 14
Projects: 1


L___ o_ G___ a__ P___


« Posted 2013-05-02 16:44:54 »

Hi all. I've been looking into learning game development over the past week and decided to just jump right in. I already have a few threads on the forum such as:

Can games like Super Meat Boy or Binding of Isaac be recreated with Java?

Need advice mapping out a plan/roadmap to follow for building a 2D platform game

And after a few days of reading and coding, what I've got to show for it is this:

<a href="http://www.youtube.com/v/JHKRu7d9ep8?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/JHKRu7d9ep8?version=3&amp;hl=en_US&amp;start=</a>

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:

main class - http://www.java-gaming.org/?action=pastebin&id=566
Barrier class - http://www.java-gaming.org/?action=pastebin&id=567
Ball class - http://www.java-gaming.org/?action=pastebin&id=568

Questions / Comments:

(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!

Offline ctomni231

JGO Ninja


Medals: 71
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2013-05-02 23:24:56 »

It depends.

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.

Offline heisenbergman

JGO Coder


Medals: 14
Projects: 1


L___ o_ G___ a__ P___


« Reply #2 - Posted 2013-05-03 01:50:29 »

It depends.

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?"

#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.
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.

#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.
How do programmers usually code to handle the different button names from one gamepad to another?

#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.
Thanks! Glad to hear that.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!