Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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 ... 297
1  Discussions / Miscellaneous Topics / Re: File replacing bat/sh file! on: 2015-08-04 17:00:29
One 'problem' with that approach seems to me, that for the launcher to update itself, it has to be launched twice. If the launcher is broken (which is the reason you want it to update itself) this might be a no-op and the player would be stuck. (short of redownloading the installer, which contains the new launcher)

For me it was all about getting 'stage 1' to only download one file, no GUI, no threading, lean and mean - to reduce the chance that it ever needed an update. Once that works reliably you can modify the 'stage 2' updater as often as you want, without any fear that your latest updater will include a bug that will 'brick' the game and breaks the sync, forcing a redownload of a new installer by the player.

Anyway, I feel like I'm pushing it a bit too much, even when I'm 'just' explaining how we did it Pointing
2  Discussions / Miscellaneous Topics / Re: File replacing bat/sh file! on: 2015-08-04 08:18:56
You have to check for corrupted files, deleted files and locked files.

You'd do this during sync (obviously), and immediately before launching the game.

We'd have one hosted 'index' file, that listed all relative paths and (post-decompression) hashes, and start the sync from there.

3  Discussions / Miscellaneous Topics / Re: File replacing bat/sh file! on: 2015-08-03 15:16:15
Which means if the game launcher updater doesn't work, you can't do anything and nothing works.
Ofcourse, at one point, something has to work, but the game-directory must always be in a state that is launchable - that is: no partial updates, ever.

If the launcher (stage 1) doesn't work, the current version of the updater (stage 2) will be started.
If the updater (stage 2) doesn't work, the current version of the game will be started.
This implies that your installer is not an 'empty shell', you must ship a (supposedly) functioning version of your game in your installer, as people may not have a working internet connection when they first launch the game.

The updater (stage 2) is typically tiny (say, 200KB) so that the launcher (stage 1) can download and store it. The launcher does not extract DLLs or anything too advanced. The ~200KB download is so small, that the 'logic' to handle stalled downloads can basically be boiled down to: "if it didn't finish in 10s, abort and launch updater".
4  Discussions / General Discussions / Re: How does JGO use long polling? on: 2015-08-03 13:01:11
Active polling through a JDBC connection (
SELECT MAX(ID_MSG) FROM jgo_msg
at 1Hz) is not worthy of optimization. I've got better things to do than to worry about 1 second of CPU time per day Pointing

JGO is never deserted Smiley and even if it were, sobeit. It is a constant load, so if it is okay when the server is under heavy load, it's certainly acceptable if the server is idle. The most important resource to consider would be my limited time, not to get a near-idling CPU to fully idle. It would be trivial to add though, but I can't be bothered.

What you have to consider though is minimizing the Socket send/recv buffer sizes, as that can take quite a bit of RAM.
5  Game Development / Newbie & Debugging Questions / Re: 3D Frustum Clipping with Textures on: 2015-08-03 12:41:42
Any one know how to fix this? I tried making the new triangle(s)' texture vectors the same as the texture vectors on the original unclipped triangle but this isn't working.
You have to calculate the new texcoords. Try to visualize the tesselated triangle, or draw it with pen and paper, and figure out how texcoords are interpolated, to figure out which texcoords are at every pixel. Once you have that down, you can calculate texcoords for an arbitrary pixel, which leads you to the answer to your question.
6  Discussions / Miscellaneous Topics / Re: File replacing bat/sh file! on: 2015-08-03 11:20:44
But how would you sync the files without an JVM? You would be moving more and more critical logic into scripts, and those scripts are limited - multi-threading is required in such a sync, and you really want a proper GUI to show while the download is in progress.

Having said that, even with a JVM you can update the JVM by simply putting one along side the current one, and invoke its java-executable.

Anyway, I'm not saying what we did at Puppygames was the holy grail, but it allowed us to update the updater, which turned out to be absolutely necessary, as getting something as simple as downloads to be reliable was truly a headache, given DNS issues (add fallbacks to raw IP-addresses, as some DNS servers will resolve to the wrong IP for sub-domains!), misconfigured firewalls (only use port 80 and 443), crippling anti-virus suites (hash your files, check the hashes regularly - you cannot overwrite a temporarily locked file either), crappy network-connections (people barely inside their wifi-range), full harddisks (if you write until it's absolutely full, you're screwed and the player's OS may get affected), etc, etc. What happens if the player accidentally launches the game twice - and the syncs will run concurrently...

There are a ton of edge cases. You simply cannot handle this all with a .bat / .sh file properly.
7  Discussions / Miscellaneous Topics / Re: File replacing bat/sh file! on: 2015-08-03 09:28:43
There is no need for scripting.

Make this launcher jar that is bare bones, that syncs the game-updater, that syncs the game.

This three-stage setup allows you to have a tiny launcher jar (no GUI, tiny chance of bugs) that can update the game-updater (has GUI, will need maintenance) that then spawns the game.

This all happens in the same JVM - use classloaders to load in the jars after the sync.

Keep in mind that 'downloading' is actually a hard nut to crack. You will need to handle stalled connections, have retry logic, etc. You cannot rely solely on socket timeout exceptions, you need a thread that monitors the I/O per download and disconnect when throughput stalls for more than N seconds. It took us quite a few iterations to handle all corner cases.

This is how we did it at Puppygames, before ditching it to fully rely on Valve's CDN.
8  Game Development / Shared Code / Re: Extremely Fast atan2 on: 2015-08-02 22:54:33
@Riven
Yeah, it was actually really slow to use the switch statement. I however have a different approach I think I'll try.
Given these benchmarks are often unrealistic because often the array can fit in cache, why not just allocate the array offheap, get the base address / size of each element, then just use dead reckoning to pull the value. If anything it should be faster as it avoids bounds checks, Unsafe should get compiled down by the jit, and it doesn't have to load the array.
I think you don't quite understand yet how memory/caching works. Smiley The JVM doesn't load 'the array' into CPU cache at all, it merely calculates a memory address and tells the CPU to retreive the value at that address. The CPU 'notices' memory access patterns and pulls entire pages (4K) from your system memory, moving it through L3, L2 and L1 cache. Whether that memory access is caused by a field access, an array access or by Unsafe, is all the same to the CPU.

The bounds check is very likely to be removed entirely as the masking basically does that implicitly.
9  Discussions / General Discussions / Re: How does JGO use long polling? on: 2015-08-02 22:48:58
Apache is easier to overload than this crude long-poller, so why would I even bother. You can do pretty effective damage control at the firewall level - why burden applications with it.

If you look at the raw network traffic you'll see I do slightly more than this, behind the scenes, but in the end the entire setup is mostly single threaded. Naturally this thread manages a JDBC connection, that polls MySQL for the latest post-id at 1Hz. Once that changes, it is considered an event, and the responses will be sent.
10  Discussions / General Discussions / Re: How does JGO use long polling? on: 2015-08-02 22:16:38
I read the http-header, parse some shit, put the Socket in a List. The socket will be the only resource I need to retain to send a response, when I need to send a notification. At the time of an event, all objects in the list are iterated, the list is cleared, and response are written to all sockets that are connected. All new connections are put in that list again. The threadpool reading the requests and writing the responses is tiny.

This all happens right at the socket level. There are no servlets, no PHP scripts, just a List that holds pending requests.
11  Game Development / Shared Code / Re: Extremely Fast atan2 on: 2015-07-31 08:44:36
Table-lookup are almost always slow (as in much worse than using the default) in real use cases.  Especially as table sizes get large.



Then we must implement the.. final solution [Sarcasm].
We use a simple loop to generate the corresponding switch statement with the thousands of elements and paste it into a static method. You'll avoid bounds checking and the caching problem if it's compiled to a tableswitch. Have fun loading that monster of text in your ide though.
A switch statement is still a lookup-table behind the scenes. It's all memory - whether that is 'data' or 'code' is irrelevant.
12  Game Development / Newbie & Debugging Questions / Re: My map load parser is taking ages on android on: 2015-07-29 20:42:48
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html

1  
2  
string.getBytes();
new String(byte[] bytes);

specify a charset or be ready to deal with unexpected behavior. besides that, the string class should not be used for abitrary binary data, only encoded charater data. even utf-8 cannot be used for storing and retrieving arbitrary binary data. use base64 for such purposes.

having said that, use DataInputStream / DataOutputStream if you're going to use a binary format.
13  Game Development / Newbie & Debugging Questions / Re: I want to work in 3D? on: 2015-07-29 14:34:55
@KevinWorkman: the screenshot he posted is his - he doesn't seem to need to lookup LWJGL.
14  Game Development / Newbie & Debugging Questions / Re: I want to work in 3D? on: 2015-07-29 14:33:34
Any specific questions we can address? Pointing

What did you try? What did not work?
15  Game Development / Newbie & Debugging Questions / Re: Problems with UnicodeFont(Slick2d) on: 2015-07-28 16:13:01
Mipmapping.
16  Game Development / Newbie & Debugging Questions / Re: multiply a variable with a delta timestep on: 2015-07-28 11:32:06
1  
2  
3  
4  
5  
6  
7  
- velocity = velocity.multiply(0.99);
+ velocity = velocity.multiply(1.00 - 0.01 * delta);

//

x += velocity.x * delta;
y += velocity.y * delta;



Having said that - use fixed timestep instead.
17  Game Development / Game Mechanics / Re: Electric network in a tile based game on: 2015-07-28 08:39:28
If you end up with 'leftovers' you could just push those back into the network, until it's all 'absorbed'.
18  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-27 20:22:56
now replace
r / Pi_SC_Dp
with
r * Inv_Pi_SC_Dp
and you copied my code exactly Roll Eyes
19  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-27 19:23:56
The LUT is 4096 elements, so 16KB (at most 5 pages).

I think memory optimisation is a bit premature Pointing
20  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-27 16:32:49
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
 -0.5PI .. +0.5PI   min err      max err      avg err      stddev
devmaster             0.000000   0.001090   0.000502   0.000318
icecore               0.000000   0.001255   0.000395   0.000319
riven                 0.000002   0.002295   0.000968   0.000566
kappa                 0.000000   0.056010   0.029677   0.019574

 -8.0PI .. +8.0PI   min err      max err      avg err      stddev
devmaster             0.000000   0.001091   0.000504   0.000318
icecore               0.000000   0.001255   0.000402   0.000322
riven                 0.000000   0.002298   0.000974   0.000565
kappa                 0.000000   ------------- // beyond supported range
21  Game Development / Newbie & Debugging Questions / Re: My map load parser is taking ages on android on: 2015-07-27 12:57:15
1  
2  
 while ((line = reader.readLine()) != null) {
            String[] split = line.split(",");
This is a regex split, which is a very heavy operation. You'll have to check whether that is the culprit...

What is your loading time currently? 'forever' is not really helping.
22  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-27 12:26:57
Because I'm always suspicious of benchmarks written by *gasp* others... I rolled my own. There was just no way that my LUT code was 'about as fast' as some of the competition Pointing

Lo and behold, the results are completely different persecutioncomplex


Executable benchmark code:


I test the performance of:
   progressive sequence in the range -0.5pi .. +0.5pi
   progressive sequence in the range -8.0pi .. +8.0pi
   random values in a float[16k] in the range -0.5pi .. +0.5pi
   random values in a float[16k] in the range -8.0pi .. +8.0pi

N.B.: All float[]s (including the LUTs) reside in L1 cache.

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  
RUN 5, Java version: 1.8.0_45 (25.45-b02)

linear progression -0.5PI..+0.5PI:
    java.math   59.895 ns/op
    devmaster   58.804 ns/op
    icecore     35.358 ns/op
    riven        3.917 ns/op
    kappa        3.932 ns/op

linear progression -8PI..+8PI:
    java.math   82.075 ns/op
    devmaster   61.671 ns/op
    icecore     37.432 ns/op
    riven        3.909 ns/op
    kappa        4.152 ns/op // breaks beyond -2PI..+2PI

input float[]/L1 -0.5PI..+0.5PI:
    java.math   59.413 ns/op
    devmaster   58.514 ns/op
    icecore     35.255 ns/op
    riven        2.085 ns/op
    kappa        2.704 ns/op

input float[]/L1 -8PI..+8PI:
    java.math   89.183 ns/op
    devmaster   63.673 ns/op
    icecore     35.955 ns/op
    riven        2.101 ns/op
    kappa        4.669 ns/op // breaks beyond -2PI..+2PI




Linear progressions are calculated like this:
1  
2  
3  
4  
5  
6  
7  
   private static float test***Linear(float min, float step, int count)
   {
      float sum = 0.0f;
      for(int i = 0; i < count; i++)
         sum += ***.sin(min + step * i);
      return sum;
   }


Reading float values as arguments:
1  
2  
3  
4  
5  
6  
7  
   private static float test***Input(float[] values, int mask, int count)
   {
      float sum = 0.0f;
      for(int i = 0; i < count; i++)
         sum += ***.sin(values[i & mask]);
      return sum;
   }


Please point out all the glorious flaws in this micro-benchmark (and improve the code while you're at it! Smiley)
23  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-27 11:33:48
Also, I want to understand the method he is using for interpolating between table values. I just use linear interpolation
I actually don't use any interpolation. The LUT is really big - I just pick the nearest value.

I think his method is even better than the comparison indicates, because I have to manage the cursor to make sure it doesn't look up a value outside the LUT, and his doesn't actually require this.
I just mask any higher bits off. Think of it as:
(int)(input * constant) % lut.length
but because of the 'carefully' chosen constant, lut.length is a power of two, which means I can do:
(int)(input * constant) & (lut.length - 1)
. By masking off higher bits I also don't have to check the lower bound, allowing a branch-free calculation.
24  Game Development / Shared Code / Re: Extremely Fast sine/cosine on: 2015-07-26 16:21:45
If the performance is FIVE orders of magnitude off, the odds are pretty good that HotSpot basically optimized it into a constant or something similar, tuned to the benchmark. Factor 10 would be beyond expectations, let alone factor 100,000. Back to the drawing board Pointing
25  Game Development / Shared Code / Re: Extremely Fast atan2 on: 2015-07-25 19:50:47
Nice one. Pointing
26  Game Development / Shared Code / Re: Extremely Fast atan2 on: 2015-07-25 19:22:26
Nice comparison. I doubt the accuracy of dsp_atan2 is enough for game purposes, but it's indeed almost 80% faster than my LUT.
27  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-07-23 16:58:32
As a design consideration, it might be a good idea to consider keeping all this I/O stuff out of the core classes, to keep them lean and mean. What are your thoughts on hijacking cylab's idea and moving all NIO related functions to their own, dedicated class. (no, I'm not suggesting involving the Collections API Pointing) At one point you might add a dedicated class for primitive array I/O without having to worry about bloating your core classes once again.

Just throwing it out there Smiley
28  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-07-23 13:04:08
We could of course, like NIO, have both relative and absolute operations. But this would make the API more complicated by providing two different methods with two different semantics.
It is a hard decision to make.
I'm not so sure this 'complicates' the API. Choice is goodTM. It also wouldn't grow the codebase much, as the relative I/O would piggyback on the absolute I/O functionality.


If only we had structs, and this whole point was moot...
29  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-07-23 09:16:45
My vote goes to incrementing position for consistency with NIO.
NIO allows for both absolute and relative I/O. Absolute puts on buffers do not increment the position.


I'm with Spasi on this one: I never liked NIO buffers being stateful. These buffers were meant to allow access to off-heap memory, but they slapped a 'design philosophy' on top that is supposedly convenient. We should (IMHO) think of buffers like primitive arrays, but they designed it like a Stack/List hybrid. As a result it took Sun roughly a decade to get NIO performance in the same ballpark as primitive arrays, sometimes. The generated ASM is still a mess, rather inefficient (compared to primitive array access), but most of this overhead is hidden by memory latency.

Anyhoo, I'm getting offtopic, so let me end with a loaded question: who here would be in favor of stateful arrays? Kiss
30  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-07-23 09:14:23
Note that all those increments, rewinds and flips do memory writes. They do have an unnecessary performance cost.
Memory writes = only the position, limit, and/or mark variables so not really.
This is exactly what Spasi meant: memory writes to position/limit are relatively expensive, even if they are in L1. It is cheaper to keep track of the position with a local variable. Unless HotSpot already hoisted position/limit into localvars, ofcourse, but this is not guaranteed, and at one point they have to be read from main memory, and eventually the localvars have to be written back to main memory.

It's a convenience/performance tradeoff.
Pages: [1] 2 3 ... 297
 
bilznatch (21 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (45 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (51 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!