Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 May 2005
Offline Last Active Aug 12 2015 10:01 PM

#5153345 Suggestions to a wannabe!

Posted by on 13 May 2014 - 12:10 PM

I am not a fan of starting with text based games ... they deal with weird comparisons and you are likely to end up with weird switch statements or nested ifs.

Especially if you use a language (JavaScript) or even engine (Unity) that is more appropriate for graphical programs, then having to deal with rendering text gets really ugly.


IMO the better idea is doing some of the Google Code Jam challenges. You are forced to learn to think like a programmer and you will be able to apply that way of thinking to making games later.


To decide if ISO is too complex to implement or not you can look at the tutorials that are listed there:



Converting Cartesian coords to ISO coords and figuring out which ISO tile the mouse is hovering over, those are not quite trivial ... but doable.

#5153232 [java] Hello! First post, a little introduction and few questions! :)

Posted by on 13 May 2014 - 12:15 AM

Hello! :-)


So you figured out the NPE is always related to missing images? Did you add debugging (System.out.println() for example) to figure out where in the code the problem occurs?

Do you know how to print and analyze StackTraces?


Missing images ... I would not suspect higher forces like viruses. Most of the time when we (companies I worked at) thought some other program or the system were at fault we had to learn that we were doing something wrong.


What does your build setup look like? The build process might delete and recreate the output / target folder (where the .class files are compiled to).

Putting the resources there does not work.

If that is how your project currently is set up you can try to create another source folder for the resources (... or put them in the source folder with the .java files which is not a nice solution). Then the build process should move those resources to the target folder after it has been cleared.


You could also use Ant or something similar to write logic for the build process but that might be too much of a distraction right now ... it does take a while to learn how to use it unless you know where to "steal" efficiently.



Btw. you might get away with using other languages, if you are not a fan of Java.

There are solutions like Apache Cordova that turn programs into iPhone or Android apps ... even if they were written in other languages (JavaScript in this case).

Probably something similar exists for other languages as well.

Engines like Unity can turn relatively neutral code into Apps for different platforms as well (I think you can do "scripting" in C# or something like that).

#5149323 Any way to make this simple tennis game more OO?

Posted by on 25 April 2014 - 01:33 AM

Somewhere there is a balance between procedural spaghetti code and the inflexible wall of rigid OOP.

I don't really agree with this.

Nothing about OOP is rigid, with the exception of cross-cutting concern implementations which lead to scattering (code duplication) and tangling (classes that have to do things they should not have to worry about).

Not sure if procedural programming helps with those.

The problem with strict OO design is the overhead (the amount of classes and methods) and the time you need to invest in coming up with a design that works, not that it is rigid.



In general for Game Development how OO should you go?

That really depends on the goals and time constraints.

It is a little project and you want to get it to market quickly? Is is a game that 10 programmers work on at the same time and for years?

Is it modular and will it be extended a lot? Is there client/server communication? Is there a server part that needs to be scalable?


The way you develop can make a difference, too. Pure agile works best if you keep things extremely clean (because you will have to do a lot of refactoring), while you can get away with (less strict) common sense OO design if you go for a well planned framework.


Probably some research would be time well invested. Articles about:

  • Separation of Concerns
  • Cross-Cutting Concerns
  • Agile Development / Scrum
  • Clean Code
  • Design Patterns
  • Programming Paradigms

are things that might help with finding the right balance. Maybe test driven development is interesting as well. There is a huge overlap with clean code principles, though.

#5149213 I want to start programing a 2d game and I need help!

Posted by on 24 April 2014 - 02:05 PM

Agree with warnexus. Probably that is a little too ambitious right away.


Careful with the ...


I want it to run smoothly on any computer

... part.


To get it to run on different platforms it needs to be compiled for those platforms (CPUs and Operating Systems) because C++ code can be portable but never platform independent. Setting up the build process will be enough of a challenge to keep you busy for weeks or even month if you do not know where/how to steal a code base layout/setup.

To get it to run on Android you need to look into the not so easily accessible parts / APIs of Android (Android NDK) ... and afaik you still need different builds for different devices, unless they found a way to deal with that problem. Not sure.


Java would be better if that is a priority. Unfortunately the way the programs (executable JARs) are installed and executed on desktop computers is messed up (IMO).

#5149209 Any way to make this simple tennis game more OO?

Posted by on 24 April 2014 - 01:41 PM

Cool thanks for the response! I'll take a look at modifying it now and see if I can get something working smile.png, is the original code an acceptable form of OOP or would it need refinement? 


I would call it appropriate for the given complexity, but not very flexible.


It does depend a lot on what acceptable means .. and that depends on context and the goals.

If you mostly want to use the project to learn proper OO design, investigate related schools of thought and get familiar with best practices, then there are quite a few things I would change.

Almost all of those changes would be overkill for the project itself, though:

  • Keeping the methods even shorter (main could call initFrame(frame) and executeGame()) ... they should do exactly one thing.
  • Freeing the Game class of anything that subsystems should handle (separating concerns and figuring out how to bring them together ... for example with listeners, references or patterns like the visitor pattern)
  • Using interfaces (provide services) and writing default implementations for them

That the game class inherits from JFrame seems shady if you want to play by most of the stricter rules. The class does too many things.

Instead it should have references, for example to a GameWindow object, and use its methods.

Ideally you would also separate rendering and input, which is unforunate, because the events are tied to the window toolkit.

From an OO design perspective you sould artificially separate those concerns, for example with a ModuleFactory service interface with a default implementation (called ModuleFactorySwing!?) that creates a GUIModule object and an InputModule using the same JFrame object under the hood.


Another little thing you might want to change:

  • Get more concrete in classes from top to bottom for better readability (define the methods after the places where they are used - Clean Code is strict there ... don't remember ... I think they are called the "Level Of Abstraction" related rules like "Just one level of abstraction per function" and "Do not mix levels of abstraction" etc.)

#5148346 undefined reference to `SDL_main'

Posted by on 20 April 2014 - 07:08 AM

I think that is a classic ... I have struggled with that error message several times as well, but that was a long time ago.


Maybe those responses help:



First thing I thought was "isn't -mwindows important as well"!? ... but not sure if that is it.

I also think it is a linking problem.




I think ... (but I am not 100% sure) the last time I fought with this error it was because of a 32-bit vs 64-bit problem. When I used the other libraries it worked as far as I remember ... even if it did not really make sense to me at the time.

#5147286 Random 2D terrain?

Posted by on 16 April 2014 - 12:31 AM

As far as I know midpoint displacement does not help with the caves ... there is an article with some more text: http://www.gameprogrammer.com/fractal.html


You will probably have to combine several algorithms to get the result you want.

Midpoint displacement can be used to create the base terrain ... then, for example, cellular automata to create caves inside that terrain!?


This is an art rather than a skill, meaning that learning to think the right way is more important than finding the right tutorial.

You should feed Google with those algorithms (http://pcg.wikidot.com/category-pcg-algorithms), pick the ones that inspire you and do simple things with them.


If you have a hard time coming up with a data structure and algorithms for populating a game world, maybe you should work on those basics some more ... for example with some Code Jam exercises.

#5147160 I need some serious help from you guys! (Bring spatulas)

Posted by on 15 April 2014 - 12:03 PM

Don't really understand the downvotes ... people read your post ... but there is a mismatch between the "I'm pumped and I will do whatever it takes" statement and "I would only be doing basic stuff since i'll outsouce the major components of the scripting and programming..".


We need to know your "target performance levels" as a programmer and/or as a game designer in order to provide helpful advice.

If you want to be able to develop an Indie game, you should start with something simple like Snake and Tetris.

That is the only way to see how awfully hard seemingly basic things are.

It seems that you want to make sure that are not confronted with that advice, but maybe I am wrong!?


I'll just say that you will pay the price if you specialize on an engine and high level libraries without getting a feel for the programming basics and the big picture stuff.

#5147102 I need some serious help from you guys! (Bring spatulas)

Posted by on 15 April 2014 - 07:45 AM

Your post seems weird. On the one hand you say you are willing to invest the time to become a developer, on the other you say a programmer will do the programming work.


I guess you have the wrong idea of what game development means. How far do you think you will get as a developer who is not much of a programmer?

In any case, you should not start with such a strong focus on the game you will eventually make. You need to start with simpler things.

#5144016 Creating a game: the terms and structure of code (libraries, languages, frame...

Posted by on 02 April 2014 - 10:48 PM

"Toolkit" and "Framework" say what strategy was chosen when people decided how to bundle functionality.

In toolkits ideally the tools are mostly isolated from each other. Their purpose is clear and they might be designed to work well together.

Still, the programmer has to bring them together.

In a framework programmers have (partly) done that job for you. They wrote convenient code that uses tools and brings them together in many common use cases.

There is less freedom, but good framework developers can make sure that the tools are not used in a wrong way.


Tools and Frameworks need APIs (the public application programming interface) that exposes classes and functions to users who want to use them.


Tools and a framework could be part of a software project and be isolated (not public at all). If the build process does extract them and it turns the tools into distributable packages those are the Libraries, which can contain standalone version of one tool, a bundle of tools or a framework using the tools.

They can often be downloaded as runtime or development versions. Runtime libraries are needed for distribution with your app, so that the functionality which your tool wants to use is actually available. Development versions usually come with public files (often as part of an SDK) that have some additional functionality and resources which are only needed at compile time.


What is SDL ... I'd go with: a framework (it offers convenience functionality to deal with rendering, input and resource loading etc.) which is distributed as a library and has an API that allows programmers to use it.


When you do an image search for Android you can see the architecture of Android.

You could develop in C++ and use the native layer ... but Android offers high level functionality to develop games more quickly.

Most of it is written in Java, so using Java for Android development is convenient. They did write or add several tools and turned them into a framework.

Because the Java bytecode is interpreted by the JVM (Java Virtual Machine) it is also platform independent, while C++ applications need to be recompiled for different target systems (CPU architectures) which means it can be portable but not platform independent.


With the SDK (software development kit) you can write apps that use the framework by using functionality that its API lets you use:



There are many tutorials that show how to build apps and turn them into executable packages.




I think you will find many resources for the Eclipse IDE. You would download the SDK from the Eclipse marketplace and then go through step-by-step tutorials that show how to do basic things ...




But careful ... SDL is mostly used by C++ programs. You would probably not use it directly and instead use the graphics functions that the Android SDK API offers (it is another thing that some frameworks do: abstraction ... which makes sure that different implementations of similar tools can be used in a unified way).

Android will probably use SDL and/or OpenGL under the hood. But I am not sure how those things work exactly.

#5143878 What path to take in programming?

Posted by on 02 April 2014 - 07:47 AM

Yes, get a feel for the big picture first. You might not want to specialize too early ... but do try to go for hands on experience with different technologies.


I wrote something for my cousin a while ago ... maybe something there is interesting for you ...


#5143685 Rotating triangle

Posted by on 01 April 2014 - 06:18 AM

If I remember correctly from OpenGl you apply transformations before you draw the triangle.


I hope people will correct me if I am wrong, but it seems as if you modify a matrix with ...

D3DXMatrixRotationX(...), D3DXMatrixRotationY(...), D3DXMatrixRotationZ(...)


and then apply it with ...






or D3DXMatrixRotationYawPitchRoll(&matRotate, ry, rx, rz);!?

There is an article:





I'd expect the transformation outside the drawing function for the triangle ...

#5143664 Managing game worlds

Posted by on 01 April 2014 - 04:01 AM

You might want to feed google the search term "scene graph".

A scene graph can be the element that renderer and entity logic / collision detection etc. share.


As L.Spiro wrote the game state / progress can be managed independently from the rendering.

For games like AoE 2 the object states might fit into the memory of the client PC.


For more complex games the entity state might be stored in databases of a server environment ... in a distributed way and only the relevant data would be forwarded to the client (into the scene graph).

#5143411 Linux development...

Posted by on 31 March 2014 - 02:09 AM

Code::Blocks might work for you.


Afaik X11 is a low level windowing system technology. I suppose if you use libraries like SDL2 or an engine you will not need to deal with its API directly.


I do not remember any kind of programming as trouble free.

Better find the right pace. Trying to accomplish too much at once is usually frustrating ... and develop the resilience to struggle through build issues. They will not just disapear ... ever ... I fear.



What exactly went wrong when you tried to use Irrlicht?


There is a tutorial for Irrlicht and C::B (Code::Blocks) btw. (oops, might be Windows specific, though):


#5143102 Browser-Based Game: Best Language?

Posted by on 29 March 2014 - 12:44 PM

There is no reason why he cannot implement the entire text based game in a single HTML page with a single input field and button for input, and a single text area for output.

Yes, but still yo have to able to tell things apart, and it is extremely hard to do that.

HTML is a markup language ... what does that even mean?

JavaScript can be used for game logic ... what is JavaScript again (what type of language)? What else can be used like JavaScript (what directly, what indirectly)?

What is the difference between Java and JavaScript?

Why are people talking about Client / Server communication?

In short: yes it is scalable, but only for people who know a lot about web development.


The time might be better invested in just setting up development environments for different languages and not even going beyond "Hello World!" projects ... and reading up on those languages / types of languages (even/especially with Dialects' update in mind).


Doing a browser based game makes sense if you want to practice the skillset.

When you want to learn about game development in general ... better keep it more simple than that, because everything will be a blur until you know more about the components/technologies that are involved.



I'd like to add that I do not plan on following a programmer's career, at least not at present. The necessity to learn programming (or at least the very fundaments of it) is only a mean to allow for greater assertiveness when creating and contemplating the design of a game. This is not to say I won't take programming seriously --I just see it in a different perspective than someone willing to make a career out of it would at this point in time.

You would not be looking at the big picture if you zoom in on web development now. That big picture knowledge is something that might be really valuable for you as a game designer.


But sure, if you want to specialize already that is fine. I still would not start with building a skill ... better do the relevant research instead.

Then break the technologies down further and practice those with simple projects for hands on experience:

  • learn about HTML5, play with pure HTML for a while
  • add CSS files for a site, play with that for a while
  • Write simple JavaScript files ... understand the role that it plays
  • Bring everything together, maybe write a style switcher before you go for the game