Java-Gaming.org
 Featured games (91) games approved by the League of Dukes Games in Showcase (579) 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
 Show Posts Pages: [1] 2 3 ... 16
1  Game Development / Game Mechanics / Re: A* path finding on: 2014-04-15 02:03:05
When each node takes only 1 to move between (A flat cost map) then you don't need to do anything. It's when you have maps of different costs (Say, moving from a road to a swamp in a strategy game, or going up stairs or something) then you have to worry about it.

What you can do when it comes to the out of bounds things is use some method call to get the nodes:
 1  2  3  4  5  6  7  8 `private static Node nullNode = new Node(-1, -1);public Node getNode(Node parent, int x, int y) {if(x < 0 || x >= boundsX || y < 0 || y >= boundsY) {return nullNode} else {return new Node(parent, x, y);}}`
2  Game Development / Game Mechanics / Re: A* path finding on: 2014-04-14 17:37:37
There were several other issues in the code that I found during exploration.

What you got here:
 1  2  3 `            if(!found1 && !found2 && node.f <= q.f) {               open.add(node);            }`

This is not the way to fix it with obstakles, but you can see what goes wrong

Won't help because of some of the other typo issues, primarily:
 1  2  3 `node.g = q.g + manhattanDistance(node, q);            node.h = manhattanDistance(node, goal);            node.f = node.g + node.h;`

Which is computing the g value wrong for all nodes (G value is the ACTUAL TRAVELED DISTANCE!) so this is giving bad values.

This file: http://www.java-gaming.org/?action=pastebin&id=898 gives you the right value and has some other misc corrections. You still end up exploring negative areas though. This version also cuts out when the F of the 'next shortest path' is greater than the best (Which is an important part of A*. )

Edit: Changing the link to one that high lights the changes.
3  Game Development / Game Mechanics / Re: A* path finding on: 2014-04-14 17:21:36
And another problem:

 1  2  3 `      Node q = null;      while(open.size() > 0) {         q = null;`

You need to set q == null at the start of each loop.
4  Game Development / Game Mechanics / Re: A* path finding on: 2014-04-14 17:04:15
I caught the problem I think.

 1  2  3  4  5  6 `Node[] successors = new Node[] {               new Node(q, q.x, q.y + 1),                new Node(q, q.x, q.y - 1),                new Node(q, q.x + 1, q.y),                new Node(q, q.x - 1, q.y)         };`

You have no range check here. So you'll be creating nodes that extend out into negative infinity and positive infinity.
 5 Games Center / Showcase / Re: [Desktop] Fragile Soul on: 2014-04-12 19:01:24 Quote from: Ashedragon on 2014-04-12 16:35:03EDIT: So it turns out I'd literally just uploaded the wrong version, my apologies!No worries! I'll try it out again a bit later today (Probably in the lulls during the open house I have to participate in in the afternoon!)
 6 Games Center / Showcase / Re: [Desktop] Fragile Soul on: 2014-04-12 08:26:58 Have a dollar (After the itch.io and paypal fees, I mean.)The graphics for the game look rather polished. But there are some issues that I've already found by playing for just a while:1) The map seems to cut out at extremely low (Towards the bottom of the screen) maps. I've had two of starting areas (Out of four now) appear in a region where the map isn't keeping track of anything (And at least one of those had the stairs in that area so it was a bugger to find them again.)2) Visual indicators of damage would be highly appreciated as would some explanation of the health. Having stamina and then those shields, without explanation made me think that the shields were like "Defense Points" and the stamina was my health.3) Instructions would be very helpful. In your post here you have what looks to be a tutorial, however when I played just now nothing was coming up.4) Disable R (Jump down three levels) and Tab (Automatically die) or have some prompt. While I was trying to figure how to attack I had it pop a few times (Pressing buttons in sequence, then seeing the screen change and going "What did that mean?")
7  Game Development / Game Mechanics / Re: A* path finding on: 2014-04-09 23:27:22
Yes and no. The correct path is a subset of the closed list. This means that all nodes from start to finish will appear in the closed list. However, the closed list contains every visited node.

From a quick glance as the pseudocode that was posted in your link, to get your path you're going to treat the end node as a sort of linked list and backtrack through path using node.parent to construct it. Something like:
 1  2  3  4  5  6 `List path = new ArrayList();Node node = goalNode;while (node.parent != null) {    path.add(node);    node = node.parent}`
 8 Games Center / WIP games, tools & toy projects / Re: Airships Engine on: 2014-03-24 16:55:43 Honestly making a bunch of assumptions for my pseudo-code. Assumption 1: You've got a grid of some sort, or some easy method by which you can tell whether two cells in your grid are adjacent.Assumption 2: You're keeping track of all cells that are added to an airship.That said, here's a bit of psuedo-code for figuring out which are included/excluded from a connectivity set: http://www.java-gaming.org/?action=pastebin&id=872If you have to, for whatever reason, deal with directionality (The you seem to describe it if Cell A is adjacent to Cell B then Cell B is adjacent to Cell A) such as with 'portal-y' things or one-way connections then the method will have to be changed. That's probably way outside the scope.
 9 Games Center / WIP games, tools & toy projects / Re: Airships Engine on: 2014-03-24 14:37:04 For this? I think that you're over thinking the check for connection.Based on what can be seen from your example you can do this using a simple BFS or DFS search from a known airship point (Say the engine room or the cockpit, just for an understandable analogy). You keep track of the number of the total number of cells that make up the ship. Then from that known point you do either a Depth First or Breadth First expansion catching all of the connected airship cells (However you define connected.) Then you take the compliment of that list (All cells not connected) and those are your disconnected squares.If you'd like some pseudo-code later on I can throw something together for you.
 10 Discussions / General Discussions / Re: Programmer jokes on: 2014-03-17 21:35:40 Quote from: Drenius on 2014-03-17 21:09:46["hip","hip"]hip hip array.I lost it.--------------------------------------What's an C Programmer's favorite food? Spaghetti.--------------------------------------(From an actual CS text I owned in the back.)Recursion (See Recursive.)Recursive (See Recursion.)
 11 Game Development / Artificial Intelligence / Re: A* trouble on: 2014-03-16 14:58:20 This sounds like it's an issue of mapping rather than an issue with your path finder. If your system is already able to find the 'Correct' paths than you should be good.What you should look into is a good mapping/movement function. By this, I mean that you should have some sort of function that maps from tile space to screen space. It sounds like you already have one for when you're drawing your tiles. That said, you probably also need some sort of 'between tiles' movement function. Basically, you use the tile-to-pixel mapping function to figure out where an object should appear on the screen when it's on a certain tile. And the movement function would be a time-based function that moves the object between those tiles in a smooth manner.
 12 Games Center / WIP games, tools & toy projects / Re: Zombie Nauts 0.0.9 on: 2014-03-08 18:45:40 I played a few games~Some things I noticed:1) The player can sometimes walk through the zombies (Maybe the same collision issue as with the bullets?)2) I ran out of bullets in one game. Not sure if this was intended or not (I ended up clicking as fast as I could to see if there was some delay.)3) There have been a few games where I had to wait quite a bit of time before I saw a Zombie for the first time (thirty-forty seconds in one game) and between respawns (twenty-thirty second gap). Not sure if this is intended or not. (It's the reason I ended up spamming the gun. I had a lot of time on screen where nothing spawned. <.<)
 13 Game Development / Newbie & Debugging Questions / Re: Generics problem when extending on: 2014-03-08 17:57:11 I think it's an issue of inner classes typically being considered part of the outer class so its visibility is sort of wonky. So you have to explicitly make it visible so that the compiler can check whether it matches the Generic's constraints.Edit: I misunderstood the problem when I wrote my response. Changed it complety! xD
 14 Game Development / Newbie & Debugging Questions / Re: [Collision Detection] Thinks it's colliding even though it isn't on: 2014-03-05 03:47:28 Glad to be of help!Also, just as a bit of extra advice: Your collision detection will likely act oddly at times the way it's written. If the player is less than the delta away from the object that's going to be collided with it's going to stop without hitting the object. By that, I mean that its DX will be set to 0 at such a point that its edge will not touch the other object. This will probably be more noticeable when the player is falling from a higher point (e.g. has a higher DX before impact) or if you increase the update time. It will have a sort of falling stutter: It'll have DX = 0 while above the ground, then have gravity applied until it's DX is greater than the distance between the player and floor, stop again, then continue. In the end, if the positional information were different then you might even see the player "float" above the ground due to this.
15  Game Development / Newbie & Debugging Questions / Re: [Collision Detection] Thinks it's colliding even though it isn't on: 2014-03-05 01:12:08
Found it! It's one of the issues with using copy paste!

If you look at your willcollide calls you're defining your rectangle incorrectly in both cases. The first two parameters are the corners of the rectangle. In this case? You're setting them as your delta not your position. So your always checking against your bottom left tile. And you'll never collide on the left edges. :3

So this:
 1  2  3  4  5  6  7  8  9  10  11 `      // Check X-Axis collision:      if(!super.willCollide(tiles, new Rectangle((int)(tempDX + super.getX()), (int)(tempDY), super.getCurrentSprite().getWidth(), super.getCurrentSprite().getHeight()))) {         super.setDX(tempDX);      }      // Check Y-Axis collision:      if(!super.willCollide(tiles, new Rectangle((int)(tempDX), (int)(tempDY + super.getY()), super.getCurrentSprite().getWidth(), super.getCurrentSprite().getHeight()))) {         super.setDY(tempDY);      } else {         super.setDY(0.0);      }`

Should be (I changed the second one slightly so that you're testing at the end X instead of at the previous):
 1  2  3  4  5  6  7  8  9  10  11 `      // Check X-Axis collision:      if(!super.willCollide(tiles, new Rectangle((int)(tempDX + super.getX()), (int)(super.getY()), super.getCurrentSprite().getWidth(), super.getCurrentSprite().getHeight()))) {         super.setDX(tempDX);      }      // Check Y-Axis collision:      if(!super.willCollide(tiles, new Rectangle((int)(super.getDX() + super.getX()), (int)(tempDY + super.getY()), super.getCurrentSprite().getWidth(), super.getCurrentSprite().getHeight()))) {         super.setDY(tempDY);      } else {         super.setDY(0.0);      }`

 16 Games Center / Showcase / Re: Asteroids on: 2014-02-28 23:41:29 I also get a blank screen when I start it up. I'm using Windows 8 myself.Attempting to start it through the CMD interface (java -jar Asteroids.jar) results in no standard error. However, if I close the UI screen the CMD does not acknowledge an exit (Not sure if that's important in this case or not.)
 17 Discussions / Miscellaneous Topics / Re: Do you put resources in or out of the .jar? on: 2014-02-24 02:17:18 I try to do it depending on the skill/knowledge of the potential user and on how much chance there is that I'd need to change the resources on the fly, or whether the users should be able to.That said, I think that the 'inside' works best for any case where you're planning on writing an installation system or something like that. The less that the user has to do themselves the better. So an installer (Point it at a directory) or a .jar with everything in it seems best. If your expecting your Use to understand the jargon and the like? Well detailed instructions with an outside resource might work as well. Hah.
 18 Discussions / Miscellaneous Topics / Re: Random brain fart: the rationale behind versioning on: 2014-02-07 21:59:56 Because Latin > Greek. So Prime > Alpha (1st), Beta (2nd), etc..
 19 Java Game APIs & Engines / Java 2D / Re: 2D RPG graphics. Walking behind and in front of objects on: 2014-02-04 20:26:48 Fake it. Change the order of drawing objects (The moving ones) such that they're drawn after the things that they are in front of, but before things they are in back of. If it's an isometric game, this means you draw objects based on their Y value and that you draw tiles/floors/walls before other objects.I'm not sure how "good" this will be for a Java 2D based engine though. Your idea of making several different sprites for the same object may work better (It's certainly viable for a small number of variations) but the number of different sprites might be high if you have a lot of dynamic objects (Players moving, Monsters moving, dropped items, etc.).The main difference is the cost trade off. The 'Fake it' could, on a map with a large number of dynamic objects, require more calls to draw. Your idea would require the same number of draw calls (one per tile/object) but it increases the number of sprites you need by around 2 (This is if EVERY object in the game has an overlap image). If there are more than just the player on the screen moving then this number could be drastically larger.I, personally, can't say which is better in a Java 2D environment but someone else might be able to. (Do note that at the same time it might not matter! Depending on the size of your drawing space-- the number of tiles/objects you're drawing-- the difference might be small enough not to matter.)
 21 Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Root table's background is not rendered in Scene2D on: 2013-12-26 01:32:51 Not sure whether it'll help or not, but call 'table.pack()' after you're done putting everything in. >.>
22  Game Development / Newbie & Debugging Questions / Re: Better way to Manage Assets... Need a tip :) on: 2013-12-16 18:09:46
Something simple like this. But, a lot depends on how you're controlling things: whether you're just implementing ApplicationListener or making use of Game and Screens.

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34 `public class MainClassName implements ApplicationListener {private final AssetManager assetManager;public void create() {assetManager = new AssetManager();Texture.setAssetManager(assetManager);// ... Load operations here.}public void resume() {if (assetManager.update()) {doneLoading();}}public void render(float delta) {if (assetManager.update()) {doneLoading();} else {// ... Draw Loading thing!}}public void dispose() {assetManager.dispose();}public void doneLoading() {// ... Get your texture assets here.// ... Change to your main game screen.}}`