Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
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
1  Game Development / Game Mechanics / Re: 2D point in polygon algorithm on: 2016-01-30 07:34:44
what about making an object that holds the polygon as triangle pieces, rather than a polygon? This even gives me an idea for a data structure...holy cow. I'll work on it later.
2  Game Development / Game Play & Game Design / Re: Collision isn't working quite right... on: 2016-01-20 02:52:35
You are doing it wrong if you are updating the position before doing collision checks. That's the sole reason this is happening.

Check first, if it is colliding with something on either side, figure out which side, and disallow the movement in that direction before updating the position. Use a separate variable to store the new position first. Or set it back where it was before hand.
3  Game Development / Game Play & Game Design / Re: Risk design on: 2016-01-20 02:50:29
Just make up countries and continents it doesn't matter all that much.
JavaFx is nice. I can use it a little. It's not terrible.
4  Game Development / Game Play & Game Design / Re: Risk design on: 2016-01-17 04:44:42
How to communication?
5  Game Development / Game Play & Game Design / Re: Risk design on: 2016-01-16 05:02:34
What is Risk?

Oh. Yeah sure I'm up for it.
6  Game Development / Game Play & Game Design / Re: Generating large tile maps from 2d array? on: 2016-01-16 04:57:03
Back to your main question:

Get your screen area.

Iterate over it with an x/y for loop, offset by the screen coordinates.

public void render(){
   int camIndexOffsetX = (camX/TILE_SIZE);
   int camIndexOffsetY = (camY/TILE_SIZE);
   Rectangle screen = new Rectangle(camIndexOffsetX, camIndexOffsetY, camWidth/TILE_SIZE, camHeight/TILE_SIZE);

   for(int x = 0; x < screen.width; x++){
   for(int y = 0; y < screen.height; y++){


This draws exactly what is in your screen based on the offsets of the screen/camera.
You might have to start x and y at -1, and add 1 to width and height, so that it encapsulates everything intersecting with your screen, rather than starting 1 tile from the offset (You would see a blank column to the left and top).
7  Game Development / Game Play & Game Design / Re: Generating large tile maps from 2d array? on: 2016-01-16 04:53:03
I would advise the use of HashMaps here, and an object that stores an X and Y position that implements a hashcode. This way, you can store all of your tile information based on the x/y position object, and look it up instantly, rather than iterating through everything.

Here is an example: Using a Point for the position of a tile...

HashMap<Point,String> TileDataHashMap = new HashMap<Point,String>();


   int Width = 10;
   int height = 10;
   for(int x = 0; x < Width; x++){
   for(int y = 0; y < Height; y++){

      TileDataHashMap.put(new Point(x,y), "tile:info");



This is great for procedural generation, because you can keep track of what has/hasn't been generated yet.
This works well in the same sense, for path finding, because you can go through and find which tiles are solid or not by holding that info in another hashmap. Easy.

I've found that hashmaps are soooo useful that you can cut out cpu use by ALOT, and I mean ALOT. For example, if you upkeep all of your tile groups that are separated by solid tiles and confined, you update that group when a tile is no longer solid, therefore making pathfinding even more efficient when you already know which tiles to iterate through and have no excess...

I came to a point where I started using special HashMap helper classes for these sorts of things... Basic HashMap rules, store 1 value per Key. Has methods to lookup which keys contain a specified value. for storing multiple values per key, and being able to look up what keys hold the same value.
8  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-20 01:01:32
9  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-19 20:46:01
I don't know how to use github. I used it back like a week or two when it came out, but never after.
Do you have skype?
10  Game Development / Newbie & Debugging Questions / Going from 2D graphics to 3D? on: 2015-11-19 02:55:20
Hi, I am trying to use some simple placeholders using 3d geometry.

Can anyone walk me through the steps of displaying them correctly?
I am trying to create a 3D version of my top down 2D display of a level I have built.
I do not know how to apply light to geometry so that my graphics can be seen properly.

I am using libGDX.

I understand how to get the graphics INto my game world. My problem is SHOWING them correctly.
I was using jMonkeyEngine, and my textures were always illuminated and I had nobody to show me how to make them dimmer, etc.
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-11-17 17:44:45

Got my random room generator finished. Paths all connect to eachother. It can be expanded infinitely in all directions with no errors.

The dimensions of the rectangles are determined by taking a chunk of the world, and splitting it up with a binary space partition with randomized widths and heights.

I am using 5 different factors of width/height size. I pick a minimum size, then force the splitting of rectangles in the BSP to make child rectangles using those factors.

Then I path the rectangles, add them into a world, and put the walls in. The walls are so complex, took me 2 days just to set up the walls or something.

Anyway, that's about it Tongue

here's some code:
   int size = 4;
   public Set<Rectangle> Split(int minWidth, int minHeight){
      int[] sizes = {

Whole method:
12  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-17 15:08:37
Update of current state:

The doorways are real doorways now. The dots you see are positions to place game objects into the level.

I am using the same bsp tree using a multiples of 4, at intervals of up to 3 for the cell sizes I believe.
It might be slightly different now.
For instance: If I tell the bsp to split up rectangles, it takes the random number to split the rectangles apart, adds the minimum size into the expression, then floors it to a random multiple of minimumsize/4 so that the dimensions are a multiple of the minimum size.

This means sizes of sides can range from [],[][],[][][]...[][][][][][] depending on how many multiples of 4 your minimum size specified contains.

Now, I use a small enough minimum side size that the randoms can't pinch my rooms so small that I can't fit my game units in them.

I then take the generated rectangles, and have the world class handle them.

I scale them up, and then fit an int[][] of the width and height times an interval divider.
If I set my Divider 'div' to 8, it would make an int[][] of int[height*div][width*div] essentially.
So theoretically, I can have as much space in my rooms to fit 32x32 size tiles for sprites.
example of taking the default room rectangle, and turning it into space for the game:
   int scale = 5;
   int div = 4;
   public void setupRooms(Set<Rectangle> roomSet){
      Rectangle hold;
      int nX = 0;
      int nY = 0;
      int nW = 0;
      int nH = 0;
      int[][] tiles;
      for(Rectangle added: roomSet){
         nX = added.x*scale;
         nY = added.y*scale;
         nW = added.width*scale;
         nH = added.height*scale;
         testRoomMap.put(added.getBounds(),hold= new Rectangle(nX,nY,nW,nH));
         roomObjects.put(hold,tiles=new int[nH/div][nW/div]);  
13  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-17 14:42:41
well done, I like it, do you think to proper open source your work? I'm thinking to use it to improve my dungeon generation (random walk, see CryptoRL2 topic)

I don't know how to open source it. It's not documented.
14  Game Development / Newbie & Debugging Questions / Re: keyboard Printing too much times. on: 2015-11-15 12:12:15
nice. It works for mouse too. I have my input handler deal with individual keys like that, using the keycodes and a boolean[].
15  Game Development / Newbie & Debugging Questions / Re: keyboard Printing too much times. on: 2015-11-15 11:48:32
   boolean keydown = false;
   public void method(){
      if(!keydown && Input.getInput().isKeyDown(KeyEvent.VK_ENTER)){
         keydown = true;
         keydown = false;

Use a boolean to stop the input from falling through the if statement.
Reset it to false when the input is no longer in. This way, when you hold the key down, it sets keydown to true, and stays that way until you are no longer pressing keys.
16  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-15 11:43:47
Final touch up:

What do you guys think?
17  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-13 21:47:43

All of the rectangle rooms that are not blue are kept in a custom hashmap.
If they are:
  • Red: 1 Connection/Door : They are a dead end room.
  • Yellow: 2 Connections/Doors : These are between 2 rooms.
  • Green: 3 Connection/Door : They are between 3 rooms.


All I have to do is iterate over all of the colored rooms, and place doors between adjacent colored rooms into the blue rooms between the colored room connectors. (Connectors are every other room during the algorithm. They are separated by a blue room because blue rooms are not part of the algorithm.)
And bingo, they all connect without having like 4 doors taking up all the space on a room wall.
18  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-13 20:19:00
What I'll be working on next is determining which rooms connect to which rooms with doors.

I will do this without checking rooms. I will generate the rooms knowing ahead of time which path of rooms is a dead end or not.
I will generate a main path from point A to point B.
Then I will go down main path again, this time, making paths like I just did. However, I will only allow them to branch off in 1 direction, instead of going in every available adjacent rectangle. (After the initial branching away, they can add rooms however they want, following the main rules).

This way, I have a main path that does go from point A to B and also have dead end paths.

19  Games Center / WIP games, tools & toy projects / Re: [Android] Floor Runner on: 2015-11-13 18:14:33
Use points for the tips of the spikes as collision, not boxes.
20  Game Development / Shared Code / Re: Dynamic Rectangle Dungeon Room Generator on: 2015-11-13 14:40:57
interesting solution!

How do you handle connections between rooms tho?
where do you place the corridor/door between 2 rooms, and what if a room has multiple neighbors, do you add multiple doors - and thus multiple paths for the player to take?

I will be working on this today.

My idea is that I will be going through the set of rectangles, and condense them into bigger ones if they match up flush with an adjacent one. After that, mark door positions. Corridors will be marked if they reach a threshold width to height ratio for later (when decorating them).

Door are easy, but there are specific ways to do it.
The simple way is to put a door down between rooms that are adjacent, in every room.
The more complex way to do it is pick a path from point A to point B, only make doors to follow that path. Get the rooms not used in that path, and branch off for the first rooms directly connected to the path, and connect doors the simple way (without letting it do it to the main path of rooms).

I'm thinking a good way to make dead end paths is to mark the dead ends as the target room, and start the branching room as path A, and use the same algorithm that makes the main path and so on.  I type alot sorry lol.
21  Game Development / Shared Code / Dynamic Rectangle Dungeon Room Generator on: 2015-11-13 01:44:22
Hey guys. I've been working on this idea for about 3 days.
Basically I did not know how to generate a maze, so I thought, why not try?
Except, I want to use random rectangles instead of fixed cells for tile traversal.

I use a binary space partition structure to generate random slices of rectangular space, then I have the following rules:
  • if there are no rectangles on the stack, there are no more positions to move. The maze is done.
  • If the rectangle adjacent to our current position has been checked, do nothing.
  • If the rectangle adjacent to our current position (a) hasn't been checked, but all rectangles adjacent to (a) have been checked, add (a) to the checked list. The current rectangle becomes that first one off of the stack, and this whole process repeats.
  • If the rectangle adjacent to our current position hasn't been checked, add all rectangles across from (a) to a list. Out of that list, pick one to keep (b), add it to the checked rectangles, and to the stack. Add the adjacent and across to the set of rectangles that are of the path. Get the adjacent tile opposite of the direction we just checked, and add it to the checked list.

When the maze can no longer add rectangles, I have it erase dead ends until all rectangles have 2 or move neighbors.

Splitting the whole rectangular world into smaller rectangles:
and the class to make the rectangles a-MAZE-ing:

When I display the result, it looks something like this

This is without the removal of dead ends

My next goal will probably be checking of adjacent rectangles, and combining the ones that have matching sides in the direction they are being checked.

So if I check A and B and A is above B, and B's width is equal is A's width, with their x positions being the same, they combine their area.

So that rooms are flush (and we don't have a corridoor that leads into a corridor.


The door placement is possible with this:

Red = rooms with 1 doors.
Yellow = rooms with 2 doors.
Green = rooms with 3 doors.
Magenta = rooms with 4 doors.
White = rooms with 5 doors.
Cyan = rooms with 6 doors.

         public SetPairMap<Rectangle,Rectangle> doormap = new SetPairMap<>();
   public void placeDoors(){        
      for(Rectangle r: path){
         for(Rectangle adj: getAdjacent(r, false).getValues()){
               doormap.put(r, adj);              
               doormap.put(adj, r);

Just to clarify, the rooms that are red only see they have one door that THEY themselves generate. They can have more than one, but they don't store their parent door. I may update this later when I show rooms that have their total doors displayed by color. As of now, it looks like red rooms could isolate from the rest of the path.

Finished Product pretty much:

Without sticking squares in. (Squares filling in the spaces makes the mazy look. This is better imo).

22  Game Development / Performance Tuning / Re: Storing entity state in Map<String,Object> on: 2015-11-03 05:29:12
If you're going component architecture, you don't have to follow the articles everyone googles and follows.
Using the <T extends ComponentType> and then making the ComponentType class is such a mess, unless you want to make it your mess then go for it.

Here's what I do, I make a hashset, and then use integers to identify the component type, then I use strings to hold the values (to take away from the oop side of programming in case I'm using over 9000 objects with this.)

The reason why is simple.

"Check if this entities collides with collide-able entities."
How do we do that?
Well instead of using a 'T extends Collideable', we just store the entity that's collideable in a Set of values that are collideable. If they aren't in that Set, they aren't solid.

I think that's what you're going after.

You will probably want to have an indexer create tags for each unique object you are using, place that object in a Map with an Integer (Tag) as the key and the Entity as the value.

Then take all the information of that entity and pass it through a class that keeps track of the Sets of entities with attributes of a certain type so that you don't have to perform excessive forloop iterations.

Seems redundant, but it's better than going through every entity you have and checking it for specific conditions, when you can hold a set for said conditions to iterate over.
23  Discussions / General Discussions / Re: Best place to handle collisions on: 2015-11-02 23:44:28
"Best Place" ?

before you update, so you know the state of dynamic entities before they act. (If they are blocked, don't perform ai/player input before checking if they are blocked; in this case you wouldn't be able to tell yet)

Only check collision with entities that move.

You 'can' have  a list or data structure that holds a group of nearby solid entities, refreshing this every time the entity moves an increment in some direction. (If tiles are 10 units long, doesn't have to be pixels, imaginary units, then if the entity moves over a multiple of 10 boundary, refresh the data.)
That would be for tiles though.
For other entities, you could use a quadtree or something to keep track of them.
24  Discussions / General Discussions / Re: JGO IDE Survey on: 2015-11-02 23:37:44
I'm Eclipse all the way baby.
25  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 17:07:05
How would I improve the readability any more than this?

More generally, your whole attitude tells more about you as a programmer than your code does. I get that this was a light-hearted boasting of some code you're proud of, and that's cool, but good programmers know that there is always more to learn.

The code you posted and the way that you posted it say a lot about you: you're probably still in high school. You probably have never worked on a real team (outside of perhaps homework assignments). You probably haven't finished any non-trivial projects. You probably get decent grades, but you haven't taken any advanced classes yet. You might have one big project that you daydream about finishing, but really you think and talk about it more than you code it. You seem a bit full of yourself and you don't seem to respond to criticism well, which is something that you'll have to get over if you want to be a real programmer.

How far off am I? :p

I am past highschool. I don't think I don't respond to criticism well, but it's funny to see that others think I seem like I'm still in highschool though Tongue

Just wanted a response.
26  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 08:30:54
Woah Woah what is that 0.o
27  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 04:09:18
Okay, so expressions then -.-
28  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 04:05:29
Then what is a formula -___-
29  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 03:54:33
 g.fillOval(tFill.n*(spacing)+offset, tFill.v*(spacing)+offset-(size*(spacing/2))+((size-tFill.n)*(spacing/2)), (spacing), (spacing));

Sure that may be a function, that's not what I was referring to.


That is what I was referring to as a formula.
30  Discussions / General Discussions / Re: What's with unorganized code? on: 2014-06-24 03:07:26
How would I improve the readability any more than this?

As for the formulas, should I put each parameter for the drawing method on a separate line with comments
for what each object in the formula does?
Pages: [1] 2
ivj94 (582 views)
2018-03-24 14:47:39

ivj94 (46 views)
2018-03-24 14:46:31

ivj94 (374 views)
2018-03-24 14:43:53

Solater (61 views)
2018-03-17 05:04:08

nelsongames (108 views)
2018-03-05 17:56:34

Gornova (150 views)
2018-03-02 22:15:33

buddyBro (691 views)
2018-02-28 16:59:18

buddyBro (91 views)
2018-02-28 16:45:17

xxMrPHDxx (493 views)
2017-12-31 17:17:51

xxMrPHDxx (730 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!