Hide game data from player?

| | August 11, 2015

I’m working on my first (C++) game, and I want to use a component based design. I’ve read a lot about this lately and yesterday I decided I wanted to store object data in external JSON files, to allow for more flexibility and ease of access.

Then it dawned on me that leaving these files in the game’s directory tree would allow the players to modify anything they want very easily.

I’m not worried about showing the code to developers, because the game will be open source, but I’m afraid an inexperienced gamer might break the game or at least ruin the fun.

Am I missing something? What’s the policy about hiding game data (in open source games)? Is it normal to leave everything plainly accessible to anyone?

If not, what is a good way to hide the data?

What's a good Open Source game to learn from?

| | August 11, 2015

I want to download the source code of an Open Source game, so I can get familiar with game architecture. Does any one know of a game with source code that’s legible, and easily understandable?

After some thinking, I’d like to make a game that can be played on the desktop or an Andriod phone with 2D graphics.

How does one disable the right-click context menu in Flash?

| | August 11, 2015

I happened to play around with habbo.com social game portal.

It clearly uses Adobe Flash as platform (if you look into the source code of the HTML page). But when you do right mouse click you don’t get the Flash right-click menu popping up!

Does anybody have an idea how this is done?

What is an appropriate OpenGL(ES)-based game engine meeting these criteria?

| | August 11, 2015

I want to try my hands on a little shooter on the Android platform, and I’m looking for a full-featured 3D game engine. I can’t afford to pay more than 400 € for a license, so expensive engines are excluded from the start.

These are my requirements:

  • The engine has to have good level editor (able to place entities, actors and triggers); so “graphics engines” like Irrlicht and Horde 3D aren’t what I’m looking for.
  • The engine should be based on OpenGL Core and use shaders rather than the fixed function pipeline.
  • It shouldn’t use octrees and BSP/PVS.
  • It needs to have decent occlusion culling because I need good frame rates on not-very-powerful graphics cards.
  • It should come with source code.

I like Horde 3D very, very much and I like it’s smart design, rendering capabilities and compactness. Sadly, I can’t use it due to the lack of tools.

So far I’ve come across Torque 3D, C4 engine, Shiva 3D, and Unity 3D.

  • Torque 3D is really nice, decent design, has good tools, good performance, it’s really cheap and comes with source code. Sadly it’s only DirectX for now.

  • Unity has a lot of features, decent performance and tools, runs on Android but they don’t give source code within my price range.

  • C4 is good enough, has tools, and source code but there’s a catch. While you have source code the source isn’t ported to Android and the engine’s owner expressly forbids anyone to port source code on other platforms or to release a game on not officially supported platforms.

  • Shiva 3D seems nice, too, supports Android, has tools but they don’t give you source code license for a decent sum.

That’s all I could find. I used the list on devmaster.net, I searched this site, I’ve searched gamedev.net, gamasutra, polycount.com and of course Google and Bing.

Any suggestions that could help me?

What is an efficient way to deal with large, scrolling background images?

| | August 11, 2015

In my mobile game you basically you just fly up (infinite height) and collect stars.

I have many quite large background images, scaled down so that their width is the same as the device width. Then they are appended after each other during rendering.

Since I implemented these backgrounds, my game runs poorly. I’ve got about 20 background images with a size of 800×480 each; without backgrounds the game is quite smooth.

Does anyone have an idea how to implement this many backgrounds without making the game slow down?

The images are used as a 2DTexture.
If I leave the clouds out of the image and “just” display the blue part, the app still slows down. Showing some code is a bit difficult, because I got many many classes which will do the loading, rendering and display stuff. Basically its done as Google does it in there “spriteMethodTest” example here:

2 of these image set.

First: http://picbox.im/view/b7c8c86abb-01.png

Second: http ://picbox.im/view/3a8162314a-02.png

How can I implement voxel-based lighting with occlusion in a Minecraft-style game?

| | August 11, 2015

I am using C# and XNA. My current algorithm for lighting is a recursive method. However, it is expensive, to the point where one 8x128x8 chunk calculated every 5 seconds.

  • Are there other lighting methods that will make variable-darkness shadows?
  • Or is the recursive method good, and maybe I am just doing it wrong?

It just seems like recursive stuff is fundamentally expensive (forced to go through around 25k blocks per chunk). I was thinking about using a method similar to ray tracing, but I have no idea how this would work. Another thing I tried was storing light sources in a List, and for each block getting the distance to each light source, and using that to light it to the correct level, but then lighting would go through walls.

My current recursion code is below. This is called from any place in the chunk that does not have a light level of zero, after clearing and re-adding sunlight and torchlight.

world.get___at is a function that can get blocks outside of this chunk (this is inside the chunk class). Location is my own structure that is like a Vector3, but uses integers instead of floating point values. light[,,] is the lightmap for the chunk.

    private void recursiveLight(int x, int y, int z, byte lightLevel)
        Location loc = new Location(x + chunkx * 8, y, z + chunky * 8);
        if (world.getBlockAt(loc).BlockData.isSolid)
        if (world.getLightAt(loc) >= lightLevel || lightLevel <= 0)
        if (y < 0 || y > 127 || x < -8 || x > 16 || z < -8 || z > 16)
        if (x >= 0 && x < 8 && z >= 0 && z < 8)
            light[x, y, z] = lightLevel;

        recursiveLight(x + 1, y, z, lightLevel);
        recursiveLight(x - 1, y, z, lightLevel);
        recursiveLight(x, y + 1, z, lightLevel);
        recursiveLight(x, y - 1, z, lightLevel);
        recursiveLight(x, y, z + 1, lightLevel);
        recursiveLight(x, y, z - 1, lightLevel);

Creating Font Textures in Direct3d without D3DX

| | August 11, 2015

Update: The completed solution using Nathan Reed’s answer is posted in my answer below

A few open source programs I’ve seen that render installed fonts do something like this…

Create a texture for the font
Draw font to texture using native calls
Store the coordinates for each character
Create a vertex buffer with a quad for each character
Render the vertex buffer using the font texture

But I’m really having trouble getting this to work consistently. GetTextExtentPoint32A() for Win32 font sizes which does NOT include italic support and seems to cut off some of the stranger fonts.

Here is an example output from my code. Notice the cut off edge of the Q and a few other characters. A much more exaggerated version happens when rendering italics.


The code looks something like this…

for (uint8 c = 0; c < 127 - 32; c++)
    str[0] = c + 32;
    SIZE size;
    GetTextExtentPoint32A(hDC, str, 1, &size);
    if (x+size.cx+1 > m_TextureSize)
        x  = 0;
        // 1 pixel vertical margin
        y += size.cy + 1;

    uint32 Diff;
    ExtTextOutA(hDC, x+0, y+0, ETO_OPAQUE | ETO_CLIPPED, NULL, str, 1, NULL);
    m_fTexCoords[c].Left = x/m_TextureSize;
    m_fTexCoords[c].Top = y/m_TextureSize;
    m_fTexCoords[c].Right = x+size.cx/m_TextureSize;
    m_fTexCoords[c].Bottom = y+size.cy/m_TextureSize;

    // 1 pixel horizontal margin
    x += size.cx;

The image above is actually just a render of the whole texture stretched from -1,-1,0 to 1,1,0 not using the stored texture coordinates to show clipping due to GetTextExtentPoint32A.

Again this works fine for some fonts but looks terrible for others and doesn’t support italics.

It is designed to work in a system like this…

cFont* g_Font;
cTextObject g_TextObject;

    g_Font = SetupFont("Arial", BOLD | ITALIC, 24pt);
    g_TextObject = CreateTextObject("The quick brown fox...", g_Font, X, Y);


So in general I guess my question is what is the correct approach for this issue?

Should I just let each text object have a texture and on text object creation use the GDI to render all text to it (which would bypass the italics and font face problem)?

But then wouldn’t texture memory usage get out of hand?

Vector games (Wireframe, Elite-like) theory and implementations?

| | August 11, 2015

I’m interesting in knowing more about how vector games like Elite and Star Wars Atari were built from grounds up. The question is not how to implement vector graphics with modern 3D APIs like OpenGL and DirectX, since doing it is quite easy and does not require to build a vector/matrix system from scratch like those games did.

Some things I presume about these games:

  • They work on an extremely low level and are written in ASM
  • They’re actual 3D games and not faking it like After Burner. Not like Wolfenstein 3D, either. Afterburner used rotozoom/raster effects and Wolfenstein 3D used raycasting and 2D scaling and it’s not really 3D, since you can’t move up. Even if you could like the Build Engine that Duke Nukem 3D used, everything except the walls is just a sprite. Star Fox is closer to it, since uses actual 3D models, but the implementation uses SNES’ Super-FX chip and probably employs scanline trickery. I know Elite probably uses said scanline trickery as well (at least on some implementations like Elite NES) but I’m not sure about SWA, since it used a custom-built arcade machine; either way, I’d like to know more about it.
  • Their 3D models are actual 3D models. They are defined as vectors and transformed according to the position of the camera.

I know the best thing to do would be to disassemble the source of Elite and see how things were done by myself but before doing that I want to know more about how they were made and if there are modern open-source projects that show similar techniques. I don’t mean Elite remakes like Oolite (which uses OpenGL and Obj-C) but projects that use similar techniques and avoid using APIs like OpenGL directly – not necessarily low-level projects, though, using 2D library like SDL (without OGL) should be enough, at least for now.

I know that the source code to MESA3D probably contains many of the routines that games like Elite and SWA implemented – I just want to see them in the context of a game. I know that what Elite and SWA basically did was implement Rasterisation, create their format for models and a loader (I’m pretty sure that at least SWA had models built from modelers using tools, although it’s not impossible to hard-code TIE-fighters it’s hard to do so accurately) and many other things I may be unaware of. But it’s really time-consuming to get into and I don’t care about much of the stuff that is in it. Keep in mind that games like Elite were very lightweight due to the low ROM and RAM that computers and consoles had at the time.

I’m new to 3D graphics and all my assumptions are based on my limited knowledge of 3D Geometry and school level maths, sorry if I said any bullshit. But I’d really like to know more about how those games work in every detail, and possibly not just “buy X book” since I’m quite broke. Although I’d buy a book about the development of Elite or a similar game, if it existed. Some general suggestions would be enough.

Cross-platform, free (for commercial use) C/C++ 2d game library or rendering engine?

| | August 11, 2015

i need a C/C++ engine that should be really cross platform (or at least windows, android, and iphone).

The 2d engine should be written in C or (better) C++, should permit the rendering of animated sprites, permit transparency, collisions (but i can integrate box2d for that), rotations (eventually with opengl support to accelerate things), handle tile-based games. If it could be a game engine (with support for events/actions, scripting and generally have the features needed when developing a 2D game) it would be fantastic.

There are a lot of open source free 2d engine out there, but soon or later you find that:

  1. the documentation is not so good and/or the tutorials are not so good (or there are
    not tutorial at all), the examples are missing (or are too few or are missing)
  2. the community is too small and not so supportive
  3. the engine doesn’t abstract system things enough. That is bad, because you
    soon find out that there is support for X and Y but not Z. With abstraction, you can
    use even Z adding system specific code
  4. the engine is a game engine but does not have an associated editor. scripting is
    good, but an editor would save a lot of time i think
  5. the engine writers have spent too much time to develop a complex (that will probably
    fails) compilation tools.

It would be useful to have something that:


In that way, using an empty implementation of the relevant interfaces, you
can simply code what you need

6 . You come to the conclusion that usually there is not a sufficient conceptual separation from what really needs to be abstracted and what can be supposed to be found on almost all systems (e.g. opengl).

Ok. The question is, regarding a free, open source 2d rendering engine or a 2d rendering engine+2d game engine for at least ios and android: in your experience, what would be a good/wise choice?

Almost working 2D Collisions

| | August 11, 2015

I’m terribly sorry I’m asking this question YET AGAIN, but I can almost guarantee that this will be the last time I’ll have to ask.

I’m currently on the verge of FINALLY getting these collisions to work for my game, made with libGDX in Java. My collisions use the same method as (and are basically copied and modified code from) the XNA Platformer example (here) where the direction of the collision is based on the rectangle where two objects are overlapping.

The collisions themselves almost work perfectly, but for some reason, holding down/up and left and colliding with the floor/ceiling while doing so doesn’t seem to work well. I’m not at all sure why.

Instead of vaguely giving my problem and snippets of code, I’ve decided to instead provide a binary and the source of the game I have so far so you can see for yourself what my problem is. Link. (Note: make sure you unzip everything into a folder somewhere or it will not work)

You’ll find the collision code in the method workingCollisions() in Link.java. Please excuse the messy code and terrible graphics as this whole thing is in pre-pre-alpha.

If anyone is kind enough and helps me out here, you are the best person ever. I’m completely desperate; I’ve been trying this on and off for months and I just can’t get it to work. I cannot thank you enough.

Page 1 of 12123456789101112