texts: How to save file in assets so it can be properly loaded in Android Studio?

texts:
I am following a guide on creating a replica of Flappy Bird. - http://www.kilobolt.com/day-6-adding-graphics---welcome-to-the-necropolis.html

The step I am having trouble is loading the texture from the assets directory. There are the author's instructions on how to do this.

And the code that he uses to actually load the texture

        texture = new Texture(Gdx.files.internal("data/texture.png"));

My file structure looks like this(I am using Android Studio 1.0 while the author is using eclipse)

I had to manually create the data directory inside the assets folder. However when I try to run the application, I get these exceptions

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/texture.png
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: data\texture.png (Internal)

Does anyone know what the issue is? The texture.png is clearly inside the data directory of assets. I also made sure to clean the project right after copying the .png file into the data directory as the author mentioned.(so resources can be properly loaded). Is the issue just that were using two different IDES, so that different method calls have to be made?


texts: Is any data structure more efficient than quad-tree for storing and querying points that lay within an OBB?

texts:
Is there any method more effective than quad-trees for storing and searching sets of points that are not spread uniformly on the plane?

I need to be able to add, remove and search for points that are within a specified range.

I am currently testing with quad-tree but it seems the results are less than optimal when the points are not spread uniformly enough.

The points are mostly clustered in specific areas:


texts: Can I export a model and texture from a terrain file built in Unity3D?

texts:
I am mostly familiar with building my level maps within unity, and have become quite use to its inbuilt terrain creator, in both generating my terrain, and spraying a texture on to it.

I am making a game using MonoGame XNA, and would like to use a terrain map I built with Unity. I would have to recover the file, however, and have not been able to find anything to support being able to, in the first place.

Can I export my terrain file with its texture, in any way, to use in XNA MonoGame?


texts:
If I have an arbitrary plane (center and normal) or a quad (center, normal and width and height) and a camera (frustum, projection & view matrix, etc). Then how would I go about calculating if the plane/quad is visible to the camera?

Additionally how would I calculate to check if it's the front or the back of the plane/quad that is visible to the camera?

My first idea was to do some ray vs plane intersection, but then I realized that it of course wan't going to work!

bool plane_visible = false;
const float denom = plane_normal.dot(camera.getLook());

if (abs(denom) > 0.0001f)
{
    const float t = (plane_position - camera.getPosition()).dot(plane_normal) / denom;

    plane_visible = (t >= 0.0f);
}

Using the dot product of the plane/quads normal and the camera's look direction. Will give wrong results!

For instance, use the following image as an example! A dot product will tell me that I'm looking at the face that's facing outwards of the frustum. Though the face that I'm actually looking on is face facing inwards the frustum/towards the camera!


texts: How can I create a wind visual effect like Ori?

texts:
I'm working on a mobile game in Cocos2D. The game mechanic is very similar to Ori and the Blind Forest's parachute (Kuro's feather) mechanic. I want to be able to render a visual effect for wind similar to Ori's (see here) to make parachuting feel better, but I'm a bit at a loss on how to do it.

Do I make a custom shader that draws everything from scratch? Do I start with a wind texture and apply some transformations to it?

I think adding particles that blow around in the wind is pretty simple but the ribbony wind field look in addition to particles would feel much better.

In case the video dies (but an image doesn't do the effect justice, it's very dynamic):


texts: How to wire finite state machine into component-based architecture?

texts:
State machines seem to cause harmful dependencies in component-based architectures.

How, specifically, is communication handled between a state machine and the components that carry out state-related behavior?

Where I'm at:

I'm new to component-based architectures.
I'm making a fighting game, although I don't think that should matter. I envision my state machine being used to toggle states like "crouching", "dashing", "blocking", etc.
I've found this state-management technique to be the most natural system for a component-based architecture, but it conflicts with techniques I've read about:
Dynamic Game Object Component System for Mutable Behavior Characters It suggests that all components activate/deactivate themselves by continually checking a condition for activation.
I think that actions like "running" or "walking" make sense as states, which is in disagreement with the accepted response here: https://gamedev.stackexchange.com/a/7934
I've found this useful, but ambiguous: How to implement behavior in a component-based game architecture? It suggests having a separate component that contains nothing but a state machine. But, this necessitates some kind of coupling between the state machine component and nearly all the other components. I don't understand how this coupling should be handled. These are some guesses:

A. Components depend on state machine:
Components receive reference to state machine component's getState(), which returns an enumeration constant. Components update themselves regularly and check this as needed.

B. State machine depends on components:
The state machine component receives references to all the components it's monitoring. It queries their getState() methods to see where they're at.

C. Some abstraction between them
Use an event hub? Command pattern?

D. Separate state objects that reference components
State Pattern is used. Separate state objects are created, which activate/deactivate a set of components. State machine switches between state objects.
I'm looking at components as implementations of aspects. They do everything that's needed internally to make that aspect happen. It seems like components should function on their own, without relying on other components. I know some dependencies are necessary, but state machines seem to want to control all of my components.


texts: Mixing interpolation with extrapolation in multiplayer game

texts:
I am creating a multiplayer drag racing game and have difficulties mixing extrapolation and interpolation. To save network bandwidth i am getting information from the opponent only on his button press, which is:

car->speed = newSpeed;
car->distanceReached = newDistance;
car->currentForce = newForce;

And i extrapolate the rest until the next update from opponent. On player update, extrapolation kicks in:

//Find new acceleration, frictionForce and mass being constants.
car->acceleration = (car->currentForce - car->frictionForce) / car->mass;

//Calculate new velocity.
car->speed += car->acceleration * dTime;

//Reduce force.
car->currentForce -= car->friction * dTime;
if(car->currentForce < 0)
    car->currentForce = 0;

//Update distance reached
car->distanceReached += car->speed;

So we got update from opponent - car starts moving until force is equal 0. This seems to be working fine. What is not - when update is received in the middle of extrapolation, i am setting new position directly as seen before and car jumps to adjust to the "real" position. So the question is - how to incorporate interpolation in this situation for car not to jump and not to ruin already running extrapolation?


texts: Instantiate two objects at random non-overlapping positions

texts:
I'm making an endless runner game.

I have the script that make coins and walls appear at the same time in front of the player.

The problem is that sometimes the coin and wall appear in the same place/position.

How can I ensure that coins and walls do not appear in the same place/position?

public class Instantiate : MonoBehaviour
{
public float betweenSpawn = 1.05f;
public float angle;
public Vector3 spawnValues; //Range of appearing
public GameObject coinPrefab;
public GameObject wallPrefab;

public Transform coinInstantiate;
public Transform wallInstantiate;

void Start()
{
    InvokeRepeating("Spawn", 0f, betweenSpawn);
}

void Spawn()
{
    Vector3 coinPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), 1, Random.Range(-spawnValues.z, spawnValues.z));
    Vector3 wallPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), 1, Random.Range(-spawnValues.z, spawnValues.z));

    Instantiate(coinPrefab, coinPosition + coinInstantiate.TransformPoint(0, 0, 0), Quaternion.AngleAxis(angle, Vector3.forward));
    Instantiate(wallPrefab, wallPosition + wallInstantiate.TransformPoint(0, 0, 0), Quaternion.AngleAxis(angle, Vector3.forward));
}

}


texts:
I am trying to improve the fps and in my scene there are 4322 scripts attached to 4322 objects. When I activate those objects the fps go down. Right now it's around 100fps when i active those objects it drops to 40fps. I found and identified these two scripts are dropping the fps signficantly. Around 20 FPS i can save by commenting the methods which i am running in lateUpdate event.
public class ZoomNamePlace : MonoBehaviour
{
    public CameraController camContrller;
    public float size;
    public float distance;
    void Reset()
    {
        camContrller = FindObjectOfType<CameraController>();
    }

    private void Start()
    {
        //GetComponent<TextMeshPro>().text = this.transform.parent.name.Split('_')[0] + "_" + GetComponent<TextMeshPro>().text;
    }

    void LateUpdate()
    {
       Zoom();
    }

    void Zoom()
    {
        // if(camContrller ==null)
        //  camContrller = FindObjectOfType<cc>();

        //size = (camContrller.currentActiveCam.transform.position - transform.position).magnitude;
        size = Vector3.Distance(camContrller.currentActiveCam.transform.position , transform.position);
        if (size >= 200) return;
        if ((size / 600) >= .8f)
        {
            transform.localScale = new Vector3(size / 600, size / 600, size / 600);
        }
        else
        {
            transform.localScale = new Vector3(.8f, .8f, .8f);
        }

    }

}

If I comment out zoom method then fps improve around 5-8.
The second script is:
public class lookAtIcon : MonoBehaviour
{

    public CameraController camContrller;

    void Reset()
    {
        camContrller = FindObjectOfType<cc>();
    }

    void LateUpdate()
    {
        transform.LookAt(transform.position + camContrller.currentActiveCam.transform.rotation * Vector3.forward *-1 ,
           camContrller.currentActiveCam.transform.rotation * Vector3.up);
    }

}

The above script LateUpdate() code taking around 10-15 fps.
If I comment out both script updates functionality then FPS is around 59-61.
If I comment out lookAtIcon script Updates event then fps around 65-67 (5 FPS improvement).
If I comment out LateUpdate script LateUpdates event then fps around 74-75 (10 FPS improvement).
So it's about 25 fps improvement if I disable both script Events.
Please help me how should I improve it? I am thinking to disable the event if the object is far from the camera. Is there anyway avaible to disable the event on some objects? or do you have any other suggestion to improve it?


texts: How to find the source of a memory leak in a Blockchain + Node.js game

texts:
We have been working in a Node.js game, part of a game network, which seems to be working slower and slower as you keep it open, as well as it seems to increase the RAM and CPU usage over time.

We are assuming it's a memory leak issue/improper use of the data structures within the application.

The question is, how could I detect the source of this type of issue?


texts:
I'm making a top-down strategy game so I thought a minimap is a must. I'm using Scene2D to display my GUI and since the minimap is technically a part of the GUI, I used the stage camera to position the minimap. Below is how I'm rendering the minimap.

    shape.setProjectionMatrix (stage.getCamera ().combined);
    shape.begin (ShapeType.Filled);
    shape.setColor (Color.CYAN);
    shape.rect ((Constants.RENDER_WIDTH - 500) + ship.getX () / 30, ship.getY () / 30, 5, 5);
    shape.end ();

    shape.setProjectionMatrix (stage.getCamera ().combined);
    shape.begin (ShapeType.Line);
    shape.setColor (Color.YELLOW);
    shape.rect (Constants.RENDER_WIDTH - 500, 0, 500, 500);
    shape.setColor (Color.WHITE);
    shape.rect ((Constants.RENDER_WIDTH - 500) + (camera.position.x) / 30, (camera.position.y - camera.viewportHeight / 2) / 30, Constants.RENDER_WIDTH / 30, Constants.RENDER_HEIGHT / 30);
    shape.end ();

The first ShapeRenderer (shape) call renders the ship marker, which is currently a small square. The second renders the bounds of the minimap which is 500x500. RENDER_WIDTH and RENDER_HEIGHT are the width and height that I'm plugging into camera as viewport dimensions (1920x1080). The map is 15000x15000, so I'm dividing the ship location by 30 so that it is always in the range of 0-500. However, when I move the camera around I actually end up being able to see the ship before the minimap says I should, which is illustrated below. I'm fairly certain it's due to the zoom level of the camera, but I haven't figured out how to incorporate that other than multiplying the width and height of the display of where the camera is (the white box), by the current zoom level, which didn't work.


texts: I am looking to make a simple program (in any language) then when you run the .exe the only thing it does is display a website (the whole website is my game) without any navigation buttons as they are integrated into the pages.


texts: moving object in unity from a point A to point B no matter what the original position of the object is

texts:
I'm moving a Game Object in unity from point A to point B no matter what the original position of the Game Object is.

Let us suppose that I have a Game Object at (0, 0, 0).

But I want to move that Game Object from (1, 1, 1) to (2, 2, 2).

How can I do this in C# ?


texts:
I'm thinking of making a spot the difference game. But immediately I stumbled over a problem. I'm thinking of storing a "difference area" in the form of a x,y coordinate. However, because on a smartphone it will be difficult selecting the exact pixel at that location, I need a way of checking if the "area" is within the "touch area". I hope that makes sense. I've attached an image to help you understand

In this example the "difference point" is located at -180,-140. A user could touch anything within 5 pixels of that and that will be marked as a correct answer. So touching -177, -147 would also be correct. How can I check if the touch-coordinates are within a 5 pixels radius of the correct "difference point"?


texts: Is there a way to set a shader define in Löve?

texts: I know I can use shader:send() to change variables, but is there a way to set/change a #define?


texts: Applying movement to a Rigid Body Isometric in Unity 3D

texts:
I'm making an isometric dungeon crawler. I initially used transform to get isometric movement and things worked well, but I couldn't use collision which meant it was unsuitable. So I'm now trying to use Rigidbody and I'm having some weird issues.

First of all, this is the code I currently have:

public class CharControllerRigid : MonoBehaviour{
    [SerializeField]
    private Rigidbody characterRigid;
    private Vector3 inputVector;
    void Start()
    {
        characterRigid = GetComponent<Rigidbody>();
    }

    void Update()
    {
        inputVector = new Vector3(Input.GetAxis("Horizontal") * 10f, characterRigid.velocity.y, Input.GetAxisRaw("Vertical"));
        transform.LookAt(transform.position + new Vector3(inputVector.x, 0, inputVector.z));
    }
    private void FixedUpdate()
    {
        characterRigid.velocity = inputVector;
    }
}

I have two issues:

First, how do I get the movement to work on an isometric plain?

Second, how do I get the movement to work in all directions? Current when I move left and right the movement is good, but up and down are really slow in comparison.


texts: Applying a shader operation to an existing shader

texts:
My procedural game has blocks that can be selected. When selected, I'd like them to to fade a bit; I can achieve such an effect in Shader Graph by applying a Blend → Lighten operation to the block shader (blending with white).
However I'm a bit stuck on how I would make this effect happen dynamically when the block is selected. All blocks within a chunk are part of the same mesh; I'm using a separate submesh for each different block type. So although I've considered using a property to conditionally apply the blend operation, I believe that would affect all the other blocks using that shader?
I've considered making a selected variant of each shader and swapping them upon object selection, but there are dozens of block types so I don't know if that's the best method.
What is the recommended approach here? Is there a way I can simply "apply" some shader operation on top of whatever the existing shader is?


texts:
I've recently started a project, building a physics engine.
I was hoping you could give me some advice related to some documentation and/or best technologies for this.

First of all, I've seen that Game-Physics-Engine-Development is highly recommended for the task at hand, and I was wondering if you could give me a second opinion.Should I get it?
Also, while browsing Amazon, I've stumbled onto  Game Engine Architecture and since I want to build my physics engine for games, I thought this might be a good read aswell.

Second, I know that simulating physics is highly computation intensive so I would like to use either CUDA or OpenCL.Right now I'm leaning towards OpenCL, because it would work on both NVIDIA and ATI chipsets.What do you guys suggest?

PS: I will be implementing this in C++ on Linux.


texts:
Possible Duplicate:
  New to creating AI - where to start?

i have been programming 2-3 games till now. but i have not used ai in any of them...so can u please suggest good ebooks or net articles or tutorials on game ai...problems featuring shortest path, pathfinding etc...
Thankyou


texts:
In my game engine I'm passing a normal matrix to my shaders like so:

Matrix3f normalMatrix = modelMatrix.invert().transpose();

However this is causing lighting to rotate with my object, producing a weird effect.

As I'm not performing any non-uniform scaling, I tried substituting normalMatrix for mat3(modelMatrix), and that worked fine.

Also doing the transpose inverse on the GPU using transpose(inverse(modelMatrix)) worked fine.

This has lead me to believe there is a bug in my invert() and transpose() functions.

According to some math websites, when the modelMatrix lacks any non-uniform scaling, calling inverse().transpose() on it will produce the exact same matrix.

However in my code the output is far from the same:

modelMatrix

0.25    0      0      2353.3474
0       0.25   0      0
0       0      0.25   51.86973
0       0      0      1

normalMatrix = new Matrix3f(modelMatrix).invert().transpose()

4.0 0.0 0.0
0.0 4.0 0.0
0.0 0.0 4.0

Would anyone be able to shed some light on this issue...
(I don't want to just stick with modelMatrix because I do want to support non-uniform scaling in the future)

Here are some screenshots describing the issue:

These are two frames of my planet as it rotates. The light source appears to be rotating with it (it shouldn't be). Using the modelMatrix instead of normalMatrix solves the issue.


texts: Unity3D - Despite using Time.deltaTime, my camera and player move faster at higher framerates

texts:
I'm pretty new to c# and Unity so I wouldn't be surprised if I had made some stupid mistakes, but as far as I know, I don't think I misused Time.deltaTime. Any help would be greatly appreciated.
Movement Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    private float crouchMultiplier = 1f;

    private Vector3 velocity;
    private bool isGrounded;
    private bool isCrouched;
    private float velocityDecay = 1f;

    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * crouchMultiplier * velocityDecay * Time.deltaTime);

        Debug.Log(Time.deltaTime);

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }

        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            isCrouched = true;
            gameObject.transform.localScale = new Vector3(1, 1f, 1);
        }

        if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            crouchMultiplier = 1f;
            gameObject.transform.localScale = new Vector3(1, 2f, 1);
            velocityDecay = 1;
            isCrouched = false;
        }

        if (isCrouched)
        {
            if (velocityDecay > 0.2f && isGrounded)
            {
                crouchMultiplier = 2.5f;
                velocityDecay *= 0.995f;
            }
        }

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}

Camera Script:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour
{

    public Transform playerBody;
    public float mouseSensitivity = 100f;

    float xRotation = 0f;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90);

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }
}
```


texts: XNA - Debugging/Testing Individual Sprites and Pixel Collision

texts:
I ran through the first training on XNA where you make a shooter game. They did some thing that I would not do and I want to use their starting point to learn more things.

I want to try better collision and adding a menu. I saw something online with the sonic physics where they have a frame by frame of sonic moving 1 pixel. See picture below.

I am new to development, but I have been programming for years now. What would you guys suggest to try these different things out.

How would I simulate a similar frame by frame testing as they do in the above picture?

Thanks!


texts: Filling a polygon with a texture (or a color) C# Visual Studio

texts:
I'm trying to figure how to put a texture or fill a "DrawPolygon" with a simple color in C# Visual Studio (using right now 2015).

 //Left Wall 1
 Point lw1a = new Point(18, 7);
 Point lw1b = new Point(99, 61);
 Point lw1c = new Point(99, 259);
 Point lw1d = new Point(18, 313);

 Point[] lw1 = { lw1a, lw1b, lw1c, lw1d };

 gr.DrawPolygon(pen, lw1);`

This is a example code for one of the things I'm drawing on screen. Any idea on how I can achieve that?
Thanks!


texts: matrix transformations 2D - place in world-space but keep size in "object/screen-space"

texts:
I have a question concerning matrix transformations. I Think I know how it could be done, but Im not sure its the best/correct way to do it.

I want to apply World translations and rotation to an object but the scale should be consistent. See the image for example. The object closest to origo scales according to World-scale, the other object has the same scale but is placed correctly (World scale is taken into consideration when translating). I know I can do this by applying the inverse scale transform in local space Before translating and applying World-transforms. But is there some better way?


texts: Can I publish a game with a name similar to a videogame developer?

texts: I'm currently developing a game and hoping to sell it in the future. Right now I'm about to make a facebook page and release a trailer, and I realised my game has a similar name to an already existing game developer, "lucid games", and in their website they call themselves just "lucid" which is what I was expecting to call my videogame (lucid). But also it's a British studio, and I'm from Ecuador. So I was wondering if this could be an issue?


texts: What are the valid DepthBuffer Texture formats in DirectX 11? And which are also valid for a staging resource?

texts:
I am trying to read the contents of the depth buffer into main memory so that my CPU side code can do Some Stuff™ with it.

I am attempting to do this by creating a staging resource which can be read by the CPU, which I will copy the contents of the depth buffer into before reading it. I keep encountering errors however, because of, I believe, incompatibilities between the resource format and the view formats.

Threads like these lead me to believe it is possible in DX11 to access the depth buffer as a resource, and that I can create a resource with a typeless format and have it interpreted in the view as another, but I cannot get it to work.

What are the valid formats for the resource to be used as the depth buffer?
Which of these are also valid for a CPU accessible staging resource?


texts: How do I manage the visibility of enemy spawn locations in a long scrolling shooter?

texts:
How do I handle the situation of an enemy spawn place being visible on a screen in a scrolling shooter?
The tutorials I have seen are about setting all the enemies on a whole map only. But it is not appropriate if the map is huge.


texts: The second double jump animation doesn't finish before the player touches the ground

texts:
I have an issue with double jump for the player my code is working but I want the second double jump animation finish(idle Animation: anim.SetBool("Jump", false)] before he touches the ground can anyone help me on that here is my code :

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

public class PlayerMovement : MonoBehaviour
{
    private Animator anim;
    private float speed = 5f;
    private Rigidbody2D myBody;
    public Transform groundCheckPosition;
    public LayerMask groundLayer;
    private bool isGrounded;
    private bool jumped;
    private float jumpPower = 5f;
    private bool doubleJump;
    void Start()
    {
        myBody = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
        isGrounded = false;
        jumped = false;
        doubleJump = false;
    }
    // Update is called once per frame
    void Update()
    {
        PlayerJump();
    }
    private void FixedUpdate()
    {
        CheckIfGrounded();
        PlayerWalk();
    }
    void PlayerWalk()
    {
        float h = Input.GetAxisRaw("Horizontal");
        if (h > 0)
        {
            anim.SetInteger("Speed", (int)speed);
            ChangeDirection(1);
        }
        else if (h < 0)
        {

            anim.SetInteger("Speed", (int)speed);
            ChangeDirection(-1);
        }
        else
        {
            anim.SetInteger("Speed", 0);
        }
        myBody.velocity = new Vector2(h * speed, myBody.velocity.y);
    }
    void ChangeDirection(int direction)
    {
        var temp = transform.localScale;
        temp.x = direction * (0.8f);
        transform.localScale = temp;

    }
    void CheckIfGrounded()
    {
        if (!Physics2D.Raycast(groundCheckPosition.transform.position, Vector2.down, 0.1f, groundLayer))
        {
            isGrounded = false;
        }
        else
        {
            isGrounded = true;
            doubleJump = false;
        }
        if (isGrounded)
        {
            jumped = false;
            anim.SetBool("Jump", false);
        }
    }
    void PlayerJump()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if ((isGrounded && !jumped) || (!doubleJump && !isGrounded))
            {
                jumped = true;
                doubleJump = true;
                myBody.velocity = new Vector2(myBody.velocity.x, jumpPower);
                anim.SetBool("Jump", true);
            }
        }
    }

}//class

Edit

I have changed the code from that :

void Update()
    {
        PlayerJump();
    }
    private void FixedUpdate()
    {
        CheckIfGrounded();
        PlayerWalk();
    }

to that :

void Update()
{

}
private void FixedUpdate()
{
    CheckIfGrounded();
    PlayerJump();
    PlayerWalk();
}

I have changed it because FixedUpdate, we use it only for physics because it's not called every frame, unlike update function.

the problem is that the double jump doesn't work in this case can you explain me why?


texts: What is the primary difference between Augmented Reality and Virtual Reality software engineering?


texts: What units does Sprite Kit use for physics?

texts:
I'm developing a simple ball game in Sprite Kit. I need to predict the ball's trajectory, so I went back to my physics book for the equations for acceleration, time, speed and space.

The problem is that Sprite Kit documentation does not declare the units of measurement of the properties of physics bodies, so it's hard to calculate the needed values.

Based on my experiments/research I suppose that:

gravity is expressed in m/s/s  (m/s^2)
since gravity is a CGVector, all CGVectors are expressed in m/s/s (m/s^2)
velocity (instant speed) is m/s

Then I realized a simple scene where a ball is falling:

Gravity: CGVector(0,1.2);
Height: 218.009499 pixels
Time: 0.302499747
Then acceleration should be:   2*Height / Time^2 = 1441.3863 pixels/s/s
And gravity of 1.2m/s/s corresponds to 1441.3863 in a world measured in pixels

Someone says the internal PTM (pixel to meter ratio) is 150.

Any hints?


texts: Calculate Orbit Path/Ellipse given mass, velocity, and distance (2body)

texts:
Calculate and draw the path of an orbit in a 2 body problem given the mass, current velocity, and distance of both bodies?

We're working in Unity and will be using the default rigidbody.mass to start while we craft a deterministic and event driven gravitational orbit calculation system.

We've got a lot of this done but need to know if anyone here speaking from experience can suggest the most optimal and the most accurate route for going about this.

Okay, so here's the intended system.

Objects have a collider-trigger sphere which represents their sphere of gravitational influence. When objects enter an SOI, they begin to be effected by that object's gravity. This represents an "encounter" event and this is where we grab initial values to determine the trajectory the object will take with those initial parameters. It will take this path as long as nothing changes. We only worry about "significant bodies" such as planets and large asteroids. We're not giving every ship an SOI but we do give them mass values so we can properly perform consistent calculations.
When a "path change event" occurs, the system will recalculate when the event is over and new velocities are established. This prevents the system from constantly calculating the force on objects every physics step and greatly reduces the overhead of the system.
The system has a way to "snapshot" everything for saves. positions, velocities, and paths. Basically from what I understand, we'd be getting arrays of velocities that we lerp between based on an array of position vectors. I was talking about how the system would to the motion, there.

So, instead of using Unity's built-in physics and forces, we bypass that for a much more efficient and customizable system. Instead of applying constant force to effect the positions of objects, we calculate the path ahead of time and assume the object will follow that path until something changes.


texts: Optimize spawn & destroy? (Unreal Engine)

texts:
I'd really like to know how you'd go about optimizing this? 20 actors each spawning 8 projectiles per 0.1 sec which are then destroyed 0.8 seconds later, all done through blueprints Gif: https://gyazo.com/eab053741012405926193c6302ef84a7
Pictures:

I thought about pooling but not sure if it's okay to have 1000 projectiles on standby since I know spawning and destroying is costly but going though all, picking one to re-locate and initializing the projectile per character might also be a problem, what cha say? other options? I can totally do pooling if that's the only way
Would really appreciate some tips/practices. Thank you all!


texts: How do you triangulate a 3D point from a pair of stereo images?

texts:
I'm working with a stereo pair of photos, and trying to obtain a set of 3D points from matching points on these 2 images. How exactly is the point triangulated? Do you throw a ray from the camera pinhole centerpoint? Or do you throw a ray perpendicular to the photos?

Edit: I'm also looking for code examples, that document the simple linear/polynomial math involved. Currently I'm simply using 3D line/line intersections to find the point. (actually line/plane intersections) I'm sure this is not accurate and the calibration data of the camera should also be used. Although I don't know how. For instance, with the points on the photos known, should I be drawing the 3D line from the camera pinhole 'origin', or is there a better way? Should I be taking the lens distort into account, or something fancier? The calibration data I have is as follows:

ix, iy -- Image sensor width and height, i.e. the dimensions of the photograph.
fx, fy -- Focal length in x- and y-dimensions measured in pixels.
cx, cy -- Principal point coordinates, i.e. coordinates of lens optical axis interception with sensor plane.
skew -- Skew transformation coefficient.
k1, k2, k3 -- Radial distortion coefficients.
p1, p2 -- Tangential distortion coefficients.


texts:
Lately, I've been doing a lot of reading on entity systems to implement in my C++/OpenGL game engine. The two key benefits that I constantly hear lauded about entity systems are

the easy construction of new kinds of entities, due to not having to tangle with complex inheritance hierarchies, and
cache efficiency, which I'm having trouble understanding.

The theory is simple, of course; each component is stored contiguously in a block of memory, so the system that cares about that component can just iterate over the whole list, without having to jump around in memory and kill the cache. The problem is that I can't really think of a situation where this is actually practical.

First, let's look at how the components are stored, and how they reference each other. Systems need to be able to work with more than one component, i.e. both the rendering and physics system needs to access the transform component. I've seen a number of possible implementations that address this, and none of them do it well.

You can have components store pointers to other components, or pointers to entities that store pointers to components.  However, as soon as you throw pointers into the mix, you're already killing cache efficiency. You can ensure that every component array is 'n' large, where 'n' is the number of entities alive in the system, but this approach is hideously wasteful of memory; this makes it very difficult to add new component types to the engine, but still throws away cache efficiency, because you're jumping from one array to the next. You could interleave your entity array, instead of keeping separate arrays, but you're still wasting memory; making it prohibitively expensive to add new components or systems, but now with the added benefit of invalidating all of your old levels and save files.

This is all assuming that entities are processed linearly in a list, every frame or tick. In reality, this is not often the case. Say you use a sector/portal renderer, or an octree, to perform occlusion culling. You might be able to store entities contiguously within a sector/node, but you're going to be jumping around, whether you like it or not. Then you have other systems, which might prefer entities stored in some other order. AI might be okay with storing entities in a big list, until you start working with AI LOD; then, you'll want to split that list up according to distance to the player, or some other LOD metric. Physics is going to want to use that octree. Scripts don't care, they need to run, no matter what.

I could see splitting components up between "logic" (e.g. ai, scripts, etc) and "world" (e.g. rendering, physics, audio, etc), and managing each list separately, but these lists still have to interact with each other. AI is pointless, if it can't affect the transform or animation state used for an entity's rendering.

How are entity systems "cache-efficient" in a real-world game engine? Perhaps there's a hybrid approach that everyone's using, but not talking about, like storing entities in an array globally and referencing it within the octree?


texts: How can I spawn a sprite based on a condition after the game starts?

texts:
How do I spawn a sprite anytime later in the game when the game starts?

I'm using FlashDevelop with Flixel. I did try it in override public function create(): void. It works only in the beginning. I try it using if (FlxG.score == 1) but it doesn't work. I also tried it in override public function update(): void. It works and it is moving but it leaves a sprite making it a multi-sprite. I also did try FlxGroup but to no avail.


texts: Sprite UV returning wrong values in script in newer Unity versions

texts:
I'm recreating in Unity 2019.4 an old project I have done few years ago in Unity 5.4.0. This project consists of a tiled map editor using unity editor scripts which reads baked data files containing all information needed for each tile (like height, texture id and texture rotation) and creates the tiled mesh on the fly for a given map to be edited in unity.
I have a single sprite (mode: multiple) containing all tiles textures that I read when creating the terrain mesh to set the correct UV for each vertex of the mesh depending on the texture id of a given tile.
In my old project using Unity 5.4.0 I can just call a tile sub sprite uv property to set in the mesh uv and it works just fine. The problem is that in Unity 2019.4 the uv property of the exact same asset (the big sprite with multiple sub sprites) returns weird values.
I compared the output of the uv property used in each tile on both projects and the values are slightly different. The difference is just the order how the elements are ordered in the uv array.
Lastly I noticed the sprite is showing additional options in Unity 2019. I have played with the options in Unity 2019 but couldn't notice any difference in the problem. I'll link the images showing the options in both Unity 5 and Unity 2019 bellow (respectively):

Does anyone have any idea or suggestion to understand why this is happening? I tried to search for this topic but couldn't find anyone with a similar problem.
EDIT: the multiple sprite is being generated and imported with the tool TexturePacker.


texts:
I'm developing a First-Person shooter game. Everything is just fine but I've a little problem with my camera moving.

My FPS camera is moving smoothly! But the camera should move like a human is walking and his head is doing up and down.

Now I'm stuck! So what kind of algorithm can I use for that purpose?

Any kind of help is appreciated.


texts: Implementing a wrapping wire (like the Worms Ninja Rope) in a 2D physics engine

texts:
I've been trying out some rope-physics recently, and I've found that the "standard" solution - making a rope from a series of objects strung together with springs or joints - is unsatisfying. Especially when rope swinging is relevant to gameplay. I don't really care about a rope's ability to wrap up or sag (this can be faked for visuals anyway).

For gameplay, what is important is the ability for the rope to wrap around the environment and then subsequently unwrap. It doesn't even have to behave like rope - a "wire" made up of straight line segments would do. Here's an illustration:

This is very similar to the "Ninja Rope" from the game Worms.

Because I'm using a 2D physics engine - my environment is made up of 2D convex polygons. (Specifically I am using SAT in Farseer.)

So my question is this: How would you implement the "wrapping" effect?

It seems pretty obvious that the wire will be made up of a series of line segments that "split" and "join". And the final (active) segment of that line, where the moving object attaches, will be a fixed-length joint.

But what is the maths / algorithm involved for determining when and where the active line segment needs to be split? And when it needs to be joined with the previous segment?

(Previously this question also asked about doing this for a dynamic environment - I've decided to split that off into other questions.)


texts: So I've recently used a PID controller to build a bot for a 2d physics based game. I also did a bit of reading on steering behavior but am still confused over one thing: Is a PID controller considered an implementation of steering behavior? Or are they two completely unrelated things?


texts: If a game is made for Windows or MacOS, and sold for profit, is Microsoft or Apple entitled to royalties, even if it's sold on a different website?

texts:
I.e. sold on some website some game developer made, and NOT sold on Apple Store or Microsoft Store.

2) Also, for any game made and sold for their platform, does Apple or Microsoft look at the game/app content, and decide whether they want that game/app to exist for their platform or not? Again, this for the case of where the game/app is NOT sold on the Apple Store or Microsoft Store.

3) same questions, but for game consoles? e.g. Nintendo, Sony, etc.

EDITED: I ask because... well... sometimes I wonder if a certain game has content which is too inappropriate. So I'm wondering ... what companies looked at these games and said they were okay when maybe they should've said no.


texts: where can I download unity assets without opening it in in unity.

texts: I'm browsing through my mobile phone and I need to download unity assets but unity asset store demands that I open the assets in unity directly. How or which site can I download it on my mobile and send it to my PC.


texts: Hi could anyone help me solving the problem of blurred texures? My viewport screen have 800px of height and 480-600px (for different aspect ratios) of width and when I test game on smartphone with bigger screen the textures, buttons and the text are so blurry, even if I use Linear texture filter. How can I get rid of that? What can possibly solve my problems?


texts: Loading a heavy scene behind some loading screen in unity

texts:
Is there a way to load a heavy built scene behind a loading screen in unity to not make the game look like stuck loading the scene rather show the player some loading bar that would help the player think some background process is happening.
any sites or vidoes that describe about this would be a great help! Thanks!


texts: I cannot move my player to right on Godot

texts:
I'm beginning with Godot making a simple Sprite which should move both left and right but when right key is pressed the KinematicBody2D doesn't move right. According to the logic it should does but it does not.

I leave the code below hoping someone could help me to find the error

extends KinematicBody2D

const VEL = 50
var vec_mov = Vector2()

func _ready():
    pass # Replace with function body.

func _physics_process(delta):
   if(Input.is_action_pressed("ui_right")):
       vec_mov.x += VEL
   if(Input.is_action_pressed("ui_left")):
       vec_mov.x -= VEL
   else:
       vec_mov.x = 0

   move_and_slide(vec_mov)

Thanks


texts: Extract eye/camera position from a view Matrix

texts:
I'm trying to improve my Camera. This camera owns a target (vec3 _at), a position (vec3 _eye) and a view mat4. When I move the mouse, I perform a rotation to the view matrix, according to 2 angles (_angleY, _angleZ), so that it gives the feeling the world is turning and not the cam.

Here is what I have, which works :

// Called each frame
void Camera::look(bool rotation)
{
    // Computes view Matrix
    _view.lookAt(_eye.X,_eye.Y,_eye.Z,
                 _at.X, _at.Y, _at.Z,
                 0, 0, 1);

    // Apply rotation to the matrix, according to angles
    if(rotation) {
        _view.rotate(_angleY, 0, 1, 0, _at);
        _view.rotate(_angleZ, 0, 0, 1, _at);
    }
}

This perfectly works. I'm able to make my world rotating around a selected target (vec3). My problem is that my eye position is not updated each frame since I update my angles which apply a new rotation. Then my eye position is wrong and I need it to be updated each frame for another calculation.

Then, I'm trying to extract the eye position after the rotation, update it, and set angles to 0 (hoping it's the best solution...)

Therefore, I need to extract the eye position of my camera, from my modelview matrix. Here is what I'm trying to do, according to what I read here , in the last comment :

void Camera::look(bool rotation)
{
    // Computes view Matrix
    _view.lookAt(_eye.X,_eye.Y,_eye.Z,
                 _at.X, _at.Y, _at.Z,
                 0, 0, 1);
    if(_angleY != 0 || _angleZ !=0)
    {
        if(rotation) {
            _view.rotate(_angleY, 0, 1, 0, _at);
            _view.rotate(_angleZ, 0, 0, 1, _at);
        }

        Vector3D d;
        d.X = _view[3];
        d.Y = _view[7];
        d.Z = _view[11];
        // This creates a vector by multiplying -d by the mat3 part of the view matrix.
        Vector3D retVec = _view.mul3(-d);
        _eye = retVec;
    }
}

few things which might be need :

void Matrix4::lookAt(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ, float upX, float upY, float upZ)
{
    Vector3D axe (upX, upY, upZ);
    Vector3D forward(targetX - eyeX, targetY - eyeY, targetZ - eyeZ);
    Vector3D normal = Vector3D::crossProduct(forward, axe);   // normal = regard x Axe
    Vector3D newAxe = Vector3D::crossProduct(normal, forward); // newAxe = normal x regard

    // Normalize new vectors
    forward.normalize();
    normal.normalize();
    newAxe.normalize();

    // lookAt matrix
    Matrix4 Matrix4;
    Matrix4.values_[0] = (float)normal[0];
    Matrix4.values_[1] = (float)normal[1];
    Matrix4.values_[2] = (float)normal[2];
    Matrix4.values_[4] = (float)newAxe[0];
    Matrix4.values_[5] = (float)newAxe[1];
    Matrix4.values_[6] = (float)newAxe[2];
    Matrix4.values_[8] = (float)-forward[0];
    Matrix4.values_[9] = (float)-forward[1];
    Matrix4.values_[10] = (float)-forward[2];
    Matrix4.values_[15] = 1.0f;

    *this *= Matrix4;

    // translation is part of the lookAt function
    translate(-eyeX, -eyeY, -eyeZ);
}

If someone understands what I'm doing wrong, it might help a lot, I spent a while with this problem...
Thanks,


texts:
I been searching for this for a while online but found no good answer so now I'm asking here. I have a scripting question about Unity's Rigidbody.

When your making a game object move with Rigidbody you typically make a script for it that starts off with

public Rigidbody rigid;

Then you put in a GetComponent call like so

void Start() {
  rigid = GetComponent<Rigidbody> ();
}

And the part I don't understand is how the Rigidbody variable works. Is it a variable type that unity is using cause even in the GetComponent it starts looking for Rigidbody not rigid. That seems like making a int variable then calling it saying Debug.Log(Int);

Also in unity script from the documentations it uses

function Start () {
  var rb = GetComponent.<Rigidbody>();
}

Theres no Rigidbody in the declaration of the variable at all. Thats what made it even more confusing for me due to how GetComponent cleary shows it getting just the Rigidbody component but from the look of the script how does it connect to the game object?

With the C# example you drag and drop the GameObject in the Rigidbody variable even when the script is connected.

The reason why I'm asking is because I'm wanting to learn intuitively where I understand all the meaning of code like a second language. Is that normal?


texts: Is there an easier way to get sprites from a spritesheet

texts:
One issue I have when working with API's such as Monogame and SFML unlike with Game Engines like Unity and Unreal is trying to extract sprites from a spritesheet. I know the method of doing it but it becomes really annoying when you use spritesheets for example that have lots of different sized sprites that are scattered all around the spritesheet. Everything seems to need to be perfectly sized and aligned to be able to extract the sprites correctly, unless you're using a game engine like Unity where you can do something like draw boxes around the sprites you want, no matter the size or position, or have this done for you.

What workflow can I use to quickly select the portions of the image corresponding to each sprite and use those extracted sprites right away in code instead of splitting the sprites into seperate .png's and using them?


texts: How to do frame by frame animation in android using open gl es

texts: I have application in some part i am using AndroidDrawable for animation but it giving  jerking effect that why i planed to  change the code to Open Gl ES for better performance .so far i have googled a lot but did not got any good example .anybody has any idea????


texts: Obstacle Avoidance steering behavior: how can an entity avoid an obstacle while other forces are acting on the entity?

texts:
I'm trying to implement the Obstacle Avoidance steering behavior in my 2D game.

Currently my approach is to apply a force on the entity, in the direction of the normal of the heading, scaled by a number that gets bigger the closer we are to the obstacle. This is supposed to push the entity to the side and avoid the obstacle that blocks it's way.

However, in the same time that my entity tries to avoid an obstacle, it Seeks to a point more or less behind the obstacle (which is the reason it needs to avoid the obstacle in the first place).

The Seek algorithm constantly applies a force on the entity that pushes it (more or less) in the direction of the obstacle, while the Obstacle Avoidance algorithm constantly applies a force that pushes the entity away (more accurately, to the side) of the obstacle.

The result is that sometimes the entity succesfully avoids the obstacle, and sometimes it collides with it, depending on the strength of the avoidance force I'm applying.

How can I make sure that a force will succeed in steering the entity in some direction, while other forces are currently acting on the entity? (And while still looking natural).

I can't allow entities to collide with obstacles when realistically they should be able to easily avoid them, doesn't matter what they're currently doing.

Also, the Obstacle Avoidance algorithm is made exactly for the case where another force is acting on the entity. Otherwise it wouldn't be moving and there would be no need to avoid anything. So maybe I'm missing something. Thanks


texts: Events vs Pinging: How should I structure my HUD-updating code?

texts:
I'm starting to develop a 2D fighting game using C++ and SMFL. I'm relying (at least sort of) on a Entity Design Pattern.

I'm struggling to see how my code should update and manage a heads-up-display (HUD).

I think there are two main possibilities:

The HUD object has references to the players. It periodically updates itself by querying them.
The different systems (input, physics, ...) update the HUD anytime by sending it new information.

The first seems costly because the information might not have changed as often as the HUD queries for it. The second one seems less automatic because the systems NEEDS to specifically call to update the HUD (plus the HUD needs to provide various methods).

What should I do?


texts: Cascaded Shadow Maps: clipping against scene bounds

texts:
I just implemented an initial version of CSMs based on the MSDN articles Common Techniques to Improve Shadow Depth Maps and Cascaded Shadow Maps.

I fit the shadow projection to the view frustum, and do not clip against the scene bounds, because in Common Techniques to Improve Shadow Depth Maps it is stated:

  It is also possible to clip the frustum to the scene AABB to get a tighter bound. This is not advised in all cases because this can change the size of the light camera's projection from frame to frame. Many techniques, such as those described in the section Moving the Light Texel-Sized Increments, give better results when the size of the light's projection remains constant in every frame.

However, in the paper from the Nvidia SDK the frustum is further clipped against the scene bounds to achieve a maximum used area for the shadow map.

This confuses me. Did the guys from MSDN miss something, is the Nvidia paper simply older or am I not understanding the Nvidia approach correctly?

Edit: I was right in not understanding the Nvidia approach, basically not at all. I confused the crop matrix with a clipping against scene bounds.


texts: How do I make a Java gave without a JFrame?

texts:
I am working on an arcade-like game, and so far, I have been using JFrame. All the action occurs in the JFrame basically.

However, I've noticed that a lot of games that you install on a computer don't have a frame. When you play them on Windows, the game covers the entire screen (the start bar disappears and you can't access any other application on your computer).

I'd like to do that for my game. Is it possible to do so with Java? If so, how would I do this?


texts: How to draw lines round selected objects and lights?

texts:
I need two things to draw in Modern OpenGL.

Please see the image:

Draw lines to represent light's position and direction
Draw xyz axises at the origin of a selected objects

How do I draw these? should I use fragment shader or what?


texts: How to keep the camera view to within room dimensions

texts:
me = self;
    view_yview[0] += ( me.y-(view_hview[0]/2) - view_yview[0]) * 0.1;
    view_xview[0] += ( me.x-(view_wview[0]/2) - view_xview[0]) * 0.3;

This is the code I use to smooth camera movement in game maker. But it's going beyond the room dimensions; showing stuff that shouldn't be shown, as the camera should stop following the player at a point.

How do I achieve this?


texts: How can I make the cursor avoid something completely?

texts:
I wrote some code for a UI button that causes the mouse to avoid it. I realize this is kind of a weird thing to do in a game design-wise, but this is a really weird game. I need a button that is not only unclickable, but also unhoverable. I got it mostly working, but I cannot seem to change the position before the mouse is drawn, probably because mouse movement is handled by the OS, unless there is a problem with my code that I missed. As a result, pushing the mouse against the button boundaries results in a stutter. The mouse briefly appears over the button before I can move it, so it is still possible to click the button.

A demonstration of the button avoidance and stutter: https://youtu.be/7tgIrJ_vMDg

[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
public static extern bool GetCursorPos(out Point pos);

...

void Update () {
    var mousePos = Input.mousePosition;
    if (Application.isFocused && isOver) {

        //Get the current mouse position from OS so we can change it;
        Point cursorPos;
        GetCursorPos(out cursorPos);

        if (oldMousePos.x > xMin && oldMousePos.x < xMax)
        {
            //Coming from above or below. Figure out which one
            //and move mouse accordingly
            if (oldMousePos.y > uiPos.y)
                cursorPos.y -= (int)(rt.rect.height / 2 - (mousePos.y - uiPos.y));
            else
                cursorPos.y += (int)(rt.rect.height / 2 - (uiPos.y - mousePos.y));
        }
        else
        {
            //Coming from either left or right.
            if (oldMousePos.x < uiPos.x)
                cursorPos.x -= (int)(rt.rect.width / 2 - (uiPos.x - mousePos.x));
            else
                cursorPos.x += (int)(rt.rect.width / 2 - (mousePos.x - uiPos.x));
        }
        //Give new coordinates to OS to update mouse position
        SetCursorPos(cursorPos.x, cursorPos.y);
    }
    else
    {
        //track the old position to know what direction
        //they moved their mouse from so we can put it back
        oldMousePos = mousePos;
    }
}

I tried using the Cursor API to force it to software mode thinking that might fix it, but it still stutters, and I would prefer to use the default cursor anyway, and hardware mode if possible. Is there any way to work around this or remove the stutter?


texts: Trying to rotate a point around another point and it's not working

texts:
I am trying to make a function to rotate a point around another point. My maths are very rusty but i did some research and i just dont understand why my function is not working.

public void rotatePoint(int pX,int pY,int angle) {
    int newX = 0, newY = 0;
    int centerX = 400, centerY = 300;

    angle *= Math.PI / 180; // convert angle from deg to rad

    double rotatedX = Math.cos(angle)*(pX-centerX)-Math.sin(angle)*(pY-centerY) + centerX;
    double rotatedY = Math.sin(angle) * (pX-centerX) + Math.cos(angle) * (pY-centerY) + centerY;

    newX = (int)Math.round(rotatedX);
    newY = (int)Math.round(rotatedY);
}

On the image i just provide my original point is in grey. After a rotation of 90 or 180deg i would expect the point to arrive where the green ones are. They arrive where the red points are.


texts: Libgdx Texture Size Rounding Problem with Camera

texts:
I have a problem with with camera usage. I use camera and a virtual coordinate system because I want to scale my game screen to whatever the actual system resolution is.

If I set camera viewport size to 1200, 1600 for example and real application pixel resolution is 600x800 then this problem happens. I want to draw a 62x62 image to the horizontal center of screen. when I use draw function with x equals (1200/2 - 62 / 2) this problem happens.

600 - 31 = 569. Since i draw 62 units wide in virtual coordinate space, its actually 31 pixels in this example. The problem is 31 pixels is impossible to center on a even numbered x axis (600 actual pixels in this example). But camera tries to solve this very badly by default. It just cuts last vertical line from my image and it's rendered wrong!

Ofc in this example I can change app resolution to whatever I want but I want to focus on mobile and support many different screen resolutions and I just wanna think in virtual coordinate space and its units not the pixels resolution of the device. What's the point of using camera when I think about the resolution? How can I prevent such problems?

If I put image to elsewhere (some even number) in x axis for example x=0 the image scales perfectly well and no missing pixels. If I don't use camera at all it also scales perfectly (using only pixel based units).

If there is no solution I feel like camera and viewport classes are useless and everyone must use pixels.

Screenshot of the problem:

Code for my game class:

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MyGame extends ApplicationAdapter
{
   private SpriteBatch batch;
   private OrthographicCamera camera;
   private Texture myTexture;

   @Override
   public void create ()
   {
      batch = new SpriteBatch();
      batch.enableBlending();
      batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);

      camera = new OrthographicCamera(1200, 1600);
      camera.translate(camera.viewportWidth / 2, camera.viewportHeight / 2);

      myTexture = new Texture(Gdx.files.internal("circle.png"), true);
      myTexture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.MipMapLinearLinear);
   }

   @Override
   public void render ()
   {
      Gdx.gl.glClearColor(1f, 1f, 1f, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      camera.update();

      batch.setProjectionMatrix(camera.combined);
      batch.begin();
      batch.draw(myTexture, 569, 150, 62, 62);
      batch.end();
   }

   @Override
   public void dispose () {
      batch.dispose();
      myTexture.dispose();
   }
}

Code for its desktop launcher:

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class DesktopLauncher {
   public static void main (String[] arg) {
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      config.width = 600;
      config.height = 800;
      new LwjglApplication(new MyGame(), config);
   }
}

Image asset I've used in this example:


texts: Why is my TouchScript gesture event not firing?

texts:
I am using TouchScript (v9.0) with Unity (2018.2.14f1) and am struggling with getting the Flicked gesture event to fire. I created an empty game object with a few UI elements in it (text and raw images) and added the Flick Gesture component to it (didn't change any of the settings on it), along with a custom script I wrote to register the Flicked event - this code is mostly from the wiki:

public class FlickGestureHandler : MonoBehaviour {
    FlickGesture gesture;

    // Use this for initialization
    void Start () {
        gesture = GetComponent<FlickGesture>();

        if (gesture != null)
        {
            gesture.Flicked += flickedHandler;
        }
        else
        {
            print("Gesture is null...");
        }
    }

    public void flickedHandler(object sender, EventArgs e)
    {
        print("Flick gesture recorded");
    }
}

I've also added an empty and added a Touch Manager component to it, although I don't know if that does anything by itself, or how to connect it to my draggable game object.

When I run the app, I wait for the gameobject's contents to appear (I am using Keyframe animation and the UI elements do not appear until a few seconds after load), then try to drag the UI elements in any direction and nothing is printed to the console. I am using a touch screen monitor and a touch pen for this. Why is the event not firing? FWIW, I tried creating a simpler example where I just attach the scripts (Flick Gesture and my custom script Flick Gesture Handler) to an image object and I got the same result.


texts: How would one outline an alpha transparency layer in javscript and/or php?

texts:
I simply want an outline/edge detection of the character/item/object that is selected or doing something.

I'm seeing lots of versions of this question for different languages, but I would appreciate an approach that can be implemented in a web context. I don't know if this is better dealt with in the server or can be done on the client side. I have no idea of how to access the alpha transparency layer in any language. Please advise. Sorry for the lack of specificity, just getting a handle on what I want. This would be in a 2d context.

This picture outline object effect shows what i'm going for. Not sure if answers in that question apply to my problem.


texts:
I have only looked into the basics, at least I assume it gets more complex. So does network code really change from one game to the next or is it pretty much portable. For example I can create say a 2 person chat app, now if you want to make it multi-chat you then need to use mutli-threading, ie a new thread for every connection(load a new Winsock object for each connection). I am also reading about mutex ojects, blocking and non-blocking sockets.

You then have 2 base networking API's, Winsock and BSD sockets, there are various wrappers for these such as Boost.

The principle is that you then send a snapshot of all the gamestate data back and forth between client and server and have some kind of load balancing to take into account lag and general synchronicity.

I can't see how this would really change from game to game though, these are fairly linear principles and one set of networking code should be compatible with the next?


texts: How do I make a vector exactly reach a line?

texts: Let's say a vector starts at Point P and points in the direction of v. How do I make sure that this vector exactly reaches the line? Its end should be exactly on the line, and not cross it.


texts: How to determine what triangle in a mesh the cursor is pointing to?

texts:
I have a game I'm working on in which items are "placed" and "selected".

In order to do this, I need to determine what triangle in a mesh the cursor is pointing to.  I have no trouble with getting the cursor position or the orientation/position of the camera - the problem is figuring out how they relate.

I'm guessing that this involves ray-picking, but I have no idea on how to convert a cursor position to a ray that I can test for intersection with a triangle.

A little bit of background:
Game engine: Irrlicht
Language: C++


texts: Finding the position of a point inside a triangle, based on the position of a point in another triangle (barycentric coordinates in Godot)

texts:
I'm trying to translate a UV coordinate into a world coordinate. (this is not in a shader, it's in GDScript in Godot, to bake out a texture based on some raycasts).
So I find out which triangle in the UV map the coordinate is in and then I find the corresponding triangle in the mesh and get it's world position, that's all good.
But then I can't figure out how to translate the points relative position inside the UV triangle to the mesh triangle.
I've been trying to use the distance from the point to each of the triangle points as weights to how much of each of the mesh points I should use to find the point I'm looking for, but having no luck.
Any help would be much appreciated.
Not sure how best to illustrate this. But imagine you had a triangle where you knew the corner points a, b, and c, and a position inside it p. And you had another triangle where you knew the corner points A, B and C, how would you find a point that was relative in the same as p is to abc in triangle ABC.

EDIT: I added an answer based on the comments from DMGregory


texts: Orthographic camera and z-axis in 3D isometric view game

texts:
I'm working  on a game in Away3d. I'm using an orthographic camera and I'm attempting to simulate an isometric view (the camera has a 37° angle and the y-axis is up/down, x-axis is left/right, and z-axis is orthographic).

I hit a snag in understanding how to handle the z-axis of the NPC's relative to the player so that, for example, when the player is below an NPC in Y coordinates, it doesn't appear to be "under" the NPC, but "besides/in front" the NPC, as currently all the 3D models in this scene are Z-axis coordinate 0.

My common sense says that there should be a relation in the sense that if the Y axis coordinates of the NPC is lower than the Y axis coordinates of the player, then the z-axis coordinates should update following an allegory is so that the apparent view of the NPC relative to the player is that the NPC is "behind" the player. But as I said, because all the z-axis are zero for all the models, the players' apparent position is "under" the NPC, as opposed to "in front" of the NPC.


texts:
Maya's preferred format for saving off a UV Snapshot is its own .IFF format, so I was hoping to find a plugin allowing Gimp 2 (Windows) to read it. I've found plenty of plugins for different linux distros, but none are win-friendly (that I can discern - admittedly I'm no whiz with Gimp). Does anyone know of one?

Alternately, .tiff seems to work just fine, so if there's no good reason to bother fiddling with IFFs, I'd appreciate the input there, too.

(sorry if this isn't on-topic)


texts: Visitor-pattern vs inheritance for rendering

texts:
I have a game engine that currently uses inheritance to provide a generic interface to do rendering:

class renderable
{
public:
    void render();
};

Each class calls the gl_* functions itself, this makes the code hard to optimize and hard to implement something like setting the quality of rendering:

class sphere : public renderable
{
public:
    void render()
    {
        glDrawElements(...);
    }
};

I was thinking about implementing a system where I would create a Renderer class that would render my objects:

class sphere
{
    void render( renderer* r )
    {
        r->renderme( *this );
    }
};

class renderer
{
    renderme( sphere& sphere )
    {
         // magically get render resources here
         // magically render a sphere here
    }
};

My main problem is where should I store the VBOs and where should I Create them when using this method?
Should I even use this approach or stick to the current one, perhaps something else?

PS: I already asked this question on SO but got no proper answers.


texts: Moving objects colliding when using unalligned collision avoidance (steering)

texts:
I'm having trouble with unaligned collision avoidance for what I think is a rare case. I have set two objects to move towards each other but with a slight offset, so one of the objects is moving slightly upwards, and one of the objects is moving slightly downwards.

In my unaligned collision avoidance steering algorithm I'm finding the points on the object's forward line and the other object's forward line where these two lines are the closest. If these closest points are within a collision avoidance distance, and if the distance between them is smaller than the two radii of the two object's bounding spheres, then the objects should steer away in the appropriate direction.

The problem is that for my case, the closest points on the lines are calculated to be really far away from the actual collision point. This is because the two forward lines for each object are moving away from each other as the objects pass. The problem is that because of this, no steering takes place, and the two objects partially collide.

Does anyone have any suggestions as to how I can correctly calculate the point of collision? Perhaps by somehow taking into account the size of the two objects?


texts: model view projection multiplication order

texts:
I'm debugging a lighting problem where the camera position is effecting the diffused lighting component on my 3d model. In researching my problem I went back and am reading over all the how to documents. I found that one of my old sources (where I learned open gl 2.0) said this (summarized):

  When creating the modelViewProjection matrix you can't change the order or you'll get unexpected results.  First take the View Matrix and post-multiply it by the projection matrix to create a viewProjection matrix. Then post-multiply the model matrix to get the modelViewProjection matrix.

Looking at my code, all this time I haven't been doing this:

matrixMultiply(mView, thisItem->objModel, mModelView);
matrixMultiply(mProjection, mModelView, mModelViewProjection);

As a test I tried changing it to this:

matrixMultiply(mView, thisItem->objModel, mModelView);
matrixMultiply(mProjection, mView, mViewProjection);
matrixMultiply(mViewProjection, thisItem->objModel, mModelViewProjection);

...but the result appears the same.

EDIT: To answer a question about what the matrices contain. A snapshot of the matrix values:

EDIT2: As a test I did the math both ways to compare the results and even with moving the camera and model around and rotating the model I'm getting the same results for the final ModelViewProjection.


texts:
Currently, my camera rotates with my model's Y-Axis (yaw) perfectly. What I'm having trouble with is rotating the X-Axis (pitch) along with it. I've tried the same method for cameraYaw() in the form of cameraPitch(), while adjusting the axis to Vector.Right, but the camera wouldn't pitch at all in accordance to the Y-Axes of the controller.

Is there a way similar to this to get the same effect for pitching the camera around the model?

// Rotates model on its own Y-axis
    public void modelRotMovement(GamePadState pController)
    {
        Yaw = pController.ThumbSticks.Right.X * MathHelper.ToRadians(speedAngleMAX);

        AddRotation = Quaternion.CreateFromYawPitchRoll(Yaw, 0, 0);
        ModelLoad.MRotation *= AddRotation;
        MOrientation = Matrix.CreateFromQuaternion(ModelLoad.MRotation);
    }

    // Orbit (yaw) Camera around model (camTarget is the model's position)
    public void cameraYaw(Vector3 axis, float yaw)
    {

        ModelLoad.CameraPos = Vector3.Transform(ModelLoad.CameraPos - ModelLoad.camTarget,
            Matrix.CreateFromAxisAngle(axis, yaw)) + ModelLoad.camTarget;
    }

    public void updateCamera()
    {
        cameraYaw(Vector3.Up, Yaw);
    }


texts:
I am currently working on a Mystery Game, where the player has to evolve in a small hamlet and find clues to solve a mystery.

The game is a first person view and the feel is going to be somewhere between the Myst series and a horror game.

I am currently in the early prototyping phase and looking at an efficient way to design my clues. Most of my clues will be in the forms of notes scattered around the game.

I need to design items in unity3d which can therefore:

have a physical presence in the game world as 3D objects.
be subjected to close-ups (either to read or inspect).
be stored in an inventory for the player to consult whenever.

So far I have taken the approach of having the notes fly toward the camera when the player picks them up. I will then have to figure out a way of handling those with an inventory system.

So one could say I have the first two points sorted out, but I'm struggling to see how I could easily stash notes in an inventory.

For the sake of simplicity I will not allow the player to drop items back into the world.

I was thinking of maybe having an "inventory_item" script attached to the game world items and on that script a UI compatible image, so that when the player wants to look up an item again it can see this image as a UI image rather than the physical game object like it has the first time it pick it up.

Alternatively, I could have an inventory script attached to the player with all the UI images already in it associated with an id (say the list index to make things simple). When the player picks up an item, a script on the item, sends a message to the inventory script on the player and adds the id of that item to a another list called "items in bag" on the inventory script. Then the inventory would also have a method which displays in the UI only the UI images of the items for which the id is in "items in bag".

Any suggestions welcome.


texts: XNA Monogame - Move .dll and .xml root folder

texts:
I was just wondering if it's possible to move the dll and xml files into a subfolder, like in this picture:

Thanks !


texts: Texture tearing with UV texture atlas mapping

texts:
The following code maps the texture from a texture atlas to a UV. The problem is I'm having texture tearing issues.

Does anyone know how to overcome this problem and have any suggestions? Here is the code I have, all images are point filtered and no mipmapping is used.

    for (int i = 0; i < mesh.uv.Length; i++)
    {
        UVs.Add(GetUVTextureFromAtlas(mesh.uv[i].x, mesh.uv[i].y, voxel, 0));
    }

    [...]

    Vector2 GetUVTextureFromAtlas(float x, float y, ushort voxel, Facing side)
    {
        Rect rect = GetVoxelTextureRect(voxel, side);
        float xout = UVLerp(rect.x, rect.x + rect.width, x);
        float yout = UVLerp(rect.y, rect.y + rect.height, y);
        return new Vector2(xout, yout);
    }
    float UVLerp(float from, float to, float t)
    {
        float difference = to - from;
        return from + (difference * t);
    }


texts:
I created a sphere object, added a rigidbody component (no kinematics) and attached a script to it like this:

function Update () {
}

function OnCollisionEnter(collision : Collision) {
    Debug.Log("OnCollisionEnter");
}

I then created a cube under the ball, added a box collider component with no trigger of course.

Then, when I run the game, the ball falls down onto the cube, but nothing happens. The OnCollisionEnter function isn't called.

What should I do?


texts:
I tried to version control my project folder with git. When it came to pull the project from the repository, though, something went wrong: apparently scripts are missing and the prefabs and kind of all the graphical elements appear to be pinkish. Does anybody know how to fix this?

This is the .gitignore I'm using at the moment:

Temp/
Obj/
UnityGenerated/
Library/

ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

Thanks in advance.


texts:
I'm currently having trouble getting my head around QueryAABB, and hope to find some answers here.

The LowerBound of an AABB the upper-left corner (and vice versa). Why is that and what idea is behind that?
When exactly does an object count as inside the AABB and is therefor found by a query?


texts:
I have been trying to use the low-level API for UNET and the focus of this problem is this: NetworkEventType recData = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, recBuffer, bufferSize, out dataSize, out error);
This line is supposed to take in information from many different clients and sits within Update() function. I haven't actually started coding anything in yet... But the point is, if the clients are all transmitting data to the server at a rate equivalent to Update() then this line of code will not be able to (I think?) receive all of them at once (10+ clients vs 1 server). So is there a way to not lose any of the incoming data and process them accordingly?


texts: Would it perform faster to split calculation between vertex and fragment shaders?

texts:
Assuming the total amount of computation would be the same (at least as far as my code goes), would there be any performance increase in splitting the calculation and using separate vertex and fragment shaders vs. doing all the calculations in just a fragment shader?

In my use case, I would not be using vertex shaders as they are typically intended (so, not processing actual vertices). I just thought if the GPU hardware is set up such that the pipeline is expected to be used, would it be better to take advantage of that, or would it be just as fast to put it all in a fragment shader. Conceptually, it would be simpler to just use the fragment shader.

Note, that I do need a lot of data going to the fragment shader that is updated every frame (eg. texture buffer object).


texts: Colors set in Blender not displayed in XNA

texts:
I'm trying to create a colored 3D model for my XNA game in Blender. I don't want to use textures - I need only solid colors. Here's the model, as seen in Blender:

After exporting to FBX and opening in Visual Studio 2012 (some kind of built-in viewer I guess), the lightning isn't perfect but the colors are preserved:

But something's wrong when I try to display it using XNA:

Here's my code for displaying objects:

protected void DrawModel(GameObject obj, bool semitransparent = false, float angle = 0.0f)
{
    var transforms = new Matrix[obj.Model.Bones.Count];
    obj.Model.CopyAbsoluteBoneTransformsTo(transforms);

    foreach(var mesh in obj.Model.Meshes)
    {
        foreach(BasicEffect effect in mesh.Effects)
        {
            effect.EnableDefaultLighting();

            Game.GraphicsDevice.BlendState = semitransparent ? BlendState.AlphaBlend : BlendState.Opaque;
            effect.Alpha = semitransparent ? 0.5f : 1.0f;

            if(obj is Player == false)
                effect.DiffuseColor = obj.IsHighlighted ? new Vector3(1.0f, 0.0f, 0.0f) : new Vector3(1.0f, 1.0f, 1.0f);

            effect.World = transforms[mesh.ParentBone.Index]*Matrix.CreateRotationY(angle)*obj.TransformMatrix;
            effect.View = ViewMatrix;
            effect.Projection = ProjectionMatrix;
        }

        mesh.Draw();
    }
}

Why is the whole model white instead of colored? I set colors of the parts by creating a new material and setting its diffuse component to the color I want. All other settings have their default values.

I thought that it's a matter of setting effect.VertexColorEnabled to true, but that gives me an InvalidOperationException saying The current vertex declaration does not include all the elements required by the current vertex shader. Color0 is missing.. Do I need some kind of shader that will understand Blender's vertex properties and will display the model correctly?


texts: Unity Extending Game Object best practice

texts:
What is best practice when wanting to add to GameObject class?

I would like all GameObject to be able to change color IF they have a renderer.
Ive tried using a helper class that takes a GameObject and lerps the color value but if i want it to have an update method it must inherit MonoBehaviour, and if it does inherit it then i cant instanciate that helper class.

Now im thinking about creating a new class that manages a GameObject and inherits from Monobehavoiur. It would have one GameObject as a member that it can manipulate. But then i would have to instanciate it from somewhere.

Hmmm unity has its logic but i havent found it yet. Is it clear what i am having problems with? Otherwise please ask.


texts: What's the difference between UnityEvent and OnTriggerEnter()

texts: I'm new into game development and programming and I have a question that might sound silly or stupid, but I'm having issue understanding the difference between UnityEvent and OnTriggerEnter(). I would like to understand what I can do with UnityEvent that isn't possible with OnTriggerEnter().


texts:
I am trying to make an on/off button for audio in Phaser, and when you click on the button once it shows the off button, but when I click on it again, the on button does not show.  Right now I did not implement the audio feature, I am just working on the button itself first.  Here is the code:
 soundOnOff() {
 gameState.on = this.add.image(this.config.width - 20 , 0 + 30, 'on')
 .setScale(2);
 gameState.off = this.add.image(this.config.width - 20 , 0 + 30, 'off')
 .setScale(2)

 gameState.on.setInteractive();
 gameState.off.setInteractive();
 gameState.off.visible = false;

 gameState.on.on('pointerdown', () => {
 gameState.on.visible = false;
 gameState.off.visible = true;
 });

gameState.off.on('pointerdown', () => {
gameState.on.visible = true;
gameState.off.visible = false;
});

}

Please tell me how I can fix this! Also, how do I make my bird, in gameState.bird, not jump when I click the button.  Thank You!


texts: Issue with Mapping Textures to Models in Blender

texts:
I've been trying to texture a model using Blender, but when I draw on the UV Editor it doesn't show up on the model, and I can't draw on the model itself. I've tried saving the image and the 3D View is set to Texture. Everything seems to be in order and I've followed several tutorials, but none of them seem to work with the version I'm using (2.64-- update was necessary for import plugin) and I'm absolutely stumped.

How can I draw textures to the model? If not within Blender itself, how do I export/import the textures?

EDIT: Vertex Paint works, though it is insufficient for my purposes. In addition, moving to the rendered view produces a solid-color model with none of the applied textures.


texts: What exactly is the difference between Unreal Development Kit and Uunreal Engine 4?

texts: I want to start learning game development and I would obviously come across this tool. So every where I went people mentioned Unreal Engine 4 to be a viable choice, I've tried a bit of Unity and now I want to try Unreal. Only issue I came across UDK and UE4, I downloaded UDK which turns out to be different from tutorials and I can't seem to find any info on that and besides I could only run the software once because after the first time it starts a game, I re-installed UDK I still get the issue, but anyways that's a different topic, what I want to know is whether UDK and UE4 are different and if they are, where do i get UE4, becauuse when I down UE4 (from - https://www.unrealengine.com/dashboard), it downloads a game launcher and no development tool. In case they are same, why is my version of UDK different fr


texts: How to handle GameObjects that have been destroyed but are still held by others?

texts:
I'm developing my own game engine in C++ as a learning exercise. I have employed a fairly standard method of handling destroyed GameObjects:

Mark them as destroyed
Have the scene delete destroyed GameObjects at the end of the update cycle

This is perfectly fine, however if I want a GameObject to hold a reference of another GameObject then I need to decide what happens to that now destroyed object.

At the moment I'm using std::shared_ptr to support multiple ownership of GameObjects so that they are held by both the scene and any other GameObjects within the game. This means that if the scene 'destroys' them they will live on as they are still pointed to by any GameObjects still using them. This could potentially cause strange behaviour when GameObjects no longer in the scene are still used by GameObjects in the scene.

There are alternatives involving raw pointers: where the GameObject pointing to another might start trying to use an GameObject that has actually been deleted, or std::unique_ptrs where GameObjects would not be able to hold a pointer to another.

Is the best strategy simply to ask the object if it has been destroyed before using it everywhere in the code base? This seems like a fairly risky way of ensuring issues don't occur.


texts: Can't import shaders/textures to Godot from Blender 2.8

texts:
I'm using this shader for my models and then i import them like this
This is the original model in blender:

the result in godot:

I think i might have missed some step but not sure of which one, i followed the tutorial video on how to import and other similar guides but the results is the same. Any ideas of what i'm doing wrong?
Looks like my model not importing shader and textures cor


texts: How to allow multiple bullets on screen at once

texts:
Using my universities API, I'm making a basic 2D game where pacman can shoot ghosts

I have a bullet class but at the moment, I only have one instance of the bullet

could anyone help edit this code/give me hints so that whenever I click i add a new bullet to the screen and after a certain amount of time it is deleted

void Bullet::update(int elapsedTime, Input::MouseState* mouseState, Player* pacman)
{

    if (mouseState->LeftButton == Input::ButtonState::PRESSED && !shooting)
    {
        setX(mouseState);
        setY(mouseState);
        shooting = true;
    }
    if (shooting)
    {
        float xDistance = mouseX - position->X;
        float yDistance = mouseY - position->Y;
        float hypotenuse = sqrt((xDistance * xDistance) + (yDistance * yDistance));

        position->X += elapsedTime * ((xDistance) / hypotenuse) / 2;
        position->Y += elapsedTime * ((yDistance) / hypotenuse) / 2;
        currentTime += (float)elapsedTime / 1000;

        if (currentTime >= maxTime)
        {
            setPosition(pacman->getPosition()->X + pacman->getRect()->Width / 2, pacman->getPosition()->Y + pacman->getRect()->Height / 2);
            currentTime = 0;
            shooting = false;
        }

    }
    else
    {
        setPosition(pacman->getPosition()->X + pacman->getRect()->Width / 2, pacman->getPosition()->Y + pacman->getRect()->Height / 2);
    }
}

and the bullet is loaded here

Texture2D* bulletTex = new Texture2D();
bulletTex->Load("Textures/bullet.png", false);
Vector2* bulletPos = new Vector2(pacman->getPosition()->X, pacman->getPosition()->Y);
Rect* bulletRect = new Rect(0.0f, 0.0f, 5, 5);
bullet = new Bullet(bulletPos, bulletRect, bulletTex);

Thanks in advance


texts: Line at edge of transparent texture on XNA mesh

texts:
I have a mesh that is computer generated with a texture on top of it with transparancy on one side. The SamplerState is set to LinearWrap because I would like the texture to wrap. The problem I have is that this transparent edge has some weird aliasing. This does not occur when I set the SamplerState to LinearClamp.

I found that when letting the U coordinate go from 0.1 to 0.9 this does not happen. Probably on the transparent side it interpolates U coordinate 1 with U coordinate 0.

What could be the solution to prevent aside from not letting the U coordinate go all the way to 1?


texts:
I want my arrow to chase the minion that I just rightclicked on.
I have a Minion Class and an Arrow Class. These are the constructors:

    /// <summary>
    ///  Constructs a minion
    /// </summary>
   public Minion(Texture2D sprite, int x, int y, int windowWidth, int windowHeight, bool isFriendly, int minionHealth)

    /// <summary>
    /// Constructor of the bullet from champion to minion
    /// </summary>
   public Arrow(Texture2D sprite, Vector2 sourceEntity, Vector2 targetEntity, float arrowSpeed, int arrowAttackSpeed, int damageDone, bool isArrowActive)

In the Game1 I have the standard if-click structure and I check if the click is on the minions. But I check this with

    foreach (Minion minion in enemyMinions)

So - I want to mark somehow the minion I clicked on and then to send the arrow directly to its moving location.

How to do that?

Update:

        //checks if rightmouse button was clicked to activate the arrow
        if (mouse.RightButton == ButtonState.Released && previousButtonState == ButtonState.Pressed)
        {
            //checks if the right mouse click was on a minion and the minion is in champion's range
            for (int i = 0; i < enemyMinions.Count; i++)
            {
                if (enemyMinions[i].CollisionRectangle.Contains(mouse.X, mouse.Y)
                    && (Math.Abs(mouse.X - enemyMinions[i].X) < vayne.ChampionRange) ||
                    Math.Abs(mouse.Y - enemyMinions[i].Y) < vayne.ChampionRange)
                {
                    //mark the minion that the click was made on
                    theCurrentTarget = enemyMinions[i];

                    //sets the arrow.targetEntity to that particular minion
                    arrow.TargetX = theCurrentTarget.X;
                    arrow.TargetY = theCurrentTarget.Y;

                    arrow.IsArrowActive = true;
                }
            }
        }
        previousButtonState = mouse.RightButton;


texts:
I was having this problem with OpenGL where I'd have all my textures being rendered upside down. I did the most logical thing I could think of and tried reversing the order of the mapping and that fixed the issue. But why? I know that OpenGL's coordinate system is cartesian and that it works by mapping each uv to a specific vertex. I had something like [0,0], [0,1], [1,1], [1,0] which would theoretically as far as I understand it go from:
top-left -> bottom-left -> bottom-right -> top-right.
I changed this to: [1,1], [1,0], [0,0], [0,1] which would represent:
bottom-right -> top-right -> top-left -> bottom left.
In my understanding it should be quite the opposite. Making a pretty quick sketch on paper it shows me that the initial order would theoretically render my texture correctly and not upside down. Am I correct and theres something else messing with my rendering? Like my perspective matrix?
This is my orthographic matrix:
        Matrix4f ortho = new Matrix4f();
        ortho.setIdentity();

        float zNear = 0.01f;
        float zFar = 100f;

        ortho.m00 = 2 / (float) RenderManager.getWindowWidth();
        ortho.m11 = 2 / -(float) RenderManager.getWindowHeight();
        ortho.m22 = -2 / (zFar - zNear);

        return ortho;

I can't really say I understand it though, I had quite a hard time with it. And looking through youtube tutorials and articles you can see most people don't really understand it either, they just use it. I do have a good linear algebra background but still can't wrap my head around how is this matrix normalizing my coordinates (screen coords to OpenGL coords (-1,1)). Anyway, I digress, any help is appreciated.


texts: Java 2D game programming: Different approaches to make a game loop

texts:
I am new to Java game programming, but the more I read the more I'm confused, because I've seen several different approaches to make a game loop:
1. The standard approach, that uses the Timer class (seems to be less precise).
2. The more precise approach that uses System.nanoTime.
3. A simple approach that uses scheduleAtFixedRate.

Which one should generally be preferred and where are the advantages/disadvantages of each approach? Thanks in advance for any info.


texts: Should I make the Cells in a Tiledmap as null when my player hits it

texts:
I am making a Tile Based game using Libgdx. I took the idea from SuperKoalio platformer demo by Mario Zencher. When I wanted to implement Collectables in my game , I simply draw the coins using Tiled Map Editor. When my player hits that, I use to set that cell as null.

Someday on this site suggested me not to do so... never use null. I agreed. What can be any other way. If I am using layer.setCell(x,y) to set the cell to any other cell... even if an transparent one .. my player seems to be stopped by an invisible object/hurdle.

This is my code:

for (Rectangle tile : tiles)
                {
                    if (koalaRect.overlaps(tile))
                    {
                        TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
                        try{
                            type = layer.getCell((int) tile.x, (int) tile.y).getTile().getProperties().get("tileType").toString();
                            }
                            catch(Exception e){
                                System.out.print("Exception in Tiles Property"+e);
                                type="nonbreakable";
                            }

                        //Let us destroy this cell
                        if(("award".equals(type))){
                        layer.setCell((int) tile.x, (int) tile.y, null);
                        listener.coin();
                        score+=100;
                        test = ""+layer.getCell(0, 0).getTile().getProperties().get("tileType");
                        }

                        //DOING THIS GIVES A BAD EFFECT
                        if(("killer".equals(type))){
                            //player.health--;
                            //layer.setCell((int) tile.x, (int) tile.y, layer.getCell(20,0));
                        }

                        // we actually reset the player y-position here
                        // so it is just below/above the tile we collided with
                        // this removes bouncing :)
                        if (player.velocity.y > 0)
                        {
                            player.position.y = (tile.y - Player.height);

                        }

Is this a right approach? OR
I should create separate Sprite Class called Coin.


texts: Inverse of perspective matrix, for what?

texts: I dont understand for what i need the inverse of the perspective Matrix in Computer Graphics and how do i calculate it?Maybe someone has an explanation for me.


texts: Why can't this event call its parent event?

texts:
It's me... Back again... with another Unreal problem...

I have an Event in my Parent Class called Overridable :: PreDialogueScreenEnter

I have overridden the same Event in a Child Class:

Yet when I attempt to call the parent event from the child class, the option is greyed out.

Tl;Dr:

Why call parent event not work >:|


texts: Deforming a lip mesh to match face-tracking points

texts:
I'm creating a lipstick filter. I have a basic mesh for the lip shape ( 140 vertices ) which I am able to render on screen.
I need the mesh since I have my own lighting system, and hence need the normal info. Plus I don't want to create a model at runtime since if I load an obj file I have the flexibility of rendering high quality meshes.
The problem that I am now facing is that when a user is going to use it, their face will be moving around in the video frame, and I will be getting the lips' positions accordingly. Hence at each frame the mesh will be rendered differently ( in one frame he might be smiling, the other he might be frowning etc), in different places in the screen.
How can I set the OpenGL vertices to match the positions of the tracked feature points, and interpolate the rest? I have only 20-ish detection landmark points for each of the upper and lower lip.


texts: How does Hierarchical Pathfinding deal with obstructions in the same chunk?

texts:
Aigamedev.com provides this visualization of HPA*:

All the nodes within the same chunk connect to each other. What if there was an obstruction between nodes in the same chunk? For example:

What would the resulting visualization look like with an obstruction in the center bottom left chunk? How would this be detected?