texts:
Let's say I have a class A with many constants (over 20) and variables (also around 20). Class B represents a character so it has a lot of constants and variables representing various stats. Class C is GUI class and draw interface showing player his stats. I would like to have also classes for dialogs, items, quests, etc. Working with such a many variables is a lot of pain for me trying to manage it only in code.

How is that type of problems managed in game development? I'm doing an android game primarily so the performance cost should be get under consideration.

Example code that is really annoying and feels bad:

Label life, xp, gold, stamina, recovery, score; // etc. Label class is GUI text

void Start()
{
    life.text = Character.instance.Life.ToString();
    xp.text = Character.instance.XP.ToString() + "XP";
    gold.text = Character.instance.Gold.ToString() + "$";
    stamina.text = Character.instance.Stamina.ToString();
    recovery.text = Character.instance.Recovery.ToString();
    score.text = Character.instance.Score.ToString();
    // etc.
}

Or even:

int level, gold, experience, life; // etc.

void Start()
{
    level = STARTING_LEVEL;
    gold = STARTING_GOLD;
    experience = STARTING_EXPERIENCE;
    life = STARTING_LIFE;
    ...
}


texts: I want camera to be positioned on the player also x axis should move continuosly by .05f in unity 2d

texts:
I am creating an 2d platformer and I am newbie to Unity; any help will be highly appreciated. I want the camera to be positioned on the player and also the X axis should move continuously by .05f. And if player is not moving or stuck somewhere and if player is behind camera player (because X axis is automatically moving by .05f)  then player should die.
Is it doable? I am using Cinemachine and any script logic will be appreciated.


texts: Bringing islands close together programmatically

texts:
I generate island/continent maps and I want to make a grand archipelago of sorts where all these islands are located. The problem is that I don't know a smart way to place the islands programmatically so that the keep a minimum distance from each other. Sure, I can create a quadtree but then how do I place it? Placing it on top of another island and move it away in a random direction? I'm attaching a photo of what I want to do, easily done in Paint .NET from 6 individual maps.

The scale I'm talking about would be placing about 3-10 continents, each with a resolution of 4Kx4K upwards. (I'll only allow reflections and translations in placement, to preserve some 4-/8- connectivity pixel work that I've done for the maps)

What I'm NOT looking for:
 - a global minimum solution ( all islands as close together as possible)
 - using a heavyweight physics/maths library or tons of code
 - a super-simplistic solution either (e.g. calculate OBBs and use those to resolve collisions)


texts: Unity - Quaternion.AngleAxis for two axes

texts:
I am creating a character controller where the camera follows the rotation of the player, and allows the user to click and drag to rotate the camera around the player, and lerps back when its released. The part I am struggling with is being able to rotate the camera on both the x and y axes using the Quaternion.AngleAxis method. It gives me the functionality I want on the one axis, but I want to be able to move freely around x and y. I am able to do this when I am not clicking and dragging because I am just lerping the camera to the offset position.

My code is below:

if (Input.GetMouseButton(0))
    {
        Vector2 mouseInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

        // This only handles rotation around x axis
        currentOffset = Quaternion.AngleAxis (cameraSpeed * mouseInput.x, Vector3.up) * currentOffset;

        Vector3 newPosition = target.position + currentOffset;

        // This is where I am just temporarily setting the y position to look down at the character.
        newPosition.y = target.position.y + 2.0f;

        transform.position = newPosition;
        transform.LookAt(target);
    }
    else
    {
        Vector3 targetPosition = target.position - target.forward * cameraDistance;
        Vector3 newPosition = transform.position;
        newPosition.x = Mathf.Lerp(newPosition.x, targetPosition.x, 3.0f * Time.deltaTime);
        newPosition.z = Mathf.Lerp(newPosition.z, targetPosition.z, 3.0f * Time.deltaTime);
        transform.position = newPosition;
        transform.LookAt(target);
        currentOffset = transform.position - target.position;
    }

As you can see I am just temporarily setting the position to 2 units above the target position so the camera slightly looks down at the player. What I would like to do is be able to move both axes to get full observational control around my player. I am not sure if AngleAxis is the right method to be using, but its given me the closest results so far.


texts: Particle system color not set properly in Android build in Unity.

texts:
I want to set the color of "Particle System" that I add to a game object in run time. Both game object and particle system are created in run time too.

I have the following code that works well on PC when I run it... But the problem is that in "Android" builds, color does not set correctly and particles are always "pink".

It should be:

But in Android it seen as:

Here is the code I use:

GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = new Vector3(x, y, z);
sphere.AddComponent<ParticleSystem>();
var ps = sphere.GetComponent<ParticleSystem>();
ps.startLifetime = 1;
ps.startSpeed = 0.01f;
ps.startSize = 0.03f;
ps.maxParticles = 10000;
ParticleSystemExtension.SetEmissionRate(ps, 10000);
var sh = ps.shape;
sh.shapeType = ParticleSystemShapeType.Circle;
sh.radius = 0.69f;

var cbl = ps.colorOverLifetime;
cbl.enabled = true;
Color mater = Color.green;
cbl.color = new ParticleSystem.MinMaxGradient(mater);


texts:
I am trying to implement collision detection in 3D between OBB/AABB and sphere.
For this i'm using sat/separating axis theorem. For sat to work in 3D i need face normals of obb (sphere to face), each vertex of obb - sphereCenter (sphere to vertex) and edge normals to sphereCenter (sphere to edge). The last i dont know how to calculate. First picture is working fine(sphere to vertex) and other two cases are giving false positives. Any other way to find minimum translation vector and distance of sphere and aabb would also be appreciated.

Box vs Sphere:

void Physics::colliderBoxVsSphere(BoxCollider* c1, SphereCollider* c2, glm::vec3& mtvAxis, float& mtvDist){
    auto spPos = c2->getPosition();

    std::vector<glm::vec3> obb;
    c1->getOBB(obb);
    auto mid = midPos2(obb);

    // (1) identity axes
    std::vector<glm::vec3> axes;
    c1->getEntity()->transform()->appendIdentiyAxes(axes);

    // (2) vertices
    std::vector<glm::vec3> verts;
    for (auto& vert : obb) {
        auto axisVec = glm::normalize(spPos - vert);
        verts.push_back(axisVec);
    }

    // (3) edges
    //TODO

    axes.insert(axes.end(), verts.begin(), verts.end());

    CollisionMath::instance()->OBBCollideSphere(obb, spPos, c2->getRadius(), axes, mtvAxis, mtvDist);
}

SAT:

bool CollisionMath::OBBCollideSphere(const std::vector<glm::vec3>& obb, const glm::vec3& spherePos, float sphereRad, const std::vector<glm::vec3>& axes, glm::vec3& mtvAxisRet, float& mtvDistanceRet){
glm::vec3 pos1 = midPos(obb);
glm::vec3 pos2 = spherePos;

float mtvDist = std::numeric_limits<float>::max();
glm::vec3 mtvAxis = glm::vec3(0, 0, 0);
for (auto& axis : axes) {
    if (axis == glm::vec3(0, 0, 0)) continue;

    glm::vec2 p1 = Math::instance()->projectOnAxis(obb, axis);
    glm::vec2 p2 = Math::instance()->projectSphereOnAxis(spherePos, sphereRad, axis);

    float d1 = glm::dot(pos1, axis);
    float d2 = glm::dot(pos2, axis);

    if (d1 > d2) {
        if (p1.x > p2.y)
            return false;
        else {      //intersect get depth
            float depth = p2.y - p1.x;
            if (depth < mtvDist) {
                mtvDist = depth;
                mtvAxis = axis;
            }
    }
}
        else {
            if (p2.x > p1.y)
                return false;
            else {      //intersect get depth
                float depth = p1.y - p2.x;
                if (depth < mtvDist) {
                    mtvDist = depth;
                    mtvAxis = -axis;
                }
            }
        }
    }

    mtvAxisRet = mtvAxis;
    mtvDistanceRet = mtvDist;

    return true;
}

Project on axis:

float min = glm::dot(verts[0], axis);
float max = min;

for (unsigned i = 1; i < verts.size(); ++i) {
    float d = glm::dot(verts[i], axis);
    if (d > max) max = d;
    if (d < min) min = d;
}

return glm::vec2(min, max);

project sphere on axis:

glm::vec3 A = center + axis * rad;
glm::vec3 B = center - axis * rad;

float min = glm::dot(B,axis);
float max = glm::dot(A,axis);

return glm::vec2(min, max);


texts: DirectXTK Model : How to draw with custom vertex & pixel shader?

texts:
Here is the code I use to render a .cmo (from .fbx) mesh :

void Render()
{
    assert(g_d3dDevice);
    assert(g_d3dDeviceContext);

    Clear(Colors::LimeGreen, 1.0f, 0);

    //g_d3dDeviceContext->VSSetShader(g_d3d_GEOM_VertexShader, nullptr, 0);
    //g_d3dDeviceContext->VSSetConstantBuffers(0, 3, g_d3dConstantBuffers);

    g_d3dDeviceContext->RSSetState(g_d3dRasterizerState);
    g_d3dDeviceContext->RSSetViewports(1, &g_Viewport);

    //g_d3dDeviceContext->PSSetShader(g_d3d_GEOM_PixelShader, nullptr, 0);
    //g_d3dDeviceContext->PSSetShaderResources(0, 1, &g_SkyboxShaderRessourceView);

    g_d3dDeviceContext->OMSetRenderTargets(1, &g_d3dRenderTargetView, g_d3dDepthStencilView);
    g_d3dDeviceContext->OMSetDepthStencilState(g_d3dDepthStencilState, 1);

    // Draw ship
    std::unique_ptr<CommonStates> states(new CommonStates(g_d3dDevice));
    DGSLEffectFactory fx(g_d3dDevice);
    auto testMesh = Model::CreateFromCMO(g_d3dDevice, L"media/meshes/space-frigate/space_frigate_6.cmo", fx, false);
    testMesh->Draw(g_d3dDeviceContext, *states, g_WorldMatrix, g_ViewMatrix, g_ProjectionMatrix);

    Present(g_EnableVSync);
}

What puzzles me :

How do I use my own vertex / pixel shaders instead of the auto-generated ones ? Notice I commented the line where I set the shaders and it works just as well...
What is the CommonStates object and what is it used for ? It doesn't seem to do anything even when adding i.e. states->Wireframe();
Why is an DGSLEffectFactory required and what is it used for ?
Why does the Z-test fail in the 2nd image ?

All in all : should I write my own mesh loader instead to rely on custom vertex / pixel shaders ?


texts:
I'm fairly new to game development, like many of us asking questions here

Currently, I'm trying my luck working on a simple space shooter.

I'm trying to add some enemy ships with movement, they will only move forwards, but, at all time, will be facing the player ship´

I have that figured out, after playing with many options, LookAt was my saviour, but now, I'm having an issue, they do rate to face the player, but they also rotate on the Y axis

This is how they are in the editor looking

This is the position setting

Their properties

Their code

using UnityEngine;

public class AlienMovement : MonoBehaviour {

    public GameObject PlayerShip;
    public float speed;

    // Use this for initialization
    void Start () {
        GetComponent<Rigidbody> ().velocity = transform.up * speed * -1;
    }

    // Update is called once per frame
    void Update () {
        transform.LookAt (PlayerShip.transform, Vector3.up);
    }
}

And how they look once the game is running (frame still)

Transform properties for the one on the right

Any idea what I'm doing wrong?


texts:
I'm trying to get the camera pixel perfect in my game. I have tried the solution described in this video: https://www.youtube.com/watch?v=eN1zV0hlkso&t=7s

I use the resolution 128 by 72.

Set the main camera to orthographic and the size to half of the screen height, 36
Duplicate the camera and make it a child of the main camera, set the value near to 0 and rename the camera to Virtual Camera.
Create a new layer called Virtual Screen and set the culling mask of the virtual camera to virtual screen.
Create a quad and make it a child object of Virtual Camera. Remove the Mesh Collider and turn ligt and reflection probes off. Rename the quad to virtual screen and set the layer to virtual screen. Set the size of the quad to the desired resolution, 128 by 72
Create a render texture, set the size to the desired resolution and the filter mode to point.
Create a material, set it to unlit/texture and the texture to the render texture created in step 5.
Set the target texture of the main camera to the render texture and the material of the virtual screen to the material created in step 6.

With these steps 1 pixel is 1 unit. Is it possible to get a pixel perfect camera with for example 16 pixels per unit?


texts: Plane won't move with transform.Translate

texts:
Code:

    void Update () {
    transform.position += transform.forward * 0.1f;
    float temp = Input.acceleration.x;
    float z = Input.acceleration.z;
    float x = Input.acceleration.x;
    float y = Input.acceleration.y;
    //Debug.Log (temp);
    transform.Translate (0,-y * speed * Time.deltaTime, 0);
    transform.Translate (-x * speed * Time.deltaTime,0, 0);
    transform.Rotate (0,0,-temp * speed);
}

The rotation seems to work fine, but when I tilt the phone, nothing happens to the plane's position in space. What's wrong?

EDIT: I know there are some silly aspects to the code, just bear with me while I debug it.

I also think it has something to do with the plane's constant velocity in the top of the code, but I don't know how to make it move with a constant speed forward but still let the user change the Z-Y coordinates via tilting.


texts: How do I pause the game immediately when it starts?

texts: I want my Unity game to start with Time.timeScale = 0f becuase it starts with a main menu that is in the same scene as the game. I tried to put Time.timeScale = 0f in Awake() but that did not work as expected. Putting it in Awake() paused it almost immediately but somehow the update funtions run at least once because some objects moved a little before the game paused. How do I pause it immediately when the game starts?


texts: What is the meaning of >> and & in this code context and what they are trying to accomplish?

texts:
I am following a tutorial on YouTube for making a 2D game. There is no clear explanation on what its actually doing.

I get bit-shifting and & operator but I don't know what they mean in this context and I understand basic Java implementation.

I've done some basic trial and error with the below code by seeing how it works, I see the effects happening but don't quite comprehend on what it is supposed to be doing in the code.

Could someone please explain how the lines marked with "//*******" work in the given context?

public class Screen {
    public static final int MAP_WIDTH= 64;
    public static final int MAP_WIDTH_MASK= MAP_WIDTH - 1;
    public static final int PIXEL_SIZE= 8;
    public static final int PIXEL_SIZE_MASK= MAP_WIDTH - 1;
    public int[] tiles = new int[MAP_WIDTH*MAP_WIDTH];
    public int[] colours = new int[MAP_WIDTH*MAP_WIDTH*4];
    public int xOffset = 0;
    public int yOffset = 0;
    public int width;
    public int height;
    public SpriteSheet sheet;
    public Screen(int width, int height, SpriteSheet sheet) {
        this.width = width;
        this.height = height;
        this.sheet = sheet;
        // ************ explain what the for loop is doing
        for(int i=0; i< (tiles.length); i++) {
            colours[i*4+ 0] = 0xff00ff;
            colours[i*4+ 1] = 0x0000ff;
            colours[i*4+ 2] = 0xffff00;
            colours[i*4+ 3] = 0xffffff;
        }
    }
    public void render(int[] pixels, int offset, int row) {
        //current x and y offset is 0 meaning that the player/map isn't moving in either direction - changing them repeats the map
        // >>3 - same as multiplying by 8 (size of pixel)
            //(0 * 8 ) + yOffset,        (height * 8) + yOffset
        // ************ what is the >> doing in this context?
        for(int yTile = (0 + yOffset) >> 3; yTile<=(height + yOffset) >> 3; yTile++) {
            // ************ what actually is yMin?
            int yMin = (yTile * PIXEL_SIZE) - yOffset;
            // ************ what actually is yMax?
            int yMax = yMin + PIXEL_SIZE;
            //sanity check if you go off the map - otherwise would crash
            if (yMin<0) yMin=0; // yMin could be below 0 because of the yOffset variable being changed is greater than (yTile * PIXEL_SIZE)
            if (yMax>height) yMax = height; // yMax could be above height because of the yOffset variable being changed
            // see above; applies to xTile as well
            for(int xTile = (0 + xOffset) >> 3; xTile<=(width + xOffset) >> 3; xTile++) {
                int xMin = (xTile * PIXEL_SIZE) - xOffset;
                int xMax = xMin + PIXEL_SIZE;
                if(xMin<0) xMin=0;
                if (xMax>width) xMax = width;
                 // ************ obviously this gives current tile you're on but what does & do in this context?
                int tileIndex = (xTile &(MAP_WIDTH_MASK)) + (yTile &(MAP_WIDTH_MASK))* MAP_WIDTH;
                for (int y = yMin; y < yMax; y++){
                    // ************ what does & do in this context?
                    int sheetPixel = ((y + yOffset) & PIXEL_SIZE_MASK)*sheet.width + ((xMin + xOffset)& PIXEL_SIZE_MASK);
                    // ************ is the tilePixel individual pixels in the tile?
                    int tilePixel = offset + xMin + y * row;
                    for(int x = xMin; x< xMax; x++) {
                        // ************ what is tileIndex * 4 doing?
                        int colour = tileIndex * 4 + sheet.pixels[sheetPixel++];
                        pixels[tilePixel++] = colours[colour];
                    }
                }
            }
        }
    }
}


texts:
Im making a user interface using libgdx
I created a Window class & a Textfield class, that both use clipping.
I use the ScissorStack class of libgdx for clipping.

The Textfield is drawn inside the window class.

Window draw method :

ScissorStack.calculateScissors(camera, batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);

//Draw textflied

ScissorStack.popScissors();

Textfield draw method:

clipBounds.setPosition(
            700,
            200
            );

//Draw textfield image

ScissorStack.calculateScissors(camera, batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);

//Draw text

ScissorStack.popScissors();

The current problem is on the Textfield class with this code :

clipBounds.setPosition(
            700,
            200
            );

If I remove this code I don't get error.

This is the error :

Exception in thread "LWJGL Application" java.lang.IllegalStateException: Array is empty.
at com.badlogic.gdx.utils.Array.pop(Array.java:292)
at com.badlogic.gdx.scenes.scene2d.utils.ScissorStack.popScissors(ScissorStack.java:77)

I noticed that if I change the value of clipBounds, something I got the error, and sometimes, with some values, I dont get the error.


texts:
I'm making a first person dungeon crawler like Eye of the Beholder.

During execution, I have a Map object. It contains Cell objects. Anc each Cell contains, at most, four Wall objects.

The Wall object has data for it's texture, and special elements like a door, a switch, etc. But most walls will end up being empty, boring walls.

My idea is to make this "boring wall" a single instance, that is referenced by all the cells that need it. Is there any design pattern or recipe in how to work with this? Or do you have any ideas?

I would like the entity's usability to be the same as the remaining entities (although I realise the default instance must be immutable).

I don't know if it helps, but I'm working with Lua.

Thanks in advance.


texts: How do I destroy a Unity prefab when it goes off-screen?

texts:
I made an infinite path using prefab.Path moving in the negative x direction. I want to destroy the path clone once it goes offscreen.

My path move script is:

var Speed:float = 5;
var hasseen:boolean;
function Start () {
    rigidbody2D.velocity.x = -1 * Speed;
    hasseen=false;
}
function Update() {
    if(renderer.isVisible) {
        hasseen=true;
    }
    if(hasseen) {
        if(!renderer.isVisible) {
            Destroy(gameObject);
        }
    }
}

and my prefab script is this:

var path_pre:Transform;
var i:long = 0;
function Update() {
    if(i<1000000) {
        Instantiate(path_pre, Vector3(i*25, -3, 0), Quaternion.identity);
        i++;
    }
}


texts: Facial expressions capabilities in various engines

texts:
For a research project, I am developing a small game focused on non-verbal communication clues, like facial expressions (smiling, frowning, looking bored, etc), eyegazing, proxemics, etc. My main issue is facial expressions, as I can't find detailed info on various engines capabilities on that point.

I usually believe that the engine/language used doesn't matter, as you can more or less do anything with any engine/language, but in this case I need something as efficient as possible (I am time limited).

I have reduced my options to 4:

UDK
Unity
Skyrim Creation Kit
Source Engine

So, what are the capabilities of these 4 regarding facial expressions? And let's be honest, in which of them are they the easiest to implement/manipulate?

If there is another engine more appropriate, I'll be glad to hear about it too.

Thanks!


texts: Tile map/terrain implementation with differing heights of neighbouring tiles

texts:
Ahoy!

I'm looking for some information about tile maps, or rather, what a specific type of tile map is called.

I'm interested in the kind of implementation used in rollercoaster tycoon, or the transport tycoon series of games and have been looking into vector field terrain and height map terrain but i'm not sure they're suitable for what i'm looking to develop.

It's been a struggle to find any decent info as most people refer to it as an isometric tile map, but I'm looking to create something in 3D with a fixed orthographic perspective. I understand that the underlying storage of the tile map has nothing to do with how it is rendered but i'm not looking to create a 2D tile map like old school pokemon/zelda games, more along the lines of diablo with the capability to include overhanging cliffs and sloping terrain.

I'm just trying to find the right terms to search google and stackoverflow for resources to help me decide which path to proceed.

So far i've managed to flesh out a basic tile map without using the height/y component stored in a VBO and rendered as a wireframe. This looks fine so far but I envisage that I will encounter problems when trying to manipulate a single vertex to create cliffs and slopes without affecting a neighbouring tile.

Is there a specific type of implementation I should be looking into? I thought i'd cracked it when I found a fair amount if info on vector field terrain but i'm not sure this would yield the correct results either.

If anyone can shed some light on this for me please, the help would be greatly appreciated :)

Update

I've included an image for further clarification as to what i'd like to achieve:

Image borrowed from How to create tilted (height) isometric tiles

This image shows the type of terrain i'd like to generate but doesn't include the "cliffs" or overhanging terrain types i'm interested in modelling. It does however raise a few other questions I hadn't considered, namely;

How would 'layers' such as the water (top left of the image) be handled to include the visible ground underneath the water?
How would the "edges" of the map be catered for so that the earth/mud is rendered to depict the world as a non-flat entity?
Could the underlying storage for this kind of terrain be used to model physics such as a ball rolling down a hill or movement speeds of a player traversing a slope?

I had an idea in that each tile of the terrain could be modelled with 8 vertices where the 4 main vertices cover the actual tile itself and the remaining 4 vertices are used to model the sides/walls of each tile. The two problems I see with this implementation is that a) the world map is essentially doubled in size and b) given that not all tiles will include "walls", some tiles will end up with redundant vertices which are not used.

I'd like to create a terrain editor which allows for each tile to be deformed as well as including the ability to change the terrain during game play. This in itself poses additional questions such as; Can a VBO be used to store and render the terrain whilst being modified on the fly and also, is it possible to modify vertices without affecting neighbouring tiles?

I'm under the impression that i'm either over-complicating things or running into analysis-paralysis in that i'm neglecting to write any code to solve the problem without having a clear idea of how I would achieve what I want.

Again, i'm really just looking for a shove in the right direction with this. Is there a specific type of tilemap/terrain implementation that would cater for a 3D map to be deformed by both a map editor as well as during gameplay or do I have to roll my own, so to speak? I'm not trying to reinvent the wheel here but I am struggling to find any resources given that I'm not sure what to be searching for.

If anyone can provide any info, resources or snippets of code, that would be hugely appreciated as i'm eager to get my hands dirty and start producing something other than the flat wireframe I currently have.

Thanks for reading!


texts: Tweaking screen transitions not to fire every time in Unity

texts:
I'm making a simple screen transition system for my game which consists of two states firing the right clips (one for the starting half od the transition animation, one for the ending one) and a condition between the end and start one which is set to true when user wants to change the level (so that the Start animation would fire in the previous animation and the End in the new one).

This is cool and all but poses two problems - firstly, the game starts with the End phase animation which looks a bit weird. Secondly, since the Restart button in the main game just reloads the level, it causes the End transition to fire every time too which looks weird and out of place.
How would I go about tweaking the Animator so that the End phase only runs when I actually change the level as opposed to when starting the game or reloading the current scene? Maybe there's some way to pass some kind of a parameter when loading a new scene that I'm not aware of? This way, I could just pass a flag like shouldFireEndAnimation so that it does not fire when the game just starts or a level restarts?


texts: First time working on 3D game: exporting steps after designer finishes 3D characters?

texts:
First time making a 3D game so could use advice. The designer is creating 3D characters with Cinema 4D (https://www.maxon.net/en/products/cinema-4d/overview/).

What steps are required to go from his 3D models to generate the files and texture maps (e.g., diffuse, normal) required to render the characters on iOS?

Is this export done within Cinema 4D, or does there need to be an intermediary step?

Does the process change if the characters are animated?


texts: Additional Entity ID for networking instead of general EID?

texts:
http://t-machine.org/index.php/2015/06/09/entity-ids-how-big-using-uuids-or-not-why-etc/

I see this one article that proposes specific IDs just for the networking side of the game. If you are already employing IDs for your entities, is there any benefit on adding IDs just for client-server communication instead of reusing the original local ID (one that you know is not subject to collisions)?


texts:
I am trying to figure out direction vectors of the arrowheads of an arrow. Basically I'm given a normalized direction vector (u,v,w) and I need the normalized direction vectors of the its two arrow heads which make a 15 degree angle.

My plan is to first start off with a simple normalized vector (0,0,1). The direction vectors of its arrow heads are (-sin(15), 0, -cos(15)) and (sin(15), 0, -cos(15)), and then rotate (0,0,1) so its parallel to the given (u,v,w). I do this by projecting (u,v,w) on its x-axis, and getting its angle relative to (0,0,1), then projecting on the y-axis, and getting its angle relative to (0,0,1), then I use the 3d rotation matrices to use those found angles to rotate the arrow head direction vector.

I have this pythoncode below, but its not working properly. Does anyone see whats wrong?

Thanks

        ra = math.radians(15)
        ca = math.cos(ra)
        sa = math.sin(ra)

        px = (0,v,w)
        if u!=1:
            px = [i/float(math.sqrt(v**2 + w**2)) for i in px]

        py = (u,0,w)
        if v!=1:
            py = [i/float(math.sqrt(u**2 + w**2)) for i in py]

        pxangle = math.acos(px[2])
        pyangle = math.acos(py[2])

        cpx = math.cos(pxangle)
        spx = math.sin(pxangle)
        cpy = math.cos(pyangle)
        spy = math.sin(pyangle)

        def rotatefunction(ah):
            xr = (ah[0], -spx*ah[2], cpx*ah[2])
            return (cpy*xr[0]+spy*xr[2], xr[1], -spy*xr[0]+cpy*xr[2])

        lah = rotatefunction((-sa, 0, -ca))
        rah = rotatefunction((sa, 0, -ca))


texts: Which code module should map physical keys to abstract keys?

texts:
How do you bridge the gap between the library's low-level event system and your engine's high-level event system? (I'm not necessarily talking about key events, but also about quit events.)

At the top level of my event system, I send out KeyPressedEvents, KeyRelesedEvents and others of this kind. These high-level events only contain the abstract values of the keys (they don't say that Space way pressed, but that the JumpKey was pressed, for example).

Whose responsibility should it be to map the "JumpKey" to an actual key on the keyboard?


texts: how to make a sprite jump or fly and fall slowly

texts:
I'm a beginner in java and im suffering to make a 2d game.
I already wrote a simple code that makes the character or the sprite jump by increment his Yposition when key is pressed and do the reverse when released ,but it doesn't satisfy me because i don't want the sprite to fall the same speed he fly with it, i want to make fall slowly ,i mean speed (Y increment) of fllying is separated from the falling one.

this may explain what im saying :
1-fllying https://jsfiddle.net/54xfevoc/embedded/result/
2- falling https://jsfiddle.net/poL9cowz/embedded/result/

thank you.


texts: How can I randomly choose a monster from an array of monsters?

texts:
I have a problem dealing of how can I call the values inside the arrays correctly. First of all, I am into making an array of monsters and a set of hp for them. I made it this way:

string monsterlist [] = {"Imp", "Orc", "Troll", "Gnome"};
float monsterhealth [] = {5.0f, 8.0f, 9.0f, 10.0f};
int monsterlife;
int monsternumber;

wherein, since i can not call the variables correctly, I made a very simple way to do it, which is:

srand(time(0));
monsternumber = 1 + (rand() % 3);
if (monsternumber == 1)
    cout << monsterlist[1];
else if (monsternumber == 2)
    cout << monsterlist[2];
else if (monsternumber == 3)
    cout << monsterlist[3];
else if (monsternumber == 4)
    cout << monsterlist[4];

Is that correct? I know it might be not the proper way. This is what I wanted:

I want to create a random number generation from 1 to 4 and store that variable in monsternumber. The next thing that will happen is, if the monsternumber is equal to 1, for example, should make the monster Imp and 5.0 as its health, seen from string monsterList and monsterHealth.

Is there a proper way to make this simplier or rather the correct way of doing it?


texts: Do I create a first login tutorial for new users?

texts:
I'm finishing my first browser game. I really don't know if I have to develop a "first login" tutorial or not. Do you think it's important?
I hate the image-based tutorials, with just few screenshot and the buttons "next" and "prev". I wanted to guide the user in the first step, using the real website but with forced choices.

Is it a good idea?

Is there some piece of code (i.e. jquery plugin) to help me in this phase?


texts:
When creating a system abstraction is better to have the platform different APIs hidden by a common interface at the lowest level that makes sense.

Taking in account the different modern (with no fixed function pipeline) native graphics APIs: OpenGLES 2.0+, OpengGL 3.0+, DirectX 10.0+, Xbox DirectX 9, LibGCM

If one was to create a stateless low level graphic API to sit on top of them all, what would be the best way to go to make it as thin and as fast as possible?


texts: How can users verify a game distributed peer-to-peer has not been modified maliciously?

texts:
I'm interested in p2p software distribution, and I'm also directly including a modding interface into my game, which is built on my own custom engine.
I was working with a folder inside of the Roaming folder to store the data (resource, saves... etc), and I quickly figured out a malicious programmer could easily modify my program and make or erase (at least) folders.
How would one prevent this kind of modification, without owning the whole distribution process?
Do you really have to trust the provider/source to trust the software? Or could you trust software on the client side using some hash or such?
The only solution I can think of would be having a website on which I put a hash of my game, and any user that gets an instance of my game can verify it was not modified by hashing it and comparing it with the one on my website. But it is definetely not user-friendly at all...


texts: MySQL for MMO-Development... What do i have to consider ?

texts:
Im currently developing an little mmo.
Its pretty basic, players can walk around... gather some resources... build some simple buildings and craft things.

Before i began to develop i read a lot about benefits using MySQL... Now im not sure if MySQL was the right choice for such a project.

Currently i store player specific data in real time, that means... once a player crafted, builded or gathered something, a server request is send which triggers a MySQL - Query to insert a new Row into the specific table.
This happens everytime a player moves, crafts, gathers or builds something.

I dont only store player-specific data in those tables... also world specific data, for example if one player visits a zone which was last updated 6 hours ago, i refresh this zone with resources and mobs. The server is generating them and after that, it inserts them as a bulk into the database.

With only one active player this works fine... but i have no idea if this will still work with dozens or hundreds active players at the same time. The serverside itself is able to handle them... but i have no idea if the database is able to.

I also heard bad stuff regarding table locks... That this is somekind of major iusse using MySQL, how does this effect dozends of database actions per seconds ? And could possible "share" be a solution for this ?

What else do i need to consider while using MySQL for a mmo ?


texts:
I am trying (and believing) to make a game of pong. I have got a slightly decent working game. I haven't implemented the scoreboard or AI yet because I want the physics to work first. I am trying to reverse the direction of the ball when it hits either paddle just to make it work cleanly and am having the issue where it changes direction twice, it bounces off the paddle as expected and then goes in the opposite direction to when it hit the paddle -.- If anyone could help me, it would be much appreciated.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class BallController : MonoBehaviour {

        private float randomNumber;
        private float range;
        private float pointOfContact;
        private float paddleTop;
        private float paddleBottom;
        private float[] limits;
        private int speed;
        private int caseNumber;
        private Vector2 direction;
        private Rigidbody2D ballRigidbody;

        void Start () {
            //Getcomponent finds the rigidbody of the attached object.
            ballRigidbody = GetComponent<Rigidbody2D> ();

            speed = 5;
            caseNumber = Random.Range (0, 2);
            range = PickARange (caseNumber);
            ballDirection (speed, range);
        }

        void FixedUpdate() {

        }

        void OnCollisionEnter2D (Collision2D coll) {
            if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "Computer") {
    //          pointOfContact = ballRigidbody.position.y;
    //          print (pointOfContact);

                ballRigidbody.velocity = new Vector2 (ballRigidbody.velocity.x, ballRigidbody.velocity.y * -1);
            }
        }

        void ballDirection (int ballSpeed, float yDirection) {
            randomNumber = (Random.Range (0, 100));

            if (randomNumber < 49) {
                direction = new Vector2(Random.Range (-1.0f, -0.5f), yDirection);
                ballRigidbody.velocity = (direction * ballSpeed);
            } else {
                direction = new Vector2(Random.Range (0.5f, 1.0f), yDirection);
                ballRigidbody.velocity = (direction * ballSpeed);
            }
        }

        float PickARange (int number) {
            switch (number) {
            case(0):
                range = Random.Range (0.5f, 1.0f);
                return range;
            case(1):
                range = Random.Range (-1.0f, -0.5f);
                return range;
            default:
                range = 1.0f;
                return range;
            }
        }
    }

I thought to multiply the whole velocity by -1 but that just caused a loop because of the lag. Even though that's the right way to reverse the direction. I think.

Thanks Peeps!


texts: Converting real-life perspective photos into orthographic view for texture creation

texts:
I'm struggling to find software that will enable me to take real life photos and make them "flat" (orthographic) for use in textures.
Does anyone know of a reliable way to take perspective photos and make them orthographic? The simpler it is the better. I've tried using Photoshop's adaptive wide angle filter with no luck.
Here is an example photo. The perspective is obvious, because the straight lines (in real life) are not straight (in the photo)


texts:
I'd like to examine a Harry Potter game for study purposes.
All of resources are fine except map file.
The maps are in a .unr file format. I know it is unreal map file.

Is there any way to convert .unr file to .fbx, .obj, or pskx formats?
I want to open map file to 3ds max or blender.


texts: Did old games like Golden Axe or Street or Rage use tilemaps?

texts:
I am wondering if old games like Golden Axe (genesis) or street of Rage (genesis) used tilemaps or background bitmaps for the levels.

I could not find any resource that explain this and searching around in the web I can find background images, but I never found any tilemap for the levels. This off course, does not answer the question, but it looks like they used background bitmaps for the entire level.

But I am not sure if it was practical for those old consoles to store such "big" images and render those.

Does anyone knows a bit of programming on those old systems and knows how those "perspective" levels were built?


texts: How do I correctly use dual quaternions for rotation and translation of an object?

texts:
Up until now I've handled a given object's rotation and translation separately using normal quaternions for rotation and vectors for translation. However I'd like to use dual quaternions to handle both an object's translation and rotation as I plan on using them for rigid body dynamics later. Basically I want it so I can have an object with an initial dual quaternion, multiply this dual by a second dual quaternion that describes the change in its displacement and end up with a third dual quaternion that describes its final position after the change is applied. I want a given object (I'll use a sphere as an example) to rotate locally around it's own center of mass but to move globally. Here's a video of the type of motion I'm looking for that apparently was accomplished using dual quaternions:

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

Unfortunately the link to this examples source code doesn't load. Now I've tried getting this to work several times however the object I'm displacing (again a sphere) will either move globally but won't rotate locally or will rotate locally but will not move globally (its movement is based on how it is rotated). Basically this sums up what I'm doing:

1) At the start of the program I have an object with an initial dual quaternion describing its position and rotation (I'll call this quaternion Q1).

2) I change the object's rotational and or translational velocity. From this I calculate a second quaternion, Q2, which describes its change in rotation and acceleration.

3) I then multiply the two quaternions together (I've tried both orders of multiplication at this point but I believe the correct order is supposed to be Q2*Q1). The formula I'm using to multiply them together is Q1*Q2 = r1*r2 + e(r1*d2 + d1*r2).

4) At this point I have a third dual quaternion that should describe the object's new location and orientation. The real part of the dual is a quaternion describing its orientation and the dual part can be converted to a translation vector using the formula t = 2*dual*(real') where real' is the conjugate of the real part of the third dual quaternion.

However this method isn't producing the results I want. The results I'm getting are predictable they just aren't the type I'm looking for, that is local rotation but global translation. Could someone please tell me the correct method of doing this?


texts: How do I change the mesh in an existing prefab in Unity?

texts: So I made a prefab some time ago and now I want to change the mesh without changing any scripts. I have an OBJ file I want to use. Is there any way to do this? I've read the documentation but I don't seem to understand how to do it.


texts: How to change transform.position code to Rigidbody.AddForce?

texts:
Vector2 vec = new Vector2(horizontal, vertical);
        vec = Vector2.ClampMagnitude(vec, 1);

        Vector3 camF = cam.transform.forward;
        Vector3 camR = cam.transform.right;

        camF.y = 0;
        camR.y = 0;
        camF = camF.normalized;
        camR = camR.normalized;

        transform.position += (camF * vec.y + camR * vec.x) * Time.deltaTime * MoveSpeed;

That's how i do my movement, but i need to change it to Rigidbody.AddForce 'cause the way that i use right now makes my character doesn't collide with objects perfectly.

Note: What i mean with "perfectly" is, if you walk to the corner of walls, you can pass through it and that's the thing that i want to prevent.


texts:
PNG loading:
I've been creating a game engine for almost a year, and since the start of the development, I have been using stb_image for loading images. It relatively lightweight but has lots of functionallity I don't personally need. I want to keep the engine as simple and lightweight as possible,  so I was hoping how to load pngs from a file directly, in pure C. I made some research and all the people was asking for was about loading BMP or TGA, but no one was asking about PNG loading, and if someone asked it, people will always recommend a third party library.
What I mean:
#define RGB 0
#define RGBA 1
// more loading types...

unsigned char* load_image(const char* filename, int* width, int* height, int* channels, int mode) {

    unsigned char* data = NULL;

    FILE* fp = fopen(filename, "rb");
    assert(fp);

    /*
     * Magic to read 'fp' and get the raw bytes,
     * the width, the height and the channels
     */
    return data;
}

How could I read the whole file, and then, return the raw bytes of the image (for OpenGL, to create textures), the width and the height as well as the image channels? Also, how could I implement a: "loading mode selector", for choosing between RGBA mode or RGB or even more modes?


texts: Term for a game that used to cost money but is now a public license

texts:
What is the term for that?
A game that used to cost money but is so old that it is now available for free (though not always open-sourced).

Also, does anyone know where I can find a list of such games?


texts: Can you create input actions using more than one key in the editor with the new Input System?

texts:
The new input system documentation says it's possible to add actions that require input combinations within the editor or code. I only see an option to add one binding path per action within in the Actions UI.

From the documentation:

  ... require the left trigger to be held and then the A button to be pressed and held for 0.4 seconds?

var action = new InputAction();
action.AddBinding("/<gamepad>/leftTrigger")
    .CombinedWith("/<gamepad>/buttonSouth", modifiers: "hold(duration=0.4)");

  Again, setting this up with the inspector in the editor is an alternative to dealing with the path strings directly.


texts: I need the player to be able to drag a game object that is connected to a rope, and for the rope to extend with it. I have purchased Ultimate Rope Editor, but it looks like it was meant for Unity 3D, and I can't get it to work. Any solutions, or am i out of luck?


texts: How can I get Visual Studio to build FXOs when I build my game?

texts:
I'm trying to compile a .fxo file when I compile my game.

The compile command-line is:

fxc.exe /T fx_5_0 /Fo Basic.fxo Basic.fx

Instead of manually using fxc.exe, where can I put this in Visual Studio so when I compile the game, the .fxo gets generated?


texts: Designing an end-less running game with levels-using LibGdx JSON

texts:
I am working on an end-less running game where obstacles are placed along the way on moving background.
I have a lot of levels in the game,and I am implementing it using JSON.

My JSON file for first level look like this:

 "obstacles": [
 {"name":"rock","position":"middle","distance":"1000","speed":"350"},
 {"name":"crow","position":"up","distance":"1600","speed":"350"},
 {"name":"gap","position":"down","distance":"1600","speed":"350"},
 {"name":"monkey","position":"middle","distance":"2200","speed":"350"},
 {"name":"fish2","position":"down","distance":"2400","speed":"350"},
 {"name":"crow","position":"up","distance":"2600","speed":"350"},
 {"name":"snake","position":"up","distance":"3400","speed":"350"},
 {"name":"fish","position":"down","distance":"3400","speed":"350"},
 {"name":"fish2","position":"down","distance":"4400","speed":"350"},
 {"name":"monkey","position":"middle","distance":"5500","speed":"350"},
 {"name":"rock","position":"middle","distance":"6500","speed":"350"},
 {"name":"fish","position":"down","distance":"6500","speed":"350"},
 {"name":"cloud","position":"up","distance":"7200","speed":"350"},
  {"name":"rock","position":"middle","distance":"8000","speed":"350"},
 {"name":"gap","position":"down","distance":"8000","speed":"350"},
 {"name":"snake","position":"up","distance":"8700","speed":"350"}
 ]

Here I am placing obstacles up to an x position of 8700 on a moving parallax back ground.

Level1 is working fine,but my issue is that how I should place the next level obstacles.I have only one way that some position after 8700 I have to choose for placing next level obstacles.

Here I want to clarify one thing.Will it become a problem when I use larger values like this?

There is more than 20 level planned in my project,and each level get loaded automatically when one is completed.

I expect suggestions from experienced persons ,for designing the levels with these aspects.

Thanks in advance.


texts: Securing HTTP data from a JavaScript game to server

texts:
Suppose I am doing a JavaScript game, and I wish the game to update the server if the user has successfully completes the game and his outcome.

How should I ensure that the request came from the JavaScript game, and that the data sent has not been tampered with. I am using PHP as the server-side language.

I do understand that no strategies are going to be 100% fool-proof, and any measures taken is more of a deterrence than absolute protection.

On Edit: Let's supposed we're not using server verification of each user's step (as in a traditional MMO). The game could be a mini-game as part of a web game or educational game (space invaders or a real-time game, for example) and requiring a server-side component for each of those games could be tedious.

Example: Supposed, when the game is completed, a request is sent to the server via. AJAX

game_finished.php?user_id=1&outcome=success&score=88

A user could 'fake' the server in believing that the game has been completed correctly by sending that request to game_finished.php. How could this be made more difficult?


texts: A motion blur technique which can cover curve movement path?

texts:
I am looking for a motion blur technique for real-time games.

I know two techniques, velocity map and accumulation buffer. Velocity map shows very good quality, but doesn't work correctly if objects are moving along curvy path. Accumulating frame-buffer does work, but consumes too much power to get acceptable quality.

Is there any other motion blur technique which can cover this situation?


texts: How would I create a save function to my random generated game?

texts:
I'm making a 2D Tower Defense and currently looking into making a save feature. The problem is that my game is procedural generated (based on the rogue-like tutorial posted by Unity):

At runtime I generate a random amount (approx 7k) tiles of treasures, obstacles and different enemies at random locations. Some tiles will also be destructible and not exist when destroyed.

What should I do to save the position of each tile and values such as "Level" and "Gold"?

This is a list of what I need to be saved:

Player value (position, gold, level, health, inventory)
Building values (Tower/Building positions, health value etc)
Wave values (wave_level)
Board values (all tile positions such as obstacles, treasures etc)

NOTE: Every tile is a GameObject.


texts: The way of avoiding branching for textured and not-textured objects

texts:
I know that branching is an expensive operation on GPU (not as much as it used to be, but still).

The most common situation where I use branching is when I have both textured and non-textured models/objects rendered with single shader (switching between shaders is also quite expensive and it only differs in 1-2 small parts).

For example, here's some pixel shader for rendering 2D objects:

constbuffer constBufferPerObject{
    float4 textureCoordORColor; //hasTexture is true => it's texCoord(x,y), color otherwise
    bool hasTexture;
};

...

float4 PS(VS_OUTPUT input) : SV_TARGET{
    if(hasTexture){
        //input.TexCoord was calculated in VS (it's meaningless if hasTexture is false)
        return ObjTexture.Sample(ObjSamplerState, input.TexCoord);
    }else{
        return textureCoordORColor;
    }
}

What would be a smart way to re-write the PS in order to avoid branching here?


texts: 3D Side-Scrolling Shooter: to use or not to use Lua scripting?

texts:
I'm programming a Side-Scroller, and I've reached the point where I need to program the enemy behaviour. I don't know what I should choose between hard-coding the enemy ships' behaviour or using a scripting language.

Going with the hardcoded way, all different kind of enemies would be different classes derived from an abstract EnemyShip class with a virtual function redefined for each of them. Going with the scripting instead I could do just a base class and a script manager which moves the ships as needed.

What should I do?


texts: How to make many perlin noise function match

texts:
I am trying to create procedural terrain using Perlin noise here is what I have so far:

I create "Chunks" of a fixed size using a Perlin noise function, each chunk is a flat mesh (like a plane).
Different Chunks can have different noise parameters (octaves, amplitude, ...) to make some part more like plains or mountains.
now because of the noise parameters some chunk borders don't match.

How can I go about this? I have tried to lerp the borders but it makes a flat edge that is kind of ugly.


texts: How to properly transform vertices for a model loaded using Assimp?

texts:
When I try to load a DAE model then vertices are not placed correctly. Here's the code snippet I use to load 3D models using Assimp  :

aiNode* CGameObject::findNode(aiNode* rootNode, const char *name) {
    if (!strcmp(name, rootNode->mName.data)) {
        return rootNode;
    }
    for (int i = 0; i < rootNode->mNumChildren; i++) {
        aiNode *found = findNode(rootNode->mChildren[i], name);
        if (found) {
            return found;
        }

    }
    return NULL;

}

void CGameObject::transformNode(aiMatrix4x4 *result, aiNode* rootNode) {
    if (rootNode->mParent) {
        transformNode(result, rootNode->mParent);
        aiMultiplyMatrix4(result, &rootNode->mTransformation);
    } else {
        *result = rootNode->mTransformation;
    }
}

Assimp::Importer importer;
    const aiScene* scene = importer.ReadFileFromMemory(buffer,
        size,
        aiProcess_CalcTangentSpace      |
        aiProcess_Triangulate           |
        aiProcess_JoinIdenticalVertices |
        aiProcess_GenUVCoords   |
        aiProcess_TransformUVCoords |
        aiProcess_FlipUVs |
        aiProcess_SortByPType);

    if (!scene) {
        return false;
    }

    const int iVertexTotalSize = sizeof(aiVector3D) * 2 + sizeof(aiVector2D);
    int iTotalVertices = 0;

    for(int i = 0; i < scene->mNumMeshes; i++) {
        _Mesh* m = new _Mesh;

        aiMesh* mesh = scene->mMeshes[i];

        aiNode* node = findNode(scene->mRootNode, mesh->mName.data);
        transformNode(&node->mTransformation, node);
        aiTransposeMatrix4(&node->mTransformation);

        int iMeshFaces = mesh->mNumFaces;
        for (int f = 0; f < iMeshFaces; f++) {

            const aiFace* face = &mesh->mFaces[f];

            for (int k = 0; k < 3; k++) {
                int vertexIndex = face->mIndices[k];
                iTotalVertices++;
                aiVector3D pos = mesh->mVertices[vertexIndex];

                aiTransformVecByMatrix4(&pos, &node->mTransformation);

                m->vertices.push_back(pos.x);
                m->vertices.push_back(pos.y);
                m->vertices.push_back(pos.z);
    ...

What am I doing wrong ? I will create a VBO for all the vertex positions later and render them.
When I load an OBJ model everything loads fine and there is no need for applying per-node transformations.

Also, I noticed that Assimp renames node names from "Cube.001" to "Cube_001", is this behavior normal/expected.
I'm using Assimp 3.1.1.


texts:
I have the main game (Game1.cs) draw the sprites like so:

        //Clear everything
        GraphicsDevice.Clear(Color.CornflowerBlue);

        //Begin drawing
        _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

        //Draw enemies
        for (int i = 0; i < ControlObj.EnemyList.Count; i++)
        {
            ControlObj.EnemyList[i].DrawObject(_spriteBatch);
        }

        //Draw powerups
        for (int i = 0; i < ControlObj.PowerupList.Count; i++)
        {
            ControlObj.PowerupList[i].DrawObject(_spriteBatch);
        }

        //Draw other stuff
        for (int i = 0; i < ControlObj.OtherStuffToDraw.Count; i++)
        {
            ControlObj.OtherStuffToDraw[i].DrawObject(_spriteBatch);
        }

        //Draw the player
        ControlObj.PlayerObj.DrawObject(_spriteBatch);

        //Finish drawing
        _spriteBatch.End();

DrawObjects method:

        public virtual void DrawObject(SpriteBatch sb)
    {
        int imgIndex = (int)Math.Floor(ImageIndex);

        //Draw the object!
        sb.Draw(Sprite[imgIndex],   //Sprite (Texture2D)
                Center,             //Location of object (Vector2)
                null,               //Source rectangle (USELESS)
                ColorBlend,         //Color blend (Color)
                Rotation,           //Rotation angle (in radians)
                CenterOffset,       //Offset (Vector2)
                ImageScale,         //Image scale (Vector2)
                SpriteEffects.None, //Flip sprite? (USELESS)
                Depth);             //Depth of the object
    }

The issue: Some objects draw other objects by overriding the DrawObject method like so:

        public override void DrawObject(SpriteBatch sb)
    {
        base.DrawObject(sb);

        for (int i = 0; i < OtherStuffList.Count; i++)
        {
            OtherStuffList[i].DrawObject(sb);
        }
    }

For some reason, objects drawn by other objects do not obey their depth property. How could I fix this?


texts:
I am trying to make a shader that applies a black image with 50% transparency to the entire screen, with the exception of a designated area.  I am starting by just trying to apply a shader to the entire screen.  So I am using the default ImageEffect Shader.

This is my before and after when applying my shader, which should invert everything.  It inverts everything except for the Balmer's Peak, which is a Unity Image:

Before:

After:

Example of what I am going for:

I attached a script using OnRenderImage to the Camera, and the attached material is being applied to everything in sight, except the UI.  What can I do to make my material applied to everything on the screen, including the UI?

I am new to shaders, so this may seem like a bit of a dumb question.  But I am not sure what direction I should be headed.  Here are my scripts, although I did not really change anything from what Unity provided me:

Script attached to camera:

using UnityEngine;

public class ButtonHighlight : MonoBehaviour
{
    [Tooltip("Material which is to be applied")]
    [SerializeField]
    private Material material;

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(source, material);
    }
}

Shader attached to material above:

Shader "Magic/Magic Shader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _MainTex;

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                // just invert the colors
                col = 1 - col;
                return col;
            }
            ENDCG
        }
    }
}

What is the correct approach to apply a shader to the entire screen?  (Keeping in mind, that the purpose is to add a filter to most, but not all, of the screen.)


texts: How to instantiate an array of Prefabs in C# Script

texts:
Sorry if this sounds quite primitive, I am new to Unity. I am trying to instantiate an array of prefabs, but it doesn't seem to appear when I run the game. Firstly I created my block prefabs, then I created an empty game object and added the following script to the empty object.

public class BlocksTestScript : MonoBehaviour {

    public GameObject[] blockPrefabs;
    // Use this for initialization
    void Start () {

        blockPrefabs = new GameObject[7];
        blockPrefabs = Resources.LoadAll ("/Prefab/BlockPrefabs") as GameObject[];

                for (int i = 0; i < blockPrefabs.Length; i++) {
        GameObject myPrefabs = Instantiate(blockPrefabs[i], blockPrefabs[i].transform.position, Quaternion.identity) as GameObject;
    }

    }

    void Update () {

    }
}

I get the following error:

  Assets/Resources/Scripts/BlockTestScript.cs(14,28): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

How can I resolve this issue?

UPDATE

After looping through to instantiate the prefabs I now get the following error:

NullReferenceException: Object reference not set to an instance of an object
BlocksTestScript.Start () (at Assets/Resources/Scripts/BlocksTestScript.cs:15)


texts: Physics: calculating angular acceleration in world vs local space

texts:
I have a pretty simple rigid body simulation written in Python. In my code I calculate the angular acceleration using formula:

angAcc = torque * inertiaTensor^-1  (note row-major matrix order)

Now, the torque is in world-space so my inertiaTensor should also be in world-space. My Python code that does the angular acceleration computation looks like this:

oriMat = quaternion.ToMatrix(self.ori)
inertia_world = self.inertia_local * oriMat
matrix.Invert(inertia_world)
angAcc = vector.Transform(self.totalTorque, inertia_world)

oriMat is effectively local-to-world transform. self.totalTorque is torque in world space. So this code transforms local inertia to world inertia and uses its inverse along with world torque to compute world angular acceleration. This code works completely fine.

I thought to check out if I could conduct the angular acceleration compuation in local space and eventually convert local angAcc to world angAcc. Here's the code:

oriMat = quaternion.ToMatrix(self.ori)
self.totalTorque = vector.Transform(self.totalTorque, matrix.Inverted(oriMat))
angAcc = vector.Transform(self.totalTorque, matrix.Inverted(self.inertia_local))
angAcc = vector.Transform(angAcc, oriMat)

Here I wanted to do the torque-inertia transform in local space. To do so, I transform self.totalTorque to rigid body's local space using inverse of oriMat. Then I mul that by inverted local inertia to get angular acceleration in local space. Finally, I transform angular acceleration to world space by transforming it with oriMat.

For some reason this code doesn't yield correct behaviour of my rigid body and I really can't tell why. Anyone got an idea?


texts:
Does anyone know how to install MonoGame on Mac. I have been looking around for a while and I can't find any guides. I have Mono and MonoDevelop up and running fine, but I cannot figure out how to install MonoGame.
Thanks.


texts: Moving a Box2D object in the direction it is facing using applyForce

texts:
I'm trying to apply force to a polygon physics object to move it. Whilst I can get it to move upwards easily enough, I'm trying to get it to move in the direction in which it is pointing.

Here's my current movement code -

private void controls(){
    if(Gdx.input.isKeyPressed(Keys.D)|| Gdx.input.isKeyPressed(Keys.RIGHT)){
        shipBody.applyAngularImpulse(-Global.ROTATIONSPEED, true);
    }

    if(Gdx.input.isKeyPressed(Keys.A)|| Gdx.input.isKeyPressed(Keys.LEFT)){
        shipBody.applyAngularImpulse(Global.ROTATIONSPEED, true);
    }

    if(Gdx.input.isKeyPressed(Keys.W)|| Gdx.input.isKeyPressed(Keys.UP)){
        shipBody.applyLinearImpulse(Global.IMPULSE,
                                    shipBody.getWorldCenter(), true);
    }

    System.out.println("Ship angle: " + shipBody.getAngle() * (float)(180 / Math.PI));
}

Global.Impulse is:

public static final Vector2 IMPULSE = new Vector2(0, 25f * MetersToPixels);

Whilst this works fine for rotating the ship, when i apply thrust, it just goes vertically up (I understand why this happens, I'm just not entirely sure how to make it move in the direction it's pointing).


texts: How to place grass on custom terrain mesh

texts:
I made a custom terrain mesh and textured it, now I want to place grass on it, but I don't know how. I only find info about grass with the unity terrain.
I am not even sure what exactly to look for.

What is the best/easiest way to place grass on a terrain?
I'd like to do it in the shader if possible, but I guess I will need additional geometry if I want it to "stick out"?

(Random example picture
http://www.beamng.com/attachments/stuff-png.16516/)

I'd appreciate a general outline on how to tackle this problem and maybe some links for further reading.

Thanks.


texts:
I have a stock biped character in 3D studio max which has a jump animation.

The problem I have with the jump animation is that there is actual y offset happening inside it which makes it awkward to play while the character is jumping since it's not only jumping in the game world but the jump animation is adding its own height offset.

I'm tryuing to remove the jump animations height offset, so far I've found the root node and deleted all its key frames which has helped a bit.

The problem I'm having now is that the character still has some height offset and if I try to lower it it has a fake 'ground' that isn't at 0 and the limbs sort of bend on the imaginary floor, si there a way to remove this restriction just for the jump animation?

Here's what I mean: http://i.imgur.com/qoWIR.png

Any idea for a fix? I'm using Unity 3D if that opens any other possibilities...


texts:
Our team is going to publish game in social networks. Expected DAU is about 100k, which is about 500 concurrent connections and 100-400 transactions\sec. Our main risk is the game-database server(Windows Server 2008 using MySQL) because it would handle most of the load.
As player enters game server SELECTs his gamestate and caches it in memory. After it most queries will be simple UPDATEs. No complex queries are planned.

So we've stumbled upon game-database configuration questions:

1) Is CPU much important for game-database server? Would 1 Intel Xeon E3-1230(or 1270) be enough for us?

2) Is RAM much important for game-database server? Would 24-32gb DDR3 RAM be enough for us?

3) Is SSD much better than HD in terms of game-database server?


texts:
I am in the design process of an RPG game and I have no experience at all in game dev.
This question is about how I should approach entity management using OOP classes.

My train of thought is as followed:

Have Entity interface with basic update() function
"Mortal" class and "NPC" class implement Entity
"Hero" and "Monster" class inherit from "Mortal" class

In this case, Mortal class are all those entities that have statuses such as HP and MP.
NPC are self explanatory.

I am sure my approach is naive so I would like to know the pros and cons and what would be a better way to approach this.


texts: What is an expected conversion rate in a free to play game?

texts: I understand that there's a lot of factors at play that decide how much free users will become paid users. What can be expected from different marketing strategies such as selling non-gameplay impacting items, selling gameplay impacting items, selling subscriptions, etc? An ideal answer would have statistics showing numbers from different games?


texts:
While rendering a cube to the gbuffer (diffuse, normal, depth) I noticed something odd when applying rotations. I build a world matrix for the cube as follows:

Yaw = Yaw % MathUtil.PI2;
Pitch = Pitch % MathUtil.PI2;
Roll = Roll % MathUtil.PI2;

Matrix4 s = Matrix4.Scale(Scale);
Matrix4 t = Matrix4.CreateTranslation(Position);

Matrix4 rotY = Matrix4.CreateRotationY(Yaw);
Matrix4 rotX = Matrix4.CreateRotationX(Pitch);
Matrix4 rotZ = Matrix4.CreateRotationZ(Roll);

return s * rotY * rotX * rotZ * t;

If I render the cube with scale 1, position 0,0,0 and no rotations my normals are rendered properly. Applying scale/position does not change this fact.

However, when I apply rotations the normals screw up in some cases.

Nothing wrong in these settings:

Yaw = Pi/2
Yaw = Pi
Pitch = Pi/2
Pitch = Pi
Yaw = Pi && Pitch = Pi

But when I apply these rotations:

Yaw = Pi/2 && Pitch = Pi/2

This happens:

For some reason the normals aren't rotated correctly. I rotate them like this in the vertex shader using the world matrix described above:

mat3 WorldMatrix3x3 = mat3(WorldMatrix);
normalWS = vertexNormal_modelspace * WorldMatrix3x3;

And store them in the fragment shader:

rtt_normal.xyz = normalWS * 0.5 + 0.5;

I display the normal buffer on the screen like this:

color = vec4(abs(texture(gbufferTexture, UV).rgb * 2.0 - 1.0), 1);

What am I missing here?


texts:
I want to display the final results at last in the game when gameobjects finish the winning(finish) line. For that I am using canvas and in that a panel onto which an image is attached.
I have to hide that canvas at start of the game and then show when gameobjects cross the last finish line.
How can I do this..? Please if anyone has an idea about this can help me.
Thanks in advance :)


texts: What's the most efficient way to find barycentric coordinates?

texts:
In my profiler, finding barycentric coordinates is apparently somewhat of a bottleneck.  I am looking to make it more efficient.

It follows the method in shirley, where you compute the area of the triangles formed by embedding the point P inside the triangle.

Code:

Vector Triangle::getBarycentricCoordinatesAt( const Vector & P ) const
{
  Vector bary ;

  // The area of a triangle is
  real areaABC = DOT( normal, CROSS( (b - a), (c - a) )  ) ;
  real areaPBC = DOT( normal, CROSS( (b - P), (c - P) )  ) ;
  real areaPCA = DOT( normal, CROSS( (c - P), (a - P) )  ) ;

  bary.x = areaPBC / areaABC ; // alpha
  bary.y = areaPCA / areaABC ; // beta
  bary.z = 1.0f - bary.x - bary.y ; // gamma

  return bary ;
}

This method works, but I'm looking for a more efficient one!


texts:
I am making a strategy game like Age of Empires. It's a pretty big project and I need a clear game structure.

I have defined a Game_Object class with variables such as:

Hit Points
Speed
Damage
Range_Attack
...and a few functions to move the game object, load the game object to the screen, check collisions, etc.

Inheriting from this Game_Object class are:

Building_Object (It is buildings in the game to train soldier and villager)
Dynamic_Object (It is dynamic objects such as villager, soldier, elephant, bird

I have defined a Civil class, it is a class about the country. It contains:

a std::vector<Game_Object*> GameObject containing game objects
variables to store the number of resources
a few variables about technology
functions to check the amount of army units, villagers, houses
a few functions to check collisions, update the game objects, move game objects

I have defined a Civil_Computer class, which inherits from my Civil class. It has a few functions to control the nation of the computer opponent.

I also have defined a Manager class, to load the map to the screen, load image, manage game objects, etc. It has std::vector<Civil*> containing the nations of AI and human players, a few function to initialize the game window, check winning, load game object to the screen, etc.

Finally, I have a header file to define many functions such as Move_Object, Check_Alive, etc.

Can someone suggest to me a clearer structure?


texts: How can I recover polygons and normal maps from compiled games through emulation of D3D or OpenGL?

texts:
I am trying to generate labeled training data for an artificial visual cortex to learn on. I'm looking for a tool that will, instead of rendering the scene at each pixel just give me the pre-rendered data associated with each pixel. Presumably something like:

[x,y] -> [normal, depth, color, lighting, (lens flares?), texture, etc]


texts: AI: Turn-Based Movement with 2 actions per Unit

texts:
I am currently building a turnbased tactics game.

The Board is a small (about 4*6) tiled grid.

The AI plans all moves of its units, each unit can

move 2 times
move and attack
or attack

at least in this basic stage.

Only one unit can be on a grid cell at any given moment. But a Unit can take a turn to a grid cell which was just left by the former occupant.

The AI plans out the whole turn in advance, and then the actions is played.

The Mission: The AI should maximize the attacks for each round. Currently only Melee is implemented, so this means maximize the count of own units in the grid cells next to the player units, and they should have a turn left to attack, if possible.

I am having a hard time with units getting moved on tiles, where a other unit is still present and so on.

Is there some kind of algorithm or even brute-force approach to match the the criteria?


texts: How to calculate a 3D orientation from 2D vanishing lines on an image?

texts:
Let say I have a image that represent a 3D scene. I did not have the 3D camera orientation of that scene (left, up and forward vectors) and i'd like to calculate it.

On that picture, I draw the following segments : A1, A2 and B1, B2.

A1 and A2 are vanishing lines for the plane defined by left and up axis.

B1 and B2 are vanishing lines for the plane defined by forward and up axis.

As input, I only have 2D coordinates of segments (in screen space), so eight coordinates in total. This is the "handles "of the segments on the picture.
I also have P0, a 2D position (in screen space) of the origin of the up / left / forward axis  (not sure if this information is needed).

Is there a way, from that information, to retrieve the 3D orientation (in world space) of the 3D scene (so the left, up and forward vectors) ?

Once the forward and left vector are calculated getting the up one is trivial : cross product would do.

EDIT : As Peethor stated, there was some missing information to get what I wanted. I have update question and picture to add more details and make it more clear.


texts: Fixed-Function vs Shaders: Which for beginner?

texts:
I'm currently going to college for computer science. Although I do plan on utilizing an existing engine at some point to create a small game, my aim right now is towards learning the fundamentals: namely, 3D programming. I've already done some research regarding the choice between DirectX and OpenGL, and the general sentiment that came out of that was that whether you choose OpenGL or DirectX as your training-wheels platform, a lot of the knowledge is transferrable to the other platform. Therefore, since OpenGL is supported by more systems (probably a silly reason to choose what to learn), I decided that I'm going to learn OpenGL first.

After I made this decision to learn OpenGL, I did some more research and found out about a dichotomy that I was somehow unaware of all this time: fixed-function OpenGL vs. modern programmable shader-based OpenGL. At first, I thought it was an obvious choice that I should choose to learn shader-based OpenGL since that's what's most commonly used in the industry today. However, I then stumbled upon the very popular Learning Modern 3D Graphics Programming by Jason L. McKesson, located here: http://www.arcsynthesis.org/gltut/

I read through the introductory bits, and in the "About This Book" section, the author states:

  "First, much of what is learned with this approach must be inevitably
  abandoned when the user encounters a graphics problem that must be
  solved with programmability. Programmability wipes out almost all of
  the fixed function pipeline, so the knowledge does not easily
  transfer."

yet at the same time also makes the case that fixed-functionality provides an easier, more immediate learning curve for beginners by stating:

  "It is generally considered easiest to teach neophyte graphics
  programmers using the fixed function pipeline."

Naturally, you can see why I might be conflicted about which paradigm to learn: Do I spend a lot of time learning (and then later unlearning) the ways of fixed-functionality, or do I choose to start out with shaders? My primary concern is that modern programmable shaders somehow require the programmer to already understand the fixed-function pipeline, but I doubt that's the case.

TL;DR = As an aspiring game graphics programmer, is it in my best interest to learn 3D programming through fixed-functionality or modern shader-based programming?


texts: How can we view 3d objects from top down view in TD game

texts:
I am making a tower defense game. I am working in x and y axis only. I have made a grid, snapped towers and made a pathfinding algo to run enemy. Initially I have worked with cubes and spheres in place of towers and enemies.

Now I am going to place real towers (3D). Note that I haven't used z axis up till now. The user will analyze the game from top down view.

I want the user to see towers placement with a little bit of 3d view but I have made my all code in 2d thing. Is there any solution to my problem that somewhat tower placement would view a 3D touch or you can say 2.5D ?? (like fieldrunners) or should I have to involve z axis and ignoring y axis ?


texts: How to distinguish multiple same element already in place on a minecraft map

texts:
I am currently working on a minecraft plugin using spigot.
It's a sort of a race  between players where checkpoints validation is needed.

I have a minecraft map edited on MCEdit and I have severals signs already set on the map that serves as "checkpoints".

All I need is to find a way to distinguish the signs.
I would like to get x y z coordinates of each signs but I've thought that there could be map makers that wouldn't name their signs the same way I do, so I need to find another way to distinguish the signs.

I have a debut code but i don't have any ideas to get it forward.

@EventHandler
public void onClick(PlayerInteractEvent e){

        if(e.getItem().getType() == Material.SIGN){

            //I'll have to getlocation() the signs
            //And maybe store the locations in an array

            e.setCancelled(true);
        }

}

Any ideas?


texts: Dynamic "Light Level" System based on alpha levels

texts:
My team and I have been working on a game in Java using the Slick2D engine and there are a few things I have questions on. As of right now, the code that I've written basically takes a cosine function and gets a value based on the current game time (which is normalized by some multiple of Pi, like 4*Pi, to give us a period (or day length) of 4*Pi). The value that comes out of the function is used directly as the alpha level of the overlaying light layer so that as the night comes on, the screen darkens until it's completely opaque, then eventually comes back to completely transparent. I've also created a mask around the player, which disallows the alpha level from drawing near the player.

Now, this looks cool and all, but if I want to draw different alpha levels around that, some that may even be non-existent until it begins to get dark like an average alpha transition that goes from the 100% transparent alpha near the player to the 100% opaque alpha outside that mask during the pitch black of night, I run into issues. Screenshot

Basically, Slick provides some tools, like static values in the Graphics class that change the draw mode. Examples are: MODE_ADD, MODE_ADD_ALPHA, etc. I'm wondering if there's a particularly good rundown on using these to get results where I have alpha levels that will vary between the current overall alpha level and the 100% transparency so I can create clean transitions so it doesn't have that clean cutoff seen in the screenshot.

Or should I scratch this and go with a grid/cell based system since the game's tile based when it comes to drawing the background layers, save for the entities. Might make a bit more sense and look a little more natural with the backgrounds, although still look a tad unnatural.

EDIT: I'd also be open to other paradigms.


texts: Custom steering system in Unity for braking and sliding

texts:
I am developing a game where the player controls a vehicle. But instead of using a first person view, the camera is top-down and orthographic.

I tried using Unity's wheel collider system. While that would work just fine for a first-person view (e.g. a traditional racing game), the controls don't work well with a top-down view (e.g. think Micromachines on the NES). The reason, I think, is that turning and acceleration need to be much more responsive with a top-down view than with a real vehicle steering simulation. You're not racing on a track. When viewing from top-down, the vehicle needs to accelerate and turn much more quickly than a "real" vehicle ever could.

I have implemented my own steering system based on Ackermann steering, which works fine. What I am missing is a good simulation of friction and skidding. For instance, I would like my vehicle to skid and slide if the user brakes while turning.

I don't have a background in physics or mechanics so I am not sure where to start. Can someone give me some pointers?

Here is the code I have so far for simple steering:

void Move() {
    bool isLeft = Input.GetKey (KeyCode.A);
    bool isRight = Input.GetKey (KeyCode.D);
    bool isUp = Input.GetKey (KeyCode.W);
    bool isDown = Input.GetKey (KeyCode.S);

    turn = 0;

    acceleration = 0;
    speed *= friction;

    if (isReverse != isDown && (isUp || isDown)) {
        speed *= reverseDamping;
    }

    turn += isLeft ? (int) (-angleVel * speed) : 0;
    turn += isRight ? (int) (angleVel * speed) : 0;

    acceleration += isUp ? Time.deltaTime : 0;
    acceleration += isDown ? -Time.deltaTime : 0;
    speed += acceleration;

    transform.Rotate (0, turn, 0);
    transform.Translate (Vector3.forward * speed, Space.Self);

    isReverse = isDown;
}


texts:
I am using projectors for shadows...When I use particles for bike speed up i.e., nitro speed the particles get cutout by those shadows....

Here is screenshot of it,

Here is my shader code of projectors ,

Shader "Projector/Projector Multiply Black"
{
    Properties
    {
        _ShadowTex("Cookie", 2D) = "gray" { TexGen ObjectLinear }
    _ShadowStrength("Strength",float) = 1
    }

        Subshader
    {
        Tags{ "RenderType" = "Transparent"  "Queue" = "Transparent+100" }
        Pass
    {
        ZWrite Off

        //Fog { Mode Off }

        Blend DstColor Zero

        CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"

        struct v2f
    {
        float4 pos : SV_POSITION;
        float2 uv_Main     : TEXCOORD0;
    };

    sampler2D _ShadowTex;
    float4x4 unity_Projector;
    float _ShadowStrength;

    v2f vert(appdata_tan v)
    {
        v2f o;

        o.pos = mul(UNITY_MATRIX_MVP, v.vertex);

        o.uv_Main = mul(unity_Projector, v.vertex).xy;

        return o;
    }

    half4 frag(v2f i) : COLOR
    {
        half4 tex = tex2D(_ShadowTex, i.uv_Main);
        half strength = (1 - tex.a*_ShadowStrength);
        tex = (strength,strength,strength,strength);
        return tex;
    }
        ENDCG

    }
    }
}

Here is my particle code,

// Simple additive particle shader.

Shader "Custom/Particle additive"
{
Properties
{
    _MainTexture ("Particle Texture (Alpha8)", 2D) = "white" {}
}

Category
{
    Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    Blend SrcAlpha One
    Cull Off Lighting Off ZWrite Off Fog {Color (0,0,0,0)}

    BindChannels
    {
        Bind "Color", color
        Bind "Vertex", vertex
        Bind "TexCoord", texcoord
    }

    SubShader
    {
        Pass
        {
            SetTexture [_MainTexture]
            {
                combine primary, texture * primary
            }
        }
    }
}
}


texts: What is the advantage of using .json to store dialogues instead of hard coding them in C# scripts?

texts:
This is a snapshot of the dialogues written in a .json file stored in the Resource folder, which I use to display dialogues in the game:
{
"dialogues":[
    {
        "characterType": 0,
        "name": "Hero",
        "atlasImageName": "Hero_Default",
        "dialogueText": "Time to address the call to adventure"
    }

An advantage I can think of using .json is that you can directly edit it in a text file.
Beyond this, is there a reason to prefer JSON over hard coding in C# classes or structs? I feel like managing hundreds of JSON files is equally difficult as managing hundreds of .cs files that are used for storing dialogues, but with .cs files I can rely enums (for character types) and string-constants (for hero names) to minimize typos.


texts: What does the term 'photorealistic' really mean?

texts:
I was wondering about the term 'photorealistic' in regards to rendering and was wondering how this is used.

Is it used to describe a shader (or set of) that have certain quantifiable features? Or any rendering thats not meant to be abstract, like the cartoon effect seen in Borderlands? Or is it just a subjective term meaning 'really really realistic'?


texts: Reading and writing components from multiple systems in ECS

texts:
As a learning exercise, I'm building my own ECS. I've got a situation where two separate systems want to query and possibly update a Transform component - input handling and collision detection.

Given that each system operates in isolation, as if it were running in its own private thread, I'm effectively doing a concurrent update, but don't really want to block. I'm also concerned that one system might update the transform and then the next system is operating on different data.

Are these valid concern, or are the periods between updates so small that this is negligible and not worth worrying about? If valid, what are some other possible options for solving?


texts: Are there existing software frameworks for traditional "Roll dice and move pawn" boardgames?

texts:
I am looking for a library or framework for creating software versions Roll and Move board games -- games where the basic play centers around players rolling a dice and advancing a pawn along a path.

I'm not interested as much in graphics, rendering methods, and so forth.  I'm more interested in a system for defining these kinds of games, their rules, and managing game states.  Ideally I'd like to see something like an XML file I could create that defines the game, and an interpreter that could load it up and run the given game.


texts: Unreal 4 why does reducing scalability take so long to compile?

texts:
I have almost nothing in my scene--in fact, I reduced my scalability settings from "High" to "Medium" before even loading my level layout--and doing this has crashed the program multiple times. It didn't crash this time, but it is telling me it is compiling over 5000 shaders (!) and my objects' materials are not showing up in the viewport.

1) that is a ton of shaders, what shaders are these? I only made like 8 shaders.

2) What is making this take so long? it is taking forever, over 10 minutes already.

3) Is this normal?


texts:
Here is my function, it makes random point on the ground and makes my sprite go there. If the x position of location is less then position of my sprite, I flip my sprite so it looked left (it looks right by default). But this is not working at all. I tried different flip methods but none work!
Please help what is wrong?

- (void) wander
{
    CGPoint rand = CGPointMake(CCRANDOM_0_1() * 270 , CCRANDOM_0_1() * 140 );

    float distance = ccpDistance([currentSprite position], rand);
    float speed = distance / 2;
    ccTime time = distance / speed;
    CCAction *move = [CCMoveTo actionWithDuration:time position:rand];

    if (currentSprite.position.x > rand.x)
    {

       currentSprite.flipX = YES;
    }
    else {
        currentSprite.flipX = NO;
    }

    [self runAction:move];
}

There is no problem with this code. Problem was that I was trying to flip sprite that was a child of my Pet object. When I tried flipping sprite everything worked just fine. If anybody could explain that, would be great.


texts: How do I add a text area to my 3D android world

texts: i am learning 3d game development on android , i was wondering is it possible to add text areas or any thing that allows a user to enter a text in a 3d world ? and how ?


texts: Perlin Noise generation always returning zero

texts:
I am using noise and I can't get Perlin Noise working, only the Simplex Noise.
So far I got this:

import noise

values = list()
string = str()
oct = 1

for y in range(20):
    print("[", end = "")
    for x in range(40):
        i = round(noise.snoise2(x, y, octaves = oct), 5)
        values.append(i)
        if i > 0.3:
            print("#", end = "")
            string = string + "#"
        else:
            print("-", end = "")
            string = string + "-"
    print("]\n", end = "")

When I try to use Perlin noise instead, I get a value of zero for every x & y.


texts:
Could I please get an example of the correct syntax for calling the

  Invert ( out vector X, out vector Y, out vector Z )

function


texts: (XNA) Checking coordinates, directly vs List vs Dictionary>

texts:
I'm currently working on a generator that generates rooms in biomes and i was wondering what is the fastest way of checking if a certain position is already occupied.

I've got 3 possible ways of doing this:

1. Use nested foreach loops to directly loop through all rooms and check the position. (ugh)

public bool IsOccupiedPosition(Vector2 position)
{
    foreach (Biome biome in this.Biomes)
    {
        foreach (Room room in biome.Rooms)
        {
            if (room.Position == position)
            {
                return true;
            }
        }
    }
    return false;
}

2. Use a List, put everything in there, then check that using the Contains() method.

public List<Vector2> RoomCoordinatesAsList { get; set; }

public void AddRoomCoordinates(Vector2 position)
{
    this.RoomCoordinatesAsList.Add(position);
}

public bool IsOccupiedPosition(Vector2 position)
{
    return this.RoomCoordinatesAsList.Contains(position);
}

3. Use a Dictionary, where the first type is the X position and the second a list of Y positions. (my preference)

public Dictionary<float, List<float>> RoomCoordinates { get; set; }

public void AddRoomCoordinates(Vector2 position)
{
    if (!this.RoomCoordinates.ContainsKey(position.X))
    {
        this.RoomCoordinates.Add(position.X, new List<float>());
    }
    this.RoomCoordinates[position.X].Add(position.Y);
}

public bool IsOccupiedPosition(Vector2 position)
{
    return (this.RoomCoordinates.ContainsKey(position.X) &&
        this.RoomCoordinates[position.X].Contains(position.Y));
}


texts: Loading SpriteFont through a different class than Game.cs

texts:
I am trying to load up a single SpriteFont to print some debug information.
In our current game, we load up both Textures and Music through a ResourceManager. They are both loaded with a filestream, and thus do not require Content.Load

SoundEffect soundEffect = SoundEffect.FromStream( fs );

Since this ResourceManager does not inherit from Game or is like Game.cs, I cannot use the usual method:

SpriteFont spriteFont = Content.Load<SpriteFont>(resource.Key.Item2);

Anyone have any idea how I can either:
-Load the SpriteFont a different way
-Create my own Contentmanager


texts: How to create a color aura around actors in libGDX?

texts:
Is there an easy mechanism to create a color aura around an actor in libGDX?

Thanks for all tips!


texts: Starter love2d physics program not working

texts:
I am starting out with my first love2d (using LöVE 0.8) physics program. I am just creating some ground/floor, a car body and attaching two wheels with revolute joints and setting the motors a-go.

However, the car stands still, whereas I expect it to move. Can someone glance over the code below and see what I am doing wrong?

UPDATE See below!

function love.load()

  -- Set up world
  love.physics.setMeter(50)
  world = love.physics.newWorld(0, 9.81*50, true)

  -- Window dimensions
  windim = {height = love.graphics.getHeight(), width = love.graphics.getWidth()}

  objects = {}

  -- Ground/Floor
  objects.ground = {}
  objects.ground.body = love.physics.newBody(world, 300, windim.height)
  objects.ground.shape = love.physics.newRectangleShape(2000,20)
  objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape)
  objects.ground.fixture:setFriction(3)

  -- Body of the car; a rectangle
  objects.carbody = {}
  objects.carbody.body = love.physics.newBody(world, 300, 500, "dynamic")
  objects.carbody.shape = love.physics.newRectangleShape(100,40)
  objects.carbody.fixture = love.physics.newFixture(objects.carbody.body, objects.carbody.shape)
  objects.carbody.fixture:setFriction(3)
  objects.carbody.fixture:setDensity(3)
  objects.carbody.fixture:setRestitution(0)

  -- First wheel
  objects.wheel = {}
  objects.wheel.body = love.physics.newBody(world, 330, 520, "dynamic")
  objects.wheel.shape = love.physics.newCircleShape(20)
  objects.wheel.fixture = love.physics.newFixture(objects.wheel.body, objects.wheel.shape)
  objects.wheel.fixture:setFriction(3)
  objects.wheel.fixture:setDensity(3)
  objects.wheel.fixture:setRestitution(0.6)

  -- Second wheel
  objects.wheel2 = {}
  objects.wheel2.body = love.physics.newBody(world, 270, 520, "dynamic")
  objects.wheel2.shape = love.physics.newCircleShape(20)
  objects.wheel2.fixture = love.physics.newFixture(objects.wheel2.body, objects.wheel2.shape)
  objects.wheel2.fixture:setFriction(3)
  objects.wheel2.fixture:setDensity(3)
  objects.wheel2.fixture:setRestitution(0.6)

  -- Create joint between car body and first wheel
  objects.carbody.wheeljoint1 = love.physics.newRevoluteJoint(objects.carbody.body, objects.wheel.body, 330, 520)
  objects.carbody.wheeljoint1:enableMotor()
  objects.carbody.wheeljoint1:setMaxMotorTorque(10000) -- Following example from http://www.emanueleferonato.com/2011/08/22/step-by-step-creation-of-a-box2d-cartruck-with-motors-and-shocks/

  -- Create joint between car body and second wheel
  objects.carbody.wheeljoint2 = love.physics.newRevoluteJoint(objects.carbody.body, objects.wheel2.body, 270, 520)
  objects.carbody.wheeljoint2:enableMotor()
  objects.carbody.wheeljoint2:setMaxMotorTorque(10000)

end

function love.update(dt)
  -- Set contstant speed for the wheels
  objects.carbody.wheeljoint1:setMotorSpeed(20)
  objects.carbody.wheeljoint2:setMotorSpeed(20)

  world:update(dt)

end

function love.draw()
  love.graphics.print(objects.carbody.wheeljoint1:getMotorSpeed(), 10, 10)

  -- Render ground
  love.graphics.setColor(72, 160, 14)
  love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints()))

  -- Render car body
  love.graphics.setColor(72, 160, 200)
  love.graphics.polygon("fill", objects.carbody.body:getWorldPoints(objects.carbody.shape:getPoints()))

  -- Render wheels
  love.graphics.setColor(193, 47, 14)
  love.graphics.circle("line", objects.wheel.body:getX(), objects.wheel.body:getY(), objects.wheel.shape:getRadius())
  love.graphics.circle("line", objects.wheel2.body:getX(), objects.wheel2.body:getY(), objects.wheel2.shape:getRadius())
end

UPDATE
I added a line to print the angle of one of the wheels (see below). When this line is present, suddenly the car flips over from the wheels spinning when it hits the ground. This leads me to believe that something did not get initialized properly first time around.

This is the line added:

function love.draw()
  love.graphics.print(objects.wheel.body:getAngle(), 10, 10) -- Line added


texts: World Canvas InputField cursor precision/control from RenderTexture output in Overlay UI

texts:
How do you have a world canvas input field cursor be controllable from the input being mapped from a UI overlay with its raw image supplied from render texture from a render camera?
Described another way:
World Canvas Input Field -> Render Camera creates renderTexture for -> Screen Overlay UI Raw Texture -> Main Camera
How do you have the cursor position be mapped from the Screen Overlay UI Raw Texture?


texts: Apply a texture on a Box - jMonkeyEngine

texts:
How can i wrap a texture (for ex a 4x4 pixels) on a box (1x1x1) in such a way that the texture is repeated and not enlarged to cover all the surface.

 Geometry box = new Geometry("Box", new Box(1f,1f,1f));


texts: BlitzMax - generating 2D neon glowing line effect to png file

texts:
Originally asked on StackOverflow, but it became tumbleweed.

I'm looking to create a glowing line effect in BlitzMax, something like a Star Wars lightsaber or laserbeam. Doesn't have to be realtime, but just to TImage objects and then maybe saved to PNG for later use in animation. I'm happy to use 3D features, but it will be for use in a 2D game.

Since it will be on black/space background, my strategy is to draw a series of white blurred lines with color and high transparency, then eventually central lines less blurred and more white. What I want to draw is actually bezier curved lines. Drawing curved lines is easy enough, but I can't use the technique above to create a good laser/neon effect because it comes out looking very segmented. So, I think it may be better to use a blur effect/shader on what does render well, which is a 1-pixel bezier curve.

The problems I've been having are:

Applying a shader to just a certain area of the screen where lines are drawn. If there's a way to do draw lines to a texture and then blur that texture and save the png, that would be great to hear about. There's got to be a way to do this, but I just haven't gotten the right elements working together yet. Any help from someone familiar with this stuff would be greatly appreciated.
Using just 2D calls could be advantageous, simpler to understand and re-use.
It would be very nice to know how to save a PNG that preserves the transparency/alpha stuff.

p.s. I've reviewed this post (and many many others on the Blitz site), have samples working, and even developed my own 5x5 frag shaders. But, it's 3D and a scene-wide thing that doesn't seem to convert to 2D or just a certain area very well. I'd rather understand how to apply shading to a 2D scene, especially using the specifics of BlitzMax.