texts: How do Action RPGs make different weapon types feel unique?

texts:
I'm getting feedback on my game which has Action RPG elements (think Diablo, Torchlight, etc.) but you control a team of heroes.  When you kill enemies sometimes new weapons will drop.  In my game the DPS of the weapon will be randomized but stronger the further you get.  Each weapon type has a hard coded range and rate of attack, but it differs between types.  As an example, every Pistol will attack once per second and every Machine Gun will attack 5 times per second.

A common complaint I'm getting is:

  The weapons needs more variety, there's not really many reasons to change weapons because they all have the same speed and small damage differences.

I'm struggling to achieve this.  I can vary speed and range for each type, and this seems like an "ok" solution but it's not good enough.  This just feels like a sliding scale that looks like this:

range <-----|-----------------> rate of attack
dps: 10

Here you can change the range and the rate of attack, but the DPS is still going to be based on the level of the enemies.  In the end, it's still not going to matter which weapon you choose because they'll all have about the same DPS.

If I make it so they don't have the same DPS, then yeah, there will be reasons to change weapons, but it'll be because some weapons suck and some weapons are good.  I don't think this puts me in a better place.

I want the player to feel like weapon type X has pros and cons over weapon type Y.  How can I achieve this?


texts: Better way to handle speed able time and action in unity

texts:
I have came across a problem where i have to do some time based task(simulation) like,
As the game started:

After 2 mintues launch a missle.
After 4 mintues star a train on    track
after 12 minutes start the charater walk etc
Now i am considering two approaches (other are also welcome)

Each script manage its time:

void Start()
{
    StartCoroutine("MyEvent");
}

private IEnumerator MyEvent()
{

    yield return new WaitForSeconds(120f); // wait two minutes
    //Launch missle etc

}

Like this kind of script attach with every object that require action after certain time:
Problem:

How do i speed up its time ?
Maybe Performance intensive.

One Timer Global script:

function Update ()
{
Timer += Time.deltaTime; //Time.deltaTime will increase the value with 1 every second.
if (timer>= 120){
//launch missle, an so one conditions
}

}

Now using above script i can get Timer variable in other script and can execute my task on based on time. Now the question is that how do i manage it first way or second way or third way(by you)?
Beacause i also want to speedup the time too which seems impossible with coroutine.


texts: I have a frag shader, one with an empty s_lightMap, how and why is it effecting the output?

texts:
I have an image of concrete rocks of different shades of colors, and I'm applying this shader, but without referencing s_lightMap's uniform in my program:

        precision mediump float;
        varying vec2 v_texCoord;
        uniform sampler2D s_baseMap;
        uniform sampler2D s_lightMap;
        void main()
        {
          vec4 baseColor;
          vec4 lightColor;

          baseColor = texture2D( s_baseMap, v_texCoord );
          lightColor = texture2D( s_lightMap, v_texCoord );
          gl_FragColor = baseColor * (lightColor + 0.25);
        }

it displays a picture with variable light color added to the final pixel color, but s_lightMap isn't even linked into the program, what is happening in this case, at first I thought it would just do the baseColor as the FragColor, but the addition of the 0.25 makes a non-negative result to (lightColor + 0.25). I'm confused, one minute I think lightColor would be set to a texture of 1's the next an array of 0's.

Or is it just random data? It doesn't appear at all random in the picture, it looks like it's obeying a rule of shading.

I'd like to mimic this effect in code that's not broken.

Here's the unshadded image:

Example "gimped" image of how it has variable shades (though this is an invert):


texts: What is a simple deformer in which vertices deform linearly with control points?

texts:
In my project I want to deform a complex mesh, using a simpler 'proxy' mesh.

In effect, each vertex of the proxy/collision mesh will be a control point/bone, which should deform the vertices of the main mesh attached to it depending on weight, but where the weight is not dependant on the absolute distance from the control point but rather distance relative to the other affecting control points.

The point of this is to preserve complex three dimensional features of the main mesh while using physics implementations which expect something far simpler, low resolution, single surface, etc.
Therefore, the vertices must deform linearly with their respective weighted control points (i.e. no falloff fields or all the mesh features will end up collapsed) - as if each vertex was linked to a point on the plane created by the attached control points and deformed with it.

I have tried implementing the weight computation algorithm in this paper (page 4) but it is not working as expected and I am wondering if it is really the best way to do what I want.

What is the simplest way to 'skin'* an arbitrary mesh, to another arbitrary mesh?

*By skin I mean I need an algorithm to determine the best control points for a vertex, and their weights.


texts: How do physics bones relate to animation bones?

texts:
Skinned animations use a tree of bones where the child bone (say a finger) is the weighted sum of the rotations of all it's parent bones. Physics bones are defined as a rotation matrix of a primitive (a cube) that has its position constrained by each of its child bones.

Is there any correlation with how they map to each other?
Can a physics bone be used in-place of an animation bone?

Thanks in advance.


texts: So I've been exporting and re-exporting my mesh from Blender and importing it into UE4 over and over again. For some reason, even after I've generated the light map in Blender, renamed both UV maps, re-applied the UV maps, baked the textures, then changed the Light Map resolution in UE4 to 512, the Light Map Coordinate to 1, and built the lighting, my mesh is still black and I can't figure out why since I've tried literally everything I could find in my research. In the image below, the left mesh is what it's supposed to look like, and the right mesh is what it looks like after building the lighting. Please help me with this, thank you.


texts: How does super.render() call this method?

texts:
Today I was experimenting with adding different screens with Scene2d in libgdx and while doing so I became confused how super.render() in my render() method from my starter class (MyGdxGame) called render() in my PlayScreen() class. Basically I understand you use super to call methods, fields, invoke a super class constructor etc... however I don't see how my Main class witch extends Game is a subclass/derived class of my PlayScreen class witch simply implements Screen. In short I don't see how those two classes are related so that super.render() in MyGdxGame class can call render() in my PlayScreen class.

Also I looked at the API and Screen implements ScreenAdapter and Game implements ApplicationListener but I still don't see how that connects.

Starter class:

public class MyGdxGame extends Game {
    Game game;

    @Override
    public void create() {
        game = this;
        setScreen(new MainMenu(game));
    }

    @Override
    public void render() {
        super.render();
    }

    public void dispose() {
        super.dispose();
    }

    public void pause() {
        super.pause();
    }
}

PlayScreen class:

public class PlayScreen implements Screen {
    private static Player player;
    SpriteBatch batch;
    GameControls x;
    CollisionManager collisionManager;
    ArrayList<Tree> trees;
    Iterator itr;
    Enemy enemy;
    Animations animation;
    Game game;
    MainMenu mainMenu;

    public PlayScreen(Game game, MainMenu mainMenu) {
        this.game = game;
        this.mainMenu = mainMenu;
    }
// more code ...
}


texts: Reflection shader (orginated from XNA 10 years ago) doesn't work - Model is just black?

texts:
can anyone help me with this one.

I'm creating a 3D game. For my game, i have created a lot of 3D objects. Im everything works as intended so far, but I'm trying to implement a "Chrome Reflection" material i need to use for some of the objects. I can find a lot of XNA samples ,and Unity samples, none of them seems to work with Monogame.

I am absolutely no expert in Shaders (HLSL), please if anyone can give me a hint :)

Here is the shader code:

#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

float4x4 World;
float4x4 View;
float4x4 Projection;
float4x4 WorldInverseTranspose;

float4 TintColor = float4(1, 1, 1, 1);
float3 CameraPosition;

Texture2D SkyboxTexture;
samplerCUBE SkyboxSampler = sampler_state
{
  texture = <SkyboxTexture>;
  magfilter = LINEAR;
  minfilter = LINEAR;
  mipfilter = LINEAR;
  AddressU = Mirror;
  AddressV = Mirror;
};

struct VertexShaderInput
{
  float4 Position : POSITION0;
  float4 Normal : NORMAL0;
};

struct VertexShaderOutput
{
  float4 Position : POSITION0;
  float3 Reflection : TEXCOORD0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
  VertexShaderOutput output;

  float4 worldPosition = mul(input.Position, World);
  float4 viewPosition = mul(worldPosition, View);
  output.Position = mul(viewPosition, Projection);

  float4 VertexPosition = mul(input.Position, World);
  float3 ViewDirection = CameraPosition - VertexPosition;

  float3 Normal = normalize(mul(input.Normal, WorldInverseTranspose));
  output.Reflection = reflect(-normalize(ViewDirection), normalize(Normal));

  return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    return TintColor * texCUBE(SkyboxSampler, normalize(input.Reflection));
}

technique Reflection
{
  pass Pass1
  {
    VertexShader = compile VS_SHADERMODEL VertexShaderFunction();
    PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
  }
}

I don't get any errors, but the model is just "black" :(
(Normal rendering using BasicEffect)

(Rendering using the reflection shader)


texts: Line renderer's baked mesh not moving correctly with the line

texts: I used LineRenderer' Bakemesh to create a mesh around the line drawn, it is placed exactly, but when the line moves, the mesh is not following its movement.


texts: Basic knowledge for 2d gaming and images?

texts:
Can anybody refer me some pdf or ebook that i should follow for basic 2d programming and  texture ,shaders and other gaming elements details in depth.By which i can easily get through the 2d game programming.

Thanks,
Balraj.


texts: Spawning prefab on touch after previous spawn(s) had been destroyed

texts:
I wrote a script which pawns an object (instantiated prefab) each time the player touches the screen.
The maximum number of these spawned objects active in the scene at once is 3, and when they are not visible they will be destroyed. I need these prefabs to be able spawn again after they had been destroyed.
I tried this but it does not work...
This script is added to a game object called "canCreator" in my scene hierarchy:
public class CreatingCan: MonoBehaviour
{
    public GameObject Can;
    public int numberOfCans;
    public bool canSpawn = true;

    private void Start()
    {
        numberOfCans = 0;
    }
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            Vector2 TouchPosition = Camera.main.ScreenToWorldPoint(touch.position);
            if (touch.phase == TouchPhase.Began && canSpawn == true)
            {
                if (Instantiate(Can, TouchPosition, Quaternion.identity))
                {
                    numberOfCans++;
                }
            }
        }

        if (numberOfCans >= 3)
        {
            canSpawn = false;
        }

    }

}

This script is on my can prefab:
public class fallingCan : MonoBehaviour
{
    CreatingCan CC;
    private void Update()
    {

        if (transform.position.x < Camera.main.transform.position.x - 10)
        {
            Destroy(gameObject);
               CC.numberOfCans--;
        }
    }
}


texts: How to create temp folder to store a file from external directory and use it in a game

texts:
I would like to copy a 3D model from external library and save it in temp/Resources/StreamingAssets folder to instantiate an object in unity scene.
`

public class FBXOBJLoader : MonoBehaviour {

    string src;
    // Use this for initialization
    void Start () {
        src = EditorUtility.OpenFilePanel("Select Model", "", "fbx");
        //Output the Game data path to the console
        Debug.Log("Path : " + src);
        StartCoroutine("CopySomething");
    }

    IEnumerator CopySomething()
    {
        print("Start");
        string path;
        path = Application.temporaryCachePath;
        FileUtil.CopyFileOrDirectory(src,path);
        yield return null;
    }
}

It's creating some unknown file format in the asset folder. can anybody please help me to complete this task.

Thanks in advance


texts:
I have added a video link for any one who whats to see what the problems are by watching the game.

I am trying to create a player movement system and there are small problems that I am running into.

I want to find the most accurate way of knowing if player is colliding with another object. I tried using if (Player.Body.LinearVelocity.Y == 0.0f) then player is not jumping and on ground. But if I add force to the X axis the y will fluctuate.   I also tried to use OnCollision but am confused on how to use it.

What is the best way to know if the player is colliding with the ground and can jump?
The player slides across the ground like it's ice how do i fix this problem? How would I make it into quick and sudden stops with little sliding.
Lets say I had a one color texture, and I wanted to use it on a rectangle and a circle but could not bother to make 2 textures and just want to do it in the coding. How could I make this texture go from a rectangle to any shape I want?
If OnCollision is the best way for me to detected where the player is hit (left, right, top, or bottom) and then use for the best and quickest collision test, were can I learn how to use this thing properly?
Here is the Video.
How do you delete an object, I got the texture to go but not the object itself. The objects are spawned in and then stored on a list. How do you remove them from the list?
How come the player on the top left is more clearer then the player being controlled?


texts: Where does XNA 4.0 takes memory from to perform operations?

texts:
I found this question which talks around the question I'm interested in. In particular I focused on the line where the guys says that GraphicsDevice object is literally a representation of the underlying graphics card.

Now, can I assume that XNA automatically uses the memory directly from the underlying graphics card (to perform the most expensive calculations like updates and drawing)?

If so, is everything (like thread management) already optimized or there are way to configure the device depending my various cases? If not, do I have to tell the GraphicsDevice object whether to use or not the GPU memory rather than the CPU?


texts: How to make a custom semantics HLSL shader for the pixel shader

texts:
I'm pretty sure it's possible but i have no idea how.

Could anyone tell me how to make a custom semantic for a pixel shader.

Thanks


texts: How do 2D physics engines solve the problem of resolving collisions along tiled walls/floors in non-grid-based worlds?

texts:
I've been working on implementing my SAT algorithm which has been coming along well, but I've found that I'm at a wall when it comes to its actual use. There are plenty of questions regarding this issue on this site, but most of them either have no clear, good answer or have a solution based on checking grid positions.

To restate the problem that I and many others are having, if you have a tiled surface, like a wall or a floor, consisting of several smaller component rectangles, and you traverse along them with another rectangle with force being applied into that structure, there are cases where the object gets caught on a false collision on an edge that faces the inside of the shape.

I have spent a lot of time thinking about how I could possibly solve this without having to resort to a grid-based system, and I realized that physics engines do this properly. What I want to know is how they do this. What do physics engines do beyond basic SAT that allows this kind of proper collision resolution in complex environments? I've been looking through the source code to Box2D trying to find out how they do it but it's not quite as easy as looking at a Collision() method. I think I'm not good enough at physics to know what they're doing mathematically and not good enough at programming to know what they're doing programmatically. This is what I aim to fix.


texts: I am using C++ plugins and passing out array ptrs in my function.  Unity 5.6 keeps complaining about unsafe code.  I added every type of .rsp file with the "-unsafe" keyword, but none of it works.  Anyone figure this out for unity 5.6?


texts: Why don't most major game engines use gifs for animated textures?

texts:
What is better to use Animation Sheets or Gifs? One advantage Gifs have over Animation Sheets is that you don't have to think about frames going too fast or too slow because of your code and updating in proper ticks.

What are the disadvantages to using Gifs and advantages Animation Sheets have over Gifs?


texts: How do I programmatically remove an image's background color?

texts:
I have a sprite sheet (image) and want to draw it on screen.

image  = sprite sheet image
x      = player x position
y      = player y position
width  = player width
height = player height

public class main extends japplet
{
    ...

    public void paint(Graphics g)
    {
        g.drawImage(image, x, y, x+width, y+height,
                   0, 0, 40, 40 ,sprite_sheet.m1);
    }
}

On the sprite sheet, I have the image of a player with a blue background color. Calling drawImage shows the blue background too. I could remove the color with Photoshop, but I really don't want to, because it would remove part of my player.

Can I remove the background color with Java code?


texts:
I want achieve a view like Mode 7 from snes games where the closer textures get stretched out more and more far away textures look smaller. Something like this:

What I have in my project at the moment is a flat 2d floor made from multiple textures aligned next to each other, but I'm not sure on how to add perspective to it. I'm using a matrix to transform the view, but when I tried using Matrix.CreatePerspective I only got an empty view. Is this effect possible to achieve using matrices? Or do I have to use the billboard effect on every texture that I'm drawing? And if so, how do I make it so that it's still possible to rotate the camera in every direction? I'm new to matrices and 3d in Monogame, so this is still confusing to me.


texts: Simple stupid funnel algorithm without visible points

texts:
In the simple stupid funnel algorithm we are searching for consecutive portals points, that are tightening the funnel (the angle between the current left and right point decreases).

But what when there is no single visible point, that would tighten the funnel, like presented on image below. How to determinate next apex and current left and right point?


texts: How can I prevent/balance waiting and turtling as a response to cooldown mechanics

texts:
I'm working on a turn-based RPG with classes. I want one of the spellcaster classes to have standard magic points, but another to have abilities with time limitations, one or more of

Use ability every N minutes of real time
Use ability every N turns of combat
Use ability once or N times per day (sleep to restore, or wait out day-night cycle)

There would be restorative items that could restore your "charge". These abilities would be more powerful than regular spells but constrained. This spellcasting class is a burster: gives you big hits but infrequently because of the limitations. The party carries them along as baggage until they get in a jam or run into a boss, then unleashes the hammer. I like it as an option to add depth, and it has interesting speedrun possibilities.

The last one is easy enough to balance if the party has to trek back to town and sleep to recharge, but I have a day-night cycle. Here are the problems as I see it:

Real time / N times per day

Player can just wait. I can make the duration punishing, but then it greatly reduces the utility. It also means that the player is not playing the game, this is after all supposed to be about entertainment. No fun.

Every N turns in combat

Player can just have every character defend/heal every round until the burster unleashes another round of big damage. I actually want this to be viable, but I don't want it to become the obviously best strategy for battles. So far it doesn't seem to be a huge issue as the caster just cycles through lesser powers until the big bang recharges. It's rough in the early game, but that's part of the balancing. The problem is that I'm having trouble getting it to be not so OP'd as to be obviously the best while still remaining good enough to be useful.

Any suggestion on how to balance these mechanics to mitigate camping/turtling?


texts: I don't know what the circle in the image below used for changing directions and movements of a character is called. Can anyone provide me anything related to it? I want to include it in my game.


texts:
Just a simple question.
To do lighting in tangent space, just take the transpose of the TBN basis Matrix and multiply that against the light direction.

Is that right?
Here is my code

 float3 normalT = 2.0f*normalMapSample - 1.0f;

    // Build orthonormal basis.
    float3 N = pin.NormalW;
    float3 T = normalize(pin.TangentW - dot(pin.TangentW, N)*N);
    float3 B = cross(N, T);

    float3x3 TBN = float3x3(T, B, N);
    TBN = transpose(TBN);

    float3 bumpedNormalW = mul(normalT, TBN);

AND

float diffuseFactor = dot(lightVec, bumpedNormalW);

Is that right because I'm getting my grid all dark. the rest of the scene seems to be right.


texts:
I was curious if anyone could explain how I would be able to create simple movement handling in monogame. So far I have a red block which I tried to move by using a loop but that didn't take any effect.

protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            position = new Vector2(0, 0);
            texture = new Texture2D(this.GraphicsDevice, 100, 100);
            Color[] colorData = new Color[150 * 150];
            for(int i = 0; i < 10000; i++)
                colorData[i] = Color.Red;
            texture.SetData<Color>(colorData);
            base.Initialize();
        }

I also have created this handler but I don't exactly know what I have to do next.

/*protected override void HandleInput(KeyboardState keyState)
        {
            if (keyState.IsKeyDown(Keys.W))
            {
                // Look Up
            }
            if (keyState.IsKeyDown(Keys.S))
            {
                // Look Down
            }
            if (keyState.IsKeyDown(Keys.A))
            {
                // Move Left
            }
            if (keyState.IsKeyDown(Keys.D))
            {
                // Move Right
            }
        }*/


texts:
This is my TextField:

EditorGUILayout.TextField("Placeholder Text", textfield, GUILayout.Height(35));

How can I add a placeholder text in my textfield that will be removed when I want to type in the field?


texts: Increasing chance of good loot after multiple tries

texts:
I'm looking for a way to make chances of getting better loot increase the more you've looted. I do not want it to be possible to get a rare item the first 5 times and not being able to get an epic item the first 10 times.

However, the more the player loots, the better chance he should have of getting better items/less chance of getting nothing, normal, ...

This is my current code, but it is, as you can see, completely static. I know this might not be of much help, but at least it shows an overview of the items and the %-chance I have in mind.

var rand = random(100); // Random number 0-100
if(rand < 40){
    return LOOT_NOTHING;
}else if(rand < 70){
    return LOOT_NORMAL;
}else if(rand < 90){
    return LOOT_UNCOMMON;
}else if(rand < 99){
    return LOOT_RARE;
}else{
    return LOOT_EPIC;
}

The project is written in GML, but pretty much any language will suffice as an answer as it's not very language-specific.


texts:
I'm working on a little MMO game as a learning experience, the server coded in Python.

When a player logs in it pulls their character data from a SQL db and into server memory. It then uses memory for just about all things in the game and only uses the database again to back up the states at periodic save intervals, or when that player leaves/disconnects.

My question though is about the chat system. I've made chat systems before for websites where it just pulls from mySQL databases. But as I've learned accessing databases can be expensive for MMOs.

Currently in my build, chat is just sent to and stored locally by the player as and when it happens, but if an important guild message is sent while the player is loading between zones/channels then they don't receive it.

Is my current way the 'common' one? (just needing tweaks) Or should I be pulling chat from a SQL database? Or should chat be saved in server memory? Maybe its a mix...

Some pointers in the right direction would be great!


texts: How can I make my table move more realistically after a collision?

texts:
Using Unity 2020.
I have a character using CharacterController and Rigidbody, colliding into the end of a long table.
My table has, as a root object, the mesh and the Rigidbody.
It also has, as child objects, 5 box colliders (4 for the feet, and 1 for the table).
The problem is that when the character collides into the table on one end, the whole table translate in the same direction as the character's travel direction.
But I want the table to move more realistically: I want it to behave like on the right:

What could be the problem there, and how do I fix it?


texts: How can i set OnClick equal to UnityEvent

texts:
The Problem

I'm making a dialogue system for a small 2d rpg.
I Have a Dialogue class with two lists for pages and responses. The response class
has a UnityEvent so i can use the ui in the inspector to set methods like a button.
Then in a DialogueManager class i have a Show() method which makes a button for every response in the list from Dialogue. The problem is when i try to set the created button's OnClick() event to the UnityEvent in the response.

The Question

So the question is how can i set the button's OnClick() to the methods in the UnityEvent from the response?


texts:
I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done.

I have came across that piece of code, but I can't get what it does 100%

if ((float)rand()/(float)RAND_MAX < 0.5) {
        m_Pos.x = -app::getWindowWidth() / 2;
        if ((float)rand()/(float)RAND_MAX < 0.5)
            m_Pos.x = app::getWindowWidth() / 2;
        m_Pos.y = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth());
    } else {
        m_Pos.x = (int) ((float)rand()/(float)RAND_MAX * app::getWindowWidth());
        m_Pos.y = -app::getWindowHeight() / 2;
        if (rand() < 0.5)
            m_Pos.y = app::getWindowHeight() / 2;
    }

    m_Vel.x = (float)rand()/(float)RAND_MAX * 2;
    if ((float)rand()/(float)RAND_MAX < 0.5)
    {
        m_Vel.x = -m_Vel.x;
        }

    m_Vel.y =(float)rand()/(float)RAND_MAX * 2;

    if ((float)rand()/(float)RAND_MAX < 0.5)
        m_Vel.y = -m_Vel.y;


texts: How to quickly create meshes that have cutouts of other meshes?

texts:
I have a mesh and I would like to quickly create planes (or boxes) that have cutouts in the shape of the silhouette that mesh, but rotated at various angles. I would like to have a system to which I can feed any mesh and it will output these cutout planes, either for random or predefined rotations of the mesh.

In the game I'm making, you have a 3D object, like a chess piece, that you rotate and translate to try to fit it in a hole in a wall that has the shape of the object. But the hole can be in the shape of any rotation of that object. For instance, in the case of a pawn, the hole can look like an upright pawn, so you wouldn't have to rotate the pawn at all; or it could just be a circle the size of the base of the piece, so you would have to rotate the pawn so it either goes in feet or head first. I want a program to procedurally generate walls with these kinds of holes for any mesh I give it.


texts: Issue with Sorting Layers with an NPC and Tilemap

texts:
I have a weird thing happening, that I can't quite explain.  I have two scenes, my starting town, and an Arcanist's shop.  When I go into the Arcanist's Shop, the Arcanist NPC stays on the same sorting layer (background layer 0) as my checkered tiles, and the table is background layer 1.  When I start the game, the NPC will switch between being "behind" the table, or on top of it whenever I reenter the Arcanist's Shop scene.  It seems to switch between background layer 0 and 1 with no cause.

I've double checked my sorting layers, they're all where they should be.  I've checked the camera's culling mask, it's fine.  I've checked to see if there are any weird components on anything in my shop scene, and there aren't

See the image attached, this is the same instance of the game, just different times when I enter the Arcanist's Shop.

Screenshot of my tilemap setup:


texts: How to display Textures, Buttons, Created with Unity's GUI (OnGUI()) to get displayed behind other objects in Scene

texts: I am making a game in which I am using OnGUI() to make Texture. I want this texture to display behind my Regular 3D objects like cube, spheres in the scene. I have tried and searched but I am unable to figure it out. Is this Possible?


texts: What does "formalism" mean in the context of video game theory?

texts:
I've come across the term "formalism" in a number of articles and discussions on the topic of video games. What does it mean?

PS: if I'm posting in the wrong place, could someone please link me a forum/site where I can ask academic game theories questions?


texts: Unity animations not playing where they are suppose to be

texts:
Hello to all those Unity Developers out there, I am having a big issue with my game, what I am trying to do is to make a cutscene but when I change camera it just goes in a completely different spot.
There are no scripting errors and the only thing that I have on the camera (Blender model) is an animator component that plays the animation when the DCT (Drone, Camera, Thing) flies into the room.
Should I try to not equip the camera with the DCT model or should I remove the animator component?


texts: Runtime Java Module Generation for Game Plugins

texts:
Edit:
Clarification:

I want to create a named module during runtime and put dynamically loaded classes into the created module.

I am attempting to build a framework that allows for code generation that is compatible with Java 9's module system. I require the ability to load some generated byte code into a "virtual" module.

From what I can tell after looking though the Java code there are no exported and public methods that allow me to do anything like this, but I am sure I am missing something.

For an example, let's say this class is generated for the module "handler".

package handler;

public class ModHandler{
    public static String fireEvent(){
        return "This is a string from the generated module!";
    }
}

How do I make the "handler" module and load the bytecode into it?
How would you add exports and requires into the module?
I do not want to write anything to the disk to implement this.


texts:
I'm rendering to a texture via DrawIndexedPrimitive (SharpDx). In some specific situations, the framerate drops significantly when doing this render. The framerate can be improved by rendering to a smaller texture.

I want to gracefully degrade the quality of the graphics performance at runtime by measuring the impact of this particular pass and rendering to a smaller texture if the framerate would be impacted by this pass. Later, when the impact of this pass is smaller I want to restore the larger texture size.

Is there some way to measure at runtime the impact of a particular draw on the gpu? It's ok if the results of the measurement are delayed to the next frame.


texts:
I've been looking for a book on actionscript3 development, but while there's tons of books out there, nobody seems to want to recommend any specific one.

One book I've been pointed towards is the cookbook by o'reilly, but it, like most books out there, seems to be based on the assumption that I'm using flexbuilder or flash. Instead, I'm "just" using flashdevelop, or the free SDK directly.

I've also been told to just go with the api reference and live with it. I could do that, I suppose, but I'd rather have a book that gives me the big picture. Kind of like with cocoa, there's the hillegrass' book, or the red book of OpenGL.

So, what would be the actionscript3 book out there?


texts: Must I buy licenses if my rhythm game lets users load music from their own library to be played in-game?

texts:
I want to create a music rhythm game, where any user can load the "map" for a song from the game server, if they have a song's sound file in their own library. Each "song map" contains information about its rhythm structure (for the game to interpret) but doesn't include any sound.

I want to monetise the game (through advertising or cosmetic items), but I don't intend to sell any music or song maps.

Do I need to pay any money to artists in this case?


texts: How do I check whether a camera has unobstructed view of a GameObject?

texts:
I want to check if a GameObject is visible to the camera. The renderer.isVisible-method only checks if the camera is turned towards the object, not if there is anything between them (like a wall).

How can I check whether the object is actually visible?


texts: How can I make a trail renderer flat with the normal of the nearest face?

texts: I'm making a basic skid system for a car model using a trail renderer. I have everything setup and working properly except that the trail renderer always faces the camera. I want the trails to be perfectly flat with the ground. So I thought if unity can make the faces all rotate towards the camera, then would it be able to rotate towards the normals of the nearest faces?


texts: How can I disable/dim the screen when I click the pause button?

texts:
I am working in an android game using cocos2d. I want to dim the background screen when I click the pause button.

How can I do this ?


texts: Implementing Achievement System in Javascript

texts:
I understand that for more complex achievements, specific code can't be avoided, but for simple ones like (player clicked 100 times) or (player earned 30 bajillion cookies) or (player played for 1 hour) it should be as simple as abstracting the achievements to something like a list of properties/values and having some event handler.

My problem is that since I'm using Javascript and there's no really clean way to do pointers, how am I supposed to create an achievement class that can be iterated through procedurally?

Ideally I'd like something like this:

Achievement class:

function Achievement(name, property, value, text, points){
  this.name = name;
  this.property = property;
  this.value = value;
  this.text = text;
}

And then I'd add an achievement like so:

achievements.push(new Achievement("Clicktastic", &numClicks, 1000, "You clicked 1000 times!");

And have some kind of function bound to a Window.setInterval that was constantly looping through all achievements and for these simple types doing something like:

for (var i = 0; i < achievements.length; i++){
  if (*achievements[i].property >= achievements[i].value){
    //deal with earning achievement
  }
}

I'm just using some C style pointer/dereferencing notation here.

Basic idea is that I'm not sure how to create a generic achievement that can arbitrarily care about specific properties without pointers.


texts: How can I implement the ability to 'cut' sprites into arbitrary shapes?

texts:
I want to create a game where you have scissors that cut a sprite in a shape that you create by dragging your finger on the screen.

My problem is that I can't figure out how can I cut my sprite in the specific shape that the user creates with their finger.

So far the only solution that I found searching the web is that I'll need to create my own shader that lets me make a specific part of a texture transparent, but don't understand how I can apply that to my scenario?


texts: Read function outside of code while run-time?

texts:
Hi it is my first post on this community. So if i was rude or something please let me know :)

So I just started learning game development alone. It's been about 1 year since I begin to learn c and c++.
Recently I started planning to make a game for my own entertainment and future career.

I'm trying to make the game as mod-friendly as possible.
So I thought that I should make abstract classes that have most of the functions for working on run-time. Then when the game starts, the system reads mod files for filling out class information and stores that base object in some data storage made with a singleton(for easy access). And, then use a factory pattern(I hope I'm using it right) to copy the base object that I need, fill it with basic information and store it in the object storage.

The problem is, I can't figure out how I can make it so each object from each mod file acts with its own behavior.

For example:
Core mod(main game) has an abstract class named 'living entity'
'Living entity' has some information like bone structure type, mesh name, entity size, etc...
And a mod file from the core mod makes a 'human' class that has information for 'human bone type','basic human','human size' etc
The human class does not need any special functions because it only uses basic functions that the game provides.

But modder A wants to make a Vampire entity.
Vampire will have information like a human. So modder A fills up or copies the 'human' file and edits the class id value with which the system identifies objects and uses as a name.
Vampire needs new skills, health effects and custom death(leaves an ash pile instead of a corpse)
The game also has skills and health effects as a kind of component or class. So modder A fills up information but one of the skills has a unique projectile effect or one of the health effects has a unique behavior that the game does not provide
So modder A wants to override projectile or health functions only for the vampire's unique skill or health

In this case how would I support them to override functions for their own needs?
One of my idea was to read the dll and store function pointers in data storage and put the code on a base abstract object and then call it if the object has a custom function.
But I am not sure this works and that it is how people do it.
So if there is some kind of information or documentation for that please let me know
I'm arguing with this problem about month D;


texts: Effectively implementing a game view using java

texts:
I am writing a 2d game in java. The game mechanics are similar to the Pokémon game boy advance series e.g. fire red, ruby, diamond and so on.

I need a way to draw a huge map maybe 5000 by 5000 pixels and then load individual in game sprites to across the entirety of the map, like rendering a scene. Game sprites would be things like terrain objects, trees, rocks, bushes, also houses, castles, NPC's and so on. But i also need to implement some kind of camera view class that focuses on the player. the camera view class needs to follow the characters movements throughout the game map but it also needs to clip the rest of the map away from the user's field of view, so that the user can only see the arbitrary proximity adjacent to the player's sprite. The proximity's range could be something like 500 pixels in every direction around the player’s sprite. On top of this, i need to implement an independent resolution for the game world so that the game view will be uniform on all screen sizes and screen resolutions.

I know that this does sound like a handful and may fall under the category of multiple questions, but the questions are all related and any advice would be very much appreciated. I don’t need a full source code listing but maybe some pointers to effective java API classes that could make doing what i need to do a lot simpler. Also any algorithmic/ design advice would greatly benefit me as well.

example of what i am trying to do in source code form below

package myPackage;

/**
 * The Purpose of GameView is to: Render a scene using Scene class, Create a
 * clipping pane using CameraView class, and finally instantiate a coordinate
 * grid using Path class.
 *
 * Once all of these things have been done, GameView class should then be
 * instantiated and used jointly with its helper classes. CameraView should be
 * used as the main drawing image. CameraView is the the window to the game
 * world.Scene passes data constantly to CameraView so that the entire map flows
 * smoothly. Path uses the x and y coordinates from camera view to construct
 * cells for path finding algorithms.
 */

public class GameView {

    // Scene is a helper class to game view. it renders the entire map to memory
    // for the camera view.
    Scene scene;

    // Camera View is a helper class to game view. It clips the Scene into a
    // small image that follows the players coordinates.
    CameraView Camera;

    // Path is a helper class to game view. It observes and calculates the
    // coordinates of camera view and divides them into Grids/Cells for Path
    // finding.
    Path path;

    // this represents the player and has a getSprite() method that will return
    // the current frame column row combination of the passed sprite sheet.
    Sprite player;
}


texts: Unity2D: Increase spawn object movement when player collects every 10 points

texts:
I want to make my spawned objects (enemy prefabs) movement speed up every 10 points my player collects.
This is my movement script, attached to my enemy prefab (so that it can be spawned in my game and move):

public static int movespeed = 20;
public Vector3 userDirection = Vector3.right;

public void Update()
{
    transform.Translate(userDirection * movespeed * Time.deltaTime);
 }
}

And this is my score script attached to my player:

public Text ScoreText;
public AudioClip Coinsound;
public Text Highscoretext;
public GameObject enemy;
Movement movement;

private int Score;
public int highScore = 0;

void Start ()
{
    Score = 0;
    SetScoreText ();
    if (PlayerPrefs.HasKey ("Highscore"))
    {
        highScore = PlayerPrefs.GetInt("Highscore");
    }
}
void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.CompareTag ("Pick Up")) {
        other.gameObject.SetActive (false);
        Score = Score + 1;
        SetScoreText ();
        AudioSource.PlayClipAtPoint (Coinsound, transform.position);

    }
}

As mentioned before I want to make my spawned enemy prefabs to move faster when my player collects every ten points. Thank you :)


texts:
I have scene rendered with a single camera using target texture (a).
Second camera is used to render UI and using same target texture (a) as the first one.
Third camera takes target texture (a), depth texture and apply post proces. Result is rendered to the screen.

How can I apply postprocess only to the output elements that are not UI?


texts: How to rotate actors around the actor like a satellite around the earth?

texts:
I'm not a pro in LibGDX and physics but I know basics, vectors, actor's actions and so.

I'm trying to achieve a movement like on the gif below:

For now, let's say that I have a stage and a central actor that the moon and comet will rotate around.

The problem is here that I have no idea if this is achievable with 2D. Should I implement some sort of 3D in LibGDX?

Also, is there a way so these objects move in a 'random' path, not the straight line like the comet below? (Moon is a little bit randomized)

I know that this question is too broad, but I really didn't know where to ask about this. I'm here to learn cause I always wanted to build a thing like this. I personally think that this is achievable with LibGDX's actions cause I saw something similiar somewhere.

If someone could point me the way I would be grateful :) Thanks!


texts: Can I have a scene graph translation node with multiple parent nodes?

texts:
I am trying to write a C++ scene graph structure. While designing the node classes I am facing the below issue.

I have a scene graph to represent a house.

I would like to have another house next to the one I have but I would like to reuse the nodes from the existing graph. In order to do that, I create another house (House 2) as a child of the original house (House 1). Although this leads to a situation where the base node in the following graph has 2 parent nodes.

I would like to know, is it a good idea to have a scene graph node (intermediate translation node) to have multiple parents?
I would like to reuse my sub-graph as much as possible.


texts: How is a moving object like a platform represented in a 2d Tilemap

texts:
I'm having trouble understanding how I would implement a moving platform in the actual map file.  Lets say its a file of character's and maybe the letter 'P' would stand for Platform.  Then, how would the game know which direction it moves, how far it's suppose to move before returning, what size it is, etc...  Am I even suppose to represent it in the map file?

I'm coming from the approach of making the game handle the maps as dynamically as possible, where you could basically make a new map file and play it in the game without having to hard code any special information for that map.


texts: XNA Float values don't work as parameter

texts:
With the Microsoft XNA Framework I can change the color of a tinted texture by changing it's integer values like so:

Int x = 255;
if(true) { x--; tint = new Color(x, 255, 255); }
Draw(texture, Vector2.Zero, tint);

If x were a float however the appearance of the sprite wouldn't change until the value x became zero. With integer the texture fades over time with the event change.

Why is this? :S


texts: how change branching logic to math equivalent glsl?

texts:
im totally newbie and this just for fun

afaik lot of best practice suggest to minimize usage of branching.

can you help me optimize below glsl especially on branch part?  ( target 120 )

the bgcolor used for minimum color level,  what i want is alpha outcome become 0.1 if the bgColor choosen on the current fragment otherwise it will get the data from uniform.

bgColor n uLightIntensity will same value for all fragment aplied within this shader.

the texcolor will be varies for each fragment ( depend on texture pixel presentation)

    varying  vec3 v_fragmentColor;
    varying  vec2 v_texCoord;

    uniform sampler2D u_texture;
    uniform  float u_lightIntensity;
    uniform vec4 u_bgColor;

   void main()
{

    vec4 texColor = texture2D(u_texture,  v_texCoord);

    // TODO POSIBLE OPTIMIZE FOR NON BRANCHING
    if(step( u_bgColor.r, texColor.r) == 0.0)
    {
        texColor.a = 0.1;
    }else
    {
        texColor.a =  u_lightIntensity/10.0;
    }
    texColor.rgb = max(texColor.rgb, u_bgColor.rgb);

    gl_FragColor = texColor;

}


texts: Starcraft 2 Editor: I want to make two players share their income

texts:
I have a scenario where there are 4 teams vs. a raging Zerg horde constantly attacking them. The idea was allow that player 1 & player 2 in the same team share their income, so that one player could focus on getting the income (SCV income as they deliver the goods) and the other defending.

I haven't gotten the trigger right yet. Anyone have some tips for me?


texts: Move objects in array with positions array

texts:
I am trying to get a line of spheres to move around but all i get is the first sphere to move and get the rest to follow as one instead of building a sort of a train of spheres. Any idea how to alter the code to get it right?
In the code bellow i get the first pbject in listBalls to move nicely along the Bezier curve but the rest move as one and overlap with the first sphere too.
    void Update()
{

    t += Time.deltaTime * 0.2f;
    ballPosition = Mathf.Pow(1 - t, 3) * p0 + 3 * Mathf.Pow(1 - t, 2) * t * p1 + 3 * (1 - t) * Mathf.Pow(t, 2) * p2 + Mathf.Pow(t, 3) * p3;
    positions.Add(ballPosition);
    listBalls[0].transform.position = positions[j];
    for (i = 1; i < listBalls.Count; i++)
    {
        Transform ball = listBalls[i].transform;
        Transform nextBall = listBalls[i - 1].transform;
        if ((ball.position - nextBall.position).magnitude > 1f)
        {
            ball.position = positions[j];
        }
    }
    j++;

Feels like it should be something easy, setting the N-1 balls to same position as the first ball must be wrong. I tried setting them at positions[j-2] but it didn't work either.
Edit:
the Spheres should start rolling left to right one after the other eventually all 10 should be on the screen and when they reach P3 they should restarting the rolling.

listBalls is the List with 10 spheres
positions is the List with 50 Vector3 positions along the curve.

[![enter code here][2]][2]


texts: MonoGame.Extended Exception when loading a TMX file

texts:
I'm getting a strange exception when trying to load in a .tmx file using MonoGame.Extended. I can load the same .tmx file into other 3rd party libraries (tried to recreate the error) without any problem which makes me suspect it's not something to do with the file.

tiledMap = Content.Load<TiledMap>("Test");  //line of code for exception

Message:

  Microsoft.Xna.Framework.Content.ContentLoadException
  Could not load Test as a non-content file!


texts: Fighting aliasing on specular highlights

texts:
MSAA does a good job removing aliases on mesh edges, but it does not help with aliased specular highlights:

Notice the aliased specular highlights on the doors and windows.

I believe the reason for this lays in the way normals are filtered after being sampled from their maps, so I wonder if there are some known methods how to make highlights more smooth?


texts: Reading text from file changes the text?

texts:
I'm currently trying to load a simple text file and filter it by a certain string. In the text file I'm using a new line for each value and sometimes use a "--" to make things easier to read for me when viewing the .txt-file.

Now, when I load the file and split it by new lines I end up with a list of substrings, each representing a value I need. Plus, all the "seperators" I put into the file.

My goal is to clean the list from all the seperators and basically just remove them from the list. However, RemoveAll does not work and I found out that the strings containing "--" are not really "--", but something else, because using string.Equals("--") fails on them.

Somewhere when reading the data or splitting it, something happened to those parts, but I can't figure out what's happening.

Here's the code:
void Awake() {

    _fileLines = new List<string>();

    TextAsset txt = Resources.Load<TextAsset>("SubjectPages/test");
    _fileLines = new List<string>();
    _fileLines = txt.text.Split(new string[] { "\n" }, System.StringSplitOptions.None).ToList<string>();

    _fileLines.RemoveAll(x => ((string)x) == "");
    _fileLines.RemoveAll(x => ((string)x) == "--");

    for (int i = 0; i < _fileLines.Count; i++) {
        Debug.Log(_fileLines[i] + " | " + (_fileLines[i].Equals("--")) + " | " + (_fileLines[i] == "--"));
    }
}

Removing empty lines with RemoveAll seems to work fine.


texts:
Is there a way to access settings for Google XR Cardboard? I've got a project straight from Google Cardboard for Unity with examples. After building it and running on a phone it shows X and Gear icons in corners of the screen. X exits the application, Gear shows some settings. Can I modify these settings?
Loading up the package creates XR Settings scriptable object, which has nothing in it. I think maybe I should extend the class, fill it with custom settings (by some key that will be then recognized by Google XR) and replace instance of generic XR Settings with my custom ones?


texts: Unity5 How can I create this particle effect

texts:
I have been trying to replicate this particle effect that moves with the mouse:

https://my.pottermore.com/patronus

I have got close with the following settings

but I can't get the movement of the particles to be the same or to have to same intense white glow. It's like they have random direction from the center of the cursor but depending on the mouse speed it's like they have spread out more instead of being clustered on the mouse (hard to explain).

Does anyone know how I would achieve this effect?


texts:
I am currently working on a game and I want to know if there is any way of handling with the elements i am drawing . For example : if i draw in a loop 100 cubes , how can i show / hide the cube number 15 or 63 or n ... clicking  I thought that initializing elements in a list would work , but i didn't find any property of it that could help.

GLuint cube;
cube = glGenLists(1);

 glNewList(cube,GL_COMPILE);

for(int i = -30; i < 3; i++) {
     for(int j = -30; j < 3; j++) {
        glPushMatrix();
        glTranslatef(i*2.0,0,j * 2.0);
           Dcube();

        glPopMatrix();
     }
 }
 glEndList();

I googled a while for deleting elements after displaying them , like in minecraft , but i couldn't find anything useful(e.g: When mouse - right click -> then create cube , and when mouse - left click  -> then delete the cube.. ) Some sugestions would be all i need ..  ...Thank you.


texts: Why is there no standard 3d file format that saves models as (collections of) primitives?

texts:
I have been looking around for a file format that saves models as a collection of primitives (Boxes, Spheres, Cones, Cylinders, etc.). After some research, I came to the conclusion that pretty much every standard available file format saves models as a collection of vertices and indices (and some other stuff like UVs & materials).

Real world example
Why would one need a file format that saves primitives? Well, in my case, I am trying to build a game where I will need to import the physics separately. Since physics are optimized per primitive type, I would deem it wise to not just import everything as a mesh collider but make use of these optimizations.
For context, I am using Three.js with Ammo.js (Bullet) running server-side.

Standard
So the question really is, why is there no standard for this? Why isn't there a standard like SVG but for 3d models? I will probably end up writing my own format / implementation, so it's not like it's holding me back. It's just that I am a bit cautious, since I feel that there probably is a reason for no such standard to exist.

Related links
Here are some links I came across during research:
http://wiki.laptop.org/go/Physics_File_Format
http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization

Edit:
Since comments aren't for thanking people, I'll just do that here. Thanks to all of you that answered and commented, very insightful! Much appreciated!


texts:
I have an enemy that I would like to move as follows:

Start at (0, 200, 0)
Move to (200, 0, 0)
Move to (0, -200, 0)
Move to (-200, 0, 0)
Move to start point, repeat as long as it remains active.

This is what I've done to achieve that:

if (position.X < 200 && position.Y > 0)
{
   Velocity = new Vector3(1, -1, 0) * speed;
}
else if (position.X >= 200 && position.Y <= 0 && position.Y > -200)
{
   Velocity = new Vector3(-1, -1, 0) * speed;
}
else if (position.X <= 0 && position.Y <= -200)
{
   Velocity = new Vector3(-1, 1, 0) * speed;
}
else
{
   Velocity = new Vector3(1, 1, 0) * speed;
}

It moves to the second point, but then gets stuck and appears to vibrate in place. How should I be doing this?


texts: Pause a Coroutine while it's waiting for seconds

texts:
I have a Coroutine (X) that waits for seconds before it does something. However, during that time there is another Coroutine that may trigger (Y), and during the time it's on X has to pause waiting for seconds, until Y finishes its job. The point is not to waste the wait time of X.

Pausing the game is not possible since everything else has to work during that time.

I tried to add the bool isLightningAbilityRunning that checks if Y is running, but since X is not repeating itself and just waiting, it doesn't get to that point.

The whole X coroutine:

 private IEnumerator TriggerGravityAbility() {
    var gravityDuration = gravityInitialDuration + UpgradeManager.instance.GravityDurationUpgrade();
    AudioManager.instance.PlayGravitySound();
    CubeSpawner.instance.gameObject.SetActive(false); // Stop spawning cubes
    Physics2D.gravity = new Vector2(0f, 1f);
    ParticleModifier.instance.SetGravity(0f);
    CubeBehavior.instance.border.isTrigger = false;
    CubeBehavior.instance.ignoreBorderLightning = true;

    while (isLightningAbilityRunning) {
            yield return null;
    }

    yield return new WaitForSeconds(gravityDuration);

    CubeBehavior.instance.DestroyOutOfCameraCubes();

    CubeSpawner.instance.gameObject.SetActive(true); // Start spawning cubes
    Physics2D.gravity = new Vector2(0f, -9.81f);
    ParticleModifier.instance.ResetGravity();
    CubeBehavior.instance.border.isTrigger = true;
    CubeBehavior.instance.ignoreBorderLightning = false;
}

How can I make this work?


texts: How do I sync the GameObjects to server in C# unity?

texts:
I have been working on Game that consists of 10 Game Objects that have to be sync by the server values. The server decides that which game object will win and then sends command to my side(Client side) but I am not able to match the server values to mine then what can I do to sort out this problem?
The track is kind of horse racing track i.e. straight and then circular.
Any help would be appreciated :)
Thanks in advance


texts: Using StartCoroutine() and WaitForSeconds()

texts:
I am trying to perform two operations. First I want to increase the size of a GameObject and then delay for 0.1s before returning it back to its original size. However, when I try using StartCoroutine(), it keeps giving me the error :

An object reference is required to access not-static members

even though I made my Delay() function static. Can somebody please tell me what I'm doing wrong?

public static void MoveSelected(int choice)
{
    GameObject rock1 = GameObject.Find("Rock1");
    GameObject paper1 = GameObject.Find("Paper1");
    GameObject scissors1 = GameObject.Find("Scissors1");

    Vector3 scl;

    if (choice == 1)
    {
        scl = rock1.transform.localScale;
        scl.x *= 1.1f;
        scl.y *= 1.1f;
        rock1.transform.localScale = scl;

        StartCoroutine(Delay());

        scl.x /= 1.1f;
        scl.y /= 1.1f;
        rock1.transform.localScale = scl;
    }
    else if (choice == 2)
    {
        scl = paper1.transform.localScale;
        scl.x *= 1.1f;
        scl.y *= 1.1f;
        paper1.transform.localScale = scl;

        StartCoroutine(Delay());

        scl.x /= 1.1f;
        scl.y /= 1.1f;
        rock1.transform.localScale = scl;
    }
    else if (choice == 3)
    {
        scl = scissors1.transform.localScale;
        scl.x *= 1.1f;
        scl.y *= 1.1f;
        scissors1.transform.localScale = scl;

        StartCoroutine(Delay());

        scl.x /= 1.1f;
        scl.y /= 1.1f;
        rock1.transform.localScale = scl;
    }

}

static IEnumerator Delay()
{
    yield return new WaitForSeconds(0.1f);
}


texts: Make a place or city feel crowded in procedural generated worlds

texts:
I have thought about this while thinking about a game concept, but it should be applicable to many game types.

Imagine an RPG or something else with an open-world. Normally you would want to populate your world to make it feel alive and allow for interaction with NPCs in any form (talk, steal from, kill.. whatever).

Now, what if you don't have the option to fill it with NPCs or similar. My example would be a procedural generated RPG world where you want to enter a house filled with people or even a city. It would be strange for none of the NPCs to talk to you.

Another example might be a space station your ship is docking to. There might be only one or two NPCs you are able to talk to, but the space station could be steaming with other people, but you might not acces them somehow.

Sure, one possibility would be to have procedural generate NPCs with random messages as well, but depending on the size of the city and/or the amount of NPCs you would need a lot of NPCs with different messages. And then it would be easily possible to have to NPCs with identical messages.
The other problem would be that you would end up with to many NPCs, that make the place feel overfilled instead of just crowded. I image that a hard number or relation for space to NPCs is impossible to pinpoint, but you surely get my point.

So, my question is, what other possibilities are there to make a city / place feel crowded? Maybe with NPCs, or maybe even without?


texts: Unity NGUI Arial Label looks different in iOS after updating Unity to 5.1.1

texts:
I am using NGUI and I have a UILabel. It uses Unity dynamic font Arial. Bold. No effects.

This is how it looks in the Unity editor:

And that's how I want it to look. When I build it in iOS, it looks the same. Great.

Then I updated Unity to 5.1.2. In editor it still looks the same, but now in an iOS build I get this:

The label looks different. It looks like a different font and style.

This line of code:

Debug.Log("Using " + label.trueTypeFont + "  " + label.fontStyle + " size " + label.fontSize);

And regardless of being in Unity's editor or the iOS device, I get this:

  Using Arial (UnityEngine.Font)  Bold size 24

So apparently this is indeed Arial. And the size is supposedly the same. Then, what is wrong?

This occurs on all iOS devices I use (iPhone 6+, iPhone 6, iPad Mini 3, etc...) with the latest iOS version. I also have the latest NGUI. I think it was the Unity update itself.

What happened? What do I do? I want the old look. I suppose that I can grab an older Unity and use one of my backup projects, but this new Unity actually has several fixes I'd like to have so...

Edit: Confirmed that Unity 5.0.1 doesn't have this problem. It occurs in newer versions like 5.1.1.


texts: Is it a bad idea to have Game1 static in XNA?

texts:
Is it a really bad idea to have my Game1 class as static? As at the moment in my Game1 class I have a class called TileHandler which handles everything to do with my current set of tiles, and AnimalHandler which handles all my animals (surprisingly).

Now if I am in AnimalHandler and want to check if a tile is walkable from TileHandler then that causes problems or I have to pass a list of walkable tiles into AnimalHandler, which I'd rather not do.

What would be easier would be to make Game1 static and then in AnimalHandler just go Game1._tileHandler.WalkableTile(position).

Now I can't see anything immediately wrong with this or anything that'd cause any problems but I've only just started using static classes, so does anyone more knowledgeable see any giant reason why that's a bad idea?


texts: Can't Get Component On Photon Instantiated Scene Object

texts:
I'm completely new to photon. I have a fair bit of experience with Unity but learning multiplayer feels like learning a new game engine lol.
I'm using photon and making a chess game, so I've put photon Views and practically everything, except the objects I want to be unique. I feel like I've gotten most of it figured out, but for some reason, when I start a multiplayer game, it doesn't initialize my chess pieces properly. So, I have it placing all the pieces at start, here is my pastebin for reference, the InitiateBoard() method is what's having issues, starting at line 85, the error is at line 100.
https://pastebin.com/bVUJ25Yu
The "pieces" array is a 2D array of the ChessPiece class, which assigns the sprites, team, and movesets based on position on the board. It's very strange, it works just fine on a single player game, but if I build the game and play two player(which is the exact same script, it just disables the AI), for some reason, only the build gets a null reference exception error at this line,
pieces[x, y] = spawnedPiece.GetComponent();
It seems to be unable to get a reference to the chesspiece, and therefore, it sets all the pieces to white rooks as white rook is in the default position. Weirdly, the pieces initialize properly on the editor's screen. And also, if I play the build version in single player, it seems to initialize everything just fine.
After some testing, I realized it's only the joined player that is having issues, I tried running the build version first, then joining through the editor, it does the exact same bug with the same error code on the editor rather than the build version. So I can look at the editor and see a bunch of white rooks, but when I look at the build, it will be a bunch of properly assigned pieces... And yes, I am certain they are in the same game, as it calls an RPC to start the game and if I move one piece, I can see said piece is moved on both games.
Does anyone know what could be causing this? It's spawning the pieces just fine, but it doesn't seem to be able to get the component on the spawned piece...


texts: What is a good format for a 3d topview map?

texts:
I am building a 3d topview game like GTA2. In this game the ground is mostly one level (except for tunnels and highways). Most of the ground is also city so the ground is usually covered by either roads or buildings. The buildings are simple 3d models which the player can walk around on. Most of the gameplay is 2d.

How should I model the map? I have considered the following options:

Bitmaps, I think this gives problems when I want to add data smaller than a tile. Also the problem of bridges and tunnels seems hard to solve with this.
Polygons, define all roads, terrain types, buildings with polygons and save that along with physics and texture information.

What approach would you take or have you ever implemented this or know of an implementation?


texts: What level editor is Phil Fish using in Indie Game: The Movie?

texts: Does anyone know what program Phil Fish is using to edit models of levels? Or is it it something he built himself? I'm new to game development and was looking for something to design levels with besides my notebook.


texts: How to fix this existing shadow shader/material with alpha textures?

texts:
I hope I could get some help here in finally resolving this problem of mine re: shadow casting with alpha textures.

Here's a screenshot on what I am hoping for as a result:

A friend of mine just sent this shader program to help out but I still can't get it to work properly. The alpha textures such as leaves still leave a rectangular shadow. I'm using a custom built Ogre based engine but overall the material and compositor system is still the same.

Attachment:
Alpha_Shader.zip

Any help would be greatly appreciated.

Thanks.


texts: Render on texture with alpha 0 for the background colour

texts:
Sorry if the question is stupid but I am very new to opengl.

I render on a target a scene with a couple of object on a background that is nothing more than the clear colour (which is 0.0,0.0,0.0,0.0).
 When I access the texture again every single pixel has 1 has alpha, how can I make sure the background has 0.0 ?

Thank you

Faye


texts: How to use Cocos2dJS to connect to a Socket.IO server?

texts:
How can I connect to a nodejs socket.io server from a cocos2djs game? I've google all the way to no avail. I tried this but it does not work:

socket = io.connect('http://192.168.254.102:7714');
if ( socket === undefined ) {
    cc.log("Could not connect to socket.io");
} else {
    socket.on('connect', function() {
        socket.emit('join', {username: 'Android Application'})
    });
}

I read in the docs that there's a module called SocketIO for doing that, but there's not enough info on how to use it. Thanks in advance.


texts: Best way to organize models with multiple meshes and textures?

texts:
I have character models which have different parts, ex: upper body, head, lower body; each part is a separate mesh in the same model. Each part has several textures associated with it (diffuse, normal, etc).

I'm wondering if there is a best practice for associating the textures with the meshes, given a .obj file as the model, for example, and .tga files for the textures.

So for instance, making sure the head textures get mapped on to the head object.

One way would be having a separate file for each mesh, and using the file names to associate them with their textures, but that seems impractical.

Is there a nice, clean way to do this, which is both easy to program (importing and rendering) and easy for the artist?


texts: How can I create a buffer suitable for dynamic updates in SharpDX?

texts:
I want to set a buffer that is updated every frame but can't figure it out, what i have to do.

The only working thing i have is this:

mdexcription = new BufferDescription(Matrix.SizeInBytes * Matrices.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0);
instanceBuffer = SharpDX.Direct3D11.Buffer.Create(Device, Matrices, mdexcription);

vBB = new VertexBufferBinding(instanceBuffer, Matrix.SizeInBytes, 0);
DeviceContext.InputAssembler.SetVertexBuffers(1, vBB);

Draw:

//Change Matrices (Matrix[]) every frame...
instanceBuffer.Dispose();
instanceBuffer = SharpDX.Direct3D11.Buffer.Create(Device, Matrices, mdexcription);

vBB = new VertexBufferBinding(instanceBuffer, Matrix.SizeInBytes, 0);
DeviceContext.InputAssembler.SetVertexBuffers(1, vBB);

I guess Dispose() and creating a new buffer is slow and can be done much faster.

I've read about DataStream but i do not know, how to set this up properly.

What steps do i have to do to set up a DataStream to achieve fast every-frame update?

Edit:

Finally got it. I used that:

mdescription = new BufferDescription(Matrix.SizeInBytes * Matrices.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0);
instanceBuffer = SharpDX.Direct3D11.Buffer.Create(Device, Matrices, mdescription);

vBB = new VertexBufferBinding(instanceBuffer, Matrix.SizeInBytes, 0);
DeviceContext.InputAssembler.SetVertexBuffers(instSlot, vBB);

Draw:

DataStream stream;
var dataBox = DeviceContext.MapSubresource(instanceBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out stream);
stream.WriteRange(Matrices);
DeviceContext.UnmapSubresource(instanceBuffer, 0); //to update the data on GPU

stream.Dispose();


texts: Throwing away inner faces of cubes of a transparent voxel structure in Unity3D?

texts:
I want to create a "Building site is (not) obstructed." indicator for my building system.

How can I throw away those faces which would be hidden if the material would be opaque?


texts: How can I cancel a contact in a b2ContactListener?

texts:
To know when contacts happen we can derive from b2ContactListener and implement our own solution which is great. I'm wondering is there anyway we can cancel a contact, that is to say when we hit begin contact we call a function or do something to destroy the contact before it has a chance to be resolved?

My game logic relies on setting any number of collision groups (which are basically integers). Collision groups can have settings to interact with one another, for example collision group 41 and 13 may be set to never collide while group 41 and 56 will collide. Some groups which are set not to collide are still meant to generate an OnContact callback (but will obviously never get to end contact).


texts:
I try enable debug system in OpenGL with helps debug output in OpenGL version >= 4.3. My code:

void GLAPIENTRY glDebugOutput(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
{

}

int main()
{
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(800, 600, "TestGL", nullptr, nullptr);
    glfwMakeContextCurrent(window);
    glfwSetKeyCallback(window, key_callback);
    glewExperimental = GL_TRUE;
    glewInit();
    int width, height;
    glfwGetFramebufferSize(window, &width, &height);
    glViewport(0, 0, width, height);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    std::cout << glGetString(GL_VERSION) << std::endl;
#if defined(DEBUG) | defined(_DEBUG)
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
    GLint flags;
    glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
    if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
    {
        glEnable(GL_DEBUG_OUTPUT);
        glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
        glDebugMessageCallback(glDebugOutput, nullptr);
        glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
    }
    else
        std::cout << "Debug for OpenGL not supported by your system!" << std::endl;
#endif

   ...... // etc
}

My output from console:

4.5.0 - Build 24.20.100.6286
Debug for OpenGL not supported by your system!

I don’t understand why the debugging tools do not work, because the OpenGL version matches the necessary one. Thanks.


texts: Help developing a scoring system for a tech tree based game

texts:
I'm working on a tech tree based project in which the player would select "advancements" to effect several measurement stats, or "basic stats".  I have a working excel model that will calculate the "scores" for these basic stats based on advancements selected, but I'd eventually like to use these measurement stats that I have to calculate higher level measurements like population or total production power.

For example in the case of calculating "Population", I'd like to take the (current pop + (current pop. * fertility rate)) - death rate.  Fertility rate would be calculated based on the "basic stats" of "health" and "food supply", and death rate on metrics like "health" and "squalor".

I'm not really sure how to use these measurements though...  If health and food supply both start at 0 and increased by 5 over the course of a few turns, how should I use these scores in a meaningful way to do what I'm trying to do in the case of fertility rate?  Fertility rate should be expressed as a certain percentage of total pop. but I'm not sure how to get there from two scores of 5.  I don't think this will be a simple process, but I feel like I'm missing some basic concepts to put this into place.  Is there a name for this kind of scoring system?

Any ideas would be appreciated!  Thanks.


texts:
I'm able to rotate any model with any angle I want, where I can not rotate my model around a given point.

e.g: My model rotates from the origin assigned in its .fpx file. I want it to rotate related to a point of its bottom plane, so that it is animated as falling


texts: Mapping a 3D texture to a standard hollow-hull 3D model

texts:
I have 3D models which are typical hollow hulls. If such a model also had a 3D volumetric/voxel texture map then given a point P inside such a model, I'd like to be able to find its uvw coordinates within the 3D texture.

Is this possible by simply setting 3D texcoords on my existing mesh or does it have to be broken up into polyhedra? Is there a way to map a 3D texture onto a mesh without doing this?


texts:
I'm trying to implement a Camera class in order to walk and look on the world as follow:

#ifndef _CAMERA_H_
#define _CAMERA_H_

#include <glm\glm.hpp>

class Camera
{
public:
    Camera();
    ~Camera();

    void Update(const glm::vec2& newXY);
    //if by = 0.0 it means, it will use the const Class speed to scale it
    void MoveForward(const float by = 0.0f);
    void MoveBackword(const float by = 0.0f);
    void MoveLef(const float by = 0.0f);
    void MoveRight(const float by = 0.0f);
    void MoveUp(const float by = 0.0f);
    void MoveDown(const float by = 0.0f);
    void Speed(const float speed = 0.0f);

    glm::vec3& GetCurrentPosition();
    glm::vec3& GetCurrentDirection();
    glm::mat4 GetWorldToView() const;
private:
    glm::vec3 position, viewDirection, strafeDir;
    glm::vec2 oldYX;

    float speed;
    const glm::vec3 up;
};

#endif

#include "Camera.h"
#include <glm\gtx\transform.hpp>

Camera::Camera()
    :up(0.0f, 1.0f, 0.0), viewDirection(0.0f, 0.0f, -1.0f),
    speed(0.1f)
{
}

Camera::~Camera()
{
}

void Camera::Update(const glm::vec2& newXY)
{
    glm::vec2 delta = newXY - oldYX;
    auto length = glm::length(delta);
    if (glm::length(delta) < 50.f)
    {
        strafeDir = glm::cross(viewDirection, up);
        glm::mat4 rotation = glm::rotate(-delta.x * speed, up) *
            glm::rotate(-delta.y * speed, strafeDir);

        viewDirection = glm::mat3(rotation) * viewDirection;
    }

    oldYX = newXY;
}

void Camera::Speed(const float speed)
{
    this->speed = speed;
}

void Camera::MoveForward(const float by)
{
    float s = by == 0.0f ? speed : by;

    position += s * viewDirection;
}
void Camera::MoveBackword(const float by)
{
    float s = by == 0.0f ? speed : by;

    position += -s * viewDirection;
}
void Camera::MoveLef(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * strafeDir;
}
void Camera::MoveRight(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * strafeDir;
}
void Camera::MoveUp(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += s * up;
}
void Camera::MoveDown(const float by )
{
    float s = by == 0.0f ? speed : by;
    position += -s * up;
}

glm::vec3& Camera::GetCurrentPosition()
{
    return position;
}
glm::vec3& Camera::GetCurrentDirection()
{
    return viewDirection;
}

glm::mat4 Camera::GetWorldToView() const
{
    return glm::lookAt(position, position + viewDirection, up);
}

and I update and render as follow :

void Game::OnUpdate()
{
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glUniformMatrix4fv(program->GetUniformLocation("modelToViewWorld"), 1, GL_FALSE, &cam.GetWorldToView()[0][0]);

}

void Game::OnRender()
{

    model->Draw();

}

Which the Vertix shader is:

#version 410

layout (location = 0) in vec3 inVertex;
layout (location = 1) in vec2 inTexture;
layout (location = 2) in vec3 inNormal;

uniform mat4 modelToViewWorld;

void main()
{
        gl_Position    = vec4(mat3(modelToViewWorld) * inVertex, 1);

}

But in result the model itslef is moving/rotating instead of moving the camera around the model. What am I doing wrong here?


texts: How can I get the entity a player is looking at in a Bukkit plugin?

texts:
I'm creating a wizardry plugin for Minecraft, and I was wondering how you would get the entity that a player was looking at, I know that you would have to use a Vector, but I really am not familiar with them. Pretty much what I'm looking for is something like this:

public void entityLookingAt(Player p){
    if(p.EntityLookingAt() instanceof Player){
        p.sendMessage("You're looking at a player!");
    }
}


texts: Other procedural material generators for Unity?

texts:
In the new version of Unity 3.4, unity announced that they would now support procedural materials (which is awesome, by the way). While I was researching it, I found this in the manual:

  Allegorithmic's Substance Designer can be used to create Procedural Materials, but there are other applications (3D modeling apps, for example) that incorporate the Substance technology and work just as well with Unity.

I don't have Allegorithmic's substance designer and don't plan on buying it soon. What other applications or 3D modeling apps can make procedural materials that work in Unity?

Edit: I found that Allegorithmic has a program called Player. But it is on Windows only. I'm on mac.


texts: How can I create a button with an image in libGDX?

texts:
I am new to LibGDX. I am trying to develop a game for Android (so it will support different screen sizes), but I don't know how to put a button with an image. I tried ImageButton but I can't resize it. I have put TextButtons in my app and it works and resizes fine too.

Any suggestions ?


texts: Work flow for modelling a city(open world)

texts:
This seems like a massive task, do each individual building/object have to be modeled individually. If so are the model imported into the world editor and places accordingly.

Or are other techniques used like laser scanners, GPS google maps data, or whatever, it just seems to big a task to model a whole city, model after model.

Can somebody give me an idea or how it is done and a typical team size/day for a modeler?


texts: Importing fbx models made in Cinema4D in unity at runtime

texts:
In my app I have requirement that I will be given a url and using this url I have to download a fbx model and then show it in the scene.

I am able to download the model from the url using the below code.

IEnumerator loadModel(string modelName)
{
    if (!isDownloaded)
    {

        string targetUrl = "http://XXX.XXX.X.XX:3000/" + modelName;
        Debug.Log("targetUrl" + targetUrl);
        WWW www = new WWW(targetUrl);

        yield return www;
        if (www.isDone)
        {
            Debug.Log("downloaded " + www.bytesDownloaded);
            var path = System.IO.Path.Combine(Application.dataPath+"/Resources", modelName);

            System.IO.File.WriteAllBytes(path, www.bytes);
            isDownloaded = true;

            LoadAndAttachModel(imageTargetTransform, modelName);
        }
        else
        {
            Debug.Log(www.bytesDownloaded);
        }
    }
}

And with the below code I tried using loading the model in the scene

public void LoadAndAttachModel(Transform parent, String modelName)
{
    Debug.Log(modelName);
    var path = System.IO.Path.Combine(Application.dataPath + "/Resources", modelName);
    String name = modelName.Substring(0, modelName.IndexOf("."));
    GameObject load = Resources.Load(modelName) as GameObject;
    Debug.Log(load.name);
    if (load != null)
        {
           // load.transform.parent = parent;
            load.transform.localPosition = Vector3.zero;
            load.transform.localRotation = Quaternion.Euler(new Vector3(90, 90, 0));
            load.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
        }

    else
    {
        Debug.LogWarning("Can't find boneName : " + parent);
    }
}

but this code always gives exception that the gameobject load is null. I tried with the obj model and that was working fine but with fbx models this is giving exception every time.

So how can I instantiate the downloaded gameobject in my scene ?


texts: So I have a 7x7 grid made using a for loop and instantiating the sprites. Now via code, let us say l placed my rectangular sprite,which takes 3 cells on the grid, somewhere on that grid. How can I get the position of the cells on which this rectangular sprite is on?


texts: Moving the rendered object/the projection perspectives based on an AR marker

texts:
I saw this video and now I am trying to making it.

I have used Vuforia AR Camera Pulgin, and so far tracked the image on a marker but the problem is getting the four projections of the 3D object on a screen. Here is an example of what it looks like.

I have used Viewport Rect method with four cameras but that does not seem to change the projections as I move the marker.


texts:
In Unity, I have an Animator on a character.
Upon saving/loading the game, I want to preserve the pose and animation state the character is in.
However, I can see no way to read/write all the data from the Animator/Animation Controller in such a way that I can store it in and retrieve it from a binary file.
Is there a non-obvious way to achieve this?


texts: Using server timestamp to synchronize actions across clients

texts:
tl;dr
The question is rather simple: how unsynchronized can internal clocks be between different machines?

Context
We have a "hybrid" approach where the Clients are authoritative on certain things, and the Server on some others. That is to make our life easier because the gameplay doesn't need to be too tight about certain things.
In this case, the Server will pre-determine a sequence of Enemy Types to be spawned at different locations with pre-determined delay between the spawns. We would then let the Clients handle the rest during the gameplay.
However, if we want the Clients to be mostly synched on the display of the enemies, they would need to initiate this sequence at the very same time, and thus we cannot rely on the network to have transmitted the data at the very same time for all Clients.
The idea we had was to send a timestamp of the format returned by System.currentTimeMillis() which would indicate when to begin the sequence.
But then one question remains in the way: how unsynchronized can internal clocks be between different machines?


texts: How do I make my character jump on a platform?

texts:
This is the code I've written so far:

Html:

Land

    <button id="howtobutton">Instructions</button>
    <button id="hsbutton">High Score</button>
    <button id="optionsbutton">Options</button>
    <button id="playbutton">Play Game</button>

How to Play

      <button class="backtomenu">Back to Menu</button>

High Scores

    (Username), your high score is:
    <button class="backtomenu">Back to Menu</button>

Options

    <button class="backtomenu">Back to Menu</button>

 Score:

      <button id="btn-quit" class="backtomenu">Back</button>

CSS:

div {
  border: 1px solid black;
} h2 {
  text-align: center;
} button {
  display: block;
  width: 100px;
  margin: 10px auto;
} #stage {
  width: 400px;
  height: 400px;
  overflow: hidden;
  position: relative;
  background-image: url(http://www.hlgjyl888.com/data/wallpapers/151/WDF_1917288.gif);
  background-size: cover;
} #splash {
  display: block;
} .screen {
  position: relative;
  display: none;
  width: 100%;
  height: 100%;
  color: white;
} #player {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  position: absolute;
  background-color: blue;
  bottom: 50px;
  top: 269px;
  left: 100px;
}
} #score {
  position: relative;
  top: 0px;
  right: 5px;
  width: 100px;
} #btn-quit {
  position: absolute;
  margin: 0;
  bottom: 0px;
  left: 0px;
} .platform {
  position: absolute;
  background-color: white;
} .onPlatform {
  background-color: blue;
}
#ground {
  top: 300px;
  width: 400px;
  height: 3px;
}

JavaScript:

var gravity = 1;
var maxheight;
var timer;
var jump = 32;
var velocity = 0;
var jumppressed = false;
// var username = prompt("What is your name?")

$(document).ready(function() {

  $('#howtobutton').click(function() {
    showScreen('#instructions');
  });
  $('#hsbutton').click(function() {
    showScreen('#highscores')
  });
  $('#playbutton').click(function() {
    showScreen('#game')
  });
  $('#optionsbutton').click(function() {
    showScreen('#options')
  });
  $('.backtomenu').click(function() {
    showScreen('#splash')
  });

maxheight = Math.round($("#stage").height() - $("#player").height());

timer = setInterval(update, 1000/60);

   $(document).keypress(function(e) {
    console.log(e.which);
    if (e.which === 32) {
      console.log("it works");
      jump();
    }});
});

function showScreen(screen) {
$('.screen').hide();
$(screen).show();
};

function jump() {
  if ($("#player").position().top >= maxheight) {
    console.log("Jump is working")
    velocity = -15;
  }
};

function update() {
  if (velocity === 0 && $("#player").position().top === maxheight) {
  } else if (velocity > 0 && $("#player").position().top >= maxheight) {
    console.log(maxheight + " through ground" + $("#player").position().top);
    $("#player").css("top", maxheight + "px");
    velocity = 0;
  } else {
    velocity += gravity;
    var newPos = $("#player").position().top + velocity + "px";
    $("#player").css("top", newPos);
  }
};

However I'm very new to game development, I've been stumped for a while now, I can't figure out a way to control my character movement. Can anyone tell me what's wrong with my code? My character should be jumping on the platform whenever the space key is pressed (that's it).


texts: How to implement framerate-independent acceleration depending on current velocity

texts:
For my client/server application, I've implemented framerate-independent acceleration like this.
Now I've advanced my formula to be using the current velocity of the moving object to calculate the acceleration factor. This causes a problem: if the client and server have different tick rates (e.g. 120 and 30 fps respectively) the movement calculated on the client is not equal to the movement calculated on the server anymore.
I've tried to update the acceleration factor on the faster ticking peer with the framerate of the slower ticking peer (i.e. the server). I can see slight improvements here, but it's far from good. I've also tried on the slower ticking machine to calculate the root mean square of the velocity of the last frame and the current velocity and calculate the acceleration factor with it. Again, does not really fix the problem.
Could anyone provide me with a clever solution or workaround if there is one?


texts:
I am looking for any input on simulating water in 2D, against a rather large (call it) blocked/not blocked array (viewed from the side). I have come up with the following ideas:

Cell Automata

Do a massively parralel simulation on the CPU, using cell automata. With rules as simple as:

If there is a cell open to the bottom move to it.
Check the left and right cells, choose a random one out of the two and move to it.

Pros

Simple to implement.
Meaningful/deterministic in a multiplayer system.

Cons

Probably really slow.
Not convincing.

Fluid Dynamics on the GPU

Perform a rough approximation of fluid dynamics on the GPU against a texture like the following:

+------+-----+-----+-------+
|R     |G    |B    |A      |
+------+-----+-----+-------+
|vX    |vY   |NULL |Density|
+------+-----+-----+-------+

Pros

Probably really fast.
Could be quite convincing.
A further pixel shader could render it directly.

Cons

Difficult to implement.
Difficult to tweak.
I can't allocate a single texture the size of my level.

I could overlap the grid areas, but this would add further complexity.

Particles

Use particles to simulate the water. During rendering using additive blending and then apply a multiplication function to the alpha channel to give the water crisp edges.

Pros

Will probably look nice.
Easy to implement.
Easy to render.
Meaningful in a multiplayer system, although would require quite a bit of bandwidth to transfer.

Cons

Inter-particle effects will probably be slow (neighborhood lookup).
Could lead to water 'leaking' through solid spaces (because the solid space is small, e.g. 1px).
Could lead to strange holes in the water depending on the particle size.
Both of the above could be mitigated by allowing particles to drift closer together than their real size, however would cause problems with the inter-particle and particle/landscape performance.

Any further ideas?

Note: This is an approximation, I am not looking for physically correct water here - just something that 'is good enough' (bonus points for quick and dirty). The game is multiplayer, so unfortunately the whole level needs to be simulated continuously.


texts:
I was following a tutorial that was recommended to me to learn the basics of game design through XNA. And I got to this tutorial:
http://www.xnadevelopment.com/tutorials/thewizardshooting/thewizardshooting.shtml

This is the tutorial that shows management of dynamic object generation and handling.

In the tutorial, he links the "Fireball" class to the "Wizard" class. The wizard class maintains a List<Fireball> and they're updated, drawn, loaded, etc. within the Wizard class itself.

My question is this: Is this good design? Should the Producer of the Objects be the one to manage them, or would it be better to implement, say, a ProjectileHandler class, that could manage the fireballs shot both by the Wizard and the Evil Dragon?


texts:
I'm creating a 2D top-down tiled game in pure Java and by now I'm trying to implement a way to do lighting.

First, some details on how I render: there is a screen class which handles all the rendering. Pixels are put inside a int[width * height] array which is drawn on the actual screen using a BufferedImage and Graphics.drawImage().

The way I am doing lighting right now is by creating a second int[width * height] array which holds all the brightness that should be subtracted from the actual pixels. I try to use only floats ranging from 0f to 1f to represent RGB intensities.

So, as an example, there is the ambient lighting which is 0.3f. What I do is a pixel to pixel operation, where for each pixel that will be drawn, its RGB values are decomposed, decreased 70% (1f - 0.3f), recomposed back into a single int and stored inside the secondary int[width * height] array. When transferring the pixels to the BufferedImage, I subtract the corresponding value inside the secondary array and get a darker image, as expected.

That was an example of darkening the image and it works fine, the problem appears when actually lighting them up: I gave the player a lightRadius and 3 light color component floats (RGB). While rendering the player, I also render it's lighting inside the secondary array by doing the following:

int mask = subtractMask[xx + yy * width];

int mr = (mask >> 16) & 255;
int mg = (mask >> 8) & 255;
int mb = mask & 255;

mr -= (int) (dist * light.r * mr);
mg -= (int) (dist * light.g * mg);
mb -= (int) (dist * light.b * mb);

subtractMask[xx + yy * width] = mr << 16 | mg << 8 | mb;

Where dist is a number ranging from 0f to 1f which makes the light fade with the distance from the source and light.r/g/b are each of the components of the light that comes from the player.
What this piece of code does is basically to "give a little bit of the light that was taken out of a pixel back to it". As you can see, mr, mg and mb are made smaller (-=) and then composed back inside the number that will be subtracted from the corresponding pixel, thus making the result of the subtraction bigger (lighter).
For white light I get the desired result:
https://dl.dropbox.com/u/68532511/light1.png

The problem is when I only use the blue component (r = 0f, g = 0f, b = 1f), getting this: https://dl.dropbox.com/u/68532511/light2.png

Of course this can be explained by the fact that the tiles have very little blue values, making the ambient light take a little part of it away and making the lighting give this little part of it back (as you can see the biggest effect is on the player's pants, which are blue).
What I still couldn't think of is a way to make lighting independent of how much brightness was taken away from the pixels and something that simply looks good in any way I combine the components (the result I expected for the second image was luminance like in the first one, but colored blue). So how can I implement such an effect?

Also, for making the lighting circular, I simply compute something light x^2 + y^2 <= radius^2, where if this sentence is true, the pixel should light up, executing the code I've showed before. Is there a faster way to compute this? (I lost almost 50 FPS on this effect).


texts: How to deal with lot of textures in one draw call?

texts:
I'am currently developing text rendering & some kind of tile based texturing for simple landscape with textures blending. e.g. something like this but in 3D.

In first realization I have been used 2D texture arrays to achieve problem of texture switching to be able to draw whole landscape mesh at one opengl draw call and it works great, but this should run on opengl es 2.0 devices and they are don't have 2 texture array support. So my question is - what can I do to deal with that kind of problem?

Of course i can just draw every landscape quad separately, but I'm pretty much sure, that this solution will really, really heart the performance. (mb i wrong?)

Also i know about texture atlases, but can I guarantee that I can put all possible textures into fragment shader for every possible tiles  combination?(terrain tiles for landscape & every possible text chars with different sizes, I think you get the point) I almost sure that i can't, that's basically why I'm asking this question here.

Sorry for my horrible english, I'm working on that.


texts: Tweaking AStar to find closest location to unreachable destination

texts:
I've implemented AStar in Java and it works ok for an area with obstacles where the chosen destination is reachable.

However, when the destination is unreachable, the calculated "path" is in no way to the closest location (to the unreachable location) but is instead some random path.

Is there a feasible way to tweak AStar into finding the path to the closest location to an unreachable destination?