texts:
I am building for Quest and signing the package with V2. I am also creating store-based Android Manifest file. Unfortunately the upload stops at 2nd step where I receive the error -
"The APK was signed with the V1 signature system, previously marked with V2 and signed again with V1. Such APKs are considered corrupted and cannot be installed."
Here is my Android Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.VR.VRCube"
android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<application>
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
<activity android:screenOrientation="landscape"
     android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
     android:configChanges="density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
     android:launchMode="singleTask"
     android:resizeableActivity="false">
</activity>
</application>
<uses-sdk android:minSdkVersion="21"/>
<uses-feature android:glEsVersion="0x00030001" />
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
</manifest>


texts: Graphic Design Resource for Indie Game Dev?

texts:
I'm creating my first game and want to improve upon the graphic design aspects of my game.

By graphic design I mean layout, font, spacing, etc..

Is there a good resource for learning graphic design for a programmer?

I've taken human-computer interaction classes, but that has more to do with task and making task as easy as possible for the user. Not necessarily about layout/spacing.

I mention layout/spacing twice because that's the biggest problem I'm having. I can clearly tell that things need to be spaced properly to be more visually pleasing.

Thanks to all that reply


texts:
I am working on a game with a lot of bullets, currently every second it loops through a vector of bullet objects and checks if its marked for erasure or not.

if (timer2>=120){

    auto it = Bulletlist.begin();
    while (it != Bulletlist.end())
    {
    if ((it->del)) {
             it = Bulletlist.erase(it);
         }
         else {
             ++it;
         }
    }
    timer2=0;
    }else{
    timer2++;
    }

This works fine for around 0-200 bullets, however when I try to scale it larger the delay becomes very noticeable. I am still very new to C++, And was curious if there is a better way of doing this. The bullet class automatically marks itself for deletion when it goes out of bounds.

    int update(){
    if (acceleration!=0){
    if (speed < acceleration){
    speed+=increment;
    }
    }
    x=(speed*cos(angle)) + x;
    y=(speed*sin(angle)) + y;

    if (x<0) del=true;
        if (x>1000) del=true;
        if (y<0) del=true;
        if (y>750) del=true;
    circ.setPosition(x,y);
    window.draw(circ);
};

Edit: Bullets are generated right now on a loop within a enemy class

void shoot(int which){
    Bullet B1;
    B1.setsprite();
    currentangle+=(6.2832/bnum)+0.05;
        B1.setvars(x,y,currentangle*which,1.f,2.f,0.01f);
    Bulletlist.push_back(B1);
    }
    void update(){
     movtimer+=0.01f;
     //x += sin(movtimer);
     //std::cout<<x;
     //printf("\n");
     sprite.setPosition(x,y);
      if (timer>=10){
      for (int i=0; i<bnum; ++i) {
      shoot(1);
      }
      timer=0;
      }else{
      timer++;
      }
      window.draw(sprite);
      for (std::vector<Bullet>::iterator it = Bulletlist.begin() ; it !=    Bulletlist.end(); ++it){
       it->update();
      }
```


texts: How can I generate natural-looking tree leaves in a Minecraft-like world?

texts:
I'm moving from working on 3D block-world terrain to more specific features like tree leaves and ore veins (the ore veins will likely be done with my existing Perlin noise for the terrain). One thing I'm having with is properly generate clusters of blocks (for example, leaves for trees).

I've tried looping through a radius and randomly skipping blocks so it seems more natural but this still doesn't look natural enough and also makes it based on a cube shape to start. I want some trees to have more of an overall sphere-shape to the leaves, or some to have a cone shape. I haven't really found helpful info on how to loop through coordinates of shapes other than a cube.

What technique(s) should I employ to generate natural looking clumps of tree leaf blocks?


texts: How to blend the sprite into background?

texts:
I try to blend the character into game but I still cannot remove the blue color in the sprite sheet and discover that the white area of sprite is semi-transparent.

Before that, the color D3DCOLOR_XRGB(255, 255, 255) is set in D3DXCreateTextureFromFileEx. You will see the fireball through the sprite.

After I change the color to D3DCOLOR_XRGB(0, 255, 255), the result will be

Now, I am trying to remove the blue color of the sprite sheet and my expected result is something like that

Until now, I still cannot figure out how to do that. Any ideas?

void initPlayer()
{
    //  Create texture.
    hr = D3DXCreateTextureFromFileEx(d3dDevice, "player.png", 169, 44,
         D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
         D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(0, 255, 255),
         NULL, NULL, &player);
}

void renderPlayer()
{
    sprite->Draw(player, &playerRect, NULL, &D3DXVECTOR3(playerDest.X, playerDest.Y, 0),D3DCOLOR_XRGB(255, 255, 255));
}

void initFireball()
{
    hr = D3DXCreateTextureFromFileEx(d3dDevice, "fireball.png", 512, 512,
         D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
         D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 255, 255),
         NULL, NULL, &fireball);
}

void renderFireball()
{
    sprite->Draw(fireball, &fireballRect, NULL, &D3DXVECTOR3(fireballDest.X, fireballDest.Y, 0), D3DCOLOR_XRGB(255,255, 255));
}


texts: Unity - What changes to a game object trigger baked lights to need a rebake?

texts:
I've noticed that sometimes when I make changes to game objects in scenes that have baked lights that the baked shadows will no longer be in effect and dynamic lights will instead be showing.

Destroying and recreating the object seems to trigger this reliably, but what other changes to games objects in a scene can cause a rebake to be needed?


texts: How to draw a 3D triangle using a VBO in OpenGL with LWJGL?

texts:
I am using LWJGL, took me about 4 hours of hard work to achieve triangle rendering and VBOs. I want to render a triangle in 3D space. I know you have to use projection matrices but when I have a vertex array like this

float[] vertices = {
    -0.8, -0.8, -2.0,
    0, 0.8, -2.0,
    0.8, -0.8, -2.0
};

it doesn't render the triangle, but when I change the z values to -1 it renders. I have tried to implement projection matrices, but they manipulate the z axis which hides the triangle.

Also I use row major matrices, do I need column major? Because apparently rotation matrix works fine (row major).

I am using OpenGL 3.3.


texts: What's the purpose to divide constant buffer into groups?

texts:
In hlsl, we always see this

cbuffer cbPerFrame
{
    float2 gRasterSize;
    float4x4 gView;
    int gVoxelDim;
    float3 gVoxelSize;
};

cbuffer cbPerObject
{
    float gObjectID;
    float4x4 gWorld;
};

I know that the group cbPerFrame is to update variables every frame.
The other group cbPerObject is to update variables per object per frame, for example 2 times per frame in this case.
But how can hlsl know that?  cbPerFrame and cbPerObject are just names but not semantics.
When we define different groups, does hlsl really know how many times this group should update every frame?


texts: Opengl - Cascading Shadow Maps Implementation

texts:
after reading about CSM, I have a few questions about the implementation that I can't find the answer to.

According to the wiki, an FBO can only take 1 depth attachment, so in order to render cascaded shadowmaps in one pass, I would have to use TEXTURE_2D_ARRAY or  TEXTURE_3D, correct?
This would force me to use a geometry shader. Would this have a performance hit vs. an alternative method?
The other problem is that I have to define gl_Layer per primative. Could it be possible that a primitive is not fully covered by any single ortho projection? e.g. the camera fov is subdivided, then an ortho projection from the sun is created for each subdivision. If the camera normal is aligned with the sun normal, then the projections' bounds would barely overlap. If a primitive isn't fully covered by either projection, then I can't calculate the depth for that primitive using gl_Layer.


texts:
What are the methods/tools for generating realistic skies with clouds and atmospheric shading?

FOSS alternatives and spherical projections get extra points.


texts: What's the largest "relative" level I can make using float?

texts:
Just like it was demonstrated with games like dungeon siege and KSP, a large enough level will start to have glitches because of how floating point works. You can't add 1e-20 to 1e20 without losing accuracy.

If I choose to limit the size of my level, how do I calculate the minimum speed my object can move at until it begins to be choppy ?


texts: C++ map isn't finding key even though it exists

texts:
I am in the process of learning C++ for the Unreal engine.
I am trying to figure out why when I use the [] operator on a map<Vector2, ControlNode> with a value that I know is in the map, it returns nullptr.
Here are the relevant pieces of code:
Vector2
**Vector2.h**
class MAGICGAME2D_API Vector2
{
public:
    Vector2(float x, float z);
    Vector2();
    float X;
    float Z;

public:
    friend bool operator< (const Vector2& c1, const Vector2& c2);

};

**Vector.cpp**
bool operator< (const Vector2& c1, const Vector2& c2)
{
    return (c1.X < c2.X ||
        c1.Z < c2.Z);
}

Creating the map:
for(auto values : *data->getAutomata()) {
    auto pos = values.first;
    shared_ptr<ControlNode> node = make_shared<ControlNode>(pos,values.second);
    controlNodes.emplace(pos,node);
}

And this is the place I make the call to check if the value is in the map:
shared_ptr<ControlNode> node = (*(*data).getControlNodes())[pos];

The data variable is a pointer, that points to an object that holds a shared_ptrstd::map<Vector2,shared_ptr<ControlNode>>. So that is why I am double dereferencing that part of the code.
This call to retrieve from the map acts a bit odd. Sometimes it will work. For example, where pos = Vector2(0,0). But then it will fail where pos = Vector2(0,25), and it will return a nullptr. The weird thing is that I have confirmed that pos = Vector2(0,25) is already in the map.
Is there something I am doing wrong with the call to retrieve the shared_ptr<ControlNode>?


texts: How does UV mapping work for the spaces between vertices?

texts: In UV mapping each vertex has a UV coordinate, but wouldn't that just make 1 pixel for every vertex? How do you find out the texture coordinate for the spaces in between the vertices? Am I not understanding UV mapping right?


texts:
So, I've been working on several smaller game project in past few months, and I've got the hang of game dev in java. Now I'm trying to optimize game performance. Is it ok to simply use g.drawImage();to display sprites and other images?

Note that I'm trying not to use any external libraries.


texts: Delaying certain actions/functions in libgdx using Timer?

texts:
Hello I am trying to delay a part of the processes in my game, but it happend that I use one of my variables in an inner class so I have to make it final, but by making it final I can't assign new value when I find it. All I am asking for is to explain me how to do the delay without making my variable final.
Here is my code:

public class TomatoScript implements IActorScript {

private CompositeActor tomato;
private static final int speed = 100;
private BitmapFont bFont;
private Batch bch;
ArrayList<FruitScript> fruits;
private final int dmg = 10;
private int hp = 50;
private Rectangle bounds;
private int state = 0;
private FruitScript collidetFruit;

private boolean dead() {
    return hp <= 0;
}

private void setHp(int dmg) {
    hp = hp - dmg;
}

public TomatoScript(Batch b, BitmapFont bf, ArrayList<FruitScript> fruits) {
    this.bch = b;
    this.bFont = bf;
    this.fruits = fruits;
}

@Override
public void init(CompositeActor entity) {
    this.tomato = entity;
    tomato.setPosition(200, 129);
    bounds = new Rectangle(tomato.getX(), tomato.getY(), tomato.getWidth(), tomato.getHeight());
    bch.begin();
    bFont.draw(bch, Integer.toString(hp), tomato.getX() + 20, tomato.getY() + 95);
    bch.end();

}

@Override
public void act(float delta) {
    switch (state) {
        case 0:
            tomato.setX(tomato.getX() + speed * delta);
            bounds.setX(tomato.getX());
            bch.begin();
            bFont.draw(bch, Integer.toString(hp), tomato.getX() + 20, tomato.getY() + 95);
            bch.end();
            if (tomato.getX() >= 1090) {
                tomato.remove();
            }
            if (collisionFound()) {
                state++;
            }
            break;
        case 1:
            if (collisionAct(collidetFruit)) {
                state = 0;
            }
            break;

    }

}

private boolean collisionFound() {
    for (FruitScript f : fruits) {
        if (f.getBounds().overlaps(bounds)) {
            collidetFruit = f;
            return true;
        }

    }
    return false;

}

private boolean collisionAct(FruitScript f) {
    com.badlogic.gdx.utils.Timer.schedule(new com.badlogic.gdx.utils.Timer.Task() {
        @Override
        public void run() {
            f.setCol(true);//here it says I should make the "f" final.
            f.setHp(dmg);//here also.
            setHp(f.getDmg());
        }
    },2);

    if (f.dead()) {
        fruits.remove(f);
        return true;
    }
    if (dead()) {
        if (!f.dead()) {
            f.setCol(false);
            tomato.getScripts().remove(this);
            tomato.remove();
        }
        return false;
    }

    return false;
}

@Override
public void dispose() {
}}

I've tried to make it final, but it ruins everything it's supposed to stop the actors do the damage taking and then the one alive to continue, but it was doing it too fast in a blink of an eye. When you make the f final, it can't get the new item it should collide with. I hope someone can help :)


texts: Destroying anything, after a moving trigger box exits it

texts:
I'm making a endless runner game, and i have a trigger box following the character, behind the camera. I want it to destroy any kind of object, after the trigger box exits the object. so far i have written this for the code, but it doesn't seem to be correct, and actually doesn't work!

 void OnTriggerExit (Collider other)
 {
     Destroy(other.gameObject);
 }

What should i add to this? Thanks.


texts: How to use quaternion on another referential

texts:
I'm new on Three.js and despite a mechanical background, I can't find how quaternion works: it's like it always refers on local part referential and not the global one.

I've illustrated it here : http://jsfiddle.net/ehsktuj2/13/

function applyRotation(){
    var redRotationQuaternion = new THREE.Quaternion();
    redRotationQuaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), control.rotationSpeedRedY );
    applyQuaternion(_cubeRed, redRotationQuaternion);

    var greenRotationQuaternion = new THREE.Quaternion();
    greenRotationQuaternion.setFromAxisAngle( new THREE.Vector3( 0, 0, 1 ), control.rotationSpeedGreenZ );
    applyQuaternion(_cubeGreen, greenRotationQuaternion);
}

function applyQuaternion(cube, quaternion){
    var cubeQuaternion = cube.quaternion;
    cubeQuaternion.multiplyQuaternions(quaternion, cubeQuaternion);
    cubeQuaternion.normalize();
}

The rotation quaternion of the green box is via the vector (0,0,1) but it's not in the global referential, it's the one of the projected referential of the green cube.

How can I project the quaternion back on the global referential? So that the green cube rotates via the (0,0,1) vector of the scene?


texts:
Do you have any reasons why my tween code didn't run or work? I already add the tween engine onto the library folder under LibGDX project folder and "Order and Export" it under Java Build Path at the Properties menu. My first two classes ran correctly and workly but my third class didn't work. Here's the sequence:

First class is the first screen. Fade animation works on the company's logo.
Second class is the second screen. Fade animation for the loading screen works.
Third class is the third screen. After the second screen, now calls for the third screen. Animation stopped or won't run since I want the black screen to fade out at the start when the menu is here.

Can you check if I did right? Look carefully by comment lines for explanation.

    //-----[ Animation Setup ]-----
    Tween.registerAccessor(Sprite.class, new Tween_Animation()); // --> Tween_Animation.java
    Tween_Manager = new TweenManager(); // --> I initialized it the TweenManager and seems okay.
    cb_start = new TweenCallback() // --> I'll use this when I choose START and the menu will fade in black.
    {

        @Override
        public void onEvent(int arg0, BaseTween<?> arg1)
        {
            goTo();
        }

    };

    Tween // --> This is where I focused the problem.
    .to(black_Sprite, Tween_Animation.ALPHA, 3f)
    .target(1)
    .ease(TweenEquations.easeInQuad)
    .repeatYoyo(200, 2.5f) // --> I set the repeat for 200 times when I noticed that the animation won't work!
    .start(Tween_Manager);


texts: Unity/vuforia imagetarget - object not showing properly

texts:
I learn it from vuforia tutorial on youtube.

I add a white cube(or sphere) as the child of image target.

When the camera catches the image target, the screen turns to be totally white. It seems that the object target is too large to show on screen.

When I move away from the image target, the camera works again. I tried a new project and repeated my steps many times, and I do succeed sometimes. I don't why most times it just shows part of object and fills all screen.


texts: How can I calculate the new vector of an object trying to push into (move along) the ground?

texts:
Say I have a sphere (planet). If I have object on the surface, I want to limit movement so that it can only travel in directions along or above the surface.

Imagine a coin on a table. If I were to push the coin from up above at an angle, the table would cancel out any downward vector component and the coin would move in 2 dimensions across the table. This is what I would like to achieve.

In the case of a planet (sphere) then I can calculate the cancelling vector to some extent (this is just the line from the centre of the sphere to the point on the surface).

Now I struggle - how do I calculate the magnitude of the opposing vector such that it is sufficient to stop the object falling through the surface but not too big that it starts to launch the object away from the surface?


texts: How to create a linear plateform between two points?

texts:
I have a set of 2D coordinates. Their positions are regular on the X axis, but unpredictable on the Y axis:

I would like to create slim platform between each point in order tu use it as ground for my game, expecting a result like this:

I'm working with Box2D, so I thought about create boxes like this:

float x1, y1, x2, y2; // Coordinates between two points
float centerX, centerY;
float differenceX, differenceY;
float width;
b2BodyDef bodyDef;
b2Body* body;
b2PolygonShape shape;

centerX = (x1 + x2) / 2.0;
centerY = (y1 + y2) / 2.0;
differenceX = x2 - x1;
differenceY = y2 - y1;
width = sqrtf(differenceX * differenceX + differenceY * differenceY);
height = 10.0f

bodyDef.position.Set(centerX, centerY);
bodyDef.angle = -M_PI / 4.0f * width / height
body = world.CreateBody(&bodyDef);
shape.SetAsBox(width, 10.0f);
body->CreateFixture(&box, 0.0f);

But the wrong part of this code seems to be on angle. I cannot find the correct rotation between two points from their coordinates.

Is there a correct math formula to find it?
Or am I simply wrong to use rectangular boxes to trace it, and should I use something else? Like a b2PolygonShape?


texts: Should I use an arraylist to store client connections

texts:
I am running a server, and I have an arraylist of clients.

When a client connects, I create a new object in the arraylist(all running on their own threads)

When a client disconnects, the server closes the Socket. And the thread terminates

My problem is when a client disconnects, it closes the Socket, but it doesn't delete its spot in the arraylist, and shift everything down one. So the arraylist is constantly growing bigger.

What can I do/use to fix this problem?

I will update with more detailed information/code if need be.


texts: XNA: Why use Xact when I can use Content.Load?

texts:
I have to add sound to a game and I found that you can use xact. That's fine, however why not just use Content.Load?

Besides the tweaking of the sound, are there any other advantages to using Xact?


texts:
I am working on a 2D (Realtime) MultiPlayer Game.

With Construct2 and a Socket.IO JavaScript Server.

Right now the code does not include the Array for each Player.

var io = require("socket.io").listen(80);
var x = 10;
io.sockets.on("connection", function (socket)
{
socket.on("message", function(data)
{
x = x+1;
});
});
setInterval(function()
{
io.sockets.emit("message", 'Pos,' + x);
},100);

I noticed a very annoying problem with my server today. It sends my X Coordinates every 100 milliseconds.

The Problem was, that when I went into another Browser Tab, the Browser stopped the Game from running. And when I went back, I think the Game had to run through all the packages.
Because my Offline Debugging Button still worked immediately and the Online Button only responded after some seconds.

So then I changed my Code so that it would only send out an update when it received a player Input:

var io = require("socket.io").listen(80);

var x = 10;

io.sockets.on("connection", function (socket) {
socket.on("message", function(data)
{

x = x+1;
io.sockets.emit("message", 'Pos,' + x);
});
});

And it Updated Immediately, even when I had been inactive on the Browser Tab for a long time. Confirming my suspicion that it had to get through all the data. Confirm Please!

It would be insane to only send information on Client Input in a Real Time Game.

But how would I write a AFK function?

I would think it is easier to run a AFK Boolean Loop on the Server.

Here is what I need help for:

playerArray[Me]
if (   "Not Given any Input for X amount of Seconds"    )
{
 "Don't send Data"
}
else
{
 "Send Data"
}


texts:
I am looking for algorithm to calculate direction and speed of balls in a pool game. I am sure there has to be some type of open source code for this since pool games are some of the oldest computer games I can remember.

I mean, when one ball hits another, I need a algorithm to calculate direction of both of them. It will depend of exact angle of where they hit each other and on speed.

I want to practice Java coding, so I am looking for java code or package that has this type of code.


texts: Is Ruby's garbage collector still as big of a problem to game developement?

texts:
I am beginner wanting to make a game, and chose to learn Ruby ,since it seems easier to read than most languages.

Reading up on Ruby, I find that Ruby could be used to make small-scale games, but it's garbage collector was a serious problem. The post I read had been closed, so the most recent post was from 2013. In contrast, Ruby 2.0 came out in 2013, and apparently the garbage collector got better. I was wondering if the garbage collector is still a major problem.

To be a little more specific, the game I want to make is going to be 2D, using pixel art. It's a small PvP game using LAN. I want to make 7 character classes, but I can start with less. This game is quite small, but there are a lot of things I want to add as I get more experience, such as a story.

Does the garbage collector still make game development a problem, in Ruby?


texts: How to refer to a object that has just been hit by a ray cast?

texts:
I would like to use RigidbodyConstraints.FreezeRotation;in order to freeze the rotation of an object that is picked up. The problem is I don't know how to refer (or call) the currently selected object. The script in it's currents state is below...

public class PhysGun : MonoBehaviour
{
    private GameObject Player;

    void Start ()
    {
       Player = GameObject.Find("Player");
    }

    // Update is called once per frame
    void Update ()
    {
        Vector3 fwd = transform.forward; // Equivalent to the code you had.

        Ray ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Input.GetMouseButton(0) && Physics.Raycast(ray, out hit, 10f))
        {
            hit.transform.SetParent(Player.transform);
            Debug.Log("We hit: " + hit.transform.name);
            hit.transform. = RigidbodyConstraints.FreezeRotation;
        }

    }

}

So, how do I call (or refer to) the object that is hit by the ray cast exactly?


texts: Locating different models in a single scene

texts:
I have a curiosity.

Say I wanted to create a big forest using Blender, in this forest I'd like to have a campfire or several campfires. What I could do is create the entire scene in Blender with campfires included and of course in-engine I would add a fire effect to it. Now what I do not understand is how can I actually find the fireplaces' locations in the engine? Since it's all in one scene, I can't just say getLocation on the model.

I guess what I'm asking isn't how to do it per say, but what the "professional" way is. Do professional game developers fiddle around with coordinates until they find it? Do they load the campfire on top of the scene as a separate model and move it until it fits the scene? Just in case it is important, I am using jMonkeyEngine.


texts: How to set the camera projectionmatrix so that it's 4 rays always exactly hit the corners of a defined plane?

texts:
I have a camera, and I have a plane.
The plane has 4 corner points.
I need to find out how to change the projection-matrix of the camera so that the projection-rays of the camera always hit the corners of the plane.

The camera and the Plane are supposed to be movable rotateable (if possible)
The Plane is also supposed to be scaleable.

Usage:

I am making a Stereo-3D-Game with Eyetracking where my 2 Eye-Vectors hit the exact same paralax-plane.

That paralax-plane is defined.
So we have the Corner-positions of the Plane.


texts:
In my game,if I touch a particular object,coin objects will come out of them at random speeds and occupy random positions.

public void update(delta){
if(isTouched()&& getY()<Constants.WORLD_HEIGHT/2){
         setY(getY()+(randomSpeed * delta));
         setX(getX()-(randomSpeed/4 * delta));
         }
  }

Now I want to make this coins occupy positions in some patterns.Like if 3 coins come out,a triangle pattern or if 4 coins, rectangular pattern like that.

I tried to make it work,but coins are coming out and moved,but overlapping each other.Not able to create any patterns.
patterns like:

This is what I tried

int a = Math.abs(rndNo.nextInt() % 3)+1;//no of coins
        int no =0;

        float coinxPos = player.getX()-coins[0].getWidth()/2;
        float coinyPos = player.getY();
        int minCoinGap=20;
        switch (a) {
        case 1:
            for (int i = 0; i < coins.length; i++) {
                if (!coins[i].isCoinVisible() && no < a) {
                    coins[i].setCoinVisible(true);

                    coinxPos = coinxPos+rndNo.nextInt()%70;
                    coinyPos = coinyPos+rndNo.nextInt()%70;
                    coins[i].setPosition(coinxPos, coinyPos);
                    no++;
                }
            }
            break;
        case 2:
            for (int i = 0; i < coins.length; i++) {
                if (!coins[i].isCoinVisible() && no < a) {
                    coins[i].setCoinVisible(true);
                    coinxPos = coinxPos+minCoinGap+rndNo.nextInt()%70;
                    coinyPos = coinyPos+rndNo.nextInt()%150;
                    coins[i].setPosition(coinxPos, coinyPos);
                    no++;
                }
            }
           break:
          ......
          ......
          default:
            break;

may be this is a simple logic to implement,but I wasted a lot of time on it and got confused of how to make it work.
Any help would be appreciated.


texts: Making a surface transparent from blackness of texture

texts:
I am making a "halo" shader in unity using GLSL. And I've come to a roadblock.

What I need to do is take a texture, like the following, and make it transparent according to the darkness of it. And I don't want a cutout, because that cuts it off at a hard edge.

This line of code doesn't seem to work.

gl_FragColor = texture2D( vec4( _MainTex.r, _MainTex.g, _MainTex.b, _MainTex.a), vec2(textureCoordinates));


texts: Which game engine to use for Android TV?

texts:
I am trying to tinker a bit on Android TV game development and I am trying to figure out which would be the best suited 2D/3D game engine for this purpose or, alternatively, which are the main aspects I should consider when choosing one. Could you give me some basic hints?

Note: I am not a professional game developer, I have experience in C++ and only entry-level Java and Android development.

Thanks in advance!


texts:
Working with the Wii I often find it necessary to recognize simple gestures, so far I've been able to mainly look at magnitude of acceleration in order to recognize the gestures called out for in our game design documents, but I'd like to create a more robust system that allows "recording" of example gestures and recognition of complex gestures.

What strategies have you used in the past? Why did they work? Why didn't they work? What would you do differently?


texts: How to convert Triangle/OBB test to OBB/OBB test?

texts:
I'm using the collision library OZCollide and I want to do OBB vs. OBB collision tests. The problem is, that this function doesn't seem to exist but instead there is a AABB vs. OBB and a Triangle vs. OBB function. I'm not very comfortable with OBB intersections, but I think the necessary code is already there!

Can anyone help me by using this code for OBB/OBB Testing?

The code is here.

This code doesn't belong to me, It's Igor Kravtchenko's!


texts: How can I find the direction a sprite is moving?

texts:
I'm trying to get the direction a sprite is moving (up, down, left, right). My current approach is to get the x and y coordinates of the target and the sprite (the sprite is the thing that I'm trying to get the direction of), and then have booleans be true/false based on the the values of the x/y coordinates (if they are greater than, less than, etc.). I'm not trying to rotate the sprite or change anything about how it's drawn, just find the direction that it's moving in. This is what I'm currently trying (this is more of a general idea of what I'm doing, and is pretty rough):
if (Target.Position.X < Position.X && Target.Position.Y < Position.Y - 500)
{
    IsFacingUp = false;
    IsFacingDown = false;
    IsFacingLeft = true;
    IsFacingRight = false;
}
else if (Target.Position.X < Position.X && Target.Position.Y > Position.Y + 500)
{
    IsFacingUp = false;
    IsFacingDown = false;
    IsFacingLeft = true;
    IsFacingRight = false;
}
else if (Target.Position.X > Position.X && Target.Position.Y < Position.Y - 500)
{
    IsFacingUp = false;
    IsFacingDown = false;
    IsFacingLeft = false;
    IsFacingRight = true;
}
else if (Target.Position.X > Position.X && Target.Position.Y > Position.Y + 500)
{
    IsFacingUp = false;
    IsFacingDown = false;
    IsFacingLeft = false;
    IsFacingRight = true;
}
else if (Target.Position.Y <= Position.Y - 500)
{
    IsFacingUp = true;
    IsFacingDown = false;
    IsFacingLeft = false;
    IsFacingRight = false;
}
else if (Target.Position.Y >= Position.Y + 500)
{
    IsFacingUp = false;
    IsFacingDown = true;
    IsFacingLeft = false;
    IsFacingRight = false;
}


texts: Why do my sprites stutter when I move them too quickly?

texts:
The Problem
I have some sprites animating across my screen (some spaceships).
I alter their X coordinates (like -5, for animation) in my game loop.

I want the animation to happen faster, however when I alter their coordinates too much (like position-=5 each time), the animation becomes jumpy and stutters.

For example, decrementing objects xPosition by 1 = slow moving smooth animation
But, decrementing objects xPosition by 5 = faster, but choppy/stuttering animation

What I've tried
The only way I can think is to make my game FPS like 100 with a lower position incrementing speed, which is extremely wasteful.

My game loop is below.
(I know this isn't a great game loop, but its one of the few I understand. I also can't see how it would be a problem for this example)

private final int FPS = 60;
private final long TICKS = 1000/FPS; //16.67ms per update max

public void run() {
    long startTime = System.currentTimeMillis();

    while(gameRunning){

        cycleEnemies();
        repaint();

        startTime += TICKS;

        sleepTime = startTime - System.currentTimeMillis();

        //So timeout isnt negative
        if(sleepTime > 0){
            try{
                Thread.sleep(sleepTime);
            }catch(InterruptedException e){
                System.out.println("Interrupted: " + e.getMessage());
            }
        }else{
            //We're running behind!
        }
    }

}

And this is my cycle method:

    private void cycleEnemies(){
        for(Enemy e : enemyShips){
            e.setXPosition(e.getXPosition() - 5);
        }
    }

This is my drawing code:

private void drawEnemy(Graphics g){
    //Loop through enemyShips array, drawing all
    for(Enemy e: enemyShips){
        g.drawImage(e.getTexture().getImage(), e.getXPosition(), e.getYPosition(), null);
    }
}


texts: GluUnproject works, but only when the camera is not rotated

texts:
I am working on a very basic 3D program, my first one using OpenGL.  What I am trying to do is trace a ray from the mouse's location on click which works, but only when the camera is not rotated. When the camera is rotated, the unproject treats it as if it was not.

What am I doing wrong?

The code for unproject:

Coord3<GLdouble> Display::GetOGLPos(uint16_t x, uint16_t y)
{
    GLint viewport[4];
    GLdouble modelview[16];
    GLdouble projection[16];

    Coord2<GLfloat> window_location;
    Coord3<GLdouble> resultant_ray;

    glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
    glGetDoublev(GL_PROJECTION_MATRIX, projection);
    glGetIntegerv(GL_VIEWPORT, viewport);

    window_location.x = (float)x;
    window_location.y = viewport[3] - (float)y;

    gluUnProject(window_location.x , window_location.y, 1.0f, modelview, projection, viewport, &resultant_ray.x, &resultant_ray.y, &resultant_ray.z);

    return resultant_ray;
}

The display code:

void Display::Render()
{
    if(!dirty)
    {
        return;
    }

    glTranslatef(camera.location.x ,camera.location.y, camera.location.z);

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glRotatef(camera.angle.y, 1, 0, 0);
    glRotatef(camera.angle.x, 0, 1, 0);

    glCallList(cube);

    glColor3ub(0, 0, 255);

    glBegin(GL_LINES);
    glVertex3f(0,0,0);
    glVertex3f(mouse_click.x, mouse_click.y, mouse_click.z);
    glEnd();

    glLoadIdentity();

    SDL_GL_SwapBuffers();

    dirty = 0;

    SDL_Delay(33);
}


texts: How to properly create a handle for setting moving platform's target position in Unity?

texts:
As the title suggests, I am trying to set up a handle for setting target position of a moving platform.

I have an empty GameObject(targetPos) and this is what I want to use for setting target position of the moving platform.

Here is the code I have for it so far but it does not seem to work correctly and I am not sure what is wrong.

The problem is, the empty gameobject's transform is not using correct position for moving platform to go to. Not that I put the empty gameobject as the child of the moving platform.

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

public class MovePlatform : MonoBehaviour
{
public Transform targetPos;
private Vector3 initialPosition, targetPosition, targetPosDebug;
public float speed = 3;
public bool loop;

void Start()
{
    initialPosition = transform.position;
    SetTargetPosition(targetPos.position);
}

void Update()
{
    transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);

    if (transform.position == targetPosition)
    {
        if (loop)
        {
            SwitchDirection();
        }
    }
}

public void SwitchDirection()
{
    if (transform.position == initialPosition)
    {
        SetTargetPosition(targetPos.position);
    }
    else
    {
        targetPosition = initialPosition;
    }
}

private void SetTargetPosition(Vector3 localPosition)
{
    targetPosition = initialPosition + localPosition;
    targetPosDebug = targetPosition;
}

void OnDrawGizmos()
{
    if (Application.isPlaying)
    {
        Debug.DrawLine(initialPosition, targetPosDebug, Color.red);
    }
    else
    {
        Debug.DrawRay(transform.position, targetPos.position, Color.red);
        Gizmos.DrawSphere(targetPos.position, 1.0f);
    }

}
}


texts: I need a scene graph/management method for a 3D editor (brute force rendering is not really a possibility), where lots of data (geometry) are constantly being modified, it also would need to work great for picking (casting rays from the camera to select objects). Octrees seem to be a great solution, but i'm not quite sure.


texts: Reasonable amount of garbage collection for mobiles games?

texts: I'm making a 2D game for mobile and I noticed that my GC seemed to spike during attack. My normal GC is 40b but during attack it could spike to 2.2kb. I think this is really high specially when I saw a 3D game with only 8b GC. I would love to hear your thoughts about what's a reasonable amount of GC for mobile(e.g device with 512ram). I know I'm supposed to keep the GC as low as possible however I want to have a value I could compare to.


texts: Use ramp and steps meshes as actual ramp in unreal engine 4.26

texts:
Is it possible to use a ramp mesh as an actual ramp in UE4? It seems that the system create a rectangle box around the ramp o the character does not climb the ramp, it is over it like on a box.
I know that we can use landscape ramp's generator, but it's one more step that could be avoid.
thanks guys!


texts: Is it possible to animate the texture of a model?

texts:
Below is how far I've got. I just made a simple block with user primitives to test it. But I haven't found a way to crop the spritesheet.

textureLava = frames[activeFrame];

This line is how I want it but off course this doesn't work. Is there a way to crop this spritesheet or is there another way to animate the texture of a model?

public void CreateFrames()
{
    for (int i = 0; i < 64; i++)
    {
        frames.Add(new Rectangle(WIDTH + i, i, WIDTH, HEIGHT));
    }
}

public override void Update(GameTime gameTime)
{
    if (System.Environment.TickCount - lastFrameTime > TIME_BETWEEN_FRAMES)
    {
        activeFrame++;
        lastFrameTime = System.Environment.TickCount;

        if (activeFrame > 15)
        {
            activeFrame = 0;
        }
    }

    textureLava = frames[activeFrame]; --> DOESN'T WORK

    base.Update(gameTime);
}

public override void Draw(GameTime gameTime)
{
    effect.TextureEnabled = true;
    effect.World = Matrix.Identity;
    effect.View = Camera.ActiveCamera.View;
    effect.Projection = Camera.ActiveCamera.Projection;

    effect.Texture = textureLava;

    foreach (EffectPass pass in effect.CurrentTechnique.Passes)
    {
        pass.Apply();

        GraphicsDevice.SetVertexBuffer(vertexBuffer);

        GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 10);
    }
}


texts: Is there a reliable and fast way of getting a list of all installed games on a Windows PC?

texts:
Note: This was the best fitting stack I could find for this. Apparently this site doesn't specify in the scope whether this is allowed. I originally asked in Meta, and they told me to create the question so the community could decide using a concrete question.

Like other people with large gaming libraries, I've often been faced with uncertainty about what game to play. There are websites that can check your Steam library and suggest you a game based on things like Metascore, user ratings, genre preferences,... but there are 3 major issues with these:

They require an internet connection;
They check all your games, which also means games you've yet to download or which you got through a bundle deal with no intention of ever playing;
They only check Steam games, not games from other clients or even just classic disc-based games.

During my spare time, I had been working on a small C# program trying to fix this. It worked using a very brute-force way: you entered a folder name, it would get ALL files from that folder, then filter out everything that wasn't a .exe file and the stuff that didn't look like it was a game executable. It kinda worked, but it had 3 main issues:

SLOOOOOOW! it took 15 minutes to get all the files, if it didn't crash due to memory issues.
it included things that weren't games, like uninstallers, C redists and utilities;
I wrote it as an UWP program, which meant it wasn't portable to Windows 7 and 8 and was lacking proper libraries for things like mocking.

I'm taking another stab at it soon, but this time, I don't want to do it brute-force. I'm hoping to leverage the power of the platform and use readily available methods to find what I need.

My question is:

Does Windows have something that can give me a list of installed games?
If Windows can't do it, do the major digital distribution clients (meaning Steam, Origin and UPlay) have a way to provide a list of installed games? I don't mind if it means parsing files and then looking things up.


texts: How to know in OPenGL ES android that one object crosses another?

texts:
I have 2 objects on the screen:

static:

non-static:

non-static object moves randomly over the screen.

How do I know that non-static Object cross the "+" (static).

Both objects I draw by using followed code:

private void updateScreenData(float screenWidth, float screenHeight){
    // takes screen Height and Width
    this.mScreenWidth = (screenWidth > 0) ? screenWidth : 1f;
    this.mScreenHeight = screenHeight;
    wRatio = 10f/mScreenWidth;
    hRatio = mScreenHeight/10f;
}

protected void drawTarget(GL10 gl){
    gl.glPushMatrix();
    try {
        float transx =  shiftX + (wRatio * (x));
        float transy =  shiftY +(mScreenHeight*wRatio) - (wRatio * (y)) - 1/hRatio;

        gl.glTranslatef(transx, transy, 0.0f);

        //###########  draw ##############

        gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, floatBufferArray[mFrame]);

        //update();

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

        //###############################

    } catch (NullPointerException e) {
    }
    gl.glPopMatrix();
}

public void loadTextures(GL10 gl) {
    Log.e(LOG_TAG, "loadTextures");

    InputStream is;

    is = mContext.getResources().openRawResource(_SRC);

    Bitmap bitmap = BitmapFactory.decodeStream(is);

    try {
        is.close();
        is = null;
    } catch (IOException e) {
    }

    gl.glGenTextures(TEXTURE_COUNT, textures, 0);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

    bitmap.recycle();

}

Any ideas?

What do I need to compare in both Objects?

[EDIT]

I see my question is not so clear, so i'll try once more.

Since my cross image stays at the middle of screen (screenWidth/2 and screenWidth/2) I know the coordinates, it do not change. But second Object changes.

How can I fetch out  coordinates (aka x,y) from dynamic object?


texts: How can I split my entity manager class into a gameworld class and gamerenderer class?

texts:
I currently have a libGDX game where I have an entity manager class which is called in the gamescreen. Instead, I would like to utilise it in a gameworld class and a gamerenderer class, but I cannot figure out how to split it up (if that makes sense). I want to do this so that I can manipulate my player class separately and not as a part of the entity manager. Previous attempts have failed because taking 'player' away meant that checkCollisions stopped working (hence why I want to use gameworld and gamerenderer classes instead). Does anyone have any ideas on how to achieve this?

Here is my entity manager class:

public class EntityManager {
    private final Array<Entity> entities = new Array<Entity>();
    private final Player player;

    public EntityManager(int amount) {
        player = new Player(new Vector2(110, 15), new Vector2(0, 35));
        for (int i = 0; i < amount; i++) {
            float x = MathUtils.random(0, ManicMeltdowns.WIDTH - TextureManager.DROPS.getWidth());
            float y = MathUtils.random(ManicMeltdowns.HEIGHT, ManicMeltdowns.HEIGHT * 3);
            float speed = 2;
            addEntity(new Drops(new Vector2 (x, y), new Vector2(0, -speed)));
        }
    }

    public void update() {
        for (Entity e : entities)
            e.update();
        player.update();
        checkCollisions();
    }

    public void render(SpriteBatch sb) {
        for (Entity e : entities)
            e.render(sb);
        player.render(sb);
    }

    private void checkCollisions() {
        for (Drops e : getDrops()) {
            if (e.getBounds().overlaps(player.rectangle)) {
                ScreenManager.setScreen(new GameOverScreen());
            }
        }
    }

    public void addEntity(Entity entity) {
        entities.add(entity);
    }

    private Array<Drops> getDrops() {
        Array<Drops> ret = new Array<Drops>();
        for (Entity e : entities)
            if (e instanceof Drops)
                ret.add((Drops)e);
        return ret;
    }
}

Thanks.


texts: Should I use an SQL database to store data in a desktop game?

texts:
Developing a Game Engine

I am planning a computer game and its engine. There will be a 3 dimensional world with first person view and it will be single player for now. The programming language is C++ and it uses OpenGL.

Data Centered Design Decision

My design decision is to use a data centered architecture where there is a global event manager and a global data manager. There are many components like physics, input, sound, renderer, ai, ... Each component can trigger and listen to events. Moreover, each component can read, edit, create and remove data.

The question is about the data manager.

Whether to Use a Relational Database

Should I use a SQL Database, e.g. SQLite or MySQL, to store the game data? This contains virtually all game content like items, characters, inventories, ... Except of meshes and textures which are even more performance related, so I will keep them in memory.

Is a SQL database fast enough to use it for realtime reading and writing game informations, like the position of a moving character? I also need to care about cross-platform compatibility. Aside from keeping everything in memory, what alternatives do I have?

Advantages Would Be

The advantages of using a relational database like MySQL would be the data orientated structure which allows fast computation. I would not need objects for representing entities. I could easily query data of objects near the player needed for rendering. And I don't have to take care about data of objects far away. Moreover there would be no need for savegames since the hole game state is saved in the database. Last but not least, expanding the game to an online game would be relative easy because there already is a place where the hole game state is stored.


texts: Unity objects with flickering and noisy edges

texts:
In our game which is still in early development we're (we, Unity rookies) facing this flickering issue occurring especially in edges which are very close to each other, but not limited to them. The problem worsens once the camera moves but in the idle state it's not also not working as expected.

Here is a video depicting the situation. Notice that once I disable the edge detection the problem improves some, but still persists.
https://youtu.be/EL28HORkbbU

Here are our Edge Detection settings

Here is our PP anti-aliasing settings (We also tried FXAA but it gives worse results)

The buildings are natively modeled with ProBuilder.
Unity version: 2018.2.14f1

Is there a way to solve this issue to obtain smoothness in such edge detection cases? Are we missing something? We want to keep that visual style in which edges are drawn in black.


texts:
I'm creating a shooter, it's still very early, but i'm implementing some polygon hitboxes.

So far i have created a polygon class, and i'm looking into how i can hook it onto my player.

I'm trying to stay away from having a Tick() function in my polygon class, and I would rather not update the position every tick (it would clutter up my tick functions). At the same time I would really like to have the positions in there somehow (it has a drawing function, and i will be using it for hit detection)

How would i go about implementing this polygon object into my entities?


texts:
I'm come from WinForm/.NET development, where there is a lot of 'cool' ready made widget like: combo box, list view with scrolling system included.

Now I'm using Unity and I'm trying to implement user GUI, but i'm facing some trouble because as i can see there aren't much ready made widget.

Specifically, I'm trying to implement a saving/loading system and i'm trying to add a window with a list box containing list of saving file.

What's the best widget / approach to do this ?

Thanks


texts: Concerns about how to efficiently implement sprite atlas

texts:
I currently transform (translate, rotate, scale) a bunch of vertices in my own Java code, then populate an mPositions array and an mTextureCoordinates array, which draws a bunch of different textured sprites to the screen in one GL draw command. Works great.

However, I now wish to move the transformation process away from native Java code and over to the vertex shader, and so I will need to pass into the shader transformation matrices which encode the translation, rotation, and scaling operations for each sprite.

Given my current approach the naive and obvious choice is to introduce another array mTransformations, passed into the shader via a GLES20.glVertexAttribPointer command, which contains a matrix for each and every vertex.

But this way seems a little wasteful for two reasons:

I will have to add the same transformation matrix 6 times per sprite to the mTransformations array since each square sprite is made of 2 triangles (3+3 vertices)
Since I'm now going to use the shader to perform the transformations, the 6 canonical coordinates of each square sprite (two triangles) will be the same for every sprite. In effect I'd have to populate mPositions with the same coordinates over and over for each sprite.

Is there a more efficient way to do achieve what I want?


texts: Implementing a Random Picker by Supplying an Outcome Table (Similar to a Drop Table)

texts:
Whilst trying to vary the draw color of some randomly positioned sprites, I really wanted to be able to just supple a table with 2 columns (colour and chance of picking) to some helper function that would do all calculations for me.

Ideally, I want to be able to do something like the follow (semi-pseudocode) :

var table = new object[]
{
    Color.White, 0.2, // Chance: 20%
    Color.Red, 0.2, // Chance: 20%
    Color.Blue, 0.5, // Chance: 50%
    Color.Black, 0, // Default, i.e. remaining chance (10%)
};

Color newColor = Pick<Color>.AtRandom(table); // Apologies if this is very wrong!

I'm fairly confident I could get something to work within the class - my issue is deciding on the correct way to supply the Pick class the chances for each possible selection. I don't want this to be specifically for Color - I want to be able to select between any type of struct / instance of a class. The last line to me doesn't seem 'possible' as in I am unsure whether or not you would require an instance of Pick or if this can be done using a static class.

The use of object[] seems like a hackerish way to implement this. It's more streamlined to use a Tuple however the chance table becomes extremely verbose when every item in the array would be along the lines of Tuple.Create<Color, double>(Color.Red, 0.2), etc.

What is the most sensible / expandable way to do this?

Thanks for your time.


texts:
I've had a good few months of experience with Ruby on Rails, creating my own CMS system, a social network and even a VOIP enabled answering phone machine. I'm also an established 3D modeller, and what I really, really want to do is create a 3D game that's executed in the browser.

I'm not talking Crysis: Online or CoD: Online, or even Doom. Nothing too graphically/RAM intensive. Not a shooter. I simply want to create a simple puzzle solving, hidden object game that can be accessed in the browser.

Maybe something along the lines of the Myst  III+ games.

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

Technically, they're very simple games, but by placing the camera inside a 3D sphere with its inner surface textured with an appropriately-distorted 2D rendering, they pull the player into thinking they're exploring a 'fully' 3D world.

They're not realtime, and I genuinely think this could be done online. Maybe some bandwidth issues with these high-res images, but by hiding loading screens behind doors that take a while to open, I think a seamless experience could be achieved.

So, is there a simple 3D engine for ruby? Open source, with a great community?

Apologies if you think I'm rambling, I've rambled in the hope that it'll give you a good feel for my technical requirements :)


texts: Fixed timestep, updates per second keeps changing?

texts:
I've been trying to create a deterministic, fixed gameloop.
The game loop should run TICK_RATE # of physics updates per second, and then render as quickly as possible (didn't do interpolation yet).
The issue I'm currently having is that the # of physics updates per second isn't constant. I want it to be the same as TICK_RATE, but it constantly changes by 1.
E.g. the tick-rate varies from 60-61 if TICKRATE = 60.
I thought this issue might be due to rounding issues, but manually calculating the delta time with System.nanoTime() and storing everything as a double gives me the same problem. If the physics simulation constantly varies by 1 frame per second, it's not longer deterministic, which I think would be hard to replicate (for networking and replays for example).
Any ideas on how to fix this so the number of physics updates per second is constant?
import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx

private const val TICK_RATE = 60 //Number of updates per second
private const val TIME_STEP = 1f / TICK_RATE //Seconds per tick
private const val MAX_FRAME_SKIP = (TICK_RATE * .2).toInt() //If fps drops below 20% of tickrate, slow down game to
                                                            //avoid spiral of death

class FixedTimestep : ApplicationAdapter() {

    private var accumulator = 0f

    //variables for ticks per second tracking
    private var tps = 0
    private var previousNanoTime = System.nanoTime()

    override fun render() {
        var frameSkipCount = 0
        val delta = Gdx.graphics.rawDeltaTime
        accumulator += delta
        while (accumulator > TIME_STEP && frameSkipCount < MAX_FRAME_SKIP) {
            accumulator -= TIME_STEP
            //do physics step

            //display tps to console every second
            tps++
            val currentNanoTime = System.nanoTime()
            if (currentNanoTime - previousNanoTime >= 1000000000L) {
                println(tps)
                tps = 0
                previousNanoTime = currentNanoTime
            }
        }
        //render
    }
}


texts:
I have a main scene where my player is loading as I start or join the server. On some player action, I want to load additive scenes in to my main scene. It is loading fine on the client, but not across the network. My other clients are unable to watch it.

I checked different links, and found a forum post and a Unity Suggestions page. It seems, to me, that this "Additive scene loading to UNet" feature is not available in Unity.

If additive scene loading in UNet is not available, then what are the alternatives?

I am able to load scene through [ClientRpc]. Is this the correct way to do this?

[ClientRpc]
public void RpcLoadLevelAcrossNetwork()
{
    SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
}


texts:
The title is a bit confusing, but I couln't think of how to explain my question in a short phrase. So here it is:

Whenever I'm writing game engines, wheter it's physics/tilebased etc, I always get to the point where I'm not sure how I should manage things. Should entities in the world handle on their own, or should there be some global system managing them?

Here's an easy example: Moving things.
Should each object see the world around him (check for collisions) and move based on that.

[note, this is a tile based game where object move per tile, so I'm not using physics to move from tile to tile]

public class Actor : GameObject
    {
        private void MoveTo(Vector2 location)
        {
            if (world.getTile(location) != solid && world.objAtTile(location) == null)
            {
                Tweener.addTween(this, location);
            }
          }
        }

Or should the movement of each object be handeled in the world, where the world checks everything?

public class Actor : GameObject
    {
        private void MoveTo(Vector2 location)
        {
            world.moveTo(location);
          }
        }

public class World
{

    public void moveObject(GameObject obj, Vector2 location)
    {
      //called from object

      if (getTile(location) != solid && objAtTile(location) == null)
         {
                Tweener.addTween(obj, location);
         }
    }
}

It doesn't really matter that much for this example I suppose, but I can see myself getting into trouble later on.
Thanks in advance.


texts: How do I use a script located not in the Assets folder?

texts:
I'm developing several games at once, and they all use the same helper C# class which I have named "Helpers.cs".

This script contains common helper functions.

I'm still making changes to this Helper.cs files quite often, and I have to take care to update this file for all of my projects: If I work at 3 projects as once, I have to make sure I didn't forget to update

Project 1\Assets\Scripts\Helpers.cs
Project 2\Assets\Scripts\Helpers.cs
Project 3\Assets\Scripts\Helpers.cs

This is error prone.

I would like to know if there is a way to have only 1 "Helper.cs", for example in

d:\dev\games\common\Helpers.cs

... and all projects would use this. Then I would only have to update the file once if edit it.

I'm using Windows.

Is this possible?


texts: How do you restrict sideway movement in 3D endless runner in Unity?

texts:
I have been making a endless runner 3d game and implemented 3 lane side way movement. It's working perfectly, although I want to restrict my movement for the 3 lanes only. If my character for example say on left lane, If I press left again it should not move to the side anymore since there's not lane beyond the left one. I did implemented a logic for this, though when I press either left or right in the borders of the lanes it freezes the side way movement. Any idea on how to stop this. This is my code.

PlayerMortor.cs

     private bool isChangingLane = false;
     private Vector3 locationAfterChanginLane = Vector3.zero;
     private Vector3 sideWayMovementDistance = Vector3.right * 2f;
     private float sideWaySpeed = 6f;

     void Update()
        {
            currentBaseState = anim.GetCurrentAnimatorStateInfo(0);

            if (controller.isGrounded)
            {
                verticalVelocity = -0.5f;
                if (currentBaseState.fullPathHash == locoState)
                {
                    if (Input.GetButtonDown("Jump"))
                    {
                        verticalVelocity = 18f;

                        anim.SetBool("Jump", true);
                    }
                }

                MoveLeftRight(); //Call sideway movement on update()

                if (isChangingLane)
                {
                    if (Math.Abs(transform.position.x - locationAfterChanginLane.x) < 0.1f)
                    {
                        isChangingLane = false;
                        moveVector.x = 0;
                    }
                }
            }
       }

    private void MoveLeftRight() //Sideway Movement function
    {
        if (controller.isGrounded && !isChangingLane)
        {
            isChangingLane = true;

            if (Input.GetKeyDown(KeyCode.A))
            {
                locationAfterChanginLane = transform.position - sideWayMovementDistance;
                moveVector.x = -sideWaySpeed;
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                locationAfterChanginLane = transform.position + sideWayMovementDistance;
                moveVector.x = +sideWaySpeed;
            }
        }
    }

    private void OnControllerColliderHit(ControllerColliderHit hit) //Restriction when we move sideways beyond border
    {
        if (hit.collider.gameObject.tag == "Border")
        {
            Debug.Log("Border Hit");
            isChangingLane = false;
            moveVector.x = 0;
        }
    }

Any help would be appreciated. :)


texts: I have cube maps in lat/long format, and i need to convert them to Horizontal/Vertical Cross, and individual cross images, is there an utility to do that?


texts:
I'm having troubles implementing a satisfying wall jump in Unity.
I managed to detect collision with a wall, but when I press the jump button, the result is alway weird or very weak. I think this have to do with the 2D physic in Unity, but I have no idead how to handle it correctly.

Here's my code with the concerned parts:

public void Move(float move, bool crouch, bool jump)
{
    // If the input is moving the player right and the player is facing left...
    if (move > 0 && !facingRight)
        // ... flip the player.
        Flip();
    // Otherwise if the input is moving the player left and the player is facing right...
    else if (move < 0 && facingRight)
        // ... flip the player.
        Flip();

    if (jump)
    {
        if (!grounded && walled)
        {
            StartCoroutine(WallJumpRoutine());
        }
    }
}

void Flip()
{
    // Switch the way the player is labelled as facing.
    facingRight = !facingRight;

    // Multiply the player's x local scale by -1.
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
}

IEnumerator WallJumpRoutine()
{
    Vector2 wallJumpVector = new Vector2(jumpForce*10, 20f);

    GetComponent<Rigidbody2D>().AddForce(wallJumpVector, ForceMode2D.Impulse);
    yield return null;
}

To be more precise, the result I'm getting is either my player being moved a tiny bit (despite using the same force as my regular jump, which is working fine) or my player being moved a good distance but at very high speed (this is when I'm using ForceMode2D.Impulse).

Any help?


texts: Efficient minimum distance between two axis aligned squares?

texts:
I have two 2D arbitrarily-positioned axis-aligned squares.

I need to find the minimum distance between those squares – i.e. if you were to draw them, what's the length of the shortest line you could draw that would touch both?

Now, I have an algorithm that works. The problem is it's quite slow. Here it is:

function min_distance(a_left, a_right, a_top, a_bottom, b_left, b_right, b_top, b_bottom) {
    if (a_left <= b_right && a_right >= b_left && a_top >= b_bottom && a_bottom <= b_top) {
        return 0;
    } else if (a_left <= b_right && a_right >= b_left && a_top >= b_bottom/* && a_bottom <= b_top*/) {
        return a_bottom - b_top;
    } else if (a_left <= b_right && a_right >= b_left/* && a_top >= b_bottom*/ && a_bottom <= b_top) {
        return b_bottom - a_top;
    } else if (a_left <= b_right/* && a_right >= b_left*/ && a_top >= b_bottom && a_bottom <= b_top) {
        return b_left - a_right;
    } else if (/*a_left <= b_right && */a_right >= b_left && a_top >= b_bottom && a_bottom <= b_top) {
        return a_left - b_right;
    } else if (/*a_left <= b_right && */a_right >= b_left/* && a_top >= b_bottom*/ && a_bottom <= b_top) {
        let a = a_left - b_right;
        let b = b_bottom - a_top;
        return Math.sqrt(a*a+b*b);
    } else if (a_left <= b_right/* && a_right >= b_left && a_top >= b_bottom*/ && a_bottom <= b_top) {
        let a = b_left - a_right;
        let b = b_bottom - a_top;
        return Math.sqrt(a*a+b*b);
    } else if (a_left <= b_right/* && a_right >= b_left*/ && a_top >= b_bottom/* && a_bottom <= b_top*/) {
        let a = b_left - a_right;
        let b = a_bottom - b_top;
        return Math.sqrt(a*a+b*b);
    } else if (/*a_left <= b_right && */a_right >= b_left && a_top >= b_bottom/* && a_bottom <= b_top*/) {
        let a = a_left - b_right;
        let b = a_bottom - b_top;
        return Math.sqrt(a*a+b*b);
    } else if (a_left <= b_right/* && a_right >= b_left && a_top >= b_bottom && a_bottom <= b_top*/) {
        return b_right - a_left;
    } else if (/*a_left <= b_right && a_right >= b_left && a_top >= b_bottom && */a_bottom <= b_top) {
        return b_top - a_bottom;
    } else if (/*a_left <= b_right && a_right >= b_left && */a_top >= b_bottom/* && a_bottom <= b_top*/) {
        return a_top - b_bottom;
    } else if (/*a_left <= b_right && */a_right >= b_left/* && a_top >= b_bottom && a_bottom <= b_top*/) {
        return a_right - b_left;
    } else { unreachable() }
}

This can also handle rectangles, whereas I only need squares.

Are there any known algorithmic tricks to calculate this substantially faster?


texts: Continuous / speed affected sound effects. What is the industries de-facto solution?

texts:
There are various types of audio material we require in games.
For instance, footsteps - these are very straight forward.
We take some boinking sounds over metal, plastic, concrete and add to our asset library.
Now, in a good game, based on player models locomotion, once foot collides with surface, we play the sound - just from start to end, let it complete. We might lower the volume, and/or fade it out in case we need it to be more silent (like, when we didn't make a full step).
In a little lesser game, we could simply play the sound once every n ticks of walk.
The result in both cases add the depth to the game that is required to make the impression that the player is really walking.
Now, what I have problems with, is, grasping the idea behind continuous and speed affected sounds.
Continuous
With continuous sounds I think of Rocket Launcher's rocket propulsion, Dash abilities sound feedback and such.
You might ask, what's so different for those vs. footsteps? Well, I see two possible solutions:

A very long, continuous sound that is faded out / cut off whenever the rocket explodes, or the dash ends.
A very short, precisely cut out sound fragment, that can be looped for as long as you wish (this could possibly be enhanced, by once in a while nipping in or overlaying another short with different tone or what not).

And I think some of you might have something else up your sleeve.
Speed affected
With speed affected effects I think of engine sounds, like those we hear in Need for Speed franchise and such.
With this, the only solution I have in mind is smart overlay of multiple set of sounds with different lengths.

For both, the continuous and speed affected I have left out real-time software intervention, which I think is rarely applied due to more consumed CPU cycles, though, I may be wrong.
And so, the question is:
What is the industries de-facto solution to create and manipulate such effects?


texts: Unity 2D, how to turn a bool true, after a set amount of time?

texts:
I have an enemy working to damage the player when they stay in collision for too long, at the moment, the enemy will attack about 30 times per second, however I want there to be a delay between each enemy attack, here is my current code:

void OnCollisionStay2D(Collision2D col){

    if (col.collider.CompareTag ("Player") && canAttack == true) {
        player.Damage (enemyDamage);
        canAttack = false;
        //wait 3 seconds or so
        canAttack = true;
    }
}


texts:
I would like to know what is the best way to implement collision avoidance and eventually pathfinding in a LibGDX 2D top view game. Think of "Binding of Isaac".

I use a sort of tilemap to place the obstacles (squares), taken from an ASCII map, but I'd prefer to keep the movements free from it. (Enemies shouldn't move from tile to tile but freely)

Since the target is mobile I can't use heavy algorithms.

I'm not particularly concearned about enemies getting stuck on weird shapes (such as 'U') since it kind of makes sense (they are white globules, not particularly smart :P) but I still want them to be a challenge.

I've taken into consideration Steering Behaviors and the LibGDX-AI framework but I can't find good documentation, I can aswell code it by myself in case.

ANOTHER QUESTION Just to know, which kind of algorithm is used in the Binding of Isaac? It perfectly suits my needs


texts: More loosely coupled way to design this attack and target concept?

texts:
In my 2d game in unity and c sharp, my friendly units are squares. Each square has a grid on it. Each cell of the grid can have one enemy attached to it at a time.
This means that my enemy's targets are not just the friendly game object, but the cell as well. Because of this, I've created a Target class for this (just contains a gameobject and cell). Enemies carry their Target reference so they know where to move to and who to attack.
However, my friendlies do not need the cell to target an enemy. Enemies are small and don't have grids on them. I cannot figure out a nice way to make this polymorphic(?) Target concept work without doing checks for "if cell is not null" in all of my targeting code.
For example, code in my behavior tree for checks like "HasTarget" are tightly coupled to check for existence of a gameobject and cell. It just feels wrong. Am I stuck using custom checks and code for an enemy vs friendly target?
I tried interfaces but they require the same return types. That differs depending on if they are an enemy or friendly. Something like unit.Itargettable.GetTarget() won't work.
Help!


texts:
I'm a brand new unity developer and I watched a few tutorials and then found a game on the Asset Store to provide a nice base for my game. However the setup, especially with multiple scenes is quite different than the tutorials I watched and I can't figure out what is happening. Here is my Scene view from the main menu:

When I click on Main Camera the tiny little thing with the green outline in the corner is highlighted.

Now if I click play, that whole menu fits in the screen, even though the Main Camera is apparently tiny? Then, while playing, I click back to scene view I see this:

It shows the camera as being empty, even though in Game View I can see/interact with the menu.

When I swap to my Scene 1, which is the game view, it is the exact opposite. This is what I see in Scene View while the game is playing:

Note the game running in the preview in the corner. Those tiny circles are the same circles on the main menu, how does the same asset fit in what appears to be two wildly different sizes?

So I ask, what is the different between the two scenes. One appears in the preview while one doesn't. One fills in the huge canvas while the other apparently fits in the tiny camera. What am I missing?


texts: How do I find an accurate current speed of a navmesh agent?

texts:
So I have a blendtree of an idle/walk/run animation of a character (the navmesh agent). I want to use a normalised float of the speed of the navmesh agent to control the blend of the animation cycles. Currently I use this:

void FixedUpdate ()
{
    speed = (transform.position - lastPosition).magnitude;
    lastPosition = transform.position;

    print(speed);
}

However the result is fluctuating all over the place and the animations blends look crap. How do I find a more accurate speed of the navmesh agent?


texts:
I am looking for someone to point me in the right direction. I am working in libgdx.  I have a game where a player will approach an object on a map and then interact with it. On interaction a new screen should come up, that then has separate interaction.

Think, lockpicking. if you walk to a door, a minigame would popup with the lock on the screen.  All background art and action halts while this happens.

I was considering using an Object that triggers a Looped event that you can't escape until the condition is met EG:  while(!Finished){lockpick()} then creating a render() inside lockpick()... is this a terrible idea? Should I just dump out to a different screen, and reload my game screen from saved settings?  I really don't know the best way to handle this...


texts: Multiple inputs for Google Cardboard on iOS and Android?

texts: So far I am having a problem with having only a singular input mechanism (the magnetic trigger) for Google Cardboard games.  Are there any other options to augment this in order to have at least two or three input "buttons" or triggers for a Cardboard app or are we stuck with one?


texts: Workflow or 'Shading Mode' for Aligning gameObject in a Scene?

texts:
I'm aligning and placing gameObjects in a Unity scene. I have difficulty seeing the vertices and objects because the scene supposed to be dark (my workaround is to increase ambient lighting temporarily).

Is there any workflow or 'Shading Mode' that artists use specifically for placing and aligning gameObjects in a scene?


texts:
This is similar to Host Migration (P2P) with RTMFP and AS3
I have a webRTC chat room, initially used Twilio and switching to skyway, the situation is that I have a bunch of peers with data broadcast and there is a firebase datastore with the game state.
I want to elect a host and deal with the host dropping. Currently all the peers just running the same code, so I was thinking I could have the one with the lowest uid propose being the host and then get accepted.
How can I make this robust to race conditions?


texts: How can I center an arbitrary string over a sprite?

texts:
Eyesore:

The problem is, the text should be exactly centered over the player, I want something like this:

My code to draw username above the player is:

g.drawString(username,(int) playerX,(int) playerY);

I can just do playerX-(some number of pixels), but this won't work all the time, because if the player makes his name something that has fewer characters, it will not be centered any more.

How can I make the user-provided String 'username' always be centered above the player sprite?


texts: How can I add a visual grid in the game state?

texts:
Much like Unity's built in grid feature used by the scene editor, what is the most efficient way to implement a similar grid into my actual gamestate?

I know unity has the Grid/Tilemap components, but this is mostly an aesthetic task, and I'm not sure if that is the best route.

Thinking about pulling the trigger on the Vectrosity asset. I am curious if there is a better alternative or if I should script something custom?


texts: Different camera movement methods in a 2d- side-scrolling game that makes it fun

texts:
Possible reference to this question, but I want specific answers pertaining to Side-scrollers.
IMO, side-scrollers can be classified as

Player doesn't move, the background graphics move to fake player movement.
Player moves also background moves, but background movement is dependent on the (x,y) movement of the player > I find this more appealing
Player can't move, the background
moves at a fast speed. Depending
upon the obstacles coming along with
the background the player has to
perform actions like jumping,
ducking, charging, etc...

I would like to know what all other things can be added to the gameplay so that the above mentioned 3 side-scroller categories can be made more addicting.Please mention the category of the side-scroller in your reply.
Edit Modified the question title to reflect what I actually want


texts: What is the logic beyond cube collisions?

texts:
I am trying to simulate a colliding of two cubes , I actually tried and read a lot for many days but i did not get the idea beyond it,I know how to detect when they collide.

Maybe my question is divided for many aspects, How to detect rotation and movement of these cubes after colliding , What is status of two cubes would be ?

Sorry if was not clear or dumb, I would thankful if you could help


texts: How can a BabylonJS FreeCamera be rotated from code?

texts:
Say I have a FreeCamera in a BabylonJS 3D world. How could I rotate that camera from program code? Or, more specifically, how might I bind camera rotation (not movement, which I know how to bind to WASD) to the arrow keys so that gamers without a mouse would not find it too troublesome to use? Is this even possible?

Thanks in advance!


texts: Trigger an action only once when a condition is met, not every frame after that

texts:
I want to avoid check if a particular function is returning true, and perform an action (Set Active) once it does return true for the first time.

Currently my code looks like this:

Update() {
    if ( IsTaskCompleted() ) {
        object.SetActive( true );
    }
}

SetActive gets called every frame after the task is completed. How can I avoid this, and call SetActive only once?


texts: Realistically, how long would it take for 1 person to create a 2D isometric RPG?

texts:
Something I have been looking into for a while is developing my own PC game. I'm very into CRPGs like Fallout 1 and 2, UnderRail, Wasteland 2, etc. I have long desired to create my own game like this, with an emphasis on plot.

While I don't have any experience in development, I use several (mostly proprietary) programming languages in my job, and have a natural aptitude for learning syntax etc. I have taken a few tutorials in Unity and Godot but generally I prefer to feel my way through software myself (tutorials rarely give you enough 'why and how') or reverse engineer an existing product.

I plan for the game to be quite minimal on the asset front, at least to begin with. I've done some basic 3d modelling and mapping (a long time ago, in Source engine - I built my school!)

My question is, if I decide to dedicate the time to this, how long does it generally take for one person to create a game like UnderRail or Darklands? I'd like to know if it's a doable project or a laughable pipe dream for an inexperienced one-man enthusiast!


texts: Unable to Execute code in (what i expect to be) the correct order

texts:
I have become completely stummped on this.   I have a login screen i have created,  i have everything working except 1 thing.   When i click "login"  i want to hide the Login screen object (wm.LoginSWindowHide()) below. and show a small window that shows "Authenticating",  then change that text when done.

my code is below the ActionAuthentication method is called on click of the button method.   The outcome i am seeing is the Rest call being done successfully then the authenticating window popup. even though i have specifically done it the other way around (change the windows,  then make the call)

public void ActionAuthentication()
    {
        wm.AuthenticatingWindowShow();  //runs after DoAuth()
        wm.LoginWindowHide(); //runs after DoAuth()

       DoAuth();
    }

public void DoAuth()
{
    loginAPI.wwwData = null;
    loginAPI.Authenticate(UserNameInput.text, PasswordInput.text);
    //this sets wwwData to the WWW result within the class.  which is why i can call
    //it later on and why i reset it to null before calling it (Clear the variable
    //in case they failed a previous login)

    hasLoginBeenAttempted = true;
    PostAuth();

}

public void PostAuth()
{

        if (loginAPI.wwwData.isDone)
        {

         //Exeucte my code.... this is currently successful but runs before updating the windows.

        }
    }
}

i have tried using co routines to do this as i suspect it's running my code and blocking Update from occurring, but i get exactly the same result.

public void ActionAuthentication()
{
    wm.AuthenticatingWindowShow();
    wm.LoginWindowHide();
    StartCoroutine("DoAuth");

}

IEnumerator DoAuth()
{
    loginAPI.wwwData = null;
    loginAPI.Authenticate(UserNameInput.text, PasswordInput.text);
    yield return new WaitForRest(loginAPI);

}

public class WaitForRest : CustomYieldInstruction
{

    private bool isDone = false;

   public override bool keepWaiting
    {
        get
        {
            return isDone;
        }
    }

    public WaitForRest(API loginAPI)
    {
        if(loginAPI.wwwData.isDone)
        {
            isDone = true;
        }
    }
}

In case it helps,  my API class contains the following code.

public WWW wwwData;

public API()
{
    wwwData = null;
}

public string Authenticate(string UserName, string Password)
{

    AuthData authData = new AuthData(UserName, Password);

    string body = JsonConvert.SerializeObject(authData);
    string url = "http://RandomURL/api/aPath/Authorise";

    byte[] postBody = Encoding.ASCII.GetBytes(body.ToCharArray());

    wwwData = DoPost(url, postBody);

    if (wwwData.error != null)
    {
        return wwwData.error;
    }
    else
    {
        return wwwData.text;
    }

}

public WWW DoPost(string url, byte[] requestBody)
{

    Dictionary<string, string> headers = new Dictionary<string, string>();
    headers.Add("Content-Type", "application/json");
    headers.Add("Accept", "application/json");

    WWW www = new WWW(url, requestBody, headers);

    return www;

}

I'm not adding the REST API Code because i don't think that's relevant and is successfully returning what i expect. (even to the code above,  i just can't get it to execute in the right order)


texts: How to fix Monogame WP8 Touch Position bug?

texts:
Normally below code will result in X:Infinity, Y:Infinity

TouchCollection touchState = TouchPanel.GetState();

foreach (TouchLocation t in touchState)
{
    if (t.State == TouchLocationState.Pressed)
    {
        vb.ButtonTouched((int)t.Position.X, (int)t.Position.Y);
    }
}

Then, I followed this https://github.com/mono/MonoGame/issues/1046 and added below code at the first line in update method. (I still don't know how it's worked, but it fixed the problem)

if (_firstUpdate)
{
    typeof(Microsoft.Xna.Framework.Input.Touch.TouchPanel).GetField("_touchScale",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).SetValue(null, Vector2.One);
    _firstUpdate = false;
}

And then, when I randomly testing something, there are several area that won't read the user touch.

The tile with the purple dude is the area which won't receive user input (It don't even detect "Pressed", the TouchCollection.Count = 0)

Any idea how to fix this?

UPDATE 1 : The second attempt in recompiling

The difference is weird. Dunno why the consistent clickable area is just 2/3 area to the left

UPDATE 2 :
After trying to rotate to landscape and back to portrait to randomly testing, then the outcome become :


texts: Metaballs created through raycasting in fragment shader - billboards are still recognizable

texts:
Good day everyone,

I'm currently programming a fluid simulation through use of metaballs and I have a very specific problem/question.

The steps I use for metaball simulation:
1. Simulate particles' positions
2. Create billboards that always face the camera with the particles' positions at its center
3. Cast a ray from camera to every fragment/pixel and determine the value of every particles' contribution along the ray.

Currently, I have nice looking metaballs with lighting, however, when you look closely you can see the edges of a billboard that is infront of another metaball because the colors are slightly off. The fragments that fail the raycasting test get discarded, but they are obviously still somehow interfering and I just don't know how or why.

Want I want to know, because I have thought about it and didn't come to a conclusion: since the actual fragments of the billboards where there is no implicit surface are discarded, that means that not the color value of the "obstructing" discarded billboard gets changed, but instead that of the actual goal billboard.
where are possible points of conflicts that may create this behaviour?

Thanks in advance!

EDIT:
I think I am wrong about my earlier assumption: the raycast used to determine the implicit surface most likely hits a metaball BEHIND the billboard, so it actually doesn't get discarded... it then takes the normal of the actual intersection, but uses the light direction vector that is made by using the fragment's position, not the actual intersection. So, my guess is that I need a better condition to let the raycast know it didn't hit anything instead of continuing and hitting a ball that is a little further away.


texts: Preloading for level transitions in a tile-based game?

texts:
I am developing a 2D Metroidvania which consists of a series of interconnected levels. When my player gets near a portal which can take him to a new map, I want to pre-load the next map so that there is a seamless transition when he actually enters the portal.

Here is some background about the structure of my code.

Each level is represented by a Tiled TMX file in which I have specified where various objects of different sprite classes spawn (for example, enemies, pickups, levers, etc.). When starting a new game, loading a saved game, or changing a level, my game loop runs through the appropriate TMX file and generates all the objects in that level.

For example, here is a simplified version of my new_game() method.

level = "level_1.tmx"

def new_game(self):
    Globals.scene = "game"

    # create groups
    self.all_sprites = pg.sprite.Group()
    self.walls = pg.sprite.Group()

    # load map and spawn objects
    self.map = TiledMap(path.join(self.map_folder, level))
    self.map_name = level
    self.map_img = self.map.make_map()
    self.map_rect = self.map_img.get_rect()

    # spawn objects
    for tile_object in self.map.objects:
        if tile_object.name == 'player':
           Player(self, tile_object.x, tile_object.y)
        if tile_object.name == 'wall':
            Obstacle(self, tile_object.x, tile_object.y, tile_object.width, tile_object.height)

I handle level changes like this: If the Player object intersects a Portal object, a change_map() method is called which loads a new map (the one associated with the intersected portal) and positions the player at the appropriate position on the new map. The change_map() method looks very similar to the new_game() method above, except that it empties all the sprite groups and hangs on to the player object for repositioning on the new map.

I want to restructure my code so that when the player gets near a portal object (say, within 640 pixels), the map associated with the portal begins to load. This way, when the player enters the portal, the map will load instantly.

I was thinking that I could check to see if the player is near a portal in my game's update() method. If he is, I could call a preload_map() method. But I am unsure how this function should look and how to transition to the new map when the player enters the portal. In order to avoid a stutter when the new map loads, do I need to learn about multiple threads? Maybe I should simply load all the new map images and sprites into their own variables (suffix them with "temp" or something) and then, when my player enters the portal, I can effectuate transition with lines like self.map_img = self.map_img_temp and self.all_sprites = self.all_sprites_temp.

So my question is: Given the structure of my code, how can I use pre-loading to achieve seamless map transitions?

Here is a similar question where the poster does not specify enough information about the structure of their code.


texts:
I just started using Slick2D and learned how simple it is to load in a tilemap and display it. I tried atleast a dozen different tmx files from numerous examples to see if it was the actual file that was corrupted. Everytime I get this error:

Exception in thread "main" java.lang.RuntimeException: Resource not found: data/maps/desert.tmx
    at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
    at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:101)
    at game.Game.init(Game.java:17)
    at game.Tunneler.initStatesList(Tunneler.java:37)
    at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
    at game.Tunneler.main(Tunneler.java:29)

Here is my Game class:

package game;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.tiled.TiledMap;

public class Game extends BasicGameState{
    private int stateID = -1;
    private TiledMap map = null;

    public Game(int stateID){
        this.stateID = stateID;
    }
    public void init(GameContainer container, StateBasedGame game) throws SlickException{
        map = new TiledMap("data/maps/desert.tmx","maps");//ERROR
    }
    public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException{
        //map.render(0,0);
    }
    public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException{
    }

    public int getID(){return stateID;}
}

I've tried to see if anyone else has had similar problems but haven't turned up anything. I am able to load other files, so I don't believe it's a compiler issue. My menu class can load images and display them just fine. Also, the filepath is correct.

Please let me know if you have any pointers that might help me sort this out.


texts: Wrong object is being detected on OnMouseUpAsButton

texts: In my 2d game project I have an object A moving above map. Both object and map have colliders (circle collider and polygon collider respectively), as well as actions to be performed on OnMouseUpAsButton. Objects are displayer properly in the game, however, when I click on the object it usually detects map (usually as in sometimes it detects the object if I press in the very centre of the object). How to ensure that my objects of type A are always checked first for MouceUp?


texts: Decorating a 3D procedurally generated interior

texts:
There are lots of materials on how to procedurally generate levels for a videogame, but they mostly focus on obtaining the layout of the level and exist in a vacuum where having generated said layout means you have reached the end goal. For 3D games, however, it is rarely ideal to just have empty rooms connected by similarly empty corridors - you want to have some kinds of props and decorations all over the level to make it more appealing.
What approaches are there to reasonably decorate a procedurally generated level?
Before you can even begin to place props in a room you need to know what type of room it is, because what props are acceptable candidates for placement depends on the room(bookcases are welcome in libraries, but not in bathrooms). The problem with any generic level generation algorithm is that you end up with a bunch of nondescript rooms, so you will need to have an algorithm that somehow identifies and assigns room types by their properties.
The problem grows more complex when you realize that some props have more placement constraints - chandeliers can't be placed randomly as we expect them to be placed according to some spatial patterns.


texts: How to estimate number or packets required to sent per second in a multiplayer lockstep RTS game?

texts:
Considered a typical lockstep implementation, what's a solid rate to send packets at for UDP protocol that games can start with in the beginning?

If anyone has experience in this field, I'd like to know the general optimal packet sends per second for a lockstep RTS game.


texts: How to update rule tile (brush) from Unity's 2D grid tile map palette?

texts:
I have created a Palette in Unity and created a map using that rule

Now, I want to replace the current rule with another one, without having to draw everything once more. I tried to drag and drop the new rule on the same position in the palette, but the drawn map was not updated.

I am a little anxious about creating a (large) map unless I know of a way to update a brush without having to redraw everything.


texts: My game is dull; how would you make it more exciting?

texts: The game is Darts for the iPhone. It's OK but it's more like a simulation than anything I'd ever claim to be overtly "fun". I am looking for some ideas to spice up the gameplay. What are your thoughts?


texts: database design for a game like "Empires and Alies" in facebook

texts:
recently im trying to create a isometric game for facebook pretty much like Empires and Allies in facebook , i have used as3isolib to create the game , the user interactions are almost ready , but im stuck in designing the database for it .

i tried to search online but i could'not find any source or sample db designs for it ,,, i have big problem in design db in the way that can handle the different item types , like , housing , research labs , units , their staus and so on, let's say when we build a house it would have different levels to be completed , or different building has different product , and some item's product is still a product , like military house which produce soldiers ... if any body can guid me or a sample design i'll really appreciate it . Thanks.


texts: Displaying smooth borders given a coarse grid-based map

texts:
I've been messing around with different algorithms trying to make a grid based map look smooth, I have tested with various shader based methods and wrote a few of my own but none of them look right.

A grid based map:

The result I'm trying to achieve

So my question is, are there any algorithms or known methods out there to achieve this?


texts: Best way to find line segment intersection

texts:
I need to find the point of intersection between two line segments in 2D space. I receive them in terms of both coordinates of both lines. Because they are line segments I would also need to know if they actually intersect in the first place.

I can find many ways to do this but I would like to know what method would have the best performance in GLSL.


texts: Unity Ads or Google Ads wich one is better?

texts: I don't know if i can ask this here, but i have a doubt about wich ad advertiser is better, a friend said unity and other said google... I want to know in general wich one is better? If there's one wich is better than both let me know. If i can't ask this here let me know and i delete this question :D thanks


texts: Memory accumulation in monogame. ‘Dispose’ and ‘Unload’ aren’t working

texts:
I'm having a huge problem with memory accumulation in all my games.
This happened after switching from monogame 3.4 to 3.5 so I switched back.
Then recently I went to 3.6(latest release) and started having the same problem again.
I would switch back again but I need 3.6 rather than 3.4 for certain reasons.

I've tried both .Dispose() and .Unload() for the content but it seems to only release a small portion of what was previously loaded.

Here is the code

public void UnloadContent()
        {
            if (overworldContent != null)
            {
                overworldContent.Unload();
            }
        }

I've also done

public void UnloadContent()
        {
            if (overworldContent != null)
            {
                overworldContent.Dispose();
            }
        }

This is a picture of the memory usage from just going in and out of an area just a few times over the course of several minutes.
A player could easily have multiple gigabytes taken up from playing for even just one hour if it goes from 86MB to 235MB in just 2 minutes

I seriously need help.