Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (726)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (796)
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 ... 41
1  Java Game APIs & Engines / Java 2D / Re: Java2D physics engine? on: 2017-04-15 17:11:32
I used it for one of my experiments a while back ( https://www.youtube.com/watch?v=-M2RoOZKhNQ )

I love that you posted that video from the future!  Grin
2  Game Development / Newbie & Debugging Questions / Re: JFrame starting up slow on: 2017-04-15 17:00:33
I'm not using text anywhere else.

This is (probably) why then.  As I said, text rendering can take a little time to set up.  You could try rendering some text somewhere prior to showing your JFrame and see if that masks the issue.
3  Game Development / Newbie & Debugging Questions / Re: JFrame starting up slow on: 2017-04-13 08:46:57
Are you using text anywhere else?  Is that setFont() call definitely commented out when it's still slow?  Setting up text rendering and initialising a font can take a little bit of time.
4  Game Development / Shared Code / Re: All-Integral Alpha Compositing Using Bitwise Operators - Also New to JGO! on: 2017-04-08 11:52:19
Nice!  This old thread might interest you too - http://www.java-gaming.org/topics/some-new-blendmodes-add-multiply-overlay-etc/24529/view.html - mostly bitwise operation and multiplication.
5  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-04-06 16:47:07
Made an up-to-date video of AMEN $ Mother Function - live-coded Java lambda.  Done two gigs in the last few weeks with this too - one in Oxford, one in Athens.

<a href="http://www.youtube.com/v/SgE9POc5BdA?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/SgE9POc5BdA?version=3&amp;hl=en_US&amp;start=</a>
6  Java Game APIs & Engines / Java Sound & OpenAL / Re: Sound tool recommendations and/or javax.sound problems on: 2017-04-06 16:45:06
Wish to encourage this. (Not the sense of persecution/paranoia, but the release of a better Java audio library.)

I'm going to be working full-time for a while on Praxis LIVE and related media libraries, so this just might happen!

Maybe it would be good to start a wish list/feature list of a minimal but genuinely useful library?

A none-obvious, but key one for me, is that it's lock-free.  This is one of the reasons I don't use Beads.  And also why I haven't yet extracted some of the code out of Praxis LIVE, because outside of the environment it's not so easy to work with - however, good use of lambdas / method references in an API might make this not too painful.
7  Java Game APIs & Engines / Java Sound & OpenAL / Re: Sound tool recommendations and/or javax.sound problems on: 2017-04-06 10:11:35

Beads is great, but has the potential issue of being GPL, unlike Minim - http://code.compartmental.net/tools/minim/  Beads has a better architecture in my opinion, but I'm also biased because I contributed the audio IO from Praxis LIVE to it!  Wink

Also, probably better to compile Beads from source as there's been a variety of changes since the last release.  https://github.com/orsjb/beads
8  Java Game APIs & Engines / Java Sound & OpenAL / Re: Sound tool recommendations and/or javax.sound problems on: 2017-04-06 09:54:10
I do not know how TinySound handles this. It seems to me he has some provision for fading in and out smoothly, but I am not up on specifics of using this library.

Doesn't look like TinySound does gain interpolation either.  Sad

Other libraries to look at would be Minim and Beads, both of which are well known in the Processing community, but will work with just Java.

One day I'll get around to exporting the pure Java audio library from Praxis LIVE ...  persecutioncomplex
9  Discussions / General Discussions / Re: C++/Java Engine without GC in graphics on: 2017-03-27 13:14:53
Well, I can halve my frame rate just by turning on G1GC...

Anyone can halve the rate of anything by turning on G1GC  persecutioncomplex   Grin

Seriously, I hope they improve things a lot by the time Java 9 is out the door.
10  Discussions / General Discussions / Re: C++/Java Engine without GC in graphics on: 2017-03-27 10:18:24
You won't gain any immediate advantage just because you use C/C++.

Well, you'll probably gain an immediate disadvantage!  Wink  Yes, well written C/C++ might outperform Java, but you've got to get there first - it's easy to write C/C++ that underperforms Java.

And GC is probably not as much of an issue as you think it is.

As for "script" in Java ...  Undecided
11  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-25 12:46:46
What is a ServiceLoader? How would that work with my enums? What kind of advantages are there here?

It's the standard method built into the JDK for an abstraction to find an implementation without having any dependency on it. eg https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html

What I mean is that you build an initialization step into the abstraction API that looks up implementations at runtime using ServiceLoader. This usually involves an implementation of a provider class.  That in itself isn't specific to your enums.  As part of that initialization the abstracted API (eg. code in the enum or same package) queries the provider implementation for each int value and caches it in the required enums.  The implementations do not have to initialize the enums themselves, or know anything about what mechanism you're using to cache the constant mapping.  You manage the mechanism, initialization order, etc. in one place rather than many.

The code @Archive posted where each backend has to call back into each enum, know all the possible values, do things in the right order, etc. becomes tiresome quickly the more the API expands and the more backends you have.
12  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-24 18:37:35
If you're going to have the variables inside the enums for speed, I'd use ServiceLoader to lookup the required implementation at runtime and request the underlying values from it, rather than have the implementation have to configure the enums itself - that's ... yuck!  persecutioncomplex
13  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-24 15:06:44
Because evidently an EnumMap is just a wrapper around an array indexed with ordinal() anyway, and using EnumMap has too much overhead, bad cache coherency and will need autoboxing of the integer constants to fit them in.

That was my point, that you were reinventing it without knowing whether it's actually a bottleneck.  True, if you're mapping to int you've got the unboxing.  Where's the bad cache coherency come from in there though?  From the Integer?  I guess you need an EnumIntMap then!   Smiley  Few around.
14  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-24 11:34:18
My proposed solution would be to have the enum--->constant mapping in the backends instead. A hashmap is gonna be way too slow, but a simple array indexed by ordinal() could work.

er ... EnumMap!

OK, so I need to write more text  Roll Eyes  Why would you use an array indexed by ordinal() over an EnumMap?
15  Game Development / Newbie & Debugging Questions / Re: JavaFX audio not working properly? on: 2017-03-21 19:36:21
Well, this comment is amusing - wonder if that's still the up-to-date source?!  Roll Eyes  Good to hear AudioClip in JavaFX is just as broken as the JavaSound one then.
16  Game Development / Performance Tuning / Re: ArrayList$Itr and Escape Analysis on: 2017-03-06 13:57:03
Are you in a position to try / use Java Mission Control?  According to various things I've read, including the article you linked to, this can analyse without switching off escape analysis.
17  Discussions / General Discussions / Re: Programmer jokes on: 2017-02-05 18:50:51
Psssssst! beat ya!  Grin
18  Discussions / General Discussions / Re: Programmer jokes on: 2017-02-05 18:49:32
@DarkCart or from the other side  Grin ...

<a href="http://www.youtube.com/v/gLDFQ_IhnDc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/gLDFQ_IhnDc?version=3&amp;hl=en_US&amp;start=</a>
19  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-29 13:09:53
IME having external dependencies in a build is a bit like building your castle on sand. The build must always succeed. Discuss.
This is actually only a mild problem with maven and gradle. If you want to see this problem in an apocalyptic scope, use npm Shocked

Yes, experienced the npm hell!  Angry From what I remember you have to specify an exact version for dependencies to build against in Maven so that every build is reproducible.  That is how to handle external dependencies IMO.  The problem @princec outlines should not be possible with Maven.

 ... oh, and while I maintain a number of libraries that use Maven for build, my main project uses Ant for reasons similar to @gouessej and I really can't be bothered trying to find workarounds. Make of that what you will.  Grin
20  Game Development / Newbie & Debugging Questions / Re: LibGdx, Eclipse and Gradle about hotSwap on: 2017-01-19 14:19:32
When you attach a debugger to your application (in your case Eclipse is the debugger client), the JPDA client can issue a request (over the JDWP / Java Debug Write Protocol) to redefine a class

More specifically, it allows you to redefine the code of a method.  You cannot change the structure of a class - add fields / methods, change method arguments, etc.

Oracle's HotSpot and OpenJDK support it)

Well, as they're one and the same thing ...  Grin  usually
21  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-15 12:12:00
This solved the "instanceof" dilemma immediately. Now when I process a collision it is more like this:

1  
2  
3  
4  
5  
public void visit(BallStateNormal visitable) {
      Ball ball = (Ball) visitable.getMob();
      brick.bounceBall(ball);
                //
}


hmm .. removing the instanceof and having a blind cast is not improving things!  Doing instanceof -> cast, using visitors, pattern matching or heterogenous containers are all about filtering a collection of entities at runtime for those that are a / have a particular capability.  If you have a blind cast like that you either know at compile time the type returned, in which case that's what the method should return, or you're making an assumption that is overriding compile time checks and will eventually blow up on you at runtime.

@Abuse may be right that generics are the way to go here.  Although your concrete subclasses probably don't want to be generic or you're likely to end up needing to know genetic types at runtime (a PITA!).  So, something along the lines perhaps of BallStateNormal extends AbstractMobState<Ball>

However, also don't forget that overridden methods in Java can return a more specific subtype, so visitable.getMob() on BallStateNormal could return Ball already without generics.
22  Discussions / Suggestions / Re: Add a link to the embedded youtube video on: 2017-01-13 17:57:07
The YouTube embeds seem to work fine for me without Flash at all?!  HTML5 player in Chromium on Ubuntu.
23  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-13 12:16:54
@cylab - I use that "pattern" a lot, but then it's basically the same as the Lookup mechanism in the NetBeans platform.  Not sure if it's the fastest approach, but it's definitely one of the nicer ones.  Smiley

Incidentally, getHandler() could also return Optional to not require the supports() method, or you could even pass a consumer into a utility method on entity that does that for you. Hey, I like keeping the logic code succinct and less error prone.  Grin 

1  
2  
3  
entities.forEach(e -> e.getHandler(PoisonGasEffect.class).ifPresent(h -> h.onPoison(1)));

entities.forEach(e ->  e.with(PoisonGasEffect.class, h -> h.onPoison(1)));
24  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-12 16:45:42
I don't get the "breaking encapsulation" part here.

Well, from GoF -

Quote
Visitor's approach assumes that the ConcreteElement interface is powerful enough to let visitors do their job. As a result, the pattern often forces you to provide public operations that access an element's internal state, which may compromise its encapsulation.

In general of your examples I prefer the behaviour in the entities (your last example), but they all have their places. Also, instanceof is not likely to be the slowest - enum would probably be slower (have seen a benchmark of that somewhere). Incidentally, the pattern matching style approach to your instanceof example could be something along the lines of -

1  
2  
3  
entities.forEach(e -> when(e)
        .is(Monster.class, m -> m.kill())
        .is(Player.class, this::updatePlayer);
25  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-12 13:03:18
I agree with @princec. The code linked to by @nsigma is nothing but instanceof-in-disguise wrapped in Java 8 to make it less intelligible.

But done in a less verbose, safer and compile-time-checkable way!  It's getting closer to smart casts in Kotlin (eg. https://kotlinlang.org/docs/reference/typecasts.html)

I generally agree with the bulk of what you've said by the way - this is always for edge cases.
26  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-12 12:51:58
Jeez, that's among the most awful code I've ever had to look upon Sad

Welcome to our functional future!  Grin

4. You want to write (and hence maintain) the bare minimum of actual code

1-3 may be right (3 might depend on number of types), but 4?!  That's why I hate it.

IMO casting in OOP is one of the strongest bad smells in code, and instanceof is essentially a cast.

So is breaking encapsulation, which is why I'd shy away from both whenever possible.
27  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-12 12:12:29
Seriously, what is wrong with visitor? It's fast, it works, it catches anything awry at compile time, and with default methods on interfaces it's not even ugly any more - what's not to like?

A lot!  It breaks abstraction, adds a load of code and ends up with logic in the wrong (or less convenient) place.  instanceof and the visitor pattern are both workarounds to Java's lack of double-dispatch, the latter originating from C++ IIRC.  Needing to use either can therefore be a sign that your code is structured wrongly.  That doesn't mean that you should never use either!  A few instanceof statements may then actually perform equally well or better than the visitor pattern, not use 10x the code, and keep your logic in the right place.

I agree with both @CoDi^R and @philfrei - look at code restructuring and look at enums before using either instanceof or the visitor pattern.  But also don't listen to anyone saying that any use of instanceof is a code smell.

I like the simple (or less simple) approaches to pattern matching over the visitor pattern, because it doesn't require changes to the target classes and keeps the logic together.
28  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-11 22:54:41
IMO if instanceof is a wart, the visitor pattern is a tumour.

A) don't be overly paranoid about instanceof Some usage isn't bad. Working around the lack of multiple dispatch in Java by adding a load of boilerplate is often not worth it.

B) Java 8 is a brave new world. Check out approaches to functional pattern matching.
29  Games Center / WIP games, tools & toy projects / Re: Hexara rewrite with Java 8 & JavaFX on: 2017-01-04 10:56:42
Don't get confused! AnimationTimers are not threads. They're all invoked on the JavaFX application thread by the JavaFX pulse.

Haha, just made almost identical response on Phil's other topic - heard it from two of us now!  Grin
30  Java Game APIs & Engines / JavaFX / Re: [SOLVED] problem Adding/removing Nodes on: 2017-01-04 10:54:24
Is the animation timer actually on the JavaFX Application thread? It is a separate thread, it seems to me.

No, the callbacks are on the JavaFX Application thread, same as the Swing Timer actions are called on the EDT.  That's the whole point of these classes.

You might be better using Platform.invokeLater(..) from your audio thread.

Don't assume all the places that require updates on the FX thread will throw exceptions if you're not on it.  This is unusual, as it forces the cost of checking what thread you're on for all usage - I assume there's a good reason why some of these methods do that, perhaps due to native code interactions.
Pages: [1] 2 3 ... 41
 
Archive (291 views)
2017-04-27 17:45:51

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

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

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

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

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

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

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

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

theagentd (690 views)
2017-03-15 22:32:18
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!