texts: When entities don't draw themselves, who actually does?

texts:
There are countless questions here about whether entities should draw themselves or not. The answer is almost universally no, there should be a renderer. And I do see a point in having a single place where everything is rendered. Makes asset management easier and the code less convoluted.

However, I'm struggling to find a good approach to implement this in my 2D game. Currently, every entity is told to draw itself, and I pass the renderer object to it. Now, I want the renderer to draw each entity, but I don't want the renderer to actually know about entities, so I need a more generic class, e.g. RenderObject, and a way to construct render objects from entities.

One obvious approach would be to have a GetRenderObject() method on each entity. However, some of my entities actually draw multiple textures, relative to their position, so I'd probably need a GetRenderObjects() function instead.

But that wouldn't really remove any rendering logic from my entities. I'd still have to refer particular assets and their positions relative to the entity position in the render objects I create.

So my question is: Doesn't having a renderer mean that my entities don't have any drawing logic anymore? If so, who will generate these render objects? Does it even make sense to take the render objects detour?

And, bonus question: How can this work together with a UI system? I'd rather not have the renderer know about widgets and containers and such, so my hunch so far is to have widgets stick to drawing themselves.


texts:
I'm just starting with game development and some physics related to that. Basically I want to calculate a trajectory given an initial velocity and as well as an elevation / angle. So I wrote this code in Java (I left out some class related code and such):

int v0 = 30; // m/s
int angle = 60;
double dt = 0.5; // s

double vx = v0 * Math.cos(Math.PI / 180 * angle);
double vy = v0 * Math.sin(Math.PI / 180 * angle);

double posx = 1; // m
double posy = 1;  // m
double time = 0; // s

while(posy > 0)
{
   posx +=  vx * dt;
   posy += vy * dt;
   time += dt;

   // change speed in y
   vy -= 9.82 * dt; // gravity
}

This seems to work fine. However, is there a better way to do this? Also, is it possible to scale so that 5 meter (in calculation) corresponds to 1 m for the posx and posy variables?

Thanks in advance!


texts: How to draw things on top of objects drawn in OnRenderObject()?

texts:
I am using Unity, here is the method in question. So I know this method draws objects after the camera is done rendering the scene. I have not come across a way in Unity to draw these objects in a certain layer, rather than being the last thing to be drawn.

If it all possible, I am looking to do exactly that: have my custom shaped objects not be renderered last. The problem is that it draws over the UI as well as one other thing that it shouldn't draw over (the player). In case anybody ask I have to use custom UI because the game uses Kinect; basically sprites that detect when the player's hand is over them.

Here is a picture of part of my scene and the problem at hand:

In this example the custom object is a simple line (I cannot use Unity's line renderer for separate reasons).


texts: Game state management (Game, Menu, Titlescreen, etc)

texts:
Basically, in every single game I've made so far, I always have a variable like "current_state", which can be "game", "titlescreen", "gameoverscreen", etc.

And then on my Update function I have a huge:

if current_state == "game"
  game stuf
  ...
else if current_state == "titlescreen"
  ...

However, I don't feel like this is a professional/clean way of handling states. Any ideas on how to do this in a better way? Or is this the standard way?


texts: Slick2D ComponentListener added to MouseOverArea not responding to right mouse clicks

texts:
I am developing a UI using Slick2D and experimenting with MouseOverArea.  I have noticed that if I add a ComponentListener to my Button (which extends MouseOverArea) it only responds to left-clicks on my mouse, but not right-clicks.  The MouseOverArea itself responds to both.  If I call notifylisteners() in my Button subclass then ComponentListener does respond to right-clicks, but it gets called twice for left-clicks.

Does anyone have any idea why this is happening and how to fix it?  Code included below:

package slick2dbutton;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.AbstractComponent;
import org.newdawn.slick.gui.ComponentListener;
import org.newdawn.slick.gui.GUIContext;
import org.newdawn.slick.gui.MouseOverArea;

public class Slick2DButton extends BasicGame {

    Button button;

    public Slick2DButton(String title) {
        super(title);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        AppGameContainer game;
        try {
            game = new AppGameContainer(new Slick2DButton("Slick2DButton Test"));
            game.setMaximumLogicUpdateInterval(60);
            game.setDisplayMode(640, 480, false);
            game.setTargetFrameRate(60);
            game.setAlwaysRender(true);
            game.setVSync(true);
            game.setShowFPS(false);
            game.start();
        } catch (SlickException ex) {
            Logger.getLogger(Slick2DButton.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void init(GameContainer container) throws SlickException {
        button = new Button(container, new Image("res/bunsen burner #1.png"), 50, 50, new Slick2DButton.Listener());
        button.setMouseOverImage(new Image("res/bunsen burner #2.png"));
        button.inputStarted();
    }

    @Override
    public void update(GameContainer container, int delta) throws SlickException {
    }

    @Override
    public void render(GameContainer container, Graphics g) throws SlickException {
        button.render(container, g);
    }

    public class Listener implements ComponentListener {

        @Override
        public void componentActivated(AbstractComponent source) {
            System.out.println("Source: " + source);
        }
    }

    public class Button extends MouseOverArea {

        public Button(GUIContext container, Image im, int x, int y, ComponentListener listener) {
            super(container, im, x, y, listener);
        }

        @Override
        public void mousePressed(int button, int mx, int my) {
            super.mousePressed(button, mx, my);
//            this.notifyListeners();
            System.out.println("Button: " + button);
            System.out.println("");
        }
    }
}


texts:
How do I delete the parent game objects attached to a script? You can see my code as an example, which is only removing the script on a game object. I am using Unity 5.5.2f1.

void destroySpawnersAndItems ()
{
    //FIX: It's deleting the script and not the complete object.
    var spawners = FindObjectsOfType(typeof(spawnerItem));
    var items = FindObjectsOfType(typeof(itemFood));

    foreach (var spawner in spawners)
    {
        Destroy(spawner);
    }

    foreach (var item in items)
    {
        Destroy(item);
    }
}


texts: Is there a better way of determining direction to turn?

texts: You have an entity A that you want to turn towards another entity B.  One way to determine the direction to turn is to compute the cross-product of the direction vector of A with the vector from AB.  If the value of z is positive, then you turn right.  If the value of z is negative, you turn left.  Is this the only way of determining which way to turn?


texts: How can I texture a large terrain mesh in OpenGL?

texts:
I want to apply a texture to a large terrain mesh in my game. I think that it is just not acceptable to have a gigantic UV map spanning over 4096 x 4096 pixels.

What's a better way to apply a texture to it?


texts: Can you access Kinect motion sensing from XNA?

texts: As of 2010 with the release of XNA 4.0, if I buy an Xbox 360 with Kinect will I be able to access its motion sensing data with the XNA game I'm developing? Or is this only restricted to C++ developers with a devkit?


texts:
I'm developing an RPG/roguelike-style game. Instead of having maps like:

.........
.........
....@....
...h.....

Oh look, a dwarf.

I was having solid background tiles, So sort of a tile based RPG without drawn tiles. I like the idea of having ascii tiles for creatures and things. It saves a lot of artist time. I can change the tiles so I get some kind of symbol slightly more...related? But better than having 4 directions for each separate thing.

If I did this in white, and had a snow area, you wouldn't be able to see. So make it black. As soon as you reach a dark place, you're again stuck as to where your character is. Is there an algorithm or something that can say 'this is too dark between the tile and the NPC' and change the colour to something seeable, but not going to a bright cyan from a pale pink or whatever?


texts: (Unity) Values set in Start() will be reset?

texts:
This is my GameController GameObject in the Inspector (Ignore Suns and Player). Note that the GameController script has GameSpawner as a SerializeField.

And my script for GameController below.

public class GameController : MonoBehaviour
{
    public GameObject sunParent;
    public GameObject playerPrefab;

    [SerializeField]
    GameObject sunSpawnerObject;

    SunSpawner sunSpawner;

    void Start()
    {
        sunSpawner = sunSpawnerObject.GetComponent<SunSpawner>();
    }

    // this is only for testing
    void LateUpdate()
    {
        SpawnSunAtY(sunParent, -3.5f);
        SpawnSunAtY(sunParent, 0f);
        SpawnSunAtY(sunParent, 3.5f);
    }

    void SpawnSunAtY(GameObject parent, float y)
    {
        sunSpawner.SpawnSunAtY(parent, y);
    }

}

When the Scene starts, it should get the SunSpawner script from sunSpawnerObject. Then what is SunSpawner? See below.

This GameObject(prefab) has SunSpawner script as a component.
And below the script for SunSpawner. (where my question begins)

public class SunSpawner : MonoBehaviour
{
    const float SUN_MIN_SIZE_FACTOR = 0.05f;
    const float SUN_MAX_SIZE_FACTOR = 0.3f;

    [SerializeField]
    GameObject sunPrefab;

    float playerRawRadius;
    float sunRawRadius;

    void Start()
    {
        // these lines work just fine
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        playerRawRadius = player.GetComponent<Renderer>().bounds.size.x / 2f;
        sunRawRadius = sunPrefab.GetComponent<Renderer>().bounds.size.x / 2f;
    }

    public void SpawnSunAtY(GameObject parent, float y)
    {
        float sizeFactor = Random.Range(SUN_MIN_SIZE_FACTOR, SUN_MAX_SIZE_FACTOR);

        Vector3 position = new Vector3(GetRandomXPos(sizeFactor), y, 0);
        GameObject sun = Instantiate(sunPrefab, position, Quaternion.identity);
        sun.transform.localScale *= sizeFactor;
        sun.transform.parent = parent.transform;
    }

    float GetRandomXPos(float sizeFactor)
    {
        float offset = Camera.main.WorldToScreenPoint(new Vector3(GetHorizontalOffsetFromScreen(sizeFactor), 0, 0)).x;
        float screenRightBoundWorldPoint = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0)).x;
        float screenLeftBoundWorldPoint = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x;

        return Camera.main.ScreenToWorldPoint(new Vector2(Random.Range(offset, screenRightBoundWorldPoint - offset), 0)).x;
    }

    float GetHorizontalOffsetFromScreen(float sizeFactor)
    {
        float horizontalMargin = 0.1f; //TODO temporary value
        float playerRadius = playerRawRadius;  // *look here (1)*
        float distancePlayerToSun = 0.5f; //TODO temporary value
        float randomRadius = GetRandomRadius(sizeFactor);

        return horizontalMargin + (2f * playerRadius) + distancePlayerToSun + randomRadius;
    }

    float GetRandomRadius(float sizeFactor)
    {
        // *look here (2)*
        print("sunRawRadius: " + sunRawRadius + ", sizeFactor: " + sizeFactor + ", scaledRadius: " + (sunRawRadius * sizeFactor));
        return sunRawRadius * sizeFactor;
    }
}

Call stack:

GameController.LateUpdate() -> SunSpawner.SpawnSunAtY(parent, y) -> SunSpawner.GetRandomXPos(sizeFactor) -> GetRandomXPos(sizeFactor) -> GetHorizontalOffsetFromScreen(float sizeFactor) -> GetRandomRadius(sizeFactor)

Look here (1):

in SunSpawner.Start(), all values are initialized properly, I can see values in the debugger or log. However, when I get to GetHorizontalOffsetFromScreen(..), I see playerRawRadius is now zero.

Look here (2):

Same thing. sunRawRadius is 0, but sizeFactor argument is properly passed down the call stack.

Question: Why is it doing this?

Follow up: How do I properly instantiate prefabs through game object chains and use them?

Big thank you in advance.


texts: Changing the texture filtering methodology within the same SpriteBatch Begin/End pair

texts:
How would I go about using changing the texture filtering method being used within the same SpriteBatch Begin/End pairing?

I have this code so far.

spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);

spriteBatch.Draw(PixelArtTexture, new Vector2(x, y), null, Color.White, 0f, Vector2.Zero, new Vector2(8, 8), SpriteEffects.None, 0f);

spriteBatch.End ();

This draws a pixel art texture using point filtering, however I want to draw another texture using linear filtering, so how would I do that?


texts: Collision detection in pong style multiplayer network game

texts:
I've recently implemented an authoritative server (node.js with socket.io) for a multiplayer pong game.

I've looked at client side prediction and fixing timesteps and starting to grasp the notion of simulated identical physics across server and clients.

However, I still can't quite figure out the approach to how to detect when the paddle truly hits the ball. The paddles can be controlled by touch or mouse movement which can be an almost instantaneous teleport to the location of the ball.

How can I determine if the paddle was in the right place at the right time taking into account the round trip time?


texts: How should I control leveling up in a knowledge/skill testing game?

texts:
I have developed a game that  tests the knowledge and skills in a series of short quiz-like games.
Players have to move from Level 1 to Level 16 (with Level 4, 8 and 12 as major milestones~BANDS). The Difficulty level of game/questions increases at each level.
The level progression is currently based on 'POINTS'. Points in turn are based on Correct responses, faster responses, Wins, Completion etc.
Points continue to increase for a user irrespective of Win / Loss (the duration of completing the levels varies)
The challenge I foresee is 'every user can progress to Level 16' if he keeps on playing the game long enough (irrespective of whether he has acquired the skill/knowledge for the next level).

I am looking for a simple to understand progression rule(s) that would make lower-skilled players remain longer in that BAND before progressing to the next level and BAND. What are some best practices in Level progression that I can refer to for overcoming this issue.

Thanks,


texts: player keeps on firing (Javascript + Canvas)

texts:
I'm brand new to game development (with Javascript)... I'm pretty sure my question is very simple, but I have a hard time to figure out myself... I'm starting at the very beginning, so this is pretty simplistic.

This is my whole code in javascript:

var fire = false;
function keyUp(evt) {
  switch (evt.keyCode) {
     case SPACE:
        fire = false;
     break;
     ...
  }
}
function keyDown(evt) {
  switch (evt.keyCode) {
     case SPACE:
        fire = true;
     break;
     ...
  }
}
function update() {
    ...
    if (fire) {
        playerHasShot = true;
        shot.x = player.x + player.w;
        shot.y = player.y + (player.h / 2);
        shot.vx += 2;
    }
    if (!fire) {
        playerHasShot = false;
    }
   ...
    shot.x += shot.vx;
   ...
    //Bullet
    if (playerHasShot) {
        playerHasShot = false;
    }
    if (!playerHasShot) {
        playerHasShot = false;
    }
    ...
    if (shot.vx > 4) {
        shot.vx = 4;
    }
    ...
    if (shot.x > canvas.width) {
        shot.x = player.x + player.w;
        shot.y = player.y + (player.h / 2);
        playerHasShot = false;
    }
    ...
    render();
    renderShot();
}

I hit the spacebar once, and that guy can't stop shooting... Would any of you mind telling me how to stop him, please ? I'm sure I'm close, but there's something I'm missing somewhere.... Thanks! :)


texts:
here's what I'm trying to do:
One house, with 3 rooms, a window in two rooms, doors in the front and back of the house and into each room (the back door has to be through one of the rooms). I've added a picture as an example
I'm using JOGL 2.0, in eclipse.

Clarification: my question is how do I code it in java using jogl?

This is what I have so far:

    glBegin(GL_QUADS)
    /* Floor */
    glVertex3f(-1,-1,-1);
    glVertex3f(1,-1,-1);
    glVertex3f(1,-1,1);
    glVertex3f(-1,-1,1);
    /* Ceiling */
    glVertex3f(-1,1,-1);
    glVertex3f(1,1,-1);
    glVertex3f(1,1,1);
    glVertex3f(-1,1,1);
    /* Walls */
    glVertex3f(-1,-1,1);
    glVertex3f(1,-1,1);
    glVertex3f(1,1,1);
    glVertex3f(-1,1,1);

    glVertex3f(-1,-1,-1);
    glVertex3f(1,-1,-1);
    glVertex3f(1,1,-1);
    glVertex3f(-1,1,-1);

    glVertex3f(1,1,1);
    glVertex3f(1,-1,1);
    glVertex3f(1,-1,-1);
    glVertex3f(1,1,-1);

    glVertex3f(-1,1,1);
    glVertex3f(-1,-1,1);
    glVertex3f(-1,-1,-1);
    glVertex3f(-1,1,-1);
    glEnd();


texts: Tile Based Collision With Moving Platforms

texts:
I am developing a platformer using pure HTML/Javascript. After remaking my collision detection system with help from HTML5 platformer collision detection problem, I realized my moving platform detection would not work because my moving platforms (only a vertically moving wall to block the player, at the moment) are not rendered using the tilemap. Currently, I am manually pushing it to the array of obstacles in the level. Here is my collision detection code:

function collisionDetection() {
    player.onLadder = false;
    var bottomY = player.y + player.height;

    var bottomCol = collisionCheck(player.x + (player.width / 4), bottomY) || collisionCheck(player.x + (player.width / 2), bottomY)
        || collisionCheck(player.x + ((3 * player.width) / 4), bottomY);
    var topCol = collisionCheck(player.x + (player.width / 4), player.y) || collisionCheck(player.x + (player.width / 2), player.y);
    var leftCol = collisionCheck(player.x, player.y) || collisionCheck(player.x, player.y + (player.height / 2));
    var rightCol = collisionCheck(player.x + player.width, player.y) || collisionCheck(player.x + player.width, player.y + (player.height / 2));

    if (bottomCol) {
        player.y -= (bottomY % 32);
        player.onGround = true;
        player.jumping = false;
    }

    if (topCol) {
        player.velY *= -1;
    }

    if (leftCol && !topCol) {
        player.x -= ((player.x + player.width) % 32) - player.width;
        player.jumping = false;
    }

    if (rightCol && !topCol) {
        player.x -= ((player.x + player.width) % 32);
        player.jumping = false;
    }

    if (!bottomCol && !leftCol && !rightCol) {
        player.jumping = true;
        player.onGround = false;
    }
}

function collisionCheck(x, y) {
    var tile = maps[level][y >> 5][x >> 5];
    //collectibles like coins
    if (tile == 14 || tile == 15 || tile == 16) {
        collectiblesCheck(x, y, tile);
        return false;
    //0 is an empty space in the map
    } else if (tile != 0) {
        return true;
    }
}

Essentially, the code finds the closest tile to the player and does necessary adjustments based on where the collision occurs. Since the moving wall is not a tile, I am unsure of the best way to deal with collision detection. I could use my old collision detection method, which traversed through the obstacle array instead of the map tiles, but I feel that that would be too inefficient.

If any of the code needs explaining, please feel free to ask. Thank you.


texts:
I am currently experimenting with creating a turn based game using Unity and am trying to come up with a sensible architecture for structuring my game systems.

So far I have decided to base everything around Game states. A game state represents a sort of "mode" of the gameplay, for instance "Select unit state" or "Game over state". A global game state manager holds a stack of these game states and can be called with pop (remove top game state), push (push the provided game state onto the stack) and replace all (pop all existing game states and push provided game state). Update is called on the top most element of the stack every logic frame.

I also have Entities which exist on the scene and represent stuff like as game units, terrain, projectiles etc. These are standard gameObjects with behaviors, unity lifecycle etc.

Finally there are a bunch of services which provide methods to handle stuff like menus and camera.

The idea is that the game states handle the "logic" of the game such as player input, transitions between game states, calling the services and controlling/modifying entities.

I also use events to facilitate the communication between state, entities and systems to avoid coupling too much. These events are stuff like "Unit destroyed" and "Objective complete" which are listened to usually by entities, calls to move the camera, create entities and such are still called normally using the relevant service methods.

Whilst this system works in theory I am having some issues with the interactions between events and game state logic. Consider the following:

Update of performActionState:

void update() {
  // Do something.
  Messanger.fireEvent(EventType.ACTION_COMPLETE);
  GameSystemManager.pushState(new NewTurnState());
}

Objectives system listening for action complete:

void handleActionComplete() {
  if (checkObjectivesAllComplete()) {
    GameSystemManager.pushState(new GameCompleteState());
  }
}

What I want to happen is for the objectives system to push a game complete state and finish the game. What actually happens is that the handle action complete pushes the game complete state, the rest of the perform action state update runs and a new turn state is pushed.

The above example might be a bit simplistic but I see this as an underlying issue with my architecture. Most events would be fired due to a change in the state of the scene or completion of something, for instance a unit being destroyed or a unit entering a trigger area. The probability of the game logic needing to change state from the game states is quite high in these cases usually.

I could easily fix the above sample in a number of ways, for instance I could move the checking of objectives into the start of NewGameState and invoke a pushGameState there instead to end the game but all the ways I can think of at the moment seem like hacks which will greatly increase coupling (New game state doesn't need to care about objectives) and code spaghetti.

Any advice for ways I could potentially architecture around issues like this?


texts: Best practices for labeling game versions?

texts:
Does anyone know if there's a best practice for labeling game versions.

I'm not sure if there's a standard name for it other than versioning but what I mean is basically:

1.0
1.1
1.2
1.3.1 beta


texts: C++, OpenGL: Building a polyhedron via geometry shader

texts:
I'm stuck with geometry shaders in OpenGL - c++ programming. I want to create simple cube by repeating 6 times drawing one rotated wall. Here is my vertex shader (everyting has #version 330 core in preamble):

uniform mat4 MVP;
uniform mat4 ROT;
layout(location=0) in vec3 vertPos;
void main(){
    vec4 pos=(MVP*ROT*vec4(vertPos,1.5));
    gl_Position=pos;
}

Now geometry shader:

layout (triangles) in;
layout (triangle_strip, max_vertices = 6) out;
out vec4 pos;
void main(void)
{
    for (int i = 0; i < 3; i++)
    {
        vec4 offset=vec4(i/2.,0,0,0);
        gl_Position = gl_in[i].gl_Position+offset;
        EmitVertex();
    }
    EndPrimitive();
}

And now fragment shader:

uniform mat4 MVP;
in vec4 pos;
out vec3 color;
void main(){
    vec3 light=(MVP*vec4(0,0,0,1)).xyz;
    vec3 dd=pos.xyz-light;
    float cosTheta=length(dd)*length(dd);
    color=vec3(1,0,0);
}

Well, there is some junk, I wanted also put shading into my cube, but I've got a problem with sending coordinates. The main problem is - here I get my scaled square (by MVP matrix), I can even rotate it with basic interface (ROT matrix), but when I uncomment my "+offset" line I get some mess. What should I do to make clean 6-times repeating?


texts: How to detect the device type in UnrealScript?

texts:
How can I recognize if the player device is an iPad or an iPhone?

Now I can do it by checking the viewport size. But I think is just a tricky way, is there any other, more standard way?


texts: Best way to read expandable voxel world (hashmap) such as in Minecraft

texts:
I'm building a 3D multiplayer Roguelike-style engine (tile and turn-based) and I'd like to make the worlds virtually "infinite", similar to what you would see in Minecraft.

I'm storing data in a manner I'm assuming to be pretty similar to Minecraft based on what I've read so far. Chunks of 16x16x16, stored in arrays that are X amount high based on world height. These arrays are stored in a hashmap indexed as integers based on a z-order / morton curve implementation (to flatten them from 2d for easier storage.)

Everything is working well so far, but I've been coding everything assuming the active world will all fit into one square (based on view distance or something along those lines) instead of multiple areas (difference illustrated here).

But once I start assuming different areas will be loaded and active in the world, it brings a huge performance issue: in order to check individual cubes I'd have to see if it's parent chunk is active and loaded in order to avoid some kind of null pointer exception.

Aside from trying to somehow do pathfinding / world interaction in batches within individual chunks (which would be really hard to think around and I'm trying to just grab individual cubes from the "world" object that handles navigating the hash map) I can't think of any way around the issue except doing a hashMap.containsKey(int) for every single world read operation. So, in other words, if 8 players are on the server in entirely different active areas in the world, every block read would require checking if the Morton Code of the chunk the requested block is in falls into the currently loaded area of Players * Active Area, so 8*(8*8) individual chunks in this example.

So I'm curious if my Hashmap-based setup is incorrect for solving this problem, or if there is any other way around this issue.


texts: Application.OpenURL in Unity works in inspector (PC) but not in Android

texts:
I'm using unity and I've got some simple code that should work but doesn't for some reason and I'm stuck. Basically I am just trying to open up a website through a button click "On Click ()" in an application meant for android but it does not work. The code goes as follows.

public string url;

public void Website()
{
    Application.OpenURL(url);
}

public void Website2(string diffURL)
{
    Application.OpenURL(diffURL);
}

public void Website3()
{
    Application.OpenURL("http://www.google.com/");
}

As you can see I have three different variations of the same "Application.OpenURL" testing on three different buttons and all three do not work. Some more information:

I have paid close attention to format the websites properly with
quotation marks and "http://"
I have already set the "Internet Access" to "require" in the player
settings,
and interestingly enough, they work in the game window when testing,
it is only when I upload the apk to my android device that it does
not work anymore
.

The buttons register I am pressing them as evident by the slight darkening of the button press when I press on my android device but nothing happens. I have seen this question asked around but no solution to my issue has been found. Are any other build settings wrong? Any other thing I should change in Unity? API level or what?(currently 19 on min and highest installed on target)

Is there some settings I should change on my android device to allow this to happen? Because as stated earlier it works when testing through the game window on unity but not on android.

(The function "Website3()" begun to work when I rebuilt the app. No changes were made. "Website1()" and "Website2()" however still do not work on android and they work perfectly fine on unity game window.)


texts: Publish game as pay-what-you-want on Steam

texts: Is it possible to publish a game on Steam as pay-what-you-want? Something in the likes of the Humble Bundle. If it's not natively supported by Steam, would it be fine (as in, not violating any contracts or agreements) to have the game published as free (or at a very low cost) and include a link to a page where you, if you so wish, could donate a sum of money?


texts: Skyrim:Papyrus Possible Conflict Error [18+?]

texts:
I am working with a friend of mine to create a mod that relies on a mod called Devious devices, which would allow BDSM be utilized in Skyrim's combat by allowing the assailants to have special weapons which, when power attacking, allow for the player to be slowly bound with different pre-selected devices which inhibit the player until they are completely bound and helpless. We are still stuck on phase one of getting the code itself to fire off before we work more fully on the aesthetics, but the .xml files does not work for some reason and we need help. We believe the code compiles correctly, but when the script is called on

        Armor toremove = akTarget.GetWornForm(0x00000001) as Armor
        akTarget.UnequipItem(toremove)
    EndIf

is the current block that has been singled out as possibly causing the issue as it has not fired correctly. The main goal here is to have a function which unequips the item the target is currently wearing then replace it with another item provided. Right now we are working on the force unequip part.

I am happy to give more information and we are using the mod Devious Devices with all prerequisite mods installed and utilized for the testing environment. Please help us help you help us find a way to have a kinkier skyrim


texts: How to add a flash light to a particle explosion

texts:
I've an explosion effect using particle system.

Explosion occur on air, so I want to add a "flash" light effect when explosion occur (that light sky and terrain ).

Can you suggest me best way to obtain ?

Thanks


texts: Find a line that connects the outer most points in a set of points

texts:
Does anyone know an efficient algorithm to find the edge of a point cloud? Hopefully the picture in the link can illustrate what I mean. It's a plus if the algorithm can handle point clouds that are distinctly separated in space. The algorithm only needs to work in 2D.

Many thanks!!

http://uploadpic.org/storage/2011/4n68m1OYLSYIGt8vfuJrK1LnA.png


texts: Do UDK mutators only apply on local games?

texts:
I have developed a pretty simple mutator. It works exactly as intended on a local game against bots, but it doesn't work (nor do any of the stock mutators) on a listen server.

Is this to be expected of UDK (May Beta Release by the way)?


texts: Proper way to use a RenderTarget2D to draw multiple textures?

texts:
In the process of trying to resolve a split screen issue, I've been trying to use a RenderTarget2D to draw a portion of my scene to a Texture2D, and then again to another Texture2D, but the end result of both Texture2D's is coming out the same. Can anybody tell me what I'm doing wrong?

Texture2D camera1Render;
Texture2D camera2Render;

                GraphicsDevice.SetRenderTarget(RenderTarget);
                GraphicsDevice.Clear(Color.Transparent);

                map.Draw(mapDisplayDevice, Camera1, new Location(0, 0), false);

                camera1Render = RenderTarget;

                GraphicsDevice.Clear(Color.Transparent);

                map.Draw(mapDisplayDevice, Camera2, new Location(0, 0), false);

                camera2Render = RenderTarget;

                SetRenderTarget(null);


texts:
How could I achieve the animated Combo bar effect used in Ski Safari / Ski Safari: Adventure time? Preferably with Unity 4.6 UI. General explanations also welcome!

Links to videos showing the wanted effect:
https://www.youtube.com/watch?v=CnfCkqiM890#t=4m46s
and
https://www.youtube.com/watch?v=aqj61liRJ74#t=7m00s


texts:
These hands are in a single prefab. I want to split this into two so that I can make bones for each of them separately and use them with leap motion.

How can make each of these hands as a single prefab? Also, I'm using Unity 2018.


texts:
Am working on the controls and camera movement for my character.  What I am trying to do is have the character head be able to rotate left and right and then when the head is rotated a certain amount, the whole character rotates around.  I have kinda of done it, the head can move smoothly, but it stutters when it starts rotating everything.

Hopefully it is visible in this GIF.

You may be able to see that the head does rotate smoothly, but when the body starts rotating, it stutters.

Here is the code that is in LateUpdate that handles all the rotations.

this.current_rotation = Quaternion.Lerp(this.current_rotation, Quaternion.Euler(new Vector3(this.pitch, this.yaw, 0)), this.mouse_sensitivity * Time.deltaTime);

this.cam.transform.rotation = this.current_rotation;
this.head.transform.rotation = this.current_rotation;

if(this.head.transform.localRotation.y > 0.3 || this.head.transform.localRotation.y < -0.3){
    Quaternion from = Quaternion.Euler(0, this.player.transform.eulerAngles.y, 0);
    Quaternion to = Quaternion.Euler(0, this.current_rotation.eulerAngles.y, 0);

    Quaternion q =  Quaternion.Lerp(from, to, this.mouse_sensitivity * Time.deltaTime);
    this.player.transform.rotation = q;
}


texts: LibGdx - How can I correctly handle tile transitions / connected textures?

texts:
So I am making a tiled game and I need to connect textures correctly based on whats next to it.

With tiles that had connection really close to the edge of the tile I could just use the 4 bit meathod ie:

x 1 x
8 x 2
x 4 x

But for tiles with more detail I need to have corners too. I have seen people use the 8 bit meathod ie:

1   2  4
128 x  8
64  32 16

But really I can only see 48 different tile combos.

Is there a way I can separate corners and u d l r. Something like this:

x 1 x  8 x 1
8 x 2  x x x
x 4 x  4 x 2

Or is there a better way all together to do this.

This is what I have tried so far but this only uses 32/48 tiles and doesn't work for special corner cases.

public class RockTile extends Tile {

int y;

public RockTile(int id) {
    super(id);
    y = 7;
}

public TextureRegion getTexture(Level level, int xLoc, int yLoc){

    int u = (level.getTile(xLoc, yLoc + 1) != this) ? 1 : 0;
    int r = (level.getTile(xLoc + 1, yLoc) != this) ? 2 : 0;
    int d = (level.getTile(xLoc, yLoc - 1) != this) ? 4 : 0;
    int l = (level.getTile(xLoc - 1, yLoc) != this) ? 8 : 0;

    int bit = u + r + d + l;

    int ur = (level.getTile(xLoc + 1, yLoc + 1) != this) ? 1 : 0;
    int dr = (level.getTile(xLoc + 1, yLoc - 1) != this) ? 2 : 0;
    int dl = (level.getTile(xLoc - 1, yLoc - 1) != this) ? 4 : 0;
    int ul = (level.getTile(xLoc - 1, yLoc + 1) != this) ? 8 : 0;
    int corner = ul + ur + dl + dr;

    if (bit == 0) {
        if (corner != 0)
            return Game.splitTiles[y + 1][corner];
        else
            return Game.splitTiles[y][bit];

    } else {
        if (corner != 0)
            if (dl > 0 && l == 0 && d == 0)
                return Game.splitTiles[y + 2][bit];
            else
                return Game.splitTiles[y][bit];

        else
            return Game.splitTiles[y + 2][bit];
    }

}

}

If you need anything else let me know.

EDIT: Side question because I've seemed to have stumped you guys. If I decided to use the 8 bit method what would be the best and fastest way to make a lookup table for that.


texts: How can I clear explosions in my function?

texts:
Hi I have a function to place bombs, and a for loop that places explosions on the tiles where possible.

My problem is that I can't remove the explosions after a while. I've tried everything I can come up with so now I turn here as a last resort.

The function looks like this:

function Bomb(){
var placebomb = false;
    if(placeBomb && player.bombs != 0){
        map[player.Y][player.X].object = 2;
        var bombX = player.X;
        var bombY = player.Y;
        placeBomb = false;
        player.bombs--;
        setTimeout(explode, 3000);
    }
    function explode(){
    var explodeNorth = true;
    var explodeEast = true;
    var explodeSouth = true;
    var explodeWest = true;

    map[bombY][bombX].explosion = 1;
    delete map[bombY][bombX].object;

    for(i=0;i<=player.bombRadius;i++){
        if(explodeNorth && map[bombY-i][bombX]){
            if(!map[bombY-i][bombX].wall){
                if(!map[bombY-i][bombX].object){
                    map[bombY-i][bombX].explosion = 1;
                }
                else
                    var explodeNorth = false;
                    delete map[bombY-i][bombX].object;
                    map[bombY-i][bombX].explosion = 1;
            }
            else
                var explodeNorth = false;
        }

        if(explodeEast && map[bombY][bombX+i]){
            if(!map[bombY][bombX+i].wall){
                if(!map[bombY][bombX+i].object){
                    map[bombY][bombX+i].explosion = 1;
                }
                else
                    var explodeEast = false;
                    delete map[bombY][bombX+i].object;
                    map[bombY][bombX+i].explosion = 1;
            }
            else
                var explodeEast = false;
        }

        if(explodeSouth && map[bombY+i][bombX]){
            if(!map[bombY+i][bombX].wall){
                if(!map[bombY+i][bombX].object){
                    map[bombY+i][bombX].explosion = 1;
                }
                else
                    var explodeSouth = false;
                    delete map[bombY+i][bombX].object;
                    map[bombY+i][bombX].explosion = 1;
            }
            else
                var explodeSouth = false;
        }

        if(explodeWest && map[bombY][bombX-i]){
            if(!map[bombY][bombX-i].wall){
                if(!map[bombY][bombX-i].object){
                    map[bombY][bombX-i].explosion = 1;
                }
                else
                    var explodeWest = false;
                    delete map[bombY][bombX-i].object;
                    map[bombY][bombX-i].explosion = 1;

            }
            else
                var explodeWest = false;
        }

    }
    player.bombs++;
    }
}

If anyone can think of a good way to remove the explosion after a delay please help.


texts: Using textureGrad for anisotropic integration approximation

texts:
I'm trying to develop a real time rendering method using real time acquired envmap (cubemap) for lightning.

This implies that my envmap can change as often as every frame and I therefore cannot use any method base on precomputation of the envmap (such as convolution with BRDF...)

So far my method worked well with Phong BRDF. For specular contribution I direclty read the value in my sampleCube and I use mipmap levels + linear filter for simulating the roughtness of the material considered:

int size                = textureSize(envmap, 0).x;
float specular_level    = log2(size * sqrt(3.0)) - 0.5 * log2(ns + 1);
vec3 env_specular       = ks * specular_color * textureLod(envmap, l_g, specular_level);

From this method I would like to upgrade to a microfacet based BRDF. I already have algorithm for evaluating the shape (including anisotropic direction) of the reflection but I cannot manage to read the values I want in my sampleCube.

I believe I have to use

textureGrad(envmap, l_g, X, Y);

with l_g being the reflection direction in global space but I cannot manage to find which values to give to X and Y in order to correctly specify the area I want to consider.

What value should I give to X and Y in orther for

textureGrad(envmap, l_g, X, Y);

to give the same result as

textureLod(envmap, l_g, specular_level);


texts: What's the economical design difference for a global auction house or seperate auction traders?

texts:
I'm playing The Elder Scrolls: Tamriel Unlimited and there we have local auction houses. (Thy don't have auctions, but I keep the term to not get confused in the following text.)

I can see the advantage that guilds (who own these AHs) can set up their own little economy, which is a nice feature.

On the other side I always have to check several guild traders to see which one offers my searched item for the lowest price.

On the forums, people are discussing heavily whether a global auction house should be introduced or not. This may have pros and cons, too, but I'm not too involved in this game design to really set up a mind for that.

Backers argument that an global AH leads to a more regulated market, easier to use and a seller will reach a broader audience (reads: When you put in an item, you can be sure that there may be a buyer.)

On the other hand critics say that this will make only really useful items get a massive increased price and common used items will drop their prices to their normal selling price.

But are these concerns really true? Would the introduction of a global AH really have such a big impact on the game's economy? And if yes, will they more tend to even the prices or really make most of the items useless for selling?

You could also ask vice-versa: If a game already has global AH, what would the impact be if they replaced it with local auction houses?

What is the difference for the game's and players' economy if you introduce a global or local auction house system?

For clarification: I do ask this for the matter of The Elder Scrolls: Tamriel Unlimited. But you can also subject this to other games. (This should be more a theoretical question for a developer's decision.)


texts:
I have an object that I am trying to export from Maya 3D to CryEngine3. In Maya the object appears fine but when I export it and place it in-game there are two problems.

1) The roof material seems to dissapear and is just a white surface which reads the standard "replace me" when you walk on it (it's still physicallised as default) and although the outside of the building appears fine (again its a solid object) the inside is "transparent" and you can see through the walls.

(after I render the default phongs)

After the materials are applied (notice the "inside" looks solid)

in-game the external walls are solid with the material. However the roof turns white and the inside appears "transparent" yet is still solid and can not be walked through.

If anyone has had this problem and found a solution, or can point me in the right direction I would be grateful for the input.


texts:
At scale for multi-users, what is the proper way to implement timer updates?

I'm making a game where Users have buildings to upgrade which involve timers (Yes I know there are plenty of questions related to front-end: back-end this is not the same)

Every building exists in a table, with a completed field for a timestamp when we level up a building. I'm curious what the most common methods are to update the database when the timer runs out.

Many articles on stack exchange talk about setting up Cron jobs or having a game loop to poll against all stored timers. Still, I don't see those solutions scaling in a game with ~1000+ users nor useful in a browser-based Nodejs game relying on event updates over a game loop.

One solution I thought looked interesting was using RabbitMQ timed queues, so AMQP pushes a MySQL update at the scheduled time, but it sort of feels like a roundabout 'hack' of solving the problem compared to a more traditional method.


texts: How can I create a dice toss that results in a specific value?

texts:
I am trying to create a 3D dice for a game. Normal dice has been created by setting cube for dice with Rigidbody and apply force to throw a dice.

Now the problem is, the user wants to give a value 1 - 6 in the text box then they will press the roll button. The dice have to rotate and need to show the dice value as the user enters in the text field once it stops rolling.

For example:

In the Input box the value entered as 5,
Now the dice want to roll on the table and show the value as 5.

Anyone, please help me to solve this

Thanks in Advance


texts: What does it mean to develop a VR game from the ground up?

texts:
Some virtual reality games are advertised as being created from the ground up for virtual reality. What does this mean exactly?
What are some of the differences between developing a 3d pc game and a vr game?


texts: How can I make car respawn with temporary invulnerability i.e. no collisions?

texts:
I'm using Unity's standard assets scripts to move my car, but the camera just follows the road.

At certain moments when the car misses or overturns the player can press 'R' to reposition the car in the middle of the road in the position where I miss or turn over.

When the car respawns, it should not collide with other cars in the race, for a few seconds. After those few seconds everything returns to normal.

I thought about using layers, but I did not find how to modify the "Layer Collision Matrix" dynamically from a script. How do I do that?


texts: Irrlicht Code::Blocks project fails to build on Linux machine

texts:
After downloading the latest Irrlicht version (1.8.4) and setting it to compile for Linux machines, I decided to try it out in Code::Blocks IDE. The build failed.

-------------- Build: Debug in Demo (compiler: GNU GCC Compiler)---------------

g++ -Wall -g -I/home/marino/irrlicht-1.8.4/include -c /home/marino/Codeblock/Irrlicht/Chrono/Demo/main.cpp -o obj/Debug/main.o
/home/marino/Codeblock/Irrlicht/Chrono/Demo/main.cpp: In function ‘int main(int, char**)’:
/home/marino/Codeblock/Irrlicht/Chrono/Demo/main.cpp:70:36: error: invalid initialization of reference of type ‘const irr::core::dimension2d<unsigned int>&’ from expression of type ‘irr::core::dimension2d<int>’
         createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/marino/Codeblock/Irrlicht/Chrono/Demo/main.cpp:10:0:
/home/marino/irrlicht-1.8.4/include/irrlicht.h:324:54: note: in passing argument 2 of ‘irr::IrrlichtDevice* irr::createDevice(irr::video::E_DRIVER_TYPE, const irr::core::dimension2d<unsigned int>&, irr::u32, bool, bool, bool, irr::IEventReceiver*)’
  extern "C" IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(
                                                      ^~~~~~~~~~~~
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

This is the line #70 of main.cpp file.

/*
    The most important function of the engine is the 'createDevice'
    function. The Irrlicht Device can be created with it, which is the
    root object for doing everything with the engine.
    createDevice() has 7 paramters:
    deviceType: Type of the device. This can currently be the Null-device,
       the Software device, DirectX8, DirectX9, or OpenGL. In this example we use
       EDT_SOFTWARE, but to try out, you might want to change it to
       EDT_NULL, EDT_DIRECTX8 , EDT_DIRECTX9, or EDT_OPENGL.
    windowSize: Size of the Window or FullscreenMode to be created. In this
       example we use 640x480.
    bits: Amount of bits per pixel when in fullscreen mode. This should
       be 16 or 32. This parameter is ignored when running in windowed mode.
    fullscreen: Specifies if we want the device to run in fullscreen mode
       or not.
    stencilbuffer: Specifies if we want to use the stencil buffer for drawing shadows.
    vsync: Specifies if we want to have vsync enabled, this is only useful in fullscreen
      mode.
    eventReceiver: An object to receive events. We do not want to use this
       parameter here, and set it to 0.
    */

    IrrlichtDevice *device =
        createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
            false, false, false, 0);

PC Specifications

Linux Mint 19.3 Cinnamon 4.4.8
Intel© Pentium© 3558U @ 1.70GHz × 2
3.8 GiB
Intel Corporation Haswell-ULT Integrated Graphics Controller

What could be the problem?


texts: Finite State Machines for Enemies (AI vs. Entity States)

texts:
Finite State Machines are a great tool for simplifying a system where an Entity has many states it can be in with different conditions that determine what state to transition to. This works well for representing a Player in a platformer, because the state machine can keep track of what state the Player is in based off of user input. This state machine would largely be based around animation states (running, jumping, attacking, etc...)

However, although this makes sense for handling Entity states and keeping track of animations, what about AI states? FSMs also provide a great framework for handling how enemies behave when interacting with the Player. My question is, what is the relationship between this FSM and the FSM that handles general entity states?

For example, in general, an enemy can be running, attacking, idling, jumping, falling, crouching, etc... In terms of AI, the enemy could be following, attacking, running away, patrolling, etc... As you can see, these states are mostly different with some overlap. I want to know how to handle these two different FSMs in code.

Questions:

Should I keep these FSMs separate and update the states separately or should I somehow combine them into one FSM?
If I keep the FSMs separate, how can I can I handle interdependence (behavior in the AI might change if suddenly the Enemy walked off a cliff and is now falling)?


texts: How to use OpenGL functions from multiples thread?

texts:
I'm writing a small game using OpenGL.

I'm implementing basic networking in this game and I'm facing a problem.

I have a thread in my client socket class that check for available data, when there are data I raise an event like this :

immutable int len = this.m_socket.receive(data);

if(len > 0)
{
    this.m_onDataEvent(data);
}

Then on my game class, I have a function that handle and parse data like this :

switch(msgId)
{
    case ProtocolID.CharacterData:

        // Load terrain with opengl, character model....

Im not able to call opengl functions because my opengl context is created from a different thread.

But I really don't know how I can solve this problem, I tried Google but it's really hard to find a solution.

I'm using D programming language if it can help.


texts: How to find perpendicular line given a line?

texts:
I have two points that form 1 line. I want to find a point that creates a perpendicular line.

Here is an image showing what I am looking for:

How do I find the red point to form a perpendicular line?


texts: Hotplugging Joysticks And Gamepads On OSX

texts:
I've tested the cross platform joystick support features on GLFW, SDL2 and SFML.  SDL2 appears to be the most complete, but it can't detect when joysticks have been unplugged on OSX.  To me, this is a fundamental feature.

Joystick detection support appears to be much weaker on the Mac than in Windows. What can I do to overcome this?


texts: Character jumping but not returning to ground platform game AS3

texts:
I am making a platform game where the main character moves right and left and jumps however my character jumps and does not return to the ground but stays on top of the stage.My characters movie-clip symbol is called 'naruto' and my ground symbol is called 'ground'.

Here is my code:

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;

naruto.gotoAndStop("stance");
var rightPressed:Boolean = new Boolean(false);
var leftPressed:Boolean = new Boolean(false);
var upPressed:Boolean = new Boolean(false);
var downPressed:Boolean = new Boolean(false);
var narutoSpeed:Number = 10;
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME,gameLoop);

function keyDownHandler(keyEvent:KeyboardEvent):void
{
    if (keyEvent.keyCode == Keyboard.RIGHT)
    {
    rightPressed = true;
    }
    else if(keyEvent.keyCode == Keyboard.LEFT)
    {
    leftPressed = true;
    }
    else if(keyEvent.keyCode == Keyboard.UP)
    {
    upPressed = true;
    }else if(keyEvent.keyCode == Keyboard.DOWN)
    {
    downPressed = true;
    }

}
function keyUpHandler(keyEvent:KeyboardEvent):void
{
    if (keyEvent.keyCode == Keyboard.RIGHT)
    {
    rightPressed = false;
        naruto.gotoAndStop("standright")
    }
    else if(keyEvent.keyCode == Keyboard.LEFT)
    {
    leftPressed = false;
    naruto.gotoAndStop("standleft")
    }
    else if(keyEvent.keyCode == Keyboard.UP)
    {
    upPressed = false;
    naruto.gotoAndStop("stance")
    }else if(keyEvent.keyCode == Keyboard.DOWN)
    {
    downPressed = false;
    naruto.gotoAndStop("stance")
    }

}

function gameLoop(loopEvent: Event): void {
    //If the right key is pressed, and the left key is NOT pressed
    if (rightPressed && !leftPressed) {
        naruto.x += narutoSpeed;
        naruto.gotoAndStop("right");
    }

    if(leftPressed && !rightPressed) {
        naruto.x -= narutoSpeed;
        naruto.gotoAndStop("left");

    }
var jumpHeight =0;
var defaultJumpSpeed = 20;
var jumpSpeed = 20;

if(upPressed && naruto.hitTestObject(ground))
{
    trace("HELLO!");
naruto.y -= jumpSpeed;
jumpSpeed-= 4;
}

if(upPressed)
{
    trace("HELLO!");
jumpHeight++;
naruto.y -= jumpSpeed;
if(jumpHeight>10)
jumpSpeed -= 4;
}

if(naruto.hitTestObject(ground))
{
    trace("HELLO!");
jumpHeight =0;
jumpSpeed = defaultJumpSpeed;
}
    }

Here is the link for my work: https://www.mediafire.com/?8d5opy49fuqmup5

Here is the problem:


texts: What are some game design YoutTube channels?

texts: I already follow quite a few game design channels like Writing On Games or Game Maker's Toolkit, and would love to find/follow some more.


texts:
In the frames of a number crunching compatible programming language (say.. C++), what would be an elegant solution for adding self collision, external collision and integration step (Euler, etc.) updates to an object? (say the already abused mass spring system).

Say the object class is this one:

class DeformableObject
{
    public:
    DeformableObject();
    virtual ~DeformableObject();
    protected:
    vector <vec3<Real> > pos;
    vec3<real> fEval(int idx); // - the internal force due to ellasticity at the idx-th node
    friend class Integrator;
}

For example, in case of the integration method, I was thinking of having an abstract Integrator class and derive from it to add specific methods (Euler, Verlet, Midpoint, you name it).:

class Integrator
{
    public:
    Integrator();
    virtual ~Integrator();
    vec3<Real> Step(Real DTime, DeformableObject * dObject, int idx);
}

Now, since I'd like to switch or perhaps let different instances of the same deformable object use  integration method A and the other use integration method B (for "benchmarking" purposes), is it safe to "think inside the box" and refer to either the Bridge or Strategy pattern? Which is more suitable and less ambiguous, especially performance-wise?

What about a self collision controller approach? Should I just add a self collision method to the DeformableObject class or "befriend" it with a Collider class? And what about external collisions, with different objects - how should that aspect be approached, at least at the conceptual level: considering the naive, brute pair-to-pair collision queries, if two objects collide, their points must be updated in the sense that velocities and forces are added to the points' own dynamic quantities (e.g. restitution forces, penalty forces, friction forces, reflected velocities, impulse conservation velocity changes, etc.).
I know this is a broad topic, but I don't know which book does tackle these natural problems for a novice programmer. Thanks for your patience in reading this question!


texts: Artificial intelligence for targeting 3D flying objects

texts: I'm working on a 3D game in Xna in which there is my jet which I am controlling. I want to add other jets as enemies. For that I need their AI so that I could have them able to target my jet. I've searched Google but couldn't find good resources. I hope professionals here can help me with my project.


texts: Dealing with interpolation and object creation/destruction

texts:
I've implemented a game loop similar to that in Glenn Fiedler's Fix Your Timestep! article.  I have an update step running at 50Hz and a render step running at 60Hz (monitor refresh rate).  To keep things smooth, the update step produces snapshots that the render step can interpolate between with a constant latency of 20ms.  These snapshots contain all the information needed for the rendering step to build skeletons and other transformations, but not anything involving physics, AI, or networking.

Actually interpolating between the snapshots is pretty simple, but something I've forgot about until now is how to deal with renderables being created or destroyed.  What would be an elegant method to go about interpolating between snapshots when a renderable may only exist in one of them?


texts: In games, materials often only influence the visual appearance of objects. The visual appearance is effected by shaders. So regarding to terminology is there a difference between materials and shaders? Should you write one shader for one material?


texts:
I'm trying to get something similar to the Nearest Neightbor Problem, except I only want neighbors with radius overlapping a radius, and all of them.

I'll explain my problem before explaining what I think I need.
I have entities made out of voxels, where i want complete collision between all voxels. I'll do this by only doing collision checks for other entities within the maximum radius of the 'this' entity plus its velocity magnitude, including the radii of those other entities. That is a whole other problem in itself, but something that I can handle. What I need right now is a way of populating the list of collisions 'this' needs to check.

Take a set of entities with arbitrary size/radius, make lines/circles/spheres out of their radii; given one of those spheres, get a list of all other spheres which overlap it.
Cubes would also work instead of spheres if its somewhy substantially faster.

Ofcourse I could just iterate over all entities, but that would be n^2 time, and I would like to have thousands of entities. I could perhaps bruteforce it with a compute shader, but I'd like to avoid that.

Sofar I've been thinking have a k-tree store all entity positions, then have each entity make a sort of footprint on the nodes as one step, in the next step, check for nodes belonging to this which also have the footprint of another entity.
So how do I make a quadtree in a way which I can set and get footprints from in a way that isnt hideous? Or is there a completely different better way?

edit: found this paper but its quite over my head


texts: Player ranking using Elo with more than two players

texts:
I would like to use Elo to track player rankings between matches of a certain game, however the game can be played with up to four players in a match. I have seen games like Carcassonne use Elo with more than two players playing, but I am not familiar with Elo beyond a 1-1 matchup.
From the wikipedia article the two-player equations I would like to extend are:

Ea = 1/(1 + 10(Rb - Ra) / 400)
Eb = 1/(1 + 10(Ra - Rb) / 400)
Rxnew = Rxold + 32 * (W – Ex), where W=1 if X wins and W=0 if X loses.

How would the computation for Ex and W change given more than two players?


texts: How to reduce a rectangle without problems?

texts:
I'm developing an asteroids' game and I'm needing to reduce the rectangle of the spacecraft because when I use the method intersect() of Rect class to detect a collision with an asteroid they are far.

Here is a part my game:

As you can see, if the red rectangle of the spacecraft intersects with the red rectangle of the asteroid the game will detect a collision.

My problem it's that there is a big space in the bottom and the top part of the spacecraft which can confuse the player.

To solve it, I'm trying to modify the rect values of top and bottom but when i do this the image dissapear of the canvas.


texts: Different kinds of movement in component based entity system

texts:
I am writing a pong clone with a component based entity system.
But I am having trouble with the different kinds of movement in the game.

The problem is the following: My paddles will just move up and down, so I only need a Y-velocity for these.
But the ball can move in each direction. So the ball will need an angle and a velocity.
Now my question is: Is it usual to put the data for moving a ball in another component than the data for moving a paddle?
Because if I would do so, I would need two systems just for movement. Is that a good approach?

A little bit information about my system: My entites are only IDs. I have an entity manager which holds all the entities and the linked components. Components only hold certain data on which systems operate.
Basically I am using this approach: Tutorial


texts: Procedural Generation, Game Updates, & Butterfly Effect

texts:
NOTE: I asked this on Stack Overflow a few days ago but had very few views and no response. Figured I should ask on gamdev.stackexchange instead.

This is a general question / request for advice on maintaining a procedural generation system through multiple post-release updates, without breaking previously generated content.

I am trying to find information and techniques for avoiding "Butterfly Effect" issues when creating procedural content for games. When using a seeded random number generator, a repeating sequence of random numbers can be used to create a reproducable world. While some games simply save the generated world to disk once generated, one of the powerful features of procedural generation is the fact that you can rely on the reproducability of the number sequence to recreate a region multiple times in the same way, removing the need for persistence. Because of the constraints of my particular situation, I must minimise persistence, and need to rely on purely seeded concent as much as possible.

The main danger in this approach is that even the slightest change in the procedural generation system can cause a butterfly effect that changes the entire world. This makes it very tricky to update the game without destroying the worlds that players are exploring.

The main technique I've been using to avoid this problem is to design the procedural generation in multiple phases, each of which has its own seeded random number generator. This means that each sub-system is self contained, and if something gets broken it will not affect everything in the world. However this seems like it still has a lot of potential for "breakage",even if in an isolated part of the game.

Another possible way of dealing with this problem could be to maintain complete versions of your generators within the code, and keep using the right generator for a given world instance. This seems like a maintenance nightmare to me though, and I'm curious if anyone actually does this.

So, my question is really a request for general advice, techniques, and design-patterns for dealing with this problem of the butterfly effect, especially in the context of post-release game updates. (Hopefully that's not too broad a question.)

I am currently working in Unity3D / C#, although this is a language agnostic question.

UPDATE:

Thank you for the replies.

It's looking more and more like static data is the best and safest approach, and also that when storing a lot of static data is not an option, having a long campaign in a generated world would require strict versioning of the generators used. The reason for the limitation in my case is the need for a mobile based cloud save / sync. My solution may be to find ways of storing small amounts of compact data about essential things.

I find Stormwind's concept of "Cages" to be a particularly useful way of thinking about things. A cage is basically a reseed point, preventing run-along effects of small changes, ie caging the butterfly.


texts: How to incorporate delta time into movement?

texts:
I want to use delta time in my movement code for my player, and I'm not sure how to do it. At the moment, I have this:

else if (keyboardState.IsKeyDown(Keys.D))
        {
            double moveSpeed = 0.3 * delta;

            if (velocity < 0)
            {
                double turnSpeed = 0.5 * delta;
                velocity += turnSpeed;
            }
            else
            {
                if (velocity + moveSpeed > .1)
                {
                    velocity = .1;
                }
                else
                {
                    velocity += moveSpeed;
                }
            }
        }

        position.X += (float)velocity;

Is this correct? I'm trying to make my player's movement gradually speed up until it hits the maximum velocity.

position.X is the Vector2 X of the player.
delta is set to gameTime.ElapsedGameTime.TotalSeconds.


texts: What are the time-efficiency characteristics of these voxel data structures?

texts:
Real-time, high-resolution voxel raycasters tend to use one of the following optimising data structures in order to achieve interactive frame rates. What are the pros and cons to these, and what other approaches are you aware of?

Octrees
KD-Trees
Uniform 2D grid with run-length encodings for 3rd dimension (as used in Voxlap)

I am primarily concerned with their impacts on time efficiency rather than space efficiency, but feel free to respond on both aspects. This includes not only raycast time, but also reconstruction time following CSG ops.

I am interested specifically in real-time performance on the CPU, so please don't suggest that I skip the above in favour of GPU-centric volume rendering approaches which may not require these optimisations; those aren't of interest to me at this time.


texts: Is it illegal to use a commercial song in your game (that you intend to sell)

texts:
If I were to buy, say this song: http://www.youtube.com/watch?v=3fumBcKC6RE, strip/find/get the instrumental, and use that instrumental in a game I'm making, as a theme, say for a recurring boss fight, and then sell this game, would this be illegal?

This is hypothetically speaking.


texts: Stencil pass in deferred rendering - far plane

texts:
For a long time I was occuring issue with lights which use light volume to reduce fragment shaders run (point, spot).

First I use stencil pass to mark pixels which should be processed by fragment shader by drawing a sphere. Then in light pass I render the same sphere again.

Everything works ok until light volume cuts with far plane. Back faces of that volume aren't rendered so stencil buffer contain 0 value.

Because of that final image has big black circle instead of lightened area. I searched how to overcome that issue and I realized that one of the solution to this problem is to enable GL_DEPTH_CLAMP which ignores near and far plane. I enabled it for both passes. The problem dissapeared.

My question are:

Is that correct solution used by people and does it decrease performance?
Why all tutorials doesn't mention about that issue? I'm curious if I have something wrong in my implementation.

I am aware that there are other methods such as screen-aligned quads or tile based deferred rendering but I want to understand this method as well.


texts: Which code is faster to convert -1 to 0 and 1 to 1?

texts:
I'm writing a shader for rendering the sides of triangles with different colors. I have a value mediump float back = dot(V, N) which is positive if the normal faces away from the camera and negative if towards the camera.

To correctly select which diffuse color to shade a particular fragment, I need something like this:

lowp vec4 color = max(0.0, sign(-back)) * frontdiffuse + max(0.0, sign(back)) * back diffuse;

It's more or less an "unrolled conditional"...

Which code produces faster instructions?

x * 0.5 + 0.5, or
max(0.0, x) ?

The former may be better mathematically behaved than the latter, but maybe min/max/clamping is super efficient in hardware


texts: I crave to become game Dev. I have watched tried and even made my first game tutored by brackeys that is a cube dodge game. I felt very happy and successful.but what to do to develop rather than buying courses costing lot of dollars. I have experience with unity but still could not get myself immersed frequently in spite of my passion for developing games. People could have same problems as mine. Please suggest me something.whatever u feel guys. Also coding ain't much of a problem. I have inspired from a lot of projects tried them and failed n even quit them even before 25 percent. I know the benefits of starting small and keeping simple which I learnt from extra credits channel yt. But u wanna learn stuff that I do not know and that too as I work in small projects for u or other people with the only goal of acquiring knowledge and skill.i use unity for a while like a month with for twthree again get inspired and cycle goes on.i want help and inspiration on making awesome content


texts:
i'm using cocos2d to build an iphone game.

my game currently has two sprites: one for the main character and another for an item i should carry once he gets on him.

the main character and the item are both box2d bodies. i can detect the collision between the two. what is want is to make the item body stick to the main character body when they meet, that way any movement of the main character would also affect the item.

any suggestions on how to implement this?

thanks!


texts:
I'm working on a physically-based renderer, and I've come to a sort of crossroads regarding the Fresnel factor. I'm having trouble finding the best way to represent it. I know that Schlick's Fresnel approximation is based off IOR, but IORs can go up to 38.6 for a meta-material, and 4.05 for a natural element, which will make representing these in a 0-1 image difficult and confusing. I also noticed that no one really uses IOR maps.

I also read a paper on Unreal's PBR integration, and I discovered that they initially wanted to use a F0 of 0.4, for non-metals. What would be the F0 for metals, in this case, and isn't the static value of 0.4 worth the limitations for that tiny bit of memory? I believe the F0 tends to the base color, as it becomes more metallic, but I'd like confirmation.

Finally, there's reflectivity or specular, as is used in modern PBR equations. Is there a standard for this, in regard to getting an F0? It seems arbitrary; is it a float value up to that directly maps to F0?

I am not sure if there are any real reasons to not combine specular color and base color, as Unreal has done this, before. I can't think of a single real reason, even for more stylized implementations.

What is the best PBR real time Fresnel function?


texts: OpenGL GLSL using projection,view and transformation

texts:
I have been trying to get a simple triangle to render on the screen. I am using Projection, View and Transformation matrices but am unable to get anything to the screen.

Main loop

...
shader->start();

Matrix4f transformation = Math::createTransformationMatrix(Vec3<float>(0,0,-25),0,0,0, 1);
shader->loadTransformationMatrix(transformation);

Matrix4f camera = Math::createViewMatrix(Vec3<float>(0, 0, 0), 1, 0, 0);
shader->loadViewMatrix(camera);

Matrix4f projection = Math::getProjectionMatrix(1080,720);
shader->loadProjectionMatrix(projection);

glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
    0,
    3,
    GL_FLOAT,
    GL_FALSE,
    0,
    (void*)0
);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);

shader->stop();
...

Math.h

static Matrix4f createTransformationMatrix(Vec3<float> translation, float rx, float ry, float rz, float scale) {
    Matrix4f matrix;
    Matrix4f::translate(translation, matrix,matrix);
    Matrix4f::rotate(toRadians(rx), Vec3<float>(1, 0, 0), matrix, matrix);
    Matrix4f::rotate(toRadians(ry), Vec3<float>(0, 1, 0), matrix, matrix);
    Matrix4f::rotate(toRadians(rz), Vec3<float>(0, 0, 1), matrix, matrix);
    Matrix4f::scale(Vec3<float>(scale, scale, scale), matrix, matrix);
    return matrix;
}
static Matrix4f createViewMatrix(Vec3<float> pos, float pitch, float yaw, float roll) {
    Matrix4f matrix;
    Matrix4f::rotate(toRadians(pitch), Vec3<float>(1, 0, 0), matrix, matrix);
    Matrix4f::rotate(toRadians(yaw), Vec3<float>(0, 1, 0), matrix, matrix);
    Matrix4f::rotate(toRadians(roll), Vec3<float>(0, 0, 1), matrix, matrix);

    Vec3<float> negativeCam(-pos.x, -pos.y, -pos.z);
    Matrix4f::translate(negativeCam, matrix, matrix);

    return matrix;
}
static Matrix4f getProjectionMatrix(int width, int height) {
    float aspectRatio = (float)width / (float)height;
    float y_scale = (float)((1 / tan(toRadians(FOV / 2)))*aspectRatio);
    float x_scale = y_scale / aspectRatio;
    float frustum_length = FAR_PLANE - NEAR_PLANE;

    Matrix4f projectionMatrix;
    projectionMatrix[0] = x_scale;
    projectionMatrix[5] = y_scale;
    projectionMatrix[10] = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
    projectionMatrix[11] = -1;
    projectionMatrix[14] = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
    projectionMatrix[15] = 0;
    return projectionMatrix;
}

Vertex Shader

    #version 330 core

    layout(location = 0) in vec3 position;

    uniform mat4 transformationMatrix;
    uniform mat4 projectionMatrix;
    uniform mat4 viewMatrix;

    void main() {
        //Works but renders without any camera or projection applied
        //gl_Position.xyz = position;
        //gl_Position.w = 1.0;

        vec4 worldPosition = transformationMatrix * vec4(position, 1.0);
        vec4 positionRelitiveToCam = viewMatrix * worldPosition;
        gl_Position = projectionMatrix * positionRelitiveToCam;
    }


texts: UE4. How to create a reference to the physical material asset (which I create in editor) in C++

texts:
Oftenly, when we want to assign asset to the particular component in C++ we write code like that:

.h

UPROPERTY(BlueprintReadWrite)
UStaticMeshComponent* Body = nullptr;

.cpp

Body = CreateDefaultSubobject<UStaticMeshComponent>("Mesh Component");
// find mesh asset
auto MeshForBody = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT
                        ("StaticMesh'/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere'"));
if (MeshForBody.Object != nullptr)
{// if asset is finded -> set to the component
    Body->SetStaticMesh(MeshForBody.Object);
}

Question: how can I set the PhysicalMaterial in C++ through the reference to the asset in editor? Is it possible?

.h
    UPROPERTY(EditDefaultsOnly)
    UPhysicalMaterial* MyPhysicalMaterial = nullptr;

.cpp

    ???

Find this, but still waiting maybe the best solution without casting exists:

auto PhysicalMaterialAsset = ConstructorHelpers::FObjectFinder<UObject>(TEXT(
         "PhysicalMaterial'/Game/PhysicsMaterials/MyPhysicsMaterial.MyPhysicsMaterial'"));

if (PhysicalMaterialAsset.Object)
{
    Sphere->BodyInstance.SetPhysMaterialOverride((UPhysicalMaterial*)PhysicalMaterialAsset.Object);
}

THNX for any tips in advance ;)


texts: Should Different "Types" of Animations be in the Same Class?

texts:
For example, say you want a character animation and a health bar animation. Since these require different algorithms, should they be in the same class?

They both re-use some of the same code but having them both in one class for me requires MANY parameters to be sent in upon instance creation.

This could just be a lack of Object-Orientation understanding on my part.

I'm no sure what you would call these different "types", possibly static and moving animations. I am sure there are plenty more. I just would like to know best practices when it comes to this type of thing.

Thanks!


texts:
Can anyone please tell me how to save data for Android.

I have too much data to save (many npc-enemy stats). Also, it should work after updating: I read on stack overflow that, with BinaryFormatter, when you update or change the class, your old settings might be lost since the classes no longer match. Sometimes, you get an exception when reading the saved data due to this.

I also read about JSON/XML. Does JSON/XML throw an error if I change class?


texts: Unreal Engine: saving in-game images to disk without blocking game thread

texts:
I am working on an Unreal based open-source UAV simulation (Microsoft AirSim) where I am trying to capture and save images from a camera that's attached to the drone. The image underneath gives an idea of how the game looks like. The rightmost view on the bottom is the actual view from the camera, the other two are just processed versions of the same image.

Right now the way it's set up in this way: There's a camera asset, which is read through the code as a capture component. The three views in the screenshot are linked to this capture component. The views are streamed without any problem as the drone is flown around in-game. But when it comes to recording screenshots, the current code sets up a TextureRenderTargetResource from this capture component, and subsequently calls ReadPixels and saves that data as an image (please see below for code flow). Using ReadPixels() as it is, is blocking the game thread directly and slowing down the whole game by a lot: drops from ~120 FPS to less than 10 FPS when I start recording.

bool saveImage() {
  USceneCaptureComponent2D* capture = getCaptureComponent(camera_type, true);
  FTextureRenderTargetResource* RenderResource = capture->TextureTarget->GameThread_GetRenderTargetResource();
  width = capture->TextureTarget->GetSurfaceWidth();
  height = capture->TextureTarget->GetSurfaceHeight();

  TArray<FColor> imageColor;
  imageColor.AddUninitialized(width * height);
  RenderResource->ReadPixels(bmp);
}

Looking at this article, it seems evident that ReadPixels() "will block the game thread until the rendering thread has caught up". The article contains sample code for a 'non-blocking' method of reading pixels (through removal of FlushRenderingCommands() and using a RenderCommandFence flag to determine when the task is done), but it doesn't significantly improve the performance: the rate at which images are saved is slightly higher, but the game thread still runs at about only 20 FPS, thus making it really hard to control the UAV. Are there any more efficient asynchronous methods that can achieve what I am trying to do, perhaps, say, in a separate thread? I am also a little confused as to why the code has no trouble streaming those images on-screen as fast as possible, but saving the images seems way more complicated. It's fine even if the images are saved to disk only at 15 Hz or so, as long as it doesn't interfere with the game's native FPS too much.


texts: Which of these DirectX11 calls actually sends data to the GPU?

texts:
I'm trying to learn graphics programming and DirectX11.

I'm trying to learn how to minimize CPU-GPU transfer and graphics programming in general.
I have a question that I have been unable to answer myself from online resources:

Which of the D3D methods actually sends the data to the GPU(and, equivalently, for a static mesh does ALL the vertex data get passed to the GPU every frame, or only once)?

Code follows:
(simplified for stackexchange)

In my "mesh" class, I have a vertex buffer:

ID3D11Buffer *m_pVBuffer;

In my mesh's constructor, I set some vertices to the vertex buffer:

D3D11_MAPPED_SUBRESOURCE ms;
devcon->Map(m_pVBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms);
memcpy(ms.pData, &vertices[0], sizeof(VERTEX) * vertices.size());
devcon->Unmap(m_pVBuffer, NULL);

Then in my mesh's "render" method, I do this:

UINT stride = sizeof(VERTEX);
UINT offset = 0;
devcon->IASetVertexBuffers(0, 1, &m_pVBuffer, &stride, &offset);
devcon->IASetIndexBuffer(m_pIBuffer, DXGI_FORMAT_R32_UINT, 0);
devcon->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
devcon->DrawIndexed(m_num_indices, 0, 0);

To repeat: Is the data uploaded to the GPU when I Map, memcpy and Unmap the vertex buffer, or is it uploaded every frame, when I call IASetVertexBuffers?


texts:
So the idea is simple.
a) Players why finish the level faster, should get higher score.
b) The levels (1 to N) where every next becomes more difficult should impact the score.
So it's kind of mix of "time to complete" and "level number".
If would know the fastest possible time the user can complete the level, I would do the fallowing:
a) If player completes the level in fastest time, it gets max score 100.
b) If it takes, for example, twice as long I divide by 2 and get 50.
c) Then I multiple by the level number assuming that every next level is twice as difficult.
Example: Player completes level N two times slower than fastest time, so: Score = 100/2 * N = 50N
But the problem is that I can't really figure out the this fastest time for each level, because my game is a complex randomized 4d maze and I have no idea how fast a pro gamer can complete it to define the max score. And without that I have no idea how to calculate the score.
This question is all about: "Can we figure out the score without knowing the fastest time"
Any help appreciated.


texts: Greenfoot java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

texts:
When an enemy comes into contact with the hero the hero class is supposed to remove the enemy class with the same X and Y. It works the first time but throws an error immediately after that:

  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          at java.util.ArrayList.rangeCheck(ArrayList.java:653)
          at java.util.ArrayList.get(ArrayList.java:429)
          at Hero.checkCollision(Hero.java:39)
          at Hero.act(Hero.java:23)

public void act()
{
    ...
    checkCollision();
    ...
}
private void checkCollision()
{
    Actor 2 = (Actor)getWorld().getObjects(2.class).get(0);
    if(2.getX() == getX() & 2.getY() == getY()) {
        getWorld().removeObject(2);
    }
    Actor 1 = (Actor)getWorld().getObjects(1.class).get(0);
    if(1.getX() == getX() & 1.getY() == getY()) {
        getWorld().removeObject(1);
    }
    Actor 3 = (Actor)getWorld().getObjects(3.class).get(0);
    if(3.getX() == getX() & 3.getY() == getY()) {
        getWorld().removeObject(3);
    }
      if (Room.totalPeeps == 0) {
          setLocation(250,250);
          GreenfootImage img = getImage();
          img.setFont(img.getFont().deriveFont(30f));
          setImage(new GreenfootImage("YOU WIN!!" , 75, Color.WHITE, Color.BLACK));
          Greenfoot.stop();
    }
}


texts:
I have absolutely no idea about game developing but want to know following things about internet sweepstake games: Click on demo and play any of the game.

What technology (programming language) is used to develop these games. e.g. Flash, Silverlight, etc.
If I wish to develop such game(s) what is the best technology to use, how much time it might take to learn and develop a simple commercial product.
Is the algorithm/code behind the scene re-usable while changing the front graphics. I mean a scalable/adjustible game.
In case I wish to hire a game programmer what would be the approximate cost or per/hr charge for such developer.
Any good books or online tutorial/videos to learn/see this in action?

Or any other ideas or suggestions?
Sorry if these are lot of questions but this is the only good place I see asking such questions. I will more than happy to post them as separate questions if that is necessary.


texts:
I'm currently developing a 3D game with its own engine. I have some performance issues in the function that orders all the draw events and sends them to the GPU. I've heard about threads, and I thought that it could be nice if I could pass that code to another thread.
The structure is something like:

Global function that receives all events and calls OpenGL to draw

void DrawAll(float dt, vector<draw_events>)

Function inside the EventSystem, that calls the previous function

Events passed by copy, that have pointers to objects in the scene  (scene is in main thread)

void ModuleEventSystem::PostUpdate(float dt)
{
   DrawAll(dt, draw_events);
}

This has been tested, and has worked well.

Now I have inside:

std::thread draw_thread;
void ModuleEventSystem::PostUpdate(float dt)
{
   if(draw_thread.IsJoinable())
         draw_thread.Join();

   draw_thread = std::thread(DrawAll, dt, events_to_draw);
}

The problem: not only the performance as become worse, objects in scene doesn't draw at all.
I have never worked on threads before, so I don't know if the issue is having a thread with OpenGl calls and pointers pointing to objects in the main thread, or is the bad structure of code... Or even if this kind of optimization is not possible at all.
Thank all of you.


texts: Unity development build not connecting to profiler

texts: my development build( with auto connect profiler checked ) is not working. The build runs correctly but no data is displayed in the profiler window. In the console, it says failed to connect.


texts:
I am working on a space orientated game, and I have done some research on the best way to simulate gas with traditional physics technologies (Creating a lots of circles)

The only obstacle I have is how to simulate pressure. For example, if one corner of the room has lots of these little circle physics bodies, how can I make them evenly distribute? If I have a huge vacuum, what is the best way to have the particles get sucked out through the corridors etc of a room into space?

I can't think of any way to do this without iterating over every single particle against every singe other particle. Obviously, I cannot do this in a real-time simulation.

Maybe I could do this on a tile-based level?

The specific technologies I am using are Java and Dyn4j.

Thanks,


texts: How to work properly with different coordinate-systems

texts:
Let's say we got a little set {S} wich has 4 possible coordinate systems (LH=left handed, RH=right handed):

LH-y_up
LH-z_up
RH-y_up
RH-z_up

Now, let's say my Opengl engine is using a RH-y_up coordinate system and I want to import models from some 3d package which uses a RH-z up coordinate system (like 3ds max). One way to do it would be at the exporting/preprocessing stage flipping the y&z model's components. That solution doesn't seem like a really good idea though... what about if i decided to change eventually on my engine from coordinate system 3) to 1) or 2)?

So, my question would be. Let be A & B 2 coordinate systems from set S. What's the proper way to use models from A onto B?


texts: Tiled Map Editor - Isometric View Problem

texts:
I'm using the latest version of Tiled Map Editor (0.9.1) to create isometric maps. I have objects that are larger than my tile size (64 x 32), so I am breaking them up into two tiles of the correct size. Below I show that the blue blocks are made of a top and a bottom (both of which are 64 x 32).

You can also see that when I am placing these blocks side by side, there is some strange rendering overlap. Shouldn't the foreground be showing if it is rendered in the correct order?

In that picture you can see 4 blocks stacked side by side with the problem, 2 blocks side by side with the problem, 1 block by itself without the problem, and 1 dissected block in its two components.

Anyone know what's up?

Note: this is the view from within the Tiled Map Editor itself, not from within my game.


texts: Partially transparent surface over opaque surface causes strange artifacts

texts:
I have a world with many unit square tiles, each made up of a 3d terrain chunk and a 2d water chunk (a square). Each chunk stretches from [0, 0] to [1, 1] (inclusive) in its tile space. This means each pair of adjacent chunks shares an edge of vertices (although for sharing the visual I've curbed in the edges of the water chunks to make it obvious where the tile edges are).

I'm having a weird issue when I make water somewhat transparent (85% in my case). It looks like "walls" form between the water surface and the terrain surface below, along the edges of the tile. The walls reflect the water color, but with 100% opacity instead of 85%.

This side has a problem:

This side looks fine:

The weirdest part to me is that I can only see these walls from one side, as shown in the screenshots. I suspected maybe this had something to do with backface culling, so I turned it off, but that didn't change anything.

I did notice that the walls disappear if I stop rendering the terrain, and maintain the same level of water transparency.

No walls from front:

And no walls from back:

(The light blue in the second set of images is the sky color.)

Does anyone recognize this issue, know a name for it, or have an idea what I could change to fix it? Thanks!


texts:
This might be a bit misplaced but is there a way to call a function by name in Unity?

I've tried Invoke(string, float) but that doesn't accept parameters.  I've tried StartCoroutine but that requires a yield return new statement.  I've also tried reflection, like this:

Type thisType = this.GetType();
MethodInfo theMethod = thisType.GetMethod(TheCommandString);
theMethod.Invoke(this, userParameters);

But this doesn't even compile giving an error of NullReferenceException: Object reference not set to an instance of an object
 and I don't really know why.  Thanks for the help guys.


texts: How to implement Ragdoll physics to 2D characters in XNA?

texts: I'm starting a new project with XNA. I want to create a game where the main character is subject to ragdoll physics when killed. I was wondering if anyone can give me any tips on how should I implement the character class and apply these ragdoll physics before I start coding so I don't have to refactor my code later. No code is necessary, just a basic overview of an algorithm and some tips. I've found a lot of information about ragdoll physics in 3D but nothig about 2D in XNA.


texts: What is a technique for 2D ray-box intersection that is suitable for old console hardware?

texts:
I'm working on a Sega Genesis homebrew game (it has a 7mhz 68000 CPU). I'm looking for a way to find the intersection between a particle sprite and a background tile. Particles are represented as a point with a movement vector. Background tiles are 8 x 8 pixels, with an (X,Y) position that is always located at a multiple of 8.

So, really, I need to find the intersection point for a ray-box collision; I need to find out where along the edge of the tile the ray/particle hits.

I have these two hard constraints:

I'm working with pixel locations (integers). Floating point is too expensive. It doesn't have to be super exact, just close enough.
Multiplications, divisions, dot products, et cetera, are incredibly expensive and are to be avoided.

So I'm looking for an efficient algorithm that would fit those constraints. Any ideas? I'm writing it in C, so that would work, but assembly should be good as well.


texts: How to save Unity assests to another drive?

texts:
My C:\ volume has almost no space left.
Therefore I want to transfer all my assets to the volume E:/. And save my new assets automatically on the E:/ volume. I have searched very long in unity for save options of unity assets but nowhere found a setting option for this.


texts: Unity3D: Rotating the head and an animation gets clashed

texts:
A rigged generic models head keeps rotating to follow the camera. When there is an animation like shaking the head, the head animates weirdly as compared to without rotation. Is there anyway to fix it?

The neck gets protruded forward.

the heirarchy is like spine
                           neck
                               neck_02
                                     head #here is my rotation script

For some reason, if I attach the script to neck, the neck doesn't rotate.

The neck gets protruded forward when the head shaking animation occurs


texts: Improving the performance of smooth movement up and down

texts:
I would like to achieve a smooth movement of a game object up and down. The way I have always seen this done is via a sine wave, and adding the value of y for a specified X to the game objects value of Y.

This method seemed slightly slow so I had the idea of using two parabolas, one of which is negative such as the following two:

and then one would only use the values above or below zero depending on the parabola.
However even this seems like an obtuse and slow method so I was wondering if there was a better way?


texts: Quaternions and rotation around world axis

texts:
Disclaimer: I am a professional games programmer, and use quaternions most days but they are close to black magic to me. I am relatively at home with math but imaginary numbers always confused me. I tend to treat quats as useful and end up reversing multiplications more than once. I try to reason about them like I would with matrices with limited success.

Anyhow....

What baffles me, is the following.
When I want to rotate an object around it's local axis I multiply its rotation with the quaternion that represents the rotation I want to apply. It is therefore a rotation in local space.

Now if I want to rotate it around an axis in world space, my reasoning would be:
Take the rotation in world space as a quaternion.
Multiply the inverse of my object rotation with this quaternion. This will bring my world rotation in local space.
Multiply my rotation with this new quaternion.
ie: newRot = oldRot * (inverse oldRot * worldRot)

However, what I need to do is
newRot = oldRot * (inverse oldRot * worldRot) * oldRot.

Why do I, after multiplying with the inverse quat still need to multiply with my own quat before applying it? I know there must be a perfect valid reason, but I can't reason my way out of it and it's frustrating as heck to me. I tried the various faqs and whatnot, but most go to deep in the math, making it less clear to me.

Anyone who can explain this to me like I'm a 5 year old?


texts: Why is keeping a constant FPS harder than keeping high FPS?

texts:
I've noticed this ever since I started playing games, and now see it in my own experiments. If I don't do any capping my game runs at 200~250 FPS, with random drops to 150FPS, but if I cap the FPS to 60 using a simple precision timer + sleep method, the game will sometimes (much more frequently than I want) render at ~40FPS during complex scenes.

I suspect this is simply because my process gets dequeued by the OS during the time I used to spend rendering the other 140 frames, meaning there's more context switches going on, as well as allowing other processes to steal all the cores and do CPU-intensive tasks in them. At the same time, this doesn't feel right, and one would think modern OS's are able to do scheduling that is good enough to avoid that.

So, my question is, are there any techniques to optimize my game for constant FPS rather than high-but-with-lots-of-variation FPS? Should I just make sure my game logic is being updated in a constant rate and don't worry about render rates?

Here's how my FPS-limiting code looks like (somehow pseudo code):

const maxFrameTime = 1/DESIRED_FPS; // say 60

while(running()) {
     now = query_precision_timer();
     thisFrame = now - lastFrame;
     lastFrame = now;

     while(thisFrame > 0.) {
          Update();

          thisFrame -= maxFrameTime;
          now += maxFrameTime;
     }

     Render();
}


texts: How do I extract and publish my game made in Code::Blocks?

texts: So I made a 2D adventure game using c++ and SFML with the Code::Blocks IDE and the GNU GCC compiler. I have been working on it for several months and been doing bug fixes and everything. I want to publish my game to steam, or maybe a website for people to download for free and enjoy my game. However I do not know how to take my code on Code::Blocks and put it into a single application that when double-clicked it can be opened and ran as a game. Please help, it would be greatly appreciated.


texts:
I'm trying to render text (or whatever) off screen. But I have a strange issue where the render target size matches the window size and not the render targets size. Yes, it is a contradiction! Here's the render target:

And here's the code, chopped up and put together to demonstrate what's happening in one place :

UserInterface.SpriteBatch.Begin(SpriteSortMode.Immediate,
                                BlendState.AlphaBlend,
                                SamplerState.PointClamp,
                                DepthStencilState.None,
                                RasterizerState.CullNone);

RenderTarget2D rt = new RenderTarget2D(UserInterface.GraphicsDevice, 200, 200);
UserInterface.GraphicsDevice.SetRenderTarget(rt);

UserInterface.GraphicsDevice.Clear(Color.Blue);

Rectangle rect = new Rectangle(0, 0, 200, 200);
UserInterface.SpriteBatch.Draw(pixel, rect, Color.White);

renderTarget.GraphicsDevice.SetRenderTarget(null);

UserInterface.SpriteBatch.End();

if (frame == 0)
    rt.SaveAsJpeg(File.OpenWrite("renderTarget.jpg"), rt.Width, rt.Height);

The render target is created at 200x200, I then set the render target on the graphics device. I clear it to blue and draw a pixel at 200x200 (in white). Lastly, I save off the render target.

But why does the sprite batch render the pixel in proportion to the window (just take my word that it is rectSize / WindowSize * RTSize) rather than filling the render target which I believe it should do in this case?


texts: How to draw and give functions to multiple things at once?

texts: I'm using plain JavaScript and I've bee coding a hardcore platformer game. I want there to be multiple enemies at once and before I write up the code I have a question. How do i approach that? Do I just have to draw and give function to the enemies each time or is there a easier way?


texts:
I'm writing a small turn-based game using libgdx.
How to make a timer on the player turn to make it work even when the game loses focus??

Or maybe there are some other ways to do it???