Slick Forums

Discuss the Slick 2D Library
It is currently Fri Nov 17, 2017 7:11 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Jul 17, 2012 6:42 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
I propose to add the following files to Slick2D to make it simpler for the game programmer to let the user configure the controls:

  1. ControlEvent.java in org.newdawn.slick.command
  2. ControlListener.java in org.newdawn.slick.command (Sends the received control to the class that implements ControlEvent if active)
  3. ControlListenerTest.java in org.newdawn.slick.tests (This an actual example on how to use the above to let the user configure the controls)
  4. simple_button.png at testdata/

While writing and testing the ControlListener, I also found out about some potential problems and ideas of the InputProvider:
  • the HashMap in the InputProvider doesn't specify the types. Should be new HashMap<Control,Command>()
  • the InputProvider seems to have a bug that when a command has been added and removed the method provider.isCommandControlDown(c) always returns true for that command
  • It would be great if there were a nice way to serialize the provider (e.g. provider.saveTo(file) and provider.loadFrom(file)) to save the configuration to disk
  • a way to check if a control already exists in the provider: provider.hasControl(c)
  • not concerning the InputProvider but the Control: there should be a way to get a string representation for every type of Control. (e.g. Control.getName(c) similar to Input.getKeyName(i))

With these changes / additions I could cut down the ControlListenerTest a lot, but I want to know your opinion about that first.

This is my first code-wise contribution to Slick2D, so..
If there's anything you're unsure / unsatisfied about (e.g naming, scope, ..), I'm glad to discuss that with you. :)


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 3:15 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
Wow, still no comment on this (and some of my other posts). It seems the forum is close to dying due to almost no activity. :|
(Maybie we should ask java-gaming.org if they harbour us (Slick, TWL, ..) in a real sub forum. They already have syntax highlighting, more activity and most of us are probably already registered there.)

Oh.. went off-topic there.. Please give me some feedback. :)


Top
 Profile  
 
PostPosted: Sun Jul 22, 2012 5:34 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
I would say no. I don't even use these control-thingies. This controll stuff was always some util stuff imho.

Also, the thing with the HashMap can be found anywhere in Slick2D. This was done to make Slick2D useable in Java 1.4 and lower since those does not have type-safty. We no have 1.5 (or 1.6) as target, so eventually all HashMaps should be changed.

If you want to save the configuration, why would you want to use Serializable? Imho you should use a Property file for that or your own saving... But I also thought Serializable was good before I just switched to streaming, where I only save the IMPORTANT information (afair. Java saves extra bytes for packages and such)

For naming, you should use toString. toString should serve as a reprensentation (right?). So just override it and use it :)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Mon Jul 23, 2012 12:04 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
R.D. wrote:
I would say no. I don't even use these control-thingies. This controll stuff was always some util stuff imho.

Yeah, but it is already part of Slick2D. Maybie we can put this together with the commands folder (and things like TiledMap(Plus) that aren't necessarily needed to make a game, in a new slick-common.jar. What do you think?

R.D. wrote:
Also, the thing with the HashMap can be found anywhere in Slick2D. This was done to make Slick2D useable in Java 1.4 and lower since those does not have type-safty. We no have 1.5 (or 1.6) as target, so eventually all HashMaps should be changed.

I agree (and there's already Java 1.7). It's type-safe and it probably increases performance.

R.D. wrote:
If you want to save the configuration, why would you want to use Serializable? Imho you should use a Property file for that or your own saving... But I also thought Serializable was good before I just switched to streaming, where I only save the IMPORTANT information (afair. Java saves extra bytes for packages and such)

For naming, you should use toString. toString should serve as a reprensentation (right?). So just override it and use it :)

I'm not sure, because toString is normally used to represent the java object (e.g. for debugging). Look at this (and the implementation): toString.

I think we should just use String Control.getNameOf(Control c). If the Control is a KeyControl it should return the same as Input.getKeyName. For the other Controls, the following should be fine:
MOUSE_1, MOUSE_2, MOUSE_3
CONTROLLER_{n}_LEFT, CONTROLLER_{n}_RIGHT, ..
CONTROLLER_{n}_BUTTON_{m}


Top
 Profile  
 
PostPosted: Sat Aug 04, 2012 3:57 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
Is there no interest in (discussion about) adding this to Slick2D or what is the matter? :|


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 8:32 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
Hello,

for my part, I sadly fail to see the use of this addition. Keep in mind that Slick2D is currently already extremely bloated, filled with features that are partly entirely unused/unusable.

At the end I think this way:
"Small" games don't have configurable controls. At least I do not know any and in most cases its not useful to allow the controls to be altered, since it makes the whole code more complicated.
Larger scale games that implement such features usually implement this in a very application specific way, leading to your work to be not usable again.

I am not saying that no one will ever use your work, but I do not thing that it should be part of the core of Slick2D as there are limited cases where your addition will be needed.
I suggest you develop and publish your work as a extension to Slick like there are so many others. This way developers can choose if they need your addition or not.

Regards,
Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 12:59 pm 
Offline

Joined: Sat Jun 23, 2012 4:14 pm
Posts: 74
Location: Germany
Nitram wrote:
Hello,

for my part, I sadly fail to see the use of this addition. Keep in mind that Slick2D is currently already extremely bloated, filled with features that are partly entirely unused/unusable.

At the end I think this way:
"Small" games don't have configurable controls. At least I do not know any and in most cases its not useful to allow the controls to be altered, since it makes the whole code more complicated.
Larger scale games that implement such features usually implement this in a very application specific way, leading to your work to be not usable again.

I am not saying that no one will ever use your work, but I do not thing that it should be part of the core of Slick2D as there are limited cases where your addition will be needed.
I suggest you develop and publish your work as a extension to Slick like there are so many others. This way developers can choose if they need your addition or not.

Regards,
Nitram


Thanks for your answer! :D

In my opinion every game should have configurable controls, because there are many gamers who have non-QWERTY layouts (for example in foreign countries or me using the NEO layout) and thus having a hard time playing the game with the default controls (for example "S" (often used with WASD) is on the right side of my keyboard). And Slick isn't only for small games. There is a commercially successful game in germany that I know of, that uses Slick: Edna bricht aus (english version)

btw. As far as I have played (am still playing it) It's a pretty hilarious and a good game! (If you like click and point adventures with such a humor, I can recommend it. :))

Back to topic: What do you think about the things written in the bullet points?


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 1:35 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
This is very "game specific" stuff. Slick2D isn't supposed to encompass every single aspect of making a game; if you want those high-level features then it would be better suited as an extension.

This is my 2c. There are already bugs with Slick, and adding more layers of complexity will mean adding more need for maintenance. If you want to contribute to Slick, the best thing to do would be to send us pull requests that fix some of the bugs or longstanding feature requests.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group