texts: Implementing a Menu System and Buttons (Waiting in a whle loop)

texts: I have a menu system with four screens and six buttons. I have created a button class and it works great. I even have events for the buttons working. The problem is that I have to run the events inside the game loop. This causes me to wait on a menu screen. Is there a way with SDL and c++ to wait until an even fires aside from setting a variable on button click and waiting in a while loop?


texts: XNA `tex2Dlod` always returns transparent black

texts:
I want to sample a texture in a vertex shader, so at first I just tried using

float2 texcoords = ...;
color = tex2D(texture, texcoords);

But apparently I cannot use tex2D in a vertex shader, and must use tex2Dlod. So then I changed the above code to

color = tex2Dlod(texture, float4(texcoords, 0, 0));

But now color is always float4(0, 0, 0, 0) (i.e. transparent black).

Why is this, and how can I fix it?

EDIT: I know for a fact that the texture does not contain just transparent black pixels.


texts: should users be asked to submit high score to leaderboard?

texts:
If a user gets a new high score in a game, should they be asked before having their score submitted to the leaderboard?  Originally I was just going to submit their score to the leaderboard without prompting them, but a friend told me that it is preferred that the user be asked.

thanks


texts: How do these Direct3D 11 components work together?

texts:
I am having a really hard time to understand how the following Direct3D components play together and what they do (or exist for) while creating a scene on the screen.

render target view
render target
viewport
back buffer target
back buffer texture (this is ID3D11Texture2D which is used as buffer target I guess)
buffer (front buffer and back buffer)

I am currently reading a book about Direct3D 11 but the explanation does not match my brain model. Can someone explain in detail how it works (is there a diagram of it somewhere)?


texts: Collision detection between 2 irregular shapes

texts:
I need to implement a collision system for a vertical-shotter and the bullets can have any type of shape; i've implemented the shape class with an array of choords and an array of lines which have the references of start and end points; in case the line is bezier it have an array of anchor points.

so:

Line { Choord Start,End; Choord [] Anchors = null; ... }
Choord { float X, Y; ... }
Shape { Choord [] Vertexs; Line [] Lines; ... }

i have to handle a collision like this:

anyone have a general idea for check collision with this type of shapes?
and this model can work?

i've tryed with SAT collisions but it works only for convex polygons.


texts:
I want to add a feature to my game engine where I can change different variables that control in-game things while the engine is still running from a console window.

I have designed the engine in C++, and because of its compile-time nature, I don't think it's possible to change inner-working variables during run-time. I have looked at python extensions for C++, but I do not know if that will be sufficient to change values while the program is running.

How do I edit runtime variables within a custom C++ game engine?


texts: Look rotation viewing vector is zero in Unity when making UI

texts:
How can I tackle the problem: Look rotation viewing vector is zero?

Here is how I get it:

I add an Image from UI.
When the Image is added I click on it in the Hierarchy view.
When focus is on an Image I take the Canvas border and move it left.
I get the Exception.

Here are some screenshots of the process which takes place:

In the last screenshot I selected the Canvas and tried to focus on it by pressing F in the Scene view. As you can see I am not able to resize the canvas anymore. That means that I would have to create a new Canvas and copy everything into it, which is pretty tiresome and error prone. That is a reason I am concerned with the Exception. Will appreciate any attention.


texts: Which for basic RTS prototype: Unity or Torque?

texts:
I'm wanting to test my hand at writing an RTS (something I've never gotten very far with), and so I'm looking for an indie engine that would give me the most success with a quick setup that I can then tweak and start to get the ins and outs of RTS design/development.

I've had a bit of familiarity with both Torque and Unity both, but never from that perspective.

Which would get me closer to base prototype faster?


texts: Unity AudioMixer sets AudioSources to 0 regardless of decibel value

texts:
My code for the decibel and volume/linear conversion is good already. I just can't figure out why my AudioMixer keeps on setting my AudioSources to 0. I've double checked to see if my decibel value on my AudioMixer is updating. It updates accordingly. But, my AudioSources remain to have a volume of 0 regardless of any update or not.

Any ideas on what could be the problem?


texts: How Can I generate a shield block from a Turn based medieval game fight?

texts:
Imagine the char below, a Spartan that in his turn attacks and in the opponent turn tris to block. What would be the logic behind the block process? I just don't want to rely generating random numbers to decide

Update:

This is what I want to do, depending of the kind of the shield it would be more likely to block than others:


texts: Making an object swing from one rope to another

texts: I am trying to make a Tarzan like game with Cocos2D and Box2D. I am having issues with the physics - making an object swing from one rope to another. I am not really sure how to do this. Could anyone please help me.


texts: Render with multiple lights (one pass per light)

texts:
I have already a system that at the moment handle multiple lights just passing an array of light struct and loop through it. I had been told to switch to a multipass rendering approach. How should I do this in an efficient way? Can you link me to some resources about this?

I cannot switch to defferred rendering.


texts: Moving a 2D character on a straight line

texts:
I am trying to create an Android Game and I am facing my first big problem.

After reading blogs, tutos ... I am able to easily move a character with a drag and drop, make it move move to a touched area, but I am unable to move it on a straight line with a finger gesture !

Here's a quick explanation of my problem

I want the character to move on a virtual grid, only up down left right, on a straight line and until it uncounter a wall.
If there is nothing on his path, he is unstopped and "fall" from the screen !

He can only move from center of a square to the center on the square he is stopped on. This mean that when he hits a wall, he bounce and go back to the center of the previous square.

For complement :

It will be a sliding movement
The wall is just a term, in fact it will be objects ( let say fruits, animals ... ), with different size in a square with the same size that all the other squares.
I want to movement to be fluid over the tiles, not moving from tiles to tiles with a stop every time.

I am on that movement since weeks and can afford to find a solution, so your help is really welcome !

Thank you very much.


texts: Do rendered-to-textures need to be bound when being drawn to?

texts:
In OpenGL, if I'm rendering to a texture using a framebuffer, do I have to have that texture bound while I'm rendering to it? In code:

glBindTexture(...);
glTexImage2D(...);

glBindFramebuffer(...);
glFrameBufferTexture2D(...);

//START DRAWING HERE: does the texture I'm rendering to need to be bound here?


texts: What does a rim shader do and what is it used for? In what cases would it make sense to utilize a rim shader?


texts: 2d array to calculate height for player in heightmap?

texts:
I'm trying to work out how to do so my player position takes into the account of the floor so if I generate a floor that is hilly when I walk I won't walk through the heel. The problem is that I'm not sure how to do it.

I can do basic collision detection for walls. However, this isn't collision detection. I need the add the height of the terrain to the player.

So as you see the terrain is really a grid with 4 points making a face. So I can get the 4 points and work out. I can probably work this out on myself, but I was wondering if I should store say the heigh at (x,z) in a 2d array or do I just work out the height again everytime I move?

It just I use simplexnoise and I worry that this will be expensive to do every turn.

 import java.util.ArrayList;

    public class VoxelLevel
    {
    Mesh mesh;
    Material material;
    Transform transform;
    Shader shader;

    VoxelLevel(String textureName)
    {
        material = new Material(new Texture(textureName));
        transform = new Transform();

        shader = BasicShader.getInstance();

        generateLevel();

    }

    private void generateLevel()
    {
        ArrayList<Vertex> vertices = new ArrayList<Vertex>();
        ArrayList<Integer> indices = new ArrayList<Integer>();

        int sizeX = 10;
        int sizeZ = 10;
        int freq = 25;

        for(int x=-300; x<300; x+= sizeX)
        {
            for(int z=-300; z<300; z+=sizeZ)
            {
                indices.add(vertices.size()+0);
                indices.add(vertices.size()+3);
                indices.add(vertices.size()+2);
                indices.add(vertices.size()+0);
                indices.add(vertices.size()+1);
                indices.add(vertices.size()+3);

                vertices.add(new Vertex(new Vector3f(x,50+25*(float)(SimplexNoise.noise(x/freq, z/freq) + 0.25 * SimplexNoise.noise(2*x/freq, 2*z/freq)),z), new Vector2f(0.75f,0.75f)));
                vertices.add(new Vertex(new Vector3f(x+sizeX,50+25*(float)(SimplexNoise.noise((x+sizeX)/freq, z/freq) + 0.25 * SimplexNoise.noise(2*(x+sizeX)/freq, 2*z/freq)),z), new Vector2f(0.75f,1.0f)));
                vertices.add(new Vertex(new Vector3f(x,50+25*(float)(SimplexNoise.noise(x/freq, (z+sizeZ)/freq)+ 0.25 * SimplexNoise.noise(2*x/freq, 2*(z+sizeZ)/freq)), z+sizeZ), new Vector2f(1.0f,0.75f)));
                vertices.add(new Vertex(new Vector3f(x+sizeX,50+25*(float)(SimplexNoise.noise((x+sizeX)/freq, (z+sizeZ)/freq)+ 0.25 * SimplexNoise.noise(2*(x+sizeX)/freq, 2*(z+sizeZ)/freq)),z+sizeZ), new Vector2f(1.0f,1.0f)));
            }
        }

        Vertex[] vertArray = new Vertex[vertices.size()];
        Integer[] intArray = new Integer[indices.size()];

        vertices.toArray(vertArray);
        indices.toArray(intArray);

        mesh = new Mesh(vertArray, Util.toIntArray(intArray));
    }

    public void input()
    {

    }

    public void update()
    {
        //SimplexNoise.noise(0.25, 0.25);
        //SimplexNoise.noise(0.35, 0.65);
        //SimplexNoise.noise(0.254, 0.225);
        //SimplexNoise.noise(0.254, 0.215);
    }

    public void render()
    {
        shader.bind();
        shader.updateUniforms(transform.getTransformation(), transform.getProjectedTransformation(), material);
        mesh.draw();
    }

}


texts: 2D Procedural Terrain Generation - Guaranteeing connectedness?

texts:
I'm working on a 2D platformer in XNA. One of things I'd like to be a main design characteristic is procedural content generation. The first step of that is to procedurally generate the terrain. So, I've done loads of research on how to generate Perlin noise, smooth it out, play with parameters and all that jazz. I've also spent loads of time at pcg.wikidot.com. The problem I have is generating a level that is 100% connected. Meaning, it's possible for the character to get from the left part of the level all the way to the right part.

Right now, I use the perlin noise to generate a sprite when the noise value at that point is < 0.

Here is a video of the issue I'm having (please excuse the crazy background issues and the fact my character gets stuck when I generate a new level).

http://screencast.com/t/uWJsIGLoih

As you can see in the video, the terrain looks interesting enough, but you can't do a whole lot because the Perlin noise compartmentalizes the level into small, random chambers.

I attempted to perform a random walk and overlay the perlin noise on top of it, so I guarantee a path from left to right. The issue with that is illustrated below:
http://screencast.com/t/ilLvxdp3

So my question is: What kinds of things can I do to ensure the player can get from the left part of the level to the right part of the level?


texts: Is there an in memory data store that is feasible for real time, non-networked games?

texts:
I would like to know if anyone has recommendations or experience with using an in memory data store for a real time, non-networked game. This is not necessarily for loading levels or saving data, but to be accessed within the game loop as the game is running. Pretty much everything I look at w.r.t. data stores in games refers to networked games like MMOs.

As I am working on my game I find myself building a lot of ad hoc structures to hold various bits of game data and I was thinking it would make more sense to leverage work in this area that would provide a more consistent (and hopefully efficient) retrieval/storage method.

Does anyone have any experience or recommendations on in memory databases or key value stores or document stores that would be reasonable?

For my own purposes, my game is being written in Scala but the answers don't need to be Scala/Java specific.

EDIT

To be more specific I am primarily talking about entity data and lists of entities not necessarily things like 3D meshes.


texts:
I'm making a simple pong game in ruby.

I did the collision detection this way:

def collides_with(player)
      ((@x + @image.width >= player.x) && (@x <= player.x + player.image.width)) && ((@y + @image.height >= player.y) && (@y <= player.y + player.image.height))
end

If this is true I multiply the ball's y coordinate by -1 (to change its direction):

@ball.vy *= -1

This is working as expected, except in one case when the ball reaches the left (or right) side of the paddle while it's moving. this will cause the ball to move into the inside of the paddle,which seems strange.

What should I do to fix this?


texts: The math behind Variance Shadow Maps - moments

texts:
I am not asking how to implement them (that's not particularly difficult), but I'm having a bit of trouble understanding why the moments used in Chebyshev's inequality (indirectly) are equal to the depth value and the depth squared respectively.

To grasp why things are like this, I tried to understand what the random variable one computes the moments for is, and what is its density (the p(x) in those integrals used to compute the moments). Now that one can equate the moments to the depth and depth^2 is the magic behind this approach, hence the key of justifying it mathematically. Can anyone please explain what p(x) is, and why is the first moment equal to the depth value? I can probably pick up from there and easily understand the second moment.


texts: How to set my game to load low-level drivers from a different System32 folder path

texts:
The title says it all
I'm doing a test with my game
and I need to know how to set it up
where my game loads low-level drivers from a System32 Folder that is
in another path instead of this

example: C:\Windows\System32

a new path I want to have my game load drivers from:
D:\Windows\System32

and can I make my game load low-level drivers from this path
with some c++ coding in visual studio?


texts:
I'm making a simple HTML5 RPG in pure JavaScript likened after Nox, Diablo or Titan Quest, with the character centered on the screen and the map moving around it.

TL;DR: My character, when colliding with the map edge, can still move outside the map in some cases. How do I quell this inconsistency?

Explanation: I have simple rectangles for the map, character, and one enemy, and I'm using bounding-box collision detection for them. When the character pushes against the map's edge, it stops moving, but the enemy box moves opposite of my character's trajectory of motion. When the enemy hits the wall, it stops, but the collision detection for my centered character fails and I'm flung into the void.

Here is a screenshot demonstrating this (map=white, character=blue, enemy=red):

Here are some bits of relevant code that might help:

Box object:

function Box() {
    this.x = 0;
    this.y = 0;
    this.width  = 50;
    this.height = 50;

    this.init = function(x, y, w, h, c) {
        ...
    };

    this.move = function(dir, amt, reverse) {
        ...
    };

    // stops 'obj' from leaving 'this'
    this.constrain = function(obj) {
        if(this.x > obj.x) {
            this.x = obj.x;}
        if(this.y > obj.y) {
            this.y = obj.y;}
        if(this.x + this.width  < obj.x + obj.width) {
            this.x = obj.x + obj.width  - this.width;}
        if(this.y + this.height < obj.y + obj.height) {
            this.y = obj.y + obj.height - this.height;}
    };
    this.draw = function() {...};
}

Main code:

var m = new Box();
var p = new Box();
var e = new Box();

function rand(a, b) {return ((Math.random()* (b - a)) + a);}

// monster moves away from player on player collision with map.
// player moves off map on monster collision with map.
function init() {
    p.init(cn.width/2 - p.width/2, cn.height/2 - p.height/2, 20, 20, "blue");
    m.init(p.x, p.y, 200, 200, "white");
    e.init(rand(m.x, m.x + m.width  - e.width), rand(m.y, m.y + m.height - e.height), 20, 20, "red");
}

function update() {
    if(key.left)  {
        m.move('left',  p.speed, true);
        e.move('left',  p.speed, true);
    }
    ...

    m.constrain(p);
    m.constrain(e);
}

function draw() {
    c.clearRect(0, 0, cn.width, cn.height);
    m.draw();
    p.draw();
    e.draw();
}

How would I make both the monster and the character consistently collide with the map?

I'm sorry in advance if the code/post is too long. I spent a good, long while shortening it up. I'll happily edit it, just ask. Thank you! :)


texts: How to set orthgraphic matrix for a 2d camera with zooming?

texts:
I'm using ID3DXSprite to draw my sprites and haven't set any kind of camera projection matrix. How to setup an orthographic projection matrix for camera in DirectX which it would be able to support zoom functionality?

    D3DXMATRIX orthographicMatrix;
    D3DXMATRIX identityMatrix;

    D3DXMatrixOrthoLH(&orthographicMatrix, nScreenWidth, nScreenHeight, 0.0f, 1.0f);
    D3DXMatrixIdentity(&identityMatrix);

    device->SetTransform(D3DTS_PROJECTION, &orthographicMatrix);
    device->SetTransform(D3DTS_WORLD, &identityMatrix);
    device->SetTransform(D3DTS_VIEW, &identityMatrix);

This code is for initial setup. Then, for zooming I multiply zoom factor in nScreenWidth and nScreenHeight.

UPDATE

This is going to work:

    D3DXMATRIX orthographicMatrix;
    D3DXMATRIX identityMatrix;
    D3DXMATRIX viewMatrix = D3DXMATRIX(
        1,      0,      0,      0,
        0,      1,      0,      0,
        0,      0,      1,      0,
        (FLOAT)(-(this->nScreenWidth / 2)), (FLOAT)(-(this->nScreenHeight / 2)),        0,      1
    );

    D3DXMatrixOrthoLH(&orthographicMatrix, (FLOAT)this->nScreenWidth, (FLOAT)-this->nScreenHeight, 0.0f, 1.0f);
    D3DXMatrixIdentity(&identityMatrix);

    this->p_device->SetTransform(D3DTS_PROJECTION, &orthographicMatrix);
    this->p_device->SetTransform(D3DTS_WORLD, &identityMatrix);
    this->p_device->SetTransform(D3DTS_VIEW, &viewMatrix);

And put D3DXSPRITE_OBJECTSPACE flag next to other flags when you use ID3DXSprite::Begin():

if(this->p_sprite->Begin(D3DXSPRITE_ALPHABLEND | ... | D3DXSPRITE_OBJECTSPACE) != D3D_OK) return 0;

For zoom functionality you can produce this matrix:

D3DXMatrixOrthoLH(&orthographicMatrix, this->nScreenWidth * this->dZoom, -this->nScreenHeight * this->dZoom, 0.0f, 1.0f);


texts: The 'speed' value of the Nav Mesh Agent component does not seem to affect speed at all (Unity3D/C#)

texts:
The speed value of the Nav Mesh Agent component doesn't seem to have any effect whatsoever on the speed of my game object. Actually none of the motion values seem to have any effect. I've attached photos of how I've set up my Nav Mesh Surface Plane and how I've set up the Nav Mesh Component attached to my game object. I followed an online tutorial to use the Nav Mesh Agent component via a C# script. The object moves randomly just fine except that the speed and other values on the Nav Mesh Agent component don't seem to do anything. You will notice that there is a commented out 'randSpeed' public float variable that I experimented with. Changing that variable also did not affect the speed.

Any ideas about this problem are appreciated. Thank you.

public class  RandomMovement2: MonoBehaviour
{
    UnityEngine.AI.NavMeshAgent navMeshAgent;
    public float timerForNewPath;
    private bool inCoroutine;
    //public float randSpeed;

    // Start is called before the first frame update
    void Start()
    {
        navMeshAgent = GetComponent<UnityEngine.AI.NavMeshAgent>();
        //randSpeed = navMeshAgent.speed;
    }

    Vector3 getNewRandomPosition()
    {
        float x = Random.Range(-40, 40);
        float z = Random.Range(-40, 40);

        Vector3 pos = new Vector3(x, 0, z);
        return pos;
    }

    IEnumerator doSomething()
    {
        inCoroutine = true;
        yield return new WaitForSeconds(timerForNewPath);
        GetNewPath();
        inCoroutine = false;
    }

    void GetNewPath()
    {
        navMeshAgent.SetDestination(getNewRandomPosition());
    }

    void Update()
    {
        if (!inCoroutine && (Reaction2.stopMoving==false))
        {
            StartCoroutine(doSomething());
        }
    }
}


texts: Public variable changed in script isn't stored in playmode

texts:
I have a public variable float x in script Foo.cs. I have a Bar.cs script with a function like this:

bar() {
    Foo foo = FindObjectOfType<Foo>();
    foo.x = 1f;
}

And a custom editor which calls bar() when a button is pressed. All of that works fine in the editor, my float x is changed to 1, but when I enter playmode the value changes itself. If I change it manually in the inspector it works fine too. So for example:

I set x manually in the inspector to 10.
I enter play mode, x is still 10.
I exit playmode and call the bar() function.
x has changed to 1 in the inspector.
After hitting "Play" x changes back to 10.

How can I fix this?


texts:
I'm working on a flow field with particle systems and starting to learn about shaders in three.js.

Current state of my work is available here.

As such amount of calculations is quite heavy for a big amount of particles I am wondering is it possible to move it to the vertex shader? (Im just a beginner, no experience with shaders, only what i've read, so please be patient)

The calculations requires previous position to add further displacement and to move the particle further according to the noise value on given position, but i don't think it is possible to output anything from the shader?


texts: Unity Adding Box Colliders Changes Mesh dynamics

texts:
I have a bi-pedal mesh in unity.
I'm adding box colliders to each bone in a mesh so the user is able to individually select each bone.
However, when I add the colliders it changes the dynamics of the mesh, when I rotate the the joint the colliders add weight to the mesh making the parts bend in in proper places

Is there a way I can add the box colliders, without having it effect the dynamics of the mesh?


texts: How to combine image with a gradient? Or make it more featured in a different way

texts:
I generate an abstract 128x128 image, that is in general two-color (it uses values scaled between "blue" and "white", or other similar color pair). I need to make the image more "featured".

Currently, I am blending a four color gradient (prepared in a separate 128x128 buffer) via techniques based on equations from gimp docs. The effects are not good – the gradient dominates over the source image.

How to add some "features" to an abstract image, in procedural way? Maybe you have some tested techniques?

EDIT: here is the image – based on Perlin Noise:


texts: How do I detect and remove completed rows of blocks in Tetris?

texts:
I am making Tetris for a learning experience in XNA, and I'm having trouble deleted completed rows.

I am having an issue with deleting rows, for some reason when I go to delete a row, I end up creating more blocks or not deleting all of the blocks in the row. The method I am using to detect and remove blocks is as follows:

    // 'rowCount' is an int[20] holding the number of blocks in each row
    // (my playing field is 20 rows tall and 10 blocks wide).
    for (int i = 0; i < rowCount.Length; i++)
    {
        if (rowCount[i] >= 10)
        {
            // The row is full, remove the blocks.
            // 'blocks' is a list of all blocks that have settled.
            for (int j = 0; j < blocks.Count; j++)
            {
                if (blocks[j].Row == i)
                {
                    // If the settled block is in this row, remove it.
                    blocks.RemoveAt(j);
                    rowCount[i]--;
                }
            }

            // Move any blocks above the now-empty row down one row.
            foreach (Block b in blocks)
            {
                if (b.Row < i)
                {
                    b.Row++;
                    rowCount[b.Row]++;
                }
            }
        }
    }

This is done in my main Update method after I've determined if the current block has settled or not.

As implemented, this algorithm will usually end up recording more than ten blocks in some rows and will not correctly clear completed rows and move the rows above down one unit. Why is this, and what can I do to fix the algorithm?


texts: How should I automatically update my entire game's files?

texts:
How should I automatically update my player's game assets and executables? It is preferable for the update software to be free. Updates must be small in size and not waste cpu-time. Also it has to be easy to run a update server to create new versions or logistically.

My use case is for updating player game versions such as in massive online clients or running distributed game testing or even normal games.


texts: how to get current zoom level from scene window

texts:
I want to show some label on some rect transforms using Handles.Label(). it shows the text with a default font size regardless of the zoom level in the scene window.

public class NodeWrapper : MonoBehaviour {

    public Node node;

    void OnDrawGizmos()
    {
        Handles.Label(transform.position + new Vector3(-.9f, .5f), node.Name);
        Handles.Label(transform.position + new Vector3(-.9f, .4f), node.Info);
        ...
    }
}

So when I zoom out in the scene window, the labels get closer and at some point they become unreadable. I want to show/hide some lines when zoom level changes. How can I achieve that? Is it possible to get the current zoom level of the scene?

edit

PS. I'm developing a node editor for another game, I use scene window to create and serialize some objects. My target is only Scene window which uses 2D config.


texts:
I'm trying to make a quick installer for my XNA 4.0 game which should be able to install silently. I did some research and figured out that WiX would probably be best for me. I don't like the setup projects inbuilt in Visual Studio 2010, and InstallShield LE doesn't have an XNA 4.0 redistributable.

So, where can I find resources on how to make a WiX installer for an XNA 4.0 game?

I've tried these links, but with no luck. They are targeting a different XNA version, and I want to make sure that a silent install would be supported (while still installing all prerequisites).

http://blogs.msdn.com/b/astebner/archive/2008/11/17/9115792.aspx

http://xnainstaller.codeplex.com/


texts: Can DDS be used in OpenGL in Linux without license/patent issue?

texts:
Is there a 'standard' for OpenGL game creation intended for both Windows and Linux? I understand DDS is the DirectX standard (or, at least, it appears to be). Is there one that does not have potential patent/license issue or does it really not matter?

I am asking as I would like to avoid focusing on DDS as the format to use, only to have that kick me in the teeth later when some license/patent/??? issue requires me to remove and replace DDS with [texture format here]. This is not about what is better or an opinion post, but what is (relatively) safe from the constraints mentioned earlier?


texts:
I'm currently studying opengl shaders but I can't figure out something: how to apply different shaders to the objects, for example, a teapot rendered using toon shader and another one in the same scene using a very reflective surface and other distorted from a noise function, like in this video

http://www.youtube.com/watch?v=1ogg4ZfdBqU

Another one is applying a bloom shader in a scene and a motion blur shader afterwards. How to achieve those effects when you can only have one vertex shader and one fragment shader? Is there any trick such as using more than one shader program?


texts:
I wanted to know if it's possible to use a texture of an FBO for post-processing and using that texture again for writing or do I need at least two textures?

I hope you understand what I mean.


texts:
I'm developing a game and i've ran into some questions about saving and resuming the game. Let's say i have 10 animated sprites drawn every frame (which move side to side) and everytime i press the home button or back button and then go back to my game, it starts drawing the sprites at the starting position rather than in the position before the back/home press.

Do i have to save every sprite and animation position in order to achive resuming the game where i left off (using Bundle, onSaveInstanceState and onRestoreInstanceState())? Or can this be achived some other simpler way.

I'm using the lunarlander example which handles the drawing in a thread and when the user presses the home/back button(onPause) the state is saved and then reloaded on resume.But if i move all the drawing methods to SurfaceView (LunarView) and just call them from a thread(LunarView.draw()), the sprites stay in the exact same position as before the back/home button pressed without saving anything. Can someone explain why this happens? Is it something i should avoid(calling SurfaceView.draw() from a thread) or is this the anwser to my question how to save game state?

Thanks for the reply's.

Regards, J.


texts: How can I use orientation to compute position in Windows Phone 7?

texts:
I'm using the motion API and I'm trying to figure out a control scheme for the game I'm currently developing.

What I'm trying to achive is for an orienation of the device to correlate directly to a position, such that tilting the phone forward and to the left represents the top left position and back to the right would be the bottom right position.

Here are some photos that should make my intent clearer. The red dot would be the calculated position.

Tilted forward and left, upper left selected.

Tilted back and right, bottom right selected.

I also have to make sure that the algorithm takes into account left landscape and right landscape device orientations (portrait is the default so no calculations would be needed for it).

I've tried using the yaw, pitch, roll and Quaternion readings. Here's a sample of my current attempt:

// Get device facing vector
public static Vector3 GetState()
{
    lock (lockable)
    {
        var down = Vector3.Forward;
        var direction = Vector3.Transform(down, state);

        switch (Orientation)
        {
            case Orientation.LandscapeLeft:
                return Vector3.TransformNormal(direction, Matrix.CreateRotationZ(-rightAngle));
            case Orientation.LandscapeRight:
                return Vector3.TransformNormal(direction, Matrix.CreateRotationZ(rightAngle));
        }

        return direction;
    }
}


texts: How to synchronize clocks in multiplayer game?

texts:
I have 2 to 3 clients, that can exchange messages through Apple Game Center.

The only synchronization I need is: start the game at the same moment.

I guess this involves clock synchronization. How to accomplish this?


texts:
I read about game loops, read tutorials of simple games like Asteroids and programmed them by myself. Nevertheless if I try to start reading code of a game with many many thousand lines of code, I have no clue at all where to start, what files to open first and which next to understand how it all work together.

My question is, are there any projects/tutorials out there, that gives a rookie some guidance (by example) how to start reading code of large open source game projects?


texts:
I'm designing a slot machine.

I need to find the number of combinations that two matching icons will appear side-by-side in a 3X5 window (3 rows, 5 reels (columns))

A match gives the user some payout.

Having the following assumptions: Icons: H1, H2, X (all the rest). Matching Icons: should meet on the same row (side by side) (wild doesn't count here)

Window is as follows:

|   |   |   |   |   |
---------------------
|   |   |   |   |   |
---------------------
|   |   |   |   |   |

I have listed all possible options, and now I would like to get the exact number of combinations per each option.

Example of what I need:

The number of possibilities for this kind of scenario (1 of 72 possible ones):

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | X | X |

Number of H1 icons on reels 1-5: R1_H1, R2_H1, R3_H1, R4_H1, R5_H1

Number of H2 icons on reels 1-5: R1_H2, R2_H2, R3_H2, R4_H2, R5_H2

Number of all icons on reels 1-5: RL1, RL2, RL3, RL4, RL5 (respectively)

Some more examples:

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | H1| H2|

| H1| H2| H2| H1| X |
---------------------
| X | X | X | X | X |
---------------------
| X | X | X | X | X |

And so on.. the only limitation I put is that H1 and H2 icons on the same reel have distance between them so I won't have kind of the following scenario:

| H1| H2| X | X | X |
---------------------
| X | X | X | X | X |
---------------------
| X | H1| H2| X | X |


texts:
I have been investigating various 3d engines for iPhone/iPad development and have mostly decided to use Ogre3d.  I have got the SDK, the iPhone dependancies, built and run the SampleBrowser project on the simulator and (with some difficulty) my 3GS. My problem is with the complexity of the SampleBrowser project.

It is a cross platform project, which (at this point) I am not interested in supporting and pre-loads all the Ogre tech samples (some of which don't work on the iPhone). What I really need is a very simple bare bones Hello World XCode project to start work with. If someone knows where I can find one, I would appreciate it. If not, building one is the next thing on my todo list.

I have posted the same question on the Ogre forums, so if I get some feedback there, I will update here.


texts:
I am creating a simple platformer using Box2d. I've implemented a variant of the technique described here.

To make the player character move more 'platformer-like' I want him to stop on (shallow) slopes.

However, the engine I am using does not support angle-joints, so I have trouble restricting the movement of the wheel. I've tried some different alternatives that not worked: Setting the horizontal velocity to 0 every game loop doesn't seem to work, because between calls the wheel catches up speed once again.

Is there another way to fix this?


texts:
What is the difference between framerate independent vs framerate dependent?
Can you please give an example.


texts: entity component - get object from entity system without knowing it's ID

texts:
Ive been building a game using a Entity Component system, but im having a bit of an issue finding a specific object in my entity system without knowing the Entity's Id.

My game is organized in Layers, with each layer owning its own set of systems, such as Entity System, Render System, Collision etc.

Right now, the game has two layers. The Game layer, which encapsulates all game objects and their data, and a Hud layer, which houses all the UI controls. (Pause, restart etc).

What I want to be able to do is, once a specific thing happens in the game layer, such as an enemy dying, I want to be able to communicate to the Hud layer to tell a button to appear or disable itself etc. The problem is, I have no way of finding that button because I have no Id to query for the button in the Hud layers entity system and the reference to the button gets lost after I create the button when the game starts up.

Ive looked into implementing a message queue type of thing, or using some sort of publish/subscribe pattern, but still the issue is how I can communicate that change to an object who's Id I dont know.

One solution I thought about is giving all UI Elements unique names. That way whenever I need to do a change in the UI, I can query the Hud Layer Entity System for an entity with that name, and get its reference back. But then that entirely ruins an entity having a unique Id, because it now relies on using a name for identification.

Is there any way I can get around this?


texts: What should be created first in a video game?

texts: When starting developing a video game, should one focus on creating the environment (buildings, trees, mountains etc) first or the A.I. (Playable character, NPCs etc)?


texts: How do I determine the collision normal in an axis aligned bounding box collision?

texts: I have a 3d moving box and a stationary box.  I can detect collisions ok but now I would like to slide the moving box against the stationary box as a collision response.  For this I need the normal of the face that collides with the moving box.  Does anyone know how I figure this out?  It doesn't seem like the collision test gives me this information.  Any help is appreciated.


texts:
I am planning to create an indie game using Java and Eclipse IDE and I want to put the finished product to Steam Greenlight.

How does the whole process work after the game is finished and running only on Eclipse?


texts: Java collision detection with rectangles

texts:
I'm trying to get the collision between two squares. I've made a Rectangle object that overlays each one and updates the position every tick.

Then I made a collision method that checks whether they are intersecting or not. It just uses rectangle1.intersects(rectangle2);

That works fine, and it detects the collision, however I can't move when it detects it.

This is my move and collision method at the moment.

public void move(int xa, int ya, Player opponent) {
    if (collision(opponent)) {
        return;
    }

    this.x += xa;
    this.y += ya;

}

public boolean collision(Player opponent) {
    if (rectangle.instersects(opponent.rectangle) return true;
    return false;
}

The detection and stuff works fine, but I can't move. I see why I can't, because the method is returning before it moves anything, but I'm just completely lost for whatever reason on where to go with it. I'm sure it's an easy fix and I'm just not seeing something.


texts: Atmospheric scattering sky from space artifacts

texts:
I am in the process of implementing atmospheric scattering of a planets from space. I have been using Sean O'Neil's shaders from http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html as a starting point.

I have pretty much the same problem related to fCameraAngle except with SkyFromSpace shader as opposed to GroundFromSpace shader as here:
http://www.gamedev.net/topic/621187-sean-oneils-atmospheric-scattering/

I get strange artifacts with sky from space shader when not using fCameraAngle = 1 in the inner loop. What is the cause of these artifacts? The artifacts disappear when fCameraAngle is limtied to 1. I also seem to lack the hue that is present in O'Neil's sandbox (http://sponeil.net/downloads.htm)

Camera position X=0, Y=0, Z=500. GroundFromSpace on the left, SkyFromSpace on the right.

Camera position X=500, Y=500, Z=500. GroundFromSpace on the left, SkyFromSpace on the right.

I've found that the camera angle seems to handled very differently depending the source:

In the original shaders the camera angle in SkyFromSpaceShader is calculated as:

float fCameraAngle = dot(v3Ray, v3SamplePoint) / fHeight;

Whereas in ground from space shader the camera angle is calculated as:

float fCameraAngle = dot(-v3Ray, v3Pos) / length(v3Pos);

However, various sources online tinker with negating the ray. Why is this?

Here is a C# Windows.Forms project that demonstrates the problem and that I've used to generate the images:
https://github.com/ollipekka/AtmosphericScatteringTest/

Update: I have found out from the ScatterCPU project found on O'Neil's site that the camera ray is negated when the camera is above the point being shaded so that the scattering is calculated from point to the camera.

Changing the ray direction indeed does remove artifacts, but introduces other problems as illustrated here:

Furthermore, in the ScatterCPU project, O'Neil guards against situations where optical depth for light is less than zero:

float fLightDepth = Scale(fLightAngle, fScaleDepth);

if (fLightDepth < float.Epsilon)
{
    continue;
}

As pointed out in the comments, along with these new artifacts this still leaves the question, what is wrong with the images where camera is positioned at 500, 500, 500? It feels like the halo is focused on completely wrong part of the planet. One would expect that the light would be closer to the spot where the sun should hits the planet, rather than where it changes from day to night.

The github project has been updated to reflect changes in this update.


texts: GameObject once walked on, gives message using C#?

texts:
I'm struggling to figure this code out by myself. I'm able to check if the objects are in the scene, and if they are print a message. I now want the GameObject of tag Zone to display a message to let me know when I've walked on it or at very least, touched it.

Am I entirely wrong with trying to do this with Raycast, or would I be better off trying to figure out how to do this with purely Collisions or something? Just looking for advice more than anything, I really want to figure this out as best I can.


texts:
I am fairly new to game development, but I have a good programming background with object oriented programming.

But with games, I do not know when I should use an object (or class) for an entity on the screen or whether I should just draw the images straight to the screen.

I think that for any graphic objects that need interacting with (say the player or certain environment objects) would need their own class and just decoration (the image that make up the background) could be drawn straight to the screen.

So, my question is: when do I use an object or class for my graphics?

If it makes any difference, I am using LibGDX.


texts: Does Unity's "Transparent Bumped Specular" translate to "semi-shiny must be semi-transparent"?

texts:
Unity's documentation for the "Transparent Bumped Specular" shader/material-type is simply a concatenation of each of the descriptions for its Transparent and Specular Shaders (and also Bumped, but that doesn't apply to the question):

Transparent Properties

This shader can make mesh geometry partially or fully transparent by reading the alpha channel of the main texture. In the alpha, 0 (black) is completely transparent while 255 (white) is completely opaque. If your main texture does not have an alpha channel, the object will appear completely opaque.

(...)

Specular Properties

(...)

Additionally, the alpha channel of the main texture acts as a Specular Map (sometimes called "gloss map"), defining which areas of the object are more reflective than others. Black areas of the alpha will be zero specular reflection, while white areas will be full specular reflection.

To me this translates to:

I have a mesh representig a car tire
The texture need to be very shiny on the rims parts, and almost not shiny at all for the rubber parts
Also since the rim is really complex, (with like cut-out decoretions and such), I will not build that into the mesh, but fake it with transparency in the texture
I can't do all this using Unity's "Transparent Bumped Specular" shader, because the "rubber" part of the texture will become semi transparent due to me painting the alpha channel dark-grey (because I want it to also be less shiny).

Is this correct? If not, how can I make this work?


texts:
I need to display text in my game, who doesn't.

I had originally thought that I could just statically render all the text I would need to images and use those.  I'm starting to think that is a bad idea.  I figure I'll have to internationalize it in the future, and the game has score counters and such which cannot be statically rendered.  It looks like I'll need to use a more dynamic approach.

So my question.

How do games usually handle font loading?

Load the TTF directly and render it to a texture atlas.
Pre-bake the TTF into an image with a configuration file storing locations and kerning.


texts: Why can't my A* implementation find a path out of an open room?

texts:
I tried to follow this article with the following example, but in my attempts it always ends up with a dead end.

If we take G being 10 in a straight line or 14 in a diagonal, and H the distance in horizontal or vertical to the target point, then we restart this search for every tile that is the nearest one to the target point.

I have this result: if we take one or the other direction with 54, it ends up with a dead end. For example, if we go up from 40 to 54, then to 60, when we restart the search with G and H, it ends up with "4" (second shema) and comes back in a dead end:

Why does this happen and how can I solve it?

I also looked at the wiki, but I did not understand the system with the colors and the code shown.


texts:
I have a small test environment where small point lights are scattered. Players should able to collect them.

The collectible lights are rendered using a simple billboard technique where two triangles with a uniform color are rendered facing the camera and a gaussian is used as an alpha-map.

0/1     1/1
+---------+
¦        /¦
¦      /  ¦
¦    /    ¦ u/v texture coordinates for alpha map (gaussian)
¦  /      ¦ every vertex has same color rgb(1, 1, 1)
¦/        ¦
+---------+
0/0     1/0

When a player collects a light, the idea is that the collected light is merged with the lights he already has collected. The players are currently rendered with the same method as the collectible lights, the collected light has influence when the lighting is calculated => higher light intensity.

What I'm looking to do is to visualize the lights better. They look really boring the way they are rendered currently. Only good thing about them is that they do not influence the performance :-)

The process of the light merge could for example be visualized in a way where all collected lights circle around as small pulsating glowing particles - sticking together to some extent - maybe some nice lines which travel with them - you know, like such a thing should look like if it is a central part of a game.

The problem is that I don't really find many resources over advanced shader effects. Most information found is over the basics (diffuse / specular shader - maybe some blurring) or does not involve the HLSL language which I use in XNA 4.0.

I would appreciate any links to resources which could help me making more awesome light effects which could actually run on the xbox without running into performance issues. Basically, any techniques which involve rendering cool light orbs / beams etc. would be fine for the moment if the result i visually appealing.


texts: Is it better to load all of the scene at once or load small parts of it as the player moves?

texts: I want to create a lot of detail in my game but I don’t want to kill the frame rate tracking all the models and movements (like all the grass). Will loading them in pieces save the frame rate or will constantly loading and unloading models with every step negate any benefits of loading in pieces? I want to only load what the player will see at that moment and nothing else until the player either moves the camera or walks. I also want to know if loading a scene on Unity uses the gpu or the cpu?


texts: Raycast is not restricting by other layer collider

texts:
I have converted my project to URP and suddenly I found the situation where my Raycast code even is working beneath the collider (other layer colliders):
if (DisplayMessage.Click && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 1000f, layermask))

I corss check the signature of raycast it is fine and the collider it self. Is there any changes in URP? Here is the way i am setting the layer:
int layermask => LayerMask.GetMask("Interact");

Scenario: In my scene, I have a plane (Default Layer) and a cube(Interact layer). The cube is beneath the Plane. But my camera Detecting the cube on mouse pointer and bypassing the Floor. The raycast should acctually not work if there any object of the desired layer.


texts:
I have a little problem with Updating my Score with TTF.
Im a neewbie so dont blame me :P

I Try to Update my Score But the Buffer Get too small after a while and my Game Crashes.

    void CText::Init(const string &_text, int xPos, int yPos, int Width, int Height)
{
    m_Text = _text;
    Font = TTF_OpenFont("arial.ttf", 30);

    SDL_Surface *pTempt = TTF_RenderText_Solid(Font, m_Text.c_str(), color);
    Texture = SDL_CreateTextureFromSurface(m_Renderer, pTempt);

    m_xPos = xPos;
    m_yPos = yPos;

    m_Rect.x = xPos;
    m_Rect.y = yPos;
    m_Rect.w = Width;
    m_Rect.h = Height;
    SDL_FreeSurface(pTempt);
}

void CText::RenderScore(int Score)
{
    sprintf_s(Buffer, "Score: %i", Score);
    SDL_Surface *pTempt = TTF_RenderText_Solid(Font, Buffer, color);
    Texture = SDL_CreateTextureFromSurface(m_Renderer, pTempt);
    SDL_RenderCopy(m_Renderer, Texture, NULL, &m_Rect);
    SDL_FreeSurface(pTempt);
}

//Game Loop
if (lastscore != currentscore)
        {
            m_Text->Destroy(); //<-- This is SDL_DestroyTexture(Texture);
            lastscore = currentscore;
        }else{
        m_Text->RenderScore(currentscore);}

It shows my score and Updetes it too but I have my char Buffer[50] and after a while it runs out of memory. And i free my font and texture in the destructor.

I thank everybody who helps me out there


texts: Efficient data packaging for a client-server network

texts:
Language: C++

My question is as follows: I would like to know what would be the best or at least a good way to pack and send data from client to server and the reverse. There will be a few data composing a single packet. A packet will have a "id", that defines what is it for, then the data in a pre-
determined order for that "action" which the packet corresponds.

For less performance-dependant systems, i would just send strings, that would be separated by a space, being them the data of the "action"and the first "word" the packet identifier and just chain if statements checking when there is a match.

Now for a more critical system, what i tought so far was something like this:

Make a string with packet id and data, and send it. Then, to unpack, i could extract the first integer in the string, and by having an array of packet handlers, with indices corresponding to the packet id they handle, and just do something like packetHandlers[packetID].Process(packetData) .

What do you think of it, any suggestions? greatly apreciated!


texts:
I have texture with black and white shapes.

I would like that white parts are emissive and black parts are transparent/glass.

How to make such material ?


texts: Is there an advantage to creating a tileset instead of multiple content items?

texts:
I'm using MonoGame to build my first game (yes, I'm new to game development). I'm trying to start by creating a 2D platformer so I want to have different "tiles" for the ground, walls, ceiling, etc.

I don't recall which tutorial I was reading, but I do know that they mentioned creating a tileset.png file and they gave a code sample of how to draw a specific tile from the tileset. I found a tileset on https://opengameart.org/ that I want to use for now, until I can replace the tileset.

I'm curious, is there any advantage to creating a tileset compared to creating, for example, multiple png content files?


texts: I am developing a mobile game in ue4. For this project, I need to have a "static" camera so that the player can move within the frame not affecting camera location and rotation. But as this is an endless scroller I also need to have the camera move at a constant pace limiting the player's area of movement. Does anyone know how to do this?


texts:
I am currently using DirectX11 and MFC. The top of the window should tell me how long it takes to render the cube (in seconds).  At the moment the cube is rendered but when I try to work out how many seconds it took to render the cube I keep getting 0 on the top of the window. This cannot be right. Help please?

This is my Ondraw function:

void CLearningVisualCView::OnDraw(CDC* pDC)
// I want the OnDraw function to create the cube..
{

    CString TimerReports;

    // TODO: add draw code for native data here

    CLearningVisualCDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    Timer.GetStartTime();
    Render(); // This renders the cube

    Timer.GetEndTime(); // The counts stopwatch ends.
    Timer.DeltaCountDifference(Timer.StartTime, Timer.EndTime);
    Timer.GetSecondsPerCount();
    Timer.FrameTime(Timer.DeltaCounts, Timer.SecondsPerCount);

    TimerReports.Format(_T("%.100I64d"), Timer.Time);

    //TimerReports.Format(_T("%.5I64d"), Timer.FrameTime(Timer.DeltaCounts, Timer.SecondsPerCount)); // This converts the DeltaCountDifference into a CString. It has 5 d.p.
    AfxGetMainWnd()->SetWindowText(TimerReports); // This displays my count difference to the top of the window.

}

This is my Timer class:

#include "stdafx.h"
#include "GameTimer.h"

GameTimer::GameTimer()
{

//  QueryPerformanceFrequency((LARGE_INTEGER*)&countsPerSec);
//  SecondsPerCount = 1.0 / (double)countsPerSec;

}

GameTimer::~GameTimer()
{

}

_int64 GameTimer::GetStartTime()
{

 QueryPerformanceCounter((LARGE_INTEGER*)&StartTime);

 return StartTime;

}

_int64 GameTimer::GetEndTime()
{

    QueryPerformanceCounter((LARGE_INTEGER*)&EndTime);

    return EndTime;

}

// The _int64& are references. We will link them to the StartTime and the EndTime in the CLearningVisualCView - OnDraw(). This is done by adding them as arguments.

_int64 GameTimer::DeltaCountDifference(_int64& TimeA, _int64& TimeB)
{

        _int64 DeltaCounts = TimeB - TimeA;

    return DeltaCounts;
}

float GameTimer::GetSecondsPerCount()
{

    QueryPerformanceFrequency((LARGE_INTEGER*)&CountsPerSecond);

    SecondsPerCount = 1 / CountsPerSecond;

    return SecondsPerCount;
}

_int64 GameTimer::FrameTime(_int64& TheDeltaCounts, float& SecsPerCount)
{

    Time = TheDeltaCounts * SecsPerCount;

    return Time;
}


texts:
I'm new to game development. Specifically server side. Currently I am trying to implement movement of monsters. From point A to point B.

I have used an a* pathfinding library to calculate the path to be taken but I do not know the logic on how to update the movement where the monster moves in 30 frames.

I am using javascript/node.js and currently I am doing something like:

// in game.update()
if (!monster.isMoving) {
  var steps = char.getPathTo(83, 213);
  steps.forEach(function (cell) {
    char.move(cell[0], cell[1]);
  });
}

Which of course is very wrong because it will evaluate all the movements first. So what are the possible approaches for this?

I followed this game loop:

var gameLoop = function () {
  var now = Date.now()

  actualTicks++
  if (previousTick + tickLengthMs <= now) {
    var delta = (now - previousTick) / 1000
    previousTick = now

    game.update(delta)

    actualTicks = 0
  }

  if (Date.now() - previousTick < tickLengthMs - 16) {
    setTimeout(gameLoop)
  } else {
    setImmediate(gameLoop)
  }


texts: How do I point with my straight line the point that moves in the figure "infinite" / "8"?

texts:
I need a help for my project.

Given a straight line "a" - "b"
I have "a" point anchored and "b" can move.
I need to make sure that the "b" point of the straight line always points to the "c" point, taking into consideration that "a" is anchored.

I can not use the LookAt () because I need to be able to use the mouse too.


texts: How can I smoothly rotate a joint to an angle?

texts:
I would like to set the speed of my Box2D revolute joint on every update such that it rotates to a desired angle and stops. It should ramp down as its angle approaches the desired angle.

My first thought was just to set the speed to +max or -max based on the difference between the current angle and the desired angle. However, I think this might cause a see-saw effect as the joint overshoots its target angle.

What torque should I apply (each tick) to a joint to achieve a rotation to a specific angle and then rest?


texts: How can I orient a circle relative to the position of a 3D object?

texts:
How can I orient a circle that has a position to a 3D object? If I have a 3D object which is a hemisphere, I would like to let the circle be underneath that hemi-sphere and whenever the hemisphere moves, the circle move with the same angle and position, and underneath it.

In other words, I would like to attach a 2D circle to a hemisphere and parallel to it.


texts:
I am working on a 3D game where you can control an object that orbits a sphere with an on-screen virtual joystick. So far I have that part working, but the object follows the joystick angle perfectly and "snaps" into the angle, rather than smoothly interpolating to the new angle of the joystick.

I would like to redo this and have it interpolate the values. I have it very close using the following code:

angle = Mathf.Atan2(joystickY, joystickX) * Mathf.Rad2Deg;
Quaternion targetRotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, currentAngle);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, TURNING_SPEED * Time.deltaTime);

This works great on one side of the sphere, but as soon as I move the object halfway around the sphere, the rotation is now mirrored and the object rotates 180 degrees until it reaches the other side again. What am I missing here?

I am basically trying to calculate the joystick angle, then apply that to the object as it orbits, but do this smoothly using slerp.

Let me know if you need any further information. Thanks!


texts: Say you are using C/SDL for a 2D game project. It's often the case that people use a structure to represent a frame in an animation. The struct consists of an image and how much time the frame is supposed to be visible. Is this data sufficient to represent somewhat complex animation? Is it a good idea to separate animation management code and animation data? Can somebody provide a link to animations tutorials that store animations in a file and retrieve them when needed. I read this in a book (AI game programming wisdom) but would like to see a real implementation.


texts: Different executions with different results using the same Random seed in LIBGDX

texts:
In my Libgdx project (for PC) I am using a Java Random object initialized with a constant seed. I use the Random object to generate a lot of different pseudorandom integers. I am not using multithreading, but the integers are a bit different each time I execute the application.

How can this be possible?

EDIT: What is really strange is that the Random object is called a few times more in some executions and I don't know why, causing the random numbers to be a bit different for each execution.


texts: Inheritance - accessing child class values

texts:
I want to use the same variable for five different child classes. It is basically a boolean that is true when a player purchases an item(represented by a child class) and false when the player is yet to purchase that item. Then save the bool status.

Can someone tell me how to do just that?

Do I create five different bool variables each on their respective classes(the child classes), then access them individually when a player wants to buy the item?
If I change the bool value of a parent class, it'll change it across all of it's child class.


texts: Simulating a 3D body with a skeleton in iOS

texts:
I would like to make an iOS application that simulates a 3D body with joints and bones, but I am not sure how to do that. The aim of the app is that you can move its arms around and throw it around (x and y axis only).
The app should need to:

import a 3D model with bones and joints (in which format to import this kind of model?)
import the collision boxes for each part of the body (I would probably need ragdoll?)
detect a collision when you touch a collision box of the ragdoll
apply inverse kinematics (IK) on the body when you move your finger (do I need IK or can this be done any other way? Apply a force on a part of the ragdoll?)
apply physics on the ragdoll

How could I achieve these tasks? And are there any libraries that support these things? What is the difference in a ragdoll with and without inverse kinematics?


texts: What does EventSystem.currentSelectedGameObject consider the current object to be?

texts:
I've been working with UI in my project as of late and I can't figure out what Unity's event system is supposed to return for currentSelectedGameObject.

if (EventSystem.current.currentSelectedGameObject != null)
{
    Debug.Log(EventSystem.current.currentSelectedGameObject.name);
}

With the code above I figured that it should return something when I'm moving the mouse across the various UI elements. Unity's documentation appears to be poor on this function stating:

  The GameObject currently considered active by the EventSystem.

maybe I'm just being stupid but does anyone know what triggers currentSelectedGameObject?


texts: How to get connected tiles in hexagonal grid system

texts:
I've been developing a game where a number of tiles can drag into a hexagonal grid background.

For some purpose I need to find the location of same tiles into an array and merge them.

Data Layer:

Presentation Layer:

I need to find the location of all the tiles those who have same value and connected with each other.

So I need a basic idea, how can I do that or if exists any algorithm.

Note: As3 related code will help.


texts: Setting the values of a struct array from JS to GLSL

texts:
I've been trying to make a structure that will contain all the lights of my WebGL app, and I'm having troubles setting up it's values from JS. The structure is as follows:

struct Light {
    vec4 position;
    vec4 ambient;
    vec4 diffuse;
    vec4 specular;
    vec3 spotDirection;
    float spotCutOff;
    float constantAttenuation;
    float linearAttenuation;
    float quadraticAttenuation;
    float spotExponent;
    float spotLightCosCutOff;
};
uniform Light lights[numLights];

After testing LOTS of things I made it work but I'm not happy with the code I wrote:

program.uniform.lights = [];
    program.uniform.lights.push({
        position: "",
        diffuse: "",
        specular: "",
        ambient: "",
        spotDirection: "",
        spotCutOff: "",
        constantAttenuation: "",
        linearAttenuation: "",
        quadraticAttenuation: "",
        spotExponent: "",
        spotLightCosCutOff: ""
    });

        program.uniform.lights[0].position = gl.getUniformLocation(program, "lights[0].position");
        program.uniform.lights[0].diffuse = gl.getUniformLocation(program, "lights[0].diffuse");
        program.uniform.lights[0].specular = gl.getUniformLocation(program, "lights[0].specular");
        program.uniform.lights[0].ambient = gl.getUniformLocation(program, "lights[0].ambient");

    ... and so on

I'm sorry for making you look at this code, I know it's horrible but I can't find a better way.

Is there a standard or recommended way of doing this properly? Can anyone enlighten me?


texts: How to work with a scene objects in batchmode?

texts:
I had an object in first scene, with DontDestroyOnLoad parameter. And when the second scene (void Start ()) loaded, I searched for this object through GameObject.Find(). But this function works only in graphical mode.

I can do this:

EditorSceneManager.OpenScene("Assets/Scenes/Main.unity");
GameObject go = GameObject.Find("TestObject");

But this will not work, engine will be searching only static objects (wich were originally on this scene).
Are there any options? Maybe I should use some additional parameters (I didnt find anything)


texts: OpenGL & SDL textures... game shuts down

texts:
I'm going to create a game in C++ with SDL & openGL but adding textures won't work.
the code is in some different classes.
here's the main file

//==============================================================================
#include "ZOMBOX.h"

//==============================================================================
ZOMBOX::ZOMBOX() {

    isRunning = true;
}

//------------------------------------------------------------------------------
int ZOMBOX::Execute() {
    Init();

    bool mainloop = false;

    SDL_Event event;

    //Create an texture
    unsigned int Ball_texture = 0;
    //Load the image into the texture using the function
    Ball_texture = loadTexture("Smile.png");
    std::cout << "OpenGL is running\n";

    while(isRunning) {
        while(SDL_PollEvent(&event)) {
            Event(&event);
        }
        if(mainloop == false){
            std::cout << "Main loop has started\n";
            mainloop = true;
        }
        Logic();
        Render();
        }

    //Clear();

    SDL_Quit();

    return 0;
}

//==============================================================================
int main(int argc, char* argv[]) {
    ZOMBOX theApp;

    return theApp.Execute();
}

//==============================================================================

Ok, now the rendering;

//==============================================================================
    #include "ZOMBOX.h"

//==============================================================================
void ZOMBOX::Render() {

    extern float ballX;
    extern float ballY;
    extern float ballWH;
    extern int vellX;
    extern int vellY;
    extern unsigned int Ball_texture;
    Ball_texture = loadTexture("Smile.png");

    //RENDERING to the screen
    //Enable textures when we are going to blend an texture
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix(); //Start rendering phase
    glOrtho(0,800,600,0,-1,1); //Set the matrix
    glColor4ub(0,0,0,255); //White color
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Ball_texture);

    glBegin(GL_QUADS); //Start drawing the pad
    //We set the corners of the texture using glTexCoord2d
    glTexCoord2d(0,0); glVertex2f(ballX,ballY); //Upper-left corner
    glTexCoord2d(1,0); glVertex2f(ballX+ballWH,ballY); //Upper-right corner
    glTexCoord2d(1,1); glVertex2f(ballX+ballWH,ballY+ballWH); //Down-right corner
    glTexCoord2d(0,1); glVertex2f(ballX,ballY+ballWH); //Down-left corner
    glEnd(); //End drawing
    //Disable textures when we are done using them
    glDisable(GL_TEXTURE_2D);

    glPopMatrix(); //End rendering phase
    SDL_GL_SwapBuffers();

    SDL_Delay(1);
}

//==============================================================================

i know the comments are not right but i understand it...

now the texture; here's the fault i think

//==============================================================================
#include "ZOMBOX.h"
//==============================================================================
//Function for loading an image into an texture
GLuint ZOMBOX::loadTexture( const std::string &fileName )
{
    SDL_Surface* image = IMG_Load( fileName.c_str() );

    SDL_DisplayFormatAlpha(image);

    unsigned object(0);

    glGenTextures(1, &object);

    glBindTexture(GL_TEXTURE_2D, object);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);

    //Free surface
    SDL_FreeSurface(image);

return object;
}
//==============================================================================

I use variables you cant see but that's no problem thus they are not nessecary(i think).

Sorry for my bad English im just a dutch highschool student.


texts: Collision detection against complex shapes and curves

texts:
I am new in game development and for simple games bounding box collision is fine. However, let's say you have a shape or bitmap like this:

This is just an example but if you had more elaborate curves or even a whole shape which was more complex than a simple polygon or rectangle-like shape, how would you do precise collision detection? I am strictly speaking in 2D here. I just want to know the concept behind how you would do this.


texts: LibGDX: Making an object move correctly based on real time

texts:
Below is an image of my gameworld. As we can see, the player starts at position 0. each cell represents 1 game world unit. My goal is to get the player to move 1 unit (the red cell) in 1 second in 'real world' time using the LIBGDX framework.

LibGDX uses something called 'continuous rendering' by default, which means its 'main loop' runs as fast as the underlying OS is able to. The range could be anywhere from 0-80 frames per second. I am capping the FPS to 60 with the below 'main' loop (In LIbGDX the main loop is called render)

@Override
public void render(float deltaTime) {

    /*
     * Get the time it took to render the last frame and make sure our delta
     * time is never larger than 0.0166666666666667 (60 FPS). This will
     * ensure that on fast OS the game at only 60 FPS.
     */
    float dt = Math.min(Gdx.graphics.getDeltaTime(), 1 / 60f);

    // **********************UPDATE*********************

    player.update(dt);

    // ************************RENDER********************

    // clear the screen and set it to cornflower blue
    Gdx.gl.glClearColor(0x64 / 255.0f, 0x95 / 255.0f, 0xed / 255.0f,
            0xff / 255.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    worldRenderer.render();

}

Below is the code for my player object's update method. As we can see it is operating solely on the delta time for now. In a perfect world of 60 FPS, this would work perfectly but unfortunatly FPS dips will always happen (especially on mobile platforms). How can I add a calculation on top of the delta time to move the player 1 unit in real time regardless of framerate?

@Override
public void update(float deltaTime) {

    // handle user input **always should come first**
    if (Gdx.input.isKeyPressed(Keys.SPACE)) {
        position.x += deltaTime;
    }

}

Below shows what is happening with my current code, if we had a perfect 60 FPS the position should = 1, but as we can see it does not because the FPS varies slightly from frame to frame.


texts: Cocos3D: weird line between adjuscent 3d planes

texts:
I have created a textured plane in blender of size 2×2 and I am using that as a tile. This is the screenshot of what I have done in blender. Nothing special, the default plane on origin, I just added a texture.

I exported this plane to iPhone as POD file. And using below code, I created my tile map.

//getting the tile
CC3MeshNode * greenSlate  = (CC3MeshNode*)[self getNodeNamed:@"GreenSlate"];

CC3Vector greenSize       = [self returnSizeOfNode:greenSlate];

//This one printed as 2.0, 0.0, 2.0 .
NSLog(@"greenSlate : %f  %f %f", greenSize.x, greenSize.y, greenSize.z);

float xOffset           =   -3;
float zOffset           =   -3;

for (int column = 0; column < 3; column++) {
    for (int row = 0; row < 3; row++) {
        CC3MeshNode * mesh  =   nil;

        float xStart        =   xOffset;
        float zStart        =   zOffset;

        mesh            =   [greenSlate copy];

        xStart          =   xOffset + column * greenSize.x;
        zStart          =   zOffset + row * greenSize.z;

        mesh.location   =   cc3v(xStart , 0  , zStart);
        mesh.visible    =   YES;

        //add to scene
        [self addChild:mesh];
    }
}

And when I run on simulator, I am getting this.

The tiles are at correct position, but there is a black line between each tile. How can I remove these lines?


texts: How to change the Rect Transform of a panel in Unity using C#

texts: I am trying to create a sort of menu for a game. I have put my main content on one panel and the menu contents on another. The menu panel is kept to the side of the main panel. I want to place a button on the main panel which when clicked would position the menu panel on top of my main panel. A button on the menu panel would push it back to its original position. What would be the script for these buttons?


texts: Problem with diagonal collision response using PyGame

texts:
So I have been having this problem for the last few days and it has me really frustrated. What I am trying to do is resolve collisions with custom hitboxes in PyGame and it looks something like this:

Everything works fine until I collide with something diagonaly, then I get a weird bug where the character suddenly teleports to the opposite axis side of what I am colliding with, like this:

https://gyazo.com/62c53cc4f3a944c317a951c0f8ae14ea

I have read a lot about this the last day and from what I have gathered this has to do with the fact that I don't resolve the x and y axis independently? maybe?

If I have a print("x") and print("y") statement in their respective code I get this when colliding with something on the "y" axis:

The bug seems to come from that somewhat random "x" in the middle there. The code resolves a collision as if the character was colliding with something on the "x" axis when in fact it was the "y" axis. It is worth nothing that this ONLY happens when diagonaly colliding with the last axis I check (y in this case). So I suppose that is my question really, why does this happen?

Here is my collision handling code:

def collide(self, direction):

    hits = pg.sprite.spritecollide(self, all_sprites_wall, False, rectconverter)
    if direction == "x":
        if hits:
            print("x")
            if self.vx > 0:
                hits[0].update()
                self.x = hits[0].hitboxrect.left - self.rect.width - camera.camera.x
                self.hitboxrect.right = hits[0].hitboxrect.left
            if self.vx < 0:
                self.x = hits[0].hitboxrect.right - self.rect.width + self.hitboxrect.width - camera.camera.x
                self.hitboxrect.left = hits[0].hitboxrect.right
            self.rect.x = self.x

    if direction == "y":
        if hits:
            print("y")
            if self.vy > 0:
                self.y = hits[0].hitboxrect.top - self.rect.height - camera.camera.y
                self.hitboxrect.bottom = hits[0].hitboxrect.top
            if self.vy < 0:
                self.y = hits[0].hitboxrect.bottom - self.rect.height + self.hitboxrect.height - camera.camera.y
                self.hitboxrect.top = hits[0].hitboxrect.bottom
            self.rect.y = self.y

And here is the players update function:

def update(self):
    self.move()

    self.hitboxrect.y = self.y + camera.camera.y + self.rect.height - self.hitboxrect.height
    self.rect.y = self.y
    self.collide("y")
    self.hitboxrect.x = self.x + camera.camera.x
    self.rect.x = self.x
    self.collide("x")

I think the problem lies somewhere in this code, but if you think otherwise feel free to say so and I would happily add more code!


texts: Detecting Collision in Next Step when Collider is rotating

texts:
In my Gamemaker: Studio game, I have a collision script for my enemy. The enemy is an alien, oSwarmer, moving through space which is also filled with drifting, spinning bits of debris. Some debris barely spins at all, others spin quite fast.

When oSwarmer executes the following collision script every step. As you can see, if it is about to come into contact with some debris (here called oSolid) it changes direction away from the colliding oSolid and maintains its original speed.

SolidTouching = instance_place(x + hspeed, y + vspeed, oSolid)

if instance_exists(SolidTouching) {

OriginalSpeed = CurrentSetSwarmerSpeed

if speed > 0 {
direction = direction - random_range(130,220)
} else if speed <= 0 {
direction = point_distance(x,y,SolidTouching.x,SolidTouching.y) - random_range(130,220)
}
speed = OriginalSpeed
}

However, sometimes when coming into contact with an oSolid, they spin madly on the spot. I've noticed that this seems to occur when the oSolid is spinning. These creatures do not move very fast, so their initial 'bounce' is not enough to carry them out of the path of the rest of the oSolid which is coming around to meet them. I think they then get caught in a loop of constantly trying to move in the opposite direction to the colliding oSolid (which is changing every step because it is spinning).

What I cannot work out is how to remedy this. Does anybody have a suggestion?


texts: How do you make game objects (enemies, NPCs) move in interesting, non-linear ways? (e.g. shoot 'em up enemies)

texts:
I'm using a series of easing equations to make menus and transitions a little more interesting in my first game. That got me thinking about how game objects (enemies, NPCs, spaceships, whatever) are 'scripted' to move along complex paths. I'm no maths guy, but I've read that paths can be plotted using Bezier curves (define 2+ control points, interpolate to get position values using start, change and duration values). However I'm not exactly sure how to best go about this (in a structured way that works for a variety of different motions).

I already have a bunch of tweening functions, but these are relatively simple linear, quadratic and cubic curves.

An example - say I wanted enemies to appear at a certain point, then spin in an archimedes spiral until they were off-screen. How would this be best accomplished, and indeed, made generic enough so that another enemy of the same type could move along a sin wave-esque path instead?


texts: Transform inertia tensor using quaternion

texts:
I have inertia tensor T in body coordinates and quaternion q for the body. I know I can transform T to world coordinate by converting quaternion to rotation matrix R and then use the relation (R * T * R^T). However this seems unnecessarily expensive and unwieldy (especially if you are doing this often).

So my question is:

How do I transform inertia tensor from body to world coordinate directly using quaternion and without having to generate rotation matrix from quaternion?


texts: Getting rid of dead objects in a game effectively?

texts:
I'm using a for loop or foreach loop (doesn't matter) to loop through all my objects when they need to be updated or drawn. However, when an object gets killed, I want it to get removed from the collection again.

I do this by adding the object to a dead-objects list, and then, when everything has been drawn and updated, I go through everything in this list, removing the objects in the list from the original source as well.

Is there a better way of doing this?


texts: Create a filled pixmap for box2d fixture

texts: I'm trying to make a pixmap that fills in a Box2D fixture. It would be kind of like a fill bucket. I've done this before, but I want it to work on rectangles and other polygons. Is there an algorithm to do is, or will I need to write on myself? Thanks.


texts: Everything is set to Bounciness 0 - Why am I still bouncing?

texts:
I am creating a platformer where rather than manipulating the character to get them from the beginning of the level to the end, you manipulate the world.  Thus, when you want to make the character 'jump' over a gap, you actually use the land like a slingshot and 'fling' them.

This is all working well and good save for one thing - whenever I pull my land down and my player falls into it again, it begins to bounce - aggressively so!

I have made EVERYTHING out of a new physics material with 0 bounce, and I set my default physics to 0 bounce.

My player is a rigidbody2D that is moving itself along on top of other rigid bodies.

What gives? Why, even though EVERYTHING is set to 'no bouncing allowed' does my game turn into a bouncy-house whenever i start to play?

EDIT: Here is a video of the behavior:

FlingyJump - Bouncing Issues

EDIT: I have noticed a correlation to the bounce occurring and the spring being active.  It have noticed that two things are happening:

1) The spring is for some reason transferring force through to the ground piece while being stretched out.

2) The player is bouncing before even ever hitting the ground.  I don't know quite how that is possible but it seems like as soon as it is enters the original position of the rigidbody2D for the ground piece it bounces.


texts: Rotate a point in 3D space with sine and cosine

texts:
I got my camera controlled by the mouse. Now I want a sphere to be always in the center of my view(just for testing). I tried that by assigning the sine of the Y rotation of the camera times 10 as the X coordinate and the same for the Y coordinate but with cosine:

SphereX = 10 * math.sin(YRotation)
SphereY = 10 * math.cos(YRotation)

But now I would like to know how to set the Z position. I can set the proper height of the sphere by doing that:

SphereZ = 10 * math.sin(XRotation)

But the problem is, that the sphere is only moving up and down and the moving towards the camera is ignored. How can I fix that?


texts: Can a .exe file ported from a program like NW.js or Electron be put console stores?

texts:
I'm early in development working on a game in HTML5/JavaScript canvas, and I wondering if porting the game with some HTML/JS to .EXE converter would allowed it to be posted on consoles?

I think it should be possible, since Downwell(though made with an entirely different language) is a .EXE file, and is available on Switch and Playstation.


texts: Problem with grid generation in Unity 5.1

texts:
Using Unity 5.1 and was following a tutorial for generating a grid for a Minesweeper-style game. Link to the tutorial for reference: http://gamedevelopment.tutsplus.com/tutorials/build-a-grid-based-puzzle-game-like-minesweeper-in-unity-setup--cms-21361

Tutorial is Unity 4, but I don't think it should matter.

Here's my code:

public GameObject tilePrefab;
public int numOfTiles = 10;
public float distanceBetweenTiles = 1f;

void Start () {
    CreateTiles();
}

void CreateTiles () {
    float xOffset = 0f;

    for (int tilesCreated = 0; tilesCreated < numOfTiles; tilesCreated++) {
        Vector3 positionVar = new Vector3(transform.position.x + xOffset, transform.position.y, transform.position.z);
        xOffset += distanceBetweenTiles;
        Instantiate(tilePrefab, positionVar, transform.rotation);
    }
}

Essentially, the problem is that when I coded the spacing algorithm, Unity decided to ignore the spacing of 1f, but instead do 10,000. No matter the number I substitute for "distanceBetweenTiles", Unity spaces the cubes by 10,000 points. I'm assuming it has to do with how Unity is handling the float numbers, but I'm not quite sure, considering the number I substitute doesn't seem to matter. I've included a screenshot of Unity running the script and the inspector view of the giant X position. Thanks so much in advance]1


texts: How to march tiles together like in Terraria?

texts:
I've been trying to get tile marching to work like in Terraria, and I got something to work. I don't think it's actually very good way of doing this, so I'm wondering what would be really the main way of doing this.

Here's a picture of what I want to accomplish:

As you can see, this really does the thing that I want, but it's so horrible looking and it'd be a pain to extend for different types of tiles.

Here is my code for this. I coded this as a test, so my full game would use tile classes etc.

for x, tile in enumerate(row):
    if tile:
        try:
            air = row[x + 1]
        except Exception:
            pass
        else:
            if not air:
                if not LEVEL[y - 1][x]:
                    tile = 3
                else:
                    tile = 6
        air = row[x - 1]
        if not air:
            if not LEVEL[y - 1][x]:
                if tile == 3:
                    tile = 5
                else:
                    tile = 4
            else:
                if tile == 6:
                    tile = 8
                else:
                    tile = 7
        LEVEL[y][x] = tile
for y, row in enumerate(LEVEL):
    for x, tile in enumerate(row):
        if LEVEL[y - 1][x] in (6, 3, 14):
            try:
            pos = LEVEL[y][x + 1]
        except Exception as e:
            print(e)
        else:
            if pos in (2, 3):
                LEVEL[y][x] = 11
    if LEVEL[y - 1][x] in (7, 4, 15):
        pos = LEVEL[y][x - 1]
        if pos in (2, 4):
            LEVEL[y][x] = 12
    if LEVEL[y - 1][x] in (5, 8):
        if LEVEL[y][x] == 1:
            LEVEL[y][x] = 13
    if LEVEL[y][x] == 6:
        if LEVEL[y][x - 1] in (2, 4):
            LEVEL[y][x] = 14
    if LEVEL[y][x] == 7:
        try:
            tile = LEVEL[y][x + 1]
        except Exception as e:
            print(e)
        if tile in (2, 3):
            LEVEL[y][x] = 15

The basic idea behind this is just to look for some air and dirt, and set the tiles image from those.

Basically then when I'm drawing this I just take the value at a coord and blit the corresponding image to the screen.

So how would I go about making this as readable and easily extendable as possible? Does anyone know how Terraria handles this?


texts:
Is there a way to "record" the display of a camera instead of rendering it on screen?

For example, if I want to stream a camera's frame block to an external application.


texts: How to abstract GLFW from my rendering library?

texts:
I would like to split my game engine in different libraries, so it is easier to maintain, however i have one problem: for example the window creation is handled by GLFW, so I encapsulated it into a class so it will be able to interact with the rest of my library. The problem is that I don't want to make the applications that use my library also depend on GLFW development headers, because otherwise when I pass user input to the application it must know about GLFW and it's data types and has to do something like this:

    //Application.cpp
    #include<mylibrary.h>

    int main()
    {
        myLibrary::window w("Title", 640, 480)
        myLibrary::event e;

        while(w.pollEvents(&e))
        {
            if(e.key == GLFW_KEY_ESCAPE) //Unnecessary GLFW dependancy
                w.close();
        }
    }

Because my header is like this:

    //mylibrary.h
    #include <glfw/glfw3.h>

    namespace myLibrary
    {
        class window
        {
        public:
            //Blah-blah-blah
        private:
            //Blah-blah-blah
            GLFWwindow* mWindow;
            //Blah-blah-blah
        };
    }

How should I go about abstracting GLFW from the application?

And I cannot use GLFW without wrapping it, because making it interact with the rest of my library ecosystem will look very ugly and out of place, and it would mean that the other libraries not only have to know about the rendering library, but also GLFW.

TL;DR: How can I hide GLFW from the user of my library?


texts: How can I disallow the changing of a parent?

texts:
I want to disable transform.SetParent(Transform) for a particular GameObject.

I am not sure where to start, so it is really difficult to show what I have tried.  Is this even possible?


texts:
I am using a Finite State Machine for my character who has the ability to change into various forms (Wolf, bird, ect).

The character changing to each state is not instantaneous and has a transition period to the next state. Most FSM i've seen set the next state instantaneously. My question is what should I do for the transitioning state? For example the "HumanState" is transitioning to the "WolfState" should I make another state class for each transition (Example: HumanState -> HumanToWolfState -> WolfState)? Or should I just have the state stay at the current state until the transition is done by using a coroutine and setting the state on completion?


texts: How to draw lines between user draggable points?

texts:
I want to create a triangle using three different points on the SurfaceView using OpenGL. Line indications between the points with one color and fill the triangle with different color. I want to pull those points from existing place to the user desired positions (where ever he wants) on the surface.

How can I do this?


texts: Do I need multiple perlin noise generators for different features in terrain generation?

texts:
I have a simple perlin noise algorithm in my 2d game, I feed it x and y location of a tile and get some value between 0 and 1. I then use a bunch of if-else statements to break these numbers into terrain types:

0 is water
0.5 and less is plain
0.6 and less is hill

Then there's features like forests, but in the current system a hill cannot have forest on it. I'm using only 1 perlin generator here, and my question is whether I need to have multiple perlin generators with random seeds to control elevation, vegetation and other terrain features?


texts: How could I get rid of these shared_ptr/weak_ptr in this entity-component architecture?

texts:
We've built an entity-component architecture that works ok for our needs, but it has something that bugs me a bit from a software engineering point of view.

We use std::shared_ptr and std::weak_ptr for the Components: the Entity owns the component through an std::shared_ptr, while the ComponentManager and other Components refer to the component through a non-owning std::weak_ptr.

The issue is that the components are not actually shared, and they should not be shared either. They're owned by a single entity. Having an std::shared_ptr there suggests that anyone can take a copy of the shared_ptr and own it too.

Here is a diagram of how the classes are organized:

Entity:

real owner of the components through shared_ptr
does not know which components it holds

ComponentManager:

we call update() on the ComponentManager, which in turn calls update() on every component it knows about
there is one instance per type of component; we've done it like this to have control over which components get updated first (e.g. CmpRigidBody updates the CmpMatrixTransform, and from which the CmpGfx is then updated)
unofficial owners of the components through weak_ptrs; it's "unofficial" because it's through them that the components are updated
weak_ptrs are stored in a vector
once the (single) shared_ptr goes out of scope (e.g. when the entity gets deleted), a custom deleter tells the ComponentManager to remove the weak_ptr from the vector (this also adds confusion to this architecture)

Component and derived:

holds the core of the information and performs the main operations of the component
can reference other components through weak_ptr (hooked up at initialization, for now)

I strongly believe in using the right tool for the job, and although this architecture works, I'm curious to see if there are alternatives that would remove the confusion introduced by the shared_ptrs.

Maybe this is pertinent:

The amount of entities and components is relatively low, so we won't gain much by making efforts to keep them close together (the rendering and the physics simulation are taking most of our frame time).
We use this approach because of the re-usability offered by the components and entities from project to project.
The project is single-threaded.
The action takes place in the Component, not in the ComponentManager (i.e. it's a entity-component architecture, not an entity-component-system archiecture), so the Component needs access to other Components if they still exist, and these can be removed at any time.

I could use a kind of handle system through the ComponentManager and query the appropriate one every time I need an access to a Component, but this adds a dependency... (Maybe that's the price to pay..?!)

Do I have other options?


texts: Unwanted left-right rotation in run animation imported from Mixamo

texts:
A humanoid run animation I downloaded from Mixamo is working fine on their site and in Blender.

When I import it into Unity it shows a strange movement: the full body is rotating left & right in a strange way when animation is running.

Here are my import settings for the animation:


texts:
I need a triangle picking algorithm, that is, I need to see if my mouse is over a triangle.
I've heard what color picking is, but it would pretty much just drop the performance twice (which is not what I want).

I use LWJGL java, and OpenGL 3.3.

If anyone can point me to a triangle picking algorithm then that would be awesome!

My best attempt was to do some transformations on the vertices and then check if it is within the center, it is limited and not what I exactly want.


texts: How to use the BillboardRenderer in Unity?

texts:
Since version 5 (?) Unity has a new component-type BillboardRenderer. Unfortunately the documentation is quite poor.

It can be added in the inspector by clicking on "Add Component -> Misceallaneous -> Billboard Renderer" but apparently it requires a Billboard Asset to do anything. There doesn't seem to be any way to create one from the Unity interface.

One of the few sentences from the equally poor documentation of BillboardAsset reads:

  imageCount    Number of pre-baked images that can be switched when the billboard is viewed from different angles.

My newest project will have sprite/polygon mix graphics, so a component which renders a billboard with a different sprite depending on the view angle is something I could really make use of. But there doesn't seem to be any method to add such images.

So I wondered if you could post an example how this component is used.


texts: Control animation using animator control class

texts:
I did a sample existing code to control animation using animation.I dragged and dropped a character into the scene then I added a Animator to it and added the animator controller.Below I have given the screen short of the animation

Then I have attached the following code to it

Animator animator;

int eatHash=Animator.StringToHash("ideal");

int stateHash=Animator.StringToHash("Base Layer.pickbothfork");

void Start () {
    animator = GetComponent<Animator>();
}

// Update is called once per frame
void Update () {
    //animator.SetBool ("isEat", true);
    float move = Input.GetAxis ("Vertical");
    animator.SetFloat ("Speed",move);

    AnimatorStateInfo stateinfo = animator.GetCurrentAnimatorStateInfo (0);
    if (Input.GetKeyDown(KeyCode.Space))
    {
        Debug.Log ("clicked spacebar");
        animator.SetTrigger(eatHash);
    }
}

The problem here is the above code is working,when I run the project the animation is getting played one after the another according to the state diagram.But when I click on the space bar the trigger function(jump animation ) is not working

if (Input.GetKeyDown(KeyCode.Space))
{
    Debug.Log ("clicked spacebar");
    animator.SetTrigger(eatHash);
}

Can anybody please help me finding solution for it


texts:
What design patterns can be used to create a rule / validation system for a game like chess (this is just a simple example, the actual game needs more difficult sets of rules)

I've read several questions on this site and haven't found a conclusive answer nor an answer pointing me in the right direction.

This system would require the following:

Every object that has rules applied to it should implement a specific
interface with a method that is the starting point for the validation
The rule should be applied in 2 steps: first, it needs to be
validated (can pawn A move to square D4), if true then execute
method A if false then execute method B
Every object can have multiple rules that need to be applied in a
specific sequence. When rule 1 is finished, rule 2 should then start to validate etc
Every separate rule (for example: can only move 1 square, can only move diagonally etc) must be in its own class and must be reusable and applicable on the objects that need rules.
Note this is going to be used in a multiplayer game on the backend
Note that every rule need multiple objects to test its validity, for
example, normally a pawn can move 1 square, now the next sqaure on
the gameboard is filled by a pawn of your opponent. Result: your pawn cannot move.
The pawn should include the other pawns positions, or the gameboard in its validation.

Another word for these rules would be behavioral limits.


texts:
I'm currently developing a PC game with the assistance of XNA and I'm integrating keyboard and gamepad control support. Up until now I've only supported gamepad control, and finding an elegant way to allow the player to choose one or the other is posing a complicated task to resolve.

I was thinking of creating a class that would sort of convert either input into a universal sort of data that the game could then use for the player's character and the rest of the game to interpret.

Then, I thought maybe it would be simpler to create a duplicate of my main character's class, except to accept keyboard input instead of the gamepad input.

Can anybody offer any insight?