Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (731)
Games in Android Showcase (217)
games submitted by our members
Games in WIP (798)
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 ... 78
1  Game Development / Shared Code / Re: "Better" LinkedList implementation on: 2017-06-20 06:40:35
imagine a pathological (but very common) case where the cache is full of objects, and then two elements are accessed repeatedly, causing them to be moved to the head of the list repeatedly. If each movement leaves a null hole, then one element would be evicted from the cache each time an element is moved to the front of the list.
Actually you could make use of this. Just don't move the object to the top of the list, if it's in the upper half (or some other threshold) already. If anything, just swap it with an object a couple of indicies up in the buffer. This way you would only produce holes for the less used objects. Since you don't need additional references, you can easily make up for the lost cache entries by increasing the array size.

Or you only move the head pointer for adding new objects and just swap existing objects up in the buffer. This would not produce any holes and while it is technically not an LRU list anymore, it might provide good enough heuristics to function as a cache.
2  Game Development / Newbie & Debugging Questions / Re: Why AnimationTimer and setTranslate on a ImageView node create jerky movement? on: 2017-06-13 09:37:27
I didn't use javafx, but having the 'now' parameter in the handle() callback method screams variable timestep to me.

You need to incorporate the now into your calculation. The javadoc says it is the timestamp of a frame in nanoseconds. You may need to save it at the first frame, so you are able to calculate the relative time to the start of the animation per frame...

Also this looks helpful: http://svanimpe.be/blog/game-loops-fx.html
3  Game Development / Game Play & Game Design / Re: has map vs instaceof for determining object kind from an arraylist of arraylist on: 2017-05-21 08:34:47
I would go with hashmapping. I don't like cluttering a baseclass with flags and also don't see any conceptional difference between entitiy.isSoldier() and entity instanceof Soldier.

This might alsobe an interesting read for you: http://www.java-gaming.org/topics/getting-rid-of/37987/view.html
4  Game Development / Newbie & Debugging Questions / Re: Null Pointer when subtracting a Vector on: 2017-04-26 12:53:02
You get a Nullpointer, if one of your variables contain a null value and you try to access a method or property on it. So in your case, at least one entry in your vertices array happen to be null.

Go on practicing using the debugger, because this kind of errors can be found easily with it. Hint: you can inspect the contents of variables in the current scope (frame) in a breakpoint, so searching for the origin of the null value should be a piece of cake, when familiar with debugging.
5  Game Development / Newbie & Debugging Questions / Re: Java ScriptEngine-Like step by step execution on: 2017-04-26 05:43:41
No  Wink

The term you are probably searching for is “continuations“ or “coroutines“. You need a library to do that in java.

See for example http://www.java-gaming.org/topics/java-continuations-and-greenthreads/28337/view.html
6  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-04-17 19:48:46
Some questions:
- Who will use the API?
- How likely is it to have anyone add a backend?
- Why would this be desireable or even useful?
- Do you plan to make a living from providing an API?
- Why is Vulkan only not good enough?
- Do you need it for your game?
- Aren't you just procrastinating to hide your creativity block from yourself?

The last one killed all my game dev ambitions years ago by keeping myself occupied with tech details until my money ran out, so don't fall for that. (You might need to work for insurance companies otherwise)
7  Discussions / Miscellaneous Topics / Re: What I drew today on: 2017-03-04 20:29:25
Wanted to draw my daughter... somehow ended up as a Scarlett Johannson lookalike Roll Eyes But I still like the outcome:
8  Game Development / Newbie & Debugging Questions / Re: Making shader 2D on: 2017-02-16 12:45:48
I don't use SLick2D, but it is implemented on top of LWJGL. It also seems to have support for shaders:
http://slick.ninjacave.com/forum/viewtopic.php?p=30305

More on GLSL shaders: https://www.opengl.org/sdk/docs/tutorials/TyphoonLabs/

You could do some of the effects you need with clever vertex animation, but in the end, learning GLSL is worth it, even if the learning curve looks a bit steep in the beginning.
9  Game Development / Newbie & Debugging Questions / Re: [Java] [Generics] How to search for a Subtype inside a Generic Collection? on: 2017-02-11 00:54:41
http://www.java-gaming.org/topics/getting-rid-of/37987/msg/363355/view.html#msg363355
10  Game Development / Game Play & Game Design / Re: Too much abstraction? on: 2017-02-08 23:34:02
By type safety, I meant my ECS returning null for objects. Any accessor can return null but that's usually a bug and/or can be prevented. For ECS, you cannot easily prevent someone from removing a component because you cannot remove mutators w/o breaking your ECS.
1. Who is "someone" removing objects from your code? Hackers? Plugin devs?
2. Have an additional component map that does not allow removal or overwriting for components you want to keep in your entity.
11  Java Game APIs & Engines / OpenGL Development / Re: Simple, solid Collada parsing on: 2017-02-08 19:41:39
There is also http://xith.org/javadoc/jagatoo/index.html?org/jagatoo/loaders/models/collada/COLLADALoader.html. I think it is not widely used and outdated, but it's standalone and might be able to serve as a converter.
12  Discussions / Miscellaneous Topics / Re: Saving, loading—oh no! Semi-tutorial discussion holy piñata thing on: 2017-02-06 18:18:44
As I said, use a datamodel. For derived data, use transient and recompute the field in readObject() or readResolve().

Btw. the danger of serializing a memory image is real when you use libs like xstream, that don't require classes to implement Serializable.
13  Discussions / Miscellaneous Topics / Re: Saving, loading—oh no! Semi-tutorial discussion holy piñata thing on: 2017-02-06 11:08:03
In my opinion, serialization is a dangerous thing to use for saving games.

(...)

Good, but then in a next version, you decided to refactor numCarsImpounded into numCarsCaptured or something for instance. When you release this version, you'll also introduce a bug, a major issue. All the existing player's game saves will be lost as serialization will fail.

This has to be solved by testing your load/save code and proper implementation of readObject() or readResolve(). Like Cas said - it would be the same, just in a different place, if you load and set values from xml/json files.

If you want to have some readable format, you can also go with the likes of xstream instead of plain java serialization.

Just make sure, you implement some kind of self contained model for your savegame, so that you don't accidently safe the whole memory image of your game Wink
14  Discussions / Miscellaneous Topics / Re: What I drew today on: 2017-02-06 09:14:42
Didn't turn out like I hoped, so I lost interest to do shading, but hey:
15  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Ongoing project: Type-Safe access to ByteBuffers on: 2017-02-05 13:34:27
Did you see http://www.java-gaming.org/topics/once-again-fast-mappedobjects-implementation/18852/view.html?
16  Game Development / Newbie & Debugging Questions / Re: Obfuscating assets on: 2017-02-01 10:35:43
A long long time ago:
http://www.java-gaming.org/topics/dll/13342/msg/106567/view.html#msg106567
17  Game Development / Newbie & Debugging Questions / Re: Obfuscating assets on: 2017-02-01 10:22:32
Isn't there a way to make it so my assets in a distributed game aren't just grab-able by the user from the explorer folder? What is this called and how do I do it?

I couldn't really find any information on it, yet I could have sworn this is a legit thing in games and other software.
Just don't bother. If they are so good that somebody want's to grab them, be happy. If they make a ton of money using them, just sue them.

There is no thing like client side security. All you can do is raise the bar, but in the end you are just hindering fans to do fan-art (free advertisement) and won't be any hurdle for real crackers anyway...
18  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-01 08:35:37
I took a break from developing my game engine and I finished a song I've been working on for a while Smiley
https://soundcloud.com/coldstream24/dreams-of-empty-skies

Do any of you produce music?
Yes, was doing some Renoise stuff (Tracker) in the past, but nothing public. Then bought a Novation Circuit to jam with my friends (https://youtu.be/5MhOYv-ymYU) and recently bought myself a present in form of an Ableton Push 2.
19  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-27 14:52:21
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
20  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Advantages of Ant? on: 2017-01-26 14:26:15
That scar thing looks like the best idea tbh.
Nah
1  
2  
3  
4  
5  
6  
7  
name: AwesomeLib
source:
    - src
    - other
---
System.out.println("The document data can be any text, ");
System.out.println("but is a convenient place to put code.");

... aaaaand there goes IDE support out of the window.

Seriously, these days it makes much more sense to start with Gradle.
+1
21  Discussions / Suggestions / Re: Add a link to the embedded youtube video on: 2017-01-13 15:46:34
@kevglass Smiley this was targeted at @riven, but indeed was caused by me wanting to see your video. Cheers!
22  Discussions / Suggestions / Add a link to the embedded youtube video on: 2017-01-13 15:38:23
My linux browser crashes, when I activate flash  Roll Eyes
So just rendering a youtube link under the embedded video player would be great.
Thanks Pointing
23  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-13 12:59:36
@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
Yupp. Can't deny my Netbeans RCP past...


1  
entities.forEach(e ->  e.with(PoisonGasEffect.class, h -> h.onPoison(1)));

For the sake of completeness, this is, how Entity would look like, then:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
abstract class Entity {
    private Map<Class<?>, Object> handlers = new HashMap<>();

    protected <T> void register(Class<T> type, T instance) {
        handlers.put(type, instance);
    }

    public <T> boolean supports(Class<T> type) {
        return handlers.containsKey(type);
    }

    // support java 8 style optional lambda execution
    public <T> void with(Class<T> type, Consumer<T> consumer) {
        T handler = type.cast(handlers.get(type))
        if(handler != null)
            consumer.accept(handler);
    }
}
24  Game Development / Newbie & Debugging Questions / Re: getting rid of "instanceof" on: 2017-01-13 09:51:58
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.

This made me think, if a more component like approach using a heterogeneous container would be desirable here:

Define what actually can happen in your game as interfaces
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
@FunctionalInterface
interface PoisonGasEffect {
    // this way, you can even require signatures for your effects
    void onPoison(int toxicity);
}

@FunctionalInterface
interface SmartBombEffect {
    void onSmartBomb();
}


Putting a registy in your Entity baseclass would allow for using composition to model the entities behaviour
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
abstract class Entity {
    private Map<Class<?>, Object> handlers = new HashMap<>();

    protected <T> void register(Class<T> type, T instance) {
        handlers.put(type, instance);
    }

    public <T> boolean supports(Class<T> type) {
        return handlers.containsKey(type);
    }

    @SuppressWarnings("unchecked")
    public <T> T getHandler(Class<T> type) {
        return (T) handlers.get(type);
    }
}


Using Java 8, you can define the effects on your Entities with relative ease:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
class Monster extends Entity {
    public Monster() {
        register(SmartBombEffect.class, () -> kill());
        register(PoisonGasEffect.class, (toxicity) -> kill());
    }
    void kill() { /* ... */ }
}

class FriendlyMonster extends Monster {
    public FriendlyMonster() {
        register(SmartBombEffect.class, () -> {}); // this basically "overrides" the effect in the _unfriendly_ Monster
        register(PoisonGasEffect.class, (toxicity) -> damage(toxicity));
    }
    void damage(int points) { /* ... */ }
}

class Arrow extends Entity {
    public Arrow () {
        register(SmartBombEffect.class, () -> remove());
    }
    void remove() { /* ... */ }
}


This works also in a more traditional way:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
class Player extends Entity {

    // or if you want to...
    private class MyUberHandler implements SmartBombEffect, PoisonGasEffect {

        public void onPoison(int toxicity) {
            damage(toxicity);
        }

        public void onSmartBomb() {
            System.out.println("HAHAHA - I told you: 'DONT MESS WITH ME!!!!'");
        }
    }

    public Player () {
        MyUberHandler handler = new MyUberHandler();
        register(SmartBombEffect.class, handler);
        register(PoisonGasEffect.class, handler);
    }

    void damage(int points) { /* ... */ }
}


The actual gameloop would then be rid of specific implementations for your Entity - it's up to you, if you consider this a good or a bad thing...
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
// ...
// Poison gas cloud! The effect is encapsulated in the Entity implementation
entities.forEach(e -> {
    if(e.supports(PoisonGasEffect.class))
        e.getHandler(PoisonGasEffect.class).onPoison(1);
});

// Smartbomb! Whatever happens will happen...
entities.forEach(e -> {
    if(e.supports(SmartBombEffect.class))
        e.getHandler(SmartBombEffect.class).onSmartBomb();
});
25  Game Development / Newbie & Debugging Questions / Re: What are you guys using for your GUI? on: 2017-01-12 10:23:54
googling libgdx gui gave me this:
<a href="http://www.youtube.com/v/ELkqiMpvMLA?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/ELkqiMpvMLA?version=3&amp;hl=en_US&amp;start=</a>
LibGDX Scene2D -- UI, Widgets and Skins
26  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-01-04 12:43:58
+1

Really nice!
The shadows are a bit off, though. Maybe you could attach and transform the shadow geometry to the outer-most pixels of the sprite's bottom...
27  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-01-03 08:38:53
Looks fantastic! Nice consistent style and kind of mystic mood. What will the gameplay be?
28  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-12-22 08:13:09
As requested, the trailer for one of our new songs:

<a href="http://www.youtube.com/v/RE6hzPKGMYs?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/RE6hzPKGMYs?version=3&amp;hl=en_US&amp;start=</a>
Nice tight drumming and smooth production. Good job!

The song itself (especially the text and the guitar at the beginning) is a bit too corny for my taste Cool
29  Discussions / Miscellaneous Topics / Re: What I drew today on: 2016-12-12 07:18:58
@basil: these would make a wonderful space shooter!
30  Game Development / Newbie & Debugging Questions / Re: Concurrent Modification when changing maps? on: 2016-12-11 09:31:35
OP doesn't seem interested anyways...
Pages: [1] 2 3 ... 78
 
Archive (335 views)
2017-04-27 17:45:51

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

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

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

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

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

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

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

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

theagentd (758 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!