Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (575)
Games in Android Showcase (154)
games submitted by our members
Games in WIP (623)
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  Game Development / Newbie & Debugging Questions / Re: LibGDX and Scene2d - simple menu issue on: 2015-04-16 06:48:41
I'm not sure what the weird behavior is you are experiencing, as the table does what you told it to. Your first example would create a table with 1 column and 4 rows, the second example will produce a table with 2 columns and 2 rows.

If you want to understand how the table functions it's best to check out the docs of the github project: https://github.com/EsotericSoftware/tablelayout

If you understand what is explained on that page you should be ready to go to make some layouts. One last note. Don't try to make your tables too complicated. You can nest them (put a table in the cell of another table) and achieve more complex layouts with this. Just make a draft of your screen on paper and try to find out how you could structure the screen with the help of tables.
2  Games Center / WIP games, tools & toy projects / Re: Airships: Conquer the Skies on: 2015-04-02 07:56:04
Hey, you are getting famous Cheesy

I've found very small article about your game in todays 20min (a local free 'news paper'):
 http://m.imgur.com/TjxNBZG.png

Sorry, but I could not make any better picture with my phone.
3  Game Development / Game Mechanics / Re: [LibGDX] Start Game with Spring Framework on: 2015-03-28 15:38:58
How do you start your game with spring framework?

If you want to understand how LibGDX is structured it's probably best you create a project with the libgdx setup and try to fiddle around with it a bit.

When you generate your libgdx project, you have one main project containing your game code and you have separate projects for each target environment (desktop, android, web etc.). You can find *Launcher.java files in the target projects.

This is the startup code from my DesktopLauncher.java

1  
2  
3  
4  
   LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
   config.width = 800;
   config.height = 600;
   new LwjglApplication(new Matcher(), config);


In this case Matcher is my main class extending ApplicationAdapter. I think this should be what you need to start your LibGDX application.

Just one thing to consider if you want to use spring. I am not 100% sure but I could imagine that it won't work (or will be a pain to port) with android and web projects. If you don't care about these platforms then you should be fine, otherwise I would investigate if you can even use it and if yes how hard it will be. Could save you some time in the long run.
4  Discussions / General Discussions / Re: How will an Araknoid do? on: 2015-03-26 11:09:52
Yes do that, you have to start somewhere. Arkanoid is simple enough so you can implement a basic version rather quickly, but it allows you a lot of room for improvements and tweaks in graphics and gameplay. Get the bare game running, add a menu, highscores, more features and polish it up. Don't try to do too much but rather try to create something that feels like a complete game, even if it's a basic one.

And watch this: https://www.youtube.com/watch?v=Fy0aCDmgnxg Wink
5  Game Development / Newbie & Debugging Questions / Re: LibGDX Changing Texture Color on: 2015-03-06 13:21:14
Not sure if I or the others are missing the point...

From what I understand you want to take a grayscaled image and apply a color to it (if you would use red for coloring the different shades of gray would change to different shades of red).

If this is your question then check out spriteBatch.setColor to set the rendering color before you draw the actual texture with a SpriteBatch.

I you are using scene2d then you can set the color via  the actors setColor method.
6  Game Development / Newbie & Debugging Questions / Re: (LibGdx) Controlling an animation on: 2015-03-01 12:25:41
Thanks, it worked perfectly. I can't medal you for some reason sadly.

A thanks is fine. Glad it worked.
7  Game Development / Newbie & Debugging Questions / Re: (LibGdx) Controlling an animation on: 2015-03-01 02:33:40
If I'm not mistaken the second parameter of getKeyFrame is the looping parameter. Once you click animateIt it is set to true, hence your animation starts to looping.

Change following things:
- Only update state time when animateIt is true.
- Use false as second parameter in getKeyFrame
- Reset the state time to 0 when the mouse has been clicked.

With this the image will be the first key frame of the animation, until you click. When you click the animation plays and should stop at the last key frame. When the user clicks again, it starts from beginning.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
@Override
public void render() {
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);                        // #14
+   if(animateIt){
      stateTime += Gdx.graphics.getDeltaTime();           // #15
+   }
-   currentFrame = walkAnimation.getKeyFrame(stateTime, animateIt);  // #16
+   currentFrame = walkAnimation.getKeyFrame(stateTime, false);  // #16
   spriteBatch.begin();
   spriteBatch.draw(currentFrame, 50, 50);             // #17
   spriteBatch.end();
           
   checkClick();                               ////////////////////
}

public void checkClick() {
   if(Gdx.input.isButtonPressed(0)) {
      animateIt = true;
+      stateTime = 0f;                                
      System.out.println("Start you animation!");
   }
}
   



It would probably be good to check if the animation has been completed and set animateIt to false, if so.
8  Game Development / Newbie & Debugging Questions / Re: LibGDX Tilemap Rendering on: 2015-02-25 00:13:25
Neither of those post have my answer. I'm looking for a way to include camera culling with a Tiled Map renderer. I know how to render tile maps.
I do search, but with the little documentation LibGDX has on TiledMaps its difficult to find a good preforming method.

The first link has the answer to your problem (haven't bothered to look at the second one).

Quote
Before you can start rendering, you have to set the view on your map. Think of the view as window through which you look. The easiest way to achieve this, is to tell the map renderer about an OrthographicCamera it should use:

1  
mapRenderer.setView(camera);

Alternatively you can also specify a projection matrix and the view boundaries manually:

1  
mapRenderer.setView(projectionMatrix, startX, startY, endx, endY);


I strongly suspect that the map renderer takes care of the culling for you when you set the view bounds.
9  Discussions / Miscellaneous Topics / Re: How to get started with music production on: 2015-02-11 13:44:27
- proper audio device (usb = pain, pci = noise when recording, firewire = best). i use this one : http://global.focusrite.com/firewire-audio-interfaces/saffire-pro-24 . had bad experience with usb, tho' those are usually good too.

Just a short addition to this comment. Use firewire when possible, but test it first. Firewire runs fine on macs, but on windows notebooks you often only find the small firewire plug (which does not include power over firewire). Also like 5-7 years ago firewire had a very bad name on windows machines in producer circles (especially on notebooks). If the firewire port was usable for audio hardware depended strongly on your chip set (it went so far that even the same notebook model sometimes worked and sometimes don't, because they don't always use the same chips).

In general I agree with basil, if possible use firewire because the protocol is much better suited for audio stuff than USB. But if you don't use a mac, then test the device thouroughly... I ran into this trap once. My notebook could not handle my firewire interface properly (it worked but I got drop outs all 5-10 minutes, which is not tolerable in a live environment).
10  Game Development / Shared Code / Re: LibGDX Lightning Effect Code on: 2015-02-11 11:06:46
Nice... Thanks for sharing. Might probably have a use for this in my project.
11  Discussions / Miscellaneous Topics / Re: How to get started with music production on: 2015-02-11 10:58:27
i dont think you can get far with 250 bucks. to me the most important things are

- proper headphones + proper monitors (not laptop speakers, no crappy logitech 2.1 "sound system"). i can recommend akg, pretty much any of theirs (http://personal.akg.com/). ESI nEar monitors, old but good (http://www.esi-audio.com/products/near05experience/).
- proper audio device (usb = pain, pci = noise when recording, firewire = best). i use this one : http://global.focusrite.com/firewire-audio-interfaces/saffire-pro-24 . had bad experience with usb, tho' those are usually good too.
- proper DAW (not magix music maker)

you can get away with trying to get whatever sounddevice you have to run with asio4all (http://www.asio4all.com/). might work. it also depends on what you want to do. if you need recording and realtime playback at the same time you need powerful hardware; if you do not care about latency you can get away with any device.

you can skip the monitors and headphones since this is really requried when you do a mixdown/final-tuning, making music is more about making music. tho' it's much nicer having a good monitors around (even if you just listen to music).

the DAW itself could be cheap if you want a full-version. i can recommend http://www.renoise.com/ if you like oldschool trackers with vst2 support.

if you're looking for realtime multitrack recording, i think the cheapest recorder for home users is still the zoom r16. http://www.zoom.co.jp/products/r16

but as with the games around here. just start recording/tracking stuff with whatever you can, nobody cares about sound-quality if the music is good. oh, if you need a simple reliable midi interface too hook up keyboards i can recommend http://www.m-audio.com/products/view/midisport-2x2-anniversary-edition but i think you got that covered already.

Sounds like reasonable advice. In todays world of virtual music studios you have a sheer amount of possibilities. Don't get overwhelmed.

In my opinion you should look for following:
- Good monitors / headphones (I would prefer monitors, because passable headphones are much more expensive than passable monitors. Also it's easier to make a clean mix with monitors).
- A decent machine. You don't need a high end machine, but it can help depending on what you use. SSD's are very handy when you are using IO heavy instruments.
- A software that suits you. I know lot of folks that are using cubase. I prefer ableton live as it has a much simpler interface and some nifty features for live scenarios. If you have any questions for ableton live, I would consider myself very profficient with the software. Other alternatives I would consider at least semi professional are Logic, StudioOne, Fruity Loops. At your beginner level it really doesn't matter which one you chose, just make sure you feel comfortable with it.
If you really just aim at chiptunes / 8bit game sound, it might be worth checking out trackers.
- An audio interface. Consumer sound cards are not really nice for audio production as they have very bad drivers. Check out native instruments, m-audio etc. for cheap and solid (given the price) external interfaces. If you don't have the money yet for an external interface, then check out ASIO4All. It's a free audio driver which yields better performance for production software, even on consumer cards.

One point I find interesting is the abundance of available  software instruments. Don't try to have every synthesizer there is, but chose one or two you really like and then learn how to use them properly. Move on the the next synths, when you think you understood them in and out. The thing is many synths are based on a similar idea, so once you get the hang of one synthesizer, the others will be much easier to understand (though there are exceptions to this rule Wink ).

Another thing to consider are samples. There are many kind of samples. Some are whole loops or phrases, others are just single sounds like drum hits etc. Ableton live feels kind of naked without any samples. You can record your own samples, find some on the internet (for free or to buy in packs). Over the years I have collected many samples (bought, recorded, received from friends and other producers etc.).

This leads me to the next point. One of the most important thing you can build as a producer is your own collection of sounds, presets, samples, effects etc. On one hand it makes it easier for you when you start something new to get some cool sounding things together, on the other hand you can build your own signature sound (have recognizable elements throughout your music). You first few atempts at making a song might be very bad (I know I didn't produce anything worth listening in the first 2 years), but you probably are able to create some cool unique sounding synths.

Also please keep in mind, it is not like you start producing music and will instantly create a nice sounding song. If you have a musical background it might be easier for you, but expect it to be a long way to where you want to be.
12  Games Center / WIP games, tools & toy projects / Re: SOLIS on: 2015-01-08 18:31:33
The background looks very nice. I like that it isn't just flat black. Made a big improvement there. It would be nice if there was a bit of color variation. I really like it when "space pics" (or visualization of space in games) have a bit variation in colors (random example from google image search: http://www.hdwallpapers.in/walls/fantasy_space-wide.jpg ). It could be subtle just fading a bit to dark red or so.

I the text in the menu buttons on the top left hard to read. Probably it would already improve, if you make it a bit lighter (or add an outline).

The ships look a bit too "tiled" with only square tiles. You could add some pieces to give your ship some nicer outlines (and not everything in 90° angles).

The UI looks functional, the icons are basic but I think they do their job.

Other than that, not much to say as I can't see any gameplay. The idea sounds interesting. Kind of an open world FTL with multiplayer Wink
13  Game Development / Game Play & Game Design / Re: Transfer an item from world to inventory [SOLVED] on: 2015-01-06 15:25:34
Have you thought of seperating an item and the definition of one? The definition contains the name, description, properties (special stats, buffs etc.), sprites. If you have this you can have a "GameObject" item which is displayed in the game world. This item references a definition. If you then pick up the item, you can "destroy" the item instance and just reference the definition from your inventory... When you drop an item from your inventory in the game world you then just need to create a new instance again. To save space in the inventory you could make an "InventoryItem" class which references the item definition and has an integer to store the item count.

I would do probably something along those lines. Hope this gives you some ideas. Probably have a look at the flyweight pattern ( http://gameprogrammingpatterns.com/flyweight.html ), which is basically what I'm suggesting here.
14  Game Development / Newbie & Debugging Questions / Re: [LIBGDX] AI with Libgdx on: 2015-01-03 06:53:15
You need to update your build.gradle file, located in your project root.

In the allprojects/ext part you can define a variable to store the version number of gdx ai at one place (I'm using 1.4.0).

1  
2  
3  
4  
5  
6  
7  
8  
allprojects {
...
    ext {
        gdxVersion = '1.4.1'
+        gdxAiVersion = '1.4.0'
    }
...
}


Then you have to add a compile action to each of your projects. Here the example for the desktop project:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
project(":desktop") {
    apply plugin: "java"

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
...
+        compile "com.badlogicgames.gdx:gdx-ai:$gdxAiVersion"
    }
}


Do the same for the other projects ( "core", "android", "html"). Note the $gdxAiVersion part, which takes your predefined version number... If you want to update to a new version, you just need to change it at one place.

When you updated the build.gradle file you can rebuild your project from command line with gradle or use the eclipse gradle tools to rebuild/refresh, if you are using eclipse. After the refresh you should be able to use the gdx-ai stuff.

Not sure if you have to provide something special for html and android versions, but it should work at least for desktop, if you add the compile line into core and desktop project. Hope this helps.
15  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [libgdx] Anatomy of an HTML5 Project? on: 2014-12-30 13:24:40
One little note for the gwt output. I think the WEB-INF subfolder in the output folder is not required and this folder makes up a huge part of the export. The export folder of my last LD game is ~70 MB, the game itself without WEB-INF is only around 10 MB (around half of it is probably from the assets.). So if I understand you correctly you should be able to build the games and then just copy everything except the WEB-INF folder to your desired location. Hope this helps.
16  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 10:10:36
@SHC: If it's top down, why don't you make just one image (or animation) which you then rotate?
17  Games Center / Contests / Re: Ludum Dare 31: "Entire Game on One Screen" on: 2014-12-09 08:43:14
Thanks...
Additional infos, desktop download and link to the source can be found on the ludum dare page http://ludumdare.com/compo/ludum-dare-31/?action=preview&uid=25076

Nice game, but the ludumdare page you linked points to Jev's Gungeon.
Definitely a sign that I needed that sleep Wink
18  Games Center / Contests / Re: Ludum Dare 31: "Entire Game on One Screen" on: 2014-12-09 01:31:07
Finally done... Hope everything works.



Check out the game http://files.mentex.ch/atombrot/ld31/

Additional infos, desktop download and link to the the source can be found on the entries contest page:
http://ludumdare.com/compo/ludum-dare-31/?action=preview&uid=7738

Now starts the fun time of finding all those cool games that have been made... But first of all I need a batch of sleep Cheesy
19  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-12-05 08:55:12
Quote
NuGet as a first class delivery vehicle

Wohooo Cheesy
20  Discussions / General Discussions / Re: Using TWL with todays versions of LibGDX? on: 2014-11-30 14:09:30
Great thank you just what I needed

I had a GUI like the Democracy 3 in mind for future plans, some kind of other simulator, you should check out that game if you havent already - would this kind of thing be possible with SceneUI then? I'm guessing so...

Fun thing is, I bought democracy 3 just yesterday in a steam sale XD Have seen some let's plays. I'm not sure if I like the game, but I find it very interesting (I love simulations Cheesy), so I thought I might just give it a try.

From what I see the UI of democracy is very well done for such a complicated game (in screenshots it looks complicated but when you see it in the videos you see that the UI provides a lot of context and help for the user). I would suggest that you don't even try to do something similar until you have grasped the basics of scene2d and scene2d.ui. Then try to identify what "components" the democracy ui (or the ui you want to make) is composed of and how you could do something like that. Make little proof of concepts for your controls and then try to get them together in the big picture.

To give you an example what I would start with, let's take this screen: http://imgur.com/Ak34HRv

From what I see this screen consists of 3 important areas. I have marked them with different colors on this image:

There is the info bar in the top (pink), the table in the center (green) and the buttons/icons that take up the rest of the screen (blue).

The top bar and the progress bar in the center can be done very easily with tables. You see how I would create the table cells (you can do a colspan to achieve the big "popularity" cell in the green table).

In the top table you then have different kind of displays, which you can compose out of other tables or buttons (TextButton/ImageButton) with nice set backgrounds.

You can add those two tables to your stage and position them how you want to.

The icons in the blue box are basically round buttons that are freely placed in the free area. This might have be done manually or autamatically, but I would suggest that you start manually.

I would probably create a Group/WidgetGroup where I put them in instead of putting them directly into the stage.

Check out ninepatches, if you haven't already. You can use them as background for tables and other actors.

Last piece of advice. Start working with a skin. It is really nice beeing able to define style properties in the skin file and change the overall look and feel in one place. Probably best advice to start with the skin is to use the files from the libgdx tests.

Downlod following files from this link https://github.com/libgdx/libgdx/tree/master/tests/gdx-tests-android/assets/data
uiskin.json, uiskin.png, uskin.atlas, default.fnt, default.png, default_00.png, font.fnt, font.png

I'm not sure if you need the default and font files. The important part is in the uiskin files.
21  Discussions / General Discussions / Re: Using TWL with todays versions of LibGDX? on: 2014-11-30 12:56:17
As far as I know TWL is discontinued since a while. LibGDX has undergone some bigger changes, so I would expect it not to work any more.

In my opinion scene2d is way better than TWL. I had the pleasure of using TWL with slick2d. It produced nice guis, once I got it running but it was a major pain to get it runnning (not because it is a bad library, but because it it a very extensive library with a steep learning curve).

Btw, scene2d also comes with some widgets (scene2d.ui). Probably not as many as TWL has, but basically you have everything you need to start building an elaborate gui. If you want to make nice guis with scene2d, try to understand Tables. For most things I need in my UI's, I often start with tables.

Have a read: https://github.com/EsotericSoftware/tablelayout , https://github.com/libgdx/libgdx/wiki/Scene2d.ui

22  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-27 13:23:54
Quote
All exceptions are unchecked  
Forgot that. Not really a killer feature but I like that too.

Quote
Coalesce
As ? is already an operator I don't find it that evil. But I understand your concerns. Nice thing is that you don't need to use it.
And the definition what it does in c# is very clear.

Quote
For various reasons but mostly because it hides stuff I like to know.

This is as I said before... If you use it wrongly you can hide stuff. But there are still many places you can use to shorten the code without losing information. This is also a very controversial topic in the c#/.net
community, so you are absolutely not alone with your dislike for var. There are some stack overflow discussions about this topics... Probably might give
you some different perspectives on the topic:
http://stackoverflow.com/questions/41479/use-of-var-keyword-in-c-sharp  
I need to check but I've read an interview with one of the language creators where he explains why they introduced var and what it should be used for. But not really sure where I read that. Google yielded no good results Wink

Quote
Nullable Types
Sure, you can do something similar in java. It is still nice not having to declare a reference type to hold a value type. Also I find it's notation (<datatype>? <name>) very nice to read, for example if you use it on a data model, entity or so. For example, when you're used to c#, you read "int? value" automatically as "nullable int value". Just a tiny improvement, but if it helps by not having to implement some wrapper classes, I'm happy to use it. (also things like entity framework use this notation to set db constraints).
Quote
Extension methods. Seem like a great idea but I started to get an uneasy feeling about them after a while.
I think this is because they change the way you program. In c# the introduction of extension methods lead to an increase in "functional" style libraries, code examples etc. classic c# (.net 1.1 - 2.0) is very similar to java 1.6/1.7. But since the 3.5 .net framework release a lot has changed. The code is less and less control code (for, if, switch) and more and more just "functions" and lambdas etc. Extension methods are used by many libraries to do very clean, decoupled libraries with nice tools that can be enabled by just including a namespace. Extension methods are now an integral part of the .net framework, and even if you don't create them directly, it is hard to not come around them. So it is good to know how they work (think you already know that), if you are required to use them.


Quote
Type erasure
It's not the end of the world, but actually it can be very handy to be able to instance a type based on the generics parameter. It makes some things (data generation/mocking, factories, IOC, dependency injection) simpler to do. I don't say that you can't do it with java, but with java you require some more boilerplate code to setup certain things. I don't come accross problems with this often, but when I'm usually annoyed about what I have to do to get it running with java. But now I usually try to avoid situation where I would need this info in java.

http://stackoverflow.com/questions/731452/create-instance-of-generic-type

Quote
Things that are in Java which are excellent ideas:   the <> operator, which removes large tracts of crappy redundant typing   static import, ditto lambda syntax, ditto, plus bells and whistles   final, which works in a lovely consistent way   for instead of foreach. Consistent use of keywords!

The <> is actually a nice addition. Would like var even more... But true, c# doesn't have an equivalent (because most cases are handled by var Wink ). Static import: This one is actually nice. But also, in many cases where you would use this, c# uses extension methods, which I find even niftier Wink Lambda Syntax: Don't really know the java lambda syntax. I like the one from c#.  final: Yes, final, readonly, etc. is a bit of a mess.  foreach: I disagree on this. For me this is semantically a different operation (and I don't like it if you have a keyword that does two different things, see final XD). I don't prefer one way or the other, but I don't see a problem with the foreach naming.

Quote
 The ability to specify byte and short literals with suffixes a la longs (dunno if C# has these)

Nope, doesn't look like it: http://stackoverflow.com/questions/5378036/literal-suffix-for-byte-in-net


The coalesce operator ?? and the elvis operator ?: are
functionally the same.

I'm not really sure if this is the same. Can you do this with the elvis
operator:
1  
return valueA ?? valueB ?? valueC ?? valueD ?? valueE ?? valueF ?? "defaultValue";

Stuff I know nothing about:   Yield.
Basically it's a limited form of coroutine. It is very useful for people who want to write implementations of Iterator; I haven't seen many other uses for it.

It is a compiler hack which let's you implement IEnumerable without having to implement anything (the compiler substitutes the required classes). This can be very useful if you are processing large streams of data or lists. Also, nothing java could not do, but it is nice that this is implemented as language feature.


Quote
dynamic
Dynamic is nice because it let's you create dynamic objects. Imagine doing a SELECT * FROM BLA and directly mapping the results to objects, without having to know the column names at run time. The micro orm dapper (which is developed by the stack overflow creators and as far as I know used as orm for stack exchange) makes heavy use of this feature.

Ah I forgot one feature I really love about c#. The using statement. C# has an interface IDisposoble. If you have an object that implements this interface, your can wrap your operations on this objects in an using statement. When the code exits the using block, all used resources are being disposed automatically.
how this looks like:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
 
Table table = new Table();
using(var connection = new SqlConnection("."))
using(var command = new SqlCommand(connection))
using(var adapter = new SqlDataAdapter(command)) {    
   command.CommandText = "pr_LoadData";    
   command.CommandType = CommandType.StoredProcedure;
      adapter.fill(table);
}
return table;

In this example, connection,
command and adapter are all classes that have resources that need to be
disposed. This happens automatically, once "adapter.fill" has run.
23  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 22:34:05
Well.. I'm not trying to limit the discussion to var. I would like someone like you to espouse the benefits of C# so we can see where it's better.

Look at the things I mentioned in my first post. I know that I cannot explain those concepts better than existing resources on the internet.

Some things:
  • Default and named parameters. I like convention over configuration. why do method overloads when you can have your values defaulted to sane values. => http://msdn.microsoft.com/en-us/library/vstudio/dd264739%28v=vs.100%29.aspx
  • Use "yield" for easy implementation of iterators => http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx
  • dynamic type in a statically typed language.  http://msdn.microsoft.com/en-us/library/vstudio/dd264736%28v=vs.100%29.aspx
  • The coalesce operator (??) => http://msdn.microsoft.com/en-us/library/ms173224.aspx
  • Generics information is not erased after compile. Reflection can access the information of the generic types.
  • You can use value types for generics.
  • Properties. I actually like them very much. I find working with properties nicer. objectA.Value = objectB.Value + objectC.Value as opposite to objectA.setValue(objectB.getValue() + objectC.getValue()). But I see that that is just a personal preference.
  • Operator overloading. A controversial one but can be definitely useful.
  • Nullable types (probably would not have much use in java, as you cannot define your own value types) => http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
  • Extension Methods:
    http://msdn.microsoft.com/en-us/library/bb383977.aspx[/url]
    A very neat way to extend existing API's without breaking encapsulation (XD, sorry, had to bring this example). This is extremely helpful if you want to add functionality to an API that you don't own or cannot change. The .NET library has some very handy extension methods that add functionality very similar to streams (java 8 ), without touching any of the underlying storage classes. A very useful tool.
  • The var operator:
    http://msdn.microsoft.com/en-us/library/bb383973.aspx
    This operator has been received with mixed reactions from the developer community, mainly because it can be abused. As far as I know it only has been introduced to allow anonymous types in the language. But they can be also very useful when having very large types or type definitions with many generics etc. I had the example with the hash map. I come across classes like BackendFormatterKeyChainOperatorImplemenation, sometimes you have even generated classes with much longer names ... That is not really a problem of the language, but the var operator helps to cope with the symptoms. I use it often, but only when it is clear what the resulting type is or when it doesn't matter.

Some of those features are mainly useful for my "boring business work", but I really miss things like extension methods, default and named parameters, ?? and var. I think there is a reason projects like lombok or xtend exist. Java has room for improvement and I really hope it will improve even further.
24  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 18:17:22
Sure, if you limit this discussion to var, there are no big advantages vs java. If you look up the features I listed in my first post you gain a lot more additional fluff and also things that java simply does not support (better generics support/valuetypes, extension methods) Wink

It's not my (nor is it your) problem that you don't see the benefits. It's my gain that I see them and can use them to improve my productivity and the fun factor while coding. Just wanted to share some thoughts that are biased in in the other direction Wink
25  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 17:11:08
Not entirely correct. You still have to type Map<>. But yes you are right, my java example was worse than it needed to be.

And I'm not advocating var for java. I'm saying that introducing var in C# has resulted in code that is easier to read. As I said. All the small improvements together make the whole package really good.

Yes, lambdas are nice and help improve java. But there is still a long way to go to be en par with c#
26  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 15:45:33
I can give you a very basic example.

HashMap<SomeUglyType, AnotherUglyLongType> map = new HashMap<SomeUglyType, AnotherUglyLongType>();

Vs

var map = new HashMap<SomeUglyType, AnotherUglyLongType>();

Already an improvement without any information loss. Why do you have to repeat yourself in java? There is absolutely no gain in defining the type twice if the variable holding the value has the same type as the instance being created... still you have to process this information everytime you read the code. This is not a very big thing, but there are many small improvments like that and all those together tend to add up. And when having a very huge code base these small things can matter a huge deal.

 I worked on some stuff that might have been more complex than sorting sprites for rendering (management and forecasts for financial portfolios, simulating different investment strategies  for said portfolios etc ...). As soon as you have to do more than "check that the account is not below 0" it is crucial that the business logic is as clear and readable as possible.
27  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 12:38:16
@cas: you don't seem to understand my point. If done properly you don't hide anything (if you are hiding relevant information you are doing it wrong). You just need less code to express the same logic and because of that you need to read less code to understand the underlying logic. It's as simple as that.

And not sure what projects you worked on, but the example you have given is probably the simplest form of complexity I have come accross in real life. Our business rules/logic are/is a lot more complex in many projects I have worked on.  
28  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 09:58:10
Verbosity suddenly becomes a great asset when you've got to read someone else's code. Which is what I spend 99% of my coding time doing (usually looking at code the old me wrote, 6 months ago) and I bet you do too.

Cas Smiley

For me it's the opposite with java... the relevant business logic is hidden by javas high verbosity which makes it harder to understand what is going on. Less verbosity is not equals less readability. Don't confuse the two. C# allows you to strip away more than is good. But if you do strip away the right amount you have less but better readable code...

Edit:
Just as an example:
"I have an apple. This apple I have is green. This apple I have has a sour taste. This apple I have has been bought by me for 1 dollar."
"I have a green, sour tasting apple, that i have bought for 1 dollar."

Both examples transport the same information, but the first one has just a lot more verbosity, which in turn has a negative impact on the readability. It takes longer to understand the first example, just because you have to read more to get the relevant information. The example is a bit constructed, but having devloped c# and java for some years it is exactly how it feels to me.
 I agree that making code less readable is a very bad thing. But in my opinion more verbose code is less readable.
29  Discussions / Miscellaneous Topics / Re: C#, did Microsoft just want to be different? on: 2014-11-26 08:07:42
I know I'm a bit in a lonely place, here in a java gaming forum, but c# rocks and makes it a lot easier and more fun to program. I don't say java is bad. But java is very verbose and c# simply has made better design decisions in some places (also worse in others. one think I like better in java is that methods are overridable by default. Prefer itthat way but I understand the reasoning behind the default settings in c#. It makes the developer think more about his public API and what parts can be reused.).

The language itself is great. real generics, reflection of generic information, user defined value types, value types used as generic parameter, properties, var, dynamic, extension methods, first class functions, expression tree, yield, operator overloading. All those features and gimmicks make your life a lot easier if you understand them well and use them at the right places, as you write cleaner, shorter and more readable code.

For game dev I use java, at work I have the pleasure of working with c#, java, groovy, sql, javascript and some other uglier things. Don't get me wrong. We got shit done in java and we get shit done with c#. But the stuff with c# let's us concentrate a lot more on the actuall business problems and hides a lot of the technical noise...

The biggest downside for me until now was the lock in on windows. But now that microsoft open sourced most of .net (including the asp.net part) i can finally run an asp server cheaply.

@nerb: here in central europe both java and c# devs are in demand. It feels a bit like the demand for c# .net is a bit higher, but that might be subjective for our company or location.
30  Game Development / Newbie & Debugging Questions / Re: Saving only one value in preferences file - libgdx on: 2014-11-21 07:57:09
You have two possibilities:
1. Don't put the values in the settings but keep them in a variable or class that you can access where needed.
2. Keep it in the settings. If I don't like a games sound or don't want it playing and I disable it it is annoying if you have to do it every time launch the game...
Pages: [1] 2 3 ... 6
 
ClaasJG (19 views)
2015-04-27 13:36:51

BurntPizza (33 views)
2015-04-23 03:42:11

theagentd (35 views)
2015-04-22 16:23:07

Riven (50 views)
2015-04-16 10:48:47

Duke0200 (59 views)
2015-04-16 01:59:01

Fairy Tailz (42 views)
2015-04-14 20:13:12

Riven (45 views)
2015-04-12 21:36:37

bus hotdog (61 views)
2015-04-10 02:39:32

CopyableCougar4 (66 views)
2015-04-10 00:51:04

BurntPizza (71 views)
2015-04-06 22:06:58
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27
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!