Eyesackery
|
 |
«
Posted
2012-07-04 01:45:26 » |
|
Hey guys I'm new to these forums, as well as being relatively new to games programming with Java. I've done a introductory course at University on Java and I'm super keen to get neck deep in some serious games coding! So far I've just been doing tutorials on-line based around clones of old arcade games like pong, pacman, tetris, etc. They have been fun but the challenge is kind of lost seeing as all the code for the games are provided for you! Although I have learned a lot within the Java 2D library and have become fairly confident in OOP design and implementation. Here is what I propose to anyone with any spare time and an interest in helping a new enthusiastic coder. I need a problem to work on, that is relatively basic yet still challenging. The idea being I will post all my progress in this thread and everyone can offer suggestions or give 'hints' to the problems that I may face. The problem doesn't have to be huge, maybe even something as simple as move a sprite with the keyboard and shoot at a target, that sort of thing. I may be going out on a limb here, but I know there are some seriously talented programmers on these forums! I see this as a awesome learning experience. Thanks for your time! ( please excuse my enthusiasm! ) 
|
|
|
|
ra4king
|
 |
«
Reply #1 - Posted
2012-07-04 02:09:35 » |
|
Welcome to JGO, Eyesackery! I love your enthusiasm for making games! Keep it up and you will go far in life, but don't get bogged down by the 'boring' parts  Based on your experience, I say you should start learning OpenGL to be able to grasp the full power of the graphics card to make some visually attractive games. Good luck! 
|
|
|
|
Eyesackery
|
 |
«
Reply #2 - Posted
2012-07-04 02:19:50 » |
|
Thank you for your suggestion ra4king  Eep! OpenGL and 3D programming seems a little daunting to me but I'm up for the challenge! Can you suggest any good material on-line to get me started?
|
|
|
|
Games published by our own members! Check 'em out!
|
|
ra4king
|
 |
«
Reply #3 - Posted
2012-07-04 05:07:22 » |
|
You're in luck! These tutorials are the best around. However, the code is in C++ but you can find the LWJGL ports over here. However, if you are confident enough that you don't need someone's else code, you can very easily "port" the C++ code yourself. Since LWJGL copies almost all functions exactly, it is safe to assume all functions you see that start with 'gl' are almost exactly the same as in LWJGL. Only one exception, function calls starting with 'glut' is just the windowing API. In LWJGL, that's simply your Display class.
|
|
|
|
Sickan
|
 |
«
Reply #4 - Posted
2012-07-04 06:59:21 » |
|
You're in luck! These tutorials are the best around. However, the code is in C++ but you can find the LWJGL ports over here. However, if you are confident enough that you don't need someone's else code, you can very easily "port" the C++ code yourself. Since LWJGL copies almost all functions exactly, it is safe to assume all functions you see that start with 'gl' are almost exactly the same as in LWJGL. Only one exception, function calls starting with 'glut' is just the windowing API. In LWJGL, that's simply your Display class. What about these tutorials? They're also pretty great.
|
|
|
|
ra4king
|
 |
«
Reply #5 - Posted
2012-07-04 07:20:01 » |
|
I heard those articles are really old and outdated. If they have been updated, I'm not aware of it.
The tutorial I linked to is an excellent tutorial on modern OpenGL.
|
|
|
|
Jimmt
|
 |
«
Reply #6 - Posted
2012-07-04 08:45:28 » |
|
You might want to make something in java2d before OpenGL. As for the actual project, how about: -a scrolling shooter -street fighter style game -tower defense
You can make pretty simple games of the above type.
|
|
|
|
pjt33
|
 |
«
Reply #7 - Posted
2012-07-04 21:34:40 » |
|
I need a problem to work on, that is relatively basic yet still challenging. Write an early entry for next year's Java4k contest. Plenty of material in the relevant subforum.
|
|
|
|
Eyesackery
|
 |
«
Reply #8 - Posted
2012-07-06 04:37:20 » |
|
Thanks a lot for the awesome replies guys! Very much appreciated!  @ra4king - That book looks great! Definitely going to set aside some study time for those! Thank you! @Sickan - That website looks awesome too, lots of information on beginning games programming in OpenGL, thanks! @Jimmt - Thanks for the suggestions man! I've been kind of working on a little project I'll talk more about it below  @pjt33 - That sounds like a very good plan, why didn't I think of that!? haha, thanks man.  So I jumped the gun a little and have been working on a bit of a project for the last few days, based of a few tutorials laying around online. However I'm stuck! I'm trying to implement a "point and shoot at mouse", type of function, and so far I have been able to get the angle and position of the mouse on mouse clicks. The ship is at the bottom of the screen shooting upwards, so I only use 180 degrees in the equation. But I'm stumped as to how to fire at that position? This is how I'm calculating the angle and position of the mouse currently. 1 2
| double anglePi = Math.atan2(mouseY - ship.y, mouseX - ship.x) * 60; int angle = (int) Math.abs(anglePi); |
|
|
|
|
ra4king
|
 |
«
Reply #9 - Posted
2012-07-06 04:46:50 » |
|
Math.atan2 returns an angle in radians, not degrees so leave it as a double  Multiplying an angle by 60 (or anything) makes no sense really  Also, negative degrees/radians is definitely not the same as positive degrees/radians.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
|
pjt33
|
 |
«
Reply #11 - Posted
2012-07-06 06:23:44 » |
|
Multiplying an angle by 60 (or anything) makes no sense really  That's not true. Multiplying by 60 and then truncating is an effective way to quantise, which is necessary if you use prerendered graphics in N rotations or convenient if you use lookup tables for trig.
|
|
|
|
ra4king
|
 |
«
Reply #12 - Posted
2012-07-06 07:42:31 » |
|
Multiplying an angle by 60 (or anything) makes no sense really  That's not true. Multiplying by 60 and then truncating is an effective way to quantise, which is necessary if you use prerendered graphics in N rotations or convenient if you use lookup tables for trig. Hey there's that swooshing sound over my head again! 
|
|
|
|
Eyesackery
|
 |
«
Reply #13 - Posted
2012-07-07 04:15:52 » |
|
So I've been cruising through the space invaders 101 tutorial on coke and code ( http://www.cokeandcode.com/index.html?page=tutorials/spaceinvaders101), and have been trying to do some of the challenges after the tutorials. I'm having trouble with getting the aliens to fire back. To me this looks like it should be working, but unfortunately it does not. Any help or hints would be very much appreciated, this has been so frustrating  . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| for (int i = 0; i < entities.size(); i++){ Entity entity = (Entity) entities.get(i); if (entity.equals(alien)) { randomAlien = rand.nextInt(entities.size()); Entity alienShooting = (Entity) entities.get(randomAlien); alienShot = new AlienShotEntity(this,"sprites/shot.gif",alienShooting.getX() + 13,alienShooting.getY(), angle); entities.add(alienShot); break; } } |
|
|
|
|
ra4king
|
 |
«
Reply #14 - Posted
2012-07-07 04:28:49 » |
|
What's the "alien" variable? If you have many aliens, why are you only checking against 1?
|
|
|
|
Eyesackery
|
 |
«
Reply #15 - Posted
2012-07-07 04:39:15 » |
|
I'm trying to check for every 'alien' in the array list. I'm not very confident with array lists 
|
|
|
|
ra4king
|
 |
«
Reply #16 - Posted
2012-07-07 05:00:15 » |
|
"entity.equals(alien)" <== that checks against only 1 instance of alien. If you want to check if an Entity is an instance of Alien, you would want: "if(entity instanceof Alien)" or whatever your Alien class is called.
|
|
|
|
Eyesackery
|
 |
«
Reply #17 - Posted
2012-07-07 05:09:39 » |
|
Ra4king! I think I love you!! Haha.  that solved my problem, thank you! I have been pulling my Hair out for hours over that one! Cheers!
|
|
|
|
ra4king
|
 |
«
Reply #18 - Posted
2012-07-07 06:42:07 » |
|
Haha glad to help 
|
|
|
|
Eyesackery
|
 |
«
Reply #19 - Posted
2012-07-11 11:51:47 » |
|
Hi guys, still been working away at my little Java 2D project and have had a million ideas for a more in depth game. I can finally see how it's possible to build games from my own imagination now, which is exciting!  Like you guys suggested I'm going to start becoming familiar with OpenGL and the JLWGL. I'm under the impression that the only way to use the JLWGL is through Slick2D? I'm a little confused, are JLWGL and Slick2D just 2 different libraries? How do they work together? If I wanted to user the JLWGL and Slick2D for my next project, where should I start? ( where/how to learn ). Here's a little screen of what I've been working on. 
|
|
|
|
|
Eyesackery
|
 |
«
Reply #21 - Posted
2012-07-11 12:06:54 » |
|
God I'm an idiot sometimes!  I hate being a total noob, it's embarrassing! Cheers for the links man! Will get cracking on those tutorials first thing 
|
|
|
|
ra4king
|
 |
«
Reply #22 - Posted
2012-07-11 12:31:48 » |
|
Sweet screenshot! How did you do that deterioration of the shields effect?
Concerning Slick2D, it's a wrapper over LWJGL. It has an API very similar to Java2D but it uses LWJGL underneath. It's mainly for people who want to make games with full hardware acceleration but don't want to get into the specifics of OpenGL.
|
|
|
|
Eyesackery
|
 |
«
Reply #23 - Posted
2012-07-11 13:44:02 » |
|
Sweet screenshot! How did you do that deterioration of the shields effect?
Concerning Slick2D, it's a wrapper over LWJGL. It has an API very similar to Java2D but it uses LWJGL underneath. It's mainly for people who want to make games with full hardware acceleration but don't want to get into the specifics of OpenGL.
Thanks man!  For the deterioration effect I just had 4 different sprites loaded into an array, (no damage, little damage, little more damage, and really damaged). Then depending on the "health" of the shields an appropriate sprite was displayed. That makes total sense now, thanks for explaining that.
|
|
|
|
davedes
|
 |
«
Reply #24 - Posted
2012-07-11 14:03:48 » |
|
Just a heads up -- Slick's website is currently out of date. For the latest version of Slick, you should pull it from bitbucket. More info: http://slick.javaunlimited.net/viewtopic.php?f=3&t=5171I'd also suggest upgrading to the latest LWJGL since Slick ships with an older version.
|
|
|
|
Eyesackery
|
 |
«
Reply #25 - Posted
2012-07-12 01:00:43 » |
|
Just a heads up -- Slick's website is currently out of date. For the latest version of Slick, you should pull it from bitbucket. More info: http://slick.javaunlimited.net/viewtopic.php?f=3&t=5171I'd also suggest upgrading to the latest LWJGL since Slick ships with an older version. Sweet, thanks for the heads up! I'm really liking Slick so far, it makes everything so easy!  Let's you fully concentrate on the awesome game you want to make, without having to worry about to many technical limitations.
|
|
|
|
|