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 25 Mar 2013
Offline Last Active Yesterday, 04:48 AM

#5207112 Best Way to Save Player Information?

Posted by Sacaldur on 28 January 2015 - 03:21 AM

There are Libraries for a huge variation of languages for both, XML and JSON. For the latter one, just take a look at json.org for a list of librearies for JSON parsing and serialisation. It's not hard to use these libraries, but it could require lot's of code. There are also more advanced libraries to not only parse and store XML or JSON, but they also analyse your data structures, e. g. by checking for annotations, and automatically generate and read XML or JSON, just from your data structures. At least in my opinion the problem about this automatic serialisation is the generated structure. Some libraries generate a child node for each list/array, containing the child nodes themselfes, even though there is only 1 list and all entries could be put into the element itself. A simple example:
<playlist name="My Playlist">
    <track [...]/>
    <track [...]/>
instead of
<playlist name="My Playlist">
  <track [...]/>
  <track [...]/>
But still: these libraries reduce the amount of code you have to write.

You can store any kind of Text in a properties file. This way, you're able to store numbers as well, but you need to store them as text - just as you have to do with every other text based file format - and you would have to parse them yourself - by calling Integer.parseInt().
Also: the order of the entries in a properties file shouldn't matter at all. You're reading the values using the keys, but you don't have to know the exact order.

Besides Properties, XML, and JSON, there are INI files as well. They are comparable with Properties files, but have some more features (e. g. sections) by default, but the set of features varies depending on the implementation.
And you could use your own file format, but since you would need to implement the file parsing yourself, you should just stick to one of the mentioned file formats.

If you don't know, which format to use for your files: just stick to what you already have (properties I guess) until you encounter some seriour issues regarding the format. Then you'll be able to make a better decision, since you know what problem you'll have to solve with another.

#5168370 Thinking in Javascript

Posted by Sacaldur on 22 July 2014 - 08:03 AM

The main problem of many programmers is, in my opinion, the desire to do everything just like they did it in other languages. Best example: object orientation.
In JavaScript, there are no classes. The only JavaScript thing which is close to be what a class in other languages is, are the constructors. (And constructors are regular functions which are used for object instanciation elsewhere.)

While working with JavaScript, keep in Mind: there are no private members. Every member is public. (Same goes for Python: "private" members will only be translated, e. g. from "__privateMember" to "_MyClass_privateMember". Knowing this, you can still access private members, but it's evil...)
In general: instead of relying on specific types you should just use objects as if they are what you expect them to be. For at least some type safety or "method overloading" you could do some type checking, but for objects of types other than the primitive types you should just check if they provide the features (methods and/or members) you need.
This also means: you have to use inheritance much less compared to other languages.

You should definitely take a look at what closures are and what you can do using them in JavaScript. Those are used frequntly to hide implementation specific functions to keep the global context clean. (-> Anonymous function containing all library setup calls, which is called immidately.)
Also Closures are used to have some kind of private "members", but due to what a closure is, those are no members ob the object. You will run into some troubles if you want to combine it with inheritance. ;)

var someVariable = {"key":"value"}
This is not a map, it's an object. (You can assign values to an array usign a non numeric key as well, but it still would be an array.)

#5093314 What programming language to use?

Posted by Sacaldur on 11 September 2013 - 11:12 AM

You could try Mono (.NET for other platforms) and MonoDevelop (an IDE).
If you're familiar with C#, you might want to have a look at Unity, too. Using Unity you're able to create 3D (and also 2D, but many people doesn't like Unity for 2D) games quite fast.

#5092061 What type of game can One person make ?

Posted by Sacaldur on 06 September 2013 - 05:44 AM

jbadams and David Ga11agher already pointed out the important things so I don't have much to say about the possibility of these projects.
But I want to add one point: don't focus to much on the genre! The genre says some kind of nothing about the final game as mentioned in one of the Extra Credits Episodes (I'm not sure about which one it was, but you could have a look at Extra Credits: Combining Genres). In an other episode if not the same they mentioned the difference between genres in film and literature. When you see a movies genre you know quite exactly if the movie is interesting for you while game genres focus on a specific mechanic or the point of view (_first person_ _shooter_, _plattformer_ (btw: in other locations referred to as "Jump'n'Run"s) and so on). I'll have a look fore the right EC video later...

As mentioned: the content will take a lot of time so you should not make a game which depends on much content. Shooter, RPGs and adventures (also action adventures) need much content to some extent. (Local) multiplayer games doesn't need much content or much mechanics in general to be very enjoyable. You may could have a look at these games. ;)
And don't forget about the sound and music!

Oh and by the way: Zelda is not an RPG, it's an action adventure! (Except for Zelda II maybe...)

#5091795 Why are static variables bad?

Posted by Sacaldur on 05 September 2013 - 09:08 AM

(I have to admit I didn't read everything...)
There are some slightly different statements which should not be mixed up.

1.) Global variables are bad. They infringe the object oriented design, no one likes them, and they don't have any friends!
2.) Dependencies should be validated during the objects initialization by passing corresponding objects as constructor arguments or by initializing them inside the constructor. There should be no initialization Method to be called from the outside after the object was created. The object already has to work.
3.) Other stuff, the object ist not dependent on should not be passed to the contructor.

In my opinion the 1. statement is true. There are in most cases other different and better solutions.
While talking about the 2. and 3. statement it's important to know what is an object depending on and what it is not depending on. A player may need to know his environment (map/level/world/...), but a wizard wand or warrior sword refining machine doesn't depends on these objects the same way. Thats why the world may should be a players constructor parameters, but a weapon should not be a refining machines constructor parameter - instad it should be the "refineWeapon"s method parameter.

An other example for a dependency could be Character and the CharacterState's subclasses. A character always needs to know his state - what the character is doing. "Nothing" could be one of the subclasses so a null pointer would be an invalid state. The constructor should set an initial state no matter if there is a parameter for the state or not (the questen would be: is there a default character state in your game?). A SetState Method would still be a valid possibility, but it's not a setters job to initialize the object.

In my opinion passing an object to the constructor and passing an object to a method are suitable for different cases. Both should be used, but not exchangable.