Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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 ... 72
1  Java Game APIs & Engines / JavaFX / Re: Off screen rendering, drawing images onto themselves and other shenanigans on: 2017-09-19 10:40:06
What you're missing is LWJGL.

Cas Smiley

Quite, but within the scope of the question?  Kiss


Another limitation that's fairly prominent:
if I want to procedurally generate an image (GraphicsContext onto a Canvas seems the only way?), then reuse said generated image multiple places in the scene graph, then I must snapshot it into a WriteableImage?

It makes sense that there's no way of having multiple Canvases in the scene graph share an underlying surface, as that'd break the scene compositing process.

However snapshotting requires the creation of multiple extraneous objects, and significant memory copying; it's slow.
Does the JavaFX API really have no performant way of accomplishing this very basic functionality?!?!

Java2D might have been a terribly API, but at least it was reasonably performant & logical once you got around its over-engineered abstraction, and knew what was actually happening under the hood.

It's maddening that all that seems to be requires is:


You'd then be able to leverage JavaFX's more feature-rich graphics pipeline, without being burdened by the limitations of the scene graph.
I've not been so thoroughly confounded by such a fundamentally flawed API design since I did MIDP development a decade ago.
2  Java Game APIs & Engines / JavaFX / Off screen rendering, drawing images onto themselves and other shenanigans on: 2017-09-19 08:53:38
I've been enticed by the additional blend modes available in JavaFX to have a little dabble with the API.
However doing low level stuff seems incredibly clumsy?

Am I correct in thinking that drawing to an image in vram (equivalent of Java2D VolatileImage), and then drawing said image onto another image in vram, is now only possible through composition of canvas elements in the scene graph?

If this is the case, how would the current api facilitate cyclic drawing dependency? e.g. drawing a vram image onto itself? (Or, more efficiently, onto an intermediary surface, then onto itself)

A scene graph is all well and good, but shouldn't the API also expose enough of the underlying rendering pipeline so that you can implement a comparable scene graph in user code if JavaFX's offering is inadequate?

I came to JavaFX expecting a Swing 2.0, but without Canvas exposing its underlying vram surface, the API seems needlessly clunky and restrictive for anything more complex than basic image composition.

Am I missing something?
3  Game Development / Shared Code / Re: Fast Atan2 [Again] on: 2017-09-12 13:03:08
Let make next Contest "Fast Sqrt" Smiley
From my tests in the past, Java's Math.sqrt() is pretty damn fast these days, only worth it if you can beat that method substantially.

My understanding is that the above approximation is no-longer relevant 'cos we have x86 instructional support (in various forms).
4  Game Development / Shared Code / Re: take ScreenShoot on: 2017-09-11 22:59:44

Also createScreenCapture works in screen coordinates, not Window coordinates, so your code is assuming the game window is positioned at the origin.
For your game that might be true, but in general it's a flawed assumption.

If capturing the desktop is your intent, then your code should not assume the top left of the screen begins at 0,0.
It's common for multi-monitor setups to have the primary monitor in the centre (origin: 0,0), and secondary displays to the left (origin: -width,0), and right (origin: +width,0)

To ascertain the full desktop dimensions you'll need to query GraphicsDevice(s) & GraphicsConfiguration(s) via GraphicsEnvironment.getLocalGraphicsEnvironment().
5  Discussions / Miscellaneous Topics / Re: Engineer/Programmer? sentenced in VW emissions fraud case on: 2017-08-27 23:19:25
Or at the least, make sure you at least have plausible deniability if you do so.

Umm, I don't think this is a great takeaway. The whole point is that programmers have an active role in, and as this sentence proves, a responsibility for, the code they write. Plausible deniability isn't enough.

Absolutely not!

A rigorous development process is there to relieve the programmer of all responsibility for the code they write.
The client takes responsibility for the acceptance of the design, and QA takes responsibility for the acceptance of faulty code.

Only when the programmer is wearing multiple hats, can he be accountable for his own code.
6  Games Center / Featured Games / Re: Demise of Nations for PC, Mac, Linux, Android & iOS on: 2017-08-09 10:43:08
Auxlia? Don't you mean Auxilia?

Oh never mind, looks like you might be correct; silly Latin.
7  Game Development / Newbie & Debugging Questions / Re: preven title bar to show in the part of your rendering screen on: 2017-08-03 13:43:48

Frame javadoc, 4th paragraph of the class description.

A frame may have its native decorations (i.e. Frame and Titlebar) turned off with setUndecorated. This can only be done while the frame is not displayable.
8  Game Development / Newbie & Debugging Questions / Re: [Help] PNG + transparency + PSP 4.12 on: 2017-07-17 23:17:45
Sounds like you just need to learn how to properly use your paint package of choice.

Though a small note; basic png supports 3 types of transparency;
  • full alpha channel per pixel
  • per color alpha (for palettized images)
  • simple alpha mask

Your paint package will typically use the one most appropriate & efficient for your image's color depth, though not always.
9  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-06 23:45:41
2. Implement that table via a ByteBuffer and do the lookup with sun.misc.Unsafe.getByte() to get rid of the default Java array access bounds checks.

Wow, you really are trusting the integrity of your data  Clueless
10  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-06 12:34:46
I'm almost certain that a single case switch...

         switch (c) {
         case '"':
            string(input, listener, inobject);

...will be slower than a simple if branch.
The reason being even a tableswitch involves a branch to check bounds (both upper & lower).

The index must be of type int and is popped from the operand stack. If index is less than low or index is greater than high, then a target address is calculated by adding default to the address of the opcode of this tableswitch instruction. Otherwise, the offset at position index - low of the jump table is extracted. The target address is calculated by adding that offset to the address of the opcode of this tableswitch instruction. Execution then continues at the target address.

Of course your benchmarking might have found otherwise?

#flibble dibble silly 90% quote content check#
11  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-06 11:50:43
Going back to isEscaped; granted it's a fringe case, but rather than counting the escaped characters, just toggle a boolean?

  • It would eliminate the limitation of 2 billion sequential escaped characters persecutioncomplex
  • It might be quicker. (not that it'd ever be noticeable outside of the degenerate case of every character in every literal being '\' )
  • It demonstrates the intent of the code a little more obviously

    private boolean isEscaped(byte[] input) {
        int p = pos - 1;
        boolean escaped = false;
        while (read(input, p--) == '\\')
        return escaped;

Though looking at the bytecode generated by javac 8, it appears that negating booleans is done with a branch now!? (I believe it used to be done with an xor)
Presumably that's something optimized by the JIT.
12  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-06 11:31:09
As it operates on bytes, it doesn't support non-ASCII characters, no?
It does support the UTF-8 character coding, since all recognized tokens (", :, 0-9, etc.) are also in the ASCII range (highest bit not set). Or in other words: There will not be any byte of the 1-4 bytes in a single UTF-8 character encoding that can be misinterpreted as a recognized token by the parser, since all such bytes use the highest order bits to indicate that there are more bytes to follow. Quite clever of them to design the character coding this way.
So you can use any UTF-8 encoded character you like in object key names and string value literals.

Makes sense; so ParseInterface#stringLiteral(int off, int len) is the number of bytes that make up the literal, not necessarily the number of characters.
Should make sure the ParseInterface javadoc makes that clear.
13  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-05 22:20:07
Really minor tweak;

byte c
in isescaped(...) should be an int. (As it is being used as a counter, not intermediary storage of a value copied from input)

....and the method itself should be named isEscaped(...)  Pointing

I'd also decide whether the class is going to be stateful, or not.
At the moment you're storing pos as state, but passing the byte[] & ParseListener around as parameters.

Go with one, or the other; doing both looks messy.
Given the aim is minimal weight & dependencies, I'd be inclined to make it stateless so everything can be static.
Either way, I doubt it'd have any noticeable impact upon performance.
14  Game Development / Shared Code / Re: "Better" LinkedList implementation on: 2017-06-19 14:49:23
I'd be inclined to have a reference in the Element, to the List that owns it.

It'd allow fail-fast protection against multiple logic errors (adding an Element to multiple lists/the same list multiple times, removing/moving an element from a List that it's not a member of, etc), making the code far less fragile.
15  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-24 12:20:42
@Abuse, I think all tests should allow laptops and spreadsheets, mostly for the ability to easily save and see intermediate results which is hard in a calculator, and to be able to see the history of working in prior cells' working to spot an error.

Are we imagining different examination techniques?
I'm still imagining paper examinations where the calculator simply supplements the written word; it's the responsibility of the student to record their working on the examination paper.

What you're suggesting sounds like a transition to completely digital examination, and while that paradigm shift is in the works, it's yet to become mainstream here in the UK.
I do agree though; digitally recording all intermediate working would be a much better way of evaluating a student's level of understanding, but spreadsheets are not the ideal tool for that purpose.

and regular * not x and / not รท symbols which are encountered all over the workplace and in everyday life.

Mathematical operator symbology is indeed a mess, and the pervasiveness of competing Computer Science symbology has only muddied the water further.
That's a whole different topic though.
16  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-23 16:30:15
Just to be clear, when I say "teaching programmin" in an elementary school, I expect to make it accordingly, that means no gradle or complex projects, but simple exercises, like moving an character through a 2d tiled-map. Something that also attract their attention and is, somehow, fun.

Teaching programming should be, indeed, teaching how to elaborate and process algorightms


I introduced my 5 year old nephew (mad on Minecraft) to's Minecraft Hour of Code, and he found it incredibly rewarding.
Programming (in all its guises) is already prevalent throughout our society, and will be even more so in the future; introducing it early as a 'play thing' is vital for future learning.

It's hardly a new concept; anyone remember this:

Or this:
17  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-23 13:33:52
On a related note, I always think it's incredibly dumb how students are forced to use such limited calculators in exams. All exams in math related subjects should allow spreadsheets or mathematica or Google or a programming language on a laptop.

At what level are you talking about?

No highschool student would ever need access to such powerful tools to solve the problems they're being examined on.
Moreover, having access to such tools would change the focus of the examination; you'd no longer be testing them on their understanding of the topic, but on their ability to use the tools.
18  Discussions / Miscellaneous Topics / Re: Programming in schools - opinions? on: 2017-02-23 02:31:47
Programming is logical problem solving; it's an essential life skill for everyone.
It can (and should) be taught to all young children.

Coding on the other hand (and which I suspect is what the OP is actually talking about?), is a far more specialised discipline that not everyone can grasp to the same level.
So while you don't anticipate every pupil who is taught coding at school, will go on to use it in their professional life, they will know of its existence & thus have an understanding of how computers & technology work.

The parallel would be the car; everyone uses them, most know how they work, but very few would dare attempt anything but the most superficial of servicing.

Thankfully both programming & coding have been a part of the national curriculum here in the UK for some time, so I guess someone in authority knows where society & technology are headed.
19  Game Development / Newbie & Debugging Questions / Re: Peculiar stacktrace and an error I've never seen before on: 2017-02-21 03:09:43
unless this person has a software running that does exactly that, which I wouldn't assume.

Yeah, I had that thought today too.

Perhaps you've detected someone messing around with your game in a dev environment, for some nefarious (or otherwise) purpose.
20  Game Development / Newbie & Debugging Questions / Re: Peculiar stacktrace and an error I've never seen before on: 2017-02-19 19:37:24
1st place I'd look would be JAVA_TOOL_OPTIONS or _JAVA_OPTIONS environment variables for anything untoward.
Presumably you log & report the values of these on launch?
21  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-29 23:45:43
We simply do not allow any external dependencies in a build, period. The entirety of the repository must be sufficient to produce all artefacts.

Cas Smiley


So you've got an entire VM image containing OS & apps checked in?  Grin
22  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-26 16:49:53
IME having external dependencies in a build is a bit like building your castle on sand. The build must always succeed. Discuss.

So you're advocating the inclusion of external packages with your build, rather than having them pulled from a central repository?

I'm of the opposite opinion; pulling from a central repository minimizes data duplication, and therefore fewer places for mysterious build errors to creep in.
Either you get the correct version of the correct library, or you get nothing. Fail fast.
23  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-25 16:49:27
Surprised nobody has mentioned Maven; from my limited experience with it, it's Ant done right.
Great Eclipse integration too, and you can host your maven repository directly on github.

Takes a little while to get your head around the concepts, but the way dependencies are handled makes it a dream to use (especially when you're pulling from others' Maven projects)
24  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-14 23:31:18
@cylab - Your post (reply # 29) showed me that you can use a class type as a key in a HashMap, so thank you for that.  Pointing I wanted to do that one point and didn't know it was actually possible. Also, I like the implementation you suggest as it is very clean. I'll probably try that at some point, but for now this implementation is working well.

I read in several spots on the thread that casting might smell of bad design, which I do in places, namely where a state is assigned to a Mob:
   public MobState init(Mob m) {
      brick = (Brick) m;
      return this;

The problem is that I can't assign the type and recognize the subclass methods without casting. It doesn't generate a compile time error if you pass the wrong type as an argument, but I have tested it and it will throw a ClassCastException and print a stack trace. So I was wondering if this is considered bad design and if there is a better approach? Thank you all for contributing to the thread- your expert advice has been very enlightening!

In that example, it looks like your MobState super-class should be a generic type, with the init method using the class' parameterized type for its parameter.
Something like:

abstract class MobState<T> {

public abstract MobState init(T m);

The return type could probably be parameterized too, though I've no idea what your MobState / Mob class heirarchy looks like.
25  Game Development / Newbie & Debugging Questions / Re: Type checking an init method on: 2016-12-27 15:44:54
I'd advise that you don't get yourself wrapped up in unnecessary Generics boilerplate.

What value is this bringing to your code?
Is it reducing, or increasing, complexity & readability?
26  Game Development / Game Play & Game Design / Re: The best way to normalize chances in a two-player game? on: 2016-12-09 23:14:42
IMO the large 1st-player advantage given by the rules necessitates multiple games for each level, with serve alternating between players.
Victory would then require a 2 game lead (break their serve & hold yours).
Basically Tennis tie breaker.

1st serve wouldn't matter, so decide it with a hidden coin toss.

It'd elongate each level, but it seems to me all the other alternatives are radical departures from the classic game.
27  Game Development / Newbie & Debugging Questions / Re: Concurrent Modification when changing maps? on: 2016-12-07 00:34:58
I am also not using multiple threads.

The JVM begs to differ:
I get a concurrent modification error ...

Not strictly true.

Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will throw this exception.

The provided code fragment could be doing this, but there's no way for us to know if collisionObjectLayer.getObjects() is the same Collection as ItemManager.itemList
28  Game Development / Newbie & Debugging Questions / Re: Concurrent Modification when changing maps? on: 2016-12-06 19:49:44
I am also not using multiple threads.

So where else is isLoading used?
If there aren't other threads referencing it, then it's completely superfluous.
If there are other threads referencing it, then it's almost certainly unsafe.
Either way, it's a pointer to a problem in design or understanding.

Rather than giving us a useless fragment of code, and having us guess at the cause, stick your code on github in its entirety so we can tell you precisely what the problem is.

Alternatively, learn to use a debugger.
29  Game Development / Newbie & Debugging Questions / Re: Concurrent Modification when changing maps? on: 2016-12-06 12:09:05
Looks to me like you're attempting to use the isLoading flag as a mutex.

That's unlikely to be thread safe.
You need to use proper synchronization.
30  Discussions / Miscellaneous Topics / Re: Humble monthly keys on: 2016-11-11 15:48:28
Would much appreciate Rebel Galaxy please!  Pointing

Thinking about it, I have a few keys of my own I could contribute to this thread...
Pages: [1] 2 3 ... 72
Ecumene (48 views)
2017-09-30 02:57:34

theagentd (72 views)
2017-09-26 18:23:31

cybrmynd (182 views)
2017-08-02 12:28:51

cybrmynd (180 views)
2017-08-02 12:19:43

cybrmynd (187 views)
2017-08-02 12:18:09

Sralse (192 views)
2017-07-25 17:13:48

Archive (744 views)
2017-04-27 17:45:51

buddyBro (876 views)
2017-04-05 03:38:00

CopyableCougar4 (1423 views)
2017-03-24 15:39:42

theagentd (1316 views)
2017-03-24 15:32:08
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 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!