Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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 ... 277
1  Game Development / Newbie & Debugging Questions / Re: *SOLVED* Stuck in recursion hell! on: 2014-08-29 10:00:52
Line 12 and 13 shouldn't be there, right? As that was the cause of the original problem.

Also, the 'on' field can be removed, as this can be implicitly determined with
wireMap[x][y].generatorID != 0
if you clear the IDs each tick, like you clear the 'on' property currently.

Last but not least: it's preferable to pass the generatorID as a parameter, removing the presumably static CURRENT_GENERATOR field.


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  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
public void turnOffAllWires() {
   for(...)
      wireMap[x][y].lastGenID = 0;
}

public boolean isWireOn(int x, int y) {
   return wireMap[x][y].lastGenID != 0;
}

public void tick() {
   this.turnOffAllWires();

   for(Generator gen: generators)
      this.calcNextWireNode(gen.x, gen.y, gen.reach, gen.id);

   for(...)
      if(wireMap[x][y].type != NONE)
         wireMap[x][y].type = isWireOn(x,y) ? ON : OFF;
   
}

private void calcNextWireNode(int x, int y, int remaining, int genID)
   {
      // if we've hit our maximum recursion (distance) depth, finish here

     if (remaining == 0) return;
     
      // if we're not in bounds, finish here
     if (!tileInBounds(x, y)) return;
     
      // if this tile isn't a valid wire type, finish here
     if (wireMap[x][y].type == WireType.NONE) return;
     
      // don't process this if we're on the same generator ID
     if (wireMap[x][y].lastGenID == genID) return;      
      wireMap[x][y].lastGenID = genID;

      CURRENT_GENERATOR_OPS++;
     
      // test the four spaces around this tile
     calcNextWireNode(x-1, y, remaining-1, genID);
      calcNextWireNode(x+1, y, remaining-1, genID);
      calcNextWireNode(x, y-1, remaining-1, genID);
      calcNextWireNode(x, y+1, remaining-1, genID);
   }
2  Game Development / Newbie & Debugging Questions / Re: *SOLVED* Stuck in recursion hell! on: 2014-08-28 16:31:50
That was actually the solution I had in mind - but I wanted to keep it simple. Great that you figured it out too.
3  Game Development / Newbie & Debugging Questions / Re: Spam Killing on: 2014-08-27 21:49:14
1  
2  
3  
4  
5  
6  
7  
8  
9  
  public void moveForward() {
      try {
         Thread.sleep(500);
      } catch (InterruptedException e) {
         // TODO Auto-generated catch block
        e.printStackTrace();
      }
      tileX--;
   }


You are accessing your data from multiple threads, leading to all kinds of race conditions.
4  Game Development / Newbie & Debugging Questions / Re: Stuck in recursion hell! on: 2014-08-27 20:44:25
Decouple 'on' state from 'traced' state.

Reset traced state prior to flood filling from each node.
5  Discussions / Miscellaneous Topics / Re: Killers/Murderers - Are they really wrong? on: 2014-08-27 20:36:08
You mean 'terrorist'.
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-27 13:03:36
It seems the voxel engine determines per voxel whether it is shaded - not per face.

Additionally, the voxels/sprites themselves are baked (?) with shading from the wrong direction, leading to the faces pointing away from the light source to be brightened (see corners facing the camera).
7  Discussions / Miscellaneous Topics / Re: Killers/Murderers - Are they really wrong? on: 2014-08-27 12:54:43
Without fighting and war, the human population has no choice but to increase over time.
How so? Is there somehow a guarantee that every pair of humans will produce two children? In many 'western countries' populations are declining without the help of fighting and/or war. If anything, it's the pursuit of careers that is the main force behind population decline in 'civilized regions' (whatever that means).



Regarding the broader topic: there is no objective right or wrong, so murder is not wrong by definition.

On a high abstraction level, society invests in individuals to prosper (for the sake of society) and society wants to perpetuate this construct - hence removing counter-productive members from society.

On a low abstraction level, an individual tries to prosper (for the sake of his/her (future) partner/offspring) - hence will be likely to support activities in said society that will reduce the chances of his/her own untimely termination.
8  Game Development / Newbie & Debugging Questions / Re: BMFont + Slick Implementation Issue on: 2014-08-27 06:41:38
When converting to BMP, you lose the alpha channel.

You should probably find an app (like Paint.NET) that allows you to re-save a PNG in a specific format (32 bit in this case).
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-27 05:28:21
Still playing, probably shouldn't, but not quite sure what you mean.
I was refering to those odd 45deg edges on the right-hand side of the leafs of each and every tree:



10  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-08-26 19:40:21
Rounding out the 45deg edges may improve the lot Smiley
11  Game Development / Newbie & Debugging Questions / Re: GLSL Lighting a 3D box on: 2014-08-23 10:44:52
Those are example use-cases, they have nothing to do with the buffer's properties.

buffer.rewind() is the equivalent of buffer.position(0)
buffer.clear() is the equivalent of buffer.position(0) + buffer.limit(buffer.capacity())
buffer.flip() is the equivalent of buffer.limit(buffer.position()) + buffer.position(0)
buffer.reset() is the equivalent of buffer.position(mark);

buffer.clear() does not affect the readability or writability of a buffer, neither directly nor indirectly. it's just common that one starts writing after a clear, and reading after a flip.


while with flip you can write to it too.
this is typically exactly what you would not do after a flip.
12  Game Development / Newbie & Debugging Questions / Re: GLSL Lighting a 3D box on: 2014-08-22 18:35:58
You shouldn't reset the buffers, you should rewind them.
Yeah, either
buffer.rewind();
or
buffer.flip();
.
With rewind the buffer becomes readable, while with flip you can write to it too.
I'd suggest to read the javadocs. reset(), flip(), clear() and rewind() alter the position and limit of a buffer, and has nothing to do with readability/writability.
13  Game Development / Newbie & Debugging Questions / Re: How do I use Ashley entity framework alongside Kryonet? on: 2014-08-22 12:49:59
If you add items to an ArrayList on thread A, and get/remove them from thread B, you must synchronize access to this ArrayList, or the behavior of the ArrayList is undefined, as shown by the following example:

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  
35  
36  
37  
38  
39  
40  
41  
42  
43  
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class Queue {
   public static void main(String[] args) {
      final int pushCount = 16 * 1024 * 1024;

      new Thread(new Runnable() {
         @Override
         public void run() {
            for(int i = 0; i < pushCount; i++) {
               push(Integer.valueOf(i));
            }
         }
      }).start();

      new Thread(new Runnable() {
         @Override
         public void run() {
            Set<Integer> set = new HashSet<>();
            for(int i = 0; i < pushCount; i++) {
               System.out.println("queue size: " + queue.size() + ", polled count: " + set.size());
               Integer got = poll();
               if(got == null)
                  continue;
               if(!set.add(got))
                 throw new IllegalStateException("repeated poll result!");
            }
         }
      }).start();
   }

   static final ArrayList<Integer> queue = new ArrayList<Integer>();

   public static void push(Integer s) {
      queue.add(s);
   }

   public static Integer poll() {
      return queue.isEmpty() ? null : queue.remove(0);
   }
}


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  
queue size: 3313, polled count: 0
queue size: 4569, polled count: 1
queue size: 4786, polled count: 2
queue size: 4989, polled count: 3
queue size: 5245, polled count: 4
queue size: 5499, polled count: 5
queue size: 5621, polled count: 6
queue size: 5902, polled count: 7
queue size: 6222, polled count: 8
queue size: 9369, polled count: 9
queue size: 9629, polled count: 10
queue size: 10100, polled count: 11
queue size: 10548, polled count: 12
queue size: 12009, polled count: 13
queue size: 12779, polled count: 14
queue size: 13314, polled count: 15
queue size: 13764, polled count: 16
queue size: 14052, polled count: 17
queue size: 14416, polled count: 18
queue size: 15165, polled count: 19
queue size: 15738, polled count: 20
queue size: 16326, polled count: 21
queue size: 16884, polled count: 22
queue size: 17444, polled count: 23
queue size: 18025, polled count: 24
queue size: 18696, polled count: 25
queue size: 19918, polled count: 26
queue size: 20622, polled count: 27
queue size: 21036, polled count: 28
queue size: 21078, polled count: 29
queue size: 21773, polled count: 30
Exception in thread "Thread-1" java.lang.IllegalStateException: repeated poll result!
   at nav.Queue$2.run(Queue.java:30)
   at java.lang.Thread.run(Thread.java:745)


Solve with:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
static final ArrayList<Integer> queue = new ArrayList<Integer>();

   public static void push(Integer s) {
      synchronized (queue) {
         queue.add(s);
      }
   }

   public static Integer poll() {
      synchronized (queue) {
         return queue.isEmpty() ? null : queue.remove(0);
      }
   }


Or much better: (among other things, due to the capped queue size)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   static final ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(n);

   public static void push(Integer s) {
      while (true) {
         try {
            queue.put(s);
            break;
         }
         catch (InterruptedException e) {
            // err
        }
      }
   }

   public static Integer poll() {
      return queue.poll();
   }
14  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Kryo/Kryonet compression and buffer on: 2014-08-22 05:27:53
Kryo compresses every single integer value during serialization. This apparently interferes with gzip compression.
15  Discussions / Miscellaneous Topics / Re: Do you ever actually just despise someone ? on: 2014-08-21 18:10:45
I just don't see the merit of a thread celebrating prejudice.
Luckily there are no such threads on JGO.
16  Discussions / Miscellaneous Topics / Re: Do you ever actually just despise someone ? on: 2014-08-19 18:11:03
This is Misc - and it has some value for the bunch of us. It's alright.
17  Discussions / Miscellaneous Topics / Re: Do you ever actually just despise someone ? on: 2014-08-19 10:23:13
With a restricted communication channel it's vastly easier to despise the other end.
18  Discussions / Miscellaneous Topics / Re: How often do you code on: 2014-08-18 19:22:37
Whenever somebody pays me for it - regardless of the amount.
19  Game Development / Game Mechanics / Re: Getting into multi-threading. on: 2014-08-18 15:44:26
People with a decade or two of experience under their belt should not tell n00bs that multi-threading is 'doable if you keep things simple'. It's not doable at all, for them, yet - no matter how simple their use-case.
20  Game Development / Newbie & Debugging Questions / Re: [Box2D] Pivot of body's rotation on: 2014-08-17 20:03:23
Having never worked with Box2D myself... Google said the center of mass (and hence the pivot) can be found with MassData.
21  Discussions / General Discussions / Re: Java & Linux Chromebook: problem running my application in fullscreen on: 2014-08-14 19:11:32
1  
if(dm.getBitDepth() == desktopDisplayMode.getBitDepth())
22  Discussions / Miscellaneous Topics / Re: Life is like a strategy game sort off on: 2014-08-10 19:23:29
My point was that the right atoms ended up in the right place at the right time to be pulled in by whatever is at the center of the earth
You know there is a black hole at the center of the Earth right, spinning so fast the centrifugal forces prevent anything from falling in, so we're safe.
23  Game Development / Newbie & Debugging Questions / Re: Solved - Need advice/guidance on path finding - A* on: 2014-08-10 16:43:28
Which path does your code find for the following graph:


1  
2  
3  
4  
5  
  B
 / \
A---D
 \ /
  C

Start: A, Destination: D

Weight for edge A→B: 1
Weight for edge A→C: 2
Weight for edge B→D: 3
Weight for edge C→D: 1
Weight for edge A→D: 6

Correct path is A→C→D

This test-case catches most common mistakes - both in searching and in backtracking.
24  Discussions / Community & Volunteer Projects / Re: Indie Game Developer Magazine. on: 2014-08-09 16:11:24
Roquen's interview is inspiring. It's similar to mine in many ways, in the sense of existence. Is this a weekly, monthly or annual magazine?
25  Discussions / Community & Volunteer Projects / Re: Indie Game Developer Magazine. on: 2014-08-09 16:07:59
I'm confused...





I posted this question at http://tinyurl.com/llugdkh and
got responses from 3 people.

Roquen’s Interview………………………………………………..Pg. 3
SHC’s Interview…………………………….Pg. 4-5
26  Discussions / Community & Volunteer Projects / Re: Indie Game Developer Magazine. on: 2014-08-09 16:00:57
So where's the 3rd interview Clueless
27  Discussions / Community & Volunteer Projects / Re: Indie Game Developer Magazine. on: 2014-08-09 15:30:34
That it's the last page of the magazine is telling.
28  Discussions / Community & Volunteer Projects / Re: Indie Game Developer Magazine. on: 2014-08-09 15:05:41
29  Discussions / Miscellaneous Topics / Re: Is our Universe Simulatable? on: 2014-08-07 09:10:19
@basil_: Like any model, it will be replaced by another. It would be presumptuous to think we already found the the lowest model. So far it always turned out there was something underneath that explained the mysteries in higher level models.
30  Discussions / Miscellaneous Topics / Re: Life is like a strategy game sort off on: 2014-08-07 07:47:11
Regarding multiple dimensions and models in general: just like Roquen said: just because the math adds up, doesn't mean we should assume it exists.



Three scientists enter an empty lab.
Five scientists leave the lab.

How many scientists have to join the remaining scientists in the lab for it to be empty again?
Pages: [1] 2 3 ... 277
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (31 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (44 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 15:40:00

List of Learning Resources
by SilverTiger
2014-08-06 00:33:27

Resources for WIP games
by CogWheelz
2014-08-01 21:20:17

Resources for WIP games
by CogWheelz
2014-08-01 21:19:50

List of Learning Resources
by SilverTiger
2014-07-31 21:29:50

List of Learning Resources
by SilverTiger
2014-07-31 21:26:06

List of Learning Resources
by SilverTiger
2014-07-31 16:54:12

HotSpot Options
by dleskov
2014-07-08 06:59:08
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!