Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (746)
Games in Android Showcase (226)
games submitted by our members
Games in WIP (827)
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 ... 6
1  Games Center / WIP games, tools & toy projects / Re: Ashworld on: 2017-12-16 15:29:15
 Pointing For all of us looking to make revenue with our games, this is incredible information. Thank you.
2  Game Development / Newbie & Debugging Questions / Re: Wrapping my head around Generics on: 2017-12-08 19:07:22
Thank you for the reply. It lifts my spirits to know I was not only on the right track, but also so close to a solution.
Here is what I have come up with for the EventBus class:

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  
public class EventBus
{
   private Map<Class<? extends Event>, List<MonoCallback<? extends Event>>> eventListeners;

   public <E extends Event> void registerEventListener(Class<E> clazz, MonoCallback<E> listener)
   {
      List<MonoCallback<? extends Event>> list = eventListeners.get(clazz);
      if (list == null)
      {
         eventListeners.put(clazz, list = new ArrayList<>());
      }
      list.add(listener);
   }

   public <E extends Event> void pushEvent(Class<E> clazz, E event)
   {
      if (eventListeners.isEmpty()) return;
      if (!eventListeners.containsKey(clazz)) return;

      List<MonoCallback<? extends Event>> list = eventListeners.get(clazz);
      if (list == null) return;

      for (MonoCallback<? extends Event> listener : list)
      {
         MonoCallback<E> castedCallback = (MonoCallback<E>) listener; // Type Safety: unchecked cast...
         castedCallback.invoke(event);
      }
   }
}


Line 25 produces a type safety warning, is there any good way of getting around, or a better design to avoid this warning. Or must I live with it?
3  Game Development / Newbie & Debugging Questions / Wrapping my head around Generics on: 2017-12-08 17:51:23
I am trying to create a sort of event bus that can handle multiple different events and their listeners.
The goal is that every event would inherit from a super Event class, the event bus would register that event, and listeners could subscribe to it.
This is probably easier to explain in code:

Event class and possible subclasses
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  
30  
31  
32  
33  
public class Event
{
    public final String eventName;
    public final long timestamp;

    public Event(String name, long time)
    {
        this.eventName = name;
        this.timestamp = time;
    }
}

public class UpdateEvent extends Event
{
    public final double delta;

    public UpdateEvent(double delta)
    {
        super("Event.Update", currentTime);
        this.delta = delta;
    }
}

public class FileUpdatedEvent extends Event
{
    public final File file;

    public FileUpdatedEvent(File file)
    {
        super("Event.FileUpdated", CurrentTime);
        this.file = file;
    }
}


EventBus class
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public class EventBus
{
    private Map<Class<? extends Event>, List<MonoCallback<? extends Event>> eventListeners = new HashMap<>();

    public <E extends Event> void registerEventListener(Class<E> clazz, MonoCallback<E> listener)
    {
        List<MonoCallback<E> list = eventListeners.get(clazz);
        list.add(listener);
    }

    public <E extends Event> void pushEvent(E event)
    {
        list<MonoCallback<E> list = eventListeners.get(event.getClass());
        for(MonoCallback<E> listener : list)
        {
            listener.invoke(event);
        }
    }
}


Listener
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public class SomeClass
{
    public SomeClass()
    {
        instance_of_eventbus.registerEventListener(FileUpdatedEvent.class, (event) -> {
            File file = event.file;
            //do stuff
        }
    }
}


Obviously, the above lacks any sort of polish with null checks and what not, and... of course all fails. But hopefully you understand the point.
So my question is,
First; is there a way to enforce that the Class key and generic parameter in MonoCallback in the eventListeners map are the same?
Second; when the callback is invoked, that the passed event parameter is ensured to be an instance of the proper Event subclass, not requiring instanceof checks and casting on the listener end? (SomeClass example)

I have been messing around with this for quite some time, and have not come to a satisfactory solution, and any online research is so jumbled and confusing that it makes my head hurt.
For the record... I hate generics  Undecided
4  Discussions / General Discussions / Re: JGO Twitter List on: 2017-12-08 14:32:21
@brotazoa
5  Discussions / General Discussions / Re: would any of you guys be offended if on: 2017-11-30 14:25:14
This is a great idea! I think you should roll with it.
6  Discussions / General Discussions / Re: Gosh, it's quiet in here on: 2017-11-11 16:34:27
It might be worth noting that a few months ago we moved away from the JGO IRC and now instead have a mildly active Discord server with ~40 people. If anyone wants to join, here's a link:

https://discord.gg/VSyAXCB

How am I just hearing about this!!!!! I have been quietly awaiting a Discord server for here for some time now!

Edit :: Is there a way to have a feed on the Forum, kinda like the shout boxes of old, linked to #general with Discord?
7  Discussions / General Discussions / Re: Gosh, it's quiet in here on: 2017-11-10 15:46:57
I don't think it is so much an issue of theme, SMF is kinda garbage.

At the end of the day a Forum is about the content. A good platform with a good theme are both desirable things, but a pretty looking ghost town is just that. Updating the site to be reasonable on mobile would help a lot I think. But looks are not going to encourage content creation. The 'Minecraft craze' is dying down or gone, so Java certainly has lost some appeal for game creation, there are a lot of JVM languages that are getting attention, like Kotlin. Maybe the Forum could draw more attention as JVM-Gaming.org  persecutioncomplex
8  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-11-10 15:32:47
Looks great ^

Do let us know when you have something playable!
9  Game Development / Newbie & Debugging Questions / Re: Loading, Screens, and General Trickery on: 2017-11-10 15:30:57
I don't really have much to say from my own experience on this topic, but take a look at libGDX's approach in their scene2d scene graph. Specifically the SequenceAction.
https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/scenes/scene2d/actions/SequenceAction.java
10  Game Development / Newbie & Debugging Questions / Re: Saving a "map" into a single file on: 2017-10-23 20:19:55
Quote
Why save all information about a level, even resources? If resources are static, you don't need to save images, or level structure, but only entities state (position, hp, etc...)

I'm afraid I don't quite understand what you mean. If I don't save these resources (images, level structure, etc.) then how...[snip]

This is not what Gornova meant. Your game should have resources shipped with the game itself. The images, sounds, and the like should come with the game, where as a save file like a map should only refer to those resources and keep information like positions, states, and other variables. The Game and all the resources needed are distributed as one package/zip/jar and saves are separate, and if you would like to share a save file the recipient would need a copy of the base game with all the resources first. I hope that makes sense.
11  Discussions / General Discussions / Re: Linux builds on: 2017-09-07 02:37:02
I hate to say this, because it's kind of a "well... thanks for nothing!" type of answer but.. Linux doesn't have a unified way of doing this. My experience is limited to Debian based distros and the way they do it is to have a .desktop file somewhere. And that somewhere is also up in the air depending on desktop environment. But here is a link to setting up a desktop file for modern versions of Ubuntu running the Unity environment:

https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles

Hope this helps a little.
12  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-06-06 12:49:05


Mobile games are all about cool vector graphics nowadays, but I prefer working with text, and SVG is a pain. So I glued JRuby to Java2D and made an editor for it with Swing Cool

This is really cool! How feature complete is it? What format does it save / load from? Open Source? Plans for release?
I would love to try it out, I too prefer working in text for vector graphics.
13  Game Development / Game Mechanics / Re: Simulating orbital gravity with a prediction of trajectory (Multiple attractors) on: 2017-02-21 00:01:39
Maybe this will be of use: https://youtu.be/OAcXnzRNiCY
<a href="http://www.youtube.com/v/OAcXnzRNiCY?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/OAcXnzRNiCY?version=3&amp;hl=en_US&amp;start=</a>
14  Game Development / Performance Tuning / Re: JNI passing data from Native to Java on: 2014-10-28 18:02:55
you're too used to a JVM!
15  Discussions / Miscellaneous Topics / Re: Getting back in touch with reality on: 2014-05-29 15:11:02
I think it is inevitable. Any time you are doing one thing long enough, no matter how fun/engaging/rewarding/challenging it is, you will need to take a step back and do something else. Otherwise you burn out, and then you hate it for a long time. I routinely take breaks from programming, so much so that my breaks are more or less scheduled. Typically I will program for about 2 weeks straight, then take a week to do something else. One of the reasons I love programming games so much is that there is so much more to do than programming! There is art, music, sound effects, character building, etc. Keeps me from getting burnt out, and I find that if I was stuck when I took a break and came back I was able to solve the problem with fresh eyes!
16  Discussions / General Discussions / Re: New feature: topic labels [solved] on: 2014-05-07 02:37:28
This is a really great feature!

Could we add an [unsolved] label? Maybe make it yellow?

That way if I am in a question-answering-mood I know at a glance which threads to pop into, or if I can't be bothered which ones to avoid  persecutioncomplex
17  Discussions / Miscellaneous Topics / Re: Can anyone give me 10 words all related to one thing in common? on: 2014-04-01 15:11:21
one, two, three, four, five, six, seven, eight, nine, ten. All these words are related to numbers!  Grin

had to do it, sorry.
18  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-01 15:07:32
Off topic just a little bit,

@cas

If you are looking for a good Linux system, I recommend Ubuntu-Gnome. They do away with the god-awful Unity Shell, and replace it with the Gnome 3 desktop environment. You still get all the benefits of vanilla Ubuntu (updates, applications, and upstream bug fixes) but with a usable workflow instead. If you are looking for Linux, then IMHO Ubuntu-Gnome is the way to go right now.

one-stop-page
Downloads
19  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-01 05:19:45
I always recommend building your own, and if you're going to build your own, then I always recommend this site:
http://pcpartpicker.com/
20  Discussions / General Discussions / Re: Programmer jokes on: 2014-03-17 21:18:24
Software is a lot like sex, make one mistake and you have to support it for the rest of your life.
21  Game Development / Newbie & Debugging Questions / Re: Compile and Debug Java on: 2014-03-09 19:40:24
Eclipse > Intellij > Netbeans. IMO

...


but what about BlueJ?
22  Games Center / WIP games, tools & toy projects / Re: Platformer - SAGL 1.0 on: 2014-03-08 05:08:46
the topic is empty...   Undecided ... what is this?
23  Games Center / WIP games, tools & toy projects / Re: eXo - snappy space strategy on: 2014-02-17 23:06:14
I played your 4k entry for hours! It is really nice to see a full game come out of it. Good work.
24  Games Center / WIP games, tools & toy projects / Re: Pixel Battle Arena //prototyp on: 2014-02-04 17:46:09
This looks amazing! Nice job man, I love the pixely graphic style. Looking forward to future development.
25  Games Center / WIP games, tools & toy projects / Re: Galactic Progress on: 2014-02-02 07:20:47
So how is this project going? Any recent updates?
26  Game Development / Artificial Intelligence / Re: Active Time Battle AI :: Am I doing it right? on: 2014-01-10 17:49:12
This looks pretty good to me. I would be interested to see the final version.
27  Games Center / WIP games, tools & toy projects / Re: Headline Benchmark on: 2013-12-19 05:46:38
Well, that was fun. Watching my computer transform into a jet turbine and fly around the room, barely held down by its power cord!  Grin

I don't think that the results were submitted though, I got a 'not supported error' in the terminal when I hit submit... still fun.
28  Discussions / Suggestions / Re: OP Marks/Tags? on: 2013-11-05 23:21:04
I think highlighting the op's posts would be a good idea. Similar to how post highlighting works currently. Though I think this is more of a suggestion to take up with the SMF guys, not here.
29  Games Center / Contests / Re: One Game A Month - November Edition on: 2013-11-05 23:18:35
+1 for a Google+ sign in. [see what I did there  persecutioncomplex ]
30  Java Game APIs & Engines / OpenGL Development / Re: Why Can't I Find Bitmap Fonts? on: 2013-10-26 22:02:17
I made a pretty good Font Loader that creates bitmap fonts from True Type Font files, and the built in Java Fonts. It is part of my home-brew game engine, GenesisEngine, and you can find the related files here, and here. If you are interested.
Pages: [1] 2 3 ... 6
 
xxMrPHDxx (74 views)
2017-12-31 17:17:51

xxMrPHDxx (38 views)
2017-12-31 17:15:51

xxMrPHDxx (43 views)
2017-12-28 18:11:33

Ecumene (214 views)
2017-09-30 02:57:34

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

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

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

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

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

Archive (1087 views)
2017-04-27 17:45:51
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
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!