texts: Issue with using two StartCoroutines in one script

texts:
I'm having a Issue with trying to use multiple StartCoroutines within my Script. I'm having an error at line 50 where is says StartCoroutine does not exist in the current context

void OnCollisionExit(Collision theCollision) {
    if ((theCollision.gameObject.tag == "Boost")) {
        movementspeed = 13000;
        //StartCoRoutine (Delay2 ());  error here
        Destroy (theCollision.gameObject);
    }
}

IEnumerator Delay2 () {
    yield return new WaitForSeconds (1);
    movementspeed = 10000;
}

void OnCollisionEnter(Collision theCollision) {
    if ((theCollision.gameObject.tag == "Wall")) {
        movementspeed = 5000;
        StartCoroutine (Delay ());
    }
}

IEnumerator Delay() {
    yield return new WaitForSeconds (3);
    movementspeed = 10000;
}


texts: How do I transfer game commands between 2 android devices via bluetooth first of all is possible to do this??If possible then someone please help in doing so.Thank u


texts: Rotating quaternion smoothly with acceleration and deceleration

texts:
I have this code for my linear acceleration and deceleration.
var currentSpeed = velocity.translation.z;
var decelerationDistance = ((currentSpeed * currentSpeed) / movementSettings.acceleration) * 0.5f;
if (distanceFromTarget > decelerationDistance)
{
    velocity.translation = float3(0f, 0f, min(currentSpeed + (movementSettings.acceleration * deltaTime), movementSettings.maxSpeed));

}
else
{
    velocity.translation = float3(0f, 0f, max(currentSpeed - (movementSettings.acceleration * deltaTime), 0f));
}

Assuming the object is already pointed at the target, this accelerates an object up to its maximum speed at its acceleration rate, and then slows it down by the acceleration rate so that it comes to a stop exactly on the target.
I'd like to have the same behaviour apply to rotation (which is a quaternion). i.e. Assuming the object is stationary, smoothly rotate to a target rotation, obeying acceleration and max rotation speed limits.
I have made a start of converting this code to work on quaternions:
private static float Magnitude(Unity.Mathematics.quaternion quat)
{
    return CalculateQuaternionDifference(Unity.Mathematics.quaternion.identity, quat);
}

private static float CalculateQuaternionDifference(Unity.Mathematics.quaternion a, Unity.Mathematics.quaternion b)
{
    float dotProduct = dot(a, b);
    return dotProduct > 0.99999f ? 0f : acos(min(abs(dotProduct), 1f)) * 2f;
}

...

var currentRotSpeed = Magnitude(velocity.rotation);
var rotDecelerationDistance = ((currentRotSpeed * currentRotSpeed) / movementSettings.acceleration) * 0.5f;
if (distance > rotDecelerationDistance)
{
    velocity.rotation = slerp(Unity.Mathematics.quaternion.identity, mul(rotationDiff, velocity.rotation), movementSettings.acceleration);
}
else
{
    velocity.rotation = slerp(Unity.Mathematics.quaternion.identity, mul(inverse(rotationDiff), velocity.rotation), movementSettings.acceleration);
}

My questions are:

Unity.Mathematics.math.slerp() doesn't seem to play well with values of t over 1. When acceleration and deltaTime are low it works, but if they increase too much it breaks in ways I don't understand. How can I multiply a Quaternion by a scalar the same way I multiply the linear acceleration by deltaTime.
This doesn't follow any max rotational speed limits or stop at 0. What is the equivalent of min/max() for a quaternion?
rotationDiff is the rotational difference between the current orientation and the target orientation. As the current orientation gets closer to the target orientation, this distance gets smaller. I know I should be using some static value instead, but I'm not sure what. Is there a way to normalize rotationDiff so it always has a magnitude of 1 radian?


texts: how to set angle between points of a bezier curve

texts: From the bezier curve image above, how can I set the angle r manually, so that changing it does not affect the distance between A and B?


texts:
I have found very useful resource on the Swiftless website on OpenGL.

Unfortunately, I cannot manage to adapt a GLSL fragment shader to my project, which uses Cg. Here it is:

uniform sampler2D color_texture;
uniform sampler2D normal_texture;

void main() {

// Extract the normal from the normal map
vec3 normal = normalize(texture2D(normal_texture, gl_TexCoord[0].st).rgb * 2.0 - 1.0);

// Determine where the light is positioned (this can be set however you like)
vec3 light_pos = normalize(vec3(1.0, 1.0, 1.5));

// Calculate the lighting diffuse value
float diffuse = max(dot(normal, light_pos), 0.0);

vec3 color = diffuse * texture2D(color_texture, gl_TexCoord[0].st).rgb;

// Set the output color of our current pixel
gl_FragColor = vec4(color, 1.0);
}

I have tried something:

struct fsOutput {
    vec4 color : COLOR;
};

uniform sampler2D detailTexture : TEXUNIT0;
uniform sampler2D bumpTexture : TEXUNIT1;

fsOutput FS_Main(float2 detailCoords : TEXCOORD0,
            float2 bumpCoords: TEXCOORD1)
{

    fsOutput fragm;

    float4 anorm = tex2D(bumpTexture, bumpCoords);
    vec3 normal = normalize(anorm.rgb * 2.0f - 1.0f);
    vec3 light_pos = normalize(vec3(1.0f, 1.0f, 1.5f));
    float diffuse = max(dot(normal, light_pos), 0.0);
    vec3 color = diffuse * texture2D(detailTexture, detailCoords).rgb;
    fragm.color = vec4(color, 1.0f);
    return fragm;
}

But it doesn't work. To debug, I have a function that catches Cg errors, and my program breaks at this point. I have identified the two texture IDs in the main program.
Can you suggest any improvement for this Cg shader?


texts: Using 4096*4096 background image in uinty tk2d

texts: I am new to Unity and I am developing a game using unity its a 2d game i am using tk2d framework. I have a big background image(4096*4096) how can I load this background so only visible part of the background has to be rendered so it wont effect the performance. How can I achive this in unity & tk2d?


texts: How do I find the set of regions that are fully enclosed by a color?

texts:
How do I get all areas surrounded by a certain color in a multidimensional array?

For example, this map has three regions that are fully enclosed by red tiles. They are highlighted enclosed in pink.

I'd want the algorithm to return three regions, with the positions of the tiles inside them.

How can I do this?


texts: Level creation of Rayman Origins type game?

texts:
Does anyone know the technique they used to create their levels (using rayman origin as an example)? I'm strictly speaking of the floors and walls. Doesn't look like tiled based.  What is the workflow that would be needed for a non-tiled based game?  I am trying to implement something like this (below) but I am stuck between two ways of doing it

First: Just have art assets and get/set positions of them, similar to tiled based but the objects would be more detailed (with different positions for the x and y)-seems slightly tedious, I could save the locations to a text file and load it from there.

Second: I have seen an article which I can't find, but the game dev pretty much drew the base level (the walls, floors) and then added a bit of imagery on top of it.  So in the picture below, they would've just drew green ledges and walls, then cover them up with leaf-like assets. - I would really like to implement this option, as I could for example, draw a straight line for a hill, then cover it up with some assets, but the collision would still be the straight line


texts:
So I understand how a game loop works (listenInputs/updateData/redrawInterface) but what I'm struggling with is how am I supposed to equalize rendering? I initially thought I had to make the thread sleep for 16.67 ms (in order to get a 60fps output on the screen) but if a user has a low quality hardware it will slow the game down instead of the traditionnal "frame skip", so I figured out this solution was not valid.
So what I thought was the way to go was (in pseudo-java but langage doesn't really matter):

long start = System.currentTimeMillis();
while(...){
    int tick = Math.round((System.currentTimeMillis() - start) / (1000.0 / 60));
    listenInputs();
    updateData();
    redrawInterface();
}

So now anything graphical such as displaying a looping animation can easily be done by printing the specific image of the whole animation for instance.
Am I right? Or is there a better solution or a way to make this one run better?
But with this technique I will have to re-synchronize it every x ticks otherwise it will shift because 1000.0 / 60 is still not an exact value.


texts: Why when drawing a circle using linerenderer the circle is not complete?

texts:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

[RequireComponent(typeof(LineRenderer))]
public class DrawCircle : MonoBehaviour
{
    [Range(0, 50)]
    public int segments = 50;
    [Range(0, 50)]
    public float xradius = 5;
    [Range(0, 50)]
    public float yradius = 5;
    LineRenderer line;

    void Start()
    {
        line = gameObject.GetComponent<LineRenderer>();

        line.positionCount = (segments + 1);
        line.useWorldSpace = false;

    }

    private void Update()
    {
        CreatePoints();
    }

    void CreatePoints()
    {
        float x;
        float y;
        float z;

        float angle = 20f;

        for (int i = 0; i < (segments + 1); i++)
        {
            x = Mathf.Sin(Mathf.Deg2Rad * angle) * xradius;
            z = Mathf.Cos(Mathf.Deg2Rad * angle) * yradius;

            line.SetPosition(i, new Vector3(x, 0, z));

            angle += (360f / segments);
        }
    }
}

In the screenshot in the left of the circle there is a gap the circle is not perfect completed.


texts: Is it possible to use Java as a scripting language?

texts:
Is it possible to use Java as a scripting language for a C++ engine/game?

I understand that you need to make a binding to the interpreter, but I haven't seen any around.


texts: how to make a onMouseEnter events in xna

texts: I have been trying different things all day to get the answer. What I need is a sound to play one time when I enter a given rectangle I need the sound to fire one time and never fire again until I exit the rectangle.It is easy for me to find out if the mouse is over the rect by using the contains() method but the problem comes when the sound gets played it just keeps looping.I added a check to see if the sound state is not playing and that stops it from just making random noise but it still loops help me obi wan.


texts: Using PyOpenGL, can I rotate raw data rather than the current matrix?

texts:
I'm trying to create a sort of PyOpenGL renderer for the Bullet physics engine, and at the moment I'm rotating my basic cubes with math in Python. However, if I do the math in Python that's going to take more time than doing the math with OpenGL.

OpenGL has the ability to rotate a matrix using glRotatef(), but it only rotates the "current matrix". I'm not really interested in convoluting my render loop with an individual check for each object's rotation and position if I don't have to.

So my question is, is there a way I can, for example, load a matrix of points into OpenGL, rotate this matrix and then read it back and give it to my render loop? Or should I instead look for an alternative 3D math library? (Or for that matter, is running the code in python really all that laggy?)


texts:
I have noticed that BoundingFrustum.Intersects() is a rather slow check in XNA. I am doing only 256 checks per frame and it eats up arround 50-60% of availible time when running at 60fps. This is kind of crazy. I would like to know if anyone else has experienced these types of performance problems with the BoundingFrustum class in XNA? Does anyone suggest I make my own boundingfrustum class/struct?

(One pitfall, when using the BoundingFrustum class, is declaring a new instance of it every frame... for some reason it is a class and not a struct. I am not doing this.)


texts:
When I go down slopes with character controller, if the speed is too high, the character just flies off the slope and lands at the bottom. I want my character to "stick" to the slope rather then just jump of it. I came up with code to do so, but it didn't turn out as I planned. Now the character just slides on the slope when I stop pressing the arrows (not staying at its place on the slope).

Physics.Raycast (transform.position, Vector3.down, out hit);
transform.position = transform.position
                     + new Vector3(0f, distance - hit.distance, 0f);

Thanks for the help, i couldn't figure this out all day.


texts: How can I change the highlighted color of a Unity button when it's clicked?

texts:
I was playing around with buttons in Unity, and I wanted to see if I could change a button's highlighted color every time I clicked on it. I added a script in the same GameObject as a button component, and I had a changeColor function attached to the component's OnClick(). The function was in a ButtonScript class written like this:

public class ButtonScript : MonoBehaviour {
    public Button button;

    public void changeColor() {
        Debug.Log ("Changing highlighed color");
        int r = Random.Range (0, 255);
        int g = Random.Range (0, 255);
        int b = Random.Range (0, 255);
        Color currentColor = button.colors.highlightedColor;
        currentColor.r = r;
        currentColor.g = g;
        currentColor.b = b;
    }
}

I couldn't do button.colors.highlightedColor = new Color(r,g,b); because I got a "Consider storing the value in a temporary variable" error. When I tried a test play and clicked the button multiple times, the highlighted color didn't change. How can I make a function that changes a button's highlighted color when it's clicked, if it's possible?


texts: Prioritizing prefabs in array for procedural generation

texts:
I am trying to create procedural space background with a bunch of sprites of nebulas and stars. I have made few prefabs with different types of sprites attached to them. I have created an array through which game will loop and randomly place different stars on a background.

The question is. I want for example 90% of white stars in the background and 10% of others. I know I can create few loops for each prefab with a different maximum number, but it doesn't look very efficient. Is there any way to prioritize some array items while looping through an array?


texts: How to handle wildly varying rendering hardware / getting baseline

texts:
I've recently started with mobile programming (cross-platform, also with desktop) and am encountering wildly differing hardware performance, in particular with OpenGL and the GPU. I know I'll basically have to adjust my rendering code but I'm uncertain of how to detect performance and what reasonable default settings are.

I notice that certain shader functions are basically free in a desktop implemenation but can be unusable in a mobile device. The problem is I have no way of knowing what features will cause what performance issues on all the devices. So my first issue is that even if I allow configuring options I'm uncertain of which options I have to make configurable. I'm wondering also wheher one just writes one very configurable pipeline, or whether I should have 2 distinct options (high/low).

I'm also unsure of where to set the default. If I set to the poorest performer the graphics will be so minimal that any user with a modern device would dismiss the game. If I set them even at some moderate point, the low end devices will basically become a slide-show. I was thinking perhaps that I just run some benchmarks when the user first installs and randomly guess what works, but I've not see a game do this before.


texts: 2D Game has very bad lag because of one script?

texts:
I am making somewhat of a flappy bird clone (mostly for practice) and everything works fine, but it is just really slow with a low FPS of 13 and a max FPS of 28. Why would this be?

So I ran a check with the unity profiler and it turns out that my MoveLeft script which I am using to reuse my obstacles is taking up 73% of the CPU. I have it attached to each of my 6 prefabs, which include 2 long obstacles and a token (to collect) in middle each. The game works by moving the prefabs along the camera, then moving them back after they pass the camera.

Here is the script:

using UnityEngine;
using System.Collections;

public class MoveLeft : MonoBehaviour
{

    [SerializeField]
    private float _speed = 5f;
    // Update is called once per frame
    void Update()
    {
         transform.Translate(Vector3.left * Time.deltaTime * _speed);
         if (transform.position.x < -15)
         {
             float randomYPosition = UnityEngine.Random.Range(-3, 3);
             transform.position = new Vector3(15, randomYPosition, 0);
         }
     }
}

I really want to fix the lag. What can I do? I am sure this is the script causing it, but without this script my game does not work. Thank you! All help is appreciated!

Hierarchy (objects that I am moving with MoveLeft script. Script only attached to tree parents)

And a scene view that displays colliders found in prefabs

Profiler with information regarding my MoveLeft script


texts: Weird rendering issue when applying lightmap through HLSL

texts:
I have a weird issue when trying to render the lightmaps in my game.

Please see the following screenshots.

Note how the scene looks up close with the lightmaps enabled.

Note how that same part of the scene is now completely blacked out (as well as its surroundings) - this happens gradually as you zoom out.

When I completely disable the lightmap, nothing is blacked out, making me believe its related to the way I apply it with HLSL.

Here's how I my Pixel Shader code looks like:

float4 PS1(VSO input) : COLOR
{
    float4 albedo = (HasAlbedo) ? tex2D(AlbedoSampler, input.UV) * input.Color : input.Color;
    float4 lightmap = (HasLightMap) ? tex2D(LightMapSampler, input.LightMapUV) : float4(1, 1, 1, 1);

    float4 finalColor = float4(albedo.xyz * lightmap.xyz, 1.0f);

    return (HasFog) ? input.FogFactor * finalColor + (1.0 - input.FogFactor) * FogColor : finalColor;
}

Am I doing something wrong in my HLSL? Or is it most likely something else?

For some additional information:

I use SharpDX in combination with C#.
The assets in the screenshots come from the game "Medal of Honor Allied Assault", so my sincere apologies for the Swastika signs if it offends anyone. This scene just happened to show the issue perfectly.


texts: How to justify friendly shopkeeper in the cave of doom among millions of mobs?

texts:
I am exploring the forbidden example cave of doom. I find, among squillions of baddies, a shopkeeper, who just happens to sell stuff inside a deadly cave where nobody goes. Weird. I accidentally cause him to be angry, and he turns out to be more powerful than literally every monster in the game. Messed up.

So here's two questions for you: How can you justify a shopkeeper in the example cave of doom just happening to be there waiting for random adventurers to buy stuff,

and,

Is there a better way to discourage stealing stuff or killing the shop-keep' than just making them pummel you with ridiculous power?

Side note: Bonus points for linking these, explain both why and how he would be down there, in the example cave of doom, surviving without a monster sword or magic to pwn things with, and why it would be a bad idea without him possessing those things, to fight him.


texts: Reference keyboard keys as "justPressed", "pressed", and "justReleased" with SDL in C++

texts:
I'm teaching myself 3D graphics with OpenGL and SDL in C++. I'm at a point where I need to be able to query states of individual keys, like so:

if (InputManager::justPressed(SDLK_UP)) {}
if (InputManager::pressed(SDLK_UP)) {}
if (InputManager::justReleased(SDLK_UP) {}

I'm not sure if I should be using SDL_GetKeyboardState or bool arrays for SDL_Keycode/SDL_Scancode, using states seems to me to be the more correct way. I've implemented this previously using states in C# with XNA (see that here). But I've been unsuccessful trying to replicate that with SDL.

Method 1 - Using SDL_GetKeyboardState

// InputManager stores
Uint8* _curKeys, _oldKeys;

void InputManager::init() {
    _curKeys = SDL_GetKeyboardState(NULL);
    _oldKeys = new Uint8[sizeof(_curKeys)/sizeof(Uint8)];
}

void InputManager::update() {
    memcpy(_oldKeys, _curKeys, sizeof(_curKeys)/sizeof(Uint8)); // this seems to work
    std::copy(std::begin(_curKeys), std::end(_oldKeys), std::begin(_curKeys));
}

bool InputManager::pressed(SDL_Keycode code) {
    return _curKeys[code];
}

bool InputManager::justPressed(SDL_Keycode code) {
    return _curKeys[code] && !_oldKeys[code];
}

bool InputManager::justReleased(SDL_Keycode code) {
    return !_curKeys[code] && _oldKeys[code];
}

In the main loop I update the InputManager instance by copying the current keyboard state and updating the current state. Since I'm relatively new to C++ I'm unsure of exactly the best way to copy the values from _curKeys to _oldKeys without using a for-loop. I can't just set _oldKeys=_curKeys because that just makes _oldKeys point to _curKeys. But memcpy seemed to work.

With this implementation justReleased is constantly true, no matter what key is pressed, and justPressed and pressed are always false.

Method 2 -Array of bools

// SDL_PollEvent() loop
case SDL_KEYDOWN: InputManager::keyDown(//event keycode);
case SDL_KEYUP: InputManager::keyUp(//event keycode);

The keyDown and keyUp functions just set keyArray[keycode] to true and false. In the InputManager update function I once again duplicate of the array, simulating "states". But with this implementation all three functions are always false.

Anyway

I hope that this question wasn't too incoherent, I tried to explain it as best as I could. I've found some forums where people had similar problems, the criticism always was that this kind of functionality isn't needed. I would disagree, a good use case for this would be, for example, a charge-up weapon in a game. At justPressed you start the charge, increment a charge counter while pressed is true, and at justReleased you fire the weapon.

If anyone has any pointers for me (no pun intended :P) that would be awesome.


texts: Solvable mazes that have contained cells

texts:
Is it possible to create a random maze that is solvable and uses a group of cells or single cells that do not depend on the cells around them?

I am using a visual language that uses self contained objects so it’s difficult to tell the other cells/objects what is next to them. I tried using a group of four cells that can only have walls on the right or bottom of the group but it can create areas that are not accessible. The example below has + for the outside border X for walls and 0 for the paths:

Valid groups:

0 X
0 X

and

0 0
X X

A small maze that has paths that are inaccessible

+ + + + + +
+ 0 X 0 0 +
+ 0 X X X +
+ 0 0 0 X +
+ X X 0 X +
+ + + + + +


texts: Creating a frustum for culling in world-space glm matrices

texts:
I need to do frustum culling where the bounding boxes are in world-space to determine which entities get to be updated/drawn. I was trying to use the classic projection/view matrix plane extraction method but it doesn't seem to work with perspective matrices created by GLM. Is this method appropriate for world-space culling? It seems like it would be (takes the eye position into account and the projection matrix shapes the frustum).

I've only looked at the near/far planes extract so far and they're wrong for a frustum sitting at the origin (Both have a c component that's negative which means near and far are facing the same direction). Also, since the d components can't match the near/far clipping values with this method is it wrong for world-space culling?


texts: Understanding Scene Graphs and Graph Edges

texts:
So I'm trying to getting to grips with using Scene graphs and nodes in my code (game coding in C++) and I think I understand the basics of them and how they are used (and I can definitely see the benefits), but I'm coming across the term "Graph Edge" and I can't find any reading material explaining exactly what they are and how they fit in with Scene Graphs/trees/nodes in object hierarchy structures.

If anyone knows of any good material or has their own answer on what graph edges are and how they fit in (in use and implementation) that would be great.

Thanks


texts:
I'm working on the first formation for my game's troops. These should simply stand on land, facing the same direction.

To achieve this, I tried to create offsets towards a pivot-unit, that is approximately the unit in the center of the formation.
The units are (temporary) elements of a squad list withing the Squad class.
I divide the List by 2 and get the closest integer, that should be the pivot point of the formation. Now I generate offsets for all units on the left side (Unit 1 to pivot-1) and right (pivot+1 to last unit) based on the distance/gaps.

This is the code for the line formation. Sadly, the units are only forming a very stange line with no visually detectable system:

int count = (int)(squadMembers.Count / 2);
pivot = squadMembers[count];
center = pivot.transform.position;
switch (type) {
    case FormationType.Line:
        int space = 5;
        for (int i = 0; i < squadMembers.Count; i++) {
            Unit tmp = squadMembers[i];
            int dist = 0;
            if (i > count) {
                dist = (count + 1) * space;
                center.x -= dist;
            }
            if (i < count) {
                dist = (count - 1) * space;
                center.x += dist;
            }
            tmp.StartMove(center);
        }
        break;
}

It also appears that this only works along the x axis, any idea how i can realize this with the walking/facing direction ov the pivot?

Is there any (obvious) error? How can I improve this script?

PS: Any idea, how I can transform this into a double line (2 Lines behind with half spacing)


texts: Connecting tiles to make a large image based on text file

texts:
If I am building my level from a text file

0,0,0,0,0
0,1,0,1,0
0,2,1,0,0
0,0,0,0,0

and I want to draw a large image, how do I go about doing that? do I take the image, separate it in tiles (the same size as the other ones) and then add a value to each image

0,1,2,3,4,5,6
0,7,8,9,10,11,12

or is there another way to do this?
Lets say I want to add a house, or a something like this ship?


texts: How should I architect my GUI for my HTML5 canvas cell phone game?

texts:
I'm making a game on the HTML5 canvas and my intent is to run or port this code to work on cell phones.  Right now it only runs on my desktop computer.  I'm trying to write my GUI code but I'm not confident in any of the architectures I come up with so I'm getting stuck in a refactoring loop.

So far I've got a Dialog and a Clickable (basically a button) type.  The Dialog is initialized with a hardcoded list of Clickables .  Whenever the user clicks on a dialog, a function iterates the current Dialog's Clickables to see if any of them were clicked and if so, runs that Clickable's action.  This action can be basically anything.

This all worked for my needs until I needed to make the number of Clickables on a Dialog dynamic depending on the game state.  For example, the inventory dialog.  This is a grid and each cell may contain an item.  Is every cell a Clickable, or only cells with an item?  When are these dynamic Clickables created?  Who creates them and where?

Also consider the level chooser dialog.  It should contain a list of levels you can play. The more levels you beat the more Clickables on this screen.  This screen will probably be scrollable.  Keeping track of where the user clicked when the window may be scrolled is blowing my mind.

I feel like any decision I make will paint me into a corner later.  I've never done this before so I'm looking for some advice from seasoned veterans.  Thanks

BTW, I've looked around the site for other similar questions.  They seem to be asking, "How do I do this in C++ w/ a library".  Here I'm asking how to design it by hand.


texts:
I can't seem to find a nice explanation of the Data Oriented Design for a generic zombie game (it's just an example, pretty common example).

Could you make an example of the Data Oriented Design on creating a generic zombie class? Is the following good?

Zombie list class:

class ZombieList {
    GLuint vbo; // generic zombie vertex model
    std::vector<color>;    // object default color
    std::vector<texture>;  // objects textures
    std::vector<vector3D>; // objects positions
public:
    unsigned int create(); // return object id
    void move(unsigned int objId, vector3D offset);
    void rotate(unsigned int objId, float angle);
    void setColor(unsigned int objId, color c);
    void setPosition(unsigned int objId, color c);
    void setTexture(unsigned int, unsigned int);
    ...
    void update(Player*); // move towards player, attack if near
}

Example:

Player p;

Zombielist zl;
unsigned int first = zl.create();
zl.setPosition(first, vector3D(50, 50));
zl.setTexture(first, texture("zombie1.png"));
...

while (running) { // main loop
    ...
    zl.update(&p);
    zl.draw(); // draw every zombie
}

Or would creating a generic World container that contains every action from bite(zombieId, playerId) to moveTo(playerId, vector) to createPlayer() to shoot(playerId, vector) to face(radians)/face(vector); and contains:

std::vector<zombie>
std::vector<player>
...
std::vector<mapchunk>
...
std::vector<vbobufferid> player_run_animation;
...

be a good example?

Whats the proper way to organize a game with DOD?


texts: How should we approach publishing our game from India?

texts:
Me and my friends are developing a game using Java for Windows operating system. We have nearly completed our game. As we feel that the game can make money, we wish to sell it. But in India we don't know any game publishing company.
We want to know the following if possible.
Will game publishers like BigFishGames.com publish our game even though we are not in USA?
We are just students in college. Is it required that we can sell only after we start a company?
Is it possible to sign contracts if the publisher wishes to publish our game, while the publisher and developer are in different countries?
Thank you


texts:
So, I am trying to make a simple GUI Instantiate system. The GUI is going to spawn successfully, but the position is wrong.

Position : (Left, Right: 249.8423 ; Top, Bottom : 400)
Anchors : (Min: X:0 Y:0 ; Max: X:1 Y:1)
Pivots : (X:0.5 Y:0.5)
Rotation : (X:0 Y:0 Z:0)
Scale : (X:1 Y:1 Z:1) always...

My Code :

    GUIPausePopup pause = UI.Create<GUIPausePopup>(GameObject.Find("Canvas"));
    //Spawn and set parent(Canvas)
    pause.GetComponent<Transform>().gameObject.SetActive(true);
    //Working without any issues.

    //Position system not work. I don't know why.
    pause.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(0f, 0f, 0f);
    pause.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f);
    pause.GetComponent<RectTransform>().localPosition = new Vector3(0f, 0f, 0f);
    pause.GetComponent<RectTransform>().position = new Vector3(0f, 0f, 0f);
    pause.transform.position = new Vector3(0f, 0f, 0f);
    pause.transform.localPosition = new Vector3(0f, 0f, 0f);

Thanks for help...


texts: What size textures do I need for a 2D grid based game if my tiles are larger than textures I have?

texts:
I'm building a grid-based game for iPad, and for usability purposes I've selected my game grid to be built of 75x75 squares. However, so far I've seen that the majority of (free)texture catalogs I can find are either 16x16 or 32x32.

Currently I have the graphics engine stretch the 32x32 texture onto a 75x75 tile, which does not look very sharp.

How can I make my game look good -  do I need to create textures whose size is equal to my game tile? Should I try to stitch multiple textures together (like 4 texture squares per game square)?


texts: Is it possible to render part of the screen in different pixel density using openGL?

texts: Say I have an openGL screen and I want to render part of the screen in different pixel density than the whole screen pixel density. Is it possible and if possible how?


texts:
How can I move an object the fastest way?
What I'm trying to do is to make an object pass by at speed that you almost cannot see - like an airplane that moves from side to side in very high speed.
Here is my code:
transform.position = Vector3.MoveTowards(transform.position,
            stopPoint, Time.deltaTime * ms);


texts: Player must places the object in the preset position

texts:
I want to know how to do like this video:
https://youtu.be/6gouxqSxeG8
At the minute 3:09, the player can put the street vendor in the predetermined location (with the green arrow show that place).

Please tell me some keyword about this or video tutorial about how to implement it in unity 2d.

Thanks.


texts:
I am developing a gaming control panel and that uses Rcon.jar to fetch data from gaming server.

the code to use it written as below

public static String rconExecute(String rcon, String command, int port, String ip) throws SocketTimeoutException{
        String response = "";
        try {

            response = Rcon.send(27778, ip, port, rcon, command);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return response;
    }

this throws an error when run using site but when done using local application like

public class RconTest {

    public static void main(String args[]) throws SocketTimeoutException, BadRcon, ResponseEmpty{
        String response = Rcon.send(27778, "59.177.45.13", 27015, "123", "status");
        System.out.println(response);
    }
}

it works fine any reason why?

the error is :java.net.SocketTimeoutException: Receive timed out


texts: What do you think about Ogre3d as first time engine for first time 3d Game?

texts:
This is a question for the experienced 3d game developers.

I'm a long time programmer (c++/java), and after 15 years, I'd like to get into 3d gaming.

After some internet research, I saw that the trend is mostly with Ogre as a 3d engine.

What do you think? I'll be targeting OSX, Linux and Windows.


texts: Unity3D -- WAV plays an octave too low on Android

texts:
I have generated a synthetic 'concert pitch A' tone from sinewaves.

It plays properly on OS X player, and on my Android device.

Now I record myself singing a 'concert pitch A' into the microphone as a MONO .WAV -- foo.wav.

In Unity I add foo.wav to my resources, making sure to turn off "is 3D sound" in the settings panel.

I then create a script that loads it into an audioclip and extracts the contents into a float buffer:

    AudioSettings.outputSampleRate = 44100; // just to be safe

    AudioClip phonemeClip = Resources.Load( filename ) as AudioClip;

    float [] phonemeBuf = new float[ phonemeClip.samples * phonemeClip.channels ];

    phonemeClip.GetData( phonemeBuf, 0 );

I then add this sound to my synthetic tone, 30000 samples in (so nearly 1 second):

    float PHONEME_VOL = 0.3f;
    int OFFSET = 30000;

    for(int i=0; i<phonemeBuf.Length; i++)
        if( OFFSET+i < buf.Length )
            buf[OFFSET+i] += phonemeBuf[i] * PHONEME_VOL;

On OSX player this works perfectly.

However on my android device the original synthetic tone plays correctly whereas the added foo.wav appears to be exactly an octave low.

What might be causing this?

I suspect it may be converting the clip into a stereo clip, with 0 for the right channel. That would interpolate the resultant float buffer with zeros, which would certainly take it down octave.

But I can't see how to address this problem.


texts: App Programming Question: Converting Code and Project Folders for the Smartphone's OS Compatibility

texts:
I was thinking about how does the Angry Bird game for the iOS successfully converted into an Android compatible version. Does it involve using Phonegap or something?

When making games for iOS, the programmer preferred XCode. For Android game app, the programmer preferred Eclipse IDE and a LibGDX engine library. Because of this, like Angry Birds for example, this game became compatible for the iOS, Android, and even on the desktop computer.

The question is...how does it work?


texts:
I have my code, for my weapon:

using UnityEngine;
using System.Collections;

public class Arma : MonoBehaviour {

    public static int municao;
    GameObject bullet;
    GUIText texto;
    // Use this for initialization
    void Start ()
    {

        //bullet = GameObject.Find("Bullet");
        municao = 10;
        texto = GameObject.Find ("qtdMunicao").GetComponent<GUIText>() as GUIText;
    }

    // Update is called once per frame
    void Update () {

        texto.text = municao.ToString ();

        if(Input.GetKeyDown("i"))
        {
            if(municao > 0)
            {
                Instantiate(bullet, transform.position, transform.rotation);
                municao--;
            }
        }
    }
}

`

How can i load the prefab to my variable to use in my instantiate?


texts: What tools are available for creating 3D collision and pathfinding data?

texts:
What is the process of creating geometry data to assist on NPCs movements and such on a 3D world to avoiding having them from going through the ground, etc? Are there specific modelling programs that can create the world and the collision geometry to be used?

The map I made has caves, lakes with deep water, varying terrains heights, mountains, etc.


texts: Can a Unity button detect a tap AND send that tap through to objects below it?

texts:
I'm trying to make a "highlight frame," like a flashing box around a button for use in the game's tutorial. When the frame is tapped, I'd like it to register the tap (so the frame can be dismissed) but ALSO allow the button underneath to register the same tap (so that button's action is triggered.)

Is this possible? For a button to "detect a raycast without blocking a raycast," or something similar?

I could just have the button's action dismiss any highlight frames that exist, but that would entail putting "dismiss frame if exists" statements all over the place in my code. It would be much neater just to have the frame be a button which dismisses itself, without blocking the interaction with whatever it's highlighting.

Is there a way to accomplish this?


texts: Delta compressed world state when networking in JavaScript

texts:
Lets say we send a snapshot from the server to the clients about world details, containing object positions, velocities etc, every second. We should send only delta-data based on the previous snapshot that was sent.

For example, if the player moved from (x:50, y:0) to (x:100, y:0), then the snapshot will only contain (move_x:50: move_y:0), and the clients will add the previous position and move_x. We should sending delta values, as it is less data to send.

How do I achieve this in Javascript?

My objects already have data stored in Float32 (by TypedArray) and there is no Float16 data type in JavaScript.

For example:

delta = currentPos - prevPos
20 = 100 - 80

okey, now I have 20 instead of 80, but this isn't less data to send.. still both will be send as Float32.

data.writeFloat32(delta); //for simplesness

there is no Float16 and I am afraid that even if JS will has Float16 TypedArrays, then it still would be not enough, because for example 20.3454356 from Float32 to Float16 will lose precision to lets say sth like 20.34, or I'm wrong?

How to send delta data in JS and gain the benefits of this technique in JS?


texts:
If you have a stationary circle with radius x, and a moving circle with radius y, when a collision is detected, how can you resolve the collision, such that the moving circle stop?

I.e. What would be the 'resolved' position of the moving circle?


texts: Unity or Monogame or Gamemaker 2 for an experienced application developer?

texts:
So i know this question has been hammered down several times but please bear with me.

I used to be a C# .Net application developer but i am no longer employed, i am pretty good at C#.

I want to get into serious game development and i dunno where to start, i used to work with unity occasionally which is a very little and i kinda find it clunky, like it works but somehow it does not feel right and feels kinda clunky. But it works with tiled map editor without much of a hassle.

I Remember using Game maker studio when i was back in college and i found it  very good, its a breeze to work with and even have its own tiled map editor, even seems to have some good tutorials, the only con is its price.

I was initially inclined towards Monogame cause of my C# background, but i neither have time nor money and resources to support me for long enough time to be able to code every single thing from scratch and i am kinda in a pretty bad situation overall right now. It just takes too much time to do anything even to make it work with a tiled map editor, and there are very few tutorials or documentation to start with.

It seems like the only option for me is Unity at the moment, cause of ease of access and how easy it is to work with tiled map editor and lots of tutorials.

which one do you guys think is good overall?

Please keep in mind that i am currently unemployed and have very little resources to support myself, and i am a programmer so i don't even know how to compose music and do art for the game and i'd prefer if it provides some asserts to be used so i wont waste time in learning stuff when i cannot afford to spend time.

I will eventually learn them but not now, its not happening now so i prefer something that comes with some sorta free asserts that can be used (mainly music and art), I mean does it even matter if all i am trying to do is earn a decent minimum living?

I just want to make simple 2D NES/Snes style games with multiplayer support.

Thank you.


texts: Is knowledge of hacking mechanisms required for an MMO?

texts:
Say I was planning on, in the future (not now! There is alot I need to learn first) looking to participating in a group project that was going to make a massively multiplayer online game (mmo), and my job would be the networking portion. I'm not that familiar with network programming (I've read a very basic book on PHP, MYSQL and I messed around a bit with WAMP).

In the course of my studying of PHP and MYSQL, should I look into hacking? Hacking as in port scanning, router hacking, etc. In MMOs people are always trying to cheat, bots and such, but the worst scenario would be having someone hack the databases. This is just my conception of this, I really don't know. I do however understand networking fairly well, like subnetting/ports/IP's (local/global)/etc.

In your professional opinion, (If you understand the topic, enlighten me) Should I learn about these things in order to counter the possibility of this happening?

Also, out of the things I mentioned (port scanning, router hacking) Is there anything else that pertains to hacking that I should look into? I'm not too familiar with the malicious/Security aspects of Networking.

And a note: I'm not some kid trying to learn how to hack. I just want to learn as much as possible before I go to college, and I really need to know if I need to study this or not.


texts:
I am currently developing a Breakout game for a school project, and I've decided to use it as an opportunity to get started with procedural content generation. I took a quick look at some of the basic procedural stuff, but I wanted to know if there is a known good method to generate levels for this kind of game (block patterns, "power up" distribution, etc).
Any articles or ideas are greatly appreciated.


texts:
I am very new to Cocos2d programming and was thinking to build up my first app. I learnt some basics related to CCMenu and CCMenuItems. But I was wondering whether I could provide animations in such a way that every CCMenuItem would animate first and then appear in the CCMenu. Will that be possible in Cocos2d? Can I get some tutorials or samples regarding this?

Thanks.


texts: How do I discourage "loot from party members who are about to leave" behavior?

texts:
In my RPG, I have companion characters that can potentially leave the party. A behavior I have witnessed among testers is something that I think many RPGs deal with, namely that players will strip the party members of all equipment before they leave the party. For instance:

One tester removed all gear from a companion, then talked to them and chose the "I want you to leave" dialogue option.
Another tester saw that a companion was removed from the party via a scripted event, then loaded to an earlier save, stripped the gear from the companion, then re-played the scripted event.

I want to avoid this behavior because it encourages meta-gaming/save-scumming and breaks immersion. If this were a real life group of medieval adventurers, one of the group members wouldn't be ordered to strip down to their underwear moments before being ambushed and captured.

I don't want gear to be "stuck" on a character so that it can never be upgraded (I once played an RPG where I was frustrated that my companion had mediocre armor, but I wasn't permitted to swap it for superior armor I found later).

Is there any way that I can get the best of both worlds by allowing character equipment to be improved, while preventing (or at least limiting the incentive) to meta-game/save-scum and loot characters who are about to leave?


texts: Issuing one-to-one inter-player challenges

texts:
I have a small game I have written in Unity (at present only for Android). It is a very simple game where you get more points the longer you last. Nothing complicated.

In order to help "spread the word," I want to enable players to challenge others to see who can score higher. I am not talking about their all-time high scores (these I save in the Google Game Play leaderboards).

How can I easily manage a one-to-one challenge?

I can't seem to find a straight forward way to do it using the Google SDK.
It has the turn based play option but in my case each one plays separately. When both have played, the results get compared.

Short of setting up my own backend, how can I go about this?

Note: I am happy to use the FB SDK if necessary since that is how the challenges will be generally sent.


texts:
We need to make a zombie videogame for a semester project and I was wondering about what are considered nice algorithms/techniques for implementing zombie AI that don't take too long to implement.

The project is a videogame product, involving other stuff as physics and multiplayer, so we have limited time, so what I'm specifically looking for is:

A quick & dirty way to implement zombie AI (I'm thinking on neural networks or perhaps even fuzzy logic)
Common ways of implementing and optimizing zombie AI
The ideal way of implementing zombie AI (I imagine it would involve pathfinding, or even swarm intelligence?)
General advice on zombie AI

Considering that the quick & dirty implementation would perhaps be a place-holder for another and better algorithm/technique.

Thanks in advance.


texts: How to move the player while also allowing forces to affect it

texts:
For now, that's how I move the player:

rb.velocity = Vector2.right * input.x;

And I affect him a force while he is damaged by an entity:

rb.AddForce(Vector2.right * force);

It works fine, until I try to move while I'm damaged by an entity.
Since my velocity = input.x while I move, I can't affect any forces to it.
I've tried to summarize velocity:

rb.velocity+=Vector2.right * input.x;

But then I need to clamp the speed and if I clamp it, my force which is affected to player is also clamped.

How can I resolve this problem?


texts: How do I zoom in using the App version of Twine?

texts: How do I zoom in using this program in Windows 10?


texts: Betatesting an android game. Best practices?

texts:
Our game is in our final stage prior to be released. I would like at this stage to add some beta testers to let them hunt bugs, etc... Is there any good platform/site to achieve this? I have noticed there's a site called betalizer but they still are in beta.

Could anyone suggest how to find beta testers for a little-medium size android game without spending a lot of bucks or any platform that could help on it?

Thanks in advance.


texts: D3DCompileFromFile() failed, gives an error HRESULT

texts:
i'm reading the "3D game programming with directx 11 " book (Frank Luna) and i'm struggling becouse he uses the old D3DX11CompileFromFile() method, which can't be used anymore. So i searched on internet how to solve this problem and i found out i have to use D3DCompileFromFile instead, which is a little bit different, but not totally. Now this is my script

DWORD flags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_DEBUG;
    ID3DBlob*compiledShader = nullptr;
    ID3DBlob*compilationMsgs = nullptr;

    HRESULT hr = D3DCompileFromFile(L"FX/effects.fx", 0, 0, 0, "fx_5_0", flags, 0,  &compiledShader, &compilationMsgs);

    if (FAILED(hr))
        MessageBox(0, L"Failed D3DCompileFromFile", 0, 0);  //THIS POPS OUT

I did this by myself and than i started copying things from internet to make it work. Could the problem be in entryPoint=0? What do i have to put there?
This is the effect.fx file

cbuffer cbPerObject
{
    float4x4 gWorldViewProj;
};
struct VertexIn
{   float3 Pos : POSITION;
    float4 Color : COLOR;
};

struct VertexOut {
    float4 PosH : SV_POSITION;
    float4 Color : COLOR;
};
VertexOut VS(VertexIn vin) {
    VertexOut vout; // Transform to homogeneous clip space.
    vout.PosH = mul(float4(vin.Pos, 1.0f), gWorldViewProj); // Just pass vertex color into the pixel shader.
    vout.Color = vin.Color; return vout; }

float4 PS(VertexOut pin) : SV_Target {
    return pin.Color;
}
technique11 ColorTech {
    pass P0 {
        SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetPixelShader( CompileShader( ps_5_0, PS() ) );
    }
}

float3 iPosL; // local space
float3 gEyePosW; // world space
float3 normalV; // view space
float4 posH; // homogeneous clip spac

Thanks


texts: What is a reasonable bandwidth usage for a RT multiplayer game?

texts:
My game uses UDP communication only.
Meaning: after the lobby connect (performed by Google Play Services), not a single TCP transmission is made. Only unreliable messages are used.

The game is currently one versus one, and the players transmit a little over 16Kbit/sec in datagrams in a steady stream. (2 kbyte/sec.)
It also receives the same steady 16kbit/sec from the other party of course.
These numbers do not include packet headers.

The player experience is pretty good, even with players between continents.

What I would like to know: is 16Kbit/sec considered normal, high or low?

I intend to add a 2vs2 mode, which would triple both the send and receive network volume. Could I get away with that? Where can I find references to typical bandwidth use in real time games?


texts: When should I extrapolate and when should I interpolate?

texts: I'm having trouble understanding when to extrapolate and when to interpolate. In gaffer on games, he said to interpolate but then in another article it recommended extrapolating the player. So my question is when is it better to extrapolate and when is it better to interpolate?


texts: How to move the object(tanker ) on slope image in chipmunk Spacemanager

texts:
I have used one polygon shape image (terrain)in my game its just like mountain and now i want to move the tanker on mountain path from one direction to other and then its turn on touching of the screne and move back and move like this continuously, i am not getting the method to move the tanker on slope(image) path in chipmunk spacemanager.

b.when collision detection happen like that if any bomb will fall on slope(image of mountain) then i want little damage on slope(image of mountain) like this video i want to please see this video for more details.

http://www.youtube.com/watch?v=vleq3Wa_jZs

i have used this code but my object(tanker) is following terrain path with rotation i want to just move like tanker moving and follow terrain path.

-(void)AddWheel
{
    cpShape *localPlayerShape;
    cpCCSprite *localPlayerSprite;

    localPlayerShape = [mySpaceManager  addCircleAt:[self GetStartingWheelPosition] mass:2 radius:7];
    localPlayerSprite = [cpCCSprite spriteWithFile:@"enemy1.png"];

    localPlayerSprite.shape=localPlayerShape;

    localPlayerSprite.shape->group=kItemIsPartOfTheTankGroup;
    localPlayerSprite.shape->collision_type=kItemIsPartOfTheTankGroup;

    localPlayerSprite.shape->u=4.5;

    localPlayerSprite.tag=100;

    [mySpriteLayer addChild:localPlayerSprite z:15];
}

Thank waiting for you all reply .


texts: Machine learning to improve strategy game AI

texts:
I am currently working on a simple strategy game as a hobby and I am starting to think about designing an AI to add opponents in the game. The idea behind the game is that you are a space explorer and that you have to achieve the highest possible score. Your score is the sum of the total number of planets you have explored + the length of time you have managed to keep the game going. Each planet that you explore gives you some resources points which decay with time and a fixed expense which remains constant over time and is discounted from your resource point pool every Unit of Time. As you can see if you don't explore fast enough then you will eventually run out of resource points, which is when the game stops.

I am now looking into adding an AI and I was wondering if it wouldn't be easier to use machine learning algorithms than code an whole AI entirely based on conditionals.

My idea was to record the player's activity every X amount of time as well as the current state of some game variables.

So I would have something like :

actions = {0 : nothing, 1: move, 2: explore, 3: search, etc ... }

And then I would record variables such as:

 variables = [ time_since_last_action, resource_pts, knowledge_pts, number_of_discovered_planets, number_of_explored_planets, time_in_game, current_expenses, current_resource_income, current_knowledge_income, current_active_events, etc...]

Then I would use some machine learning algo (as a black box) to find a relationship between game variables and actions to make. I would also record the final score at the end of each game so that the AI learns more from successful games than unsuccessful ones (or even better set a score threshold above which to send the data to the AI).

I am also thinking that by maybe feeding two different AI's with different data over a few games I could then let them teach one another.

And finally, since I am not quite sure myself what the optimal game strategy should be maybe I could get some valuable information out of the process (eg: how does each variable affects the action outcome, or the overall score).

I'm thinking that since my game is relatively simple that could be a good opportunity to get into machine learning as well (since I am also doing this project to learn).

Any thoughts or directions towards interesting resources /tutorials would be very welcome.


texts:
Now I finished my 2d game but when I set up it in my mobile it becomes like this so I change some scripts in Maincamera but it's still the same

How can I change the screen to become horizontal in my mobile like this?

what I need that how can I make it fit my mobile screen.


texts:
I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite drifts away from the point its intended to stay in.
The code I'm currently using is as follows, and I'm pretty sure there's something wrong with it, I just don't know what it is.

rad = sqrt((x-originx)^2 + (y-originy)^2)
x = originx + cos(cameraangle+asin(x-originx)) * rad)
y = originy + (sin(cameraangle+acos(y-originy)) * rad)


texts: Dealing with AI in a simple strategy game

texts:
Hi I am currently working on a small real-time strategy game.

The game consists in discovering and exploring planets to get knowledge and resource points. Every Unit of Time (UoT) in the game those points are adjusted based on a various factors. Basically the more planets you have explored the more points are generated, yet the more planets you get the greater the expenses per UoT, so it is a balance. There are a variety of planet types, some which allow to discover planets in a greater area, but produce little points, whilst others produce a lot of points. The longer the players lasts before running out of resource points and the more planets they explore the higher their score is.

I kind of got a decent game at the moment, but I wanted to add an AI to have other explorers competing against the player. I don't really know how to handle it.

So far my thoughts are to add weights to various parameters (like the number of points provided by each planet, the cost in points to explore it, the fact that it has been already explored, etc...). Those weights would be adjusted based on a variety of conditions, say if the player resource points drop below x then the weight attributed to the number of resource points provided would be greater than that of knowledge points.

I was wondering if anyone had any thoughts on this, is it likely that I'm going to get myself tangled in all of it if I do it this way.

Also one important thing to note is that the game space is randomly generated, i.e every time a UoT passes or an explorer explores a planet there is a chance that 2 new planets are being randomly generated. Which means I can't really use methods which are based on calculating a few turns ahead to make the best decision.

Finally, the game is relatively peaceful, I don't have a combat system, and the only risk of exploring a planet already explored by another explorer would be that, if that explorer is nearby, he might just re-explore it as soon as you have left meaning you have spent valuable resource points for no benefits, since all the point generation will go to the most recent explorer.


texts: Problem with Input.GetKeyDown to set a counter in Unity: multiple values in only one pressing

texts:
Using Unity 5, I want to use have one keyboard key ("f") increase a counter when pressed. It means, using Input.GetKeyDown("f") function in a way that: if "f" is pressed when the counter=1, then the counter is set to be equal 2. If counter was equal 2 when "f" is pressed, then counter is set to 3.

However, it does not work properly: it seems that Unity detects the key being pressed many times, no matter if it was only pressed once. See the code that illustrates the situation:

using UnityEngine;
using System.Collections;

public class TestingKeyGetRecursion : MonoBehaviour {

int counter = 1;

void Update () {

    if(counter == 1 && Input.GetKeyDown("f"))
    {
        counter = 2;
        Debug.Log(counter);
    }
    if(counter == 2 && Input.GetKeyDown("f"))
    {
        counter = 3;
        Debug.Log(counter);
    }
    if(counter == 3 && Input.GetKeyDown("f"))
    {
        counter = 1;
        Debug.Log(counter);
    }
}

void OnGUI()
{
    GUI.Label(new Rect(30, 10, 250, 20),  "counter: " + counter.ToString());
}
}

As you can see in the console if you run the above example, the values are properly set into the counter variable and printed in the console. However, it happens several times in the same key-hit and, in the end, the counter ends up equal as it started, i.e. equal 1.

Can anyone please explain:

1) why does the Engine behave like that;

2) is there a way to solve such situation? I cannot substitute the counter with a bool variable and just do "counter != counter" when "f" is pressed.


texts: How to detect screen boundary using AndEngine GLES1?

texts:
I am using the AnalogOnScreenControl to move my sprite around the screen. I would like to restrict the sprite so it can not move outside the screen boundaries.

I have tried putting a line at the top of the screen and checking collisions between the sprite and the line, but the effect is that the sprite sticks to the top line.  It does not move at that point.  So I tried the onAccelerometerChanged() method as an alternative, but that also doesn't work.

How do I detect the screen boundary and prevent the sprite from going beyond it?


texts:
The problem described below is a follow-up of Seamless tilemap rendering (borderless adjacent images).

I'm not sure to fully understand the rendering issue I have, so I'll try to describe as much as I can.

I had "seams" when rendering a tile map of tiles of 16px by 16px, more precisely I was seeing the following:

I followed the recommendations describes in this answer. It solved entirely the previous problem. However I now have the following rendering issue:

As you can see, everything is blurry.

I have also tried to do what is recommended in this answer, but it didn't change anything. I got the exact same output.

Last note, this is not always visible. When changing the position and scale of the camera, the rendering can end-up being correct. This is quite random though.

If you are interested in seeing some code, please have a look on the following links:

This gives you a rough idea of the pipeline executed
This is where the texture coordinates are generated
This is where the buffers are instantiated
This is the fragment shader
This is the vertex shader

If you think you need more details, please feel free to ask me.


texts: Partially observable game map — is A* appropriate?

texts:
I know very little about game development and I'm trying to wrap my head around pathfinding algorithms.

Consider this setup: an agent is on a 2D map and must find the shortest path to a globally know object but only has information about obstacles in his local vision scope (ie. only immediate obstacles are known, the general layout of the map is unknown).

Also, every move to an adjacent square is expensive and the pathfinding algorithm should minimize the number of moves.

Computational efficiency is also of utmost importance and more important than accuracy.

Is A* appropriate for this use-case?


texts: Easy SpriteKit question on creating a function

texts:
The following code is what I'm working on to animate characters in a SK scene class. I can run the code without building, no problem, but I can't build it and run it; I get one error message: Binary operator '+=' cannot be applied to operands of type '[(SKTexture)]' and '[SKTexture!}'.
The code is below:

func initStoryBegin() {
    let CaitAtlas = SKTextureAtlas(named: "cait")
    let DrewAtlas = SKTextureAtlas(named: "drew")

    CwalkAnimation = self.animateSheet(CaitAtlas, walkAnimation: CwalkAnimation, formattedword: "cait%01d")

}
// ***This is where I am having trouble. In the walkAnimation += line.
func animateSheet(nameAtlas: SKTextureAtlas!, walkAnimation: [(SKTexture)], formattedword: String) -> [SKTexture] {
    for index in 1...nameAtlas.textureNames.count {
        let imgName = String(format: formattedword, index)
        walkAnimation += [nameAtlas.textureNamed(imgName)]
        println(walkAnimation)
        return walkAnimation
    }
}

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    let charNode = self.childNodeWithName("charNode")

    if (charNode != nil) {
        let animation = SKAction.animateWithTextures(CwalkAnimation, timePerFrame: 0.2)

    charNode?.runAction(animation)

    }
}

I can't figure out why the code works when I run it, but it doesn't work when I try to build and run? Any help would be greatly appreciated.


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

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

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

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

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


texts: Mismatch cordinate system of unity and android

texts:
I am new to unity3d, Right now i am adding a cube as game object with coordinate 0,0,0 But when i run it on android device Iam facing 2 problem a) Coordinate system of unity3d are different from coordinate system of device, For device top left is 0,0 but for unity center of the screen is 0,0. How to fix that mismatch or i need to multiply with some factor to make it work.

b) Iam moving the object on x-axis this is what iam doing for moving object on x-axis

if(xback){
     xaxis+=(2*Time.deltaTime);
     if(xaxis >Screen.width/2){
      xback = false;
      }
     }
else if(!xback){
     xaxis-=(2*Time.deltaTime);
     if(xaxis<=-(Screen.width/2)){
      xback = true;
  }
 }

Vector2 temp = transform.position;
temp.x = xaxis;
temp.y = yaxis;
transform.position = temp;

But the problem iam facing is as soon as my xaxis equals 9 it touches the right of screen and then it get out of screen, so iam little bit confuse is unity3d pixel system is different from the one on device, because iam moving the cube by one pixel every time but movement is not equal to 1 pixel of device. so i want to know is pixel system of unity is different from pixel system of android or iam doing something wrong.


texts: Why "polar angle" should be restricted to the range of [0,PI] when moving camera?

texts:
In the sample code d3d12book-master\Chapter 6 Drawing in Direct3D\Box\BoxApp.cpp of "Introduction to 3D Game Programming with DirectX12 : Frank D. Luna", the camera position is modified via three variables mTheta for the azimuthal angle, mPhi for the polar angle, and mRadius, in the mouse move event handler.

As shown in the code, there is not any restriction to mTheta. However, mPhi is restricted to [0,PI]; if the restriction is commented out, the image changes suddenly at the boundaries of [0,PI]. Could you help to comment the reasoning behind such restriction ? Is it possible to see a continuous rotation of camera across the boundaries of [0,PI] ? O_O

initialized to certain values in world space in constructor

    XMFLOAT4X4 mWorld = MathHelper::Identity4x4();
    XMFLOAT4X4 mView = MathHelper::Identity4x4();
    XMFLOAT4X4 mProj = MathHelper::Identity4x4();

    float mTheta = 1.5f*XM_PI;
    float mPhi = XM_PIDIV4;
    float mRadius = 5.0f;

modified in mouse move

void BoxApp::OnMouseMove(WPARAM btnState, int x, int y)
{
    if((btnState & MK_LBUTTON) != 0)
    {
        // Make each pixel correspond to a quarter of a degree.
        float dx = XMConvertToRadians(0.25f*static_cast<float>(x - mLastMousePos.x));
        float dy = XMConvertToRadians(0.25f*static_cast<float>(y - mLastMousePos.y));

        // Update angles based on input to orbit camera around box.
        mTheta += dx;
        mPhi += dy;

        // Restrict the angle mPhi.
        mPhi = MathHelper::Clamp(mPhi, 0.1f, MathHelper::Pi - 0.1f);
    }

    mLastMousePos.x = x;
    mLastMousePos.y = y;
}

used to update camera postion

void BoxApp::Update(const GameTimer& gt)
{
    // Convert Spherical to Cartesian coordinates.
    float x = mRadius*sinf(mPhi)*cosf(mTheta);
    float z = mRadius*sinf(mPhi)*sinf(mTheta);
    float y = mRadius*cosf(mPhi);

    // Build the view matrix.
    XMVECTOR pos = XMVectorSet(x, y, z, 1.0f);
    XMVECTOR target = XMVectorZero();
    XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);

    XMMATRIX view = XMMatrixLookAtLH(pos, target, up);
    XMStoreFloat4x4(&mView, view);

    XMMATRIX world = XMLoadFloat4x4(&mWorld);
    XMMATRIX proj = XMLoadFloat4x4(&mProj);
    XMMATRIX worldViewProj = world*view*proj;

    // Update the constant buffer with the latest worldViewProj matrix.
    ObjectConstants objConstants;
    XMStoreFloat4x4(&objConstants.WorldViewProj, XMMatrixTranspose(worldViewProj));
    mObjectCB->CopyData(0, objConstants);
}


texts:
In a game that I'm working on, any player has (at max) 460 items within their inventory. Each item has simple attributes, such as owner and quantity, but equips have different attributes, such as strength, dexterity, luck, intelligence, speed enhancement, jump enhancement, etc.. To save all the items, I have a column in a MySQL table for every item (meaning that equips also are categorized as items), and another table for extra equipment data.

The player has the ability to change the stats of any item, via obtaining more of a certain item, removing some of the items they have, scrolling an item to change its stats, and so on.

What I'm trying to figure out is - what's the best method to save all this information? Currently, what I do is delete all items that the player owns within the item table (which the equip table is linked to, so those entries get deleted too), and then insert the items that the player has. The issue with that is that there's a very high chance of players losing their items in the event of the server crashing, and it seems kinda odd to be deleting entries.

My new proposed method is to set a flag within each item's instance, and (for example), if the flag is 0, the item has not changed and does not need to be resaved, if it's 1 then some attribute has changed and needs resaving, and if it's 2, the item needs to be deleted from the database. I'm not sure if this is any better though.

Additionally, how often should I be saving the items? Right now it's done after important events (like quest completion), but what about saving on a timely basis?


texts:
I've been spending a lot of my time working with libgdx scene 2d & have become very familiar with it. I've decided I want to move over to 3D & take a couple of weeks to learn & better understand the 3D side.

I've gotten a clear understanding of loading 3D objects, camera, & more. Where I'm stuck is deciding which method for loading a terrain is best &/or a decently clear tutorial/snippet on loading a 3D terrain tiled terrain without the use of a height-map & I can learn on my own from there.

A specific terrain in mind is a grid terrain. Similar to the first image w/ multi-texturing (smooth textures - paint effect) similar to the second image.

Places/repositories I have taken into account & have thoroughly taken a look into.

Fabula-Engine (Decent but hastle to understand & get working), gdx-proto (decent but the terrain is created using a meshbuilder & required a full texture (similar to first image), xoppa (didn't cover 3D terrain)

Things I would like to take into account are low polygon count & no usage of a height-map.

Question's Summary:
Is there any tutorials/snippets to help better understand generating tiled/grid maps?
Is the method provided suitable for multi-texture painting similar to the second image?


texts: How to handle scaled aspect ratio multiplayer player coordinates

texts:
I'm building a cross platform multiplayer game. I'm using pixel graphics and starting at a small 256x144 16:9 aspect ratio That gets scaled up to larger 16:9 resolutions. The graphics look ok however the movement is off. I'm publishing the players x,y coordinates and having other clients subscribe and render the entity based on these. This works in the case of same resolution clients however if the client is at a different scale the movement is off. It does seem consistent though when moving to a 0,0 position.

I've tried taking the published coordinates and applying the scale of the local client to them which seems more accurate. How can I equalize the coordinates across many clients?


texts: Understanding particle texture rotation / space

texts:
I want to remake a "portal" that I've seen in RE4. It looks like this:

I have observed it, and to me, it looks just like a texture rotating on a cylinder.

To remake this, I thought that I should use a Particle System.

First question: Is that a good choice?

In my particle system, I'm using this texture:

I'm also using a cylinder mesh.

I have then set the following settings:

Duration: 1.0
Start lifetime: 1
Emissions Rate over time: 1
Rotation over Lifetime: Separate Axes: Y: 360

It does rotate on the cylinder as expected, but the texture is really strange.
I have no idea in which way it's being used. Therefore I have added the red, blue, green and yellow dots.

As on can see, the spikes come from above as well instead of only from below.
Also, there's a "gap" in that circle:

I thought that it was perhaps caused by the texture tiling, so I played around with that. It didn't really help. Here is a video of my desperate attempt.

Can anybody tell me which pitfall I have stumbled over?

If I can't make the texture fit correctly by tiling and offset, what else could I do to make the texture fit perfectly here?

Edit: This is what the cylinder unwrap looks like. I just used Smart UV Project in Blender:


texts: How do console games avoid port forwarding with user hosted servers?

texts:
On AAA xbox games (Call of duty, etc.), the company acts as a matchmaking service but the users host all of the games. Because not everyone has ports forwarded on their router, how do these games create an accessible server without relying on port forwarding?

In other words, how would one (on a high level) implement NAT to NAT connections?

The only thing I can think of is:

Try to open up a port via UPNP
If that fails, use a centralized relay server (latency!) or host on the centralized server

Is that a suitable idea or is there a better option?


texts: How do I combine multiple squares into one Tetris block?

texts:
I am learning Phaser by making a simple game—Tetris. I'm having difficulties:

Can I use simple rectangles as tetrominoes or they should be sprites? I don't know how make the figure's block from simple rectangles and apply physics to it.
How I can join 4 separate squares into one tetromino?


texts: Showing Unicode in XNA on Windows Phone 7

texts:
I am creating an application which downloads names from server. These names can be any  unicode language text which I need to render in XNA on WP7. The biggest problem I see here is WP7 xna system can't render unicode (especially complex script) well. I tried few asian scripts and it looks ridiculous. Some aisan scripts render a character differently depending on neighbor character (generally vowels). Spritefont just renders them one after another without giving any consideration to vowels.

I think I need something like freetype library to render vector fonts on runtime. I wish to know if there are any alternatives to overcome this issue.


texts: Finding if a point is inside of a mesh (Point-in-polyhedron)

texts: How can I find if a point (Vector3) is inside of a mesh? Would this work for both concave and convex objects? I read somewhere that if you raycast in both directions of every axis (X, -X, Y, -Y, Z, -Z), take the count of the hits, and if it is even it is outside, if it is odd it is inside. I tried this and it didn't work.


texts: Does LibGDX have methods capable of creating dynamic text like in candy crush?

texts:
As you see, the "Retry" button and the "Invite Friends" button are both animated, smoothly and cleanly.

If I were to do this in Libgdx, would I have to use the Animation class and provide multiple texture regions of the buttons to create this animation effect? Or are in built methods included to help simulate this effect?

I've seen examples of people claiming you must use OpenGl ES methods directly. Is that true? Are there extensions to help create this effect?


texts:
I would like to "push" an object using a raycast.
With the following code, the problem is that depending of player rotation, i don't push the object but i pull it.

What am i wrong ?

Vector3 fwd = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast (RayCastSpawnOut.transform.position, fwd, out hit, 5)) {
                if (hit.transform.tag == "MyObjectTag") {
                    GameObject myobj = hit.transform.gameObject;
                    Rigidbody myobj_rb = myobj.GetComponent<Rigidbody> ();
                    Vector3 dir = transform.position - myobj_rb.transform.position;
                    dir.Normalize(); //Normalize to get the correct direction
                    myobj_rb.AddRelativeForce (dir * 0.5f, ForceMode.Impulse);
                }
            }


texts: Initializing a blank texture in OpenGL without artifacts

texts:
I'm generating a texture atlas in OpenGL, where I want to create a blank texture and copy my sprites to it.

The texture is generated like this:

glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
  GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
  GL_CLAMP_TO_EDGE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
  GL_UNSIGNED_BYTE, NULL);

While the sprites are copied like this:

GLenum format;
if (sprite.hasAlpha)
{
    format = GL_RGBA;
}
else
{
    format = GL_RGB;
}

glTexSubImage2D(
    GL_TEXTURE_2D, 0,
    sprite.x, sprite.y,
    sprite.width, sprite.height,
    format, GL_UNSIGNED_BYTE,
    sprite.data);

The issue is I keep getting artifacts in the texture not covered by a sprite:

Here I'm supposed to only have two slugs, one sword in the stone, one light grey tile, and one dark grey tile.

I tried creating a width * height * sizeof(GLuint) GLuint array filled with zeros and passing it to the glTexImage2D call, but that didn't seem to do anything.


texts: How can I make Maya export a mesh as double-sided?

texts:
I'm exporting from Maya 2009 to OBJ.  The mesh I'm exporting has in it's Render Stats "Double Sided" checked, but when the polygon is exported, only a single side is actually exported.

What really needs to happen is for each polygon that is double sided, two polygons need to be exported, facing in opposite directions..

I can do this manually, but is there a way to make the OBJ exporter do it for me?


texts: Using large textures on limited hardware

texts:
I've run into a problem where some of the models that I'm loading can have very large textures (2000x2000 for example). While my desktop computer can load them just fine, my laptop gets a segfault at the glTexImage call. I've thought of a couple of things I can do in this situation:

Before giving the image to OpenGL, I could downscale it so it's below the max texture size, but I'm not sure how to then stretch the image to its original width and height
I could also outright refuse to load the texture, and replace it with a generic repeating texture, like Valve's black and purple grid, but this isn't at all reliable or desired

Are these two options viable? How is it done with game engines like Unity or Source? Are there any other options that are better than my ideas?


texts:
I am using delta timing to account for potential drop in frame rate. Only trouble being when I do this, I can notice an ever so slight wobble. I checked out the following JSFiddle coming from a tutorial on the subject and I can even see the wobble there, specifically on the 30fps example. http://jsfiddle.net/straker/bLBjn/

my code is:

var delta = {
    now: 0,
    last: 0,
    difference:0,
    time: 1000/60
}

var d = function(val){
    return val/delta.time * delta.difference;
}

Then further down at the game loop

delta.last = Date.now();
animate();
function animate(){
    delta.now = Date.now();
    delta.difference = delta.now - delta.last;
    delta.last = delta.now;

    //update a sprite
    platform.x -= d(10);

    requestAnimationFrame( animate );
}

How can I keep the animation smooth?


texts: Procedual level generation for a platformer game (tilebased) using player physics

texts:
I have been searching for information about how to build a 2d world generator (tilebased) for a platformer game I am developing. The levels should look like dungeons with a ceiling and a floor and they will have a high probability of being just made of horizontal rooms but sometimes they can have exits to a top/down room.

Here is an example of what I would like to achieve. I'm referring only to the caves part. I know level design won't be that great when generated but I think it is possible to have something good enough for people to enjoy the procedural maps (Note: Super Metroid Spoiler!):

http://www.snesmaps.com/maps/SuperMetroid/SuperMetroidMapNorfair.html

An idea I had to accomplish this was to let the computer play a level and carve the dungeon as the "computer player" plays. But don't know how to handle branches in the way, etc... Using this way of carving I could be confident that at least an exit exists in the map and that it is reachable.

Another idea I had was using a cellular automata with some heuristics to do the carving. A problem arises here: how could I make sure that all zones carved are reachable by the player (that is limited by gravity, etc...) ?. I guess I could use some kind of graph that could follow the different dungeon floors the automata is carving and then somehow I could measure  if some part would be reachable or not by the player and add platforms or new terrain to make it reachable.


texts: How do I load 100+, 480*800, 30KB PNGs into a frame by frame animation on Android without OOMs?

texts:
I'm an Android dev who's trying to get into game dev.

As the title says, I'm trying to load a hundred PNGs as an animation, fullscreen on Android, but no matter what I try, I always getting out of memory errors, ,or heavy lags.

I've tried different engines, as well as different approaches to loading assets, here's a list of what hasn't worked :

1 - Libgdx :

Using Atlas textures, loaded in splash screen using the assets
manager :  Process killed with no errors after loading 20 2048*2048
Atlas.
Atlas Textures without Assets Manager : Huge Lag before the animation actually starts.
Sequence of PNGs using Assets Manager : Crash with explicit OOM.

P.S : All Atlas files have been compressed to the Max. Average Final file size is about 1.5MB.

2 - AndEngine :

Using Atlas Textures : So far I haven't been able to load multiple
atlas pages. Seems like Andengine can only load single page atlases.
Using createTiledFromAssetDirectory() and loading every single PNG from the assets directory to a BuildableBitmapTextureAtlas : Seems
like I need to set a fixed size for the BuildableBitmapTextureAtlas,
and again, it doesn't support multiple pages. So I'm stuck with
loading all my 100s of assets, into a single 2048*2048 atlas. Not
what I'm looking for.

Please keep in mind all PNGs are exactly 480*800px and I'm looking to play those in full screen android devices. Each PNG is about 20KB - 40KB after compression with PNGQuant.


texts: How do I convert screen coordinates to between -1 and 1?

texts:
I'm writing a function that allows me to click on my tiles. The origin for my tiles is the center, however, the mouse's origin is the top left. I need a way to transform my mouse coordinates into my tile coordinates.

Here is what I already have (but is not working):

void mouseClick(int button, int state, int x, int y)
{
    x -= 400;
    y -= 300;
    float xx = x / 100; // This gets me close but the number is still high.
    float yy = y / 100; // It needs to be between -1 and 1
}


texts:
Right now my player can move forward and backward using

case 'a':case 'A':
    speed.x = lx * 0.1;
    speed.z = lz * 0.1;
    break;
case 'b':case 'B':
    speed.x = -(lx * 0.1);
    speed.z = -(lz * 0.1);
    break;

Ly is equal sin(vertAngle);

Lz is equal -cos(horAngle);

What should i do for sideways movement?


texts:
I'm working on a 2D side-scroller, and I've got the technical aspects working. OpenGL renderer, camera movement using acceleration.

However, while scrolling I'm constantly seeing tiny random hiccups. Split-second pauses, just enough to cause the perception of smooth scrolling to feel choppy instead. Turning on VSync actually accentuates the hiccups. But when I display frame render times, it's always constant (well, constantly flipping between 0.016 and 0.017 second). So far it's just a render loop, no processing going on in the background.

When I look at other 2D side-scrolling games, I never see this stutter, so I don't know if there's something I'm missing that other games know to do...

I recorded a video of it from my phone, on a repeating row of tiles, to show what I mean. It's poor quality, but recorded at slow-motion to emphasize the hiccups. Any tips on how to get rid of this would be great.


texts:
So I have an animated sprite of 15 frames, needless to say, at 15 frames, it plays jumpy with a low frame rate.

I want to increase that, by somehow tweening or generating intermediates between the authored animation frames.

I found tools that do frame interpolation for video, and I'm wondering whether similar techniques could be applied to sprite sequences.

Do you know any methods I could use to tween my sprites?


texts: Collision Avoidance/Steering around moving obstacles

texts:
I've done a decent amount of research and I've read up on pathfinding algorithms and such, but I can't seem to find anything to do with the mentioned behaviors when moving around obstacles that also move.

My character has a circular hitbox, as do the obstacles. My character has a fixed velocity, but can also come to a full stop. My character can also change directions near instantly. Acceleration/deceleration of my character is instant. I can predict, with 100% accuracy, where the obstacles will be; I know their velocity, starting position, and ending position. Obstacles are generated by the user, move at a predetermined velocity (depending on which obstacle it is), and have a predetermined length (again, depending on the obstacle).

I want my character to path from point A to point B while moving around all the obstacles (with no collisions). Point A is where my character currently is, and point B is a user picked point which might change at any time (edit: Pathfinding itself isn't the issue; it's just local collision avoidance that I need to deal with).

Let me know if you need any more info; I don't know what is needed!


texts: I followed a youtube timelapse video to make same 3d model in blender, Can I use this in my game?

texts:
I saw a youtube timelapse video about making a car 3d model, I liked it and followed the same, I design almost same looking model (90% same), Can I use this in my game?

There is no license mentioned on video, the creator of video has just written 'Just for fun' in description of youtube video.

Update:
As per my understanding if we download or copy/paste a copyrights protected asset, we will need permission of its author, but I am neither downloading nor copy pasting anything, I am simply just seeing a video and making something similar asset, so do I really need a permission of the video creator and however he hasn't mentioned any license term also in the video.


texts: How can I implement a renderer that can draw many kinds of primitives?

texts:
This is somewhat linked to a question I previously asked concerning the drawing of indexed primitives.

My problem was that I was only drawing one cube when I wanted to draw many. I was told that the problem was that I was overwriting the vertex and index buffers with each new instantiation of Cube and that instead I should create one at the origin and then draw many, passing through a transformation matrix to the shader that makes it appear in different places. This worked beautifully.

I now have a new problem though: how would I draw many different types of primitives?

Here is my code from the previous question:

Cube::Cube(D3DXCOLOR colour, D3DXVECTOR3 min, D3DXVECTOR3 max)
{
// create eight vertices to represent the corners of the cube
VERTEX OurVertices[] =
{
    {D3DXVECTOR3(min.x, max.y, max.z), colour},
    {D3DXVECTOR3(min.x, max.y, min.z), colour},
    {D3DXVECTOR3(min.x, min.y, max.z), colour},
    {min, colour},
    {max, colour},
    {D3DXVECTOR3(max.x, max.y, min.z), colour},
    {D3DXVECTOR3(max.x, min.y, max.z), colour},
    {D3DXVECTOR3(max.x, min.y, min.z), colour},
};

// create the vertex buffer
D3D10_BUFFER_DESC bd;
bd.Usage = D3D10_USAGE_DYNAMIC;
bd.ByteWidth = sizeof(VERTEX) * 8;
bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
bd.MiscFlags = 0;

device->CreateBuffer(&bd, NULL, &pBuffer);

void* pVoid;    // the void pointer

pBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &pVoid);    // map the vertex buffer
memcpy(pVoid, OurVertices, sizeof(OurVertices));    // copy the vertices to the buffer
pBuffer->Unmap();

// create the index buffer out of DWORDs
DWORD OurIndices[] =
{
    0, 1, 2,    // side 1
    2, 1, 3,
    4, 0, 6,    // side 2
    6, 0, 2,
    7, 5, 6,    // side 3
    6, 5, 4,
    3, 1, 7,    // side 4
    7, 1, 5,
    4, 5, 0,    // side 5
    0, 5, 1,
    3, 7, 2,    // side 6
    2, 7, 6,
};

// create the index buffer
// D3D10_BUFFER_DESC bd;    // redefinition
bd.Usage = D3D10_USAGE_DYNAMIC;
bd.ByteWidth = sizeof(DWORD) * 36;
bd.BindFlags = D3D10_BIND_INDEX_BUFFER;
bd.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
bd.MiscFlags = 0;

device->CreateBuffer(&bd, NULL, &iBuffer);

iBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &pVoid);    // map the index buffer
memcpy(pVoid, OurIndices, sizeof(OurIndices));    // copy the indices to the buffer
iBuffer->Unmap();

//this is simply a single call to the update method that sets up the scale, rotation
//and translation matrices, in case the cubes are static and you don't want to have to
//call update every frame
Update(D3DXVECTOR3(1, 1, 1), D3DXVECTOR3(0, 0, 0), D3DXVECTOR3(0, 0, 0));
}

Clearly if I duplicated and modified the code to be a different object or shape, the last shape to be initialized would overwrite the vertex buffer, wouldn't it?

Do I use multiple vertex buffers? Do I append the new vertex buffer to the old one and use the appropriate indices to draw them? Can I do either? Both?


texts: Free movement in a tile-based isometric game

texts:
Is there a reasonable easy way to implement free movement in a tile-based isometric game? Meaning that the player wouldn't just instantly jump from one tile to another or not be "snapped" to the grid (for example, if the movement between tiles were animated but you'd be locked from doing anything before the animation finishes). I'm a really beginner with anything related to game programming, but with the help of this site and some other resources it was quite easy to do the basic stuff, but I haven't been able to find any useful resources for this particular problem.

Currently I've improvised something close to this: http://jsfiddle.net/KwW5b/4/ (WASD movement). The idea for the movement was to use the mouse map to detect when the player has moved to a different tile and then flip the offsets, and for the most part it works correctly (each corner makes the player move to wrong location: see http://www.youtube.com/watch?v=0xr15IaOhrI, which is probably because I couldn't get the full mouse map work properly), but I have no illusions that it is even close to a good/sane solution. And anyway, it's mostly just to demonstrate what kind of a thing I'd like to implement.


texts: 2D Tile based game Texture Atlas combining

texts:
I am new to OpenGL and game dev, I have been to courses and trying to learing everything about this. My task is to implement a Texture Atlas in a 2D tile based game (very similar to Tibia) using OpenGL.

Now the game have the sprite sheet loaded into memory and on each tile the program generates an image, load to a texture, bind and make a draw call. You can imagine how ineficcient it is. So what I have to do is to load this sprite sheet as a Texture Atlas and get the advantage that it has.

The problem is that in the first step while generating an image, the program makes some combinations on the sprites. For example, the character has an outfit and player changes its colors (boots, pants, t-shirt, hair) to do this there is a sprite for the base outfit, and a sprite for each element of the outfit, so the program apply a mask on color for each element and combine this five sprites into an image, then make the process that I mentioned above. This is an example that happens with outfit, but it happens to other things too, so this is not a special case with outfit only.

My question is: is there any way to make this combinations using OpenGL elements? Combining this multiple textures in my Texture Atlas into one draft and do it in a single draw call?


texts: How can I detect "rooms" in a 2D side scrolling game?

texts:
I'm looking to create a system that recognizes certain types of buildings and rooms you can create in game, like how Terraria detects "residences." In that game, a house can be constructed in a tile-based world by constructing a zone of blocks satisfying a set of conditions:

The zone is completely insulated from the "outside" by player-placed blocks.
The zone can fit a 5x7 rectangle.
there is at least one table, one light source, and chair in the enclosed area.
There is a door leading out from the zone.
Terraria has both a foreground and background tile layer. The entire background of the zone must be filled with player-placed blocks.

How can I efficiently detect when a player has constructed a suitably-sized area, and how can I efficiently check that the area contains all the required furnitture/components?

Example of an interior zone that satisfies all the housing requirements:


texts: Alternatives to multiple sprite batches for achieving 2D particle system depth

texts:
In my 2D XNA game, I render all my sprites with a single sprite batch using SpriteSortMode.BackToFront and BlendState.AlphaBlend.

I'm adding a particle system based on the App Hub particles sample. Since this uses
SpriteSortMode.Deferred and BlendState.Additive, I will need to have two SpriteBatch.Begin / SpriteBatch.End pairs: one for 'regular' sprites, and one for particles.

In my top-down shooter, If I want to have explosions appear under planes, but above the ground, then I believe I will have to have three Begin/End pairs, first to draw everything under the explosions, then to draw the explosions, then to draw everything above the explosions. If I want to have particle effects at multiple different depths, then I'm going to need even more Begin/Endpairs.

This is all easy to code, but I'm wondering if there is an alternative way to handle this?


texts:
I recall in a certain code, there were named constants with exponential values. Two constants' values could be added two include both of them in one go.

Example:

{ STR = 1, AGI = 2, INT = 4}
From this, combining the enumerations would always give a unique number, which lets us identify "3" as "STR&AGI" and 5 as "STR&INT".

How I would implement this is somewhat confusing.


texts: Accessing a database with a php script from Unity mobile game

texts:
So I am attempting to keep track of some user data in my game that I am creating in Unity 3d. I am using Unity's WWW class to do this. I am following this tutorial: http://wiki.unity3d.com/index.php?title=Server_Side_Highscores

I am not sure why but I keep getting a 404 error even though the file is on the server. I am using godaddy to host my website and I have the php script that I am trying to access in there so that it can use it to query the database. I am using "http://www.mysite/myscript.php?" followed by the values that I want to push to the database, as the tutorial shows to do.

No matter what I do I end up with a 404 and it doesn't make any sense as I know that it is there in the path I am attempting to connect to. If I type out the path to the php file in a browser it will take me to a page that gives an error about the hash not existing (since I am not passing one unless it is in my game) so I know that the file is there.

3/18/16

Here is my php script to add the values to the database.

<?php
    $server = "MyServersIP";
    $user = "MyUser";
    $pass = "MyPassword";
    $db = "MyDB";

    $conn = mysql_connect($server, $user, $pass);

    mysql_select_db($db);

    $Username = mysql_real_escape_string($_GET['Username'], $db);
    $Fuel = mysql_real_escape_string($_GET['Fuel'], $db);
    $IAPCar1 = mysql_real_escape_string($_GET['IAPCar1'], $db);
    $IAPCar2 = mysql_real_escape_string($_GET['IAPCar2'], $db);
    $Score = mysql_real_escape_string($_GET['Score'], $db);
    $Level = mysql_real_escape_string($_GET['Level'], $db);
    $Wins = mysql_real_escape_string($_GET['Wins'], $db);
    $Losses = mysql_real_escape_string($_GET['Losses'], $db);
    $Ads = mysql_real_escape_string($_GET['Ads'], $db);
    $LicensePlate = mysql_real_escape_string($_GET['LicensePlate'], $db);
    $hash = $_GET['hash'];

    $secretKey = "mySecretKey";

    $real_hash = md5($Username . $Fuel . $IAPCar1 . $IAPCar2 . $Score .     $Level . $Wins . $Losses .
    $Ads . $LicensePlate . $hash);
    if ($real_hash == $hash)
    {
        $query = "INSERT INTO Player values (NULL, '$Username', '$Fuel', '$IAPCar1', '$IAPCar2',
        '$Score', '$Level', '$Wins', '$Losses', '$Ads', '$LicensePlate');";
        $result = mysql_query($query);
    }

    mysql_close($conn);
?>

Here is the code I use to call the php script:

public string setValues = "http://www.mysite.com/Set_Values.php?";
private string secretKey = "SecretKeyFromThePhpScript";
public void SetValues(string username, int fuel, bool iapCar1, bool iapCar2, int score,
    int level, int wins, int losses, bool ads, string licensePlate, bool firstTime)
{
    string hash = Md5Sum(string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}", username, fuel, iapCar1, iapCar2,
        score, level, wins, losses, ads, licensePlate, secretKey));
    string url = string.Format("{0}username={1}&fuel={2}&IAPCar1={3}&IAPCar2={4}&Score={5}&Level={6}" +
        "&Wins={7}&Losses={8}&Ads={9}&LicensePlate={10}&FirstTime={11}&hash={12}", setValues, username, fuel, iapCar1, iapCar2,
        score, level, wins, losses, ads, licensePlate, firstTime, secretKey);

    WWW www = new WWW(url);
}