Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (428)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 16
1  Game Development / Newbie & Debugging Questions / Re: Problems with generating subclasses on: 2014-04-23 16:23:38
A simple 'clone' style method would work for this. So long as your concrete classes are also final (Otherwise, the return might be iffy).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public class Spell {
   ... A lot of stuff.

   public abstract Spell clone();
}

public final class Fireball extends Spell {
   private int damage;
   public Spell clone() {
      Fireball spell = new Fireball();
      spell.damage = this.damage;
      return spell;
   }
}


Then when you cast a spell from your list, you'd call 'clone()' on it and get a copy-- Perhaps even a shallow copy-- that can be used by the Active Spell Handler.
2  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);
}
}
3  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*. Cheesy)

Edit: Changing the link to one that high lights the changes.
4  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.
5  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.
6  Games Center / Showcase / Re: [Desktop] Fragile Soul on: 2014-04-12 19:01:24
EDIT: 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!)
7  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?")
8  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<Node> path = new ArrayList<Node>();
Node node = goalNode;
while (node.parent != null) {
    path.add(node);
    node = node.parent
}
9  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. Cheesy

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=872

If 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.
10  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.
11  Discussions / General Discussions / Re: Programmer jokes on: 2014-03-17 21:35:40
["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.)
12  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.
13  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. <.<)
14  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
15  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.
16  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);
      }

17  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.)
18  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.
19  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..
20  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  Discussions / General Discussions / Re: Game Cliches? on: 2014-01-09 15:24:59
For me it's games that force you into a position where you end up being morally/emotionally punished for the actions taken. Especially in games where your character has no identity beyond the actions you've taken.

I know this is an old thing, especially in the Final Fantasy series: FF2/4 had Cecil and his destruction of Mist Village (Which in the original english version had the player delivering a 'Package' to the village, though in the Japanese version it was 'bomb'. There were Bowlderization issues there!) and then FF3/6 had the whole thing with Terra invading that city with the Magitech troopers. However, these both had character development outside of that and you knew why the player ended up playing though those sections.

Shadow of the Colossus had something of this in it, not that I minded because it was really a pseudo-story game anyway.

I've seen a couple of flash games do that where the story is accomplishing these semi-evil acts just because you were asked, then you're morally punished at the end (I can't remember the name of the one I'm thinking about, but it was basically that the PC ends up being asked by a wise man to get some items from the guardians of the world, and at the end you're basically told "Asshole, you just slaughtered the guardians just because this old man wants you to do something? What's wrong with you!")
22  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. >.>
23  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.
}

}
24  Discussions / General Discussions / Re: Completely Lost, Don't know what to do. on: 2013-12-16 14:16:33
Story is, often, the hardest part of a game. Especially figuring out a way to include it that does cause a shoehorning or railroading sensation in the player. This is, perhaps, one reason why games like Minecraft and Terrarria are so well liked. They don't provide a story beyond "Go forth and survive". That said for platformers/top-down games implementing a way to put in a storyline is mostly a task of adding in event regions that cause the normal 'gameplay' engine to be superseded by the 'story engine' which is what pops up the dialog, plays the animations, etc. Neverwinter Nights used a system like this and several others did. They basically had a special type of 'invisible' collision object that when entered would cause these events.



All of that said, how to create a complete game and release it? I know, given my own track record, that I shouldn't be the one saying all of this (Though I now have two relatively complete and playable games that I need to polish and upload here), but the best way to do it is to set in stone what you want. Create a document, some sort of contract with yourself, that states what it is you intend to do, the features you want to include and the like. Write it up as best you can, even if it's just a general description of the UI, the gameplay features and all of that. Then stick to it. If you think you might have come up with a better way to do something or a better mechanic write it down then look back at your document. Will the new gameplay mechanic require you to rewrite the rest of the game? Then put it down in an idea folder for a later incarnation of the game or for another game entirely.

This is why so many games have a road map or upcoming feature list. It's so that they can focus on one idea long enough to get it working. Later on, you can look back at your code, refactor it and decide whether the fantastic idea you had while you were working on it would actually improve the game in anyway. If it can, then you write up another document/contract with yourself defining the scope of the changes you're going to make. Google the idea of a 'Game Design Document' and read up on it a bit.


This is coming from a person who feels your pain when it comes to changing gears in the middle of coding. The only game that I've manage to write to a playable degree is one that I wrote for a class (I WAY over did it) and I only managed to get it done on time because I laid down the mechanics prior to starting to code it and (almost) every time I thought "The game would be better if I did this" I said "Yes, but that'd require me to rewrite other mechanics and it won't be the game idea I defined earlier". Every other game I've attempted to write has sort of crashed and burned because I got too deep into the "Oh, this would be a great mechanic, why don't I add it" until I was too bogged down with them and went "Screw this, I need a break... Oh, that's a great NEW idea'.
25  Game Development / Newbie & Debugging Questions / Re: Better way to Manage Assets... Need a tip :) on: 2013-12-16 13:48:13
Creating a new AssetManager with out calling its dispose method will in eventual memory issues. Many of the objects that it loads are not lost during the pause/resume of a mobile application. Creating a new one will cause it to reload everything that is not lost during the context switch as well (I believe that this includes any sounds, music and non-image files that were loaded up, though some of these may require a bit of processing. I may be wrong about everything that is saved. I might be wrong about this, though!)

 The AssetManager class already provides some support for the pause/resume. The AssetManager can be set to reload the assets that are required to load when a resume is called by doing: Texture.setAssetManager(AssetManager manager).

Then in your screen/application listener class, you can have the resume method either wait for the AssetManager to reload or you can cause it to switch to a loading screen until it's complete (Look at the very end of: https://github.com/libgdx/libgdx/wiki/Managing-your-assets )
26  Discussions / Miscellaneous Topics / Re: Starbound on: 2013-12-10 01:31:06
Well, I shall soon join the group of ya'll who're playing this game. But it won't be for several days. And then the Ludum Dare shall drag me away to the delight of attempting to get a game done in two days!
27  Discussions / General Discussions / Re: Bad Habits on: 2013-12-04 03:22:45
I'm bad about using the "System.out.println()" method of debugging.
I'm not certain this is really a bad habit/method. Especially if you know where the error is happening (Exception Stack), but not the when (Which values cause it to mess up). You can use the print statements in an attempt to discover some of the values that are coming in before the crash/error happened and use them to insert an if (variable == THIS ONE I FOUND THAT HAPPENS JUST BEFORE THE CRASH) and then put your little debug point there. Cheesy And by then, you'll normally have a better idea of just what's going wrong in the first place just by reading variables and stuff that you might be able to solve it without going through the debugger. Otherwise, you sit there and have to sit there and go through the execution calls one by one and probably sit through enough that your finger hits next by habit and it crashes without you getting enough data. >.>


Another problem I have. Changing ideas mid project. In fact, I almost failed to finish a class project (One where I decided to go way over board and write a full LibGDX program for a relatively simple game that was meant to be done using Java Swing and the like) because after turning in a basic design idea document I thought "You know what, now that I've gotten this mostly coded, I've found that it doesn't make for a fun game. But if I change this and this other thing..." Which is why I almost never finish a game.
28  Discussions / General Discussions / Re: Bad Habits on: 2013-12-02 08:09:47
Somewhat excessive attempts at code organization, even for private code. I spend more time working on that than anything else.

Always encapsulating data. Even when it leads to a lot of boiler plate style code. I only just broke the habit in a project I'm working on right now. I'm actually using public fields.

Prematurely optimizing code.

Commenting after I code.
29  Game Development / Newbie & Debugging Questions / Re: Distributing runnable files on: 2013-11-04 18:58:49
Another option is to create a .bat file or something similar that they can use to run the game (So that if there's anything else you might need to do to set it up you can do so in the .bat). That's the route I turned to when there were issues with getting anything I ran to actually work.
30  Discussions / Miscellaneous Topics / Re: Logic Errors on: 2013-11-02 02:23:36
Biggest reason why I complain about the bracket-less/single line control statement (in Java):

I was working on a project for my BS in CS editing another team member's code to provide a better reader for an XML document we had to parse. I always use brackets, he didn't. So I was reading his code like it was mine. I added a line to an if statement and could not, for the life of me, figure out why that line was always executing. It took me about eight hours to discover that error.
Pages: [1] 2 3 ... 16
 

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 (79 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

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