Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (714)
Games in Android Showcase (214)
games submitted by our members
Games in WIP (787)
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 ... 308
1  Game Development / Newbie & Debugging Questions / Re: LWJGL vs LIBGDX on: 2017-03-15 19:45:58
If you want help with your decision on either a wheel or a car, we'd need more information on what it's going to be used for, apart from 'travel'.
2  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-03-08 09:30:09
You could have removed the branching and the parameter Pointing
3  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-03-08 07:15:01
I had previously written a function that checked if a number was a prime, and so I just found the largest factor of 'n' checked if it was a prime [snip]
All (smallest possible) factors are prime by definition, no need to verify Smiley

Any number > 1 can be factorized into a series of primes, raised to some power.

145499 = 83^1 * 1753^1
145500 = 2^2 * 3^1 * 5^3 * 97^1
145501 = 145501^1

(2, 3, 5, 83, 97, 1753 and 145501 are primes)
4  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-03-07 23:47:39
Decided I was finally going to tackle the problems on projecteuler.net. Problem 3 was to find the largest prime factor of 600,851,475,143, managed to write a small 15 line program that does it in 9ms. Seems like it would be rather easy, but my first two ideas made the JVM run out of memory. Made me so happy to get it working so fast. Cheesy

Time to tackle all the things!

Maybe my definition of largest prime factor is wrong?
1  
2  
3  
4  
5  
6  
7  
   private static long maxPrimeFactor(long num) {
      long max = 0;
      for (long i = 2; num > 1; i++)
         if (num % i == 0)
            num /= (max = i--); // decrement i, the factor may repeat
      return max;
   }

1  
maxPrimeFactor(600851475143L) <-- returns 6857 in 65us (0.065ms)


Only when the prime-factors are really big, you have to optimize.
5  Java Game APIs & Engines / OpenGL Development / Re: OpenGL - Draw multiple objects issue on: 2017-03-05 11:45:52
When using instancing we cannot do that anymore, because we are back at model-space. So, we need a way to represent rotation. We could get away with a single rotation angle, but that would then require to evaluate sin/cos in the shader. This however would hurt performance more than storing 3 additional float values for the 2x2 matrix, in which that sin/cos calculation has already been done once on the CPU.
If you take a 16bit integer (giving you up to 0.005 degrees of accuracy), you can then lookup the sin/cos values in a uniform-buffer or (as a fallback) a texture. This reduces 128 bits (4 floats) to 16 bit, at the cost of 2 lookups on the GPU. I expect that would yield a slight performance increase. You can decide to use only 10 bits, reducing the side of the uniform-buffer. For grass even 256 distinct rotation angles (8 bit integer) would be enough.
6  Game Development / Performance Tuning / Re: Quadtree Efficiency? on: 2017-02-23 10:56:27
Developers asking these questions shouldn't be making games that require anything more than grids Pointing

It may sound patronizing, but it's true Smiley




(I'll show myself out Kiss)
7  Game Development / Performance Tuning / Re: Quadtree Efficiency? on: 2017-02-22 13:58:38
Grids are extremely fast and trivial, but you need to spend some time tweaking them when you have objects with negative positions. Since you'll typically implement them as 2D arrays, negative indices will be a problem.

You just add a value to the coords to ensure they are positive... you'll never need negative cell index logic.
8  Game Development / Newbie & Debugging Questions / Re: mt object wouldnt load image on: 2017-02-22 07:38:06
Not sure why you think you have to use "//" -- did you see "\\" and attempt to swap the slashes to make it cross-platform? Simply use "/"

That will be the first step to solve your problem. This thread will help you with the next steps:
http://www.java-gaming.org/topics/faq-cannot-find-the-resource-file/33226/view.html
9  Game Development / Performance Tuning / Re: Quadtree Efficiency? on: 2017-02-22 07:18:07
Use grids. They have a lot less cache-trashing, and the logic is trivial. You will have quite a lot of empty cells, but that's OK.
10  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Ongoing project: Type-Safe access to ByteBuffers on: 2017-02-11 13:27:22
Yes. Pointing
11  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Ongoing project: Type-Safe access to ByteBuffers on: 2017-02-11 11:37:13
I've reviewed existing approaches related to this topic.

http://homac.cakelab.org/projects/org.cakelab.nio/existing.html


I think I've found everything about it, but if someone knows about a tool or framework I haven't mentioned, please tell me.

Quite an impressive review!


Quote
@StructField: Used to declare a field to be part of the struct. Fields without it will be considered to be transient in respect to the structs layout.
@CopyStruct: Used to declare methods to return a copy of the struct.
@TakeStruct: Used to declare methods which take a parameter, which is a mapped struct object.

@CopyStruct and @TakeStruct both refer to the return-value (unrelated to parameters). It is basically an instruction to the callsite, on whether to copy the struct that was returned to the head of its stack (in case it was stack allocated in the called method), or take it as is (in case the struct was malloc-ed or pre-existing, surviving the scope of the callee).
12  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Ongoing project: Type-Safe access to ByteBuffers on: 2017-02-05 14:09:11
LibStruct is zero-copy. You just map a struct to an existing memory pointer / buffer
13  Games Center / Contests / Re: Urgent announcement about java4k.com on: 2017-02-04 21:19:31
So I don't like registering domains anymore, because if u choose to move on then someone will swoop in and take up whatever u were doing.

You could have spared yourself this outcome by handing over the domain to those who offered, I vaguely recall I wasn't the only one. You already stated that you wished to handover the site, but that there were no takers, so it was your intent to see a continuation of the java4k site. Why did you choose not to take the offer, let the domain expire and expose it to the trolls?
14  Java Game APIs & Engines / OpenGL Development / Re: LWJGL-3 What is the best way to make a voxel engine? on: 2017-02-03 20:10:15
We have a dedicated sub-board for Cube World Projects Pointing

http://www.java-gaming.org/boards/cube-world-projects/83/view.html

You'll find a lot of discussion about the topic!
15  Games Center / Contests / Re: Urgent announcement about java4k.com on: 2017-02-03 16:13:40
How is this hacking? Somebody abandoned a domain, they bought it - at most this is copyright infringement, I think.
16  Discussions / Miscellaneous Topics / Re: Retrieve random point inside regions of Perlin noise? on: 2017-02-01 17:08:51
Use floodfill indeed. And drop the requirement that your game is supposed to be infinite. Not a single gamer cares about infinity Smiley

Try to make a relatively small world, and make a fun, functioning game - that is hard enough!
17  Games Center / Contests / Re: Urgent announcement about java4k.com on: 2017-02-01 09:16:24
Some months ago I let the domain expired, the contest had been dead for 3 years. I had offered to others to adopt it but no takers.

Hey, I offered to be your fallback volunteer Smiley



http://www.java-gaming.org/topics/should-i-let-java4k-die/36852/msg/351025/view.html#msg351025

If, and only if, there are no suitable volunteers, please extend the domain registration, I will reimburse you. Once that is done, we can take some time to transfer ownership of the domain & website.

IMHO java4k.com should stay online if only for historical reasons.
18  Game Development / Newbie & Debugging Questions / Re: Lighting whoes on: 2017-01-31 08:24:37
@JESTERRRRRR, yes, light is cumulative.
19  Game Development / Newbie & Debugging Questions / Re: Libgdx HTTPRequest on: 2017-01-10 22:44:45
Note sure what you mean, as CORS is not used for <img src="..."> requests, and is used for ajax-calls with specific http-methods and non-trivial http-headers. So it does not stop content leeching of images and I'm not sure how many people leech content through the ajax API... Smiley

In earlier versions of Chrome, you could disable CORS with the CLI param:
--disable-web-security


Anyhoo, this is a tad offtopic. If you wish to elaborate I could split it off this topic.
20  Game Development / Newbie & Debugging Questions / Re: Libgdx HTTPRequest on: 2017-01-09 18:02:46
CORS is actually a security measure, not a way to block content leeching.
21  Game Development / Performance Tuning / Re: Tips for reducing frame rate spikes due to JIT early in a game? on: 2016-12-26 17:42:14
Shouldn't we go back to the original post and wonder whether all assertions are correct?

A 1000ms JIT pause is highly unlikely, given that the JIT does its work incrementally.


I bet it's a code path that the OP isn't expecting, triggering a lot of disk I/O, the incorrect initialisation of a data-structure, etc etc.

If you simply profile your code (and use System.currentTimeMillis / System.nanoTime to confirm your suspicions) you'll most likely find the culprit quite quickly.
22  Discussions / Miscellaneous Topics / Re: What I drew today on: 2016-12-20 12:42:36
You forgot the cheekbones and the fat/muscles in the cheeks. That is how mere human brains determine age quite accurately. Your brain told you she has smooth skin, so you didn't draw anything there. Shading, implying some curves will solve your problems Smiley
23  Game Development / Newbie & Debugging Questions / Re: Delay Line of Code for X Amount of Seconds on: 2016-12-19 07:35:28
I guess that you didn't completely understand what Riven said, you seem to not understand the logic. He just gave you the core logic. While it works in the raw form, you can make your life easier by introducing a
GameTimer
class.

1  
2  
3  
4  
5  
6  
public GameTimer(long millis, boolean loop, Runnable action)
{
    this.millis = millis;
    this.loop = loop;
    this.action = action;
}

We take the number of milliseconds to wait, whether to keep running or stop after the first run, and an action, which is a Runnable which can be invoked later when the time expires. Now, we just need start and stop methods so we can control the timer whenever we want.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public void start()
{
    this.elapsed = 0;
    this.active = true;
}

public void stop()
{
    this.active = false;
}

This is simple enough, we have the basic encapsulation of the timer. All we need now is the core logic of the timer. We'll do it in the update method of the timer.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public void update(long elapsedMillis)
{
    if (!active) return;

    elapsed += elapsedMillis;

    if (elapsed >= millis)
    {
        action.run(); // Run the action
        stop();

        // If in loop, start the timer again
        if (loop)
            start();
    }
}

That is all there is to it. Just update the timer object every time you update the game along with your objects and you are done.

I'd actually be (mildly) against this abstraction layer. The more complex your game gets, the more trickery is involved adjusting the internal state of the timers. In the end you are going to expose all fields with getters and setters and your abstraction layer is getting in the way.
24  Game Development / Newbie & Debugging Questions / Re: Delay Line of Code for X Amount of Seconds on: 2016-12-18 10:34:23
1  
2  
3  
4  
5  
6  
7  
8  
public static final int HZ = 60;

private int countdown = 0;
private int state = 0;

public void update() {
   ... [snipped]
}

This works brilliantly! One problem though, I can't seem to find a way to reset the two integers for the next level. I tried setting them back to 0 after the if statement that checks the level, but it just keeps looping again.
You can make your state-machine as advanced as you want. You can even introduce an integer for 'level', but it might be better to create a new Level class with it's own update-logic with a unique state-machine. I'm not sure what the problem is that you describe, what is wrong with looping? Once the two integers are reset to zero, it will restart all logic. Is this not desired?
25  Game Development / Newbie & Debugging Questions / Re: Delay Line of Code for X Amount of Seconds on: 2016-12-16 16:13:02
To avoid the time-sensitive issues with pauses, and other time related oddities Cas (of puppygames' fame) introduced me into the wonderful world of counters. Just get your game to run at 60fps, always. (this may be a barrier, but it's one of the best investments for your game). Then, when you need to schedule an action, you'd just do:

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  
public static final int HZ = 60;

private int countdown = 0;
private int state = 0;

public void update() {
   if(countdown == 0) {
      if(state == 0) {
         doThingX();
         countdown = 3 * HZ; // reach state=1 in 3sec
      }
      else if(state == 1) {
         doThingY();
         countdown = 30 * HZ; // reach state=2 in 30sec
      }
      else if(state == 2) {
         doThingZ();
         countdown = 10 * HZ; // reach state=3 in 10sec
      }
      state++;
   }
   countdown--;

   // do your typical update-stuff
}


Make it as complicated as your heart desires. You can have multiple counters, states that freeze counters until a certain condition is met, etc etc. You end up with a (fully deterministic) state-machine.
26  Discussions / Business and Project Management Discussions / Re: Crowdfunding in 27 Easy Steps video on: 2016-12-14 15:01:10
Awww... I should really stop reading these replies, you're making me feel sick.
27  Game Development / Performance Tuning / Re: Has anyone tried creating an optimized HashMap implementation? on: 2016-12-13 22:55:22
A similar strategy is to have N hash-functions, to calculate N possible key indexes. If the first is full, try the second, until you arrive at N, and are forced to expand your backing table. This is less wasteful, but causes lots of cache misses (but not more than a linked list).
28  Game Development / Performance Tuning / Re: Has anyone tried creating an optimized HashMap implementation? on: 2016-12-13 22:41:11
Sure, give each slot (derived from the hashcode) N keys and values.

Once the slot overflows, it's likely you have to grow your backing table, or you fall back again to (linked) lists for keys beyond N.

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  
private int calcSlot(int hashcode) {
    // precompute, and keep both keys.length and N POT,
    // to allow for some bit-magic. you'd just zero out some lower bits.
    return hashcode % (keys.length / N);
}

public V get(K key) {
    int slot = calcSlot(key.hashCode()) * N;
    for(int i=0; i<N; i++) {
      K got = keys[slot + i]; // could be null, who cares
      if(key.equals(got)) {
         // would be tempting to swap keys[slot+0] and keys[slot+i] here, for future lookups
         return vals[slot + i];
      }
    }
    return null;
}

public void put(K key, V val) {
    int slot = calcSlot(key.hashCode()) * N;
    for(int i=0; i<N; i++) {
      K got = keys[slot + i]; // could be null, treat as free
      if(got == null || key.equals(got)) {
         keys[slot+i] = key;
         vals[slot+i] = val;
         return;
      }
    }

    // dreadful logic here
}
29  Game Development / Performance Tuning / Re: Has anyone tried creating an optimized HashMap implementation? on: 2016-12-13 22:25:42
I tried, with moderate success. Even if you make the logic 10x as fast as HashMap, the L1 cache misses are going to ruin the party. If you can make any assumptions about how your lookups are grouped, try to make those keys fit in common pages. If you want performance, your data-structures will have to be highly specialized - I wouldn't expect a drop-in replacement of HashMap that was more than 10% faster in real-world cases.

I wrote a binary-search algorithm some time ago that had hardly any cache-misses (which is the last hing you'd expect from binary-search on an array), as it used a layered binary-search, should be here on JGO - I'll look it up here it is.
30  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-12-11 18:23:07
Reflowing solder connections.
Pages: [1] 2 3 ... 308
 
CopyableCougar4 (39 views)
2017-03-24 15:39:42

theagentd (25 views)
2017-03-24 15:32:08

Rule (92 views)
2017-03-19 12:43:22

Rule (79 views)
2017-03-19 12:42:17

Rule (89 views)
2017-03-19 12:36:21

theagentd (98 views)
2017-03-16 05:07:07

theagentd (98 views)
2017-03-15 22:37:06

theagentd (92 views)
2017-03-15 22:32:18

theagentd (90 views)
2017-03-15 22:31:11

ral0r2 (138 views)
2017-03-03 11:52:41
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

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!