Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 13 Sep 2012
Online Last Active Today, 01:10 AM

#5199254 Is Java a good Language for Games?

Posted by TheChubu on 20 December 2014 - 09:29 AM

But since I'm only doing such in class constructors, class initializers, and static initializers, should I still be concerned with allocation, de-allocation, re-allocation, et cetera?

It depends. When stuff like that is done mostly in initialization phases, you have to consider that probably the JVM has just started to execute that code for the first time. By that fact alone it will work quite slow, and if you add on top array trashing, it will work slower than it should.


Its not that the reallocations themselves are that bad, after all the JVM manages its own preallocated heap, you probably heard a few times that an allocation in the JVM is "just a pointer bump", its just that you put reallocations in places where they might have more impact in startup time.


If the code is "hot" code though (ie, has been run at least a few hundred times), the VM might be able to inline the resizing and notice it allocates an array, puts stuff there, then reallocates another array, then copies back the contents, and eliminate the intermediary array in the process. Its something plausible, but I haven't read anything about such thing so I wouldn't expect it to do it. And even if its done, its probably done by the C2 compiler after a couple thousands calls rather than a few hundred (HotSpot does tiered compilation now so C1 and C2 compilers kick in at different stages in the same code).


You can only be 100% sure by checking the assembly output after a couple tests. Or you could just properly size your collections beforehand :D

#5198835 a little dilema abotu glut

Posted by TheChubu on 17 December 2014 - 02:59 PM

Why don't you try another portable libs first? SDL and SMFL both can handle window creation and input and are supported in Windows and Linux.

Add to that GLFW too, plenty of multi platform choices.

#5198801 Should the player be just another entity in the etities list?

Posted by TheChubu on 17 December 2014 - 11:41 AM

My "player" implementation is terribly simplistic at this point but yeah, modeling the player as another entity with just specific player components, just like a vehicle would have vehicle specific components, looks natural to me. Besides, you'll have much less player specific hooks in your code that way (ie, why would a player animation be different from any other entity animation? or why would be the player entity movement be different from other entity movement? etc).

#5198785 Minimalist Programming Environment

Posted by TheChubu on 17 December 2014 - 10:34 AM

Do I still get marks for using part of the Lugaru source as my example?
I was expecting somebody to point out how awful the code looked :D

#5198573 html & opengl ( what should i use or should i recreate html render engine )

Posted by TheChubu on 16 December 2014 - 01:23 PM

What are you trying to do? ie, if you had this, what would you do with it?

#5198571 Terrain tesselation and collision

Posted by TheChubu on 16 December 2014 - 01:14 PM

EDIT: Also if the tesselation is the result of shaders, how on earth do you apply lighting and shadows to it?
Applying the shader to the tesselated mesh? Tesselation stage comes before the fragment stage. So when you get to the fragment shader, you're receiving tesselated vertices converted to fragments. So basically, apply your shading normally, its just geometry like any other.

#5198386 Minimalist Programming Environment

Posted by TheChubu on 15 December 2014 - 01:24 PM

I suck at remembering keyboard shortcuts, thus why text editors always seemed terribly clunky to use for me. Then again, most of what I do with Eclipse revolves around ctrl+space,  ctrl+alt+r or ctrl+click, everything else I do through the good ol' contextual menus.


Then again, when I don't need such "awareness", like, editing YAML/GLSL files, I do like text editors. Much more to the point, and basic autocomplete works 60% of the time, every time.

#5198320 Is Java a good Language for Games?

Posted by TheChubu on 15 December 2014 - 08:30 AM

So I should stick with Java with Slick2d to make a 2D game
No, not at all. Use libGDX instead. Slick2D has been abandoned for years, whereas libGDX is the go-to framework for most Java game developers. You'll find tutorials and even books for libGDX.


But In my expirience making programs with java and deploying them was quite awful, i had to create a launcher with launcher4j and this wasnt working always also there were some permance issues(maybe my fault) but Java doesnt and compatibilities with the JRE.
AFAIK, its the same as with all programs. You need the proper runtime installed and the libraries linked and put in the right place. Its just like that with any kind of program, Java or whatever.


For best compatibility you need to setup your libraries properly (Eclipse has a handy "export libs in separate folder" option for that) and setup the proper JRE in the target computer. If you code it in Java 8 and user has Java 7, it will be the same as if you coded an application for Visual Studio 2013 and try to run it on a Windows Vista install without the proper runtime update installed.


And for performance: Don't do stupid things and performance will be good.


Don't reallocate things blindly inside a loop, don't retain references forever, don't use HashMaps for everything, don't throw 10 different subclasses of the same class in the same place at the VM inside a tight loop, plain array iteration is good, everything else is bad, small objects are good, complex objects with monster constructors are bad, don't use doubles everywhere, beware of object size, don't use boxed primitives, use primitive collections, don't go overboard with the "object oriented design", objects are good and all but a static function call is fast and simple, easy for the VM to resolve, easy for the VM to invoke, easy for the VM to inline, excessive composition leads to tons of pointer indirection, excessive inheritance leads to tons of megamorphic calls that the VM can't optimize for.


And a big ass et cetera. Performance ain't easy, its nothing it can be magically solved by changing the language, you have to design for it.

#5197962 How should i call my classes instead of "xyManager"?

Posted by TheChubu on 13 December 2014 - 06:30 AM

- ImageManager: It load the images,
ImageLoader then, or ImageCache. Or an ImageCache in which you plug an ImageLoader. Caching strategy doesn't depends on the format of the image IMO so you could plug different ImageLoaders for different formats and the ImageCache could store the data loaded by them. Then if you don't want a cache for certain things, just use the loader directly.


No, these classes just iterate through all Units and Buildings, and call the update on them. Everything else is done by the given Unit's or Building's update function.
Then that "update" function should do less things.

#5197097 Want to become a Computer Scientist

Posted by TheChubu on 08 December 2014 - 10:55 PM

I am programming in C++ around a half-year and currently learning HTML5 and Javascript.
Then keep programming!


Seriously, important bit is stick to something and learn from it. Over time you'll switch to different things, try new things, harder things (which tend to be the ones most interesting!), but you get to those parts if you keep practicing.


So there, keep programming.

#5196724 Is this a good example of an Entity Component System?

Posted by TheChubu on 06 December 2014 - 07:12 PM

In this article there's also a "System"

No wonder why its called Entity Component System EDIT: Ninja'd by sean tongue.png


The "pure" ECS approach has 3 parts:


  • Entities, which are an ID (integer, long, UUID, whatever you prefer).
  • Components, which are data, and only data (no behavior, no methods, no logic).
  • Systems, which are the logic and manipulate components and entities.

For setting up these, you need a way to track what components each entity has (many ways to do this) and a way for the systems to specify what kind of entities they can process, that means, a way to specify what components a system needs in an entity for processing it (again, many ways to do this), for example, a PhysicsSystem won't process an entity if it doesn't has a "RigidBody" component.


That's the general idea, you put components in an entity, and let the systems resolve what entities they process, run all the systems in the game loop.


Ideally the systems aren't very coupled, ie, only few of them need to be run in a specific order, and ideally, when a system processes an entity, it doesn't has side effects that go beyond the components of said entity. This allows for running decoupled systems in parallel and for running the entity processing itself of each system in parallel too.


I said "ideally" because coming up with such decoupling can be a challenge in itself (just like designing class hierarchies).


This is the most "pure" approach I'd say. Of course you can go off tangent by having Entities being more than pure unique IDs, components having some logic, and using inheritance here and there when it merits it. As with everything, nothing is set in stone and no one says doing ONLY components and ONLY systems and ONLY entities will fix all of your problems.


EDIT: On the "data oriented" part. The idea is that components are stored contiguously in memory, so that when a system iterates over entities, it can fetch contiguous components from an array and make the best use of CPU cache. How you do this part depends on your game.


For example, if you put every kind of component in their own array, and use the Entity ID to index into said arrays, your data essentially becomes a struct of arrays.


If a system that processes most of the entities in the game uses 5 or more different types of components at the same time, it might be more worthwhile placing those 5 components into an array of structures instead, so the 5 components are near each other in memory and can be prefetched by the CPU more efficiently.


This part depends a lot on how your game is set up (remember we're making a game after all), you might want some components grouped in memory rather than isolated by type, and some others might be better isolated by type rather than grouped.


That is something you'd only know when you have all the components and systems set up, and can profile everything. You can't make these kind of decisions as you go (or maybe you can if you really, really know what you're doing). Ideally, the layout in memory should be abstracted in such a way that you can do these sort of changes (grouping some components, isolating others) without having to refactor everything. As always, YMMV.

#5195618 30k concurrent players on a (private) MMO server...is this possible ?

Posted by TheChubu on 30 November 2014 - 09:54 PM

Have in mind Ragnarok Online is a 2D game, so don't think "30k WoW players doing PvP" level of complexity. Its sprites on a 2.5D background.


You can get some info about the game and the engine on Wikipedia






Apparently, it wasn't very well designed.


And btw, if he is remembering stuff from 10 years back, definitively he is painting it a bit pink at least. Maybe it "worked", but it lagged like fucking hell.

#5194872 OpenGL 5 - Release?

Posted by TheChubu on 26 November 2014 - 06:27 PM

Its not customary of Khronos to tell release dates... or anything, at all.


So expect it to be done when its done. And that's assuming it will be done, it might not.

#5194343 Best language for mobile apps

Posted by TheChubu on 23 November 2014 - 06:29 PM

Afaik, with mono (commercial licence I think?) you can use C# on both Android and iOS.


You can use Java(ish) on Android, and with RoboVM you can use it on iOS too.


You also have Objective-C and Swift for iOS.

#5193890 HDR Rendering

Posted by TheChubu on 20 November 2014 - 06:39 PM

You forgot a couple of steps:

- Render the scene to D3DFMT_A16B16G16R16F texture
- Apply bloom effect
- Apply tone mapping

- Apply more bloom
- Render the final scene (Fullscreen Quad)

- Apply even more bloom

- Screw the scene, just draw a white fullscreen quad.

- Then add bloom to it.

There you go.