Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Dec 2011
Offline Last Active Apr 12 2015 11:35 AM

#5203317 Killer game programming in java

Posted by on 10 January 2015 - 01:57 PM

Killer Game Programming in Java has a bit of useful beginner information in it but I would just avoid it now because of its age. I bought it two years ago and it was out-dated then. The entire 3D section is a bit useless now, unless you want to use Java3D. 


Having trouble remembering good beginner books.. A good way to learn game development would be through a Youtube video series. It's almost like having a teacher. TheCherno has a big Java game development series which goes over the same kind of stuff Killer Game Programming does (game loops, graphics, input, etc). It's a 112 episodes so I imagine it goes over all the very basics of game development. 


On another note, touching up on your maths would be a good idea if you're just starting out. There's a whole lot of mathematics when it comes to game development (especially with the graphics programming).


Have fun learning gamedev

#5157761 Rigidbody Attraction Orbit

Posted by on 03 June 2014 - 02:45 AM

Using the same way I described could be used to create a really stiff connection but it would need to be changed. It wouldn't be a solid connection, per say, but to the player it would look pretty solid, in my opinion. 


First of all, the multiplier would have to changed using an equation based on distance, instead of 3 set values so that the bodies are held at a certain distance, which would be the minimum distance. The nice thing about this method is that the minimum force required to separate the objects would be just be anything bigger than the force holding them together. 


So something like this:

if(distance < minDistance){

    force = -connectionStrength / (minDistance-distance);

else if(distance > minDistance && distance < maxDistance){

    force = connectionStrength / (minDistance-distance);

else if (distance > maxDistance) {

    force = 1/distance;


This may not work properly because you're dealing with acceleration. I think the rigid body might bounce around. I'll have to test this myself and get back to you. 

#5046066 First Pong Game - Code review

Posted by on 23 March 2013 - 04:19 PM

Yeah I imported your project into eclipse and I found a few problems at the start.

On starting, it gave me an error with loading the images from the project. I found that this was because you were loading the image by reading from a URL instead of the folder that you're running from (might be because it's an applet but I'm not sure). Anyway, I found a bunch load of junk-code when you're importing images. I'm just going to make the assumption that this isn't meant to be an applet (because if it isn't then you don't need ALL the image load code that you have).


Ok so I can't remember what your image loading code was but it was in the SpriteStore class in the getSprite function.

The entire block can either be shortened by one of two ways.


			System.out.println("Importing Image:" + ref);
			Image image = ImageIO.read(new File(ref));
			Sprite sprite = new Sprite(image);
			sprites.put(ref, sprite);

			return sprite;
		}catch(Exception e){
			System.out.println(ref + " does not exist");
		return null;


or if you want just 3 lines:



Sprite sprite = new Sprite(new ImageIcon(ref).getImage());
sprites.put(ref, sprite);
return sprite;




Also, Ball.png was corrupt when I downloaded it. Might just be my WinRar but I thought I should tell you just in case.


All in all, I think the code is pretty good and well commented. It's very easy to see what's going on in the code which is a very good thing.


My tips for future games:

I see that you have all of your game logic code, window code and window animation code in one class. My tip for the future would be to write the game logic in its own class. This class could extend an abstract class called State which has 3 abstract methods init(), update(), and render(Graphics g). Then you could have an application holder class which would be created by passing an instance of a class extends from the State class. Sooo for example:

EDIT: this isn't supposed to be a quote.

public class Pong extends State{

     public void init(){
              //Initialize crap in here
     public void update(){
           //All of the update logic EG checking for collisions and resolving
     public void render(Graphics G){
           //Do all your drawing code here

public class AppHolder extends JPanel implements Runnable {

     State state;

     public AppHolder(State state){
          this.state = state;
          Thread thread = new Thread(this);

     public void run(){
     public void paint(Graphics g){


Then you can just initialize a JFrame and add a new instance of AppHolder and it'll do the crap.

The reason that this is better (not necessarily this but the general structure) is because you'll have to re-write a bunch of crap-ass initialization code if you want something like a main screen. Or, if you just put it all in the Game class then the game class will begin to be cluttered and ugly. Having this structure means you can just access the AppHolder class and set the state object to a new one such as MainScreen that extends state and do all the mainscreen logic and drawing in there. 

After you get more advanced you can start using the more complicated, flexible game architecture types. This is just one that will make the work easier in the long run.


Anyway, I'm bored of writing, hope this helps!

Also, sorry if I made any mistakes, it's pretty late.

#5040967 Little help needed

Posted by on 08 March 2013 - 03:59 PM

Well, if you don't want to pass it around as a reference and you only need one instance of it then you can just make a static Input object. Then, all you have to do is use the static object instead of passing it as a reference everywhere.

I'm not sure how you would do it in C++. 

Have a main.cpp or something then declare a namespace, then inside that namespace have a static Input object then all you have to do is: namespaceName::input.something().

Not sure if that'll work though, I'm not very proficient in C++.

#5028304 how determined they composed the coordinates of the area of all polygons?

Posted by on 03 February 2013 - 05:28 AM

1. You're in the wrong section.

2. Your wording is sloppy, explain your question again. Do you want to found out the area of the intersection, the area of each polygon or the area of the entire thing?

#5019588 Is it such possible to create fast games without using C/C++ ?

Posted by on 09 January 2013 - 01:47 PM

When I was asking this question I decided to email and 'industry veteran'. He said that when he employs people he is looking for C++ developers. As a Java coder wanting to be a game developer, this kind of gave me the urge to learn C++. In my opinion, I think C++ gives you a lot more access to your machine and code (if that makes sense) whilst Java is a lot easier to code. But, this could just be because I've been coding in Java for two or so years.


The only problem I ever have with C++ is trying to use external libraries. The Windows SDK sucks ass and requires a lot more code than writing windows apps in Java. I always get compiler errors from Visual C++ and it usually takes me an hour or two (3 days in the case of CUDA) to get the IDE to stop being a pain in the ass. In the case of Java, it's just referencing a single file then writing your code. In the case of C++, add a bunch of DLLs to here and here then add these include files to your compiler's include folder.... It's just a pain in the ass. I wonder if there's a way to write straight to the graphics card in C++ so I don't have to bother with any external libraries.


My advice would be that C++ is a good choice but if it's too hard at the start you should try an easier language and move onto C++ later.

#5015134 How easy is it to collaborate on a game remotely?

Posted by on 28 December 2012 - 01:02 PM

From personal experience, whenever I've joined a team from the classified section, it all starts out really well. Everyone is ambitious and want to create a good game.


Firstly, where it's failed for me is when the other members are from vastly different time zones. It means that you have to either wake up early to get some decision work done or stay up late. Sure, programming wise it's very easy to do because all you need is a list of things needing to be added to the game and you add it whilst everyone else is offline but, by the time you've gotten a basic concept written down, all the ambition is gone from the frustration of not being able to communicate properly.


Secondly, I find that organization in the project is always lacking unless there is someone leading the project. When it comes to team decisions it sometimes goes out of hand and people tend to disagree with other peoples ideas which can aggravate people. When it comes to deciding what to develop, if the team is comprised of non-programmers or nooby starting out programmers, people decide on the higher level of development instead of thinking of the development in a detailed way. For instance, someone in the team who is a ignorant nooby programmer or an ambitious game developer (etc) thinks: Concept(demo game), kickstarter, game, steam. This is wrong because it leaves lots of the development to be made up as it goes along. What a team should be doing is split each part into modules.

So for concept one of the modules would be engine which would have separate modules in itself, graphics, physics, world, etc.


Anyway, I'm sure collaborations work but this is just from my experience in the past.

#5000679 Strange "Double Jumping" Behavior + Momentum Question

Posted by on 13 November 2012 - 03:29 PM

I'm not sure what you are asking in your momentum section but your double jump could be solved by two boolean switches. The first boolean sets to true if the player presses the jump button when on the floor. The second boolean sets to true if the first boolean is true and the player is in the air and if the second boolean is false to start with. The player only jumps if one of the booleans are false. So first jump sets boolean 1 to true then if the player hits the ground it sets back to false. Second boolean sets to true if the player jumps in the air again but if he tries to do it a third time then he can't because both booleans are true.

When you do your collision detection it's only checking at point A and B of it's trajectory meaning that it misses collisions when the velocity is greater than the size. So if a 10*10 pixel square is going 100 pixel velocity then it's missing out 10 potential collisions. To solve this you are finding the previous position then incrementing the position by the size of the object then checking collision at that point all in one game update. This could cause lag when travelling fast but it will stop bugs.
I could draw a diagram if it helps because I'm finding hard to explain.
Here is an example.
Your player is moving downwards at 300 pixels and update. The floor has a y position of 400 and a height of 20 so the floor covers 400 - 420. The player's y position is 300 and the players height is 50. When it checks collision they don't collide because they aren't touching at that point. The game updates and the player moves downwards to y position 600. The collision still brings back nothing because the floor and player aren't touching at that point even though the player has travelled through the floor. To fix this you have to check the collision at each point of the velocity.
So, in one game update, check collision at 350, 400, 450, 500, 550, 600. The player will collide at 400. To do the segmented collision detection all you have to do is divide the velocity by the height of the player (6) which gives you the amount of detections you need to do that update. Then you do:
for(int i = 0; i < amountOfDetections; i++){
checkCollision(previousYPosition + (i*height));
this will do the 350, 400, 450... thing and detect all possible collisions.
There may be a faster way to do this but this is what I came up with.

#4997700 Potion Making Adventure Game. Viable Game Type?

Posted by on 05 November 2012 - 01:54 PM

Right now you have an interesting idea, a concept.
It would be nice if you update your first post and expend it a bit. Give details.
For example, do I have to complete a dungeon for each ingredient? Or do I find all the ingredients that are needed to make one potion in one dungeon?
Also you call the book "Potion Brewing - Basics", does this mean that the book can be upgraded or new books can be found?
What kind of game could this be implemented in?

I definitely agree that potion making as been a bore in the past; even Minecraft made the process of making a potion a bit tedious (They don't give you a recipe book!) However, your idea sounds fun so make sure to expand it.

Yes I'm going to come up with a full concept of which I will add to over time. I'm going to write the full concept and add it to the main post along with a bullet point list of all the ideas I come up with which I will think about and expand upon. I think as soon as I've come up with a relatively finished concept I'm going to start imagining the world.

As for the dungeons, I had the idea that different ingredients would need to be found in different environments. Dungeons would be one environment which would contain little grown ingredients but more living creatures that you can kill to harvest ingredients from (Rat hair or a beholder eye for example). Other environments would include things like forests which contain several rare grown ingredients but are defended by strong, non-rare creatures. Although, I'll have to think a bit more about the environments idea and how it would work with the basic concept and kind of feel I want for the game. I would imagine that you would be able to find multiple ingredients in certain places but depending on their rareness they could be defended by creatures or just things you come across.

Yeah I'm sorry for the vagueness, I didn't really expand upon most of the ideas. I had the idea that the only kind of guide book you would have is the "Potion Brewing - Basics" book which would tell you how to find basic ingredients and how to process them and, finally, turn them into potions (A bit like one of those tutorials you get in a game). Other, rarer ingredients would only have things like folklore or myths which would contain secrets on how to find them and brew them into potions. I think this wouldn't be too practical though because if you accidentally brew it wrong you have lost it forever. Unless you had the option to chop the ingredient up and only use a certain amount at a time to experiment or even if the potion had a limit to how much of the ingredient could be included until the potion turned into junk.

I've been thinking of how I could implement this concept into a game and I can't really decide what would be best. I was thinking that a 3D game would be too much work because you would have to model every ingredient along with modelling the world and programming the engine. A 2D game, on the other hand, would be a lot easier and mean that I could use a variety of art styles. Then I come onto the decision of top-down, isometric or platform based rendering. I guess I'll just have to come up with all the pros and cons of each one to see which one would be the coolest yet most practical.

Thanks for the feedback!

#4997044 Potion Making Adventure Game. Viable Game Type?

Posted by on 03 November 2012 - 07:12 PM

I've seen a few games about brewing potions but they do sound quite different from this concept - they are more like a real-time sim where the player grows plants or tends animals to get the brewing ingredients. The goal of the actual brewing is mainly to unlock new levels of sim, though it also generates money to spend on plants/animals/upgrades/consumbable bonuses. Or the potions themselves can be the consumable bonuses.

Yeah it does sound a bit different. I guess the main difference would be that the rarer ingredients would have to be taken through some sort
of danger. For instance, you are looking for troll saliva which is hard to extract from a live troll so you will have to slay one but to do this you need to be strong enough which would mean drinking a potion to enhance your body (a potion that transforms you into a wolf for example). So to be able to progress in the game you would need to get ingredients that make stronger potions that help you get ingredients to make even stronger potions.

#4997041 Potion Making Adventure Game. Viable Game Type?

Posted by on 03 November 2012 - 07:03 PM

Newly discovered potions could be named by the player along with having different coloured bottles so the player can colour code his/her collection.

I don't know what platforms you are looking at, but to me this particular idea just screams to be included in a social game, and it could be a bit of a race and a big deal to be the first player to discover how to create a new potion -- particularly if it was a very useful one.

Just standard indie PC game. I'm going to write it in Java so if I decide to port it to android then it may be a little easier. I would imagine that after something is discovered then people would just share the information which, I guess, destroys the element of discovery in the game. I doubt anything like this would be popular enough to get any online guides anyway ;)
I'm thinking that finishing the game then putting it on steam green light is a good idea but I don't know much about green light really.

#4997022 Potion Making Adventure Game. Viable Game Type?

Posted by on 03 November 2012 - 06:06 PM

Sounds like an interesting concept, and something a bit different from the norm! As usual, the devil is in the details, and whether or not it is actually fun would depend on the execution.

ground the ingredient with a mortar and pestle. This would include hitting the ingredient by clicking with the mouse

This sounds like it might get tedious and frustrating, especially if it's something that has to be done often. It would probably be a great mechanic for a different input device like the touch stylus on a DS, a WiiMote, or perhaps even Kinect, although obviously those options may not be available to you. It could also be well suited to a touch screen, but unfortunately the adventuring aspects would likely be much less so unless you could come up with a different approach.

Yes, it does sound like it would become rather tedious. Although, one idea I had would be that the mortar and pestle would have to include some sort of accuracy to keep it interresting. The player would have to crush the ingredients based on the instructions provided. For instance, you have to break a certain ingredient to a 'not too fine' consistency and player would have to guess whether they have broken the ingredient down to that consistency without any other help apart from the vague scrawlings in the book.

Another idea I had would be that, past a certain level, a lot of ingredients would have no knowledge to them whatsoever and the player would have to experiment to find the functions of these ingredients. The player would have an empty bookshelf where he/she could fill with journals full of information and diagrams which the player would write. Like a personal encyclopaedia. This would be useful due to the sheer number of ingredients and potions which could be made. Newly discovered potions could be named by the player along with having different coloured bottles so the player can colour code his/her collection.

Thanks for your feedback.

#4997007 Potion Making Adventure Game. Viable Game Type?

Posted by on 03 November 2012 - 05:28 PM

I've been thinking of different game ideas for my next project and I thought this game idea was the most interesting and unique (in my opinion).
I have been playing the elder scrolls series and I've noticed that, even though alchemy is used a lot in the game, it is not at all fun or interesting. There is little fun in making different combinations of ingredients with practically no interaction or research involved.

So, I decided I wanted to make a potion making game. I also wanted the potions in the game to have a use so I've decided to incorporate some kind of a dungeon crawling aspect. I want to make finding the ingredients fun. I don't want it to be like in Skyrim where you happen to come across an ingredient, I want it to be a search for a certain ingredient. I have the idea that the player would be given a book at the start of the game which could be called something like "Potion Brewing - Basics" where the player would gain all the knowledge to make basic potions. You would have guides on identifying certain ingredients, constructing tools to help make the potions and guides on making the potions all together.
I want the potion making to be incredibly interactive. For instance, you want to make a potion that helps you see in the dark but before you can do this you have to get a certain ingredient then ground the ingredient with a mortar and pestle. This would include hitting the ingredient by clicking with the mouse ;)
The adventuring aspect of the game would be requiring rare ingredients. First of all, you would be able to make basic potions with ingredients which grow in safe areas. You would then use the potions you have made to make you better at combat to then slay creatures to harvest ingredients for their bodies or to get past them to get access to these ingredients.

Inspirations for this idea come from The Elder Scrolls series and a Harry Potter movie (The Half Blood Prince to be exact).

This is a work in progress idea and I would love to get constructive criticism or questions regarding the idea. I'll be sure to keep gamedev.net updated when I start to develop the game.
I've decided to give it the working name: Potius Dominus
It's Latin for Potions Master. I thought calling the working title Potions Master would be a bit cliché, hence the Latin. Potius isn't actually Latin for potion. The Latin should actually be Potio but I thought it didn't sound right.

#4979328 [SOLVED] 2d cordinate rotation in 3d space

Posted by on 12 September 2012 - 09:14 AM

Good afternoon!

I am stuck on a little math problem and i dont know how to solve it.
I want to force Object A rotate around Object B. 2d math does it well.

x = -sin(angle) * distanceFromTarget + target->x
y = cos(angle) * distanceFromTarget + target->y
z = target->z

Everything works fine. But i have no idea how to adjust the angle of orbit math wise. I can simply do stuff like glRotatef(90, 1, 0, 0) and it will do the trick, but i want to have exact cords without using GL calls. Furthermore, i dont want to be bound only to one axis.

To make my question more precise - How to "bend" my orbit mathematically?

I'm not sure what you mean. If you want to change your angle around of the object orbiting another object all you have to do is change the angle variable in your equation then use glTranslate to move the object (make sure you call glLoadIdentity() every update). Or, you could just do glRotate but it depends what you want to do. Using glTranslate then glRotate probably mess everything up so make sure it's the other way around. Also, you can just have a separate angle of each axis so your call is not bound to a single axis. For instance, glRotate(xAngle,etc); glRotate(yAngle, etc);
Not sure what you're asking though so if you could reword it then that would be easier to answer.

#4970245 Rotating Images With Angles On KeyPresses

Posted by on 16 August 2012 - 11:12 AM

Your best bet is to use a class called AffineTransform. To rotate an image:
public void paint(Graphics g){
Graphics2D g2d = (Graphics2D) g;
Image derp;
//Get the image
AffineTransform form = new AffineTransform();
form.rotate(angle); //Cant really remember this part. Google how to do it?