Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  Game Development / Newbie & Debugging Questions / Re: Game running slower with many objects on: 2018-06-11 17:08:30
Centralising all your resource loading into some kind of repository is fine
However calling getSubimage every time you're drawing the image is going to be creating a new Image object. It'll share the underlying source pixel data (I think), so won't involve a *huge* amount of work, but will possibly interfere with the hardware rendering pipeline (which involves caching images in vram) thus dramatically slow rendering

So like, what other options do I have? I can obviously create 48 images and load them in the main game constructor, but it seems really dumb thing to do, what else can I try? thanks.
Image[]explosionFrames = .....

Though better yet would be to generalize what's currently contained in Explosion, into some kind of AnimatedSprite.

As I said in my 1st reply, you should profile your code to see what's the slow bit; getSubimage *might* not be the source of the problem, without inspecting how the Java2D's hardware acceleration cache is implemented it's impossible to know. (However it's a logical place to start as I've never relied upon that particular method to be performant)
2  Game Development / Newbie & Debugging Questions / Re: Game running slower with many objects on: 2018-06-11 16:35:03
Centralising all your resource loading into some kind of repository is fine
However calling getSubimage every time you're drawing the image is going to be creating a new Image object. It'll share the underlying source pixel data (I think), so won't involve a *huge* amount of work, but will possibly interfere with the hardware rendering pipeline (which involves caching images in vram) thus dramatically slow rendering
3  Game Development / Newbie & Debugging Questions / Re: Game running slower with many objects on: 2018-06-11 14:48:28
To the original question of why your current code is running slowly, it's likely one of the following:

1) You're doing something silly inside your LoadImages class (you've not provided code).
2) Your gameloop timing logic is flawed; hard to say without studying & running your code.
3) Invoking getSubimage every frame might be expensive, either copying pixels, or preventing proper caching of the image data on an accelerated surface. (just call getSubimage once, and store the result)
4) Your graphics card is some integrated solution that the JRE has identified as not compatible with Java2D's hardware rendering pipeline. (thus causing it  to use software pipelines that are many magnitudes slower)

Profile your code to identify where all the time is being spent.

While I wouldn't recommend starting a large project with Java2D*, on even moderately capable hardware, when used correctly, it's more than capable of rendering many thousands of fully alpha blended images @ 60+ fps

*take the advice given above, and learn one of the many Java bindings/wrappers for OpenGL.
4  Discussions / General Discussions / Re: VR motion sickness on: 2018-03-20 10:11:22
Not everyone wants to have to move actively when playing a game for hours.
I think that the market for games that you can play sitting lazily on the sofa, will always have a larger market than games where you have to move.
I wonder why there's no official Battletech VR game yet (Mechwarrior).

Stranglehold on licensing I imagine.

Though I'm curious how copyright Vs patent works here; would the design (3D model?) for a fictitious mechanical war robot constitute a patentable work?!
Or are they relying only on copyrighting of the various mech likenesses, and MechWarrior brand?
5  Discussions / General Discussions / Re: Gun violence in video games: Donald Trump meets with video game execs on: 2018-03-10 19:03:12
and the vast majority of the people here (including myself) being American

I'm genuinely curious if that's true; I was under the impression that there were many Europeans here.
6  Game Development / Newbie & Debugging Questions / Re: Java regex pattern for finding text between [[ ]] on: 2018-03-04 11:30:20
Don't forget to include lots and LOTS of unit tests if you want that regex to be anything but a blackbox when you (or some unlucky other) come back to it in a few months time.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java Bytecode Editor on: 2018-02-20 14:06:15
though no Eclipse plugin? Sad
An Eclipse plugin would be useful but its absence doesn't drive this editor useless especially when I see that I've found no other tool to do this job. Okay, maybe I've forgotten to talk about some not polished editors that require Python and without any binary build and I haven't tested JBE as I fear it supports only Java 1.5.

If it's up to be, why not contributing? You could make a request for enhancement and implement this feature, couldn't you?

I'd love to contribute.... but I don't have the time to work on my own projects, let alone other people's Cry
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java Bytecode Editor on: 2018-02-20 13:41:57
Looks like it'd be useful for analyzing obfuscated code (love the flow graph), though I'm still left doing the heavy lifting of building the actual transformations by hand.
Also, no Eclipse plugin? Undecided

I'd love a tool to automate the complete workflow; e.g.

- browse and edit the obfuscated code.
- tool analyses your changes, and builds code to perform those transformations programmatically.

Though for instrumenting obfuscated code you'd want the code injection points to key off certain other prominent bytecode features, which would be highly dependent upon context; rather hard to fully automate such a feature.

What I'm imagining would be similar to the code creation engines behind GUI builders, but generating bytecode transformations instead of UIs.

I guess no tools like these exist?
The closest I've seen is ASM's ASMifier (generates ASM code that'll programmatically recreate a visited class.), though that's a loooong way from what I'm wanting.
9  Game Development / Newbie & Debugging Questions / Re: Comments & feedback on this health-bars? on: 2018-01-24 17:42:08
Your UI design should stem from how the game is balanced.

Is the player going to be required to accurately read when the bar is nearly empty/full/at a precise level?
If so, the UI should give special emphasis to these states, or always present an accurate (possibly numerical) value.

Examples where precise reading is necessary:

Health bar, if health packs are sparse & over-healing is impossible.
Shield level, the there is significant mechanical difference between 0 and >0 (e.g. no damage bleed through 'shield break' state change)
Ammo clip when reloading destroys unspent ammo.
Golf swing'o'meter.
Combo-meter, when level determines if a special action is possible/impossible.
stamina meter, when level determines if a special action is possible/impossible.
etc etc

What your last video seems to place special emphasis upon is the 1/6th boundaries.
Partitioning a bar like this is usually done to indicate a significant mechanical change between boundaries.
10  Java Game APIs & Engines / Java 2D / Re: How to have BufferedImages take up less RAM on: 2017-12-08 06:57:00
Maybe I'm confused, but I recall that Java automatically caches a VolatileImage copy of a BufferedImage somewhere if you draw that image a lot, meaning that it is in fact best to use BufferedImages for your regular textures.

Essentially yes, VolatileImages are generally only of relevance for the target of a draw, not a source.
Typically of use if you're doing some fancy compositing, or buffering.

If all you're doing is drawing images, stay well clear of them.
11  Java Game APIs & Engines / Java 2D / Re: How to have BufferedImages take up less RAM on: 2017-12-05 21:47:57
- Java is an OO language, thus the term for a unit of code is 'method' not 'function'.
- Not wishing to reload the images is not a good reason to make them static.
As your program develops, the scope of your resources is likely to change; encapsulating the resources within instanced objects makes refactoring your code to accommodate such changes easier.
The typical example of this would be where your design transitions from:
a) having a single level, where all resources are held in memory at once
b) to multiple levels, where intermediary loading screens are presented to the user.
c) to, perhaps, an infinite world where resources are streamed into memory in the background as the user navigates the world.

- Images returned from ImageIO have been eligible for hardware acceleration for many years; there's no need to copy them to a new image.

As to your question:

1) Increase heap size; seems obvious, but you haven't stated whether you've tried this.
2) Don't keep everything loaded at once. As suggested above, levels + load screens, or background streaming.

It's also worth keeping in mind that every Image in the heap also occupies VRAM for its cached copy used by the h/w accelerated pipeline.
Depending upon the h/w rendering pipeline being used by Java2D (which will vary by platform, and cmdline flags), you might be wasting large amounts of VRAM because Java2D is creating power-of-2 textures that poorly fit the dimensions of your Image.
While this inefficiency won't increase your heap usage, it might significantly increase vram usage - perhaps to the point where it negatively impacts performance.
The solution here is to adopt sprite sheets, along with the associated tooling to generate them, and code to draw them.
12  Discussions / General Discussions / Re: would any of you guys be offended if on: 2017-12-01 21:10:08
Treat all religions/religious figures with equal contempt, and you'll be fine.
13  Game Development / Performance Tuning / Re: Optimal 2D rendering. on: 2017-10-18 11:53:12
For drawing a single pixel onto an accelerated surface, drawLine is faster than fillRect.

However if per pixel stuff is *all* the drawing you're doing, then do it on an unaccelerated surface direct to the image's backing int [] (exposed via DataBufferInt.getData() )

Though without hardware acceleration it's still going to be comparatively very slow; if you want to do stuff at the per pixel level, don't use Java2D.

You might be able to achieve a similar lighting effect while keeping your surfaces accelerated, but you're constrained to the composition rules defined in AlphaComposite. (The useful ones being dst_in for overlaying shadow, and src_over for applying colour). There are tutorials around on how to do this.
Though without a means of doing additive blending, you'll eventually hit a wall in what you can achieve.

Frustratingly JavaFX offers several useful (and hardware accelerated) blend modes not available in Java2D(including additive blending), but hides them behind a fundamentally flawed API design rendering them useless for the common use case.
14  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.
15  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?
16  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).
17  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().
18  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.
19  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.
20  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.
21  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.
22  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
23  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#
24  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.
25  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.
26  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.
27  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.
28  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.
29  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:
30  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.
Pages: [1] 2 3 ... 72
EgonOlsen (44 views)
2018-06-10 19:43:48

EgonOlsen (24 views)
2018-06-10 19:43:44

EgonOlsen (46 views)
2018-06-10 19:43:20

DesertCoockie (200 views)
2018-05-13 18:23:11

nelsongames (126 views)
2018-04-24 18:15:36

nelsongames (125 views)
2018-04-24 18:14:32

ivj94 (866 views)
2018-03-24 14:47:39

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

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

Solater (142 views)
2018-03-17 05:04:08
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!