Jump to content

  • Log In with Google      Sign In   
  • Create Account

Karsten_

Member Since 19 Jul 2011
Offline Last Active Today, 03:58 AM

#5109312 How Languages Compare?

Posted by Karsten_ on 14 November 2013 - 05:56 PM

Nowadays the trend in game development is to use the component entity system which works really nicely with languages like C which don't actively enforce rigid object orientation.

At work we tend to write fairly typical C code using similar patterns to Gtk+ for our small amount of object orientation but then we attach components to a single type akin to Unity's GameObject.
We do however use the GNU C++ compiler so we can access some of the really useful C++ functionality like std::string, std::vector, smart pointers etc. We also use external C++ and C libraries so using a C++ compiler was the most compatible choice.

Also, it seems easier to interface with C code from a Java or Objective-C shim layer (for mobile devices), than C++.

My personal favorite feature of C over C++ is that if you define the struct in the .c file and just have a forward declaration of the struct and corresponding functions in the .h file, it is much more encapsulated than even a class with everything private in C++ since other developers can't even see the data and you have complete control over any aspect of the data being exposed. This can't seem to be done so well in C++ without rewrapping all the functions because the class contains the functions so has to be exposed. Thus the pimpl idiom which I find a tad messy and convoluted.


#5107125 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 05 November 2013 - 04:08 AM

Ah good point, it is worth mentioning that Emscripten provides SDL 1.x (and soon SDL 2.0). However, since the emscripten version of the SDL API has been tweaked to run in a mobile browser (i.e touch events) and is already 3D accelerated, it is likely to stick around for many years to come (and will almost certainly still outlive commercial proprietary products like Unity).


#5106975 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 04 November 2013 - 02:00 PM

Whao, that's sounds amazing, i think it's the time to learn SDL. Thank you! smile.png


smile.png

Luckily SDL also has some fantastic tutorials written by GameDev.net's own LazyFoo (http://lazyfoo.net/SDL_tutorials/). These should help you get started. For 2D games it covers pretty much everything.

As an added bonus, when compiled with Emscripten, your SDL games will actually be hardware accelerated because they use the web browsers HTML5 canvas underneath.


#5106968 C++ (SFML) and Flash player/Unity

Posted by Karsten_ on 04 November 2013 - 01:34 PM

FlasCC unfortunately still targets the unportable proprietary Flash stage system.

Emscripten could be perfect here. It is basically a C++ to Javascript compiler but also provides well known C++ media libraries such as SDL, OpenGL, SDL_mixer, SDL_image, Qt, glut etc...

My software always uses either SDL or Glut and OpenGL so it has been very easy to put out a web build. I highly recommend these technologies if you want to keep with C++ but also target the web (as well as every other platform under the sun ;)

https://github.com/kripken/emscripten

A few simple demos using the technology can be found at http://devio.us/~kpedersen/mutiny/doku.php?id=demos (apologies for the slow server)


#5106880 Linking libraries in VS 2012 (Express)

Posted by Karsten_ on 04 November 2013 - 04:37 AM

We use the Microsoft C++ compiler in much the same way as GCC on Windows. The following is a few examples from our Makefiles if it helps (personally I find the documentation for commandline MSVC usage to be really lacking!).


.cpp unit to .obj
cl.exe /nologo /EHsc -c -I..\..\..\import\msvc\include -I..\..\ $(CXXFLAGS) /Fo$@ $<

relevant .obj files to static lib. Here we are also including the GLEW32s.lib into our static lib so it doesnt need to be linked in during the final step.
lib.exe /OUT:..\..\lib\mutiny.lib $(OBJ) ..\..\import\msvc\lib\GLEW32s.lib

Link other .obj files to final .exe and then link against required libs and our static lib we generated in the step above
link.exe /SUBSYSTEM:WINDOWS /OUT:$(BIN) $(OBJ) /LIBPATH:..\..\..\import\msvc\lib /LIBPATH:..\..\..\lib OpenGL32.lib GLU32.lib SDLmain.lib SDL.lib mutiny.lib $(LDFLAGS)

The main thing to notice is the /LIBPATH parameters are similar to -L on gcc. Also note that there is no need for -l, you just specify the name of the lib (including the .lib suffix).


#5102678 so i took one look at the sdl source code...

Posted by Karsten_ on 19 October 2013 - 12:39 PM

Take comfort in the knowledge that SDL is already written (and open-source) for you to always use rather than having to rewrite something similar yourself.

Also, using SDL with C and C++ is easy. Just like using .NET (C#) is easy whereas if you look through the source code of Mono (or shared source (rotar) versions of Microsoft's .NET) it is incredibly complex.

 

I tried porting Microsoft's .NET to a modern version of FreeBSD (it originally was created for Windows XP and FreeBSD 4.7). I got as far as the PAL abstraction layer before I started to get the shakes. Now I am writing games until I recover from the experience haha.




#5101332 Best way to showcase a game made in Python/Pygame

Posted by Karsten_ on 14 October 2013 - 11:35 AM

A website with pictures, an embedded video and downloadable 32bit Windows exes or perhaps an Android APK* of the game is usually your best bet.
This also has the added benefit of letting your viewers get a local copy of your game to pass around so not having to worry about internet streaming which is quite a benefit (whereas many web games need internet or a small local html server (like mongoosehttpd) to be provided). Or even worse, they need horrible web plugins**!

With Python, you might want to use a packaging system since Python isn't very common on Windows machines for a typical user. If you can modify your install of python to be portable, then you might have some luck creating a self extracting .exe using WinRAR.

Emscripten (C/C++ to Javascript) compiler can compile a Python interpreter so depending on what dependencies your game uses, you might be able to get it running on a webpage too.

* Android is the most common tablet OS (rivaling even that of desktop systems) and seeing as you are not trying to sell your showcase game (at this point in time) your viewers can sideload it without the faff of developer certificates from something like iOS or Metro.

** I am looking at you, Unity web player! Though the developers are currently working on a WebGL javascript exporter using Emscripten.


#5100013 Multiplayer Extension?

Posted by Karsten_ on 09 October 2013 - 04:08 PM

They would need a good diagram tool and a telnet client ;)

Making an existing game multiplayer is very tricky to do properly. Much of the logic needs to be delegated to the server so that players cannot cheat by modifying the client.

Existing libraries that may make this process easier are things like Distributed Objects. http://www.aplaypowered.com/

<shamless_plug>
You might be interested in some of the ideas I presented in a paper at GAS2013(ICSE2013). It attempts to create a system to distribute local data in video games.
http://50.57.98.84:8080/doe2/icsews13gas-11-p-16814-preprint.pdf
</shameless_plug>

 

I find one thing that helps in a language is that cleanup is automatic but also deterministic (i.e in C++). This way, it is possible to send a message as soon as a local object is destroyed. There are many ways round this when using a garbage collected language but I prefer not having to think about this issue.




#5099212 C++ Pointer clean up question

Posted by Karsten_ on 06 October 2013 - 05:09 PM


...
if (pkObj ->id = id)
...

Did you perhaps mean to use == rather than =? (If this was just a quick demonstration example then nevermind ;))

 

Also, unless you know of a specific reason not to, you should look into using something like std::vector to create arrays in C++. It will help you against most (if not all) memory issues of this sort.

 

You might also want to consider using a std::vector of std::shared_ptr or std::unique_ptr if you don't want to worry about manual memory cleanup (almost critical if you use exceptions).

If you are new to smart pointers, start with std::shared_ptr so you dont need to worry about exclusive ownership and using std::move to push_back into a vector.




#5096171 Open world 3D game without a specific game engine

Posted by Karsten_ on 23 September 2013 - 09:49 AM

If I decide to use an existing engine, I do not need to learn the low-level stuff, maybe not even C++.

You will still need a programming language. C++ is as good as any.

 

What I suggest you do is evaluate some of your options. Dont worry if these are not the exact technologies you want to try. This is research at this stage.

 

Try building a simple cube platform jumper using the following tech.

 

1) Irrlicht - To try out a basic open-source 3D engine (use Ogre 3D if you prefer)

2) OpenGL - Have a look at implementing what you have just created in Irrlicht without using a graphics API directly (use DirectX if you prefer)

3) UDK - Try out a commercial engine (use Unity 3D if you prefer)

 

Once you have implemented all of them. Run them all and decide which one you have the most enthusiasm to extend and use to implement your next project.

 

:)




#5093567 Tile Map Editor/Collision Detection

Posted by Karsten_ on 12 September 2013 - 09:02 AM

If it is necessary, don't be afraid of creating your own tools. We have an internal tile editor but it certainly isn't in the same state as Tiled and is a long way off commercial tools. It is however more fit for purpose for our game than any of the others we had found. In other words, it would take longer to understand how the plugin system works for a 3rd party tool than it did to just knock together our own.
 
Here are a few of our tools. You can see how rough they are ;)

(One day we do aim to clean them up to release to allow modding for the actual game but polishing is pretty time consuming lol)

 

cdt.png

 

This map editor isn't actually tiling. Our days or tiling map editors ended once we realized none of us were very good at pixel art ;)

 

tdat.png

 

Both were coded in C++ and wxWidgets and it works on all our development platforms (something proprietary tools fail to do). All in all, it probably took about a day or two for each one but features were added as we needed them so I am not sure of total coding hours. Well worth it though because now we aren't relying on companies owning tools like Unity or Spine to stay in business or to keep up support of a feature smile.png




#5093021 Some Queries about game dev?

Posted by Karsten_ on 10 September 2013 - 08:57 AM

The term "engine" is perhaps a bit overused in game development. Typically it is just a collection of other separate libraries (i.e OpenGL, glm, OpenAL, SDL, libpng etc...) with a bit of glue code to hold it all together as a framework (often including extra things like a scripting layer, serialization, etc...).




#5092514 Stick with C++ or venture into C#?

Posted by Karsten_ on 08 September 2013 - 12:10 PM

A typical programmer will certainly need to know a few languages so it is always worth improving your knowledge of a language. I guess just try to avoid falling into the trap of always flittering between different languages and never specializing in any.

 

I only ever choose to use C++ (and it has paid off since I like to think I am pretty good at it now ;). However I still need to know C# so I can understand example algorithms that are written using it. I also need to know C# so I can implement glue code between Microsoft technologies.

 

For example, I also needed to know enough Java so I could kickstart my native C++ game on Android. I also needed to know enough Objective-C to kickstart the same game on iOS.

 

Programming languages are like cars. Once they crash and burn, you need to be able to move onto something else in order to get to your destination.




#5092031 sucking potata

Posted by Karsten_ on 06 September 2013 - 02:57 AM

Since C++ is on a much lower level Socket programming makes use of sockets implemented for each Operating System

Although C++ makes it easier than Java or .NET to work directly with low level C code, generally there is no reason that you should.

 

However as Khatharr mentioned, the sockets API on most platforms is very similar (Mainly because Winsock was designed based on BSD sockets a long time ago).

This combined with the fact that using the sockets API directly isn't that difficult (i.e not too much boilerplate code required to get quick results) so I probably suggest wrapping your own socket library. I could give you a link to loads of premade socket libraries but personally I dislike using other peoples wrappers for this kind of thing.

 

Below is a list of simple examples. I use these as a basis for my own netcode.

 

Winsock

Server - http://msdn.microsoft.com/en-us/library/windows/desktop/ms737593%28v=vs.85%29.aspx

Client - http://msdn.microsoft.com/en-us/library/windows/desktop/ms737591%28v=vs.85%29.aspx

 

POSIX / BSD / UNIX Sockets

Server - http://www.linuxhowtos.org/data/6/server.c

Client - http://www.linuxhowtos.org/data/6/client.c

 

Of course there is also Boost.Asio if you want to use a pseudo standard library (Akin to .NET and Java sockets).

 

For UDP, have a look at the simple examples here - en.wikipedia.org/wiki/Berkeley_sockets




#5090227 Confused about OpenGL 3.0+ shaders

Posted by Karsten_ on 29 August 2013 - 03:31 PM

From the looks of it, TheChubu based his answer off your sample code where you used vertexPosition_modelspace.

 

Try using in_Position instead because that is the correct name of the uniform.






PARTNERS