Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  New to game programming  (Read 3362 times)
0 Members and 1 Guest are viewing this topic.
Offline jparril1

Junior Member





« Posted 2010-12-02 02:55:53 »

Hey guys.

So Ive been programming in Java for a few years now, but nothing game related. I am quite comfortable programming in Java.. although I do know Python and C/C++ on a beginner/medium level. Since I want to do game programming, and since its a notoriously difficult thing to do, I thought it would make sense to use the language that Im the best with. So, how can I start game programming in Java? What libraries will I need for 2D games? It seems like other languages are more clear cut... for C++ Id just use SDL, for Python I'd use pygame, etc. Mind you I dont want some pre fabricated game engine... just the API to access graphics, sound, input, etc. Basically I want to do as much on my own as I can, because its all about learning for me. Once I have a library, where do I start? People have said do something simple like tetris or breakout... but I wouldnt even know where to start those. Ive looked at LWJGL and it seems like what Im looking for. But Im also confused as to the difference between using something like that, or using the AWT and applets to create a game? Some of the tutorials Ive seen use threads and the AWT rectangles and circles to draw animations to make simple pong games and such. Should I be doing something like this instead of getting a library? Im so confused... I just want to get started on the right track. Thanks
Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2010-12-02 03:27:31 »

LWJGL gives you OpenGL, OpenAL, and JInput, which take care of graphics, sound, and input. It usually replaces anything Java has built in (ie. the AWT). You might use AWT for utility functions such as loading images still, or even use LWJGL embedded in AWT frames as a convenience, or even use AWT's input methods instead of JInput.

Cas Smiley

Offline philfrei
« Reply #2 - Posted 2010-12-02 04:03:33 »

I'm interested in seeing the range of replies and suggestions. I have been programming Java for a year. My background is MS Access database & VBA programming. I have been using a 2D game project for learning Java.

I think the Graphics2D library is perfectly good for doing a Breakout or Pong, if that is what you want to do. There is a lot to learn in terms of game structure and basics. You would want to know how to use a Timer object, like java.util.Timer, for animation. And some Swing components, and how to integrate listeners for them. That would be a substantial start for stage I "bouncing ball" and stage II "Pong" or "Breakout" which mainly needs the ability to make a controllable paddle once you have the ball bouncing.

I am very much looking forward to getting into LWJGL! Haven't tried it out yet. For now, for sound, I've been using the javax.sound.sampled library. At first it was really confusing, but after becoming acquainted with the "Decorator" design pattern, I don't find the multiple nesting of objects quite so off-putting. But I hear that this library may not be the best in terms of doing sound, and am open to learning about other options. As a learning project for sound, I built a little windchime, and it runs and sounds great. So I don't know yet what the problem is with this library other than a rough learning curve.

I wouldn't worry about the Applet vs Application distinction. It is easy enough to convert from one to another when the time comes.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Ninja


Medals: 38



« Reply #3 - Posted 2010-12-02 09:44:13 »

I think the best way to get you up to start is to do Kev's space invaders tutorial http://www.cokeandcode.com/spaceinvaderstutorial. It even starts with Java2D and moves to OpenGL in the end, so it should be exactly the kind of experience you need to help you decide which route to follow.

Mathias - I Know What [you] Did Last Summer!
Offline gouessej
« Reply #4 - Posted 2010-12-02 13:15:07 »

If you want to use OpenGL in Java, think about JogAmp too (OpenGL, OpenGL-ES, OpenCL and OpenAL binding for Java):
http://jogamp.org

Offline fletchergames

Senior Member





« Reply #5 - Posted 2010-12-02 18:03:24 »

I stick with the basic stuff in AWT rather than using an outside library.  It's less to keep track of that way.

I did write my own basic widget system though - AWT and Swing really aren't that good for games.  I have one instance of JFrame that everything goes into, and I create my input events from the input events AWT sends me.  I also use the AWT for image loading because it takes care of hardware acceleration for me.

The games are make are mostly rather simplistic.  Even the more complicated game I'm trying to work on now doesn't have complicated graphics.
Offline jparril1

Junior Member





« Reply #6 - Posted 2010-12-03 16:42:31 »

Ok yea so Im planning on just making a few simple games using built in Java, then Ill learn a library to enhance things. Ive been trying to find a clear and concise tutorial on making games with built in java libraries... but most of them are really unorganized. Every one of them just throws code together without any structure, and its really hard for me to follow. It seems like there really arent any useful books either. Can you guys point me towards some valuable resources?
Offline psychopat316

Junior Newbie





« Reply #7 - Posted 2010-12-03 17:11:36 »

Killer Game programming in java : http://fivedots.coe.psu.ac.th/~ad/jg/
Offline cylab

JGO Ninja


Medals: 38



« Reply #8 - Posted 2010-12-03 17:13:14 »

Ive been trying to find a clear and concise tutorial on making games with built in java libraries...

Took a look at the one I posted?

Mathias - I Know What [you] Did Last Summer!
Offline jparril1

Junior Member





« Reply #9 - Posted 2010-12-03 18:44:23 »

Thanks psycho pat!

cylab:  OO crap I didnt even see that.. sorry man. thanks so much Ill check it out.

I was looking through "TheNewBostons" tutorials but he really confused me with his organization of code.. I just really got tripped up in the way he did things.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jparril1

Junior Member





« Reply #10 - Posted 2010-12-04 17:42:24 »

Ok I wanted to ask something. Im working Kevins tutorial for space invaders over at http://www.cokeandcode.com

Im pretty much following it, but what I dont get is how the hell is somebody supposed to go about learning and remembering all of these damn built in Java  classes and methods? Just my sprite class alone has types such as Sprite, Image,  GraphicsConfiguration, BufferedImage, etc... plus I am using methods like getClass(), getClassLoader(), getResource(), getLocalGraphicsEnvironment(), getDefaultScreenDevice(), getDefaultConfiguration(), etc.

I hate just copying this shit without knowing what each this is doing. The goal of this is for me to be able to do all of this on my own in the future and not follow someone else. But I feel like Im just copying his methods because there are just so many built in ones. He has his code commented but its doesnt help as to why we are doing these things.

I made a call: 
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();

Thats fine, but why??? Will the books like Killer Game Programming in Java explain these things to me so I can use them on my own?
Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2010-12-04 17:45:31 »

I'm afraid that's exactly what programming is all about.

Each of those methods and classes has very thorough Java documentation. You can look them all up online (or download the Javadocs), or they should be directly accessible from your IDE. (In Eclipse, for example, just open the Javadoc view, and then any method you hover over will show its documentation which for the core Java APIs is usually very comprehensive)

Eventually you'll learn about 10% of the API very well, and that's all you mostly need. Takes a few years. Took me about 10.

Cas Smiley

Offline jparril1

Junior Member





« Reply #12 - Posted 2010-12-04 18:20:46 »

I'm afraid that's exactly what programming is all about.

Each of those methods and classes has very thorough Java documentation. You can look them all up online (or download the Javadocs), or they should be directly accessible from your IDE. (In Eclipse, for example, just open the Javadoc view, and then any method you hover over will show its documentation which for the core Java APIs is usually very comprehensive)

Eventually you'll learn about 10% of the API very well, and that's all you mostly need. Takes a few years. Took me about 10.

Cas Smiley

Yes well thats fair..all of that is definitely true... but the biggest problem for me is that I cant figure out how I would know when I needed to use all of these things. Is all of that sort of the "backbone" of a Java game? So like getting the graphics environment and all that would be something all Java games would need to use? Im guessing the if an external API is used like JOGL or LWJGL , I would no longer use these built in Java methods?
Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2010-12-04 18:36:29 »

LWJGL is a complete API unto itself really. Init code can be just a single line:
1  
Display.create();

but then you have to learn OpenGL...

Cas Smiley

Offline fireside

Senior Newbie





« Reply #14 - Posted 2010-12-04 18:55:31 »

Quote
but the biggest problem for me is that I cant figure out how I would know when I needed to use all of these things.

That's why I really don't agree with trying to start on the internal libraries.  I think it's better to pick a useful library and learn it well.  I know I don't understand a lot, but I don't really care.  I just want to write games.  The nice thing about java is that it's class based and I can add functionality by extending classes.  That's a lot better than trying to do things with scripts in my book.
Offline jparril1

Junior Member





« Reply #15 - Posted 2010-12-05 16:47:18 »

Ok so is the general recommendation for me to just stick with the Java base libraries for a while and get comfortable making games with it... then move onto a more extensive library once I need functionality beyond the scope of built in Java graphics? Or would diving into LWJGL right off the bat be better? The books I have "Killer game Programming in Java" as well as a few others tend to rely heavily on built in JAVA API's, so maybe sticking with them right now makes sense so that I can make use of books? Right now using built in Java for games is confusing the shit out of me, so if moving to another library with deeper functionality will only be worse, it doesnt make sense to do that at this point.
Offline philfrei
« Reply #16 - Posted 2010-12-08 02:53:34 »

You can always ask questions here about the things in core Java that are confusing! Better to clear them up sooner rather than later, I would think.

Sometimes more advanced libraries make things much easier, sometimes they propagate misconceptions that really should be dealt with. But you know that.

I just (last two days) tried my hand at making a game tutorial, with an emphasis on the things in core Java that I personally found confusing, and posted it in the tutorials section above. Would love to have some feedback if you take a look at it. But it might be pitched at too easy a level for what you are looking for.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline jparril1

Junior Member





« Reply #17 - Posted 2010-12-08 04:59:05 »

thanks philfrei. Ill check out the tutorial.

I think Im going to go the route of getting comfortable with the base java graphics library, and then ease my way into opengl and LWJGL. As far as my level, I think I am a pretty advanced Java programmer. I am by no means a master of the language, but Ive been using it for many years now, just nothing graphical. Game programming is proving to be a totally different evil than general app programming. The game logic part is sort of tough for me, but Im catching on rather quickly. Its the graphics that are killing me. I think its just the whole idea of the Canvas and JFrame and Buffering, etc. Plus I still have no idea what a graphics context is! I think I need to read the java docs a bit better and really try to understand whats happening. doing that plus following tutorials plus reading source code should do it.

 I am not by any means trying to find an easy way, i know that this stuff isnt easy... I never thought it would be. Im ready to bust my ass and learn
Offline philfrei
« Reply #18 - Posted 2010-12-08 05:44:37 »

You are probably ahead of me in many aspects then, as far as Java programming. But I have been spending some time with various aspects of graphics while working on a puzzle game, so I might be able to help a bit. Helps to have a concrete question.

There's a LOT of good stuff in the Graphics2D library. Sounds like you may already be aware of these tutorials, but just in case:
http://download.oracle.com/javase/tutorial/2d/index.html

I frankly haven't looked into the "Canvas" as an object for displaying. I'm not even sure what it is. AFAIK, a JPanel is perfectly fine for display. Could someone say why prefer a Canvas to a JPanel? I can't find any references to "Canvas" object in Horstmann's Core Java 8th ed. And JPanel has built in double buffering. I've been able to display repaints in the teens (in terms of milliseconds), for example at www.adonax.com/Jean/BotBlocker/ if you'd like to see my amusing captcha fiasco. (Commentary in "Miscellaneous Topics" was very educational.)

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Captain Awesome

Junior Member


Medals: 2


Hi


« Reply #19 - Posted 2010-12-08 10:40:48 »

You are probably ahead of me in many aspects then, as far as Java programming. But I have been spending some time with various aspects of graphics while working on a puzzle game, so I might be able to help a bit. Helps to have a concrete question.

There's a LOT of good stuff in the Graphics2D library. Sounds like you may already be aware of these tutorials, but just in case:
http://download.oracle.com/javase/tutorial/2d/index.html

I frankly haven't looked into the "Canvas" as an object for displaying. I'm not even sure what it is. AFAIK, a JPanel is perfectly fine for display. Could someone say why prefer a Canvas to a JPanel? I can't find any references to "Canvas" object in Horstmann's Core Java 8th ed. And JPanel has built in double buffering. I've been able to display repaints in the teens (in terms of milliseconds), for example at www.adonax.com/Jean/BotBlocker/ if you'd like to see my amusing captcha fiasco. (Commentary in "Miscellaneous Topics" was very educational.)


With a Canvas, you have full control over when the screen is repainted. With a JPanel, you're basically tellingt the EDT to "repaint this when you have time".
I recommend using a Canvas for games since it provides much smoother gameplay than a JPanel. It's very easy to implement doublebuffer on a canvas as well.
Offline mhogshaw

Junior Newbie





« Reply #20 - Posted 2010-12-08 15:28:19 »

Hi i am trying to create a 2d racing game and i am stuck with code to get my AI to go around the track could any1 help??

This is what i have currently got with a million errors
  // Pathfollowing + seek behaviour
        // To get acceleration which updates velocity
       
       
        FollowPath(Object source, Path path, float pathOffset);
        {
       
        float pathPosition = path.getPathPosition(source.position);
        float targetPathPosition = pathPosition + pathOffset;
        Vector target = path.getPosition(targetPathPosition);
       
        acceleration = Seek(source.position, target);
       
        Vector velocity = new Vector();
        velocity.x += acceleration.x * timeDelta;
        velocity.y += acceleration.y * timeDelta;
        // veclocity.x += acceleration.x * timeDelta;
        // veclocity.y += acceleration.y * timeDelta;
        }

Any help would be greatly appreciated thanks
Offline SimonH
« Reply #21 - Posted 2010-12-08 20:21:12 »

Hi i am trying to create a 2d racing game and i am stuck with code to get my AI to go around the track could any1 help??
Have a look here. There's loads of other useful stuff!

People make games and games make people
Offline philfrei
« Reply #22 - Posted 2010-12-09 00:57:57 »

Thanks for the explanation Captain Awesome!

I also found this tutorial:
http://download.oracle.com/javase/tutorial/extra/fullscreen/index.html
>>Do you want to use high-performance graphics in the Java development environment? Have you always wanted to program a game, but your images wouldn't move fast enough? Has your slide show program not worked properly because you had no control over the user's display resolution? If you've been asking any of these questions, then the full-screen exclusive mode API, introduced in release 1.4, may be what you're looking for.<<

This will be my next learning step in terms of handling graphics, though for the puzzle-game I am working on, the Timer-driven repaints of the JPanel are quite adequate.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline jparril1

Junior Member





« Reply #23 - Posted 2010-12-09 02:47:17 »

Lol Mhogshaw you should probably create a new thread if you have a specific question, just throwing youre unrelated question in the middle of a conversation is hijacking Smiley

And thanks so much philfrei and captain awesome. I think I know where Im headed and approximately how to get there. For now Ill be running through the various tutorials that I found/was given that use basic Java 2D and other internal libraries. Then I will slowly introduce myself to LWJGL and opengl in general with books or other resources. To me that seems like the logical path.
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.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (19 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!