texts:
I am drawing a simple outline of the world using GL_LINE_STRIPs (in WebGL).
I want to not draw those lines that are on the other side of the spinning globe.
Using Nicol Bolas approach below I am trying to determine if a point is going away from the camera or not:
scene.map = {
    vbo: gl.createBuffer(),
    draw: function(pMatrix,mvMatrix,camera,t) {
        gl.useProgram(this.program);
        gl.uniformMatrix4fv(this.program.pMatrix,false,pMatrix);
        var spin = mat4_rotation(t,[0,1,0]);
        mvMatrix = mat4_multiply(mvMatrix,spin);
        gl.uniformMatrix4fv(this.program.mvMatrix,false,mvMatrix);
        var nMatrix = mat4_inverse(mat4_transpose(mvMatrix));
        gl.uniformMatrix4fv(this.program.nMatrix,false,nMatrix);
        gl.uniform3fv(this.program.camera,camera);
        gl.uniform4fv(this.program.colour,[0,1,0,1]);
        gl.enableVertexAttribArray(this.program.vertex);
        gl.bindBuffer(gl.ARRAY_BUFFER,this.vbo);
        gl.vertexAttribPointer(this.program.vertex,3,gl.FLOAT,false,3*4,0);
        var ofs = 0, parts = this.data.ofs;
        for(var part=0; part<parts.length; part++) {
            var start = ofs;
            ofs += parts[part];
            gl.drawArrays(gl.LINE_STRIP,start,ofs-start);
        }
        gl.disableVertexAttribArray(this.program.vertex);
        gl.bindBuffer(gl.ARRAY_BUFFER,null);
        gl.useProgram(null);
    },
    program: createProgram("precision mediump float;\n"+
            "attribute vec3 vertex;\n"+
            "uniform mat4 pMatrix, mvMatrix, nMatrix;\n"+
            "varying vec3 n;\n"+
            "void main() {\n"+
            "   gl_Position = pMatrix * mvMatrix * vec4(vertex,1.0);\n"+
            "   n = (nMatrix * vec4(vertex,1.0)).xyz;\n"+
            "}\n",
            "precision mediump float;\n"+
            "uniform vec4 colour;\n"+
            "uniform vec3 camera;\n"+
            "varying vec3 n;\n"+
            "void main() {\n"+
            "   if(dot(camera,n) < 0.0) discard;\n"+
            "   gl_FragColor = colour;\n"+
            "}\n",
            ["pMatrix","mvMatrix","colour","camera","nMatrix"],
            ["vertex"]),
    data: getFile("json","data/world.json"),
};
var pts = [], deg2rad = Math.PI/180;
for(var i=0; i<scene.map.data.pts.length; i+=2) {
    var lng = scene.map.data.pts[i] * deg2rad,
        lat = scene.map.data.pts[i+1] * deg2rad;
    pts.push(-Math.cos(lat)*Math.cos(lng),Math.sin(lat),Math.cos(lat)*Math.sin(lng));
}
pts.push(0,0,0); // centre of sphere, for sprite z-culling trick
gl.bindBuffer(gl.ARRAY_BUFFER,scene.map.vbo);
gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(pts),gl.STATIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER,null);

and to draw it:
var pMatrix = createPerspective(60,canvas.width/canvas.height,0.1,4),
    eye = [-2,0,0],
    mvMatrix = createLookAt(eye,[0,0,0],[0,1,0]);
scene.map.draw(pMatrix,mvMatrix,eye,t);

However, this is only drawing the left hemisphere rather than the front:

How can I correctly compute the normal of a point, and the position of the camera?


texts: GLSL Shader Effects: How to do motion blur?

texts:
I have a full 2D environment, with sprites going around as landscape, characters, etc.

To make it more state-of-art looking, I want to implement a motion blur effect, similar to modern FPS games (i.e. Crysis) blur when moving the camera quickly.

In a sidescroller, the desired effect is having this slight blur appearing to give the idea of fast movement when the camera is moving. If anyone could give me some tips on doing this, I'm assuming in a pixel shader, I'd be grateful.


texts: What player rating system can I use when the rating can only get larger?

texts:
I am developing a turn-based multiplayer app (2 players per match) for Android. As backend I use Google Play Game Services. I have implemented a leaderboard.
Now I consider how to design the ranking system - I just realized that Leaderboards in Play Games Services only support increasing existing scores but not decreasing them. Of course that means that I cannot use the Elo system.

Are there good rating systems that only take into account the current scores of both players and do not decrease the score of the user losing the game? The new score of the winning player should be the higher when he was much worse than his opponent and vice versa. I know, that it means there will be inflation :(.


texts:
I'm making a voxel rendering engine. My "chunks" are 32 * 32 * 256 blocks and I can render a 16 * 16 square of them (which corresponds to Minecraft's maximal render distance). I'm using VBOs holding XYZ float positions and UV float coordinates. I use one VBO per chunk.

VBOs are alloacted with:

GL44.glBufferStorage(GL15.GL_ARRAY_BUFFER,
            BufferUtils.createFloatBuffer(32 * 32 * 256 * 6 * 6 * 5),
            GL30.GL_MAP_WRITE_BIT | GL44.GL_MAP_PERSISTENT_BIT);

I map them once at creation:

GL30.glMapBufferRange(GL15.GL_ARRAY_BUFFER,
            0,
            32 * 32 * 256 * 6 * 6 * 5 * 4,
            GL30.GL_MAP_WRITE_BIT | GL30.GL_MAP_UNSYNCHRONIZED_BIT | GL44.GL_MAP_PERSISTENT_BIT, null);

Then I can write directly into the buffer and make changes visible to the GPU with:

GL42.glMemoryBarrier(GL44.GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT);

This works, except I get about 20 FPS, while Minecraft gets 300 without frustum culling. The CPU is clearly not the bottleneck, as I have 1M FPS when the window is minimized.

Am I doing something wrong or are VBOs slower than Minecraft's Display Lists? How can I speed this up?

System specs: i7 4770 & GTX 770 OC


texts:
When I kill my enemy some kind of gold get out of him. This gold moves forward to the player if he gets close. In my cast it moves very slow. I need it becomes more faster when get close to the player.
Example

using System.Collections;
public class souls : MonoBehaviour {

public Transform _attractorTransform;

private float paticlesFarFrom;

private ParticleSystem _particleSystem;

private ParticleSystem.Particle[] _particles = new ParticleSystem.Particle[1000];
void Start ()

{

_particleSystem = GetComponent<ParticleSystem> ();

}
public void Update()

{

if (GetComponent<ParticleSystem>().isPlaying) {

int length = _particleSystem.GetParticles (_particles);

Vector3 attractorPosition = _attractorTransform.position;

for (int i=0; i < length; i++) {

paticlesFarFrom = Vector3.Distance(_particles[i].position,_attractorTransform.transform.position);

if (paticlesFarFrom <=200) {
 // this line need to fix
_particles [i].position = _particles [i].position + (attractorPosition - _particles [i].position) / (_particles [i].remainingLifetime) * Time.deltaTime;
}

}

_particleSystem.SetParticles (_particles, length);

}
}

}


texts: The rightmost part of the game screen is truncated in HTML

texts:
I created a game that, when I play it in Unity, looks like this:

But when I build it in WebGL, the rightmost part of the screen (with the red player character in it) is truncated:

Play it in-browser on itch.io to confirm. It looks the same when I open the HTML file locally, so the problem is with the WebGL version and not with itch.

Only when I click the "full screen" button, the rightmost part is shown.

What am I doing wrong?


texts: How do teams prevent overwriting work in source files?

texts:
It occurred to me the possibility that while, for example the game engine, is being worked on simultaneously by multiple people how is overwriting prevented?

Let's say developer one is working on Audio.cpp and developer two is also working on Audio.cpp, how is this generally managed in large teams to combat overwriting? (In other words to stop developer two from opening the file until developer one is finished)


texts:
I need to debug my scripts, but if I click "Attach to Unity" or "Attach to Unity and Play" then the button is just grayed out and after a few seconds it is clickable again, but nothing happens.

I already tried to restart visual studio, but it did not helped.

I restarted unity, but this brings no success too.


texts: Want to play 1 of 3 tracks depending on current level

texts:
I want to play a gameplay music track depending on what the current level is.

E.g.

1 - Play track 1

2 - Play track 1

3 - Play track 2

4 - Play track 2

5 - Play track 3

repeat...

6 - Play track 1

7 - Play track 1

8 - Play track 2

9 - Play track 2

10 - Play track 3

This is what I have, but problem is track 2 will be used at level 6 when it should be track 1.

public static function playGameplayMusic(waveId:Int):Void
{
    var gamePlayTrackId:Int;

    if (waveId % 5 == 0) {
        gamePlayTrackId = 3;
    } else if (waveId % 3 == 0 || waveId % 4 == 0) {
        gamePlayTrackId = 2;
    } else {
        gamePlayTrackId = 1;
    }

    trace('playing gameplay track: ' + gamePlayTrackId);

    SoundPlayer.playMusicByName('gameplay/' + gamePlayTrackId, false);
}

Update:

Went with this. Thanks for all your contributions!

public static function playGameplayMusic(waveId:Int):Void
{
    var gamePlayTrackId:Int = Math.ceil(((waveId - 1) % 5 + 1) / 2);

    SoundPlayer.playMusicByName('gameplay/' + gamePlayTrackId, false);
}


texts: How can I determine which direction a 2D collision is occurring from?

texts:
The problem is as follows:

Think 2D Zelda (Links Awakening, A Link to the Past) style movement where you can run into walls from any of the four cardinal directions, or basically up, down, left, and right. The difference between my movement and these games is I want to allow for diagonal movement as well. When the player collides with a wall on the left, for example, if he is pushing left and up I want him to stop moving left but continue moving up. The problem I am having is my code currently detects the collision as both an upwards and a left collision so the player simply stops. What is the approach I should take to remedy this?

        bool canCollideLeft = false;
        bool canCollideRight = false;
        bool canCollideUp = false;
        bool canCollideDown = false;

        if (HeroRect.Left > OldHeroRect.Left)
        {
            canCollideLeft = false;
            canCollideRight = true;
        }

        if (HeroRect.Left < OldHeroRect.Left)
        {
            canCollideLeft = true;
            canCollideRight = false;
        }

        if (HeroRect.Bottom > OldHeroRect.Bottom)
        {
            canCollideUp = false;
            canCollideDown = true;
        }

        if (HeroRect.Bottom < OldHeroRect.Bottom)
        {
            canCollideUp = true;
            canCollideDown = false;
        }

        foreach (RectangleItemProperties rectangle in CollisionRectangles)
        {
            Rectangle CollisionRect = new Rectangle((int)rectangle.Position.X, (int)rectangle.Position.Y, (int)Math.Abs(rectangle.Width), (int)Math.Abs(rectangle.Height));

            if (HeroRect.Intersects(CollisionRect))
            {
                if (canCollideDown && HeroRect.Bottom >= CollisionRect.Top && HeroRect.Bottom <= CollisionRect.Bottom)
                {
                    hero.position.Y = OldHeroRect.Location.Y;
                }

                if (canCollideUp && HeroRect.Top >= CollisionRect.Top && HeroRect.Top <= CollisionRect.Bottom)
                {
                    hero.position.Y = OldHeroRect.Location.Y;
                }

                if (canCollideLeft && HeroRect.Left <= CollisionRect.Right && HeroRect.Left >= CollisionRect.Left)
                {
                    hero.position.X = OldHeroRect.Location.X ; ;
                }

                if (canCollideRight && HeroRect.Right >= CollisionRect.Left && HeroRect.Right <= CollisionRect.Right )
                {
                    hero.position.X = OldHeroRect.Location.X;
                }
            }
        }

In summary the code compares the old position with the new position to see which direction we have moved and checks for a potential collision there. So if we move up and to the left, canCollideLeft and canCollideUp will be true. I am pretty sure this is where my problem lies and I need to better check which direction I am colliding from.

Any thoughts or insight?


texts: What is the geometrical interpretation of Input.GetAxis("Mouse X")?

texts:
According to the documentation, Input.GetAxis("Mouse X") produces a range of values from -1 to 1. However it will produce another range if it is setup to be  delta mouse movement.

  Returns the value of the virtual axis identified by axisName.

  The value will be in the range -1...1 for keyboard and joystick input. If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.

Question

I don't understand what the value means geometrically. Is it a displacement between two points each in  consecutive frame updates? If so what is its unit? Pixels, points, centimeters, etc?


texts: How do I work out what resolution my backgrounds should be?

texts:
I'm working on a game that's 1200 x 800. The pixels per meter ratio is 1:20. When I add my background texture that is 400 x 225. It fits well in the zone however the lines on the image are pixelated. How can I work out what resolution my background should be in order for it to not look pixelated?

Here's what I have so far:

@Override
public void show() {
   ...
   b1 = new Texture(Gdx.files.internal("backgrounds/spr_stars01.png"), true);
   b1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   ...
}

@Override
public void render(float delta) { //(43, 55, 61)
   ...
   Gdx.gl.glClearColor(132/255f, 0/255f, 35/255f, 1f);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   world.step(TIMESTEP, VELOCITYITERATIONS, POSITIONITERATIONS);
   world.getBodies(bodies);

   camera.position.set(player.getPosition().x, player.getPosition().y, 0);
   camera.update();

   timer += (delta*1.25f);
   batch.setProjectionMatrix(camera.combined);

   batch.begin();
   batch.draw(b1, player.getPosition().x/20, player.getPosition().y/20);
   batch.end();
   ...
}

@Override
public void resize(int width, int height) {
    camera.viewportWidth = 1200 / 20; //60m
    camera.viewportHeight = 800 / 20; //40m
    hud.getViewport().update(width, height);
}

The result:

The original background:

edit: my windows resolutions is 1200x800

edit2: Both answers have helped greatly in understanding background scaling. I have decided to create reusable polygon textures, much smaller than my original background, that I can scale with my box2d world. Thanks for the help!


texts:
How can I add a trigger variable negation in Animation machine's transition in Unity?
I have two transitions.
First happens if jump == false && grounded == true && duck == false && shoot, second happens if jump == false && grounded == true && duck == false && run == false. I want to change the second to the jump == false && grounded == true && duck == false && run == false && !shoot, i.e. add the trigger variable negation in the end.
How can I achieve this?
First

Second


texts:
I have used Gamemaker Studio 2 before, briefly, and found that the xprevious and yprevious variables are extremely useful.

Since I am developing a pixel-based roguelike in LibGDX, what is the best way to implement this? I was using this logic:

Create two variables, x, xprev
In the render loop (or in the player class) make xprev equal to x
change x by player speed
Repeat 2 & 3

However, this seems to be very glitchy. Here is my render function:

player.xprevious = player.position.x;
player.yprevious = player.position.y;

if(movingRight) player.position.x += speed
if(movingLeft) player.position.x -= speed;
if(movingUp) player.position.y += speed;
if(movingDown) player.position.y -= speed;

Since after this code the position is not being changed until the next iteration, player.position.x and player.xprevious should be different?

Right after this, I logged the values of the variables, e.g.:

xprev 716.0, x 716.0   yprev 1435.0, y 1435.0

Help is greatly appreciated! Thanks.


texts: Accessing and changing texture data in SlimDX

texts: How can I access and change texture data in SlimDX?  I have a Texture2D and a Texture3D and I need to be able to go in and change either a single or group of pixels.


texts: Is continuous loop best idea for Android OpenGL game?

texts:
I've done some small OpenGL games for computer. I've used continuous loop (with VSync) for game life cycle, input - update - render. Now i'm going to write simple game for Android, but i'm wondering if it is the right way to go.

What matters? Battery usage, i've played some simple games that used so much battery compared to their complexity and graphics and i don't wanna to create that battery hungry game.


texts: LibGdx table with label children at fixed positions

texts:
I'm trying to make a table containing three labels in each row.

Something like this:

Label1 Label2 Label3

Text1 Text2 LongerText

LongTextLoremIpsum LongTextLoremIpsum LongTextLoremIpsum

Is there a way to fix the position of the labels so that they will be at the same position horizontally regardless of the length of the text in the label?

So far I'm using a table as the root container, and then HorizontalGroup for each row.


texts: Graphical Android game: Bad performance in some situations

texts:
I am developing a simple graphical game for Android (Java and OpenGL ES). There is no high-end graphics involved, basically a few (less than 10) sprites and some (about 10) dynamically drawn primitives. The performance of the game is quite fine, I get about 50-60 FPS on my HTC Desire.

However, there is one specific performance issue. In my game I can fire a characters' gun, which then fires a laser beam that moves over the screen following its velocity vector. This beam is dynmically drawn. The thing is: when I fire the gut the first time, the laser beam is moving very unsteady (its "hopping" over the screen). But, after this first time, when I then fire the gun for how often I like, the laser beam is moving very smooth over the screen.

I first thought this might be an issue with Android's garbage collector. But I double-checked my code. Not one single new object is created within the main game loop, I solely use pre-created objects (i.e. class instances). I also doubt the problem is related to the dynamic drawing of my primitives (laser beam), because as said its working fine and very smooth for every gun shot after the first one. It is solely this first shot where I encounter this performance issue.

So my question is, does this behaviour sound familiar to anyone of you guys? I would appreciate any idea very much.


texts: Unity 5.6 - Compilation Error with UWP using Facebook SDK for Windows

texts:
I built my unity game for UWP and I added winsdkfb to authenticate user with facebook ID. When I build my project in visual studio 2017, it throws an error which is:

  Severity Code Description Project File Line Suppression State Error
  The command ""C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Unity\Tools\AssemblyConverter.exe" -platform=uap
  -lock="C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku Free\project.lock.json" -bits=32 -configuration=Master
  -removeDebuggableAttribute=True -uwpsdk=10.0.15063.0 -path="." -path="D:\Unity5.6\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\dotnet\x86\Master"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\Assembly-CSharp.dll" "C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Kukku Free\Assembly-CSharp-firstpass.dll"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\UnityEngine.dll" "C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Kukku Free\Facebook.Unity.Settings.dll"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\nunit.framework.dll" "C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Kukku Free\GameSparks.dll"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\UnityEngine.UI.dll" "C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Kukku Free\GameSparks.Api.dll"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\UnityEngine.Networking.dll" "C:\Users\saada\Documents\Tap n
  Jump\Build\W10\Kukku Free\Facebook.Unity.dll"
  "C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku
  Free\GameSparksRT.dll"" exited with code 1. Kukku Free
  C:\Users\saada\Documents\Tap n Jump\Build\W10\Kukku Free\Kukku
  Free.csproj 321

When I remove my code which involves facebook authentication, it builds and runs fine. I googled it but didn't find any solution. Any help would be appreciated.


texts:
So I finally perfected my RTS multiple movement. The situation is that the game objects are added into a list in a script bound to the camera called UnitController they are added from a unit client script MultiselectClient, this client accesses the UnitController class and adds itself the gameObject into the list. Each time I do the drag select I want it to clear the list first before adding any more. But for some reason, it doesn't work?

This is in my UnitController (below):

void MultiSelect(RaycastHit hit)
{
    Debug.Log(SelectedUnits);
    if (SelectedUnits.Count > 0)
    {
        Debug.Log("Moving group to: " + hit.point);
        foreach(GameObject gameObject in SelectedUnits)
        {
            gameObject.GetComponent<NavMeshAgent>().SetDestination(hit.point);
        }
    }
}

This is in my client (below):

public bool Selected = false;
void Update()
{
    if (Input.GetMouseButton(0))
    {
        Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
        camPos.y = Screen.height - camPos.y;

        //if inside the cameras drag selection area then mark player as selected
        Selected = UnitController.selection.Contains(camPos);

        Debug.Log("Selected");
        if(selected){
           addTo();
        }
    }

}

void addTo()
{

    UnitController.SelectedUnits.Remove(gameObject); //I have also tried .clear() which also hasnt worked.

    if (!UnitController.SelectedUnits.Contains(gameObject))
    {
        UnitController.SelectedUnits.Add(gameObject);
        Debug.Log("Added to list: " + UnitController.SelectedUnits);
    }
    else
    {
        Debug.Log("Im already in that list.");
    }
}


texts: Why does this code to filter events with SDL not function properly?

texts:
According to the SDL2 wiki,

  SDL_SetEventFilter : Use this function to set up a filter to process all events before they change internal state and are posted to the internal event queue.

  void SDL_SetEventFilter(SDL_EventFilter filter,
                          void*           userdata)

  The function prototype for filter is:
  int YourEventFilter(void*      userdata,
                      SDL_Event* event)

And so, my code as follows is:

`

#include <SDL.h>
#include <stdio.h>
#include <memory>

//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int isMouseEvent(SDL_Event* ev);

int main(int argc, char* args[])
{

    SDL_Event ev;

    //The window we'll be rendering to
    SDL_Window* window = NULL;

    //The surface contained by the window
    SDL_Surface* screenSurface = NULL;

    //Initialize SDL
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
    }
    else
    {

        //Create window
        window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
        if (window == NULL)
        {
            printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
        }
        else
        {

            bool black = false;

            //Get window surface
            screenSurface = SDL_GetWindowSurface(window);
            SDL_SetEventFilter(isMouseEvent);
            bool isOn = true;
            while (isOn)
            {
                //Pump events
                SDL_PumpEvents();

                SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));

                //Update the surface
                SDL_UpdateWindowSurface(window);
            }
        }
    }
    //Destroy window
    SDL_DestroyWindow(window);

    //Quit SDL subsystems
    SDL_Quit();

    return 0;
}

int isMouseEvent(SDL_Event* ev)
{
    if(ev!=NULL) {
        if (ev->type == SDL_MOUSEMOTION)
            return 0;
    }
    return 1;
}

However, when the code is ran no events are filtered, every event passed to isMouseEvent() is null. The SDL2 Wiki is very bare, and the examples on using SDL_SetEventFilter are very basic and do not work properly. Any ideas as to where I should go from here, seeing as the events are constantly null when checked from the isMouseEvent() function?


texts:
My game server will have to respond to requests very often, so I consider threading a good option.

But should I use Task class from .NET or have several threads that would execute requests which I would store in a queue (linked list). Which way would be faster?


texts: Where do I handle my input in a basic game loop?

texts:
I recently had the occasion to work on a game, during a game jam at my college, and it really got me into it, so I've decided to start something more polished with a friend of mine. During the game jam, I made a top-down 2D hack'n'slash with a capped frame rate, thinking it would be easier. However, I ran into some problems for animations, and realized that capping the frame rate wasn't the best solution, as it would also cause the game to run slower on weaker hardware.

I updated the engine, so that it would use variable time steps. However, I've read a lot about patterns, and realized that variable time steps are highly deprecated. After some reading, I thought I'd settle for something like this:

const sf::Time MS_PER_UPDATE = sf::seconds(1 / 60);

sf::RenderWindow window(sf::VideoMode(800, 600), "GameEngine");

sf::Clock clock;
sf::Time lag = sf::milliseconds(0);

while (window.isOpen()) {
    sf::Time elapsed = clock.restart();
    lag += elapsed;
    sf::Event event;
    window.pollEvent(event);

    if (event.type == sf::Event::Closed) {
        window.close();
    }

    // Where to process input?
    while (lag >= MS_PER_UPDATE)
    {
        // Update game logic
        lag -= MS_PER_UPDATE;
    }

    window.clear();
    // Rendering
    window.display();

The question is, where do I handle my input? In my last project, I passed the event polled in the update function (something like update(event, dt)), and handled user input there; I'm wondering if it is actually the way it is supposed to be done. Since I'm only polling one event per frame, I'm wondering if it would significantly affect the user experience.


texts: What does it mean to "strafe" the camera?

texts:
I'm looking at a tutorial in which both the terms camera moving and "strafing" are used. I looked onto dictionary.com and found:

  strafe
  verb (used with object)
  1. to attack (ground troops or installations) by airplanes with
  machine-gun fire.
  2. Slang . to reprimand viciously. –noun
  3. a strafing attack.

WTF???

I'm not a native english speaker.


texts: Script no longer working now that it is attached to a child object. Why is this?

texts:
So I decided I wanted to make this script part of a separate swap-able weapon so I made a child and put the script there. Before the script worked fine but now it won't work. The script works as follows: if the left mouse button is pressed send a ray cast out forward, if it hits something matching the condition (a tag check, and distance check) parent it to the player, and if the right click button is pressed than un-parent it.

The code:

public class PhysGun : MonoBehaviour
{
    public GameObject Player;
    private bool isPlayerHolding;
    private GameObject RayCastHitObject;

    // Update is called once per frame
    void Update()
    {
        Vector3 fwd = transform.forward;

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

        if (Input.GetMouseButton(0) && Physics.Raycast(ray, out hit, 10f) && hit.collider.gameObject.CompareTag("Pickable"))
        {
            Debug.Log("Press detected");
            isPlayerHolding = true;
            hit.transform.SetParent(Player.transform);
            Debug.Log("We hit: " + hit.transform.name);
            hit.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
            MoveScrollWheel();
        }
        if (Input.GetMouseButton(1) && Physics.Raycast(ray, out hit, 10f))
        {
            hit.transform.parent = null;
            isPlayerHolding = false;
            hit.rigidbody.constraints = RigidbodyConstraints.None;
        }
        if (isPlayerHolding != false)
        {
            MoveScrollWheel();
        }
    }

        void MoveScrollWheel ()
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0f) // forward
            {
                Debug.Log("Mouse wheel up");
            }
            else if (Input.GetAxis("Mouse ScrollWheel") < 0f) // backwards
            {
                Debug.Log("Mouse wheel down");
            }
    }
}

What is wrong with my setup?

To clarify a few things...

It's not working - By this mean it does not parent the object to the player like it should.
Steps I've taken to resolve the issue (some are already above)...
Remove tag check requirement - this causes a weird issue no matter where I am it always parents the terrain to the player and causes the player fall through it.
Manually attach the player GameObject to the script.
Detach the child (and make it a sibling) and put in front to see if it works that way (it doesn't).
The raycast is hits something without the tag check (in this case the terrain as described above) but that is totally the wrong thing.
No error messages appear in the console or anywhere.
As per request here is a demonstration of the issue.


texts: Resources to learn XNA for a professional c# developer

texts:
I'm a .net consultant (mainly c#) for my job, but for a while now, I've been interested in making a game in XNA (as a hobby project).

I've had a "beginner" course in XNA when I was still a student, but I've lost most of the information (plus, it was VERY beginner, not enough to get you really started).

So my question, which resources would be useful for me to learn XNA (books, blogs, websites, tutorials, resource websites - like textures, audio files, etc..)?

I know this is a very open question, but I'm thankful for any information.


texts: MonoGame minimises when I click on second game window

texts: I've problem with my MonoGame project. I have one full-screen game window and one window form with some info (part of the game too). And the problem lies in when I click on the window form, the main window is minimised. So my question is, how to let the game window on full-screen.


texts: Unity3D - Screen Capture of particular UI elements

texts:
How can I screenshot particular UI elements?

In my case I need screen capture UI Panel with child objects like UI Text, UI Input and etc.

Please take a look at picture. Thanks in advance


texts: How to calculate a 3x3 rotation matrix from 2 direction vectors?

texts: I've got 2 direction vectors, for the X axis and the Y axis of the object. How do I calculate the rotation matrix of the object using these?


texts: Quick algorithm to identify undrawn rectangles inside a map

texts:
I already have a working algorithm for this but it's home-made and there is some redundancy in the things it checks, so I'm looking for a fast algorithm (or the name of it) that would detect undrawn portions of a 2d map (a picture or a grid), returning those portions as a list of Rectangles which borders are parallel to the axis (x, y, width, height). The map is not very big, like 200x200.

Edit: Rectangles to detect have to be parallel to the axis x and y

For instance ran on this map and looking for space character " " and for 2x3 rectangles :

*C***DDD****
*01F  *E*  *
***   ***  *
**    *    *
*A****  ****
************

It would detect the portions marked with "X":

*C***DDD****
*01FXX*E*XX*
*** XX***XX*
**  XX*  XX*
*A****  ****
************

Has anyone heard of one algorithm like this, but fast? Right now what I'm doing is that I'm scanning through each cell and checking if the w*h Rect at current position is filled with the search value. However you can see there is a lot of redundancy there.

I wonder if some bitmap compression algorithm like PNG don't use that kind of detection, so as to compress repetitions of tiles/uniform areas. If that's the case that should be very fast algorithm they use because speed is an issue for them.

The detection doesn't have to be exact (it's ok if some areas are not detected, but most need to be). So mostly it needs to be very fast.


texts: Could someone help me to develop a method to run any .jar file (with parameters) from in C# with XNA?


texts:
I'm trying to get a simple cannon to rotate to point at the mouse, but I only want it to follow the mouse for 180 degrees and then stop following the mouse, and pick up again when the player re-enters the 180-degree area.
I got the cannon to follow the user's mouse but when I tried to camp it to the 180-degree area I found it worked for one side, but when I went to the other it "teleported" to the other side.

I video to explain my issue: https://imgur.com/a/DZYA305
Sorry about the crude graphics, frame rate, and the software doesn't show my mouse making things more difficult, but as you can see, the clamp works fine when I move my mouse to the right, but when I move it to the left it "teleports" or instantly moves to teh right no matter where my mouse is.

Here is my code:

public int rotationOffset = -90;

    // Update is called once per frame
    void Update()
    {
        var mouse = Input.mousePosition;
        var screenPoint = Camera.main.WorldToScreenPoint(transform.localPosition);
        var offset = new Vector2(mouse.x - screenPoint.x, mouse.y - screenPoint.y);
        var angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
        float finalRotation = angle + rotationOffset;

        // I have tried both the normal Mathf.Clamp and the if statments below and I get the exact same result.
        //finalRotation = Mathf.Clamp(180, 0, finalRotation);

        if (finalRotation >= 89f)
        {
            finalRotation = 89f;
            Debug.Log("Left");
        }

        else if(finalRotation <= -89f)
        {
            finalRotation = -89f;
            Debug.Log("Right");
        }

        transform.rotation = Quaternion.Euler(0, 0, finalRotation);

    }

I don't know if this might be a bug in Unity, But I've spent days trying to fix it, I'm tired, I'm stressed, I don't know how to fix it.


texts: Building a C-E engine in a high level language, how can I integrate optional lower-level components that own overlapping state?

texts:
To clarify, by overlapping I do not mean overlapping between said components, but rather, let's say I have:

My entity contains components, and a parent-children system. Call it a mandatory Hierarchy component if you may.
A Transform component that has x, y, r, sx, sy, and relative properties.
A Drawable component family that is drawn by a RenderingSystem, it uses position information from Transform.
Script components that can read and manipulate position of objects.

Now, what I want to add is a Box2DPhysics component family(shape(s), body) and a Box2DPhysicsSystem that internally just updates the physics world, but the problem is: The Transform component is not compatible with that. Box2D has its own internal position, rotation, velocity information, that here can only be accessed via getter and setter methods. Now, it's not impossible for me to wrap the Transform component's fields and methods to use said getters/setters, but then I'm implementing half of the functionality in the Transform component...

Now, what should I do? Some options that come to my mind would be:

Make the physics component override the Transform component, somehow. Either by writing its position info into Transform every frame, or something like that
Allow some components to be two or more subcomponent, such as Box2DPhysics being both a Physics component and a Transform component.
Not use Box2D whatsoever, write my own verlet-based physics engine, likely significantly slower, but functional and fully interoperational with the rest of the code.
"Freeze" some of the components and functionality, effectively making it 100% built-in - prohibit the user from replacing or implementing few basic most important components, and handle things like this interally.

I feel like personally I'm leaning towards #2, but honestly, I just don't know. It's probably my anxiety/indecisiveness that is at fault, but I feel like I simply cannot proceed without getting someone's opinion.


texts:
I have some trouble finding out how I can load my character at the start of the level, instead of resetting the whole thing. The game mechanics are quite straight forward; don't touch the walls. If the player touches the walls, he "pops" (seeing as it is a balloon.)

This is my current script:

public class playerSpawner : MonoBehaviour {

public Sprite charAlive, charDead;
public AudioClip popAudio;

void  OnCollisionEnter2D (Collision2D col ){

    if (col.gameObject.name == "dirtWalls") {
        AudioSource.PlayClipAtPoint(popAudio, transform.position);
        gameObject.GetComponent<SpriteRenderer>().sprite = charDead;
        StartCoroutine (Dead ());
    }
    if (col.gameObject.name == "gooWalls") {
        gameObject.GetComponent<SpriteRenderer>().sprite = charDead;
        StartCoroutine (Dead ());
    }
    if (col.gameObject.name == "grassWalls") {
        gameObject.GetComponent<SpriteRenderer>().sprite = charDead;
        StartCoroutine (Dead ());
    }
}

IEnumerator Dead() {

    AudioSource.PlayClipAtPoint(popAudio, transform.position); // PLAYS SEVERAL TIMES
    yield return new WaitForSeconds(3/2);
    Application.LoadLevel ("untitled");
    // LOAD LEVEL RESETS EVERYTHING, MAKE LOAD CHAR INSTEAD?
}

}

How can I just respawn the player object instead of resetting the whole scene?


texts: How is the value of transform.position updated and accessed between different private methods?

texts:
I followed this YouTube video but I'm still confused about how the code actually retrieves the value of transform.position.
I can understand the Camera.main.ScreenToWorldPoint code is to transform the screen position to a position in the world based on the camera's view, and it then uses this to update the transform.position as in the private void OnMouseDrag method.
However, I also learnt that since the method is declared as private, the "transform.position" cannot retrieve the value of "transform.position" in each {}bracket.
So how does the value of "transform.position" in private void OnMouseUp, private void Awake get updated, unless I misunderstood the concept?
using UnityEngine;

using UnityEngine.Assertions.Must;

using UnityEngine.SceneManagement;

public class GreenBird : MonoBehaviour

{
    Vector3 _initialPosition;
    private bool _birdWasLaunched;
    [SerializeField]private float _launchPower = 500;

    private void Awake()
    {

        _initialPosition = transform.position;
    }

    void Update()
    {
        if (_birdWasLaunched &&
                 GetComponent<Rigidbody2D>().velocity.magnitude <= 0.1)
        {
            timeSittingAround += Time.deltaTime;
        }

        if (transform.position.y > 10.00 ||
            transform.position.y < -10.00 || transform.position.x > 10 || transform.position.x <-10)
        {
            string currentSceneName = SceneManager.GetActiveScene().name;
            SceneManager.LoadScene(currentSceneName);
        }

    }

     void OnMouseDown()
    {
        GetComponent<SpriteRenderer>().color = Color.red;

    }

    private void OnMouseUp()
    {
        GetComponent<SpriteRenderer>().color = Color.white;
        Vector2 directionToInitialPosition = _initialPosition - transform.position;
        GetComponent<Rigidbody2D>().AddForce(directionToInitialPosition * _launchPower);
        GetComponent<Rigidbody2D>().gravityScale = 1;
        _birdWasLaunched = true;

    }

    private void OnMouseDrag()
    {
        Vector3 newPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector3(newPosition.x, newPosition.y);

    }
}


texts: Why are my sprite sheet's frames not visible in Cocos Builder?

texts:
I have created a sprite sheet with zwoptex. Then I just dragged the .plist and .png files to my Cocos Builder project. After this I wanted to take a sprite frame and set it to a sprite:

But the sprite image is empty! At first I thought it was just empty in Cocos Builder, and that it must have been working correctly when imported to a project. But if I try to run that scene with CCBReader I still see an empty sprite. Why?


texts: What takes up more processing power between whole character models or models that are pieced together in Unity?

texts:
In terms of performance when it comes to animation what takes up more processing power: Whole character models or models that are pieced together? (1 object vs multiple objects).

I also wonder if animating multiple objects allows us to get a better overall animation quality instead of working with one object (especially if we deal with action packed scenes).


texts: Other methods to save data than PlayerPrefs?

texts:
I've been saving data using the playerPrefs option in Unity till now.
Is there any better/secure way of saving data for developing mobile games.
Somes sites have mentioned encryption of data - how do I approach that?


texts:
How do I rotate the object only once after a key press. So after it rotates say 10 degrees upwards, the user can't rotate it anymore.

this is my code which as continuous rotation -:

   void Update(){
 if (Input.GetKey(KeyCode.J))
     transform.Rotate(0, 0, 3f);
  }


texts:
I'm trying to create a custom name laucher for Minecraft. I run an offline server and was wanting to give some of my friends a laucher to use so they can play. I have done this before with a batch file. Now I'm using JavaUI and I'm trying to start Minecraft from the Java program. I have yet to get Minecraft to pop up.

Here is the code i am using:

if (e.getSource() == app.startNorm){
    List<String> command = new ArrayList<String>();
    command.add("java");
    command.add("-jar");
    command.add(System.getenv("APPDATA") + "\\.minecraft\\bin\\* -Djava.library.path=\"" + System.getenv("APPDATA") + "\\.minecraft\\bin\\natives\" net.minecraft.client.Minecraft CustomNameHere");
    try{
        //line below wont work
        ProcessBuilder builder = new ProcessBuilder(command);
        Process proc = builder.start();
        app.setSize(500, 300);
        app.process.setVisible(true);
        app.memory.setVisible(false);
        app.start.setVisible(false);
        InputStream in = proc.getInputStream();
    } catch (IOException e1) {
        //always get dialog, when not never see minecraft pop up
        JOptionPane.showMessageDialog(null, "There was a problem with starting Minecraft");
    }
}

I was hoping someone could show me how to get this, or any other way to lauch Minecraft from inside my program.


texts: How to implement auto-aiming / auto-targeting

texts:
We all know how auto-aiming or auto-targeting works in games.

Now, I need to find how to implement it in my game.

In fact I should implement it in UDK and I would be glad if anyone gave me more specific explanation for UDK. But conceptual explanation is also enjoyable and I'll implement it myself in my way.


texts: Trouble with Lightmaps When Meshes Intersect

texts:
I've been working on making lightmaps for a game on mobile devices (meaning that individual texture sizes cannot exceed 2048 and that file size needs to be as small as possible), but I'm running into some problems that I cannot seem to fix.

The most glaring problem (as can bee seen in the attached picture), is the appearance of these "rough edges" (I'm not sure what to call them) that appear on or around certain objects that occur wherever two meshes intersect with eachother. During rendered previews, both by camera and Rendered Mode, the quality of the lights and shadows look just fine, it is only after baking that these problems are visible.

I've tried simply making the lightmap textures larger, but even that does not remove the problem, not to mention that even the roughly 3x3 foot rock in the picture is using a 512 image just for that 1 rock (and giving each object in the scene a individual lightmap will create a massive game size for a mobile device). I've tried playing with AO and Environment Lighting, and I've tried changing lamp light settings and have not made any progress.

Any ideas on how to fix or improve this result are appreciated.

Other Notes:
-I'm using Full Render on baking, with margins at 8 (I've set them to 15 and have not noticed any difference).
-I'm using Bledner 2.69


texts: Mapping simulated onto real with a Kinect and projector

texts:
I have this partially working already, but my implementation doesn't animate very well (lots of jitter, some random movements) and I thought that you guys in Game Development might be able to point me in the right direction.

I have a "Listener" application that listens to updates from the Kinect, finds the object in the frame, and sends an update of that objects location. (I just care about x/y in my case, not the z axis)
In a separate "Projector" program I listen for that update, and update the actual position of the object in my model.
In the "Projector" program there is also a rendering thread, triggered once per screen update, that attempts to move the projected object smoothly along the path of the real object using that model. (trying to project the image on top of the real object)

The problem I need to solve is: How do I track the object's real location with my projected object in a way that animates smoothly?

The kinect updates the location at 30 FPS, the render cycle happens at 60 FPS (on a ui thread), but I'm trying to project on top of my object as best I can while keeping the rendered image moving smoothly. (right now it tracks with the object but jitters quite a lot)  I came across http://gafferongames.com/game-physics/integration-basics/ on the RK4 algorthim, which is probably more complex than I need but I wasn't able to implement it correctly for my case. (likely because I don't fully understand it)


texts:
I am trying to make it so that when a user hovers over an image on my JPanel, the image turns into a different image. I have 2 classes, one for the JPanel and the other is for the gameplay (snake game). How do I implement the mouseListener to make it so that the image changes on hover?

snake.java (main):

public class snake {

    public static int mouseX;
    public static int mouseY;

    public static void main(String[] args) {

        // JFrame
        JFrame obj = new JFrame("Snake");
        gameplay Gameplay = new gameplay();
        obj.setBounds(10, 10, 905, 700);
        obj.setBackground(Color.DARK_GRAY);
        obj.setResizable(false);
        obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        obj.add(Gameplay);
        obj.setVisible(true);

        obj.addMouseMotionListener(new MouseAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                mouseX = e.getX();
                mouseY = e.getY();
            }
        });

    }
}

Image I want to change:

    settingsImage = new ImageIcon(getClass().getResource("/assets/settings.png"));
    settingsImage.paintIcon(this, g, 700, 23);

If you need to see any of my other code please tell me!


texts: Unity3D - Android build has no Internet Access

texts:
I'm having trouble connecting to the internet in an Android build.
I created a simple program that checks if there is an connection. Also I set in 'Edit > Project Settings > Player' the Internet Access to Require. But there is still no sign of connection in the app. Does anyone know what the problem is? Thank in Advance!

public class CheckInternet : MonoBehaviour {

    private bool isInternet = false;
    public Text ConnectedText;
    public Text IntText;
    int i = 0;
    // Use this for initialization
    void Start () {

    }

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

        StartCoroutine (TestInternet());
        IntText.text = i++ + "";
        if (isInternet) {
            ConnectedText.text = "Connected";
        } else {
            ConnectedText.text = "Not Connected";
        }
    }

    IEnumerator TestInternet(){
        WWW internet = new WWW("www.google.com");
        yield return internet;
        if(internet.error!=null)
            isInternet=false;
        else
            isInternet=true;

    }
 }

Source

In the Play-Modes it had internet access:

And in the Android Build it has not Internet Access:


texts: Autodesk Kynapse and Havok AI comparison

texts:
Kynapse

  Autodesk® Kynapse® game middleware is a leading artificial intelligence (AI) solution for game development and the creation of real-time simulations for nonplayer characters (NPCs).

Havok AI

  Havok AI is a new platform-optimized SDK focused on efficient pathfinding and path following. Havok AI is built from the ground up to consider dynamically changing environments.

Information about both of these middleware solutions is limited.  I was looking for pros and cons of using either.  As well as any type of comparison between both middleware packages.

In particular:

Pros
Cons
Features
Experience with using
Difficulty
Latency of response
Clock cycle utilization
API/tutorial documentation
Source code included? or binary
Supported platforms
Supported languages
etc

A good response should be fact based, and any subjective subjects like difficulty should be based on an explained experiences with the product.


texts: How would I go about generating a star map?

texts:
Im trying to generate a star map.

My try would be:

Have a width and height for the map.
Place points (stars) randomly across the area of width and height.

A simple approach, but it has the problem of randomly placing stars extremely close to each other.

To solve this problem, one approach would be to have a minimum distance and when generating a star, you compare the distance from the new star to every generated star and if its below minimum distance, you generate a new one, but I dont know if thats efficient. Any tips?


texts: How can you extract orientation from a transformation matrix?

texts:
I have a 4x4 transformation matrix M, and I want to find out the shape of a sphere when transformed by M. (Sphere is at the origin and has radius 1.)

I know I can find the center by just multiplying M by (0,0,0,1).

However, the radius becomes a problem as M can squash and rotate the sphere.  How can I find out the new radius(es) of the resulting ellipsoid?  Is there any way to find out the orientation?

More specifically, I need to know the size of the bounding sphere which would enclose the transformed sphere.  In other words, what is the maximum of |M*V - M*(0,0,0,1)|, where V is a unit vector (a point on the original sphere).


texts:
I am trying to solve the following game http://www.hacker.org/brick/ using some kind of AI.
The target of this game is to finally clear the board by clicking on groups of at least 3 bricks of the same color and removing them.
If a group is disappearing the remaining bricks above will fall down or be moved left if a column got no bricks left.
The higher the level -> more colors and larger board.

I already guessed that a pure bruteforce approach wont scale nice for higher levels. So i tried to implement a monte carlo like approach which worked ok for the first levels. But i am still not confident i will make the maximum level of 1052 with this.
Currently i am stuck @~ level 100 :) The finding of the solution takes too much time...

Hoping that there is a better way to do this i read some stuff about neural networks but i am really at the beginning of this. Before becoming obsessed by ANNs i want to be sure it is the right way for my problem.

So my question is: Does it make any sense to apply an ANN to this game?
Any suggestions?


texts: GenerateProjectFile error Referenced directory [...] does not exist

texts:
I am following this tutorial to install Unreal Engine 4.22 from GitHub on Windows. I forked the project and cloned it on my computer. I've executed Setup.bat and everything went fine, but when I execute GenerateProjectFiles.bat I get all these errors:

PS D:\software\UnrealEngine> .\GenerateProjectFiles.bat
Setting up Unreal Engine 4 project files...
Binding IntelliSense data...
D:\software\UnrealEngine\Engine\Source\ThirdParty\IntelTBB\IntelTBB.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\IntelTBB\IntelTBB-4.4u3\Include' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\DirectShow\DirectShow.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\DirectShow\DirectShow-1.0.0\Lib\Win64\vs2015' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\Ogg\UEOgg.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Ogg\libogg-1.2.2\lib\Win64\VS2015' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\Vorbis\Vorbis.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Vorbis\libvorbis-1.3.2\Lib\win64\VS2015' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\Vorbis\VorbisFile.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Vorbis\libvorbis-1.3.2\Lib\win64\VS2015' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\OpenSSL\OpenSSL.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\OpenSSL\1.1.1\include\Win64\VS2015' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\OpenSSL\OpenSSL.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\OpenSSL\1.1.1\lib\Win64\VS2015\Release' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\Kiss_FFT\Kiss_FFT.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Kiss_FFT\kiss_fft129\lib\x64\VS2015\Release' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\VHACD\VHACD.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\VHACD\lib\Win64\VS2015' does not exist.
D:\software\UnrealEngine\Engine\Plugins\Experimental\ProxyLODPlugin\Source\ThirdParty\OpenVDB.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\IntelTBB\IntelTBB-4.4u3\include' does not exist.
D:\software\UnrealEngine\Engine\Source\ThirdParty\Qualcomm\TextureConverter\QualcommTextureConverter.build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Qualcomm\TextureConverter\Lib\vs2015\x64' does not exist.
Binding IntelliSense data... 0%ImportError: No module named site
Python SDK not found
D:\software\UnrealEngine\Engine\Plugins\Runtime\LeapMotion\Source\LeapMotion\LeapMotion.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Source\ThirdParty\Leap\Include' does not exist.
D:\software\UnrealEngine\Engine\Plugins\Runtime\nDisplay\Source\DisplayCluster\DisplayCluster.Build.cs: warning: Referenced directory 'D:\software\UnrealEngine\Engine\Plugins\Runtime\nDisplay\ThirdParty\VRPN\Include' does not exist.
Binding IntelliSense data... 100%
Writing project files... 100%
PS D:\software\UnrealEngine>

At the end of this command it creates a UE4.sln (but no UE4.v12.suo file) but when I try to compile the project on Visual Studio 2019 I get plenty of errors that are quite reminiscent of the ones above, so I assume the problem comes from the generation of the project files.

How can I fix this problem?

Thank you for your help.


texts:
So I am drawing an inventory with slots like so:

private void DrawItemSlotAndAttachActions(Item currentItem, Rect slotRectangle, Event e, int itemSlotPosition)
    {
    if (!(currentItem is EmptyItem))
        {

            GUI.depth = 0;
            GUI.DrawTexture(slotRectangle, currentItem.Icon);
            if (slotRectangle.Contains(e.mousePosition))
            {
                _tooltip = currentItem.CreateTooltip();
                _showTooltip = true;

                DragAndDropItem(e, itemSlotPosition);
                UseConsumable(e, currentItem);
            }
        }
        else
        {
            DropItemOnEmptySlot(slotRectangle, e, itemSlotPosition);
        }
    }

    public void OnGUI()
    {
        _tooltip = ""; //reset every time...can this be done better?
        GUI.skin = Skin;

        DrawItemSlotAndAttachActions(.....);
        ShowTooltip();
    }

    private void ShowTooltip()
    {
        if (_showTooltip)
        {
            GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 200, 150), _tooltip,
                Skin.GetStyle("Tooltip"));
        }
    }

    private void HideToolTipWhenEmpty()
    {
        if (string.IsNullOrEmpty(_tooltip))
            _showTooltip = false;
    }

In here I have the problem that when I hoven over an item, all the boxes that are drawn after are on top of my tooltip Box.

How can I make sure that the box is drawn on top of all the rest?

Screenshot:

As you can see, it is still behind the rest of the buttons.


texts:
I have a question about something I don't really understand.
In OpenTK, should I have shaders? Is it frowned upon not to? What are the pros and cons of having shaders?
Can I go perfectly fine without having anything to do with vertex or fragment shaders?


texts: How can we make our character move smoothly across tiles? He moves tile by tile, but that looks unprofessional. In addition, when you hold down the arrow keys he zips across the screen. How can we prevent that from happening?


texts: In a TPS, how to aim bullets to the direction the camera is pointing, but make the shooting from the player?

texts:
(In C#/XNA.) I mean, I can't find an answer nowhere. I'm trying to learn how to make a Third Person Shooter, especially like the one I found in a game called "M.A.R.S.", from Epic Games. I don't want to remake that game, I just want to understand how the Third Person works.

There, the screen aims to a direction, has a crosshair and its center stays right next to the player, slightly above the shoulder. And the player aims to that same direction the screen aims, pointing to that.

What I don't understand is how the bullets the player shoot go to that direction if the player is not aiming from the same position the camera is (or is it?).

For now, in my game, I can only select things that are in front of the player, having his own View Direction (a Vector3) which follows camera's WorldMatrix.Forward and applying a Ray from the player to that direction. So if I change the direction of the camera, the player will select things in front of him, following the camera direction.

And it doesn't work to be a shooter, because if I put a crosshair in the center of the screen, the player won't shoot there but to his own front.

Thanks for any help. I'm still searching, but even here I couldn't find what I want yet.

EDIT: what I found in this link is how to make the Ray cast come out from the camera. But how much should I rotate the character's view direction so its Ray goes to the same point the camera's one goes? So the Rays make something like this: /|.

EDIT 2:
Now I'm testing some code. The closest way I created until now is this.

            Game.ActiveCamera.FollowPosition = Player.Position;
            Game.ActiveCamera.FollowReference.Y = Player.Race.Height * 0.5f;

            Vector3 target = Player.Position;
            target.Y += Game.ActiveCamera.FollowReference.Y;
            target += (Player.ViewDirection * Game.ActiveCamera.FarPlaneDistance);
            //if (Game.Input.KeyHeld(Keys.F2))
            //    Game.ActiveCamera.Target = Game.ActiveCamera.Position + Game.ActiveCamera.WorldMatrix.Forward;
            //else
            Game.ActiveCamera.Target = target;
                //MathConverter.Convert(Player.Character.Body.Position + Player.Character.ViewDirection * 10);

I use a chasing camera that follows the FollowPosition. It has an Offset with X and Z, and I change Y to stay right above the character's shoulder.

Then the camera's target, which is the problem, I'm using the Player's Position plus its Forward (ViewDirection) times the camera's FarPlaneDistance, so the camera aims far away to the same point the character aims.

But I still don't know if the bullets are going to respect the crosshair on the screen this way.


texts: Player rewards in games where you normally have nothing to purchase

texts:
In many games there are rewards such as gold coins, points, etc. When these rewards can be used to purchase in-game items, it motivates the player to keep playing.

Let's say we have an online game, poker, Yatzy etc.  What type of reward would keep the players playing if there are few in-game items available to buy, or none at all?

What I am looking for is a reward system that entices the players to play more in a game environment where there isn't that much to purchase. For example, there isn't much to buy in a poker or Yatzy game with the gold you win.

I guess having some titles that are added to the userid is one way, or maybe purchasing a logo for the id... A leaderboard is another.

Any thoughts on this?


texts:
I'm checking to see if the ray that I've created is intersecting with a rectangle. I'm using the boundingbox class to pass the rectangle into the intersect method in the Ray class, but unfortunately it isn't working I'm wondering if it has something to do with how I constructed either the boundingbox or the Ray.

The code is below, any help with this would be great.

  Ray bulletRay = new Ray(new Vector3(lensPosition, 0.0f), (new Vector3(lensPosition, 0.0f) - new Vector3(level.Player.Position.X, level.Player.Position.Y - 32.0f, 0.0f)));

Rectangle tileBounds = Level.GetBounds(x, y);
                        BoundingBox box = new BoundingBox(
                        new Vector3(tileBounds.Left, tileBounds.Top, 0), // Front = 0
                        new Vector3(tileBounds.Right, tileBounds.Bottom, 0)); // Back = 0

                        float? output;

                        bulletRay.Intersects(ref box,out output);
                        if (output.HasValue)
                        {
                          wallInWay = true;
                        }


texts:
My world is procedurally generated. As the player moves, chunks behind them are unloaded and chunks in front of them are loaded. Each chunk has a mesh of triangles.

At the moment, I create two VBOs for each chunk (vertices and colours), when the chunk is loaded. Once a mesh is created, it is only edited every few seconds. These buffers are deleted when the chunk is no longer visible.

Am I leaking memory here by constantly creating and destroying buffers?

I've heard somewhere that OpenGL (or WebGL in this case) doesn't do garbage collection until the program quits, due to it being slow. Is this right?

Could I improve this system somehow?


texts:
I already have an hemisphere.obj 3D model. But I'm trying to build a half-hemisphere (quarter sphere) model. How can I do that? What is the easiest way to do that?

Generally, is there any easy way to create 1/n of sphere?


texts:
A little problem with my tessellation shader. I try to implement a simple tessellation shader but it only makes points.

Here's my vertex shader :

out vec4 ecPosition;
out vec3 ecNormal;
void main( void )
{
    vec4 position = gl_Vertex;

    gl_Position = gl_ModelViewProjectionMatrix * position;
    ecPosition  = gl_ModelViewMatrix * position;
    ecNormal    = normalize(gl_NormalMatrix * gl_Normal);
}

My tessellation control shader :

layout(vertices = 3) out;
out vec4 ecPosition3[];
in vec3 ecNormal[];
in vec4 ecPosition[];
out vec3 myNormal[];
void main()
{
    gl_out[gl_InvocationID].gl_Position =  gl_in[gl_InvocationID].gl_Position;
    myNormal[gl_InvocationID] = ecNormal[gl_InvocationID];
    ecPosition3[gl_InvocationID] = ecPosition[gl_InvocationID];
    gl_TessLevelOuter[0] = float(4.0);
    gl_TessLevelOuter[1] = float(4.0);
    gl_TessLevelOuter[2] = float(4.0);
    gl_TessLevelInner[0] = float(4.0);
}

And my Tessellation Evaluation shader:

layout(triangles, equal_spacing, ccw) in;
in vec3 myNormal[];
in vec4 ecPosition3[];
out vec3 ecNormal;
out vec4 ecPosition;

void main()
{
    float u = gl_TessCoord.x;
    float v = gl_TessCoord.y;
    float w = gl_TessCoord.z;
    vec3 position = vec4(gl_in[0].gl_Position.xyz * u +
                 gl_in[1].gl_Position.xyz * v +
                 gl_in[2].gl_Position.xyz * w );
    vec3 position2 = vec4(ecPosition3[0].xyz * u +
                  ecPosition3[1].xyz * v +
                  ecPosition3[2].xyz * w );
    vec3 normal = myNormal[0] * u +
              myNormal[1] * v +
              myNormal[2] * w );
    ecNormal = normal;
    gl_Position = vec4(position, 1.0);
    ecPosition = vec4(position2, 1.0);
}

A screenshot:


texts: How to refactor and improve this XNA mouse input code?

texts:
Currently I have something like this:

public bool IsLeftMouseButtonDown()
{
    return currentMouseState.LeftButton == ButtonState.Pressed && previousMouseSate.LeftButton == ButtonState.Pressed;
}

public bool IsLeftMouseButtonPressed()
{
    return currentMouseState.LeftButton == ButtonState.Pressed && previousMouseSate.LeftButton == ButtonState.Released;
}

public bool IsLeftMouseButtonUp()
{
    return currentMouseState.LeftButton == ButtonState.Released && previousMouseSate.LeftButton == ButtonState.Released;
}

public bool IsLeftMouseButtonReleased()
{
    return currentMouseState.LeftButton == ButtonState.Released && previousMouseSate.LeftButton == ButtonState.Pressed;
}

This is fine. In fact, I kind of like it. However, I'd hate to have to repeat this same code five times (for right, middle, X1, X2). Is there any way to pass in the button I want to the function so I could have something like this?

public bool IsMouseButtonDown(MouseButton button)
{
    return currentMouseState.IsPressed(button) &&  previousMouseState.IsPressed(button);
}

public bool IsMouseButtonPressed(MouseButton button)
{
    return currentMouseState.IsPressed(button) &&  !previousMouseState.IsPressed(button);
}

public bool IsMouseButtonUp(MouseButton button)
{
    return !currentMouseState.IsPressed(button) &&  previousMouseState.IsPressed(button);
}

public bool IsMouseButtonReleased(MouseButton button)
{
    return !currentMouseState.IsPressed(button) &&  previousMouseState.IsPressed(button);
}

I suppose I could create some custom enumeration and switch through it in each function, but I'd like to first see if there is a built-in solution or a better way..

Thanks!


texts: Gameobject-Component model with many background tiles - long iteration time

texts:
So I'm making a game engine for a game I'm making - the game is a 2D tile-based game

I've implemented a gameobject-component style for the engine, for decoupling reasons

However, every frame, the engine iterates through every gameobject, and calls the update method of every component on that gameobject - as it's a tile-based game, every tile is a gameobject, which means that that update loop could go through several thousand gameobjects every frame. Add into that the fact that each gameobject could have multiple components (transform component containing location/rotation info, renderer component, collider component etc), and a hell of a lot of time is spent in that loop. This is only magnified by the fact that the game is a mobile game, and as such the processing power isn't as great as on a desktop

Any ideas on algorithms/programming styles/design styles that would help to minimise this performance sinkhole please?


texts: How to rotate a 3D character on top of a plane with an isometric picture on it

texts:
How to calculate the angles of the 3d charater so that it fits into the isometric environment projektet on a 2d plane?
Also, how do you calculate the rotation of my character?
What I want to achieve:

Describing the scenario:


texts: How can use a 3D map with 2D characters (Unity)?

texts:
I tried to search something about it but I can't find any complete or well-explained tutorials about how to use a 3D map with 2D characters and items, like Ragnarok or Final Fantasy Tactics.

If there is no tutorials about this topic, are there any recommendations for studying the subject? I've already developed some games using XNA, but only 2D games, I've never tried to use 3D models, nor have I used Unity to develop games.


texts:
I should say first, that I have the rotation down. Its just that I want my square to rotate exactly 180 degrees. Currently, it will rotate but it will rotate but by less each jump. So after several jumps it will be moving on one of its side.
There's not much code to show but I'll show you how I'm rotating:

if (jumped)
        {
            roation += 0.1f;
            playerVel.Y += gravity;
        }

I haven't initialized rotation to anything.
I've also tried using some Math functions but I just get the same result.


texts: Am I allowed to push my Unity based game's source code to github?

texts:
I got the Personal version of Unity 5.5 to play around with it1. Let's say I own the rights on all the assets I use in my project, or they are licensed in a way that allows me to use, modify and republish them. That includes all the scripts, models, images, sounds and whatnot. But what about the fact that it's built with a commercial game engine?

Do the Unity terms allow me to host my project's source folder (including the assets) on github? Do I need to include a certain license for that?

Note that I don't care about releasing the game, I'm just talking about sources of stuff I am making to learn the technology.

1) no pun intended


texts:
I'm designing a game that depends heavily on audio; I will have some 300+ speech files (most of them just a word or two long). This can very quickly escalate the size of my final game.

What's the optimal way to encode/compress speech files to keep the size minimal without getting audio artifacts?

Please address both per-file compression/encoding, and also zipping/compressing the set of all speech files together in your answer. Because I'm not sure which (or combination of both) factors will give me the best results.

Edit: I need this to run in Silverlight and Android, so I'm presumably stuck with only MP3 as my option (other than uncompressed wave files).


texts:
Quaternion objectRotation = Quaternion.identity;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
objectRotation *= rotation;

gameObject.transform.rotation *= objectRotation;

here angle = -90

But the gameobject isn't rotating as desired,
when I replaced

gameObject.transform.rotation *= objectRotation;

with

 gameObject.transform.Rotate (0,0,angle);

Then the gameobject rotated -90 degree, dont understand why the Quaternion part isn't working? It rotated 90 degrees


texts:
I'm having a bit of trouble developing code to figure out which doors connect in Rogue which is written in c. Not the actual path making. I just dont understand how they link to each other.

If rooms have 2 doors each then, while not the cleanest solution, I can connect the first rooms door1 to the second rooms door2 and continue that pattern, finally going around in a loop.

However, say there are 3 doors for one room, then that would break because one door wouldnt connect to anything. The same thing goes for a one door room.

Any help would be appreciated and links to examples would help too.

Thanks

EDIT

I'm not really generating paths right now, its more of the player teleporting to another door. If it were paths then of course it could intersect which takes care of the paths.


texts: How can I separate component functionality from networking logic?

texts:
Is it possible to make network independent components that allow networking details to be specified externally?

For example, if I have a "Follow" script that follows a game object, it would need to do certain actions on the server and certain actions on the client. However, these things can change based on the network architecture. Single player games would not even need to consider what runs where. That makes perfect sense, except why should a component as general as "Follow" need to be different across different types of game?

I've tried creating a base component class that figures out how to call each method based on options set in the editor, but that failed due to RPC names needing to be different across all components attached to one game object. Not to mention it was messy. I've tried abstracting method calls to figure out how they should be called, but that doesn't solve the problem of WHICH methods should be network invoked.

I really don't want to build this into the components themselves, even though it might be the easiest / most obvious solution. That would destroy their portability across projects.


texts: Is this possible to edit the Unity app through inspector while running on Android device?

texts:
When on PC, I can run the app and edit things temporarily through the inspector.

I know that I can attach the Android ADB and the profiler, but is there any option to edit objects through the inspector while running on the emulator/physical device?


texts:
I was reading this answer on the type of math a game developer should know and this part really stood out at me:

How do I move my game object? The novice might say:

"I know! I'll just do:" object.position.x++.

That is how I would think to do it so I guess that shows my skill level. At least for the types of 2D side-scrolling, arcade-style games that I've made in the past, that's all I needed.  That and a bit of trigonometry.

In fact, I haven't used much linear algebra or even heard of quaternions before reading that post.  Is it because these math don't show up until you work with 3D or is it because my 2D games are fairly simple that I got away with naive implementations.

Follow up question: If I want to get familiar with that type of math, what type of projects should I undertake? IE: write a game engine, work on a 3D game, etc.


texts: What is the state of the art in procedural character animations?

texts:
I'm a programmer and I'm interested in programmatic character animation — walking or running, bipedal or many-legged: what is the state of the art today?

I heard about NaturalMotion's Euphoria system and Ubisoft's IK Rig, and they look amazing. Where can I find more info about similar algorithms?


texts:
I have a 2d player who can only walk on black area. There is a red collider so player can't walk past it.

Player has capsule collider.

The problem is player can't walk toward the edge with his feets becasue of the it's collider. But player would probably want to walk toward the edge.

Here is a sketch I've made.

Is there a way to tweak this ?


texts: Unable to use Maya animation with scripts when imported to Unity

texts:
I am testing to import Maya animation over to Unity. I set up a simple cylinder with 2 bones and an IK handle. Made a simple animation where the cylinder bends and goes back to straight position over 24 frames.

Following that, I selected everything and baked, all bones,ik,(animation by selecting all at the graph editor) and even the cylinder. I saved the scene and then select all and export as FBX with animation and bake checked.

In unity imported it and at the preview able to see the animation. When I load the model into scene and play (after assigning the controller), able to see animation too.

But now when I try to script it and control the animation, nothing happens. Even to test, I tried the following under the Update method.

if(animation.isPlaying)
    Debug.Log("Animation Works");
else
   Debug.Log("Animation not working");

The bool doesn't even return true nor false. My animation is called "bend", thus just for try I did the following and nothing happens.

animation.Play("bend");

Can please advice based on my steps, am I missing something. Do I need to add the controller or is that an unnecessary step? Did I screw up on the Maya part or the Unity part. Thanks for help.


texts: Authenticating users without a username or password

texts:
I'm curious about what the process is for anonymously authenticating users when it comes to mobile games. There are quite a few examples out there, but the ones that immediately come to mind are Lords Mobile, Family Guy: Quest for Stuff, and Clash of Clans. When you first open the game, you're assigned an account id and that id is tied to your device until you choose to register an account with a password or sign in through some SSO service.

In that initial step where you're not creating a password or using SSO, how are these games making sure the requests are from both the user/device that they come from? Or is it that they actually don't?

I can imagine a simple setup where you're providing a key that needs to be refreshed every now and then just like you would with something like OAuth, but other than that you don't care that the user is who they say they are. After all, you're dealing with a request that already has to be validated for legality within the game rules.


texts:
I want to know how to create good AI for a Java game,  I'm still learning the language and I'm not an expert.
I can do static AI but wanna know about  writing an AI that follows the player and considers how to reach him via pathfinding.


texts: How can I fetch a list of games and DLC for a user via Steam's API?

texts:
We're trying to figure out how to fetch a list of all games and DLC owned by a Steam user using that user's Steam ID.

There is a method for fetching a list of games for an account by using the Steam Web API but this does not include any DLC. Another option is to use the public community XML data provided by Steam.

The problem with this is first of all that this information can be made public/non-public so we can't be sure to get the whole picture. Also this way of fetching data is flagged as deprecated by Steam.

Does anyone know of a way to achieve this using supported Steam APIs?


texts: How can I create random noise that is seamless across modular game assets?

texts:
Does anyone know how I can create a texture for a modular tile, such that when the tiles are arranged, random weathering effects such as scratches will be continuous across seams?

An example photo below shows the ideal result. The scratches are continuous between different tiles. Is creating weathering effects like this possible using any procedural software?


texts: Possibly a more efficient way to structure my game's map?

texts:
I need a little help with structuring my map. I want to make it efficient but I'm not sure if there's a better way to do this:

public class Map
{
    Chunk[][] Chunks;
    Object[] Objects;
}

public class Chunk
{
    public int[][] Tiles;
    public List<int> Objects;
}

This is the current structure of my map. I basically load and unload chunks if the player is too far from them. Every chunk has the same size, and has a list of objects. For each integer in the list of integers in a chunk, the corresponding Object will be updated in the parent map.

This way, I can handle collision detection without comparing two objects that are far apart: I only compare objects to other objects that are in the same chunk, or neighboring  chunks.

However, I'm wondering if there is a better way to structure my map. Faster runtime. Less processing. More efficient.

This may seem like an opinion based question but for those who perceive it that way, the question is how can I improve my map to make it more efficient?


texts: procedural forest canopy for terrain lighting

texts:
I would like to create a forest scene where directional light moves through the trees canopy and is projected onto the terrain and characters underneath like so:

I'm using Unity 5.6.  My tree line is not in view of my camera which is set to isometric.  I thought because there is no need for the tree models, I would create a quad between my directional light source and terrain.  The quad would have a material with a perlin noise texture and cutout transparent shader.  A majority of my scene is under the canopy with sporadic light leaking through:

My question, is the a performant way to reproduce the effect or is all the shadow casting expensive? Is there a better way to produce the effect so that my dynamic gameobjects receive real-time lighting? Is there a texture or noise function that better represents a forest canopy?


texts:
I'm making a map in Tiled.

I quickly ran out of room in the north of my map and would like to "shift" the tiles down. I'd prefer not to have to redo each of the tile layers.

Is this possible?

This is a picture of my minimap. I'd like to move them down around the red square.


texts: How to force keep the aspect ratio and specific resolution without stretching the output screen view?

texts:
I'm using Screen.SetResolution()

But when I run in Android device, it shows the output image is stretched to fill up the full screen which I don't want. I want it to keep the aspect ratio properly.

Example 01 : This is coincidentally match and ok because my device screen aspect is 16:9.

But here is the incorrect one (stretched)

Example 02:
This is 640 x 480 in resolution but it should remain in aspect ratio of 4:3.

How could I keep it's aspect ratio and [make it black at the extra space outside] or [customize it using my own image to cover the extra space]? in Android.

Note: I'm not talking about the canvas but entire output view.


texts:
Relevant background information

I'm developing a game in Java & LibGDX. Well, I started a project. I made a game with LibGDX about a year ago before. I made a new project with the Gradle setup and imported it into eclipse. I ran it and it didn't work

The problem

In the basic template it displays the badlogic image. It says it's not there or it can't find it.

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:148)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.kymed.dank.rpg.GameState.create(GameState.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:145)

Though it's in the assets folder


texts: Generating transformation matrix for 2D camera with pan/zoom/rotate

texts:
Question

How do you implement a camera with pan/zoom/rotation for a 2d game? Is it acceptable to multiply together a series of transformation matrixes to generate a final transformation matrix that is applied to the vectors/vertices in a scene, or is there a more efficient way?

Overview

Working on a 2d game in löve2d I recently tried implementing a camera class that allows for panning/rotation/scrolling.

I tried finding a good resource for how to implement such a 2d camera, but was unable to find one that covered all three degrees of movement, and so I came up with my own solution.

I would like some feedback on if this is a good approach, and how it could be optimized/improved upon.

My Attempt

My camera object stores the following values:

position: (Vector2)(World-Space position relative to the origin)
angle: (float)(how much the world is rotated, in radians)
zoom: (float)(the zoom factor, 1 = normal, 0.5 = 2x zoom, etc)
offset_center: (Vector2)(center the camera on the point of rotation using [screen_width/2,screen_height/2])
offset: (Vector2)(any additional offset away from the center of rotation, typically just [0,0]

Whenever a camera value changes (basically each frame) I run camera:computeMatrix() which calculates its transformation matrix:

Camera.computeMatrix = function (self)

    local m_pos = Matrix{ -- World-space Position
        {1, 0, self.position.x},
        {0, 1, self.position.y},
        {0, 0, 1}
    }

    local m_zoom = Matrix{ -- Zoom
        {self.zoom, 0, 0},
        {0, self.zoom, 0, 0},
        {0, 0, 1}
    }

    local m_rot = Matrix{ -- Rotation
        {math.cos(self.angle), math.sin(self.angle), 0},
        {-math.sin(self.angle), math.cos(self.angle), 0},
        {0, 0, 1}
    }

    local m_offset = Matrix{ -- Screen-space Offset
        {1, 0, self.offset_center.x + self.offset.x},
        {0, 1, self.offset_center.y + self.offset.y},
        {0, 0, 1}
    }

    self.matrix = nil
    -- reverse order than when applying them 1 by 1
    self.matrix =  m_offset * m_rot * m_zoom * m_pos
end

So once Camera.matrix is calculated as a 3x3 matrix, I apply that to a given vertex/vector:

Vector2.TransformM = function (v, m)
    -- m is a 3x3 matrix of format {{a,b,c},{d,e,f},{g,h,i}}
    return Vector2(v.x*m[1][1]+v.y*m[1][2]+m[1][2], v.x*m[2][2]+v.y*m[2][2]+m[2][3])
end

An example of this implementation:

Download (pan with WASD, rotate with Q/E, zoom with 1/2)


texts: Change 3ds max mesh local origin pivot point

texts:
I'm developing a 3D videogame in C# with XNA, my problem comes when I load my model done in 3ds max, and I try to rotate a mesh of it, because the pivot point isn't exported so it takes the local origin of the mesh, the point you get when pressing "Reset Pivot" in 3ds max.

What I want to do is to change its point default value, so that my animation gets the correct pivot point, how can I achieve this?

Thanks in advance! :)


texts: Andengine. Put bullet to pool, when it leaves screen

texts:
i'm creating a bullet with physics body. Bullet class (extends Sprite class) has die() method, which unregister physics connector, hide sprite and put it in pool

public void die() {
    Log.d("bulletDie", "See you in hell!");
    if (this.isVisible()) {
        this.setVisible(false);

        mPhysicsWorld.unregisterPhysicsConnector(physicsConnector);

        physicsConnector.setUpdatePosition(false);

        body.setActive(false);

        this.setIgnoreUpdate(true);

        bulletsPool.recyclePoolItem(this);
    }

}

in onUpdate method of PhysicsConnector i executes die method, when sprite leaves screen

physicsConnector = new PhysicsConnector(this,body,true,false)
    {
        @Override
        public void onUpdate(final float pSecondsElapsed) {

            super.onUpdate(pSecondsElapsed);

            if (!camera.isRectangularShapeVisible(_bullet)) {
                Log.d("bulletDie","Dead?");
                _bullet.die();
            }

        }
    };

it works as i expected, but _bullet.die() executes TWICE.
what i`m doing wrong and is it right way to hide sprites?

here is full code of Bullet class (it is inner class of class that represents player)

private class Bullet extends Sprite implements PhysicsConstants {
    private final Body body;

    private final PhysicsConnector physicsConnector;

    private final Bullet _bullet;

    private int id;

    public Bullet(float x, float y, ITextureRegion texture, VertexBufferObjectManager vertexBufferObjectManager) {
        super(x,y,texture,vertexBufferObjectManager);

        _bullet = this;

        id = bulletId++;

        body = PhysicsFactory.createCircleBody(mPhysicsWorld, this, BodyDef.BodyType.DynamicBody, bulletFixture);

        physicsConnector = new PhysicsConnector(this,body,true,false)
        {
            @Override
            public void onUpdate(final float pSecondsElapsed) {

                super.onUpdate(pSecondsElapsed);

                if (!camera.isRectangularShapeVisible(_bullet)) {
                    Log.d("bulletDie","Dead?");
                    Log.d("bulletDie",id+"");
                    _bullet.die();
                }

            }
        };

        mPhysicsWorld.registerPhysicsConnector(physicsConnector);

        $this.getParent().attachChild(this);
    }

    public void reset() {

        final float angle = canon.getRotation();

        final float x = (float) ((Math.cos(MathUtils.degToRad(angle))*radius) + centerX) / PIXEL_TO_METER_RATIO_DEFAULT;
        final float y = (float) ((Math.sin(MathUtils.degToRad(angle))*radius) + centerY) / PIXEL_TO_METER_RATIO_DEFAULT;

        this.setVisible(true);
        this.setIgnoreUpdate(false);

        body.setActive(true);
        mPhysicsWorld.registerPhysicsConnector(physicsConnector);
        body.setTransform(new Vector2(x,y),0);

    }

    public Body getBody() {
        return body;
    }

    public void setLinearVelocity(Vector2 velocity) {
        body.setLinearVelocity(velocity);
    }

    public void die() {
        Log.d("bulletDie", "See you in hell!");
        if (this.isVisible()) {
            this.setVisible(false);

            mPhysicsWorld.unregisterPhysicsConnector(physicsConnector);

            physicsConnector.setUpdatePosition(false);

            body.setActive(false);

            this.setIgnoreUpdate(true);

            bulletsPool.recyclePoolItem(this);
        }

    }

}


texts: Check collision with rectangle and pixels

texts:
I have done a function to check the pixels collision against two animated sprites, and now I need to check a "Rectangle x animated sprite" collision, but I have no idea how to do this. I tried to create a new Texture2D for the rectangle and fill it with some color, but it is expensive to do at every frame when I need check the collisions.

This is my function to check the pixel colisions of two animated sprites:

public static bool IntersectCharacterSpritePixels(CharacterSprite spriteA, CharacterSprite spriteB)
{
    if (!spriteA.BoundingBox.Intersects(spriteB.BoundingBox))
    {
        return false;
    }

    // Get the current frame for each sprite
    var rectangleA = spriteA.GetCurrentFrameRectangle();
    var rectangleB = spriteB.GetCurrentFrameRectangle();

    // Create the color data based on the current frame
    Color[] dataA = new Color[rectangleA.Width * rectangleA.Height];
    spriteA.TextureRegion.Texture.GetData(0, new Rectangle(rectangleA.X, rectangleA.Y, rectangleA.Width, rectangleA.Height), dataA, 0, dataA.Length);

    Color[] dataB = new Color[rectangleB.Width * rectangleB.Height];
    spriteB.TextureRegion.Texture.GetData(0, new Rectangle(rectangleB.X, rectangleB.Y, rectangleB.Width, rectangleB.Height), dataB, 0, dataB.Length);

    // Find the bounds of the rectangle intersection
    var boundingA = spriteA.BoundingBox;
    var boundingB = spriteB.BoundingBox;

    int top = Math.Max(boundingA.Y, boundingB.Y);
    int bottom = Math.Min(boundingA.Bottom, boundingB.Bottom);
    int left = Math.Max(boundingA.Left, boundingB.Left);
    int right = Math.Min(boundingA.Right, boundingB.Right);

    // Check every point within the intersectionbounds
    for (int y = top; y <bottom; y++)
    {
        for (int x = left; x < right; x++)
        {
            // Get the color of both pixels at this point
            Color colorA = dataA[(x - boundingA.X) + (y - boundingA.Y) * rectangleA.Width];
            Color colorB = dataB[(x - boundingB.X) + (y - boundingB.Y) * rectangleB.Width];

            // Ifboth pixels are not completely transparent,
            if (colorA.A != 0 && colorB.A != 0)
            {
                // then an intersection has been found
                return true;
            }
        }
    }

    // No intersection found
    return false;
}


texts: In my game I'd like to move sprites on a fixed path. Until this point I was trying to stick with the tools already provided by libGDX, like the Tiled map renderer classes so I'm looking for a solution nearly as convenient as that, e.g. I'd like to avoid creating the adjacency matrix by hand. Tiled has the functionality to add objects to the map but I'm not sure if I can use it for this purpose. Any idea?


texts: Rotate smoothly object to angle (Y axis) of the collided object

texts:
Well, let's say I have two planes, one which I am moving, and another one that I collide with, that has a different y rotation. I want to make that, once both planes collide, the plane the user controls changes it´s rotation to the collided plane rotation.I´ve achieved it simply equaling both planes transform.rotations, but that was just a testing, i would like to rotate the plane smoothly. I have tried with eulerAngles, and Quaternion.Lerps, but it doesn´t work, or I am not following well the sintaxis. I know that a rotation and the eulerAngles are different values. There seems to be a solution with the dotween scripts, but I would like to learn the right approach to do it, rather than make it directly with dotween. Here I paste the trigger enter code, with the methods I tried (are commented). I guess that the rotation origin would be another issue.

void OnTriggerEnter(Collider col)
{
    if (col.gameObject.tag == "Plane")
    {
        Debug.Log ("Yup...Angle: " + col.gameObject.transform.rotation.y);
        //this.transform.rotation = col.gameObject.transform.rotation;

        /*newAngle 0 (this.transform.eulerAngles.x, col.gameObject.transform.eulerAngles.y, this.transform.eulerAngles.z);
        this.transform.eulerAngles(newAngle, 2 * Time.deltaTime);*/
        this.transform.rotation = Quaternion.Lerp (this.transform.rotation, col.gameObject.transform.rotation, Time.deltaTime * 0.1f);
    }
}


texts: How do graphics evolve so much on the same console hardware?

texts:
Is it only a matter of code optimization?

Do game developers plan to start small on a new hardware, to have space to evolve while creating a series of that game?

Are computer graphics breakthroughs common enough to happen in a console lifetime?


texts:
So.. I'm learning lwjgl currently and I stumbled on this weird error caused by slick-util which seems to be incorrectly displayed.

ERROR :

java.lang.UnsupportedOperationException: Unsupported format for this image
at org.newdawn.slick.opengl.PNGDecoder.decode(PNGDecoder.java:272)
at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:97)
at org.newdawn.slick.opengl.CompositeImageData.loadImage (CompositeImageData.java:62)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.
java:200)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
at com.saumi.utils.Renderer.loadTexture(Renderer.java:91)
at com.saumi.assets.Assets.<init>(Assets.java:23)
at com.saumi.main.Main.init(Main.java:27)
at com.saumi.main.Main.<init>(Main.java:45)
at com.saumi.main.Main.main(Main.java:71)

The problem is that even though it says unable to read png data, the picture that the error points to is loaded properly and even displayed onto the screen!

I don't know what is is supposed to mean, please help.

EDIT :

My texture loader code :

public static Texture loadTexture(String path , String fileType){
    Texture tex = null;

    InputStream in = ResourceLoader.getResourceAsStream(path);
    try {
        tex = TextureLoader.getTexture(fileType,in);
    } catch (IOException e) {
        e.printStackTrace();
    }

    return tex;
}

My Assets code which loads the textures :

public class Assets {

public static Texture playBtn , tutBtn , quitBtn;

public static Texture background;

public static Texture player , missile;

public Assets(){
    playBtn = Renderer.loadTexture("res/PlayBtn.png", "PNG");
    tutBtn = Renderer.loadTexture("res/TutBtn.png", "PNG");
    quitBtn = Renderer.loadTexture("res/QuitBtn.png", "PNG");

    player = Renderer.loadTexture("res/KillSkull.png", "PNG");
    missile = Renderer.loadTexture("res/Missile.png", "PNG");

    background = Renderer.loadTexture("res/Background.png", "PNG");
}

}

The Error points to the Background Image , and the order in which it is loaded does not matter, it always points to that image.