texts: Implement continuous integration (smoke test)

texts:
Moving from J2EE industry to Android development there is a question in my mind, about continuous integration to perform smoke or integration testing.

I'm building a single game, a memory card game, with junit for small logic testing of classes but cannot figure how to implement the testing for the use of canvas.

If the application is developed just with UI elements from android, it is easy to use the UI Testing environment on the SDK:
UI android automatic testing

but what for canvas?

I would try to explain the current infrastructure:

github or bitbucket as CSV
Jenkins server

  Which captures with SCM a commit on github or bitbucket, download the
  changes, compiles and executes all the junit on the application for
  fail-fast.

TestRail

  Where the testcases for QA are described

While working on J2EE industry I had, a part from previous ones:

JBehave (http://jbehave.org/)

  Which reads from testrail all the testcases linked to a Test plan and
  executes it (the test-cases should use a pattern)

ex:
Preconditions:
1. Be on login screen

Steps:
1. Fill login with *{username}*
2. Fill password with *{password}*
3. Click on button *Login*

Expected:
1.
2.
3. Message with info *Login error*

Jemmy

  As the link you can find above, it is used to test java swing
  components, looks for a common element and interacts with it.

So, from jenkins:

1. we check for changes on code
2. compile the code
3. execute junit
4. execute BDD (deploy code on a server, and execute the integration-testing with jbehave)

graphically it is shown as a pipeline:

My question is:

Is it possible to implement the part I miss, the automatic testing, on canvas application?

As the application can be run on multiple devices, each one with different screen sizes, menu positions, I don't like to use x,y coordinates on tests definitions.

Was anyone in my same concern and found a correct "best practices" solution?

Currently, our QA team, is moving from excel, yeah you read it right, from excel to test rail, so moving from manual testing for test-cases to automatic fail-fast continuous integration would help QA as Development team.

Thank you!!!


texts: How can I use imprecise accelerometer data for controls?

texts:
I want to rotate an object with respect to the phone's position. I use the accelerometer output to detect orientation:

float roll = Gdx.input.getRoll();
float pitch = Gdx.input.getPitch();
float azimuth = Gdx.input.getAzimuth();

Vector3 accel=new Vector3(accelX, accelY, accelZ);
bat.transform.setToRotation(0f, -1f, 0f, pitch);

bat.transform.setFromEulerAngles(azimuth, -pitch, -roll);

However, the accelerometer data fluctuates so strongly that the object jitters.

How can I deal with this?


texts:
I have a process A that starts OpenGL programm with empty world, and need to populate this world from process B that start as separated programm, also all events (like raycast, etc ) has to be communicated from process A to B.

Could someone at least point me in right direction ?

PS
Is this something to do with OpenGL context ?


texts: What might cause edges of an FBX model to appear curved?

texts:
I'm developing an importer/exporter using the FBX SDK. One model I've been using for testing really has me scratching my head:

http://www.turbosquid.com/3d-models/maya-tower-bridge/328242

When I look at the model with my own viewer, with some other 3rd party ones (like the Clockstone one), or based on the screenshots on TurboSquid, all the edges of the bridge look straight. But when I open it with Autodesk FBX Review, it looks all "bulgy":

The scene is composed entirely of meshes and I tried a variety of calls on the mesh parts to see if anything would be returned that didn't just look like default values. All to no avail.

Any perspective would be much appreciated!


texts:
I was thinking about 2D games (like Starcraft), where the sprites are in two dimensions, but the objects that are "higher" in the screen are behind the other objects (I think this is obvious when you think that "higher" in the screen means "far" when simulating a 3D environment).

But, how do you do this programmatically? It is a good idea to track every movement for every object, assigning object to different layers in order to simulate movement in that axis?

Is there a better way?


texts:
I'm using xaitment plugin for Unity as the AI for a demo level but I have a problem. My character is supposed to walk to random points but while it's walking there it's rotating around the point. I can't see what is causing this in my code, I'm assuming it's something to do with my lookat function

using UnityEngine;
using System.Collections;

public class MovementGoto : MonoBehaviour {

    // target position for the movement
    private Vector3 mTargetPosition;
    public Vector3 TargetPosition
    {
        get { return mTargetPosition;}
        set { mTargetPosition = value;}
    }

    public float Speed = 40.0f;

    // Update is called once per frame
    void FixedUpdate()
    {
        // get the current steering direction to reach the target position
        Vector3 walk = this.mTargetPosition - this.transform.position;

        // ignore 3d
        walk.y = 0.0f;
        walk.Normalize();

        // move into the desired direction
        this.transform.LookAt(this.TargetPosition);
        this.transform.Translate(walk);
    }
}


texts: How do I compute the point of a triangle-ray intersection?

texts:
I have a line (the direction vector of the player) and a triangle representing the face of a model (so composed of 3 points).

I can't find the mathematical operation to check if that vector is intersecting with this triangle, and how far from the player...


texts: Handling keyboard and mouse input (Win API)

texts:
There is a number of ways to catch mouse or keyboard under Windows. So I tried some of them, but every of them has some advantages and drawbacks. I want to ask you: Which method do use?

I've tried these:

WM_KEYDOWN/WM_KEYUP - Main disadvantage is that, I can't distinguish between left and right-handed keys like ALT, CONTROL or SHIFT.
GetKeyboardState - This solves problem of first method, but there is new one. When I get that the Right-ALT key is pressed, I also get that the Left-Control key is down. This behaviour happens only when using localized keyboard layout (Czech - CS).
WM_INPUT (Raw Input) - This method also doesn't distinguish left and right-handed keys (if I can remember) and for mouse movement sometimes generates message with zero delta values of mouse position.


texts:
I'm creating a simple asteroids game and I have three lists with: big asteroids, small asteroids and missiles. When the player hits a big asteroid two small asteroids are created. But The problem is that for the most of the time, the two small asteroids never get time to show up! It seems like the missile hits them too, despite that I remove the missile from the list, before the small asteroids are created. The code below is from my object manager.

What is wrong and how can I improve my code to avoid this?

 // Check if missile hit big asteroid
    public void CollisionControlMissileHitAsteroidBig(ContentManager content)
    {
        for (int i = 0; i < missilesList.Count(); i++)
        {
            for (int ii = 0; ii < asteroidsBigList.Count(); ii++)
            {
                if (missilesList.ElementAt(i).Bounds().Intersects(asteroidsBigList.ElementAt(ii).Bounds()))
                {
                    missilesList.RemoveAt(i);
                    for(int x = 0; x < 2; x++)
                        AddNewSmallAsteroidToList(new AsteroidSmall(content, asteroidsBigList.ElementAt(ii).Position));

                    asteroidsBigList.RemoveAt(ii);
                    i--;
                    ii--;
                }
            }
        }
    }

    // Check if missile hit small asteroid
    public void CollisionControlMissileHitAsteroidSmall()
    {
        for (int i = 0; i < missilesList.Count(); i++)
        {
            for (int ii = 0; ii < asteroidsSmallList.Count(); ii++)
            {
                if (missilesList.ElementAt(i).Bounds().Intersects(asteroidsSmallList.ElementAt(ii).Bounds()))
                {
                    missilesList.RemoveAt(i);
                    asteroidsSmallList.RemoveAt(ii);
                    i--;
                    ii--;
                }
            }
        }
    }

EDIT:

I'm not sure I have done right? There are some problems, the big asteroids is still on the screen and then I guess the missile is still there to, because when two new small asteroids are created, most of the time there is only one, which I think is because it collide with the old missile? That's why I removed the missile from the list before I created the new small asteroids. More help is appreciated!

    public void CollisionControlMissileHitAsteroidBig(ContentManager content)
    {
        for (int i = 0; i < missilesList.Count(); i++)
        {
            for (int ii = 0; ii < asteroidsBigList.Count(); ii++)
            {
                if (missilesList.ElementAt(i).Bounds().Intersects(asteroidsBigList.ElementAt(ii).Bounds()))
                {
                    //missilesList.RemoveAt(i);
                    for(int x = 0; x < 2; x++)
                        AddNewSmallAsteroidToList(new AsteroidSmall(content, asteroidsBigList.ElementAt(ii).Position));

                    asteroidsBigListRemove.Add(asteroidsBigList.ElementAt(ii));
                    missilesListRemove.Add(missilesList.ElementAt(i));
                }
            }
        }
        asteroidsBigListRemove.Clear();
        missilesListRemove.Clear();
    }


texts: Instantiate works fine in Editor and does not work after building game

texts:
Here is the situation, In my project everything works fine. After I build the game for windows, the prefab does not instantiate. I don't know which part I missed.
This is how I load the prefab from Resources folder
private void Awake()
{
    areaButtonPrefab = Resources.Load<GameObject>("Prefabs/AreaButton1");
}

And this is how I instantiate prefab for each data in a List
public void SetAreaToUI()
{
    foreach (var j in areaList)
    {
        cloneItem = Instantiate(areaButtonPrefab, originalRect.position, new Quaternion(0, 0, 0, 0), rect);
        TMP_Text text = cloneItem.GetComponentInChildren<TMP_Text>();
        AreaButtonData buttData = cloneItem.GetComponent<AreaButtonData>();
        buttData.area = j;
        text.text = j.areaName;
        cloneItem.SetActive(true);
        cloneItems.Add(cloneItem);
     }
}


texts:
Thinking about a common game, doesn't matter the type of the game, it's very likely that we need some camera type. For example:

Debug camera: controlled by keyboard and mouse, with that we are able to move around in any place of our scene.
Scripted camera: with that we can instruct the camera to move around, following a determinate path.
Player camera.
...

Each of these camera types has its own update function.
The easiest (and bad) system,is to have a camera manager class with a generic update function and specialized update functions for every camera type. Inside the generic update function we have a switch statement that, based on the camera type, calls the proper update function.

Instead of this I've thought to another approach: strategy pattern. We move each camera behavior (update method) in an appropriate class that implements a common interface. In the camera manager we have a member to that interface, and we can set dinamically any behavior we want.

What do you think about that? What other systems do you suggest me?
Thanks.

Additional info: there is the are real possibility that I need more than one camera active, for example for reflections. In short, I must take account also of that.


texts: Whats the mobile touch version of raycast2D and Input.GetAxis Mouse X and Y in Unity?

texts:
I tried
      float pointer_x = Input.GetAxis("Mouse X");
      float pointer_y = Input.GetAxis("Mouse Y");
      if (Input.touchCount > 0)
      {
          pointer_x = Input.touches[0].deltaPosition.x;
          pointer_y = Input.touches[0].deltaPosition.y;
      }

`
for Mouse X and Y but didn't do the results i wanted. I basically have shapes that I want to move on the X and Y axis. So when I move up and Down only move on Y axis, and when I move left and right only move on X axis.
The Raycast2D mobile version of this I'm not sure either.
         Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);

         RaycastHit2D hit = Physics2D.Raycast(worldPoint, Vector2.zero);

         if (Input.GetMouseButtonDown(0))
         {

             for (int i = 0; i < empty.Length; i++)
             {
                 empty[i] = true;
             }

             if (hit.collider != null)
             {
                 startPos = transform.position;

                 offset = gameObject.transform.position -
                          Camera.main.ScreenToWorldPoint(
                          new Vector3(Input.mousePosition.x,
                          Input.mousePosition.y, screenPoint.z));
             }
         }

         if (Input.GetMouseButton(0))
         {

             if (hit.collider != null)
             {

                 Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
                 Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;

                 if (!posY)
                 {
                     if (Input.GetAxis("Mouse X") > 0.1 ||
                         Input.GetAxis("Mouse X") < -0.1)
                     {
                         posX = true;

                         if (Mathf.Round(transform.position.y * 2f) * 0.5f == Mathf.Round(hit.transform.position.y * 2f) * 0.5f)
                         {
                             transform.position = new Vector3(curPosition.x, startPos.y, curPosition.z);

                         }
                     }
                 }

                 if (!posX)
                 {
                     if (Input.GetAxis("Mouse Y") > 0.1 ||
                         Input.GetAxis("Mouse Y") < -0.1)
                     {
                         posY = true;

                         if (Mathf.Round(transform.position.x * 2f) * 0.5f == Mathf.Round(hit.transform.position.x * 2f) * 0.5f)
                         {
                             transform.position = new Vector3(startPos.x, curPosition.y, curPosition.z);
                         }

                     }
                 }

 Mathf.Round(transform.position.y * 2f) * 0.5f + " " + Mathf.Round(hit.transform.position.y * 2f) * 0.5f);
             }

         }

         if (Input.GetMouseButtonUp(0))
         {
             posX = false;
             posY = false;

             if (hit.collider != null)
             {
                 transform.position = new Vector3(outputX, outputY);
 Mathf.Sign(hit.transform.position.x) * (Mathf.Abs((int)hit.transform.position.x) + 0.5f));

 Mathf.Round(transform.position.y * 2f) * 0.5f + " " + Mathf.Round(hit.transform.position.y * 2f) * 0.5f);
             }

             if (Mathf.Sign(transform.position.x) * (Mathf.Abs((int)transform.position.x) + 0.5f) >= 2.5f ||
                 Mathf.Sign(transform.position.x) * (Mathf.Abs((int)transform.position.x) + 0.5f) <= -2.5f ||
                 Mathf.Sign(transform.position.y) * (Mathf.Abs((int)transform.position.y) + 0.5f) >= 1.5f ||
                 Mathf.Sign(transform.position.y) * (Mathf.Abs((int)transform.position.y) + 0.5f) <= -4.5f)
             {
                 Destroy(gameObject);
             }

             clicked = false;
         }


texts: Does XNA provide any special class to make a game server?

texts:
For my multiplayer game server, I made a class inheriting from "Microsoft.Xna.Framework.Game", just like I did for the client-side part.

The thing is, I don't need any graphical display for the server, so I end up with a useless blank game window floating around. Also, the LoadContent/UnloadContent and Draw overrides are left empty. On the other hand, I still need to use Microsoft.Xna.Framework.Game for the game loop and logic update parts.

So is there any special class in XNA made especially for the server-side part, or is everyone else doing it just like I do?


texts:
I'm making a very simple game that revolves mostly around user-created mods. So far I've seen most games using Lua or something like Lua to enable user scripting, but recently I've seen people using dynamically loaded, AOT'd libraries to increase performance. When would I use one over the other?

The only advantages I can find are that scripting languages are easier to approach by non-programmers (particularly Lua), or that dynamic loading will improve performance and will be more lightweight (no need for an embedded interpreter).


texts: How to only allow one space in an InputField?

texts:
I've been messing with this for a while now and I can't get this to work 100%. I'm using an InputField for players to enter a character name, and I want to allow a first and last name. Here's how I've been trying this:

private void CharNameRestrictions() {
    Debug.Log(spaceCount);

    if (Input.GetKeyUp(KeyCode.Space)) {
        spaceCount++;
        if (spaceCount > 1) {
            spaceCount = 1;
            playerNameInput.text = playerNameInput.text.Remove(playerNameInput.text.Length - 1);
        }
    }

    if (!(playerNameInput.text.Contains(" "))) spaceCount = 0;
    if (playerNameInput.text.Length > 15) playerNameInput.text = playerNameInput.text.Remove(playerNameInput.text.Length - 1);

}

This sort of works, but if you press and hold space while typing another character, it still lets you add additional spaces. Is there a way to simply ignore the space keycode when there is already a space in the field?


texts: How to find 2D grid cells swept by a moving circle?

texts:
I'm making a game based on a 2D grid, with some cells passable and some not. Dynamic objects can move continuously, independent of the grid, but need to collide with impassable cells.

I wrote an algorithm to trace a ray against the grid, that gives me all cells that ray intersects. However, actual object are not point-sized; I'm currently representing them as circles. But I can't figure out an effective algorithm to trace a moving circle. Here's a picture of what I need:

The numbers show in what order the circle collides with grid cells. Does anybody know the algorithm to find these collisions? Preferably in C#.

Update The  circle can be bigger than a single grid cell.


texts: How would you declare a Texture object in the libgdx skin json file, using a region from a texture atlas?

texts:
I have a texture atlas that is linked to my skin.json file. The atlas contains a region named "game-title".
I would like to declare a com.badlogic.gdx.graphics.Texture object in the json file, to retrieve it later in my code via skin.get(name, Texture.class).
I tried declaring it as follows, but it does not work - exception gets thrown - com.badlogic.gdx.utils.SerializationException: Class cannot be created (missing no-arg constructor): com.badlogic.gdx.graphics.Texture:

"com.badlogic.gdx.graphics.Texture": {
  "game-title": {name: "game-title"}
}

What am I doing wrong here? What would be the correct way to do this?
Is trying to declare a Texture in such a way a correct thing to do, in the first place?

Many thanks in advance for your feedback.


texts: How to create in game menu attached to unit

texts:
I'm creating a game similar to Banner Saga, except my game will be in 3D, with a camera that can move around and zoom in and out. What I want is for a menu to appear after the user clicks on a unit. This menu must always be visible and facing the camera.

The menu that has the foot and sword symbols is what I want.

How can I get a similar result in 3D? The new Unity UI canvas isn't really suitable, since the camera will move around, and the menu must stay next to the unit. The menu elements can't be covered up by things in front of it, like other units. Thanks


texts: How to calculate vector of projectile initial velocity

texts:
There are point A (origin) and point B (target). And also there is gravity vector G.
I need compute initial velocity of projectile (throwing arc trajectory from point A to point B).

Also I need to control speed of projectile (Speed) and flexion of throwing arc.

How compute this?


texts: How can I create a mesh of triangles made from the vertices of a polygon and contained within that polygon?

texts:
I'm trying to programatically generate a mesh, given the vertices of a polygon, which is contained within that polygon. For example, starting with these points:

I would want to generate a mesh similar to this:

My first port of call would be a Delaunay triangulation, but having implemented this, I came up against the problem that this was not contained within the polygon, i.e. it produced a mesh like this:

My question then is, is there either an algorithm which produces the desired result rather than the Delaunay result (because I can't find one online), or a modification that I can make to the Delaunay triangulation algorithm that will fix this?
I'm using the Bowyer-Watson algorithm, by the way. Thank you!


texts: How does Unity input work with touchscreens

texts: I'm trying to make a racing game on android using unity.  I want to make a car move forward when I touch an image button like in the picture below.  I've already made it work using the keyboard.  How do I do the same with on-screen buttons and touch input in android?


texts: Should widgets be part of a scene in a 2D game?

texts:
I'm in the middle of separating logic and drawing of a 2D game, i.e. I'm moving from scenes/entities that draw themselves to scenes/entities that merely store and update data, getting drawn by a renderer.

This works pretty well for scenes and entities, but I can't figure out how the UI fits in. Right now, I draw widgets in the draw routines of some scenes. Scenes can currently also handle input, so it's relatively close to how UI toolkits do things. There are even scenes with nothing but UI, e.g. the main menu. But with the new approach where scenes don't draw themselves anymore, I need a new approach.

How could I do this? Are widgets even supposed to live in scenes, alongside entities? Or should they be in their own kind of scene, e.g. windows or dialogs?


texts:
Possible Duplicate:
  How do I make a jumping dolphin rotate realistically?

I want to program a dolphin that jumps and rotates like a real dolphin. Jumping is not the problem, but I don't know how to make the rotation. My dolphin always rests in the same angle while it jumps. But I want that it changes the rotation during the jump, like a real dolphin does.
How can I improve the rotation?

public class Game1 : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    Texture2D image, water;
    float Gravity = 5.0F;
    float Acceleration = 20.0F;
    Vector2 Position = new Vector2(1200,720);
    Vector2 Velocity;
    float rotation = 0;
    SpriteEffects flip;
    Vector2 Speed = new Vector2(0, 0);

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        graphics.PreferredBackBufferWidth = 1280;
        graphics.PreferredBackBufferHeight = 720;
    }

    protected override void Initialize()
    {
        base.Initialize();
    }

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
        image = Content.Load<Texture2D>("cartoondolphin");
        water = Content.Load<Texture2D>("background");
        flip = SpriteEffects.None;
    }

    protected override void Update(GameTime gameTime)
    {
        float VelocityX = 0f;
        float VelocityY = 0f;

        float time = (float)gameTime.ElapsedGameTime.TotalSeconds;
        KeyboardState kbState = Keyboard.GetState();
        if(kbState.IsKeyDown(Keys.Left))
        {
            rotation = 0;
            flip = SpriteEffects.None;
            VelocityX += -5f;
        }

        if(kbState.IsKeyDown(Keys.Right))
        {
            rotation = 0;
            flip = SpriteEffects.FlipHorizontally;
            VelocityX += 5f;
        }

        // jump if the dolphin is under water
        if(Position.Y >= 670)
        {
            if (kbState.IsKeyDown(Keys.A))
            {
                if (flip == SpriteEffects.None)
                {
                  rotation = 45;
                  VelocityY += 40f;
                }
                else
                {
                  rotation = -45;
                  VelocityY += 40f;
                }
            }
        }
        else
        {
            VelocityY += -10f;
        }

        float deltaY = 0;
        float deltaX = 0;

        deltaY = Gravity * (float)gameTime.ElapsedGameTime.TotalSeconds;

        deltaX += VelocityX * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration;
        deltaY += -VelocityY * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration;

        Speed = new Vector2(Speed.X + deltaX, Speed.Y + deltaY);

        Position += Speed * (float)gameTime.ElapsedGameTime.TotalSeconds;

        Velocity.X = 0;

        if (Position.Y + image.Height/2 > graphics.PreferredBackBufferHeight)
            Position.Y = graphics.PreferredBackBufferHeight - image.Height/2;

        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin();
        spriteBatch.Draw(water, new Rectangle(0, graphics.PreferredBackBufferHeight -100, graphics.PreferredBackBufferWidth, 100), Color.White);
        spriteBatch.Draw(image, Position, null, Color.White, MathHelper.ToRadians(rotation), new Vector2(image.Width / 2, image.Height / 2), 1, flip, 1);
        spriteBatch.End();

        base.Draw(gameTime);
    }
}


texts: What was game development on the Apple II like?

texts:
I've asked a similar question about DOS development a while ago and got an excellent answer:
What was the typical toolchain for DOS game development?

Now I'm wondering what game development was like on the Apple II in the late 70s/early 80s. I'm mainly interested in the early ones: II and II+, but I'd like answers about IIe etc. as well.

So here are my questions:

What languages were used?

I presume 6502 assembler, but BASIC was bundled and probably used a lot, too. Can you think of popular games written in BASIC? How about C?

What was 6502 assembler development like?

I've noticed that you can enter op codes directly if you start the system monitor, and you can even execute assembler directly with the mini assembler. But I cannot imagine that games were written like that, were there editors/IDEs? How were programs stored on disks/tapes?

What was BASIC development like?

The Apple II BASIC interpreter is not half bad, I guess you can write full programs in there. It also allows you to SAVE/LOAD programs, I presume to disk/tape. But was there no visual editor?

Were there any APIs or Middleware?

Or was it necessary to talk directly to the hardware all the time if you wanted to draw something or play a sound? Were there any libraries at all?

Anything else that's different from today?

I'd be happy to hear any other differences, like what image/audio formats were used. Given that there wasn't really a concept of files if I understand it correctly, I'm wondering how that worked. Did you have to type your graphics and sounds in assembler? How did that work in BASIC?


texts: Android threads trouble wrapping my head around design

texts:
I am having trouble wrapping my head around game design. On the android platform, I have an activity and set its content view with a custom surface view. The custom surface view acts as my panel and I create instances of all classes and do all the drawing and calculation in there.

Question: Should I instead create the instances of other classes in my activity?

Now I create a custom thread class that handles the game loop.

Question: How do I use this one class in all my activities? Or do I have to create a separate instance of the extended thread class each time?

In my previous game, I had multiple levels that had to create an instance of the thread class and in the thread class I had to set constructor methods for each separate level and in the loop use a switch statement to check which level it needs to render and update. Sorry if that sounds confusing.

I just want to know if the method I am using is inefficient (which it probably is) and how to go about designing it the correct way. I have read many tutorials out there and I am still having lots of trouble with this particular topic. Maybe a link to a some tutorials that explain this? Thanks.


texts:
I'm developing an RTS, and having a little difficulty with collision detection.  From what I understand RTS generally don't bother with collision detection and just try to avoid collision, and that is what I am trying to accomplish.

My game uses a grid for static obstacles, but units are not bound to the grid for movement.  How do I allow for units to avoid collisions, both with static obstacles and with other units?  Right now my workaround is to redirect units around static obstacles every time they move from point to point (and every time a new obstruction is placed on map, units replan their routes).  This doesn't seem like an ideal solution, but it works.  I have no idea how to handle unit-unit collisions.


texts: How to code Time Stop or Bullet Time in a game?

texts:
I am developing a single-player RPG platformer in XNA 4.0. I would like to add an ability that would make the time "stop" or slow down, and have only the player character move at the original speed(similar to the Time Stop spell from the Baldur's Gate series).
I am not looking for an exact implementation, rather some general ideas and design-patterns.

EDIT:
Thanks all for the great input. I have come up with the following solution

    public void Update(GameTime gameTime)
        {

            GameTime newGameTime = new GameTime(gameTime.TotalGameTime,
 new TimeSpan(gameTime.ElapsedGameTime.Ticks / DESIRED_TIME_MODIFIER));
            gameTime = newGameTime;

or something along these lines. This way I can set a different time for the player component and different for the rest. It certainly is not universal enough to work for a game where warping time like this would be a central element, but I hope it should work for this case. I kinda dislike the fact that it litters the main Update loop, but it certainly is the easiest way to implement it.
I guess that is essentialy the same as tesselode suggested, so I'm going to give him the green tick :)


texts: Entity interpolation with a Unity listen server

texts:
How can this be done? I've implemented client side interpolation but I'm at a loss on how to implement it on a listen server. In order for the listen server player to see the same thing as the clients, it needs to display it's past positions.

The problem with this is, as far as I know, there's no way to specify positions for rendering and positions for collision and everything else in Unity. transform.position is used for everything. Is there a way to draw in a different position?


texts: What are the most commonly used programming languages?

texts: When I took my Java courses a year ago, I was told that Java is used mostly in the overseas gaming companies while C++ is used here in the US. What languages should I focus on learning in-depth?


texts: Is there a way to set the cursor's location in JavaFX while the window is in focus? I've searched the possibility of the Scene's cursor object, but that leads to a dead end.


texts:
I'm getting some artifacts when I try to use a colour attachment on an FBO. I'm saving my first pass as a texture, then passing it as an input to an anti-aliasing shader. The result is, as below, some weird noise and an enforced black background. The AA is applied fine.

GL.BindFramebuffer(FramebufferTarget.FramebufferExt, _hndFBO);
GL.BindTexture(TextureTarget.Texture2D, 0);
GL.DrawBuffer((DrawBufferMode) FramebufferAttachment.ColorAttachment0Ext);
GL.PushAttrib(AttribMask.ViewportBit);
GL.Viewport(0, 0, _intWidth, _intHeight);
//Do rendering here
GL.PopAttrib();
GL.BindFramebuffer(FramebufferTarget.FramebufferExt, 0);
GL.DrawBuffer(DrawBufferMode.Back);

Any ideas? Need more code?


texts: Two player platformer game - gameover issue

texts:
I'm creating a two player platformer game but facing issues when one of the player dies. So far I have created two players and added the following script to both. The issue I'm facing is that once any of the players hits an obstacle, the dying animation and the gameover screen just keep on repeating. I think this is because I have the code to check if the player is dead in the update function of the gamemanager script. I would like the game to stop as soon as any player hits an obstacle and then the gameover screen should pop up.

public class Player: MonoBehaviour {

public Rigidbody2D myRigidbody { get; set; }

public float jumpForce = 2.0f;

[SerializeField]
public Animator animator;

public bool isDead = true;

public GameManager gameManager;

public bool IsDead
{
    get
    {
        return isDead;
    }
}

void Start () {
    myRigidbody = GetComponent<Rigidbody2D>();
}

void Update () {

        if (Input.GetMouseButtonDown(0) && !IsDead)
        {
           jump = true;
           animator.SetBool("jump", true);
        }else
        {
           animator.SetBool("jump", false);
        }
}

public void OnTriggerEnter2D(Collider2D collision)
{
    if (!isDead && collision.tag == "Obstacle")
    {
        StartCoroutine(Die());
    }

}

public IEnumerator Die()
{
    isDead = true;
    animator.SetBool("Die", true);
    yield return new WaitForSeconds(2);
    gameManager.GameOver();

}

public void Jump()
{
    myRigidbody.AddForce(jumpForce* Vector2.up, ForceMode2D.Impulse);
}

This is the gamemanager script:

public enum GameStates { Start, InGame, GameOver};

[SerializeField]
private Player player;

[SerializeField]
private Player player1;

public GameObject startPanel, ingamePanel, gameoverPanel;

void Update () {

    if(player.IsDead )
    {
        StartCoroutine(player.Die());
        GameOver();

    }

    if (player1.IsDead)
    {
        StartCoroutine(player1.Die());
        GameOver();
    }
}

public void GameOver()
{
    UpdateUI(GameStates.GameOver);
}


texts:
How do I would precalculate trajectory of a kicked ball, when it's spinning?

I'm applying spinning using simplified Magnus effect every frame like this and it works:

acceleration += swerve × velocity

My question is: do the equation below for calculating object trajectory can be extended to include the ball spinning?

position = start + 0.5*acceleration*time^2 + velocity*time;

I'm using Euler integration and ball moves fine. I just want to know how to predicts ball's movement path.


texts: Battle Simulation for Singleplayer/Online Hybrid Game

texts:
So I was playing Clash of Clans, and just wondered on how they authenticate the result of the battle.

This isn't exactly specific to Clash of Clans though. In my observation, while CoC is an online game. Their battle is just a singleplayer, but still I feel like the battle is verified somewhere in their server?

This would apply to games that are :

Singleplayer (no 2nd player to sync to).
Doesn't need constant communication to server during battle.
But the result still important and must be authenticated/verified.

My current guess is during/after a battle, the client app will send the inputs/actions of the player to the server. Then in server, the battle will be re-simulated again using the input/actions at a much faster time/pace.

For this to work, the battle has to be deterministic (unsure if that's the right word) so that same inputs/actions will produce the same result.

But if this is the "proper" way, then it would be really heavy on the server CPU's side isn't? even with scaling, I think.

I am leaning on this solution, but something doesn't feel right... there might be a better way...

That's why I came here today to consult for ideas/suggestions..

I'm thinking if there is a safe way to do the simulation/result on the client side? like encrypt the sensitive stuffs? is this even possible?

Thank you!


texts: UE4 - Event Tick and getting Forward Vector

texts:
I'm trying to make a game where my character rotates towards cursor (that works). He can choose between a few weapons (also works). One of the weapons works like a machine gun. My idea was to make a simple solution with:
Event tick -> gate (opened by pulling LBM and closed by releasing it) -> gate (closed after firing and opened after some delay) -> spawning projectile which leads to a sequence that closes / opens the second gate.

It doesn't work perfectly. The projectile spawns with the right scale and location, but the rotation is always pointing straight forward.
If the exactly same blueprint is attached to anything else (straight up to the LMB pull or a timer), it works perfectly. However, doing the LMB pull defeats the whole purpose, as it's not a machine gun any more, and timer... is less then perfect I believe. I liked my solution using gates but it just doesn't want to work.
For example, this bit works with no problem (even though the spawning and rotation code is literally copy pasted):

Does anyone have an idea on how to fix this?


texts: How to calculate move forward direction in Libgdx with Box2d body

texts:
I'm working on a game using Libgdx, I've create my world, bodies, fixtures etc. Everything is functional everything is working perfectly but the problem is my body just can left-right-up or down and I do not want to just do this, I want my body go toward to its front side, so it will be like that; User press "D" and Body (player) rotate around and user press "W" body should go wherever its looking direction.

The picture maybe will tell you what is the problem more clearly.

I do not think to share any code blocks because I didn't write any specific code, I just wrote body properties etc. you know. But here is my update method;

     public void update(float dt) {
       if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
            player.getBody().setLinearVelocity(0f, 0.5f);
    }
       if (Gdx.input.isKeyPressed(Input.Keys.D)) {
           player.getBody().setAngularVelocity(-0.5f);
    }

And if it is possible, I don't want to use body.setTransform() method for move my bodies.


texts: I want to create a button whose clickable area is only specified by a BoxCollider with Unity's new UI (similar to how you would do it from within NGUI). I can't get a Unity Button to work without the presence of an Image component (which ultimately represents the clickable area of the button).


texts: Is there a way to capture back button twice in same activity libgdx game

texts:
Can anybody tell me if there is a possibility to capture back button twice in same activity in libgdx.
What i want to achieve is  that if the user press back button once the game pause. if in the pause screen user press back key again so the level exit. This happens well in "Video" that is the built in app in android OS. During video play a if user press back button it toast to press back again to exit.

so I want somthing like this.

if (Gdx.input.isKeyPressed(Keys.BACK)) {

        code to call game pause  state

  if (Gdx.input.isKeyPressed(Keys.BACK)){   //// is this possible?

  game.setScreen(new Menu(game))

 }

    } else {
        code to call game resume state
    }


texts: Cant get a Farseer Physics body’s rotation to follow the mouse

texts:
Here is what’s in my HandleKeyboard() method that is called from the Game1 Update method.

        MouseState mState = Mouse.GetState();
        // the Vector2 that will hold the angle from the player to the mouse pointer.
        Vector2 mDirection = new Vector2(0, 0);

            // Get the current mouse position from the state update in the beginning of this method.
            Vector2 mPosition = new Vector2(mState.X, mState.Y);
            // Subtract the potsition of the player fromthe mouse pointer to get the exact angle in a vector2
            mDirection = mPosition - arrow.Position;

            // Control Rotation
            arrow.FixedRotation = true;
            // display the arrow in the rotation gathered above.
            arrow.Rotation = (float)Math.Atan2(mDirection.Y, mDirection.X);

From what I have read, this seems like the exact right thing to have the arrow look at my pointer. However when I rotate the mouse around the pointer it really doesn’t work properly.

It's hard to explain so here is a youtube video displaying what’s happening

I really hope you can tell me what’s going wrong.


texts:
How do I turn Simplex noise like:

into something like:

or

The noise has too many white spots and varies too much to represent things like continents. Where it's water, water, water, and then land with cut out edges.


texts: OnCollisionEnter2D just flat out not running for certain objects

texts:
I am working with the Unity3D Engine in 2D mode. Currently I am trying to make a circle collider bounce off of a composite collider for the walls of my game. The only issue is that for some reason the OnCollisionEnter2D function does not seem to even trigger when the circle collider hits the walls. I have used the log to determine this. I am curious as to why it has this behviour, since it does end up triggering when the player contacts the circle collider? Here is the important parts of the script:

public class sword : MonoBehaviour {

public Rigidbody2D rb;
public CircleCollider2D coll;

public float speed;
public Vector2 trajectory;
public GameObject Player;

// Use this for initialization
void Start () {
    speed = 0.0f;
    anim = Player.GetComponent<Animator>();
}

private void OnCollisionEnter2D(Collision2D collision)
{
    Debug.Log("collided");
    if (collision.gameObject.tag == "player")
    {
        transform.position = new Vector2(-1000, -1000);
        Player.GetComponent<movement>().equipped = true;
    }
    if (collision.gameObject.tag == "solid")
    {
        ContactPoint2D otherObject = collision.contacts[0];

        Vector2 hit = otherObject.point;
        Vector2 normal = otherObject.normal;
        trajectory = Vector2.Reflect(trajectory, normal);

    }
}

private void FixedUpdate()
{
    //constantly calculating new velocity
    rb.velocity = speed * trajectory;
    speed = speed * 0.93f; //drag
    if (speed < 0.0001f)
    {
        speed = 0.0f;
    }
    if (speed > 1)
    {
        Physics2D.IgnoreCollision(Player.GetComponent<CircleCollider2D>(), coll, true);
    }
    else
    {
        Physics2D.IgnoreCollision(Player.GetComponent<CircleCollider2D>(), coll, false);
    }
}
}

More Details: My speed variable is set from a separate script, in case you are wondering. Everything is on the layer 0.. The Rigidbody for player is dynamic, for the ball it is kinematic, and for the walls it is static. Also here is an image of what the game screen would look like, I've labelled the walls and the circle collider (used for a sword).

Thank you.


texts: How to load sprites manually from a file in unity?

texts: We're making a game, in which the User can apply their own textures to the game in order to make their own rooms. Is there a way to make a prefab with sprites, scripts, colliders, etc during runtime? With a script or something?


texts: Calling function every n second javascript game

texts:
I making a game and I want to call a function that runs every random second to spawn something every time. I've seen some posts that said to use the setInterval() function to keep track of the time but I don't know where to implement it because I'm using the requestAnimationFrame() to loop the game. I also tried to implement it in the update function of the classes but it doesn't seem to work.
This is my main with the loop
import Game from '/src/game.js';

let canvas = document.getElementById('main');
let ctx = canvas.getContext('2d');

const WIDTH_SCREEN = 800;
const HEIGTH_SCREEN = 600;

let game = new Game(WIDTH_SCREEN, HEIGTH_SCREEN);
game.start();

function loop() {
    ctx.clearRect(0, 0, WIDTH_SCREEN, HEIGTH_SCREEN);

    game.update(ctx);

    requestAnimationFrame(loop);
}

window.addEventListener("keydown", (event) => game.controller.keyListener(event));
window.addEventListener("keyup", (event) => game.controller.keyListener(event));
requestAnimationFrame(loop);


texts: How to define a weak-perspective camera in openGL?

texts:
I know how to define the perspective camera as well as weak-perspective camera in the Math.
But how to define a weak-perspective camera () in openGL?


texts: How remove banner adView from a Screen in libgdx?

texts:
I have an AdMob banner in the game. But I need this banner not to be shown in Screen_1 and when user enter Screen_2 I need to show the banner.
When I call AdView.gone() it dissapears from screen but coordinates becomes wrong and touch position doesn't match with coordinates. How can I properly remove AdView.


texts: I'm planning to implement an ecs system for my game but i have foreseen a problem.  How will a rendering system be able to render entities in the correct order based on their depth component?  What are some of the ways that this can be accomplished?  One way i can think of is sorting the components array by depth of but this can be tricky especially if using a mega array of components for all entities.  I'm using python but i might want to make the ecs in rust.


texts: Should I package and sell my game on the unity3d asset store?

texts:
I'm trying to figure out if I should refurbish and refactor a game I and some friends have made. It's released on kongregate and wasn't a super hit but I feel there's a lot of interesting techniques and solutions going on that new or intermediate developers would like to see. The only thing that's holding me back is that I don't know if people are interested in it at all. Would you be interested in buying the source code and assets for this game?

Check it out and you'll see that there's a lot of things happening in the game. If we packaged it and sold it, we would of course tidy it up a bit which would involve more work so I would really appreciate your honest opinion.

We've looked around and haven't found actual released games in the unity3d asset store. Maybe we just didn't look enough though. We're thinking of setting a price tag of between 150 and 200€. What's your opinion on this price?

And in general, what's your opinion on selling assets and source code? Should I be wary of any legal implications (like my customer licensing my stuff and then forbidding me from selling it)?

I posted this over at UnityAnswers as well but I know I rather go here for gamedev questions so I'm hoping other unity devs will drop by here too.

Edit:
Reconsidering after getting some great advice we'll probably rip out the assets only and market those as space stuff or something. We'll then market the assets with the help of some free classes of code showing off some of the examples that were hard for us to do when we were (more) beginners. The unify wiki might benefit from having some of the code that we've done and that isn't all that hard but a bit tedious.

If we actually "finish" the game (it is indeed an asteroids spinoff and was never intended to be anything else, apart from some sandbox modes we've been experimenting with) we'll probably sell it with a decent price tag for an indie game like this.


texts: Achievement / Upgrade / Unlockable Bonus Calculations

texts:
I'm trying to figure out a good way of handling a system of upgrades in a game where multiple upgrades (including things the player can't directly purchase, e.g. achievement bonuses) can affect the same value (e.g. "+X% more income" or "Y% faster production").

I've seen at least three different approaches and I'm not keen on any of them and was wondering if there was another pattern that would work.

The approaches I know of:

Keep an array of all possible upgrades, loop over them any time the value needs to be retrieved. Computationally expensive, as the value is not cached.
Keep a cached value and recompute only when the upgrades are purchased. Requires having a value for every possible modifier as a variable in the code.
Keep a list of all achievements/upgrades (likely already done) and if-check only the ones relevant. Requires large blocks of code in cases where multiple upgrades affect the same value.


texts: How do I Fallback to Older DirectX Versions?

texts:
I had a feeling that it would be easier to tackle this problem before I got too deep into development (unless, of course if that's a bad idea/the hard way, please inform me...). I'm creating my game to be run ideally on DirectX 11, however, I want to offer it on DirectX 10, and I'm unsure if it is worth offering it for DirectX 9 for XP users. I'm not too sure how this fallback even works, as I can't find many articles on the internet. If someone could give me an in-depth article, that would be great.

I've read a little about how since DirectX11 is completely absent on XP, it is hard to even check for support. Someone mentioned having multiple applications for each version, is this a good idea?

Thanks to anyone who can point me in the right direction here.


texts:
I'm making a simple tile-map system in LWJGL, and I'm trying to figure out how to detect if the mouse is clicking inside of a tile. So far no matter where I click it's always the same tile that is shown.

Code:

int blockWidth = 100;
int blockHeight = 100;

List<Tile> tiles = new ArrayList<Tile>();

private void addTiles(){
    for(int i = 0; i < ((Display.getHeight() / blockHeight) * (Display.getWidth() / blockWidth)); i++)
        tiles.add(new Tile(10,10,blockWidth,blockHeight, i));
}

//...

if(Mouse.isButtonDown(0)){
            System.out.println("Mouse clicked at (" + Mouse.getX() + ", " + Mouse.getY() + ")");
            for(Tile tile : tiles){
                if(tile.inBounds(Mouse.getX(), Mouse.getY())){
                    tile.highlight();
                    System.out.println("Box clicked at (" + Mouse.getX() + ", " + Mouse.getY() + ").");
                    break;
                }
            }
}

the inBounds method:

public boolean inBounds(int x, int y){
    Rectangle bounds = new Rectangle();
    bounds.setBounds(x, y, width, height);
    if(bounds.intersects(x,y,1,1)){
        System.out.println("Tile " + num + " clicked. X/Y val is (" + this.x + "," + this.y + ")");
        return true;
    }else{
        return false;
    }

}


texts: Displaying performance data per engine subsystem

texts:
Our game (Android based) traces how long it takes to do the world logic updates, and how long it takes to a render a frame to the device screen.

These traces are collected every frame, and displayed at a constant interval (currently every 1 second).

I've seen games where on-screen data of various engine subsystems is displayed, with the time they consume (either in text) or as horizontal colored bars.

I am wondering how to implement such a feature?


texts:
Created a game login form using the Nifty GUI. The interface reacts to the movement and clicking of the mouse, but ignores the input in the text fields. Whether the program is looking for a click handler, instead of typing, or I don’t know what. What could be the case and how to fix it?

Interface/screen.xml:

<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd
https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
    <useStyles filename="nifty-default-styles.xml"/>
    <useControls filename="nifty-default-controls.xml"/>
    <screen id="start" controller="mygame.LoginScreen">
        <layer id="background" childLayout="center">
            <image filename="Interface/start-background.jpg"></image>
        </layer>
        <layer id="foreground" childLayout="center">
            <panel id="panel" height="25%" width="75%" align="center" childLayout="horizontal">
                <panel id="panel_left" height="100%" width="25%" align="left" childLayout="vertical">
                    <text text="E-mail:" font="Interface/Fonts/Default.fnt"/>
                    <text text="Password:" font="Interface/Fonts/Default.fnt"/>
                </panel>
                <panel id="panel_center" height="100%" width="50%" align="center" childLayout="vertical">
                    <control name="textfield" maxLength="50" font="Interface/Fonts/Default.fnt"/>
                    <control name="textfield" maxLength="100" passwordChar="*" font="Interface/Fonts/Default.fnt"/>
                </panel>
                <panel id="panel_right" height="100%" width="25%" align="right" childLayout="vertical">

                </panel>
            </panel>
        </layer>
    </screen>
    <screen id="hud" controller="de.lessvoid.nifty.screen.DefaultScreenController">

    </screen>
</nifty>

src/mygame/Main.java:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import com.jme3.niftygui.NiftyJmeDisplay;
import de.lessvoid.nifty.Nifty;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }
    public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
    public Nifty nifty = null;
    @Override
    public void simpleInitApp() {
        NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
        nifty = niftyDisplay.getNifty();
        nifty.fromXml("Interface/screen.xml", "start");
        guiViewPort.addProcessor(niftyDisplay);
        inputManager.beginInput();
        flyCam.setDragToRotate(true);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
        nifty.update();
        inputManager.update(tpf);
    }
}

src/mygame/LoginScreen.java:

package mygame;

import com.jme3.app.Application;
import com.jme3.app.state.BaseAppState;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

public class LoginScreen extends BaseAppState implements ScreenController {

    @Override
    protected void initialize(Application app) {

    }

    @Override
    protected void cleanup(Application app) {

    }

    @Override
    protected void onEnable() {

    }

    @Override
    protected void onDisable() {

    }
    @Override
    public void update(float tpf) {

    }

    @Override
    public void bind(Nifty nifty, Screen screen) {

    }

    @Override
    public void onStartScreen() {

    }

    @Override
    public void onEndScreen() {

    }
}


texts: How can I move the object back to his original position after the object reached the target?

texts:
InteractableItem target;
    private void Update()
    {
        if (target != null && target.name == "kid_from_space_helmet")
            objToThrow.transform.position += (target.transform.position - objToThrow.transform.position).normalized * 2f * Time.deltaTime;

        if(Vector3.Distance(objToThrow.transform.position, target.transform.position) < 1f)
        {
            objToThrow.transform.position += (objToThrow.transform.position - target.transform.position).normalized * 2f * Time.deltaTime;
        }
    }

The object is moving to the target but never moving back.
This IF is not working good :
if(Vector3.Distance(objToThrow.transform.position, target.transform.position) < 1f)

My guess is that the problem is that when the object distance is less then 1 he try to move back but then he is not less then 1 anymore. but anyway it's not working.
I want to move the object to the target then wait 1 second at the target and then to move the object back.


texts: Implicit conversion error - why is this code trying to convert a 'World' to an 'int'?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class World {
    Tile[,] tiles;
    int width;
    int height;

    public World (int width = 200, int height = 200) {
        this.width = width;
        this.height = height;

        tiles = new Tile[width, height];

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                tiles[x, y] = new Tile[this, x, y];
            }
        }
    }

    public Tile GetTileAt(int x, int y) {
        if (x > width || x < 0 || y > height || y < 0) {
            Debug.LogError ("Tile (" + x + ", " + y + ") is out of range");
            return null;
        }
        return tiles [x, y];
    }

}

anyone see anything wrong with this code because on line 18 of my code i get this error "cannot implicitly convert type 'World' to 'int' and i don't know what is going wrong.


texts: Unity Shader Material Only Activates when Clicked

texts:
I am currently programmatically settings some shader textures, related to a Mesh Filter.  The Mesh Filter is using a standard shader, and I am merely generating and setting the Bump and Height maps, via code.

Sphere.materials [0].mainTexture = biome;
Sphere.GetComponent<MeshRenderer> ().materials [0].SetTexture ("_BumpMap", bump);
Sphere.GetComponent<MeshRenderer> ().materials [0].SetTexture ("_ParallaxMap", heightTexture);

This is fine.  The issue is that the shader only seems to activate itself once it is clicked in the inspector.  Is there some sort of Activate() function I need to call in order to apply the shader effects to the Mesh?

Notice in the example (this is running in Play mode), that the shader only activates once I click the expand button on the Shader in the inspector.

What is going on here?


texts:
I'm attempting to change / toggle the material that's applied to a BSP brush. I've seen where it's possible on static meshes, but I can't seem to get it to work on brushes. Below is an example scenario.

The ground (BSP Brush) is covered in a stone material
The player hits a trigger.
A new "moss" material is applied to the brush, removing the old stone material.

Any assistance you could offer would be greatly appreciated.


texts: Draws fine in full OpenGL; not drawing anything in Chrome NaCL

texts:
I'm appealing to people's psychic debugging skills:
I have an OpenGL app that uses shaders and attributes in uploaded VBOs exclusively.
It runs fine on the desktop (Linux with integrated Intel card).
It compiles for and runs on Chrome NaCL, which is OpenGLES 2.0.  It does not draw anything, however (Vista, an ATI card).
The glClearColorf() and glClear() are working, and by picking a random clear colour I can get a nice flicker going so I know I've got the whole draw and flush cycle going fine in Chrome NaCL.
However, as I said, my program doesn't draw any of its content.
I have liberal glGetError() checks everywhere, and at first when porting they found lots of stuff such as needing to specify a float precision in shaders and not using full ints for element arrays and such.  But now there are no errors reported anywhere.
I have printf debugging so I know my code-path is right and that everything I can think of is asserted.
The NaCL "tumbler" demo does run.  Apart from their codebase being massively smaller, I can't spot what they are initializing that I aren't.
Anyone got any ideas what classic thing I've run into?


texts: 2d Collision detecton axis aligned boxes

texts:
I have recently run into some trouble with my collision detection. My game is composed of a map made out of axis aligned squares. The player has an x and y velocity, and I want to know how I can find out with which side the player is colliding. So if they move left, I want to know that if they collide with a square, and with which side they collide with it.

Edit: Basically, what I want to know is how to find out which face the player is colliding with.


texts: How to make a character in a Box2D world jump faster?

texts:
I have a question about using Box2D to simulate a physics-platformer.
I manage to make the character move to the right and left, and jumping as well. However, jumping seems extremely slow when compared to most tile-based platformers.

Is there a way to speed up the jumping  and falling of the player? I of course know from my basic physics lessons that 'heavier' objects don't fall faster in the real world, but is there a way to simulate this in Box2D?


texts: C++ OpenGL trouble trapping cursor in window

texts:
I am using OpenGL and I try to trap my cursor inside my game window (using both        SetCursorPos
and
    ClipCursor)

But, these conflict with my camera rotation code as my camera is rotated with my mouse. If there is a way to do it, please let me know. If possible, I would be willing to make it so that when the cursor reaches an edge of the screen, it jumps to the opposite edge (though I fear that would also conflict with my camera code).

EDIT: My camera code:

float heading;              // Also Y rotation, hard to explain
GLfloat yrot;               // Y Rotation
GLfloat lookupdown = 0.0f;
float mouseX, mouseY, oldMouseX, oldMouseY;

    case WM_MOUSEMOVE:
    {
        // save old mouse coordinates
        oldMouseX = mouseX;
        oldMouseY = mouseY;

        // get mouse coordinates from Windows
        mouseX = LOWORD(lParam);
        mouseY = HIWORD(lParam);

        // these lines limit the camera's range
        if (lookupdown < -90)
            lookupdown = -90;
        if (lookupdown > 90)
            lookupdown = 90;

        if ((mouseX - oldMouseX) > 0) {     // mouse moved to the right
            heading -= 3.0f;
            yrot = heading;
        }
        else if ((mouseX - oldMouseX) < 0) {     // mouse moved to the left
            heading += 3.0f;
            yrot = heading;
        }

        if ((mouseY - oldMouseY) > 0) {     // mouse moved up
            lookupdown += 3.0f;
        }
        else if ((mouseY - oldMouseY) < 0) {     // mouse moved down
            lookupdown -= 3.0f;
        }
    }


texts: How can I convert OBJ data into CSS3D transformations?

texts:
I want to convert the data in a 3D .obj file (vertices, normals, faces) to CSS3D (width, height, rotateX,Y,Z and/or similar transforms).  I found a bunch of formulae and what-not, but 3D isn't my forte, so I don't know which I should use.

Essentially: How can I get the X/Y/Z-rotation of a 4-point plane from it's matrix of x,y,z coordinates?

For example, here are  2 simple planes in .obj format:

g plane1
# simple along along Z axis
v  0.0  0.0  0.0
v  0.0  0.0  1.0
v  0.0  1.0  1.0
v  0.0  1.0  0.0

g plane2
# plane rotated 90 degrees along Y-axis
v  0.0  0.0  0.0
v  0.0  1.0  0.0
v  1.0  1.0  0.0
v  1.0  0.0  0.0

f  1 2 3 4
f  5 6 7 8

I'd like to convert it into CSS:

#plane1 {
    width: X;
    height: Y;
    transform: rotateX(Xdeg) rotateY(Ydeg) rotateZ(Zdeg) translateZ(Zpx)
}

#plane2 {
    width: X;
    height: Y;
    transform: rotateX(Xdeg) rotateY(Ydeg) rotateZ(Zdeg) translateZ(Zpx)
}

/* Or equivalent, like using transform: matrix3d() */


texts: Pathfinding using nodes/waypoints without connecting them?

texts:
I've been doing some research on pathfinding lately because I want to code a game modification for a game (won't say which exactly) and what I've done is defined a huge list of 3D vectors where a player can possibly go to. The thing is, I want to implement some sort of pathfinding system which can navigate from one of the points in the list to the other.

I've read some tutorials and websites about pathfinding like A* and Dijkstra's algorithm but all those examples seems to use tiles/squares and are all in 2D environments...

So far, I'm performing some simple distance checks (for example, checking for any points that are less than 100 units away from the current one) and sight/bullet checks (to see if the point is walkable/accessible) and selecting the best point according to distance from the destination. This seems to work most of the time, however there are times where it may try to navigate along a dead end and just fail or it might do some strange, unneeded zig-zags as well as taking really long routes.

Have you guys got any ideas of any algorithms I could implement as well as provide some psuedo-code? That would be so great. I want to avoid having to define vertexes/edges or connecting these points because I find that the maps are so large/vast, it'd be too much trouble. I would only do that if it were a last resort.


texts:
I have fixed some of the previous problem. The collision when running into a corner(a wall on two sides) however is still not working. When the player runs into a corner he just falls down and out of the map. Not sure what is happening.

manageWallCollision Method:

@Override
public void manageWallCollision(Scene currScene) {
    for(int i = 0; i < currScene.getMapManager().getWalls().size(); i++){
        MapTile currTile = currScene.getMapManager().getWalls().get(i);

        if(currTile.isCollidable()){
            if(this.getBounds().intersects(currTile.getBounds())){
                //down
                if(vy > 0 && y2 > currTile.getY() && y2 < currTile.getY2()&& y < currTile.getY() && y < currTile.getY2() ){
                    setY((currTile.getY() - getHEIGHT()) - 7);
                    break;
                }
                //up
                else if(vy < 0 && y < currTile.getY2() && y > currTile.getY() && y2 > currTile.getY2() && y2 > currTile.getY()){
                    setY(currTile.getY2() + 7);
                    break;
                }
                //right
                else if(vx > 0 && x2 > currTile.getX() && x2 < currTile.getX2() && x < currTile.getX() && x < currTile.getX2() ){
                    setX((currTile.getX() - getHEIGHT()) - 7);
                    break;
                }
                //left
                else if(vx < 0 && x < currTile.getX2() && x > currTile.getX() && x2 > currTile.getX2() && x2 > currTile.getX()){
                    setX(currTile.getX2() + 7);
                    break;
                }
                break;

            }
        }
    }
}

If you need any more code or info just ask. Any help is appreciated.

bump


texts: How do I break an image into 6 or 8 pieces of different shapes?

texts:
I am working on puzzle game, where the player can select an image from iPhone photo gallery. The selected image will save in puzzle page and after 3 second wait the selected image will be broken into 6 or 8 parts of different shapes. Then player will arrange these broken parts of images to make the original image.

I am not getting idea how to break the image and merged so that player arrange the broken part. I want to break image like this below frame. I am developing this game in cocos2d.


texts: How To Add Animation Graphics To An Android Game

texts:
How to make something like this animation drawings that coming out from the car ?

(I'm using android studio)

The Game's Link : Finger Driver


texts:
I am new to game development and am working on my first game using OpenGL and C++.
I have a game class which handles everything necessary in an update() function.
Now i want to handle keyboard inputs. I use GLFW which supports key callbacks. However i wonder how to deal with inputs. Should i record the keys pressed and poll on it the next time my game updates or should the callback immediately perform the necessary actions? And why?

Thanks :)


texts: Render angles of a 3D model into 2D images?

texts:
Is there a tool out there that you can give a 3D model file, and it will output 2D renders of it from various angles? For example if you were making a 2D RPG but you want to make your character look nice, you might make the character in 3D and then just render the character from 8 or more angles into images which then are used by the 2D engine to give a pseudo-3D look.

Does such a tool exist or will it need to be custom-written or done manually?


texts: Matrix transform from one coordinate system to another

texts:
I have been beating my head against the wall for weeks on this and it is time I just break down and ask for help.

I need to move a 3D camera from an in house system into Unreal 4.  The two use different coordinate systems.  I thought I could just use a matrix multiplication to convert from one system to the other, but so far I have had no luck finding the magic numbers to do so.

The source system is the same as Maya; Y up, -Z Forward, X right

The destination, Unreal; Z up, X forward, Y right

Besides the different Up axis, there is a LHS/RHS difference as well which is making things more complicated for me.  I am very bad at 3D math and would appreciate any help, and can amend this question with any additional details that are required.

This is the math I am using with any given conversion matrix:

newMatrix = conversionMatrix * sourceMatrix * conversionMatrix.Inverse()

My source matrices are 4x4, but in Unreal I specify a 3x3, ignoring the last column.

An example source matrix (somewhat rounded):

 0.4608        0.0072       -0.8874
-0.4448        0.8671       -0.2239
 0.7679        0.4979        0.4028
 982.0462      1196.9969    -107.6024

This represents in Maya approximately:

POS: x982.0462, y1196.9969, z-107.6024
ROT: x-29.866, y62.319, z0.479

Thanks in advance!


texts: How do I inverse level progression and make new stats?

texts:
I'm trying to make something like Vampire: Dark Ages in RPG Maker MV, but the problem is that I need new stats and a reverse level progression, as long as you start at 12nd generation (like the "level 1" in the rest of the games) and the next "level" is 11st generation.
It should have this stats:

Strenght

Dexterity

Resistance

Charisma

Manipulation

Appearence

Perception

Intelligence

Wits

This would only change by "buying abilities" with Job Points, and they determinate most of actions in the game. The only that would change would be the "Vitae Points", that act as Magic Points or Mana Points. When you have higher generation (low level), you have less Vitae/Blood points than if you have lower generation (high level).
How can I make this work? There's some plugin for this?


texts: How should I pause a rotation when my character collides with a gameObject?

texts:
My character always moves forward and when he enters a turn(Trigger) this is what happens:

if(other.CompareTag("TurnLeft"))
{
    // Rotates the character in 90 degrees in 6 seconds.
    MoveObject.use.Rotation(transform, Vector3.down * 90.0, 6);
}

But when he contacts with the ("StageColliders"), he keeps rotating, even though he doesn't change his position. I practically need him to pause rotating when he hits ("StageColliders") and continue when he's free of collision.
Something like this would be ideal.

if(other.CompareTag("StageColliders"))
{
    // Pause the rotation above.
}

I found the MoveObject script here http://wiki.unity3d.com/index.php?title=MoveObject
in case someone's curious.


texts: Can't deserialize parameters from JSON in LibGDX

texts:
I am quite new to JSON and I have been having trouble with this data-driven asset manager (not my code). I have been trying to deserialize parameters for my TmxMapLoader object from JSON. It takes the parameters of TmxMapLoader.Parameters type.

Here is the Asset.class file that's responsible for deserializing JSON:

public class Asset implements Json.Serializable  {
public Class<?> type;
public String path;
public AssetLoaderParameters parameters;

@Override
public void write(Json json) {
    json.writeValue("assetType", type.getName());
    json.writeValue("path", path);
    json.writeValue("parameters", parameters);
}

@Override
public void read(Json json, JsonValue jsonData) {
    try {
        type = ClassReflection.forName(jsonData.get("type").asString());
    } catch (Exception e) {
        type = null;
    }

    path = jsonData.get("path").asString();

    JsonValue parametersValue = jsonData.get("parameters");
    parameters = parametersValue != null ? json.fromJson(AssetLoaderParameters.class, parametersValue.toString()) : null;
}
}

And here is my JSON file:

{
"base" : [
{
    "type" : "com.badlogic.gdx.graphics.Texture",
    "path" : "data/background.jpg"
},

{
    "type" : "com.badlogic.gdx.graphics.Texture",
    "path" : "data/player.png"
},

{
    "type" : "com.badlogic.gdx.maps.tiled.TiledMap",
    "path" : "data/map.tmx",
    "parameters": [{
        "flipY": true
    }]
}
]}

Everything works fine and loads properly if I don't add the "parameters" element. Whenever I add the "parameters" element into the JSON file, the map fails to load. Am I adding the parameters wrong or missing something? Please help!

EDIT: Whenever I add the "parameters" element in .json file, the assets are being loaded. Here is my .json loading method:

private void loadGroups(String assetFile) {
    groups = new ObjectMap<String, Array<Asset>>();

    Gdx.app.log(TAG, "loading file " + assetFile);

    try {
        Json json = new Json();
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(assetFile));

        JsonIterator groupIt = root.iterator();

        while (groupIt.hasNext()) {
            JsonValue groupValue = groupIt.next();

            if (groups.containsKey(groupValue.name)) {
                Gdx.app.log(TAG, "group " + groupValue.name + " already exists, skipping");
                continue;
            }

            Gdx.app.log(TAG, "registering group " + groupValue.name);

            Array<Asset> assets = new Array<Asset>();

            JsonIterator assetIt = groupValue.iterator();

            while (assetIt.hasNext()) {
                JsonValue assetValue = assetIt.next();

                Asset asset = json.fromJson(Asset.class, assetValue.toString());
                assets.add(asset);
            }

            groups.put(groupValue.name, assets);
        }
    }
    catch (Exception e) {
        Gdx.app.log(TAG, "error loading file " + assetFile + " " + e.getMessage());
    }
}

And the console output is:

Assets: loading file data/assets.json
Assets: registering group base
Assets: error loading file data/assets.json Error parsing JSON on line 2     near: parameters: {
*ERROR*flipY: false

}


texts: How to draw a circle that is around an object and becomes smaller if the player enters it

texts:
I'm making a game in Java w/ slick and lwjgl and right now I want to do the following: draw a circle, that is drawn around an object with a radius of e.g. 75. I want the object to be IN THE MIDDLE of that circle. That is easy but I also want the circle to become smaller when the player enters it. Basically this is an example:

Players x is 100

The OBJECT'S x is 300

The circle's x is (300-75 == 225),(object's x - radius) and its width is radius*2, so 150

When the player is inside of the circle (players x > circles x;  e.g. 230 > 225) then I want the RADIUS of the circle to shrink to 70 (75 - (230 - 225), or, radius - (palyers x - circles x)), and after the circle shrank it should still be perfectly around the object from before.  (AND BTW I didn't mention the y variable because it's self-explanatory after I figure out the x)
Can anyone explain me the maths behind it please. Thank you


texts:
I can't understand how to use texture region.

I have a png file which has images (sprite sheet) and I must "extract" every image I want.

From here it just says TextureRegion(texture, 20, 20, 50, 50);

Where 20, 20, 50, 50 describes the portion of the texture,

How can I find which portion has the image I want to extract?

Should I open the png file with Gimp for example? And then I am search for some coordinates? And if yes, how?


texts: Are there any anti-cheating frameworks for Java games in order to make it a bit harder to cheat? (eg. something that protects from things like Cheat-Engine) Obviously if the cheater were to develop his own tools this wouldn't help much, but I'm looking to protect the game from the average cheating 13 yr. old child.


texts: How can I record my vector graphics game without  blurring the graphics?

texts:
A lot of people asked for a trailer for my game, because screenshots do not do it justice. I have tested PlayClaw, Fraps, CamStudio, VirtualDub, and some other minor tools; none have produced a viable result. My game uses vector graphics and is designed to run at 60fps, so lossy compression of a regular screen capture video destroys the graphical appeal.

How can I record gameplay without blurring my graphics and slowing down the framerate?


texts:
Working on some effects that require depth (Z) data in Unity, I saw that these use a method to store the depth data encoded in the RGBA channels of a regular texture.

half4 frag(v2f i) : SV_Target
{
    float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv.xy);
    d = Linear01Depth(d);

    return EncodeFloatRGBA(d);
}

Main question: why do this? Why not just store the result in a single-channel 16-bit float (R16F) texture?

Sub question:

What also surprises me is that the data is used as if these were independent RGBA channels. (the _EncodedDepth below contains the output of function above)

half4 color = float4 (0,0,0,0);
color += 0.40 * tex2D (_EncodedDepth, i.uv);

Then after that, information is decoded into a float value again.

float4 depth = tex2D(_ProcessedDepth, i.uv);
depth.a = DecodeFloatRGBA(hrDepth);
// do something with depth.a

Does this mean that linear operations applied to the encoded values are equivalent to linear operations applied to the original float? I.e.:

DecodeFloatRGBA( 0.5 * EncodeFloatRGBA(d) ) == 0.5 * d   // really?


texts:
Anyone know how to make a glass material in Unity 5?

I can do metal and image textures, but not sure how to create a glass material.

A search on Google would not get me anything for Unity 5 so it must be fairly easy to do.

It's for a shower door and plane glass like this:


texts: How to change Alt+Drag and Shift+Drag shortcut in Unreal Engine?

texts:
As a 3DS Max user, the ALT/SHIFT commands are reversed in Unreal, and for the life of me, I cannot easily switch between these differences. I always try to copy an asset by Shift+Click+Dragging it, and end up panning with it instead. The alt key is supposed to deselect, and instead it duplicates in Unreal.
I've looked everywhere in the General - Keyboard Shortcut settings and don't see those keybinds.


texts:
I have multiple AudioClips that I have attached to a GameObject and I'm trying to play them when certain conditions are met.  Each clip is in an array and I have each array item attached to a variable.  I'm also getting the GameObject's Audio Source.  My problem is, I can't get the clips to actually play, how do I get them to do so?

C#

private Rigidbody playerCar;
private AudioSource engine;
public AudioClip[] carSounds = new AudioClip[3];
AudioClip accelerate;
AudioClip toppedOut;
AudioClip idle;
private bool accelerating;
private bool idling;
private bool maxed;

void Start(){
    playerCar = GetComponent<Rigidbody>();
    engine = playerCar.GetComponent<AudioSource>();
    carSounds = playerCar.GetComponents<AudioClip>();
    idle = carSounds[0];
    accelerate = carSounds[1];
    toppedOut = carSounds[2];
    idling = true;
}

void Update(){
    if(idling){
        engine.PlayOneShot(idle);
        accelerating = false;
        maxed = false;
    }
}

Editor

For further clarification, here is the exact error Unity is giving me.

ArgumentException: GetComponent requires that the requested component 'AudioClip' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponents[AudioClip] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineGameObjectBindings.gen.cs:100)
UnityEngine.Component.GetComponents[AudioClip] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineComponentBindings.gen.cs:183)
MoveCar.Start () (at Assets/Scripts/MoveCar.cs:28)

Line 28 is carSounds = playerCar.GetComponents<AudioClip>();


texts: combine two translation/rotation/scale triplets without matrices

texts:
Let t1/2, r1/2 and s1/2 be two sets of transformations.
Translations are vec3, rotations are quaternions and scales are vec3.
Lets assume that all common operations are defined (overloaded operators in c++).

How do I combine (in what order) the two sets of transformations into a third set t3, r3 and s3, such that mat4(t1, r1, s1) * mat4(t2, r2, s2) == mat4(t3, r3, s3), without actually converting to matrices?

Mat4 is composed as M = T * R * S. (OpenGL conventions, if it makes any difference)

Thanks

My original code:

transform transform::operator * (const transform &other) const
{
    transform r;
    r.orientation = orientation * other.orientation;
    r.scale = scale * other.scale;
    r.position = position + (other.position * orientation) * scale;
    return r;
}

this used to work when scale was just one number (uniform scale). But it does not work with non-uniform scale. I guess that one of the scales have to be rotated, but I am failing to find the correct way.

This is how I test it:

for (uint32 round = 0; round < 10; round++)
{
    vec3 pa = randomDirection3() * randomRange(-5, 20);
    vec3 pb = randomDirection3() * randomRange(-5, 20);
    quat oa = randomDirectionQuat();
    quat ob = randomDirectionQuat();
    vec3 sa = randomRange3(real(0.1), 10);
    vec3 sb = randomRange3(real(0.1), 10);
    transform ta(pa, oa, sa), tb(pb, ob, sb);
    test(mat4(ta * tb), mat4(ta) * mat4(tb));
}


texts: Say I have a game which has lots objects (NPCs, monsters, etc.), I want a console so I can change the variables of the objects (like changing HP for example), how could I embed python into my program, so that I can change these variables and classes with a few keystrokes in the console? An example of a command would be: /monster 1 1 HP 100 (monster is the object name, 1 1 is the coordinates, and HP 100 is the variable to change, and to what amount)


texts:
I have a function to perform sprite rotation :

void Sprite::rotateSprite(float angle){
    //Making an array of vertices - 6 for 2 triangles

    Vector2<gamePos> halfDims(_rect.w / 2, _rect.h /2);

    Vector2<gamePos> bl(-halfDims.x,-halfDims.y);
    Vector2<gamePos> tl(-halfDims.x,halfDims.y);
    Vector2<gamePos> br(halfDims.x,-halfDims.y);
    Vector2<gamePos> tr(halfDims.x,halfDims.y);

    bl = rotatePoint(bl,angle) + halfDims;
    br = rotatePoint(br,angle) + halfDims;
    tl = rotatePoint(tl,angle) + halfDims;
    tr = rotatePoint(tr,angle) + halfDims;

    /**
        1st triangle
    **/

    //Top right
    _dataPointer.vertices[0].setPosition(_rect.x+tr.x,_rect.y+tr.y);

    //Top left
    _dataPointer.vertices[1].setPosition(_rect.x+tl.x,_rect.y+tl.y);

    //Bottom left
    _dataPointer.vertices[2].setPosition(_rect.x+bl.x,_rect.y+bl.y);

    /**
        2nd triangle
    **/

    //Bottom left
    _dataPointer.vertices[3].setPosition(_rect.x+bl.x,_rect.y+bl.y);

    //Bottom right
    _dataPointer.vertices[4].setPosition(_rect.x+br.x,_rect.y+br.y);

    //Top right
    _dataPointer.vertices[5].setPosition(_rect.x+tr.x,_rect.y+tr.y);
}

Vector2<gamePos> Sprite::rotatePoint(Vector2<gamePos> pos, float& angle){

    Vector2<gamePos> newv;

    newv.x = pos.x * cos(angle) - pos.y * sin(angle);
    newv.y = pos.y * cos(angle) + pos.x * sin(angle);

    return newv;
}

And the result is

Am i doing something wrong ? It happens also when i put small angle (even if i put here angle 1 )

Thanks for help.


texts: How to skip the sky in lighting shaders?

texts:
I recently implemented a sky in my deferred rendered game. It is a procedurally calculated sphere with a texture applied to it. Unfortunately all lighting shaders (light sources, ambient occlusion) are applied to that sky dome geometry as well.

Therefore the sky is completely dark without a huge light source in the level. And if there is one, the edges between triangles of that sphere are darkened by the ambient occlusion shader.

My quick and dirty fix was to read the depth texture to determine whether the lighting effect should be applied or not. For example, the view distance is 1000.0f and every pixel with a depth higher than 900.0f isn't shaded anymore. That works partly since every pixel of the sky is between 900.0f and 1000.0f.

But there are some issues with this approach. For example level geometry further away than 900.0f isn't shaded, too. Moreover the depth values come from projecting the scene on a plane, the screen. That means that the distance to the sky, which is equally in all directions from the players world position, differs over the image. Sky seen on the sides of the screen is nearer than sky pixels seen in the center of the screen. That effect varies with the field of view setting. The issue with that is that for every field of view setting I would need different depth thresholds for shading.

Is there a common way to not, or differently, shade some pixels of the image? In my case, I would need to not shader sky pixels. If I could determine which pixel is from the sky, I could store that in a buffer and read from that in lighting shaders to skip those pixels. But I have no idea how to approach this.


texts: Ensure house map maze with lifts can be solved?

texts:
In my game we see the floors of a house from the side, and the hero can take lifts -- a lift either goes up (to the next lift upwards), or down (to the next lift downwards), depending on the arrow as shown, and there's always a pair of exactly two lifts connected. That's the only way the hero can move vertically, though he can freely move horizontally. The house map is a randomized 11x5 grid with different items, and unpassable walls to the far left, far right, and sometimes in one of the two middle positions:

My question: How can I ensure the map is always randomized yet always solvable and that the hero, starting at the left side of the bottom floor, can always leave it via any upwards-pointing lift at the top floor?

For what it's worth I'm using the Lua language for development. Thanks so much!


texts:
I would like to create skeletal animations, and Synfig looks quite promising.

This is a video walk through
of its "bones" feature, used to do skeletal animation.

Ticks all the boxes thus far, however, I couldn't find out if animations could be exported as SVG. The closest I got to this was sif2svg, which is a pure XSLT transform, and lists "All sif elements aren’t supported, so it may have a lot of glitchs." as a limitation.

Has anyone had any experience here creating and exporting skeletal animations to SVG?
Is Synfig capable of doing this?
Are there alternative tools capable of doing this?


texts: Problem with collisions with tiles, using AABB

texts:
After having a little look around about collisions. I can't seem to find what i'm doing wrong every time i touch the bottom of the tile it send's me through it and throws me out to the right of the tiles. I maybe going about this the wrong way if someone could help i'd be very grateful i'll copy all the relevant code down below.

void Game::update(float dt)
{
//check collision with world
vector<Tile>* world = level.getLevel();
for (int i = 0; i < (int)world->size(); i++)
{
    if ((*world)[i].isAlive())
    {
        //if "alive" check collision
        //world tile that are not alive don't do checks
        if (checkCollision(&mario, &(*world)[i]))
        {
            mario.collisionResponse(&(*world)[i]);
        }
    }

}

bool Game::checkCollision(MySprite* sprite, MySprite* sprite2)
{
 if (sprite->getAABB().left + sprite->getAABB().width <sprite2->getAABB().left)
    return false;
 if (sprite->getAABB().left > sprite2->getAABB().left + sprite2->getAABB().width)
    return false;
 if (sprite->getAABB().top + sprite->getAABB().height < sprite2->getAABB().top)
    return false;
 if (sprite->getAABB().top > sprite2->getAABB().top + sprite2->getAABB().height)
    return false;

return true;

}

Mario Class

void Mario::collisionResponse(MySprite* sp)
{

    //setPosition(getPosition().x, sp->getPosition().y - getSize().y);
    //velocity.y = 0;
    sf::Vector2f collide(getPosition().x - sp->getPosition().x, getPosition().y - sp->getPosition().y);

    //check left side
    if (abs(collide.x) > abs(collide.y))
    {

        if (collide.x < -5)
        {
            //right side
            setPosition(sp->getPosition().x - getSize().x-1, getPosition().y);
            velocity.x = 0;
        }
        if (collide.x > 5)
        {
            //left side
            setPosition(sp->getPosition().x + sp->getSize().x + 1, getPosition().y);
            velocity.x = 0;
        }
    }
    else
    {
        if (collide.y < -5)
        {
            setPosition(getPosition().x, sp->getPosition().y - getSize().y);
            velocity.y = 0;

        }
        else if (collide.y > 5)
        {
            setPosition(getPosition().x, sp->getPosition().y  + getSize().y);
            velocity.y = 0;
            falling = false;
        }
    }

}


texts:
In my Game I'm currently have "Scene Coordinates" which are the X,Y coordinates relative to a Game Scene.

In that Scene there are Game Entities, let's say there's a GameEntity A in x=100.0, y=100.0 ( scene coordinates )

Which is the best way to have "Entity Coordinates" so that from GameEntity A point of view, he's standing at x=0.0, y=0.0 with OpenGL transformations?

In that way if I apply something like

glRotatef(angle, 0, 0, 1)

The entity will rotate around it's own origin and not the scene "global" origin.


texts: How to balance a non-symmetric "extension" based game?

texts:
Most strategy games have fixed units and possible behaviours.

However, think of a game like Magic The Gathering : each card is a set of rules.
Regularly, new sets of card types are created.

I remember that the firsts editions of the game have been said to be prohibited in official tournaments because the cards were often too powerful.
Later extensions of the game provided more subtle effects/rules in cards and they managed to balance the game apparently effectively, even if there is thousands of different cards possible.

I'm working on a strategy game that is a bit in the same position : every units are provided by extensions and the game is thought to be extended for some years, at least. The effects variety of the units are very large even with some basic design limitations set to be sure it's manageable.

Each player choose a set of units to play with (defining their global strategy) before playing (like chooseing a themed deck of Magic cards).
As it's a strategy game (you can think of Magic as a strategy game too in some POV), it's essentially skirmish based so the game have to be fair, even if the players don't choose the same units before starting to play.

So, how do you proceed to balance this type of non-symmetric (strategy) game when you know it will always be extended?

For the moment, I'm trying to apply those rules but I'm not sure it's right because I don't have enough design experience to know :

each unit would provide one unique effect;
each unit should have an opposite unit that have an opposite effect that would cancel each others;
some limitations based on the gameplay;
try to get a lot of beta tests before each extension release?

Looks like I'm in the most complex case?


texts: Cannot find declaration of element nifty JME

texts:
I'm new to nifty. I am trying to learn how to create nifty GUI in JMonkey Engine game. I'm going through tutorials and tried to run project. Project runs fine but I get following error when I tried to edit xml:

Cannot find declaration of element nifty

Below is my start.xml code:

<nifty xmlns="http://nifty-gui.sourceforge.net/nifty.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty.xsd http://nifty-gui.sourceforge.net/nifty.xsd">
<useStyles filename="nifty-default-styles.xml" />
<!-- Screen Codes here-->
</nifty>

I guess most possible reason is that above namespace might have been deprecated and already been replaced. Or there might be other steps that I have to perform in JME SDK to make it recognize nifty tag. Please Help.


texts: ERROR: The application bundle does not contain a valid identifier

texts: I'm getting this error "The application bundle does not contain a valid identifier" after my application successfully compiles.This error prevents my game from launching on the phone or the simulator. I have no idea how to fix this as I was following this tutorial How To Make A Space Shooter iPhone Game using Cocos2d.


texts: Random/Procedural vs. Previously Made Level Generation

texts:
What the advantages/disadvantages of using random/procedural generation vs. pre-made levels?

There seems to be few that I can think of, other than the fact that items may be a problem to distribute in randomly generated terrain, and that the generated terrain may look weird.

The downside to previously made levels is that I would need to make a level editor, though. I cannot decide what is better to use.

Could answers include code/examples of both procedural and premade generation, as well as the pros/cons?


texts:
How do I create some circle - like the one on the image - in Java, and in various colors?

I would like to make more of these circles to fly from specific position to random direction.


texts: Aspect ratio of drawn quad messed up after rotating

texts:
When I draw a quad that is rotating the aspect ratio of the quad gets messed up and the size changes.

Gif of what is happening

I am confident it has something to do with the way I calculate the size because that is relative to the width and height of the screen, I just don't know why the aspect ratio would change since the aspect ratio of the screen doesn't change.

Code of transformationMatrix creation:

        Matrix4f matrix = Maths.createTransformationMatrix(
                new Vector2f(
                        gui.getPosition().getX() / Display.getWidth() * 2 - 1 + gui.getSize().getX() / Display.getWidth(),
                        -gui.getPosition().getY() / Display.getHeight() * 2 + 1 - gui.getSize().getY() / Display.getHeight()
                ), gui.getRotation()
                ,new Vector2f(
                        gui.getSize().getX() / Display.getWidth(),
                        gui.getSize().getY() / Display.getHeight()
                )
        );
        shader.loadTransformation(matrix);

The x size, y size, x position and y position are in pixels, if you put in 1600 pixels for x position and the screen is 1600 pixels wide it will fill the whole screen. The calculation that is done here will translate those sizes to a value that the shaders will display on the screen.

I had tried calculating the sizes in a different way:

gui.getSize().getX() / (float) (Display.getWidth() * Math.abs(Math.cos((Math.toRadians(gui.getRotation())))) + Display.getHeight() * Math.abs(Math.sin((Math.toRadians(gui.getRotation()))))),

but this does not work at all, my thought process was that if it is sideways it should use Display.getHeight to calculate the x size and if it is vertical it should use Display.getWidth. This does work for 0, 90, 180 and 270 degrees rotation, but in between it gets smaller and weird. Of course I've also done this for the x position but then cos and sin switched around.

video of this method

And this is the createTransformationMatrix method:

public static Matrix4f createTransformationMatrix(Vector2f translation, float rotation, Vector2f scale) {
    Matrix4f matrix = new Matrix4f();
    matrix.setIdentity();
    Matrix4f.translate(translation, matrix, matrix);
    Matrix4f.rotate((float) Math.toRadians(rotation), new Vector3f(0, 0, 1), matrix, matrix);
    Matrix4f.scale(new Vector3f(scale.x, scale.y, 1f), matrix, matrix);
    return matrix;
}


texts: How to deal with pushing objects out of collision in a physics engine

texts:
I'm developing a 3D physics engine (I know, I should use one of the many good existing physics libraries, however my collision detection is optimised for objects with highly ordered highly complex substructure which seems to be unusual and slow in the engines I've tried).

Collision detection is working really nicely, as are bouncing type behaviours but contact behaviours are not behaving nicely at all. Initially I had the problem that an object would spin up out of control if it had prolonged contact with a surface; I found that the reason for this was that an object was falling under gravity into collision, then getting a "free ride" upwards while it was pushed out of collision; giving the object free energy. If a significant portion of this energy made it into rotational degrees of freedom then considerable energy could be imparted before eventually the object was flung outwards. My solution to this was to impart an energy penalty when pushing out of collision equal to:

 EnergyPenalty=mass * gravity dotted with the push-out-of-collision vector (i.e the E=m*g*h it has gained for free)

This improved matters considerably, but now objects "get stuck" on their corners just before the shape relaxes into its resting position; presumably because too much energy seems to be being taken away.

A loop round the engine works as following

-Collisions detected
-Pushed out of collision (energy penalty if pushed up against gravity)
-Collisional forces applied if object are still approaching (may not be the case if push energy penalty slowed to 0)
-Gravity applied
-Contact forces applied if object are still approaching (as collision but with elasticity = 0)
-Move and rotate objects

I've taken friction out of the equation for the time being

I’ve found that while in contact with the surface the contact forces correctly bring the two objects at their collision points to zero relative velocity (taking into account both translation and rotation) but that that balance of translational movement balancing rotation  is instantaneous. I.e. over a complete physics step the rotational component changes to be no longer in perfect balance with the translational. So a very small push-out-of-collision is required even when in ‘contact mode’ with a very small energy penalty to boot. However this energy penalty seems too large; freezing the object in position.

Which brings me to my question; what is the correct way to deal with the “free energy” imparted by a push-out-of-collision in a collision resolution step? (Even if the answer is; what you're doing is the correct way to deal with it i'll know this is a debugging issue not an algorithmic issue)