texts:
I've seen lots of examples of theory about the reason for client-side prediction, but I'm having a hard time converting it into code. I was wondering if someone knows of some specific examples that share some of the code, or can share their knowledge to shed some light into my situation.

I'm trying to run some tests to get a the movement going (smoothly) between multiple clients. I'm using mouse input to initiate movement.

I'm using AS3 and C# on a local Player.IO server. Right now I'm trying to get the Client side working, as I'm only forwarding position info with the client.

I have 2 timers, one is an onEnterFrame and the other is a 100ms Timer, and one on mouseClick listener.

When I click anywhere with a mouse, I update my player class to give it a destination point
On every enterFrame Event for the player, it moves towards the destination point
At every 100ms it sends a message to the server with the position of where it should be in a 100ms.
The distance traveled is calculated by taking the distance (in Pixels) that the player can travel in one second, and dividing it by the framerate for the onEnterFrame handler, and by the update frequency (1/0.100s) for the server update.
For the other Players, the location is interpolated and animated on every frame based on the new location.

Is this the right way of doing it?


texts: Network client-server message exchange and clock synchronization help

texts:
i'm doing a fast paced physics game that is a  table hockey. With two mallets and one puck. The game runs on iphone / ipad and i'm doing the multiplayer part through GameCenter.

This is how the network system works. The client wich stars the match, will be settled as the server and the one that accepts the match request is the client.

The 'server' has the physics running and the response is immediate and the client also has their physics running so it looks smooth between messages exchange. What i do as the server, is that i send to the client my puck velocity and my position and the client adjusts his puck velocity/position related to the server to keep it sync. Otherwise the physics desynchronizes and it screws it up.

When the network latency is good, bellow 100ms the results are pretty good, i got a smooth playable game on the client side and the weird behavior are minimum. The problem happens when the lag is around 150 to 200ms. In that case, happens that my client puck already hitted a edge and inverted direction but it receives a delay message from the server and it backs a bit causing a weird feeling to the ball behavior.

I've readed a few things about it:

Pong Network Example

Click Synchronization Example

Wikipedia on Clock Sync

So, how can i solve this? As far as i've read the best option that i have is to do a clock synchronization on the server/client with a timestamp so that when i get delay messages related to my clock, i just ignore then and let the clients simulation do the job. Do you guys agree with that? And since im sending data unreliable (UDP) i may get delayed messages or messages out of order.

If that is the best approach, how do i implement the clock synchronization. I've read the steps on how to but i didn't quite understand it.

It says that:

Client stamps current local time on a "time request" packet and sends to server.
Upon receipt by server, server stamps server-time and returns
Upon receipt by client, client subtracts current time from sent time and divides by two to compute latency. It subtracts current time from server time to determine client-server time delta and adds in the half-latency to get the correct clock delta. (So far this algothim is very similar to SNTP)
The client repeats steps 1 through 3 five or more times, pausing a few seconds each time. Other traffic may be allowed in the interim, but should be minimized for best results The results of the packet receipts are accumulated and sorted in lowest-latency to highest-latency order. The median latency is determined by picking the mid-point sample from this ordered list.
All samples above approximately 1 standard-deviation from the median are discarded and the remaining samples are averaged using an arithmetic mean.

Following this example i would have this:

Lets pretend the game has loaded and my client time is 0 now, so i send to the server that my time is 0.

The messages takes 150ms to get to the server but the server's clock had already started and is 1 second ahead of the client. When the server get the message the time will be:
1.15 and sends that time to client, are we good?
Lets pretend our lag is constant at 150ms.

Now the client receives the time 1.15 and subtracts current time from sent time and divides by two to compute latency. Wich is: 0.3 - 0 = 0.3/2 -> 150ms.

It subtracts current time from server time to determine client-server time delta and adds in the half-latency to get the correct clock delta:
Client time: 0.3 Server time 1.15
0.3 - 1.15 = .85 + latency(.15) = 1

How is that synchronized? What am i missing?

It's my first time on multiplayer and network experience, so i'm a bit confused.

Thank you.


texts: Unity3D: Multiple OnTriggerEnters are called before the first one could finish and destroy the object

texts:
I'm working on a projectile which explodes when it reaches a destructible object and damages its voxels. (The projectile is a trigger)

But the problem is that I use raycasting in OnTriggerEnter which makes it slow to finish. Which lets multiple OnTriggerEnter to be called before it could be finally destroyed.

I fixed it by having a flag which lets only one call to be executed. But it feels a bit hacky, so I decided to ask you, maybe you have some better solutions.

void OnTriggerEnter(Collider collider)
{
    if (!hit && LayerMask.LayerToName(collider.gameObject.layer) == "Destructible")
    {
        hit = true;
        DoImpact();
        Destroy(gameObject);
    }
}

void DoImpact()
{
    //Do ~1 SphereCast
    RaycastHit[] hits = Physics.SphereCastAll(transform.position, ExplosionRange, transform.forward, 0.0001f, 1 << LayerMask.NameToLayer("Destructible"));
    //Iterate through voxels
    foreach(var hit in hits)
    {
        //the parent object which manages its voxels
        var destructible = FindDestructibleParent(hit.transform);
        //Make some damage to that voxel based on the projectile, the voxel, and some "whole container/parent object properties"
        destructible.TakeDamage(this, hit.transform.gameObject);
    }
}


texts: Need to translate a Rotation Matrix to Rotation y, x, z OpenGL & Jitter for 3D Game

texts:
I am using the Jitter Physics engine which gives a rotation matrix:

M11 M12 M13
M21 M22 M23
M21 M32 M33

And I need it so OpenGL can use it for rotation

GL.Rotate(xr, 1, 0, 0)
GL.Rotate(yr, 0, 1, 0)
GL.Rotate(zr, 0, 0, 1)

Initially I Tried

xr = M11
yr = M22
zr = M33

[1 0 0]
[0 1 0]
[0 0 1]

Which did not work, please help, I have been struggling on this for days :(

Re-Edit

The blocks are stored in text files with Euler angles so it needs to be converted or the rendering engine will simply fail.

I am now using the matrix in the text files.

Example Block

1,1,1                      'Size
0,0,0                      'Position
255,255,255                'Colour
0,0,0,0,0,0,0,0,0          'Rotation Matrix


texts:
I'm doing character control with kinect. I need to mirror the joint orientation because the character faces the player. Somehow by Googling through internet I've done it and everything works very well. But I have little idea about how the math works, here's my code:

//-------------------------------------------------------------------------------------
Ogre::Quaternion JointOrientationCalculator::buildQuaternion(Ogre::Vector3 xAxis, Ogre::Vector3 yAxis, Ogre::Vector3 zAxis)
{
    Ogre::Matrix3 mat;
    if(isMirror)
    {
        mat = Ogre::Matrix3(xAxis.x, yAxis.x, zAxis.x,
                            xAxis.y, yAxis.y, zAxis.y,
                            xAxis.z, yAxis.z, zAxis.z);
        Ogre::Matrix3 flipMat(1, 0,  0,
                              0, 1,  0,
                              0, 0, -1);
        mat = flipMat * mat * flipMat;
    }
    else
    {
        mat = Ogre::Matrix3(xAxis.x, -yAxis.x, zAxis.x,
                           -xAxis.y, yAxis.y, -zAxis.y,
                           xAxis.z,  -yAxis.z, zAxis.z);
    }

    Ogre::Quaternion q;
    q.FromRotationMatrix(mat);

    return q;
}

When I need to mirror/flip it by axes z I calculate mat = flipMat * mat * flipMat;
but I don't understand how this equation works.


texts: Möller-Trumbore false positive result in specific point

texts:
I copied code from this whitepaper and i can't figure out while it gives me false-positive intersections.

Here's problematic values:

Triangle points: (100.0, 100.0, 100.0), (-100.0, 100.0, 100.0), (-100.0, 100.0, 50.0);

Ray origin point: (0.0, 98.0, 50.0);

Ray direction point: (-100.0, 5.88235, 73.5294).

This points gives me an intersection when it shouldn't.

Here's my implemetation:

#include <iostream>
#define EPSILON 0.000001
#define CROSS(dest, v1, v2) \
    dest[0] = v1[1] * v2[2] - v1[2] * v2[1]; \
    dest[1] = v1[2] * v2[0] - v1[0] * v2[2]; \
    dest[2] = v1[0] * v2[1] - v1[1] * v2[0];

#define DOT(v1, v2) (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2])
#define SUB(dest, v1, v2) \
     dest[0] = v1[0] - v2[0]; \
     dest[1] = v1[1] - v2[1]; \
     dest[2] = v1[2] - v2[2];

int intersect_triangle(double orig[3], double dir[3],
                    double vert0[3], double vert1[3], double vert2[3],
                    double *t, double *u, double *v) {
    double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
    double det, inv_det;

    // find vectors for two edges sharing vert
    SUB(edge1, vert1, vert0);
    SUB(edge2, vert2, vert0);

    // begin calculating determinant - also used to calculate U parameter
    CROSS(pvec, dir, edge2);

    // if determinant is near zero, ray lies in plane of triangle
    det = DOT(edge1, pvec);

    if (det > -EPSILON && det < EPSILON)
        return 0;
    inv_det = 1.0 / det;

    // calculate distance from vert to ray origin
    SUB(tvec, orig, vert0);

    // calculate U parameter and test bounds
    *u = DOT(tvec, pvec) * inv_det;
    if (*u < 0.0 || *u > 1.0)
        return 0;
    //prepare to test V parameter
    CROSS(qvec, tvec, edge1);
    //calculate V parameter and test bounds
    *v = DOT(dir, qvec) * inv_det;
    if (*v < 0.0 || *u + *v > 1.0)
        return 0;
    // calculate t, ray intersects triangle
    *t = DOT(edge2, qvec) * inv_det;

    return 1;
}

int main() {
    double orig[] = {0.0, 98.0, 50.0};
    double dir[] = {-100, 5.88235, 73.5294};

    double vert0[] = {100.0, 100.0, 100.0};
    double vert1[] = {-100.0, 100.0, 100.0};
    double vert2[] = {-100.0, 100.0, 50.0};
    double* u;
    double* v;
    double* t;

    if(intersect_triangle(orig, dir, vert0, vert1, vert2, u, v, t))
    {
        std::cout << "Intersect" << std::endl;
    }
    else
    {
        std::cout << "Doesn't intersect" << std::endl;
    }
    return 0;
}

Another implementation of this algorithm tells me that intersection is in (-34, 100, 75).


texts: How can I respond to mouse events in AS3?

texts:
Background:

Trying to make a simple "drop the ball" game.

The code is located inside the first frame of the timeline. Nothing more is on the stage.

Issue:

Using QuickBox2D I made a simple If statement that drops and object acording the Mouse-x position:

if (MouseEvent.CLICK) {
sim.addCircle({x:mouseX, y:1, radius:0.25, density:5});

I imported the MouseEvent library:

import flash.events.MouseEvent;

Nothing happens if I click, no output errors either.

See it in action:
http://gabrielmeono.com/download/Lucky_Hit_Alpha.swf
http://gabrielmeono.com/download/Lucky_Hit_Alpha.fla

Full Code:

    [SWF(width = 350, height = 600, frameRate = 60)]
import com.actionsnippet.qbox.*;
import flash.events.MouseEvent;

var sim:QuickBox2D = new QuickBox2D(this);
sim.createStageWalls();
//var ball:sim.addCircle({x:mouseX, y:1, radius:0.25, density:5}); //

// make a heavy circle

sim.addCircle({x:3, y:1, radius:0.25, density:5});
sim.addCircle({x:2, y:1, radius:0.25, density:5});
sim.addCircle({x:4, y:1, radius:0.25, density:5});
sim.addCircle({x:5, y:1, radius:0.25, density:5});
sim.addCircle({x:6, y:1, radius:0.25, density:5});
// create a few platforms

sim.addBox({x:3, y:2, width:4, height:0.2, density:0, angle:0.1});
// make 26 dominoes
for (var i:int = 0; i<7; i++){
//End
     sim.addCircle({x:1 + i * 1.5, y:16, radius:0.1, density:0});
     sim.addCircle({x:2 + i * 1.5, y:15, radius:0.1, density:0});

//Mid end

      sim.addCircle({x:0 + i * 2, y:14, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:13, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:12, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:11, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:10, radius:0.1, density:0});

      //Middle Start
     sim.addCircle({x:0 + i * 1.5, y:09, radius:0.1, density:0});
     sim.addCircle({x:1 + i * 1.5, y:08, radius:0.1, density:0});
     sim.addCircle({x:0 + i * 1.5, y:07, radius:0.1, density:0});
     sim.addCircle({x:1 + i * 1.5, y:06, radius:0.1, density:0});
}

if (MouseEvent.CLICK) {
    sim.addCircle({x:mouseX, y:1, radius:0.25, density:5});

sim.start();
/*sim.mouseDrag();*/

    }


texts: How do I make an 8 bit sprite sheet using GIMP or Paint.NET?

texts:
I'm looking to create a sprite sheet for an 8 bit, 2D RPG I'm making. All I need to do at the moment is render in some textures. To do this, I want to make an 8x8 sprite sheet. Now, I am really bad at using anything to do with GIMP or Paint.NET, so I came here for some help.

Are there any ways to create an 8x8 blank sprite sheet using either GIMP or Paint.NET?

I have some other info you might need for whatever reason down here:

I'm using Java to code this game.
I'm following Ryan van Zeben's (DesignsByZephyr) tutorials, and I'm trying to make the same sprite sheet he made in Episode two of his series.
At the moment, I don't have access to Photoshop or anything that requires a lot of money (I'm quite young).
I'm willing to use plugins and/or other free photo-editing programs.
I am using Windows 7 as my OS, and Eclipse Luna as my IDE.


texts: JOGL hardware based shadow mapping - computing the texture matrix

texts:
I am implementing hardware shadow mapping as described here.

I've rendered the scene successfully from the light POV, and loaded the depth buffer of the scene into a texture. This texture has correctly been loaded - I check this by rendering a small thumbnail, as you can see in the screenshot below, upper left corner. The depth of the scene appears to be correct - objects further away are darker, and that are closer to the light are lighter.

However, I run into trouble while rendering the scene from the camera's point of view using the depth texture - the texture on the polygons in the scene is rendered in a weird, nondeterministic fashion, as shown in the screenshot.
I believe I am making an error while computing the texture transformation matrix, but I am unsure where exactly.

Since I have no matrix utilities in JOGL other then the gl[Load|Mult]Matrix procedures, I multiply the matrices using them, like this:

void calcTextureMatrix() {
  glPushMatrix();

  glLoadIdentity();
  glLoadMatrixf(biasmatrix, 0);
  glMultMatrixf(lightprojmatrix, 0);
  glMultMatrixf(lightviewmatrix, 0);
  glGetFloatv(GL_MODELVIEW_MATRIX, shadowtexmatrix, 0);

  glPopMatrix();
}

I obtained these matrices by using the glOrtho and gluLookAt procedures:

  glLoadIdentity()
  val wdt = width / 45
  val hgt = height / 45
  glOrtho(wdt, -wdt, -hgt, hgt, -45.0, 45.0)
  glGetFloatv(GL_MODELVIEW_MATRIX, lightprojmatrix, 0)

  glLoadIdentity()
  glu.gluLookAt(
    xlook + lightpos._1, ylook + lightpos._2, lightpos._3,
    xlook, ylook, 0.0f,
    0.f, 0.f, 1.0f)
  glGetFloatv(GL_MODELVIEW_MATRIX, lightviewmatrix, 0)

My bias matrix is:

float[] biasmatrix = new float[16] {
  0.5f, 0.f, 0.f, 0.f,
  0.f, 0.5f, 0.f, 0.f,
  0.f, 0.f, 0.5f, 0.f,
  0.5f, 0.5f, 0.5f, 1.f
}

After applying the camera projection and view matrices, I do:

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
glTexGenfv(GL_S, GL_EYE_PLANE, shadowtexmatrix, 0)
glEnable(GL_TEXTURE_GEN_S)

for each component.

Does anybody know why the texture is not being rendered correctly?

Thank you.


texts: 2D BoundingBox Collision Detection Problem

texts:
I implemented collision detection into my game (using Bounding Boxes) The character is floating above the blocks instead of standing on them. I know what is happening, but I can't figure out how to calculate how high that space is, so I can change the position.

Here is a picture:


texts: How to go from Texture2DContent to Texture2D in a content processor?

texts:
I'm using reflection to create a manifest of all assets, strongly typed.

It's working fine for my own types: I get the type of the asset, if a processor is ran on it I get the output type. Then I check to see if there's a ContentSerializerRuntimeTypeAttribute applied to the type. If so, then I get the RuntimeType value and do a Type.GetType() to get the type back.

The problem I have is if the type is Texture2DContent (for example) as that doesn't have the ContentSerializerRuntimeTypeAttribute.

How can I go from a Type representing Texture2DContent to a Type representing Texture2D?

I know I can just check for EndsWith("Content") as a last resort, but how to I get the namespace qualified type so I can get my Type object?


texts: Making color of sprite darker or lighter

texts: Is there any way to make a sprite darker or lighter in AndEngine? I dont want to use the alpha thing. Nor I want to loose the texture/design of the image.


texts:
I notice that for several games on Kongregate, the copyright notice either uses the author's handle name (login name), the name of the group that produce it or a domain name.

Are all those valid copyright notices?


texts: Making only one side of a object receive light in Unity

texts:
So I want to achieve a visial asthetic in my game that looks like this

Meaning I dont want the outer parts of my dungeon walls to be affected by light.
Now I know this is posible if the object itslef is created with 2 materials that way I can make the back material solid black. But I was wondering if there is a easy way to achieve this with a shader.


texts: Why is the size of glm's vec3 struct 12 bytes?

texts:
When trying to determine the size of glm::vec3 (from GLM math library) by using the size of operator like so:

sizeof(glm::vec3)

I get 12 returned. When I look at the definition of a vec3 struct I see this:

    template <typename T, precision P = defaultp>
    struct tvec3
    {
        // -- Implementation detail --

        typedef tvec3<T, P> type;
        typedef tvec3<bool, P> bool_type;
        typedef T value_type;

#       ifdef GLM_META_PROG_HELPERS
            static GLM_RELAXED_CONSTEXPR length_t components = 3;
            static GLM_RELAXED_CONSTEXPR precision prec = P;
#       endif//GLM_META_PROG_HELPERS

        // -- Data --

#       if GLM_HAS_ANONYMOUS_UNION
            union
            {
                struct{ T x, y, z; };
                struct{ T r, g, b; };
                struct{ T s, t, p; };

#               ifdef GLM_SWIZZLE
                    _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, x, y, z)
                    _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b)
                    _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p)
                    _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, x, y, z)
                    _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, r, g, b)
                    _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, s, t, p)
                    _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, x, y, z)
                    _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b)
                    _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p)
#               endif//GLM_SWIZZLE
            };

         //other code......
       }

For which I see three structs, each with three member variables of templated type T, which in GLM defaults to float type. My question is why is the sizeof() operator returning 12 bytes as the size of glm::vec3 when it looks like it should be 36 bytes:

3 structs, with 3 float members each = 3*3*4(number of bytes in a float) = 36.


texts: Best practice where to store Projectile Damage amounts?

texts:
I have a projectile and an enemy, both with colliders. On the projectile script, I'm destroying the projectile OnTriggerEnter:
public class bulletBehavior : MonoBehaviour
{
    private Rigidbody rb;
    public float smallGunSpeed = 500f;

    void Start()
    {
        rb = this.GetComponent<Rigidbody>();
        rb.AddForce(transform.forward * smallGunSpeed);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            Destroy(this.gameObject);
        }
    }
}

On the Enemy Script I'm handling the health and the damage from the different projectiles using tags.  Is this the right way to do it? I would much rather attach the damage amount to the projectile but I'm not sure how to "Transfer" the damage value to the NPC script from the projectile script?  Storing them on the NPC script seems incredibly inefficient.
public class NPCscript : MonoBehaviour
{
    public int maxHealth = 300;
    public int currentHealth;
    public HealthBar healthBar;
    private GameObject enemy;

    void Start()
    {
        currentHealth = maxHealth;
        healthBar.SetMaxHealth(maxHealth);

        StartCoroutine(AutoHeal());
    }

    void Update()
    {
        if (currentHealth <= 0)
        {
            Destroy(this.gameObject);
        }
    }

    void TakeDamage(int damage)
    {
        currentHealth -= damage;
        healthBar.SetHealth(currentHealth);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Bullet")
        {
            TakeDamage(10);
        }
        else if (other.tag == "Grenade")
        {
            TakeDamage(75);
        }
    }
}
```


texts: Can I use a list sorted by Morton Code for broad phase collision detection?

texts:
Until now I used a list of objects sorted by a single axis for limiting the amount of objects that collisions are checked against.

The idea is simple: if the x coordinate of two objects differs by more than their width it is plain impossible that they collide. So if I want to know all possible objects inside a specific rectangle I just need to check those that are inside the indices of the smallest possible and the biggest possible x value.

Now recently I have learned about Morton Code as a way of reducing multiple axes into a single value that preserves locality. However the implications for it aren't 100% clear to me.

Can I determine something like "all objects with a morton code smaller than varA or bigger than varB can't possibly be inside rectangle A"? If so how do I determine these values?


texts: How can i create sprite sheet from 3d model (3D studio max)

texts:
I built simple 3D model of a car, with simple animation in which it's wheels are turning.

Now i want to create a sprite sheet, the only way i know how to do it, is to render manually 20 frames from the from, then combine them to a strip manually, then rotate it by 10 degrees, render 20 frames of animation again and combine them to a strip...

Is there a way to do it automatically ?
With out rotating the scene manually and render it and combining .. it's a lot of work, takes more time then the modelling itself...

Thanks


texts: Is the rendering of distorted point clouds more complex?

texts:
I have two point clouds of n points:

A dense ball-shape point cloud with many points inside
A spherical point cloud with points on its surface.

Is there (really) any difference between rendering (complexity/time) of these two point clouds?

How does the distortion of points affect the complexity of the rasterisation process?


texts: Get different result on different devices (same resolution) after setVelocity

texts:
I'm dying with physics , i've tried to use setVelocity however i got slightly different value from different devices.

I've tested on iPhone 5 (on simulator)
and iPhone 6 (real device)
The Director::getInstance()->getOpenGLView()->getFrameSize() returns both devices is 640x1136 pixels

But i see they have different result after the animation , its about 2-5 pixels.
I really don't know why.

I'm making a multiple player game so i need exactly same coordinates of objects on every devices.
Does cocos physics return randomly result?

After deep digging, i realize that even i set specific velocity for one object in same device will return different result.

So i don't think this is about the devices, Chipmunk returns different result with the same input parameter!


texts: Any significant performance cost to using BlendState.Premultiplied?

texts:
Normally I guess you'd use BlendState.AlphaBlend because normally when you load your textures through the pipeline they're already premultiplied. However, if you're loading textures at runtime from PNGs or some such, you have to loop through the pixels and premultiply them, which can take a long time if you've got a lot of textures to load.

So it looks (haven't tried it) like using BlendState.NonPremultiplied instead of BlendState.AlphaBlend should handle non-premultiplied textures and produce the same visual result, without all the startup costs. I have to wonder if there's a non-obvious cost to doing this, like a huge drop in performance or something. Anyone know?


texts:
I'm back with another question that may be really simple.

I've a texture drawn on my spritebatch and I'm making it move up or down (y-axis only) with Libgdx's Input Handler: touchDown and touchUp.

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    myWhale.touchDownY = screenY;
    myWhale.isTouched = true;
    return true;
}

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    myWhale.isTouched = false;
    return false;
}

myWhale is an object from Whale Class where I move my texture position:

public void update(float delta) {
    this.delta = delta;
    if(isTouched){
        dragWhale();
    }
}

public void dragWhale() {
    if(Gdx.input.getY(0) - touchDownY < 0){
        if(Gdx.input.getY(0)<position.y+height/2){
            position.y = position.y - velocidad*delta;
        }
    }
    else{
        if(Gdx.input.getY(0)>position.y+height/2){
            position.y = position.y + velocidad*delta;
        }
    }
}

So the object moves to the center of the position where the person is pressing his/her finger and most of the time it works fine but the object seems to take about half a second to move up or down and sometimes when I press my finger it wont move.

Maybe there's another simplier way to do this. I'd highly appreciate if someone points me on the right direction.


texts:
Impressive trailers for your game can really help show players how awesome your game is, but I'm having trouble finding tips that describe how to create a great trailer.  I would like to learn about the best way to decide trailer length, structure, music/sound, and content.  Basically, what parts of my game do I show in a trailer, how should the scenes be organized, and how would you do the sound?

Any advice on things to avoid would be great as well; for example, I read that splicing some video, switching to a screen with text, switching back to video, etc., probably isn't the best way to do it.  Thanks!


texts: Responding to mouse input on game objects

texts: I'm trying to make a simple button in unity using a cube. My plan is for when the cube is highlighted that it will move towards the camera and be highlighted in a specific color and then when it is clicked it will move back and change to a different color. I would also like to know how to make events happen when clicking an object.


texts: How to set tranparency for one image only in openGL ES in Android?

texts:
I code game on Android where I have several sprites.

My goal is to set gl.glColor4f(1f, 1f, 1f, 0.2f) a.e. transparency only for specific image. (I don't like Photoshop).

In my case its  image that represents a "number" and moves up and begin to be transparent till disappear at all.

However, when I use it, I see that all sprite images are transparent or not what I want.

What I do wrong? Does my code seem right? (i'm junior in OPenGL)

Here is relevant part of code:

Renderer

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig confid) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glShadeModel(GL10.GL_SMOOTH);
    //gl.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
    //gl.glClearColor(0,0,0,0);
    gl.glClearDepthf(1.0f);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    gl.glEnable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,                /*GL10.GL_REPLACE*/ GL10.GL_MODULATE);
}

[text sprite image]

gl.glPushMatrix();
try {
    float transx = ...'
    float transy = ...;

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

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

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

    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);

    gl.glColor4f(1f, 1f, 1f, 0.2f); // <---- alpha 0.2f
} catch (NullPointerException e) {
   Log.e("Fess", e.getMessage());
}
gl.glPopMatrix();

[other sprite images with alpha 1f]

gl.glPushMatrix();
try {
    float transx = ...'
    float transy = ...;

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

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

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

    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);

    gl.glColor4f(1f, 1f, 1f, 1f);
} catch (NullPointerException e) {
   Log.e("Fess", e.getMessage());
}
gl.glPopMatrix();

and this is how im load them:

public void loadTextures(GL10 gl, Context context) {
    Log.e(LOG_TAG, "ExplosionSprite :: loadTextures");

    mFrame = 0;

    InputStream is;
    Bitmap bitmap;
    is = context.getResources().openRawResource(DRAW_SOURCE);

    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();

}

Thank you


texts: Transform translation relative to world space

texts:
What is common algorithm for translating a transform matrix relative to world space axis?
E.g. Matrix M is representing some local space.
When I want to translate M relative to it's own local axis, I just do it like
        M.Translate(translationVector);

But what should I do when I want to translate same matrix but relatively to world space axis?


texts:
This web player is for the Unreal Development Kit, and works very well without a browser plugin. I'm wondering how it is built.
How do I create a web player for a game engine written in C++?


texts: Running Unity development build in Android emulator without signing

texts:
I am working on project with a friend who uses Windows while I am using Ubuntu. We are using Unity collaborate and it's going fine except when we want to build.

The keystore is in his filesystem, D:/Programs -Work/Game Dev/Keystore/user.keystore and I can't replicate his path.

Also, when I try to do a development build and run, it fails because Unity says the apk isn't signed, contrary to this article which says that development builds do not need to be signed.

So this leads to two questions:

Is there any way to build from both devices?
Is there any way to emulate the game on android emulator?


texts:
I'm developing a game and
I'd like to make model * pos4 calc (that's usual in glsl vertex shader) in cpu instead of doing it in gpu. I'm using LWJGL and for the math impl I use JOML. Anyone know how to multiply a vec4 with a matrix 4x4? It would be nice showing me the JOML code but also the way to mul the mat values with the vec4 values is fine!


texts: How to produce a texture to represent a vector field

texts:
I would like to be able to produce a texture that essentially represents a 2D vector field (eg red represents vector {1, 0}.

What I would like is to draw a path and the vector at the point on the path should be tangential to the path. Ideally, I would like the path to be thick (i.e. the points on the path are the tangent colour and then all points within r perpendicular to the path at that point are a smaller version of that vector). All other points would have the zero vector.

So for example, if I had a circle path, the vectors would push a particle around the circle.

How would I easily produce this texture? I am currently considering writing a tool that parses a SVG file and produces a bitmap that can be used but I'm wondering if there are existing tools that do this already.

NB: I tried to tag this with "vector-fields" as I believe this could be a common theme (since UE4  supports using them with particles), but don't have enough rep to create the tag.


texts: How to set max string length on my EditorGUI.TextArea?

texts: How to set max string length on a EditorGUI.TextArea? A GUILayout.TextArea has a maxLength property but sadly the editor-version doesn't.


texts:
So, given a sun sprite set at the horizon (x = 0, y = worldheight/2) I'm trying to devise a function to make the sun rise, then fall.

The best way to do this would be the sin function, but I have no idea how to use it.

if using y = sin(x), then x would have to range between 0 and pi for a full curve, while having a constant velocity for X.

Any thoughts or suggestions?

Edit: Thanks guys!


texts:
In my Minecraft-clone style game, blocks are textured with a border that is lighter then the block color. See picture below:

To achieve this effect without the textures being blurry I use this code:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

Without setting the MAG_FILTER to GL_NEAREST, it looks like this:

This is ugly and blurry. The upper picture (with GL_NEAREST enabled) is obviously superior. My issue is that the edges in the upper picture are aliased (it is more obvious if you view the photo full-size.)

Is there any way to anti-alias textures? It does not look very good if the borders are aliased like this. Alternatively, is there any way to get rid of the aliasing on the borders?

Thank you for any help!


texts:
I have problem when trying to use the uiskin.atlas from github/libgdx. I've downloaded(cloned) it from libgdx.git but it just doesnt work.

I get the following error:
Com.badlogic.gdx.utils.GdxRuntimeException: Error reading pack file: data/uiskin.atlas

And further down in the catlog it says:
Caused by: java.lang.IllegalArgumentException: 256,128 is not a constant in com.badlogic.gdx.graphics.Pixmap$Format

What does that mean?
Anyone knows how to solve it?

Im using the line
skin = new Skin(Gdx.files.internal("data/uiskin.json"));

Im at work at the moment so can't give more info than this. The error happens both in Eclipse and in AIDE on my phone.


texts:
So I have been learning HTML5 canvas recently and ran into a bit of a snag. I created a proof of concept that builds a block based 2d map that you can move a character inside of using arrow keys. This works well because everything is free moving (character moves 1 pixel per frame, so the movement is fluid and looks good).

I am trying to fork off of this code to create another concept that forces grid based movement (like in a typical roguelike). I have updated my movement code to move in chunks equal to tile size.. but the issue is that the refresh rate is so fast that it just seems like the character is moving at super speed.

Here is a snippet of my code that handles animations:

function gameLoop() {
        ctx.clearRect(player.x,player.y,PLAYER_SIZE,PLAYER_SIZE);
        getInput();
        ctx.fillStyle = '#000000';
        player.draw(ctx);
        window.requestAnimationFrame(gameLoop);
}

Is using requestAnimationFrame() for this sort of movement not a good idea? Is it better to just setInterval() for this sort of thing? I found a article via Google that talks about using variables for time, delta, fps, etc to limit the framerate... but Im not sure I understand how to do that in conjunction with requestAnimationFrame(). Should I somehow hold my gameLoop() from hitting requestAnimationFrame() until some time interval is hit? That seems like it would just be a waste because I would need to force a loop of some kind... doesnt seem too elegant


texts:
I have an area say a x b of cells. actually I render every single cell in this matrix with a tile representing floor, wall, etc. What I'm trying to achieve it to replace this tiling system with a unique tile covering the whole a x b area.

I tried to play with creating a single GameObject and then adding a SpriteRenderer component with the base idea to stick in a sprite with desired size so that the image (whatever it is) gets stretched to fit it but apparently all the suitable fields which could be involved in this are readonly (I considered the rect and the bounds attribute).

In other words I feel like I'd need to attach a SpriteRenderer with a dynamic size based on given dimensions. How could I reach this goal?


texts: Why am I seeing streak artifacts on the cube map I'm rendering?

texts:
I'm getting strange streaks on my cube map when rendering to it. He is my code that is being called each frame:

void drawCubeMap(void)
{

int face;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBindFramebuffer(GL_FRAMEBUFFER, fbo);
//glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapTexture);
//glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glViewport(0,0,sizeT, sizeT);

for (face = 0; face < 6; face++) {

   glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, cubeMapTexture, 0);
   drawSpheres();
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glViewport(0,0,900, 900);
}

Any idea what it might be? The streaking occurs when I'm rotating the spheres around the main sphere.


texts:
I have written a fragment shader, on a shape which is a square made with gl.TRIANGLE_STRIP, and which displays a radar:

To build the radar, I'm using distance from the center of the shape.

Currently, I'm using gl_FragCoord and have to pass the shader the size of the window, the position of the center of the radar, in order to determine where I am in the shape. I'm not really OK with that..

I would like to know if there is a better way to make the shader, to make it independent from display variables.

For example I thought I could use gl_PointCoord whose x and y coordinates goes from 0. to 1., but it requires to use GL_POINTS... I could give it a try by using GL_POINTS, but I'm not sure it's THE best solution.

For example, I could make a 3d scene, with lot of cubes, and display this radar on the faces of that cube. If the shader isn't independent from gl_FragCoord, it feels like it will be a nightmare to make it work.

Is there a way to get the relative position of the pixel we are giving the color, in the shape (triangle) we are rendering?
Do you have suggestions / tips?


texts:
I want to create a 2D side scrolling game in a similar style as the game "Castle Crashers". (Go to: http://store.steampowered.com/app/204360/ to see some pics of the game).

I have experience creating 2D games which use an array of tiles (a tilemap), to see if the player/enemies/bullets are moving to a blocked or unblocked tile by referencing the entities x and y coordinates with the tile in the corresponding location.

My question is: How do I implement collision with the "game map", in a game that doesn't use tiles, but instead shapes.

For instance: if the current "map" was a circle, the p[layer could move freely around the inside of the circle, but could not leave the circle.

Sorry if this question is long-winded and confusing, but I would really appreciate some help with this!

Thanks!


texts: Way to Get Collision Box Width Gamemaker

texts: I was coding the wall collision system for my game, and I wanted to do it using intersect boundaries instead of checking every step if they are off the screen. When the player crosses the boundary they get moved back to half of the sprite, but because the intersect boundary uses the collision box, it appears to jitter when you walk into the wall. Is there a way to get the width and height of the collision box so I can move them half of that away from the wall?


texts: Why does clipping take place after illumination?

texts: Can you explain why clipping takes place after the illumination process in the rendering pipeline? Would it be not cheaper to clip first and do then the illumination?


texts: calculating and saving latencies for multiplayer game

texts:
i am making a simple multiplayer puzzle game which basically presents a group of connected users some simple questions and whoever answers first wins the  game. but i am having some issue in designing this game. assuming there are two players A and B connected & player A submits answers before player B but player A has some network lag, the server thinks that player B submitted the result first so player B wins.W chich is not correct.

i thought of calculating latencies for each player and store it on the server in something like in-memory database redis.

so when any player submits their answer i can just minus the latency with the time when the game started. that way i can know which player actually won.

i was thinking to use fping program to get latencies every 2 seconds and store it. but the problem is when there are 1000 players playing simultaneously calculating ping times would take more time than 2 seconds( loop for every connected player then find their ping times & store them in db) so the next run to calculate ping time will be delayed.

How is this usually handled?am i going in wron direction?


texts: How minecraft manages interactable blocks (Chest)?

texts:
I am wondering, how does minecraft handle blocks like chest?

I guess normal blocks are ids in simple array, but how does it store and references blocks with special behaviour?


texts: Skinning on simple model doesn't work as expected

texts:
I have created a simple application to make skinning work with OpenGL. so I want to share with my vertex shader:
#version 330 core

layout (location = 0) in vec3 RealPos;
layout (location = 1) in vec3 vertex_color;
layout (location = 2) in vec2 vertex_textcoord;
layout (location = 3) in vec3 RealNor;

layout (location = 4) in vec4 Joint;
layout (location = 5) in vec4 Weight;

uniform mat4 u_jointMatrix[2];

out vec2 vs_text;
out vec3 vs_color;
out vec3 normal;
out vec3 FragPos;

uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;

uniform bool isSkin;

void main()
{

    mat4 skinMatrix = Weight.x * u_jointMatrix[int(Joint.x)] + Weight.y * u_jointMatrix[int(Joint.y)] + Weight.z * u_jointMatrix[int(Joint.z)] + Weight.w * u_jointMatrix[int(Joint.w)];

    vs_text = vertex_textcoord;

    vs_color = vertex_color;

    FragPos = vec3(model * vec4(RealPos, 1.0f));

    normal = mat3(transpose(inverse(model))) * RealNor;

    if(isSkin)
        gl_Position = projection * view * model * skinMatrix * vec4(RealPos, 1.0f);
    else
        gl_Position = projection * view * model * vec4(RealPos, 1.0f);
}

so as you can see, if my model is skinned then it will call the first statement.
and here my C++ code:
unsigned j = 0;
for (unsigned u = 0; u < m.numOfJoints; u++)
{
    glm::mat4 g = glm::mat4(inverseBindMatriceHandler.at(j), inverseBindMatriceHandler.at(j + 1),
    inverseBindMatriceHandler.at(j + 2), inverseBindMatriceHandler.at(j +
     3),inverseBindMatriceHandler.at(j + 4), inverseBindMatriceHandler.at(j + 5),
     inverseBindMatriceHandler.at(j + 6), inverseBindMatriceHandler.at(j + 7),
     inverseBindMatriceHandler.at(j + 8), inverseBindMatriceHandler.at(j + 9),
     inverseBindMatriceHandler.at(j + 10), inverseBindMatriceHandler.at(j + 11),
     inverseBindMatriceHandler.at(j + 12), inverseBindMatriceHandler.at(j + 13),
     inverseBindMatriceHandler.at(j + 14), inverseBindMatriceHandler.at(j + 15));
     m.inverseBindMatrice.push_back(g);
     glm::mat4 gTransform = glm::inverse(g);
     m.globalTransform.push_back(gTransform);
     j += 16 ;
}
                        }

 if (Model.isSkinned)
{
    for (unsigned l = 0; l < Model.numOfJoints; l++)
        jointM[l] = Model.globalTransform.at(l) * Model.inverseBindMatrice.at(l);
    int isSkinLoc = glGetUniformLocation(program, "isSkin");
    glUniform1i(isSkinLoc, 1);
    for (unsigned l = 0; l < Model.numOfJoints; l++) //2
    {
        std::string name = "u_jointMatrix[" + std::to_string(l) + "]";
        int jointMatrixLoc = glGetUniformLocation(program, name.c_str());
        glUniformMatrix4fv(jointMatrixLoc, 1, GL_FALSE, glm::value_ptr(jointM[l]));
    }
}
else
{
    int isSkinLoc = glGetUniformLocation(program, "isSkin");
    glUniform1i(isSkinLoc, 0);
}

inverseBindMatriceHandler is a vector.
I have 2 joints (numOfJoints).
I can't understand why my model doesn't work properly.
can someone help me?
Thanks


texts:
I have a set of objects placed on the same layer where all the objects are invisible except one. When I drag an object into a selected area, the current dragged object gets destroyed, and the object should be loaded in the same position. I have added polygon collider and rigid body (SET FIXED ANGLE) to all the objects. The problem here is: when I drag the object to the selected area, the object gets destroyed, and the next object gets loaded, but the position varies when the object is loaded.

public Vector3 ObjectSpawnPosition1;
public GameObject obj1;
void OnCollisionEnter2D(Collision2D col) {
  if (col.gameObject.name == "SemiCircle") {

    if (Input.GetMouseButtonUp(0)) {
      scoreCalculate.currentScore += 10;
      Destroy(gameObject);
      Instantiate(obj1, ObjectSpawnPosition1, Quaternion.identity);
      obj1.renderer.enabled = true;
    }

  }
}


texts:
I am making a game, where two zombies will spawn after every three moves my character makes. The problem is that I have no idea how to do this.

I have my character moving correctly, in each key press event, so I want the game to count each time one of these events are triggered, and perform the action after every third trigger. Perhaps I need a global variable/counter that can count these events?

How do I make instances of enemies spawn after every three keypress movements?


texts: Recreating retro/NES style physics with intentional imprecision

texts:
Background:

I'm having a problem getting the jump curve correct for a retro platformer remake project of mine. The original game is for the NES, and the player's velocity is stored in two separate parts: one byte for the whole number and another for the fractional part.

Gravity is added to the player's Y speed at a rate of 0.25/frame.

When the player jumps, his Y speed is set to -4.64453125. The rest of the jump curve is left to gravity.

As the player ascends his vertical velocity converges to 0 at a rate of 0.25/frame. When the player's velocity reaches a value less than zero, however, the velocity changes following a different pattern. Instead of decreasing steadily by 0.25 every frame, it follows this pattern:

[1.75, -0.25, -0.25, -0.25, 1.75, -0.25, -0.25, -0.25, 1.75, ...]

It appears to have something to do with integer overflow.

Data:

Here is a dump of the data from the original. It's a table of the velocity.

Jump Curve

Y-Hi Y-Lo    Decimal        Change/Frame
4    165     4.64453125     ?
4    101     4.39453125     -0.25
4    37      4.14453125     -0.25
3    229     3.89453125     -0.25
3    165     3.64453125     -0.25
3    101     3.39453125     -0.25
3    37      3.14453125     -0.25
2    229     2.89453125     -0.25
2    165     2.64453125     -0.25
2    101     2.39453125     -0.25
2    37      2.14453125     -0.25
1    229     1.89453125     -0.25
1    165     1.64453125     -0.25
1    101     1.39453125     -0.25
1    37      1.14453125     -0.25
0    229     0.89453125     -0.25
0    165     0.64453125     -0.25
0    101     0.39453125     -0.25
0    37      0.14453125     -0.25
-1   229     -1.89453125    1.75
-1   165     -1.64453125    -0.25
-1   101     -1.39453125    -0.25
-1   37      -1.14453125    -0.25
-2   229     -2.89453125    1.75
-2   165     -2.64453125    -0.25
-2   101     -2.39453125    -0.25
-2   37      -2.14453125    -0.25
-3   229     -3.89453125    1.75
-3   165     -3.64453125    -0.25
-3   101     -3.39453125    -0.25
-3   37      -3.14453125    -0.25
-4   229     -4.89453125    1.75
-4   165     -4.64453125    -0.25
-4   101     -4.39453125    -0.25
-4   37      -4.14453125    -0.25
-5   229     -5.89453125    1.75
-5   165     -5.64453125    -0.25
-5   101     -5.39453125    -0.25
-5   37      -5.14453125    -0.25
-6   229     -6.89453125    1.75

Problem:

In my game I haven't been able to achieve this effect. When the velocity is less than zero it continues to decrease regularly by 0.25 rather than the pattern described above. Rather than storing the whole and fractional parts separately, I am storing them together in a single float.

How can this effect be achieved?


texts:
An upcoming goal of mine is to write a procedural generation algorithm for daggerfall-esque dungeons.  However, I plan on including doors locked with specific keys and I would rather they be able to be accessed by the player, at least at some point. (Perhaps in a hypothetical situation.  one or two keys are accessible at first and the rest are locked behind those doors)
How would I go about approaching this?


texts: Modern examples of Multiplayer Network Architecture

texts:
There's a lot of documentation on Multiplayer Network Models for games from the early 2000's (Quake3, Unreal, Counter-Strike, Source Engine) which go through concepts such as client-server architecture, latency compensation methods, prediction and delta-compression of game states.

However, as these models were rapidly improving (as you can tell from Doom to Quake1 to Quake3 and so on) I am led to believe that a lot of improvements probably happened after these as well. Therefore I am looking for documentation on a contemporary Multiplayer Network Model such as League of Legends or similar. It seems to me that LoL has an excellent model given how responsive and accurate it feels compared to a lot of alternatives.

Which is the latest well documented client-server Network Model for a twitch gameplay multiplayer game? Are the Source and Unreal engines continuously improved upon? Does CS:GO use the Source Engine of old?


texts: When are HLSL literals taken as a float and integer?

texts:
float2 uv = float2(fX % 1, fY % 1) * 1/16;

In the above example 1/16 is treated as a float, multiplying the float2 by 0.0625, but in:

float2 uv = float2(fX % 1, fY % 1) * 1/16 + float2(1/16,0);

The second 1/16 is taken as an integer and the second float2 becomes (0,0).

What's the order in which a specific type is used.  And is there any suffix to force a float?  I know 1.0/16.0 would work.


texts:
There are tons of tools and instructions for making 3d models and animations in various software products. My question is: in video-game engines, when would you use a pre-rendered animation, and when would you use armature data in the model to manipulate your model in to the desired action?

Secondary questions:
Are there any games that even use the model's rigging, in-game, or is everything pre-rendered?

Are there any human-readable file formats that contain armature data?

Lastly, from a OpenGL-level and up perspective, how would you implement a system for animating something like walking?

I am building an OpenGL graphics engine from scratch as a personal project, so if answers can cater to that context, it would be fantastic.


texts: How to avoid rows on screen when cutting spritesheet tiles?

texts:
I'm having a problem with my spritesheet, I generate a map but when I zoom in on it I can observe these lines as in the image below:

When I used the tiles each in their separate image, that did not happen, how do I avoid this case?

I'm drawing like this, the problem happens when I give a "ctx.scale":

ctx.drawImage(
    imgSolos.img,
    (imgSolos.width * resultSolo), // resultSolo is current frame in the spritesheet
    0,
    32,
    32,
    x,
    y,
    imgSolos.width,
    imgSolos.height
);


texts:
I am trying to make my sprite start moving from the moment it is created and do its animation. It draws on the screen right and animates but doesn't move. It should start moving towards the direction it is facin this means right and if collision detected to stop the animation do whatever and continue the animation.
Here is my code:

public class grt extends ApplicationAdapter {
 Misheva mshv;

@Override
public void create () {
    mshv = new Misheva();
    mshv.init();

}

@Override
public void render () {
    mshv.drawIt();
    mshv.act(Gdx.graphics.getDeltaTime());

}

@Override
public void dispose() {
    mshv.disposer();

     }

 }

Misheva.java

public class Misheva extends Actor {
int state;
TextureAtlas atl;
TextureRegion [] walk;
SpriteBatch batch;
Animation anim;
float stateTime;
float elapsed = 0;
int horizontalspeed = 10;

public void reset (){
    state = 0;
    stateTime = 0;
}

@Override
public void act(float delta) {
    super.act(delta);
    stateTime += delta;
    switch(state){
    case 0: setX(getX()-horizontalspeed*delta);

    }
}

public void drawIt(){
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    elapsed += Gdx.graphics.getDeltaTime();
    batch.draw(anim.getKeyFrame(elapsed,true), 0, 0);
    batch.end();

}

public void init (){
    atl = new TextureAtlas(Gdx.files.internal("data/tomaton.atlas"));
    batch = new SpriteBatch();
    walk = new TextureRegion[3];
    walk[0]=atl.findRegion("tomato");
    walk[1]=atl.findRegion("t_walk2");
    walk[2]=atl.findRegion("t_walk1");
    anim = new Animation(1/10f,walk);
}

protected void disposer(){
    batch.dispose();
    atl.dispose();
    }

 }


texts:
I have a formula which returns a Lerp Vector3 value in integers but the problem is it never reaches the desired target value. It's converting to pixel values first by multiplying by PPM which is float 32f.

private Vector3 lerp(final Vector3 source, final Vector3 target, float alpha) {
    Vector3 sourcePPM = new Vector3(source.x * PPM, source.y * PPM, 0);
    Vector3 targetPPM = new Vector3(target.x * PPM, target.y * PPM, 0);
    sourcePPM.x += Math.round(alpha * (targetPPM.x - sourcePPM.x));
    sourcePPM.y += Math.round(alpha * (targetPPM.y - sourcePPM.y));
    source.x = sourcePPM.x / PPM;
    source.y = sourcePPM.y / PPM;
    source.z = 0;
    return source;
}

I initialize my vector variable source to new Vector3(0.0, 0.0, 0.0). Then, each frame I update it like this:

source = lerp(source, new Vector3(26.0, 29.0, 0.0), 0.06f);

But instead of eventually reaching the target, the value plateaus at a certain point:

Target destination: (26.0,29.0,0.0)
Actual final destination: (25.75,28.75,0.0)

Falling short of the target destination. If I don't round the values then it gets there fine but I need it to be in whole pixels.

The final line of intermediate values (too many to add all of them):

(25.0,27.90625,0.0)
(25.0625,27.96875,0.0)
(25.125,28.03125,0.0)
(25.1875,28.09375,0.0)
(25.25,28.15625,0.0)
(25.28125,28.21875,0.0)
(25.3125,28.28125,0.0)
(25.34375,28.3125,0.0)
(25.375,28.34375,0.0)
(25.40625,28.375,0.0)
(25.4375,28.40625,0.0)
(25.46875,28.4375,0.0)
(25.5,28.46875,0.0)
(25.53125,28.5,0.0)
(25.5625,28.53125,0.0)
(25.59375,28.5625,0.0)
(25.625,28.59375,0.0)
(25.65625,28.625,0.0)
(25.6875,28.65625,0.0)
(25.71875,28.6875,0.0)
(25.75,28.71875,0.0)
(25.75,28.75,0.0)


texts: Instantiation of a GameObject not working for a threading reason

texts:
I receive the following error

  "INTERNAL_CALL_Internal_InstantiateSingle can only be called from the main thread."
      "Constructors and field initializers will be executed from the loading thread when loading a scene."
      "Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function."

whenever I try to instantiate some GameObject's using this function:

public void DisplayCalls () {
    for (int i = 0; i < calls [0].Count; i++) {
        for (int j = 0; j < impFields.Length; j++) {
            GameObject textClone = Instantiate (textBox, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject;
            textClone.transform.SetParent (canvas.transform);
            Text text = textClone.GetComponent <Text> ();
            text.text = calls[impFields [j]][i];
            text.alignment = TextAnchor.MiddleCenter;
            textClone.transform.localPosition = new Vector3 (-262.5f + (175f * j), (182f + (30f * i)), 0f);
        }
    }
}

The function is called using this other function:

public void GetPanelInfo () {
    string file = "getpanelinfo.php";
    string hash = Md5Sum (mostRecentID.ToString () + SecretKey1 + SecretKey2);
    string parameters = "?mostrecentid=" + mostRecentID.ToString () + "&hash=" + hash;
    string fullURL = baseURL + file + parameters;
    Uri fullURI = new Uri (fullURL);
    WebClient client = new WebClient ();

    string jsonString = string.Empty;
    client.DownloadStringCompleted += (sender, e) => {
        if (!e.Cancelled && e.Error == null) {
            jsonString = e.Result;
            JSONNode json = JSON.Parse (jsonString);
            for (int i = 0; i < json["calls"].Count; i++) {
                for (int j = 0; j < calls.Length; j++) {
                    calls[j].Add (json["calls"][i][names [j]]);
                }
                mostRecentID = json["calls"][i]["callID"].AsInt;
            }
        } else if (e.Cancelled && e.Error == null) {
            Debug.Log ("Cancelled");
        } else {
            Debug.Log ("Error: " + e.Error);
        }
        loading = false;
        LogCalls ();
        DisplayCalls ();

    };
    client.DownloadStringAsync (fullURI);
}

Which is called once using a button.

I cannot seem to find the problem, but as stated above, the error says that it is a threading problem and that I cannot call instantiate from another thread other than the main one. I do not know how to change the instantiation to another thread, but any help to solve this problem would be much appreciated.


texts: Removing texture wrapping artifacts in OpenGLES

texts:
I'm drawing an 2D array of cubes in 3D space using OpenGLES.  The texture that I have bound is spritesheet-style; that is, it's multiple textures packed into one.  If you look closely at the front of the image below, you can see 1-pixel thick lines that are lighter than the crates.  And, thicker lines in the back of the image.  They are not supposed to be there, and are what I believe to be pixels from another texture in the spritesheet.

I'm using GL_NEAREST_MIPMAP_NEAREST and GL_NEAREST for the min and mag filters, and I've tried all of the different clamping modes and nothing changes (GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRROR_REPEAT).

At  first I thought it was float precision error, but now I think it's something else (since using precision highp float in the shader makes no difference).


texts: How to put OpenGL in a state for drawing blended, colored, nontextured polys?

texts:
Using OpenGL1.1 (sadly) I'm trying to draw a cube, which is colored and alpha blended. It is instead showing up as opaque black. Even without including alpha in the color it still shows up as opaque black so I don't believe blending is the problem.

    @Override
public void doRender(Entity entity, double d0, double d1, double d2,
        float f, float f1) {
    assert(entity instanceof EntityExplosion);
    EntityExplosion explosion= (EntityExplosion) entity;

    glPushMatrix();
    glPushAttrib(GL_BLEND);
    glPushAttrib(GL_COLOR_MATERIAL);

    //glDepthMask(false);

    glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);//TODO fix

    glEnable(GL_COLOR_MATERIAL);//i dunno if this even does anything

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glColor3b((byte)0, (byte)255, (byte)255);//TODO fix

    glTranslated(d0, d1, d2);//trans whole thing

    for(NukeParticle p : explosion.particles){
        glPushMatrix();
        glTranslated(p.x, p.y, p.z);
        glCallList(callCube);
        glPopMatrix();
    }

    glPopAttrib();
    glPopAttrib();
    glPopMatrix();
}

This is being done during a Minecraft Entity Renderer, meaning that the current state of GL  is for drawing shaded, textured polys. What attribs or whatever do I change so that I can draw the way I want to?


texts: Collision Checking in Unity immediately after instantiation

texts:
I'm working on a dungeon generation script and I'm having some issues detecting overlap. Each piece that I spawn has attachment points, with rotation values and an offset amount so things lineup correctly. So far this is working. After spawning, I then check to see if the piece is overlapping with another, but sometimes it seems like unity hasn't caught up with the collision system, as I check to see if a bool bOverlap is true(which gets set in an ontriggerstay function) and if so destroy the piece. However, many times the script will have gotten past this collision check portion, before the collision event fires.

Any suggestions?

Each piece has a rigidbody and box collider on it for the simple collisions.


texts: How Do Shapes (Rectangles) Work in Quad Trees?

texts:
I've been told that a quad tree is the ideal data structure for my game, but I'm having trouble understanding how exactly shapes work within quad trees.

I'm doing this in JavaScript, but I think these questions could apply to quad trees in any language.

I think I mostly understand how basic (x,y) points and point insertion works in quad trees, and that I could do it on paper.

Here is a JSfiddle of my experimenting with points.

Aside from one case, my tests with points are working as expected.

But my confusion starts when shapes like rectangles are involved.  When you are retrieving from a quad tree with shapes, does it check each point of the shape, and what nodes they fall into?  And how do shape insertions even work, when it accepts (x,y,width,height) parameters for each shape?  Does it use the width/height from the starting point to calculate other corner points, which are then dispensed into appropriate nodes?  If an inserted shape spans into four nodes, is that shape's data saved into all four nodes?

And when a retrieval method accepts a shape as the parameter(x,y,width,height), what is actually going on?  Is it first seeing what nodes the shape would span to if it were to be inserted, and then retrieve all the objects of those nodes?

I have a JSfiddle working with shapes, but I am utterly confused on the results of my testing.  I am getting duplicate objects being returned!

For example, the red square is a drawn equivalent of the parameters I am entering into my retrieval method.  I would think that since this red square spans all four nodes, it should return every object in the quad tree!  But it doesn't, and I am having trouble  rationalizing what it does return.  I have a number of other tests that are currently commented out, but you can un-comment and run them to see more confusing results!

As say, if I want to return all points in a quad tree, how would I do that?  A retrieve method using a shape the entire size of the bounds?  In example, retrieve(0, 0, canvas.width, canvas.height)?

The JavaScript QuadTree library I am using has been referred to by various other sources, so I assume the actual implementation is correct and reputable.

I think a lot of my confusion may stem from a misunderstanding of quad tree terminology.  Like, why do they say bounds instead of dimensions, when a "point" has width/height parameters as well?  Is it a matter of convention/short-hand, or are they completely different concepts?

Thanks for your time!


texts: Is Google App Engine a good platform for an online MMO?

texts:
I'm looking at some ideas of creating a smale scale MMORPG game, based in Java, this is a side/hobby project to help my learning process

I've already had a play with GAE and have put up a simple web app, I'm thinking of using this as my platform for a game

Is this a good idea? Are there any games out there that use such a platform? I can't see any limitations so far, other than Google might be able to "own" it rather than myself


texts: Accounting for waves when doing planar reflections

texts:
I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending on the state of the wave's height.

Naturally, after examining the brief paragraph of code:

// calculating correction that shifts reflection up/down according to water wave Y position
float4 projected_waveheight = mul(float4(input.positionWS.x,input.positionWS.y,input.positionWS.z,1),g_ModelViewProjectionMatrix);
float waveheight_correction=-0.5*projected_waveheight.y/projected_waveheight.w;
projected_waveheight = mul(float4(input.positionWS.x,-0.8,input.positionWS.z,1),g_ModelViewProjectionMatrix);
waveheight_correction+=0.5*projected_waveheight.y/projected_waveheight.w;
reflection_disturbance.y=max(-0.15,waveheight_correction+reflection_disturbance.y);

My first guess was that it compensates for the planar reflection when it is subjected to vertical perturbation (the waves), shifting the reflected geometry to a point where is nothing and the water is just rendered as if there is nothing there or just the sky:

Now, that's the sky reflecting where we should see the terrain's green/grey/yellowish reflection lerped with the water's baseline. My problem is now that I cannot really pinpoint what is the logic behind it. Projecting the actual world space position of a point of the wave/water geometry and then multiplying by -.5f, only to take another projection of the same point, this time with its y coordinate changed to -0.8 (why -0.8?).

Clues in the code seem to indicate it was derived with trial and error because there is redundancy. For example, the author takes the negative half of the projected y coordinate (after the w divide):

float waveheight_correction=-0.5*projected_waveheight.y/projected_waveheight.w;

And then does  the same for the second point (only positive, to get a difference of some sort, I presume) and combines them:

waveheight_correction+=0.5*projected_waveheight.y/projected_waveheight.w;

By removing the divide by 2, I see no difference in quality improvement (if someone cares to correct me, please do). The crux of it seems to be the difference in the projected y, why is that? This redundancy and the seemingly arbitrary selection of -.8f and -0.15f lead me to conclude that this might be a combination of heuristics/guess work. Is there a logical underpinning to this or is it just a desperate hack?

Here is an exaggeration of the initial problem which the code fragment fixes, observe on the lowest tessellation level. Hopefully, it might spark an idea I'm missing. The -.8f might be a reference height from which to deduce how much to disturb the texture coordinate sampling the planarly reflected geometry render and -.15f might be the lower bound, a security measure.


texts: How do I make a circular hole inside an editable poly without boolean operations?

texts: I have created a rectangle, then converted it into an editable poly. Then I created a circle and converted it to editable poly too. How to make it so that that the circle becomes a hole in the rectangle?


texts:
I've built my own entity manager, as I found out some days ago, it is very similar to the Artemis framework.

For now, I just use integers as entity ids. Behind the scenes, there is a simple integer counting up every time a new entity is created so that the ids are handed out in incrementing order by the manager.

But recently I faced the problem that I cannot load multiple savegame files into the same scene. The issue here is that two savegames could use the same entity id for different things, causing a conflict when being load into the same scene.

Anyhow, the ability to load multiple savegames is useful to keep separated player data (his skills, inventory, custom items and tools he crafted) with scene data (rocks, trees, players in a town) and data from mods (cool new weapon pack).

So I need unique ids among every savegame file that will be created at all, without them knowing about each other. The idea that came to my mind is using timestamps as entity ids instead of consecutive integers.

(Since multiple entities might be created in the same millisecond, the timestamp should contain microseconds. And to play safe there could be also a mechanism to suffix a consecutive number if multiple entities are created in the same microsecond. To be honest I don't know how fast modern CPUs are and if they could do that, but I guess they can.)

Since I haven't heard of other people doing that, I assume that there is a trade-off. What are the disadvantages of using timestamps as entity ids? I think the performance hit will be minor and be can neglect that point.


texts: Unity build error "Value cannot be null. Parameter name: path1"

texts:
I'm getting this error when trying to build my game for Android, I've googled it but there's only 1 result about it and it didn't work for me as I use 64-bit windows. How can I fix this and what's causing it?

  ArgumentNullException: Value cannot be null.
  Parameter name: path1
  System.IO.Path.Combine (System.String path1, System.String path2) (at :0)
  UnityEditor.Android.AndroidComponentProperties.Read (System.String directory) (at :0)
  UnityEditor.Android.AndroidComponentProperties.GetPackageRevision (System.String directory) (at :0)
  UnityEditor.Android.AndroidSDKTools.BuildToolsVersion () (at :0)
  UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKBuildToolsDetector.GetVersion (UnityEditor.Android.AndroidSDKTools sdkTools, UnityEditor.Android.AndroidJavaTools javaTools) (at :0)
  UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector.Detect (UnityEditor.Android.AndroidSDKTools sdkTools, UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.ProgressHandler onProgress) (at :0)
  UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.EnsureSDKComponentVersion (UnityEditor.Android.AndroidJavaTools javaTools, System.Version minVersion, UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK+SDKComponentDetector detector) (at :0)
  UnityEditor.Android.PostProcessor.Tasks.CheckAndroidSDK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
  UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
  UnityEditor.Android.PostProcessAndroidPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at :0)
  UnityEditor.Android.AndroidBuildPostprocessor.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at :0)
  UnityEditor.PostprocessBuildPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:106)
  UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

  Error building Player: ArgumentNullException: Value cannot be null.
  Parameter name: path1

  Build completed with a result of 'Failed'
  UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)


texts: Getting dynamic objects to match baked lighting on nearby static objects

texts:
Here's how the hallway in my game looks now:

You might notice the dark section near the centre of the screen; This is, in fact, a pair of cupboard doors which are not set to static and so don't get included in the baked lighting.

The problem is, since all of my house lights are baked only, it looks like the only light these doors are getting is the ambient light - so quite dark.

Is there an alternative, best practise to ensure non-static objects get lit sufficiently when lighting is baked?


texts:
How to lerp velocity to 0 in specific time? For example in two seconds? I need this for jumping.

velocity.Y = MathHelper.Lerp(velocity.Y, 0, [time]);


texts: Calculating displacement in physics simulation

texts:
Something's been bugging me and I haven't been able to figure this out.

In a simply physics simulation, where you'd calculate a net force acting on a body every frame, calculate the acceleration that frame and from that the velocity and then distance travelled. (like this):

a = F(given)/m v = a*dt s = v*dt

Why is it not s=0.5*vfinal*dt (for constant acceleration), in other words, why is not customary to assume that the speed changes linearly during the timeframe dt instead of assuming that the velocity is constant during the frame.


texts: Mobile Game: Google Play no supported dev country and capitalization alternatives (no policies violation or suspicious behavior)?

texts:
If my country is listed as not supported as a developer country (for payments), this mean developer can upload app but no make any money with it. If I understood correctly, not even in app ads are allowed (I have my doubts about ads because It has no sense they aren't allowed).

Is there any mean, friendly with Google policies, to monetize the app?

For example:

Desktop version is free to play. Optional content requires a payment.
Mobile version is free to play. Optional content requires you to log in with same account you used to purchase it on desktop. No ads and no in-app purchase in mobile version.

Is the above scenario OK? Which are the alternatives?

Notes:

To me, no ads has no sense. After reading Developer Console documentation I assumed that ads are OK but after doing some research It turns on that many people thinks that ads are not OK.


texts: Godot Mono cannot find .NET framework 4.7

texts:
I cannot get anything to compile in Godot Mono using C#.  It keeps giving me the following error:

  The reference assemblies for framework ".NETFramework,Version=v4.7" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\Users\my_name\Desktop\GODOT\Projects\test\Test.csproj]

I have installed the SDK found here which did not fix the problem.  Maybe I need to explicitly direct Godot to it, but I can't find any option to do so.  Can someone please point me in the right direction?


texts: Height and Width of Player Depth View using Kinect SDK

texts:
This code shows that how we can find the player from the depth Image:

this.depthData = new short[frame.PixelDataLength];

frame.CopyPixelDataTo(this.depthData);

    for (int depthIndex = 0; depthIndex < depthData.Length; depthIndex++)
    {
            player = depthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;
    }

I wanna ask about how can I find Width and Height of Depth View of the player ?
Thanks


texts: At what point of Game Dev pipeline it is good idea to start adding Oculus Rift Support?

texts:
I am still in pre-dev phase - creating Assets, editing storyline, doing OOP analysis.
I plan to make game in UE 4 and would like for game to have VR support.
Would it be good idea to start right away with Oculus Rift(like "mobile first" approach) or add it when I have working game prototype?
Thanks


texts:
I have a 3D Model like above in which i want to rotate it from a given location(pointed in red) but I can only rotate it from the middle. How can I rotate it from a custom point.

Edit:

I successfully able to rotate the model from the below position by getting the radius of the model and applying it to the world matrix

        Vector3 point = new Vector3(-radius, 0, 0);
        world = Matrix.CreateTranslation(-radius, 0, 0);

But now I cannot change the position of the object and it always centered in middle of the screen. I think that's because i applied the above code. How can I place it anywhere I want?


texts: Unity / NodeJS Projectile synchronization

texts:
I am working on a MOBA game similar to League of Legends. I am building the game server system in NodeJS/Socket.IO but I'm running into issues on figuring out the best way to handle projectiles (aka player skill-shot abilities) on the server-side. The Main goal is to be able to spawn a projectile (or projectiles) on the server-side and update the position in a certain direction (all on the server-side separate from Unity) until I specify the projectile to be destroyed. This way, each time the projectile moves I can check with every single players current position and see if the projectile hit (thus allowing me to damage the player on the server-side).

How could I achieve this effect, or something similar?


texts:
Hello I am a 10th grade student from India...I have been playing games since a very young age. I want to work in the game industry as a game developer...I have started learning the basics of C programming language...Can anyone tell me which language I should focus on or should I just continue with C

Thank You


texts: Nestling into contact with a group of physics objects without exerting forces on them

texts:
I'm making a pool game, and would like the circle (imaginary) to be in contact with the table and balls, and to fit perfectly as a ball would.

Now I thought I would use Rigidbody and lerp the position of the circle to the raycast hit, and its collider it would force it into a fitting position.

The problem I encountered is that since it has a collider, it also pushes the balls, which I do not want.

So my question is, how do I make an object act like it's touching & blocked by other GameObjects with Colliders and Rigidbodies, without pushing them?


texts: How can I get textures on edge of walls like in Super Metroid and Aquaria?

texts:
Games like Super Metroid and Aquaria present the terrain with the other facing parts having rocks and stuff while deeper behind them (i.e. underground) there's different detail or just black.

I would like to do something similar using polygons. Terrain is created in my current level as a set of overlapping square boxes. I'm not sure if this rendering method will work such a system for creating terrain but if anyone has ideas I'd love to hear them. Otherwise I'd like to know how I should re-write the terrain rendering system so it actually works to draw terrain in this manner...


texts: Legalities of using song names in a music guessing trivia game

texts:
I have an idea for a new new music trivia game with a table top skirmish twist. My question is related to the trivia part of the game: are there any copyright laws against me using names of songs in my trivia questions?
The way the game works is that questions will be based on different genres of music (E.G. pop, hip hop, RnB, heavy metal, etc.) and players will be asked to describe it and have other players guess its name without saying the song name, but by quoting a lyric, humming the melody/harmony or base line.  Much like in the game Articulate, but you'd be describing music rather than people and things and there would be song names on the question cards for each category.
Am I able to do from a legal point of view or not.


texts:
I'm designing a 2d RPG where you navigate on a overhead map. The terrain is mostly open with big parts of inaccessible terrain such as mountains and rivers. The player navigates short distances at a time by clicking/tapping where to go on the map.

I'm looking for a pathfinding algorithm for the navigation. Avoiding obstacles isn't the most important issue. I can see the game stopping the player when hitting an obstacle and leave it to the player to take another path. Although having it would be a bonus, e.g. when crossing bridges etc. it would be easier for the player if he just has to click on the other side and don't have to worry about bumping into walls.

The more important issue is the roads on the map, and I can see it being rather tedious for the player to constantly have to correct the path for staying on the road. As there are incentives to stay on the road such as walking faster and encountering less enemies - I want to make it easy for the player to stay on the roads. So navigation should gravitate to using roads, before going off-road. I also think the game will be more aesthetically pleasing if the navigation gravitates to using roads on the map.

Pathfinding is a new topic for me so I'm unsure where to begin. What is a good way to represent the terrain and roads? Should I use waypoints for the roads and what is a good algorithm for finding a good path that gravitates to using roads?

Thanks


texts:
I am working on a platformer game for the final year project in HS.
However... The collision detection system I use is basically about checking wether a specific part of the character intersects with another block or not.

The collision seems to be working fine except that it causes some bugs such as player king of getting stuck or slowing down when hitting from the sides or gets thrown up when both upper and < or > keys are used.

My question is; How can I improve the collision code in order to avoid such glitches and have sort of 'slippery' collisions?

here is a preview of how the bounds look

and here is a preview of what it actually looks like in game
(click for better quality)

The code i use for collision detection:
(tempObject are blocks that the player is intersecting with)

if(getBoundsTop().intersects(tempObject.getBoundsBottom())){
    y = tempObject.getY() + height;
    velY = 0;
    System.out.println("Top collision");
}

if(getBoundsBottom().intersects(tempObject.getBoundsTop())){
    y = tempObject.getY() - height;
    velY = 0;
    falling = false;
    jumping = false;
    //isOnBlock = true;
} else {
    falling = true;
    //isOnBlock = false;
}

if(getBoundsRight().intersects(tempObject.getBoundsLeft())){
    x = tempObject.getX() - this.width;
}

if(getBoundsLeft().intersects(tempObject.getBoundsRight())){
    x = tempObject.getX() + this.width;
}

and here is are the bound methods:

public Rectangle getBounds() { return new Rectangle( (int)x, (int)y, (int)width, (int)height ); }

    public Rectangle getBoundsTop() {
        return new Rectangle(
                (int)x,
                (int)y,
                (int)(width-(width*0.01f)),
                (int)(height/2)
        );
    }
    public Rectangle getBoundsBottom() {
        return new Rectangle(
                (int)x,
                (int)(y+(height/2)),
                (int)(width-(width*0.01f)),
                (int)(height/2)
        );
    }

    public Rectangle getBoundsLeft() {
        return new Rectangle(
                (int)x,
                (int)y,
                (int)((int)width*0.15f),
                (int)height
        );
    }

    public Rectangle getBoundsRight() {
        return new Rectangle(
                (int)
                ((int)x+(width-(width*0.15f))),
                (int)y,
                (int) ((int)width*0.15f),
                (int)height
        );
    }


texts: Should components in Entity Component System pattern have logic?

texts:
Is often read that in entity component system pattern we should treat components just as a passive data structure with no logic at all, this way we follow to a data oriented design approach with efficient usage of cache memory and gain performance.

I was developing a simple game using this rule and when the game was getting bigger I start facing some serious code smells such as repeated code in systems, let's suppose its a shooter to illustrate an example. In this shooter I had bullets being fired so I created a BulletComponent and a BulletSystem that handles when it collides and make some damage and if don't collide with anything the bullet dissapear in five seconds. Then I wanted some explosives so I created the ExplosiveComponent and ExplosionSystem, once the explosive is placed it explodes in ten seconds. At this point we can notice the first repeated code between systems then we can make an abstraction and we create a DurationComponent and a DurationSystem so the bullet and the explosive contains it with the time it should last.Then I realized that when the explosive should explode I want to create some particle effect in the area so this abstraction is no longer valid as I want to perform differents actions when time runs out, but if I do as at the beginning I have the repeated code between systems (ugh!). This example is simple but I'm facing this with more complex things like AI, or reacting to collisions.

One solution I came to this is that I really wanted an ActionComponent with a ActionSystem that executes the action contained in the component but this way I'm breaking that components only contains data and they should not have logic! this is more an 'hybrid' approach. But if you start thinking deeply the ActionSystem is very generic and you can almost do anything with it so it's hard to determine whether a system is necessary or not. The same can be applied to collisions, instead of having lots of systems with logic for different entities colliding, you can just have a CollisionHandlerComponent  with the logic on it for each entity.

I found the following advantages making generic systems like this:

Higher flexibility (you can customize each entity easily)
No repeated code
Less systems (more performance?)

But as I said the main disadvantage is that is really confusing if a system is needed as you can stick logic to components.

Is it wrong to follow this sort of hybrid ecs? If yes, what would be your approach to the example without repeating code in systems?


texts:
How can I see whether my sprite is .png or .jpg in the Inspector view or some place alike in Unity?

Here is an example of me trying to get the file extension using Editor:


texts: Creating Transparent Game Menu Items using AndEngine

texts:
I'm trying to create a Game Menu which contains some Menu Items like

New Game
Multiplayer
Options
Exit

I want to make this Menu Items Transparent. Only Text in White color should be visible.
So i guess i do not need any background image for Menu Items.

I have seen examples of SpriteButton like given below.

ButtonSprite playButton = new ButtonSprite(0, 0, btnNormalTextureRegion, btnPushedTextureRegion, this.getVertexBufferObjectManager(), new OnClickListener() {
    @Override
    public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
        // Do Stuff here
     }
}

The thing which i don't understand is how can i initialize btnNormalTextureRegion?
I use the code give below to initialize ITexture and ITextureRegion for objects.

mBackgruondTexture = new BitmapTexture(activity.getTextureManager(), new IInputStreamOpener() {
                public InputStream open() throws IOException {
                    return activity.getAssets().open("gfx/backgrounds/greenbg.jpg");
                }
            });
mBackgruondTextureRegion = TextureRegionFactory.extractFromTexture(mBackgruondTexture);

This code openes up an Image from assest.
As i do not want to use any image for Menu Item How can i initialize btnNormalTextureRegion for SpriteButton.

OR

Is there any alternative to create Game Menu?


texts: How do I use elapsed time as the player's score in Unity?

texts:
I'm making a "survival" game, where the goal is to stay on a rotating board as long as possible. I want to add a score system based on how many seconds passed. For example, if you stay on the board for 5 seconds, your score should be 5.

How can I do this in Unity using JavaScript?


texts: No response to touch from XNA page after navigated from Silverlight page

texts:
I am creating XNA/Silverlight game in Windows Phone Mango. Testing with the emulator in both the Release and Debug mode.

From the main page, I call a settings page written in Silverlight. Then I back out without making any changes. I enter the XNA page, the touch does not work properly.

If I start the app, then enter the XNA page straight from the main page, the touch does work.

In OnNavigatedTo:

TouchPanel.EnabledGestures = GestureType.Tap

Calling the settings page from main page:

NavigationService.Navigate( new Uri("/Pages/SettingPage.xaml", UriKind.Relative));

Games.cs buttons tap detection (only the detection lines):

while (TouchPanel.IsGestureAvailable && ! actionFound)
{
    GestureSample gestureSample = TouchPanel.ReadGesture();
    if (gestureSample.GestureType == GestureType.Tap)
    {
        // do work
    }
}

I add breakpoints in the 'do work' sections, it only gets hit after 3-4 taps.

I change the settings page to embedded Silverlight on XNA page, the same problem happens.

Just to make sure the timer is working, I change one of the sprites to move up and down in OnDraw. The sprite moves OK in both cases.

I been stuck on this for two days, and I got three more pages to code I need to call for a proper game.

Thanks in advance for any help.


texts: Simple physics for modelling ship/submarine movement

texts:
for a first iteration of my sim, I need a very basic physics model for ship/submarine movement. I'd guess it might be a good approach to use vectors here (ship heading but also considering sea states etc.). Basic acceleration and that stuff should be taken into account

I do not need any 3D stuff...the 'client' for that 'ship movement' physics is only the 2D rendering of a navigation map.

I've found some papers on the net but they are far too complex for my needs.

Anybody does know some 'simplified' vector algorithms etc. for that?

Thanks a lot.

EDIT: To be clear: I do not want to simulate ship movement/ocean physics in detail, because this is not the focus of my (naval) simulation. It 'just' must be somewhat believable in that sense that if you have different sea states(wind/waves/currents) that the vessel is somewhat believable influenced (on the navigation map) by those forces.

The main issue for me is how I model/calculate those forces (wind etc.) by simple vectors and (eg. for a given wind velocity like 50kn) in an easy way withouth studying physics ;).


texts: I'm writing a shader and I just wanna ask if it's possible to get the ID of the vertex that is currently being manipulated. I read something about gl_vertexID, but I couldn't find out if that is something I can use.


texts: How can I draw things just in an area that can have a shape such as the shape of the letter B and not draw outside this form?

texts:
I want to draw stuff on an image, for Example, if I have a letter, as an image and I want to draw on the letter it is necessary that this image is touchable.
This is what I did:

Image.addListener (new clickListener () {
public boolean Touchdown (InputEvent event, float x, float y, int pointer, int button)
{
/ * posCurseurX = x;
posCurseurY = y * /

// Begin to draw on the screen

touch = true;
traitSprite = new Sprite (rectangleTexture, 0.0, tailleTrait, tailleTrait)

traitSprite.setPosition (x-tailleTrait / 2 (height) -y - tailleTrait / 2);
tabRectangelSprite.add (traitSprite);
counter ++;

dessinerTrait (touch);
dessinerCurseur ();
// The index of the number of meter rectangle forming a line

return true;
}
});

But I want to add another listener for mouse movements, but it does not work with MouseMove.
and the other thing I would like, is to draw that if I'm on my image. If the cursor position is not between the coordinates of the image so I will not draw.

that's what I tried:

if (posCurseurX> = image.getX posCurseurX && <= + image.getX image.getWidth) {

..}

But the texture does not necessarily have that width, that's an example:


texts:
I'm trying to determine the max line count of a UI.Text with VerticalOverflow set to truncate so that the line count can be used later. So far I came up this code which obviously is rather unpractical and perhaps even dangerous:

/// <summary>
///     Returns the max visible line count of a UI.Text component. The text's vertical
///     overflow must be set to truncate or this method will return 0.
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static int GetMaxLineCount(Text text)
{
    if (text == null || text.verticalOverflow != VerticalWrapMode.Truncate) return 0;
    var textBackup = text.text;
    var lineCount = 0;
    text.text = "";
    while (true)
    {
        text.text += "\n";
        Canvas.ForceUpdateCanvases();
        var nextLineCount = text.cachedTextGenerator.lineCount;
        if (lineCount == nextLineCount) break;
        lineCount = nextLineCount;
    }
    text.text = textBackup;
    return lineCount;
}

Is there any better way to (pre)determine the max line count of a UI.Text component (before text is truncated at the bottom)?


texts:
What is the difference between the constructor of a BasicGameState and the init method?  It appears that they are both called at the same time when the BasicGameState is registered in StateBasedGame, so what makes them different?

A follow up question to this is how do I run a method only when a state becomes active?  Initially I thought the init method was only called when a new state becomes active, but this is not true.  Note that I'd like to call this method only once at the beginning of the new state, so putting it in the update method seems like the wrong place.


texts:
I don't understand, am I missing something?
I have hundreds of moving images on screen that only need to render and do their logic/physics when they are in the canvas.
Otherwise they can just deactivate to save on performance and there is a very big fps difference when they are deactivated vs activated outside the canvas.
RectMask2D on the canvas does barely anything.
Checking the bounds for hundreds of UI elements seems like madness.
So what are you supposed to do?


texts: Stretching a tetragonal shape in a texture to a square object

texts:
I'd like to write a fragment shader that stretches a tetragonal shape in a texture to a square shaped game object of mine. My problem is best described with a picture, seen below. The shader receives a texture and the four corners of the red tetragon, and I'd like to stretch the tetragon as such that that's the only thing that'll appear on my square object, nothing outside of it. In this example, the texture coordinates u and v (0, 0) would be transformed into (x1, y1), and in a similar fashion, (1, 1) would become (x4, y4).

I don't know how I should go about this though. I've done my research, I believe bilinear interpolation could be what I'm looking for, but from what I can see, it would only work if my red tetragon was a rectangle, in other words if its four corners where (x1, y1), (x1, x2), (x2, y1) and (x2, y2), which is clearly not the case here as all my four coordinates are different. Any help from a little hint to a complete code solution would be welcome.

Edit: I did try implementing bilinear interpolation, however it did not work. Here are the equations from the wikipedia article that I tried modifying to my specific case:

What R1 and R2 correspond to can be also seen on the image on wikipedia, my math notation may not entirely be correct but I tried to make it as understandable as possible. This did not give me the result I was looking for, however. I tried setting the red tetragon to be a triangle by setting (x1, y1) to (0.5, 0.5) while the remaining three coordinates went in their corresponding corners), and while I was expecting the texture to be stretched in some way, the end result still was a crystal clear, non-stretched picture (due to my testing circumstances, I can't tell the exact difference to when I set (x1, y1) to (0, 0), but the results were extremely similar).

Edit 2:
I'll also include the code from my fragment shader, for good measure.

in vec4 tex;
in vec3 normal;
out vec4 fragmentColor;

uniform struct {
    sampler2D colorTexture;
    vec2 p1;
    vec2 p2;
    vec2 p3;
    vec2 p4;
} material;

void main(void) {
    float x = tex.x / tex.w;
    float y = tex.y / tex.w;
    float x1 = material.p1.x;
    float x2 = material.p2.x;
    float x3 = material.p3.x;
    float x4 = material.p4.x;
    float y1 = material.p1.y;
    float y2 = material.p2.y;
    float y3 = material.p3.y;
    float y4 = material.p4.y;
    vec2 R1 = (x3 - x) / (x3 - x1) * material.p1 + (x - x1) / (x3 - x1) * material.p3;
    vec2 R2 = (x4 - x) / (x4 - x2) * material.p2 + (x - x2) / (x4 - x2) * material.p4;

    vec2 interpolatedPoint = (R2.y - y) / (R2.y - R1.y) * R1 + (y - R1.y) / (R2.y - R1.y) * R2;

    fragmentColor = texture(material.colorTexture, interpolatedPoint);
}

Here's what I see when I set p1 to (0, 0), p2 to (0, 1), p3 to (1, 0) and p4 to (1, 1)

And here's the same image but with p1 set to (0.5, 0.5)

The slight differences are only there because I had to position my camera manually, the two results are identical, even though in the second case I would expect to see an image that's clearly been stretched in some way.


texts:
getMusicPlaying is set to false whenever someone touches the button, but libgdx runs show method only once, at the start of the game, hence the music will keep playing forever.

I tried to use the render and batch.begin instead of show() same result.

private boolean musicPlaying = true;

button.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
 return true;
}

public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
 setMusicplaying(!musicplaying);
}
});

}
});
}

public void show() {
 if (getMusicPlaying ==true)
  music.play();
}