texts: I have implemented functions that can draw any polygonal shape, however I have been unable to generate a smooth shape that mimics the rounded edges of a lake. I tried generating two circles and joining the edges but there is not enough variation or smoothness to it. Does  anyone have any pointers or ideas that could generate a shape like this?


texts: I need to sell an almost-complete MMORPG project. How can I do that?

texts:
I need your help. We have to sell MMORPG at an advanced stage. The game has a unique engine, written on the need for the game, graphics, sound, map editor, web site etc.

As it happens in the play mmorpg we can develop the characters, monsters. We can fight with other characters or to establish cooperation in solving the challenges. We can fight using own monsters, or throwing their own cards with spells.

Unfortunately we have no idea how to promote the game. Ended fund and I think the whole team surrendered. How can I find a buyer? Where can I find him? Thank you for your help.


texts: How to get normals from volume density grid?

texts: I am meshing my volume density data with marching cubes. The density data is a flat array and it's elements contain a) distance from surface, b) a normal (xyz). However this normal is for the density grid point, no the calculated vertexes. So having this data can i calculate normal for each vertex?


texts: How to create custom editor script only for one field of an object and leave the rest default in Unity?

texts:
I have a script attached to a game object. The script has many public fields and I'm satisfied with how Unity displays most of the fields for editing in the Editor. Except for a few. I'd like to write a complex custom editor script for those fields and leave the rest as is - public and visible in the Editor. I don't want to write lots of extra code to mimic what the editor does so far.

The perfect scenario would be to be able to define a custom editor script for a certain type (the type is not derived from MonoBehavior and cannot be). If a field of that type is public in any script attached to a GO I'd like the Editor to display it the way I've defined.


texts:
I am trying to extend Unity's BoxCollider class.  So I am extending it in the editor like such:

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(BoxCollider))]
public class MyBoxCollider : Editor
{
    public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("My Box Collider");
        base.OnInspectorGUI();
    }
}

However, I cannot figure out how to override OnTriggerEnter, OnCollisionEnter, etc.

How can I override these?  They appear to be declared as private in the base class.

My end goal is that when I add a BoxCollider to a GameObject, it has a label in addition to its normal stuff. Then when BoxCollider's OnTriggerEnter method is called, it prints out what the label says before continuing on about its business. (This is a simplification, but I think it helps clarify my objective.)


texts: Optimizing file-size of a sprite-sheet for a 2D game

texts:
I have a question regarding the method of creating a sprite-sheet so that it will not consume to much disk space and still preserve graphics quality.

I was researching about this topic and found that my sprite-sheets should have sizes that are a power of two. So valid sizes would be 512x512, 1024x1024, 2048x2048 etc.

Then I created two sprite sheets (one is 1024x1024 and the other is 2048x2048), they are exported as 16bit but they still use too much disk-space. How can I optimize my sprite-sheet to use the least amount of disk-space possible?

This is one of my sprites:


texts: Mathematics should I learn for 2D and 3D game programming/development

texts: What mathematics should I learn to become game programer 2D and 3D. From the very basic for beginner until advance


texts: Blender - creating bones from transform matrices

texts:
Notice: this is for the Blender 2.5/2.6 API.

Back in the old days in the Blender 2.4 API, you could easily create a bone from a transform matrix in your 3d file as EditBones had an attribute named "matrix", which was an armature-space matrix you could access and modify.

The new 2.5+ API still has the "matrix" attribute for EditBones, but for some unknown reason it is now read-only.

So how to create EditBones from transform matrices? I could only find one thing: a new "transform()" function, which takes a Matrix too.

  Transform the the bones head, tail, roll and envelope (when the matrix
  has a scale component).

Perfect, but you already need to have some values (loc/rot/scale) for your bone, otherwise transforming with a matrix like this will give you nothing, your bone will be a zero-sized bone which will be deleted by Blender.

if you create default bone values first, like this:

bone.tail = mathutils.Vector([0,1,0])

Then transform() will work on your bone and it might seem to create correct bones, but setting a tail position actually generates a matrix itself, use transform() and you don't get the matrix from your model file on your EditBone, but the multiplication of your matrix with the bone's existing one. This can be easily proven by comparing the matrices read from the file with EditBone.matrix.

Again it might seem correct in Blender, but now export your model and you see your animations are messed up, as the bind pose rotations of the bones are wrong.

I've tried to find an alternative way to assign the transformation matrix from my file to my EditBone with no luck.


texts: Preferred option for indicating player's movement choices on a hexagonal grid on touch

texts:
I'm building a prototype turn-based game and I'm considering the best approach for user interaction with the game board. It's a hexagonal grid, where the user can select units and move to other cells on the board. The number of steps they can take in a single move is variable and depends on the unit.

I'm aiming this for use ontouch screen devices, so that will exclude hover-based indicators (which make the most sense in terms of interaction).

So, with that limitation, what methods are possible for indicating to the user the amount of cells they can move?

So far, I've come up with these options:

Allow the user to take their turn and move step by step, highlighting the nearest 1 neighbour cells each time.
Highlight all possible destination cells:

Highlight the outer ring of maximum distance:

Draw a line through the outer-most cells to indicate maximum distance:

Each of these has their own drawbacks. The first, will be done dynamically and will require creating the markers on the fly (not inconceivable) and will also look kind of strange when there are lots of options. The image shows a unit which can move 2 cells and already looks over-crowded.

The second would solve the problem of too many cells being lit up at once. Unfortunately, I'd be worried the user wouldn't understand that they could move to one of the non-highlighted cells within the ring.

The last has the same problem as the second where I'm not sure they'd understand where they can move. It would alleviate the need to create multiple markers and store temporarily as I'd only have to store a single hexagon of varying size.

So, any ideas? Am I over-thinking this one?

NOTE: I've made the images above from this extremely useful site: http://www.redblobgames.com/grids/hexagons/


texts: Using enums for detecting object collisions

texts:
As far as I know, I can detect what objects the player is colliding with is by the following code:

private void OnCollisionEnter2D(Collision2D collision)
{
    if(collision.collider.name.Equals(""))
}

But I have heard that I can use enums instead to reduce computations. Could anyone explain to me using examples?


texts:
I wanted to support etc1, because it shoul improve the performance and loading times, but somehow its worse than using normal png files.

I'm using Mali compression tool with seperate RBG pkm texture and Alpha pkm texture.
I'm using a GLSL shader to deal with the alpha problem ofc ETC1. With the shader the performance is really bad. but even without the shader, just working with the RGB pkm file (where transparency is black) the performance is equal to png. does anyone know what the problem might be?


texts: Monobehaviour can not find a member OfType in Unity

texts:
This is the line where I am getting above mentioned error:

var listeners = FindObjectOfType<MonoBehaviour> ().OfType<iPlayerRespawnListener> ();

I have already imported these libraries including System.Linq which has the above mentioned method OfType:

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

Where is it going wrong and how to fix this?


texts: Why the cube is getting to the other cube instead stopping when both colliders hit?

texts:
I don't want to use a script with OnTriggerEnter or something like that but to simulate the red cube as a wall and when the blue cube collider hit the red cube collider it should stop.
Both cubes have a box collider and on both the Is Trigger is checked true I also tried one of them or both when not checked true. And both colliders size on Z set to 3.

But the blue cube is getting to the red one and not stop when colliding :

The blue cube is getting inside the red one :

I tried to add a rigidbody to the moving cube the blue cube but if using Is Kinematic same behaviour if not using Is Kinematic the blue cube is falling down.

This is the script attached to the blue cube to move it to the target red cube :

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

public class MoveObject : MonoBehaviour
{
    public GameObject target;
    public float speed;

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector3.MoveTowards(transform.position, target.transform.position, Time.deltaTime * speed);
    }
}

I want that the blue cube will stop when colliding the red cube collider that's why I set them on Z to 3.
I don't need physics for now.

Do I need must using OnTriggerEnter in my script for that ?

I thought I tried it too but this seems to be working :
Both box colliders on the cubes unchecked set false the is trigger and I added a rigidbody to the moving cube the blue one and unchecked the use gravity and now it seems to be working.

So I need a rigidbody even if I'm not using physics. I wonder why.


texts: How or when to add a copyright notice in published games?

texts: I've seen lot of videogame title screens show a copyright notice together with the company name. I'm about to publish my game and I am looking for possibilities or requirements on how or when to add such a copyright notice (including date or year published). Does it apply to both indie game makers and larger companies?


texts: How to use the latest MongoDB C# driver with Unity?

texts:
I recently updated my Unity 2018 to the 2020 version then I created a new project to connect my game to a MongoDB database.
My main goal is to be able to store not only common data in my collection but also files and images by using GridFS.
I use Visual Studio 2019 Community so for my project. I installed the MongoDB drivers directly from NuGet. In Visual Studio everything is OK, I added a using for all required libraries and I have no errors but when I switch to Unity 2020 it seems that I can't start my project because my MongoDB driver is not correctly loaded there.
I found some tutorials like this one where they had the same problem and fixing it by adding the DLLs directly in the Unity folders. That works for me, but only with the DLLs shared in the tutorial (you can access the working DLLs in the video description).
What is a bit disturbing is that the DLLs' versions seem to be outdated, since the connections process is a bit different from the one in the MongoDB documentation.
I cloned the latest MongoDB C# driver repository from GitHub and tried to reproduce the same process with the latest DLLs, but once again it only works in VS 2019 but not in Unity, even though I have added the DLLs in the Unity folder.
Is there is some kind of compatibility problem between Unity and the latest MongoDB? How can I fix this to work with the latest version?


texts: How should I handle interrupting the current goal with goal-oriented action planning?

texts:
I'm reading about goal-oriented planning for AI, but there I'm having difficulty finding an implementation so that I can address some questions that I have.  Specifically, I don't understand how to handle scenarios in which an agent is in the middle of a goal, but then another goal gets calculated as higher priority.  For example, suppose I have the following goals/subgoals/actions
MineGold (goal)
|--> MoveToGoldMine (goal)
|    |--> MoveToPosition (action)
|--> SwingPickaxe (action)
|--> TakeGold (action)
|--> DeliverGold (goal)
|    |--> MoveToTownHall (goal)
|    |    |--> MoveToPosition (action)
|    |--> DropGold (action)

AvoidEnemy (goal)
|--> MoveToHidingSpot (goal)
|    |--> MoveToPosition (action)
|--> Wait (action)

AttackEnemmy (goal)
|--> MoveToEnemy (goal)
|    |--> MoveToPosition (action)

When the game starts, my agent calculates its goal priorities and its highest priority is the MineGold goal.  So it pushes the list of subgoals and actions for MineGold onto its planning stack.
Suppose the agent moves to the gold mine, mines the gold, takes the gold, and then starts to move back to the town hall.  While it's moving back to the town hall, an enemy soldier gets close enough such that the AvoidEnemy goal becomes higher priority than the MineGold goal.  So now the agent pushes the AvoidEnemy subgoals and actions into its stack, ahead of the remaining DeliverGold subgoal.
While the agent is avoiding the soldier, an enemy assassin sneaks up on his team's commander.  The commander calls for help so the AttackEnemy goal becomes the highest priority.  So AttackEnemy is pushed onto the stack ahead of AvoidEnemy.
Eventually the assassin is killed, so the AttackEnemy goal is no longer valid and gets popped off the stack.  Now the topmost goal is AvoidEnemy to avoid the enemy soldier.  But if my agent just attacked the assassin, it would be weird for him to then start running away from the soldier (or maybe the soldier is already far away and I don't want to keep moving to a hiding spot), so I would rather him return to his original goal of DeliverGold.
Here are my questions:

Am I correct in assuming that I should be periodically recalculating the highest priority goal and switching to the highest priority goal if it's different than the existing goal?
Am I correct that when a new goal becomes higher priority than the current goal, then I should be pushing that new goal onto the stack ahead of the current goal, as opposed to overwriting the current goal with the new goal?
Assuming I'm correct that new goals are additive, how do I handle this situation where sometimes I don't want an agent to return to certain prior goals?  I know that I could accomplish this through a set of "mutually exclusive" flags or something, but that seems like an inelegant way and that it would start to return me to using finite state machines instead of goal-oriented planning.


texts: Is the Microsoft recommendation to use C# properties applicable to game development?

texts:
I get that sometimes you need properties, like:

public int[] Transitions { get; set; }

or:

[SerializeField] private int[] m_Transitions;
public int[] Transitions { get { return m_Transitions; } set { m_Transitions = value; } }

But my impression is that in game development, unless you have a reason to do otherwise, everything should be nearly as fast as possible. My impression from things I've read is that Unity 3D is not sure to inline access via properties, so using a property will result in an extra function call.

Am I right to constantly ignore Visual Studio's suggestions to not use public fields? (Note that we do use int Foo { get; private set; } where there is an advantage in showing the intended usage.)

I'm aware that premature optimization is bad, but as I said, in game development you don't make something slow when a similar effort could make it fast.


texts:
I have a sprite group created with pygame.sprite.Group() (and add sprites to it with the add method)

How would I retrieve the nth sprite in this group?

Code like this does not work:

mygroup = pygame.sprite.Group(mysprite01)
print mygroup[n].rect

It returns the error: group object does not support indexing.

For the moment I'm using the following function:

def getSpriteByPosition(position,group):
    for index,spr in enumerate(group):
        if (index == position):
            return spr
    return False

Although working, it just doesn't seem right...

Is there a cleaner way to do this?

EDIT:
I mention a "position" and index but it's not important actually, returning any single sprite from the group is enough


texts: How to transform Unity terrain coordinates

texts: My map creator created some terrain in Unity, but all my scripts are based on the X-Y axis. Is there an easy and smart way to transform them into Z-Y, or do I have to change all the vector variables to Vector3 and move the coordinates to (0,Y,Z)?


texts:
I'd like to be able to direct a game object to move to a new target position over a certain amount of time. There are lots of different easing functions available, but for now let's say I'm just planning to use a standard quadratic ease-in ease-out function and also a quadratic ease-out function.

For example

Math.easeInOutQuad = function (t, b, c, d) {
    t /= d/2;
    if (t < 1) return c/2*t*t + b;
    t--;
    return -c/2 * (t*(t-2) - 1) + b;
};

Now suppose while it is still in the process of moving to that target and I want to give it a new target. Rather than have it instantly change directions with a zero starting velocity, I'd like a smooth transition.

How is this done mathematically and programmatically?

I want to avoid keeping a dynamic array of tween commands for every parameter of each game object. (I want to tween all sorts of parameters besides position.) that could get really heavy and bloated. But that's the only thing that comes to mind that might work... Keeping an array of active tweens and averaging all of them.

Maybe some easing functions lend themselves better toward being interrupted? Or is there a way to recalculate the four inputs to the ease function when a new target is set, such that the same function can continue to be used once per frame without a jarring speed/direction change, and ending at the second target instead?


texts:
My goal is to have my animals walk around within a certain range. Everything works except for when it comes to the y axis. I can choose a position for it to walk and it will go there but I have no way of telling the height of the terrain at the selected point, or at the points all along the way. Im wondering how I can have my npc's always walk on the ground rather than walking through the ground.

My code is here if it helps, but my problem is pretty straight forward.

    if(timer == 0) {
        //Look at target
        myTransform.rotation = Quaternion.Slerp (myTransform.rotation, Quaternion.LookRotation (walkToPosition - myTransform.position), rotationSpeed * Time.deltaTime);

        if(Vector3.Distance (walkToPosition, myTransform.position) > 1) {
            //Move towards target
            myTransform.position += myTransform.forward * walkSpeed * Time.deltaTime;

            anim.CrossFade("walk");
        } else {
            walkToPosition.x = Random.Range(initialSpawn.x - walkDistance, initialSpawn.x + walkDistance);
            walkToPosition.z = Random.Range(initialSpawn.z - walkDistance, initialSpawn.z + walkDistance);
            timer = walkCooldown;
            anim.CrossFade("idle");
        }
        Debug.Log (walkToPosition);
    }

EDIT:

I am doing this project in Unity3d. I do not need to know how to render this, all I am looking for is some kind of function or something that I can use to tell the character to walk along the ground rather than walking through it.

At the moment when I set a new walk to position, the Y coord is 0, which means the character is going to forcibly go to the 0 axis without even considering the terrain.


texts:
I am the narrator for a RPG game I'm creating. I have two questions:

1) Quality: I have a mic that seems to pick up a lot of background static along with my voice, so the overall quality sounds terrible. Is there a specific type of mic that should be used for game narration?

2) Performance: Narration quality is important for the game, but there will be many audio files. Is there a method to delivering quality audio files while compressing the file? Since it's narration, I need the audio to be snappy and clear.


texts: 2D object-aligned bounding-box intersection test

texts:
I have two object-aligned bounding boxes (i.e. not axis aligned, they rotate with the object).  I'd like to know if two object-aligned boxes overlap.  (Edit: note - I'm using an axis-aligned bounding box test to quickly discard distant objects, so it doesn't matter if the quad routine is a little slower.)

My boxes are stored as four x,y points.  I've searched around for answers, but I can't make sense of the variable names and algorithms in examples to apply them to my particular case.

Can someone help show me how this would be done, in a clear and simple way?  Thanks.  (The particular language isn't important, C-style pseudo code is OK.)


texts:
I have a circular shape object, which I want to rotate like a fan along it's own axis.

I can change the rotation in any direction i.e. dx, dy, dz using my transformation matrix.

The following it's the code:

 Matrix4f matrix = new Matrix4f();
 matrix.setIdentity();
 Matrix4f.translate(translation, matrix, matrix);
 Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1,0,0), matrix, matrix);
 Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0,1,0), matrix, matrix);
 Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0,0,1), matrix, matrix);
 Matrix4f.scale(new Vector3f(scale,scale,scale), matrix, matrix);

My vertex code:

 vec4 worldPosition = transformationMatrix * vec4(position,1.0);
 vec4 positionRelativeToCam = viewMatrix*worldPosition;
 gl_Position = projectionMatrix *positionRelativeToCam;

Main Game Loop:

  Object.increaseRotation(dxf,dyf,dzf);

But, it's not rotating along it's own axis. What am I missing here? I want something like this. Please Help


texts: Servers do not remove spawned prefab after disconnection

texts:
I built a multiplayer game with the Unity UNET. For doing this I bought a VPS server. Everything works fine.
But sometimes when players want to quit the game, the servers do not destroy him from the scene!!!
& the other players still can see him in the scene till the servers being restarted and ran again!!
For quitting the game I wrote this code :
NetworkManagers.singleton.client.Disconnect();
Destroy(NetworkManagers.singleton.gameObject);

For more explanation, this is my ConnectionConfig for server & client:
MinUpdateTimeout:15
ConnectTimeout:1200
DisconnectTimeout:2000
PingTimeout:500
NetworkDropThreshold:50
OverflowDropThreshold:50
AckDelay:32
AcksType:1
MaxSentMessageQueueSize:150

Why this happening?! Did I miss something?! & how can I avoid that?!


texts:
I have four points in a 3D space, example:

(0,0,1)
(1,0,1)
(1,0,2)
(0,0,2)

Then I have a 2D position on that square plane:

x = 0.5
y = 0.5

I need to find out the 3D space point of that position in the plane. In this example it's easy: (0.5,0,1.5) Because Y is zero. But imagine that Y was not zero (and not all the same), that the plane is leaning in some direction. How would I calculate the point in that case?

I imagine this should be a pretty easy thing to solve, but I can't figure it out. Please answer in programming terms and not in straight math terms.

Update with image: The gray plane (made out of two triangles) are the real one actually existing. I create a non-existing plane on top of this, the ABCD corners are exactly the same, however it doesn't slope. What I need to do is project a pixel (blue one in example) from the non-existing plane to the existing plane. It will be in the exact same location, except that it has gained a Y value from the sloping plane.

What I've been able to work out so far on my own is which one of the two triangles to use in the gray plane and the normal of triangle. I basically just need to figure out how I can project the pixel.


texts: Why does my sprite shifts position on specific animationframe?

texts:
I have created a spritesheet to create animation. Everything is working fine untill I come to a specific frame in one animation.

I have currently 3 animations loops

Idle Animation
Moving Animation
Shooting Animation

Nr 1,2 is working fine and behave like they should but when I am shooting my sprite shifts a little to the left. And I don't why it does.

Here is a gif for the animations

Here is the spritesheet I am using for the animations

And here is the code I am using for looping and shifting different animations

public void DrawSpriteSheetFrame(CustomTexture2D ct, Vector2 position, StateOfObject soo, GameTime gt, SpriteFont sf)
    {
        if (!_currentstate.Equals(soo))
        {
            _currentframe = 0;
        }
        _currentstate = soo;

        List<SpriteFrameInfo> currentLoopsheet = ct.SubTexture.FindAll(x => x.name.Contains(soo.ToString()));
        _timeSinceLastFrame += gt.ElapsedGameTime.Milliseconds;
        if (_timeSinceLastFrame > _frameUpdateSpeed)
        {
            _timeSinceLastFrame -= _frameUpdateSpeed;
            if (_currentframe <= currentLoopsheet.Count - 1)
            {
                _currentframe++;
            }
            else _currentframe = 0;
        }
        var t = currentLoopsheet.Where(x => x.name.Contains(_currentframe.ToString())).FirstOrDefault();
        Vector2 origin = new Vector2(t.width, t.height);
        var rec = new Rectangle(0,0, 400,200);
        _spriteBatch.Begin();
        _spriteBatch.DrawString(sf, "Currentsheet: " + t.name, new Vector2(100), Color.White);
        _spriteBatch.DrawString(sf, "Position X: " + position.X, new Vector2(100,150), Color.White);
        _spriteBatch.DrawString(sf, "Position Y: " + position.Y, new Vector2(100,200), Color.White);
        _spriteBatch.DrawString(sf, "SheetCord X: " + t.x, new Vector2(100, 250), Color.White);
        _spriteBatch.DrawString(sf, "SheetCord Y: " + t.y, new Vector2(100, 300), Color.White);
        _spriteBatch.Draw(ct.Texture, position, new Rectangle(new Point(t.x, t.y), new Point(t.width, t.height)), Color.White, 0, origin, 1, SpriteEffects.None, 1);
        //DrawBorder(new Rectangle(new Point(t.x, t.y), new Point(t.width, t.height)), 1, Color.Black);
        //_spriteBatch.Draw(ct.Texture, position, new Rectangle(new Point(t.x, t.y), new Point(t.width, t.height)), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1);
        //_spriteBatch.Draw(ct.Texture, position, rec, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 1);

        _spriteBatch.End();
    }


texts: Online Multiplayer - cheating w/ delta time movement

texts:
I'm making a multiplayer game with basic linear movement and interpolation. I've read gabriel's article about client-side prediction and server reconciliation and have tried applying it to my own. My server is supposed to be authoritative, but I am worried clients can still exploit the system.

The system works like this:

the client sends timestamped input to the server at 60hz
the server runs at 30hz. Each tick it applies all the input since last tick and uses a time delta calculated from the client side input packets to determine movement (e.g. entity.x += message.delta * speed). The server then sends a timestamped state back to all clients.
the client receives a timed state from the server and applies the "authoritative" positions.

My concern is with step #2. Because player movement relies on the client's delta time, I'm afraid they can cheat by sending a "fake delta time" to the server and additionaly spam input messages quicker to make them move faster in-game. If I remove the delta time altogether, the game will appear "jumpy". How can I resolve this issue?


texts: How to get mouse position relative to the map?

texts:
I'm creating a game in XNA similar to Minecraft - Minecraft 2D

It looks like this

Here's how it works:

All blocks are generated once with fixed x,y coordinates and just re-drawn.

    //generate world
    for (int i = 0; i < 25; i++)
    {
        blocks.Add(new Block("top", i * 32, 32 * 7, Color.White));
        for (int j = 8; j < 20; j++)
        {
            blocks.Add(new Block("dirt", i * 32, 32 * j, Color.White));
        }
    }

When user clicks on a block, I just browse through all blocks and check whether block exists.

if ((mouseCoordinate.X - (mouseCoordinate.X % 32)) == block.x && (mouseCoordinate.Y - (mouseCoordinate.Y % 32)) == block.y) {
      //destroy block
}

Currently, without any camera movements, everything works. When I move my camera just about 32px to the right, for example, it's all broken. I can't do previous step anymore.
What I need: I need to get mouse position relative to the map, not to the game window. How can I get mouse position relative to the map? Basically, I want mouse position 0,0 on the point I have circled here

How do I calculate it?

EDIT: here's my camera class (yes, Matrix)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Reflection;
namespace MojePrvniHra
{
    public class Camera2d
    {
    protected float _zoom; // Camera Zoom
    public Matrix _transform; // Matrix Transform
    public Vector2 _pos; // Camera Position
    protected float _rotation; // Camera Rotation

    public Camera2d()
    {
        _zoom = 1.0f;
        _rotation = 0.0f;
        _pos = Vector2.Zero;
    }// Sets and gets zoom
    public float Zoom
    {
        get { return _zoom; }
        set { _zoom = value; if (_zoom < 0.1f) _zoom = 0.1f; } // Negative zoom will flip image
    }

    public float Rotation
    {
        get { return _rotation; }
        set { _rotation = value; }
    }

    // Auxiliary function to move the camera
    public void Move(Vector2 amount)
    {
        _pos += amount;
    }
    // Get set position
    public Vector2 Pos
    {
        get { return _pos; }
        set { _pos = value; }
    }

    public Matrix get_transformation(GraphicsDevice graphicsDevice)
    {
        _transform =
          Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
                     Matrix.CreateRotationZ(_rotation) *
                     Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
                     Matrix.CreateTranslation(new Vector3(graphicsDevice.Viewport.Width * 0.5f, graphicsDevice.Viewport.Height * 0.5f, 0));
        return _transform;
    }

    }
}

and here's how I start my spriteBatch

       spriteBatch.Begin(SpriteSortMode.BackToFront,
                BlendState.AlphaBlend,
                null,
                null,
                null,
                null,
                cam.get_transformation(graphics.GraphicsDevice));


texts: Why do I get a "Value Cannot be Null" error on material.SetTexture?

texts:
Probably a really noob question, but:

I'm following this tutorial here and, using the code in the tutorial, I'm getting an annoying error:

Here's the code in question, the error is referring to line 20 (highlighted in the comments):

public class RayTracingMaster : MonoBehaviour
{
    public ComputeShader RayTracingShader;

    public Texture SkyboxTexture;

    private RenderTexture _target;

    private Camera _camera;

    private void Awake()
    {
        _camera = GetComponent<Camera>();
    }

    private void SetShaderParameters()
    {
        RayTracingShader.SetTexture(0, "_SkyboxTexture", SkyboxTexture); // <- Line 20 is here
        RayTracingShader.SetMatrix("_CameraToWorld", _camera.cameraToWorldMatrix);
        RayTracingShader.SetMatrix("_CameraInverseProjection", _camera.projectionMatrix.inverse);
    }

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Render(destination);
        SetShaderParameters();
    }

    private void Render(RenderTexture destination)
    {
        // Make sure we have a current render target
        InitRenderTexture();

        // Set the target and dispatch the compute shader
        RayTracingShader.SetTexture(0, "Result", _target);
        int threadGroupsX = Mathf.CeilToInt(Screen.width / 8.0f);
        int threadGroupsY = Mathf.CeilToInt(Screen.height / 8.0f);
        RayTracingShader.Dispatch(0, threadGroupsX, threadGroupsY, 1);

        // Blit the result texture to the screen
        Graphics.Blit(_target, destination);
    }

    private void InitRenderTexture()
    {
        if (_target == null || _target.width != Screen.width || _target.height != Screen.height)
        {
            // Release render texture if we already have one
            if (_target != null)
                _target.Release();

            // Get a render target for Ray Tracing
            _target = new RenderTexture(Screen.width, Screen.height, 0,
                RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
            _target.enableRandomWrite = true;
            _target.Create();
        }
    }
}

I really can't see why it's telling me the value is null when I'm calling the name of an already defined Texture class. I have set the texture from the inspector. Any help would be appreciated.


texts: why each game does not provide the option to download only one graphic quality, instead of having to download low, medium, high and ultra graphics?

texts:
If there is an option like this it will definitely save storage space.
When you download or stream a film there is an option for graphic quality, and we only download that one graphic quality.
Or is there another reason behind it all?


texts: Entity/Component System and UI "Entities"

texts:
I'm still green to entity/component systems. I find that since I have useful components for drawing sprites (or spritesheets) and handling input (mouse/touch clicks), I naturally want to reuse these to create UI components (like buttons, eg. level-select screen).

This strikes me as very odd. I always understood entities as "game model" things like players, enemies, power-ups, etc. On the other hand, from a code-reuse perspective, reusing compnents for UI makes perfect sense.

How (and where) do UI/GUI concerns fit into an entity/component system?

(Note: this question is platform agnostic since it applies to multiple platforms/languages)


texts: AI Algorithm to make enemy smarter from level to level in Runner game

texts:
I am designing a City-Runner game in Unity 3D Engine.I am a beginner in game development (not in programming). The idea is really simple, the Runner will be followed by AI enemies, and if caught by one of them it will be dead or his energy will decrease.

Anyway I cannot find any Algorithm for implementing a "smart" AI, in the sense that not only he will follow the player and do Path-finding to the player, but also get smarter from the first level to the second level.

Probably AI must store some information/state in regards to the terrain and the runner position.

My question here is :

Is it a good idea to make the AI smarter (because all the runner does is running in a straight line, only the person who is playing the game can change his direction- left, right; so maybe its not like the learning will be very beneficial)
If this is a good idea, do you have any knowledge on what algorithms may be used (implementing neural-nets or something alike)
If it's not the best idea, what AI mechanism can I use expect of path-finding, wandering, seeking, flocking ??

Any kind of advice would be greatly appreciated !!

Thank you.


texts: Accessing DualShock 4 motion sensor in Windows

texts:
I am attempting to access the accelerometer and gyroscope functionality of the dualshock 4 controller for implementation into Unity.

DMGregory seems to have found a solution to this problem, my question is how he succeeded in getting the motion input working here.

He mentions that he reached his solution by grabbing the DS4Tool source and copying parts of the files: NativeMethods, HidDevices and HidDevice

I understand a lot of what is happening here, I just do not have the coding chops to get it working. I believe I should be "using NativeMethods" but do not fully understand how to access the read report to retrieve the necessary data.

Any help is greatly appreciated!


texts: How to tell what part of a 3D cube was touched

texts:
I am writing a rather simple android game and I am implementing Open GL to draw a 3D cube that spins upon the X, Y and Z axis and I need to know where the user has clicked on the texture of the cube.

The texture is a simple square bitmap (100x100) that has a smaller square in the center. I need to know if the user touches the inner square. As well was tell which face of the cube the user touches. Does anyone know how this can be accomplished if not can anyone give some pseudo code on how to tell where the ray correlates to the texture? Or at least point me in the right direction.

The textures of each face are like this:

The whole cube looks like this:
https://docs.google.com/file/d/0BzmLnD4ub-ohaU9CM21WWC1GRW8/edit?usp=sharing

The code I am using is from: http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_3D.html2.9
It is a port to android from Lesson 6 NeHe.
Example 6a: Photo-Cube


texts: Determine which button is at specific coordinates

texts:
I am implementing a weapon wheel in Unity and I have most of it all worked out, but am struggling with one issue:
My weapon wheel looks a bit like this one (example only):

And mine is for something else, not weapons.. but that doesn't matter.
There is no mouse involved.. the idea is to spin the wheel left and right until you've selected the item you want.. the selected one would be the one in the top most position (the example above is the bottom most position, it seems).. Anyway, I have it moving left and right just fine.. the problem now is trying to figure out which button (yes, they are implemented as UI buttons) is currently in the selected position.
My initial thoughts are

To calculate the center X, Y pair of the "selected" location and store those..

When user hits action button to select, then iterate through the 8 buttons I have in that weapon wheel and..

Calculate the current X and Y of each button in the loop

If the button overlaps the "selected" location, then invoke that button's click()

This is proving to be a real pain in the neck though.. for example, I have found that the button transform's positon is always 0,0 until you show the UI at least once.. so I have to use Update() instead of Start().. In addition, trying to calculate the overlap means needing to add width of button to current X and height to current Y and getting pixel width does not seem to be an easy task.
Is there some simpler way to do this? How can I have a "selected" button on my weapon wheel without too much fuss like this? And if this really is the only way, then please let me know how I can get the pixel width and height of buttons.


texts: Jumping onto higher ground Collider issues

texts:
What's the general solution to the following character animation problem (I'm using Unity)?

You have a character with a capsule collider and a jump animation that allows you to jump onto higher ground (such s boxes, etc.). The character shouldn't be able to jump unrealistically high so she goes into a crouched posture while in the air and the collider is scaled accordingly in an animation curve.

However when the character jumps onto the box to land, the character animation (and collider) want to extend back to wards the ground but there is not enough space and either collision detection fails and the character falls into the geometry or the collider starts a collision fight with the box and keeps bumping up and down, keeping the character in an airborne state.

Please see screenshots to get a better idea...

What would be a good way to work around this problem?


texts: Any ad network for XNA games on the PC platform?

texts: There's a lot of press about the ad controls included on the new 7 phone, but I'm looking for candidates for the PC platform.


texts: How can I get the Selector dialog to include my prefabs

texts:
When setting a variable for an object in Unity, for built-in types there is an option on the right-hand side to bring up a dialog that lists the possible values that can be chosen for that variable, for example when selecting a Sprite for a Sprite Renderer:

Is it possible, and if so what do I need to do, to have that list populated with the prefabs within my project?

In this example, there are a number of Item prefabs (both inside and outside the Resources folder if that makes a difference), however they do not appear in that dialog. Is there an attribute I am missing that needs to be specified on the Item class, or something else to enable this?

using UnityEngine;
using System.Collections.Generic;

public class Item : MonoBehaviour, IIdentifiable, IFilterable
{
    [SerializeField]
    private int IdField;
    [SerializeField]
    private bool ActiveField;

    public int Id => IdField;
    public bool Active => ActiveField;
}

public class ItemRandomiser : MonoBehaviour, IWeightedObject
{
    [SerializeField]
    private List<string> NamesField;
    [SerializeField]
    private List<Item> ItemTemplatesField;
}


texts: I'm trying to check if a pixel of a certain color at (x,y) has moved within a boundary of [(x1,y1),(x2,y2)] and also update its new position to console. I'm doing this as a desktop application so no html canvas. Also I'm not sure how to define a boundary in this manner.


texts: Picture rendered from above and below using an Orthographic camera do not match

texts:
I'm using an orthographic camera to render slices of a model (in order to voxelize it). I render each slice both from above and below in order to determine what is inside each slice.

The model I render is a simple 'T' shape constructed from two cubes. The cubes have the same dimensions and have the same Y (height) coordinate. Here's a render of it in Blender:

I render this model once directly from above and once directly from below. My expectation was that I would get exactly the same image (except for mirroring over the y-axis). However when I render using a very low resolution render target (25x25) the position (in pixels) of the 'T' is different when rendered from above as opposed to rendered from below. See figure 2 and 3. The pink blocks are not part of the original rendering but I've added them so you can easily count/see the differences.

Rendered from above

Rendered from below

This is probably due to what I've read about pixel and texel coordinates which might be biased to the top-left as seen from the camera. Since I'm using the same 'up' vector for both of my camera's my bias only shows on the x-axis. I've tried to change the position of the camera and it's look-at by, what I thought, should be half a pixel. I've tried both shifting a single camera and shifting both cameras and while I see some effect I am not able to get a pixel-by-pixel perfect copy from both camera's.

Here I initialize the camera and compute, what I believe to be, half pixel. boundsDimX and boundsDimZ is a slightly enlarged bounding box around the model which I also use as the width and height of the view volume of the orthographic camera.

Matrix projection = Matrix.CreateOrthographic(boundsDimX, boundsDimZ, 0.5f, sliceHeight + 0.5f);
Vector3 halfPixel = new Vector3(boundsDimX / (float)renderTarget.Width, 0,
    boundsDimY / (float)renderTarget.Height) * 0.5f;

This is the code where I set the camera position and camera look ats

  // Position camera
                if (downwards)
                {
                    float cameraHeight = bounds.Max.Y + 0.501f - (sliceHeight * i);
                    Vector3 cameraPosition = new Vector3
                    (
                        boundsCentre.X, // possibly adjust by half a pixel?
                        cameraHeight,
                        boundsCentre.Z
                    );
                    camera.Position = cameraPosition;
                    camera.LookAt = new Vector3(cameraPosition.X, cameraHeight - 1.0f, cameraPosition.Z);

                }
                else
                {
                    float cameraHeight = bounds.Max.Y - 0.501f - (sliceHeight * i);
                    Vector3 cameraPosition = new Vector3
                    (
                        boundsCentre.X,
                        cameraHeight,
                        boundsCentre.Z
                    );
                    camera.Position = cameraPosition;
                    camera.LookAt = new Vector3(cameraPosition.X, cameraHeight + 1.0f, cameraPosition.Z);
                }

Main Question
Now you've seen all the problems and code you can guess it. My main question is. How do I align both camera's so that they each render exactly the same image (mirrored along the Y axis)?


texts: I'm a newbie here. I need to add a second collider in CharacterController in the separate script with possibility to enabling/disabling them. I tried to find answer how to do it but I find nothing. Thanks for any help!


texts:
I wanted conditions that could determine which direction (north, south, east, west, northwest, northeast, southeast, southwest) the player is following, what I got was just north, south, east and west, as shown in the code below:

var playerX = player.x, playerY = player.y;

var destX = 8, destY = -15;

    if (playerX < destX) {
      playerX += 0.5; // east
    } else if (playerX > destX) {
      playerX -= 0.5; // west
    } else {
      playerX = destX; // maintains direction
    }
    if (playerY < destY) {
      playerY += 0.5; // north
    } else if (playerY > destY) {
      playerY -= 0.5; // south
    } else {
      playerY = destY; //maintains direction
    }

image example:


texts: Is it safe StringToHash() to use in Unity?

texts:
I'm currently browsing through the Unity tutorials and saw that they're recommending to use Animator.StringToHash("some string") to created unique ids for animation properties (see here).

Since I'm a programmer, to me the word "hash" doesn't represents something unique. Like the Java documentation for hashValue() states:

  It is not required that if two objects are unequal [...], then calling the hashCode method on each of the two objects must produce distinct integer results.

So, according to this (and my definition of "hash"), two strings may have the same hash value. (You can also argue that there are an infinite number of possible strings but only 2^32 possible int values.)

So, is there a possibility that StringToHash() will give me an id that actually belongs to another property (than the one I requested the hash for)?


texts: Disabling and re-enabling the clicked child objects

texts:
I am currently working on 2D platform game. The following script adding the child objects inside the array and identifies the child object I click on and checks the tag on it. Now I don't know how to disable the child object that I have clicked and I want the disabled child object to be re-enable when I click on another child object inside the same parent object. Any help would be appreciated.

public class SelectedPlatform : MonoBehaviour {

    public GameObject platform;
    void Start()
    {
        Transform[] children = new Transform[transform.childCount];
        for (int i=0; i<transform.childCount; i++)
        {
            children[i]=transform.GetChild(i);
        }
    }

    void Update()
    {
        if(Input.GetMouseButtonDown(0))
         {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if(hit.collider.gameObject.tag == "Platform")
            {
                Debug.Log ("Target Position: " + hit.collider.gameObject.transform.position);
            }
         }
    }
}


texts:
Good time of the day.
My question might sound stupid, due to the knowledge you might have, but here it is.

I've purchased Diablo 3 a long time ago and been enjoying it since then. Since many of my friend are playing other Blizzard titles, i tried to convince them to purchase Diablo and to play all together. However, they don't want to invest money in the game they don't understand (yet).

So i've decided to write a game, which will be similar to the Diablo in the way of interaction and gameplay, but will (obviously) have some unique points in it (since i'm not only doing this for them, but also to educate myself in the game development area). Other this is, i've decided to take Masters in the Game Development (later this march, just got my bachelors in computer security) and wanted to have some basic knowledge about game development.

I used to make "RPG" games before, tho only browser style ones using LAMP stack, and have some basic knowledge on storing/retrieving data to/from server.

In order to implement multiplayer part of the game, i've decided to use free package PUN (Photon Unity Networking). Had no problem with creating my first room and spawning a player prefab for every new connection (tho they all move no matter on which client action is performed).

Now to the question(s):

By using PUN, i'm able to create new room for players (limited to 5), is it possible to set room names BEFORE they are actually initialized by the player? (set of rooms might be stored on MySQL server and retrieved by the API call)
Is it possible to save progression of the player on the server, and later pass it back to the spawned player (by PUN). This is my main concern, since i've no actual access to the data processed by the server. (Solution is to create another connection to the "storage" server, and keep both of them "online"?)
Does PUN allows you to select which scene should be loaded upon first player entering the room, if so, a bit of pseudo code might be helpful.
What will happen to the player, if there is no spots left to join the server (this is just theoretical question, since i'm not going to publish this game, and amount of friends playing games is less than 20)
How would one deal with the item equipped, which is received during the gameplay? (This one links to the second question) What i'm talking about is, is it possible to restore player object with the set of data received form the server (if possible, ofcourse)

I know, the first suggestion will be to go and to read documentation (i'm in the process of reading it, don't worry). But i've decided to write here, since there are many skilled people out there in this area, who can give me basic understanding on how this whole PUN system works.

I would like to thank you for all of the responses, which you are about to post (or maybe not), and again, have a great day.


texts: undefined reference to std::__throw_out_of_range_fmt

texts:
after some time with oxygine i have decided to start learning SFML, i configured codeblocks to link the header files and .so files, and whenever i try to compile i get this error:

||=== Build: Debug in shouldWorkNow (compiler: GNU GCC Compiler) ===|

SFML-2.3.2/lib/libsfml-graphics.so||undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'|

||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

the SFML package came from their website, under the gcc 64bit for linux, the files are DEFINITELY linked as i used a hundred tutorials on the Internet and youtube.

(mint 17.2 Rafaela | default gcc from apt-get | sfml 2.3)


texts:
I have a list of gizmos in a simple gizmo drawing manager. This list is updated from different parts of the codebase, usually from Update() methods. It goes something like this:

public class RenderGizmos : Singleton<RenderGizmos>
{
    private List<GizmoData> gizmos = new List<GizmoData>();

    public void AddNewGizmo(GizmoData[] gizmos)
    {
        this.gizmos.AddRange(gizmos);
    }

    public void AddNewGizmo(GizmoData gizmo)
    {
        this.gizmos.Add(gizmo);
    }

    void OnDrawGizmos()
    {
        if (gizmos == null) return;
        for (var i = 0; i < gizmos.Count; i++)
        {
            //draw gizmos
        }
    }
}

Can you advise me on when to clear the gizmo list? Ideally I would like to clear it every frame. However:

Clearing it at the end of the OnDrawGizmos() method will render no gizmos (as I suspect this method might be called several times a frame).
Clearing it in an LateUpdate()/Update() method is dependent on execution order, sometimes it draws gizmos, sometimes it doesn't
Clearing it in a Coroutine has rendered no gizmos (but it might just be dependent on the execution order as well)

I would like not to be dependent on the execution order so I prefer not to use the Script Execution Order system.


texts: How to calculate falling speed in spritekit?

texts:
Is there a way to calculate falling speed based on physics body settings, instead of waiting it to fall and getting velocity?

I would like to find what time it takes for object to fall from defined point and hit the ground. Usually using this formula time = distance / speed, but this time speed is a problem.


texts: 2D Platformer: add ability to jump on top of other character

texts:
I want to add ability to jump onto a head of other character/player, but still be able to go through them horizontally.
There is one useful tutorial about one-way platforms, but that approach doesn't allow player to go through a platform from a side.

I tried to add sensor to foot and head of characters and enable contact in  preSolve method, but it doesn't look to work very well (sometimes bodies are thrown out from each other with additional impulse).

Do you have any ideas? Also it would be nice to not change sources of box2d as it was done in tutorial as I'm using it from LibGDX.


texts: Optimizing gaussian blur with linear filtering

texts:
There's a few (here, and here) gaussian blur tutorials out there suggesting that you can essentially cut the number of texture lookups in a gaussian blur shader in half by exploiting the GPU's hardware linear filtering.

Essentially turning this:

Into this:

It sounds good in theory, but after attempting to implement this, I've come to the conclusion that it can't be done correctly, and I'd like someone to prove me wrong :)

My beef lies with the weights.  Take the far left 2 texels in the first image.  Their overall contribution to the shader equals:

t1 * w1 + t2 * w2

In the image, their weights 1 and 4, respectively.  Now let us assign abitrary color values to the texels... 10 and 20.  This gives their overall contribution, according to the formula, of 90.  Great.

Now let us try to work this out with linear filtering.

What we want is essentially a new sampling location and a new weight, such that the value sampled at this new location, multiplied by the new weight, equals our original formula.

((t1 - t2 * new_offset) + t2) * w3 = t1 * w1 + t2 * w2

Let's make it easy and choose a sampling location halfway between texels 1 and 2, so that the value sampled is 15 (((10 - 20) * .5) + 20).  So the new weight MUST be 6, so that 15 * 6 = 90.  Ok great.

Now what happens when you change the values...instead of 10 and 20, you use 10 and 30.  With the first way, you get 10 * 1 + 30 * 4 = 130.  But with the linear sampling way, you get a linear sampled value of 20 ((10 + 30) / 2), times the weight of 6...120!  It doesn't match!

Can anyone shed any light on why the linear sampling optimization is thought to work, and what I'm misunderstanding about it?  I would be more than thrilled to be wrong about this :)


texts: Collision detection in multiplayer games

texts:
This a followup to my previous question: How to implement physics and AoE spells in an MMO game?.

There, we concluded that all physics have to be done on the server, and that I should use cylinders for calculations.

Now, how can I check for collision detection on a ground-to-player basis on the server? It's fairly easy if the ground is a flat space, I just check if the player's z coordinate is lower than some value and voila, but, what if the map/ground itself is a model? How do I know where hills are on the server-side? How do I know when object collisions happen?

I'm using node.js and socket.io.


texts: Unity3D: Move the parent gameobject relative to the child

texts:
So, I have X and Y game objects. I have a vector Z = X - Y which is indicated by the green line.

Also, I have a Parent game object and it has a Child game object. How do I move the parent such that the child game object is at the Point Y

I tried,

                  Z -= new Vector3(child.localPosition.x, 0, child.localPosition.z);
                  Parent.transform.position = Z

which is not working as expected.
Thank you!


texts: Using Bullet physics engine to find the moment of object contact before penetration

texts:
I would like to use Bullet Physics engine to simulate the objects in 3D world.

One of the objects in the world will move using the position from 3D mouse control. I will call it "Mouse Object" and any object in the world as "Object A"

I define the time before "mouse object" and "Object A" collide as t-1
The time "mouse object" penetrate "Object A" as t

Now there is a problem about rendering the scene because when I move the mouse very fast, "Mouse object" will reside in "Object A" before "Object A" start to move. I would like the "Mouse Object" to stop right away attach to the "Object A". Also If the "Object A" move, the "Mouse object" should move following (attach) the "Object A" without stop at the first collision take place.

This is what i did

I find the position of the "Mouse Object" at time t-1 and time t.  I will name it as
pos(t-1) and pos(t)

The contact time will be sometime between  t-1  to t, which the time of contact I name it as t_contact,  therefore the contact position (without penetration) between "Mouse object" and "Object A" will be  pos(t_contact)

then I create multiple "Mouse object"s  using this equation

pos[n] = pos(t-1) *  C * ( pos(t) - pos(t-1) )   where  0 <= C <= 1

if I choose C = 0.1, 0.2, 0.3,0.4..... 1.0, I will get  pos[n] for 10 values
Then I test collision for all of these 10 "Mouse Objects" and choose the one that seperate between "no collision" and "collision".

I feel this method is super non-efficient. I am not sure the way other people find the time-of-contact or the position-of-contact  when "Object A" can move.


texts: Can USB device be aware of in-game death?

texts:
I intend to design a peripheral that changes state (in this case, LED color) in response to software state (ideally, player death in-game). I have adequate experience in manufacturing design, but not on the driver/software side of things. Before I try to contract out the driver/software need, I'd like an objective opinion from those who know (GameDev SE) whether or not this is even possible.

Potential Use-case: player in Source-engine game dies >> peripheral lighting changes from green to red for duration of dead period. Player respawns, lighting returns to green state.

Are there hooks in modern engines that would allow a USB peripheral to be aware of this sort of specific game condition? We don't want to require customers to install and run a background process to monitor state. That's way too intrusive.


texts: Loading levels from .txt or .XML for XNA

texts:
I'm attemptin to add multiple levels to my pong game. I'd like to simply exchange a few elements with each level, nothing crazy. Just the background texture, the color of the AI paddle (the one on the right side), and the music.

It seems that the best way to go about this is by utilizing the StreamReader to read and write the files from XML. If there is a better, or more efficient alternative way then I'm all for it. In looking over the XNA Starter Platformer Kit provided by MS it seems that they've done it in this manner as well. I'm perplexed by a few things, however, namely parts within the Level class which aren't commented.

/// <summary>
    /// Iterates over every tile in the structure file and loads its
    /// appearance and behavior. This method also validates that the
    /// file is well-formed with a player start point, exit, etc.
    /// </summary>
    /// <param name="fileStream">
    /// A stream containing the tile data.
    /// </param>
    private void LoadTiles(Stream fileStream)
    {
        // Load the level and ensure all of the lines are the same length.
        int width;
        List<string> lines = new List<string>();
        using (StreamReader reader = new StreamReader(fileStream))
        {
            string line = reader.ReadLine();
            width = line.Length;
            while (line != null)
            {
                lines.Add(line);
                if (line.Length != width)
                    throw new Exception(String.Format("The length of line {0} is different from all preceeding lines.", lines.Count));
                line = reader.ReadLine();
            }
        }

What does width = line.Length mean exactly? I mean I know how it reads the line, but  what difference does it make if one line is longer than any of the others?

Finally, their levels are simply text files that look like this:

....................
....................
....................
....................
....................
....................
....................
.........GGG........
.........###........
....................
....GGG.......GGG...
....###.......###...
....................
.1................X.
####################

It can't be that easy..... Can it?


texts: Battle Engine for Text based browser game

texts:
I am starting to code a browser game, I have a rudimentary chat set up, and would like to start creating the battle engine, I have a general idea of how I want it to play out, but I don't know where I should do the calculations,

SQL Server
ASP.NET

I don't post JavaScript as an option because I don't want the user to be able to alter/hack the game that way.

What are the benefits and drawbacks of either method of coding the Battle Engine?


texts: Is good practice to optimize FPS even when it's above the lower limit to give illusion of movement?

texts:
I started over 50 FPS on the iPhone, but now I'm bellow 30 PFS, I've seen most iPhone games clamped to either 60 or 30 FPS, even when 24 or less would give the illusion of movement.

I've concidered my limit to be a little bit over 15 FPS, in fact my physics simulation is updated at that rate (15.84 steps/s) as that is the lowest that still give fluid movement, a bit lower gives jerky motion.

Is there a practical reason why to clamp FPS way above the lower limit?

Update:

The following image could help to clarify

I can independently set the physic simulation step, frame rate, and simulation interval update.

My concern is why should I clamp any of those to values greater than the minimum?

For instance to conserve battery life I could just to choose the lower limits, but it seems that 60 or 30 FPS are the most used values.


texts: Game Development In C Only. Is it possible?

texts:
I am a first year college student in India and want to make a small game as a this semester project.

I am quite good at C and am learning it rapidly but I wanted to ask if developing a game entirely in C (no C++ or C#) I'd love to use these but for college projects, we have strict requirements of using only C.

What I am looking for is a simple top view driving game. It won't have anything fancy and even the visual things will be powered by simple characters. For example, user controlled car can be represented by ▓ and edges of road by series of |'s.
What do you think?


texts:
I have the following problem: Although I know some of color theory, and the interface design ideals (about how it must be usable, and etc...), my interfaces are REALLY ugly. fugly, eye bleed material, etc...

I am not finding anywhere, information on how to create the graphical part of a interface, how to choose the layout, objects, colours, cursor, etc...

I am doing now most by copying other games, or by "feeling", something that does not always work correctly...

So, what I need to know about it? Where I find it? How I do it?


texts: Eliminate an Actor dragged outside SlotTarget

texts:
As the title suggests, i would like to eliminate an Actor from the Stage when the player moves it outside my SourceTarget. The default behavior of DragAndDrop class doesn't allow to drag an Actor on a place that isn't a valid SourceTarget, but i need to implement the elimination of an Actor in this way.

So, can i implement one or both the following solutions?

1) When the Actor is dragged outside SourceTarget, remove it

2) Use a special TargetActor over which the dragged Actor gets removed (like a trash can)

In this latter case i should create a second special TargetActor, but seems that Libgdx doesn't allow it. I can have only one TargetActor. In my particular case SourceActor and TargetActor are the same.

dragAndDrop.addSource(new SourceActor(slotActor));
dragAndDrop.addTarget(new TargetActor(slotActor));

Thank you


texts:
I am developing a sprite based 2D game for mobile platform(s) and I'm using OpenGL (well, actually Irrlicht) to render graphics. First I implemented sprite rendering in a simple way: every game object is rendered as a quad with its own GPU draw call, meaning that if I had 200 game objects, I made 200 draw calls per frame. Of course this was a bad choice and my game was completely CPU bound because there is a little CPU overhead assosiacted in every GPU draw call. GPU stayed idle most of the time.

Now, I thought I could improve performance by collecting objects into large batches and rendering these batches with only a few draw calls. I implemented batching (so that every game object sharing the same texture is rendered in same batch) and thought that my problems are gone... only to find out that my frame rate was even lower than before.

Why? Well, I have 200 (or more) game objects, and they are updated 60 times per second. Every frame I have to recalculate new position (translation and rotation) for vertices in CPU (GPU on mobile platforms does not support instancing so I can't do it there), and doing this calculation 48000 per second (200*60*4 since every sprite has 4 vertices) simply seems to be too slow.

What I could do to improve performance? All game objects are moving/rotating (almost) every frame so I really have to recalculate vertex positions. Only optimization that I could think of is a look-up table for rotations so that I wouldn't have to calculate them. Would point sprites help? Any nasty hacks? Anything else?

Thanks.


texts: Bitmap BMP Reading Question: I need to read (large) 8MB 32BPP BMP Files into Memory so they may be queued for game play

texts:
class Surface
{
protected:
    Surface();
    virtual ~Surface();

    class IMAGE // create a discreet type to be used to instantiate queue template
    {
    public:
        // single bitmap image width and height
        unsigned short width, height;
        unsigned int size;      // single bitmap image size
        DWORD* buffer;          // buffer to hold a width X height _size_ image
…

class Bitmap : protected Surface
{
public:
    class BMP_32
    {
    public:
        BMPHeader       HeaderSection;
        BMPInfo         InfoSection;
        BMPColorTable       ColorTableSection;

…

void Bitmap::BMP_32::Read(Bitmap::BMP_32& a_bmp32, IMAGE& an_image, SURFACE& a_surface, const char* file_name)
{
…
fread(&a_bmp32.HeaderSection.FileType, sizeof(a_bmp32.HeaderSection.FileType), 1, fp);
…
fread(&a_bmp32.InfoSection.HeaderSize, sizeof(a_bmp32.InfoSection.HeaderSize), 1, fp);
…
fread(&a_bmp32.ColorTableSection.RedIntensity, sizeof(a_bmp32.ColorTableSection.RedIntensity), 1, fp);
…

an_image.buffer = new DWORD[IMAGEBUFFERSIZE];

…
// The following three examples render the same output visually:

// DWORD dwords_read = fread(an_image.buffer, sizeof(DWORD), an_image.size, fp);  // dwords_read = 2,073,600

DWORD dwords_read = fread(an_image.buffer, (SCREEN_WIDTH * SCREEN_HEIGHT), 4, fp);   // dwords_read = 4
// DWORD dwords_read = fread(an_image.buffer, ((SCREEN_WIDTH * SCREEN_HEIGHT) * 2), 2, fp);  // dwords_read = 2

Background Detail: I am building up a class framework to read in 32BPP BMP files, that I am creating on a backsurface, which I then bltfast to the frontsurface and flip to GDI. The 32BPP background BMP that I am reading in is 8294400 in size, but the most I am able to read using “fread()” is 2073600, which is exactly 25% of the original artwork. I am using Visual Studio 2019 Community Edition and fread(&MyBuffer, arg2, arg3, stream) extensively. My application is an MFC application.

I have a need to read in the entire BMP Pixel Data Section into memory, because I am saving this into a queue Abstract Data type. Once I have the BMP in memory the I/O is done to disk and I just make calls to update the backsurface, bltfast and flip to update my scene. I am creating a class library for the BMP code.

Question: Is fread() hitting an upperbound on size limit? If so can someone suggest how I might be able to overcome this problem. If so I am hoping to make a minor substitution for this fread() API call for another C++ call. I cannot do anything too fancy with multiple buffers or doing a lot of I/O, as I have tried that approach already without success.


texts: Why isn't this UIButton visible in Xamarin.iOS?

texts:
I'm trying to implement buttons into my game. I noticed iOS has the UIButton class, which I tried, but upon drawing it nothing is shown. The asset image is properly loaded, I've checked this. The SpriteBatch isn't drawing on top of the buttons either. Draw is properly being called on every frame. The button's enabled property is set to True.

The code, simplified:

private List buttons;

public void AddButtons()
        {
            UIButton b = new UIButton(UIButtonType.Custom);
            b.SetBackgroundImage(UIImage.FromBundle("icon.png"), UIControlState.Normal);
            b.Frame = new System.Drawing.RectangleF(0, 0, 256, 256);
            buttons.Add(b);
        }

    public void Draw()
    {
        foreach (UIButton b in buttons)
        {
            b.Draw(b.Frame);
        }
    }

Why isn't it visible?


texts:
Could there be a 3D scanner that captures movement? One that scans, let us say, 30 times per second (for 30 fps) to make an animated 3D scene? Is this possible? Why?

Suppose we want to scan a person dancing (I know a similar result could be achieved by applying a 3D scan of the person to a motion-captured data, but it is an example). Instead of a simple 3D scan of the person, it would make 30 scans every second. Then a computer would get all these point clouds data (of each "frame") and merge them into an animation by comparing different scans.
It is different from motion capture because these 3D scans would create many point clouds every second, rather than just capturing the motion by itself. Just like normal cameras film several frames per second to make a video, 3D movement scanners would make several scans to make a 3D animated scene.

Does this already exist? And do you think the limit of nowadays computers processing powers are a problem to scan a scene with such high frequency (30 scans per second)?


texts: LibGDX: Google Play Game Service (Dec 2016) - Cannot call Games class

texts:
I'm trying to include Google Play Game Services in my Android game and I tried adding BaseGameUtils library. But it is not really working.

I can call the GameHelper class from AndroidLauncher but not the Games class for getting leaderboards.

I also have this warning in my console: (which does not interfere with the actual problem - see the answer)

project ':android': Unable to resolve additional project configuration.
Details: groovy.lang.MissingPropertyException: Could not find property 'main' on SourceSet container.

Can somebody give any insight to this problem?

This is my android gradle: http://pastebin.com/ya85gGs4

And this my BaseGameUtils gradle: http://pastebin.com/0iyz2j12

Also the root gradle: http://pastebin.com/in2MmYMM

When I check Project Structure -> Problems, I have these messages:

EDIT: I have tried changing android support library, appcompat and google play services to different versions including the latest ones but this error keeps pissing me off.

PS: Please feel free to edit the title. I put the date because I wanted to imply that this is a recent issue.


texts: Need help with a field of view-like collision detector!

texts:
I ran into a trouble while making a field of view for my character. I figured how to make it work with a Linecast, but what I really need is a cone-shaped field, so that the character can detect objects or enemies if they get in that field of vision. It also needs to be intersectable by other objects, so OnCollisionEnter won't work. I suspect that Raycasting might solve the problem, but I couldn't quite understand it's workings, because I'm still new. I would really appreciate any ideas that might help to solve it.
Here is what I need:

Here is what I have so far, but this detector is unsuitable, because it can only detect objects in a straight line:

public Transform sightStart, sightEnd;
    // Update is called once per frame
    public bool objectSpotted = false;
    void Update () {
        Raycasting1 ();
}
void Raycasting1()
{
    Debug.DrawLine(sightStart.position, sightEnd.position, Color.green);
    objectSpotted = Physics2D.Linecast (sightStart.position, sightEnd.position);
}


texts: Should I bake all textures to a texture atlas in a game level?

texts:
I'm writing my own game engine using Java/OpenGL.  I'm creating levels in Blender 3D and exporting them in a custom file format.  I'm not going to be auto-generating any terrain - everything is going to be exported directly from Blender.

I'm trying to figure out the best way to deal with textures for the static objects in my scene (including very large objects like long ridges of cliffs, grassy fields, canyon floors, etc).  One possibility is to just use the textures at they are applied in the editor.  I have a lot of tiling textures for grass and dirt and such that are not too big and which cover large meshes.  This doesn't take up much texture memory space, but is a little inflexible from an art/design standpoint.  Also, if I want to do something special - like create a blend shader to have a dirt path run through my field - I'll need to code a unique shader to handle this case.  (To complicate things further, Blender doesn't provide support for custom GLSL shaders, so exporting unique things like this will be non-trivial).

Alternately, I can create a single texture atlas for the entire level and bake everything onto it.  This way I don't have to worry about special purpose shaders or multiple tiling textures.  The down side is that this texture would be enormous.  I'm worried such a large texture might be bigger than my device can handle.

Anyhow, I'm not sure what the best practice is in these cases.  Should I bake everything out, or have each model with its own texture?


texts: DXGI and 2+ full screen displays on Windows 7

texts:
I am developing a program that needs two full screen Direct3D dispalys. According to the documentation I should create the swap chains in windowed mode and then switch to full screen mode. While this works fine on Windows 8 (currently I'm just using Alt-Enter to do the switch), it does not work on Windows 7. On Windows 7 I get a problem similar to this issue where the screen that has most recently been switched to full screen works fine, but the other screen, which was previously working just fine in full screen, goes black (and stays at the same full screen resolution) until I take it out of full screen.

You can find my mess of a rough prototype at this tag: github.com/AllenPestaluky/InputLagTimer/tree/DXGI

Apparently there have been other bugs relating specifically to Windows 7 in the past... But I appear to be getting an issue that is slightly different: scalibq.wordpress.com/2012/05/25/the-story-of-multi-monitor-rendering/

Also, I have tried disabling DWM Composition like suggested in the linked question, but that did not do anything to resolve the problem..

Please let me know if there's any more information I can provide about the issue... I guess worst case scenario is I simply fall back on DX9 which apparently works fine for multi-monitor full screen setup...


texts: Hue, saturation, brightness, contrast effect in hlsl

texts:
I am new to pixel shader, and I am trying to write a simple brightness, contrast, hue, saturation effect. I have written a shader for it but I doubt that my shader is not providing me correct result, Brightness, contrast, saturation is working fine, problem is with hue. if I apply hue between -1 to 1, it seems to be working fine, but to make things more sharp, I need to apply hue value between -180 and 180, like we can apply hue in Paint.NET.

Here is my code.

// Amount to shift the Hue, range 0 to 6
float Hue;
float Brightness;
float Contrast;
float Saturation;
float Alpha;

sampler Samp : register(S0);

// Converts the rgb value to hsv, where H's range is -1 to 5
float3 rgb_to_hsv(float3 RGB)
{
    float r = RGB.x;
    float g = RGB.y;
    float b = RGB.z;

    float minChannel = min(r, min(g, b));
    float maxChannel = max(r, max(g, b));

    float h = 0;
    float s = 0;
    float v = maxChannel;

    float delta = maxChannel - minChannel;

    if (delta != 0)
    {
        s = delta / v;

        if (r == v) h = (g - b) / delta;
        else if (g == v) h = 2 + (b - r) / delta;
        else if (b == v) h = 4 + (r - g) / delta;
    }

    return float3(h, s, v);
}

float3 hsv_to_rgb(float3 HSV)
{
    float3 RGB = HSV.z;

    float h = HSV.x;
    float s = HSV.y;
    float v = HSV.z;

    float i = floor(h);
    float f = h - i;

    float p = (1.0 - s);
    float q = (1.0 - s * f);
    float t = (1.0 - s * (1 - f));

    if (i == 0) { RGB = float3(1, t, p); }
    else if (i == 1) { RGB = float3(q, 1, p); }
    else if (i == 2) { RGB = float3(p, 1, t); }
    else if (i == 3) { RGB = float3(p, q, 1); }
    else if (i == 4) { RGB = float3(t, p, 1); }
    else /* i == -1 */ { RGB = float3(1, p, q); }

    RGB *= v;

    return RGB;
}

float4 mainPS(float2 uv : TEXCOORD) : COLOR
{
    float4 col = tex2D(Samp, uv);

    float3 hsv = rgb_to_hsv(col.xyz);

    hsv.x += Hue;
    // Put the hue back to the -1 to 5 range
    //if (hsv.x > 5) { hsv.x -= 6.0; }
    hsv = hsv_to_rgb(hsv);
    float4 newColor = float4(hsv,col.w);

    float4 colorWithBrightnessAndContrast = newColor;

    colorWithBrightnessAndContrast.rgb /= colorWithBrightnessAndContrast.a;
    colorWithBrightnessAndContrast.rgb = colorWithBrightnessAndContrast.rgb + Brightness;
    colorWithBrightnessAndContrast.rgb = ((colorWithBrightnessAndContrast.rgb - 0.5f) * max(Contrast + 1.0, 0)) + 0.5f;
    colorWithBrightnessAndContrast.rgb *= colorWithBrightnessAndContrast.a;

    float greyscale = dot(colorWithBrightnessAndContrast.rgb, float3(0.3, 0.59, 0.11));
    colorWithBrightnessAndContrast.rgb = lerp(greyscale, colorWithBrightnessAndContrast.rgb, col.a * (Saturation + 1.0));
    return colorWithBrightnessAndContrast;
}

technique TransformTexture {
    pass p0 {
        PixelShader = compile ps_2_0 mainPS();
    }
}

Please If anyone can help me learning what am I doing wrong or any suggestions?
Any help will be of great value.

EDIT:
Images of the effect at hue 180:

On the left hand side, the effect I got with @teodron answer. On the right hand side, The effect Paint.NET gives and I'm trying to reproduce.


texts: Why can't I store a value in transform.position.y?

texts:
Well I have this line of code

            Vector3 pos = cell.CellPosition;
            float light1Height = 10f;
            pos.y = light1Height;

            lightGameObject.transform.position.y = light1Height;
            lightGameObject.transform.position.x = pos.x;
            lightGameObject.transform.position.z = pos.z;

The error states that

Cannot modify a value type return of 'UnityEngine.Transform.position". Consider storing the value in a temporary variable.

What should i do? Thanks!


texts: Inventory management syncronized network

texts:
I'm implementing an inventory system with items in 1x1 slots in a open-world multiplayer game. But I can't decide how I want to synchronize the item management with the server. I see two options here.

Server and client are fully synced after every move.
Synchronize every action the player takes in their inventory, even the action of "lifting" items.
Server only syncs "when neccessary" An unordered list on the server keeeping track of WHAT items the player has and not WHERE (in what slot) they are. Then every time the player drops/uses/acquires or stacks/unstacks an item the client syncs their inventory including slot positions with the server.

Is there perhaps another option that's even better?


texts: Trying to create a sphere in UDK on which I can stand

texts:
Trying to build a globe in UDK, but when I do (create a sphere), my player falls straight through it.  How do I make a sphere that I can walk on?  Every other shape (cube, cone...etc) work just fine.

--

Edit:  Specifically, I want to build a CSG/Brush sphere, not a mesh sphere.  It appears to work just fine if I set the "sphere exptrapolation" to 1 or 2, but if I bump it up to 3 or higher, I fall right through.  I literally created 2 spheres next to each other, one set at "2" and one at "3" - I can walk from the top of the "2" sphere and jump onto the "3" sphere, but I fall right through it.


texts:
Using something like Blender, would it be easier and more time and space efficient to create 'tiles', and use some kind of software like Tiled to use these tiles in the various maps, or would it be faster to just create the entire maps in Blender?

I ask because the first approach sounds better, in that it takes less space, time and effort, but the second approach seems to be used everywhere. Right now my game uses tiles, but it's very hard to add any kind of elevation. So should I ditch tiles for building the entire scene in Blender or not?

(sorry if my question doesn't fit the format!)


texts: What are the pro/cons of Unity3D as a choice to make games?

texts:
We are doing our school project with Unity3d, since they were using Shiva the previous year (which seems horrible to me), and I wanted to know your point of view for this tool.

Pros:

multi platform, I even heard Google is going to implement it in Chrome
everything you need is here
scripting languages makes it a good choice for people who are not programming gurus

Cons:

multiplayer ?
proprietary, you are totally dependent of unity and its limit and can't extend it
it's less "making a game from scratch"
C++ would have been a cool thing

I really think this kind of tool is interesting, but is it worth it to use at school for a project that involves more than 3 programming persons ? What do we really learn in term of programming from using this kind of tool (I'm ok with python and js, but I hate C#) ? We could have use Ogre instead, even if we were learning direct x starting january...


texts:
http://altdevblogaday.org/2011/02/24/introduction-to-behavior-trees/

Obviously the most interesting article I found on this website. What do you think about it ?

It lacks some code example, don't you know any ? I also read that state machines are not very flexible compared to behaviour trees... On top of that I'm not sure if there is a true link between state machines and the state pattern... is there ?


texts: How do I merge quads to simplify a heightmap?

texts:
I'm trying to improve my frame rates.

My map has an area of 200 * 200 vertices, where each vertex has a height.
200 * 200 = 40000 vertices per frame.

I'd like to create a method to simplify the whole heightmap (i.e. decrease vertex count). Every 4 vertices form a quad, so when there are 2 or more adjacent quads with the same height on each vertex, they could be merged.

How do I detect and merge vertices like that?

My height map is a list of floats representing the height of each vertex. The list is indexed by an x and y coordinate.

package rgc.area;

import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

public class Terrain {

    private HeightMap map;

    public Terrain(HeightMap map) {

        this.map = map;
    }

    public void render() {

        float spaceBetwVert = 1f; // Space between each vertex

        GL11.glColor3f(0.1f, 1.0f, 0.2f);
        GL11.glBegin(GL11.GL_QUADS);
            for(int i = 0; i < map.getHeight() - 1; i++) {

                for(int ii = 0; ii < map.getWidth(); ii++) {

                    GL11.glColor3f(0.1f, 1.0f - ii * 0.1f, 0.2f);

                    float vz = i * spaceBetwVert;
                    float vx = ii * spaceBetwVert;
                    float nextVz = (i + 1) * spaceBetwVert;
                    float nextVx = (ii + 1) * spaceBetwVert;

                    GL11.glVertex3f(vx, map.getHeight(vx, vz), vz - 80);
                    GL11.glVertex3f(nextVx, map.getHeight(nextVx, vz), vz - 80);
                    GL11.glVertex3f(nextVx, map.getHeight(nextVx, nextVz), nextVz - 80);
                    GL11.glVertex3f(vx, map.getHeight(vx, nextVz), nextVz - 80);

                }
            }
        GL11.glEnd();
    }
}


texts: Tools for generating texture atlases/sprites from source images?

texts:
Is there an industry standard file format for texture atlases?

What are the apps that take a directory of images and turns it into a texture atlas png and a text file describing what's on it?

This is primarily for use in OpenGL iPhone/Objective-C, but it seems like there ought to be a standard across many platforms.  I can create these by hand or by writing a script to simply tile them, but it seems like there would be some tools already made for this.


texts: Are environments built in external applications or in Unity?

texts: Totally new to game development here– I know models are never built in Unity, but what about environments? Is it common to say, build an office building environment with hallways and doors (sans furniture and props) in Blender and import that into Unity and assemble the scene there?


texts:
Are the Daz products viable for 2D/3D game asset creation or are they geared more towards creating art?  I am thinking of the products: Daz Studio 3D, Bryce and Carrara.

If you have used any of these products for 2D or 3D asset creation please provide input on any export issues you have encountered.


texts: SDL2 with OpenGL -- weird results, what's wrong?

texts:
I'm porting an app to iOS, and therefore need to upgrade it to SDL2 from SDL1.2 (so far I'm testing it as an on OS X desktop app only). However, when running the code with SDL2, I'm getting weird results as shown on the second image below (the first image is how it looks with SDL, correctly). The single changeset that causes this is this one, do you see something obviously wrong there, or does SDL2 have some OpenGL nuances I'm unaware of?
My SDL is based on the latest from HG.

Update:  another question about the iOS port of the same project is here.

Update 2: this is now also on the SDL newsgroup: http://thread.gmane.org/gmane.comp.lib.sdl/58026

Update 3: I tried using Regal for portable OpenGL, the not-so-good result is on the third screenshot, produced merely by replacing

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>

with

#include "GL/Regal.h"
#include "GL/RegalGLU.h"


texts: Can 2D Rigidbodies detect collisions with 3D Box colliders?

texts:
I would like to know if Rigidbody2D's can detect collisions with 3D Box colliders and/or normal rigidbodies.

I seem to have a problem where my 2D Colliders don't detect collision with my 3D Cubes. :/


texts:
I have a turret with a 2 gunbarrels. The turret rotates towards my mouse. So far no problem. When it creates a few bullets and positions them at the end of the gun barrels.

Here is the problem. It only works the moment the gun is point upwards. The moment it rotates the end of the gun barrels have moved ofcourse, thus the bullets don't spawn at the end of the gun battels, but at the place the where the gun barrels are when the turret is pointing upwards.

How can I check where the end of the gun barrels are the moment it rotates?

EDIT:
With the following code it positions the bullet next to turret, not at the end of the gun barrels.

To see what I mean:

    Vector2 _bulletPosition = new Vector2();
    _bulletPosition.X = (float)((Math.Cos(_rotation)) * _barrelLenght) + _position.X;
    _bulletPosition.Y = (float)((Math.Sin(_rotation)) * _barrelLenght) + _position.Y;

_rotation = the angle the turret is rotated at.

_barrelLenght = the length of the barrels.

_position = the position of the turret.

EDIT 2:
With this code I get the bullets right between the 2 gun barrels.

    _bulletPosition.X = (float)((Math.Cos(_rotation - (float)(Math.PI / 2))) * _barrelLenght) + _position.X;
    _bulletPosition.Y = (float)((Math.Sin(_rotation - (float)(Math.PI / 2))) * _barrelLenght) + _position.Y;

With this code I get the 2 bullets at the right end of the gun barrels, but only when the turret is pointing upwards.

    _bulletPosition.X = (float)((Math.Cos(_rotation - (float)(Math.PI / 2))) * _barrelLenght) + _position.X + bulletSpawn.X;
    _bulletPosition.Y = (float)((Math.Sin(_rotation - (float)(Math.PI / 2))) * _barrelLenght) + _position.Y + bulletSpawn.Y;

I have to get the bulletSpawn relative to the end of the gun barrels position.

EDIT: THE FIX I FOUND

I found a fix that worked

    //Create Matrix with rotation value
    Matrix rotationMatrix = Matrix.CreateRotationZ(_rotation);
    //Create Vector2 with offset from turret center to end of barrel.
    Vector2 _bulletPosition = point;
    //Do a transform with the bulletPosition Vector2 and the rotationmatrix
    _bulletPosition = _position + Vector2.Transform(_bulletPosition, rotationMatrix);


texts: Why is there high performance hit with many meshes?

texts:
I am currently reading upon Geometry Instancing, as I want to render a lot of animatable objects on the screen.

However I have come to a more fundamental question first: Why do I even need to use it?

Consider this setup:

A plane as the base of the game world
On top of that a lot of tiles, which can be destructable with the use of a Physics Engine.
A camera which you can control with WASD + mouse for direction.

Now I do understand that there definately must be a performance hit at some point. I thought it would occur when sending all object data (vertices) to the GPU.

However the performance hit remains to be there, at every single frame it renders, what is actually happening in the background? Considering nothing at my scene is changing at all, it even happens when I do not move the camera at all.

I have no clue what exactly is going on and would definately want to read up more about it before starting to fix an issue that I do not understand, thus making the fix also harder to understand. I do know however that the fix (Geometry Instancing) works by sending the vertex data only once per multiple of objects based on that same vertex. So somehow it would have to do with the amount of vertices, yet I don't see what is going on?

Also: I am using the Ogre3D engine, so any specific answers/tips to that engine would also be welcome.

Regards.


texts:
I am trying to write some code in Java for drawing sprites on a BufferedImage.

As of now I have each sprite in a single dimension array. However this is not good for my game because each sprite would only have one image for their sprite.

I would like each sprite to be animated meaning there would be more images to be stored. I have tried using two dimensional arrays for this but I keep running into the same issue with only one frame being stored.

What would be the proper way to solve this?

int[][] pxArry;
this.pxArry = new int[][]{
    new int [pxArry.length],
    new int [pxArry[1].length]
};
for(int i = 0; i < pxArry[0].length; i++)
    for(int i2 = 0; i2 < pxArry[1].length; i2++){
        this.pxArry[1][i2] = pxArry[1][i2];
    }


texts: Does calling VSSetShader() twice with the same shader have a performance penalty?

texts:
Let's say I render 2 objects that are using the same shader (and the same ID3D11VertexShader object). When I call VSSetShader() to set the shader for the 1st object DirectX has to change previous shader to the new one which takes some CPU/GPU time. But when I then render the 2nd object and call VSSetShader() again with the same argument(s) does it set the shader again (and take as much CPU/GPU time as before) or is DirectX "smart" enough to figure out it's the same shader and it doesn't have to change anything?

Actually, I'd like to ask a broader question - does the same hold true for other analogous state changing function calls? Like setting buffers, sampler states, blending states etc... Pretty much whenever it's a matter of "applying"/"setting as current" objects and states when I actually try to set the same as before.


texts: What should I use to handle input? I am wanting to use OpenGL so that my games are cross platform. DirectX provides input libraries, and OpenGL does not. Because my games need to be cross platform, I cannot use DirectX's libraries. What should I do, or what is the common solution to this type of problem?


texts:
Simplified version of my deferred rendering looks like this:

bind fbo1
clear color and depth buffers
gbuffer stage (gbuffer contains only these pixels which pass a depth test)
unbind fbo1
bind fbo2
clear color buffer
draw a full screen quad, shading stage (render to the texture for some post processing effects)
unbind fbo2
clear color and depth buffers
draw a full screen quad and render to the default framebuffer

How to combine that with the forward rendering ?


texts: CopperCube game engine Android export failed

texts:
I am using CopperCube 6.0.2 to develop my game.

I am able to export my game to exe and webgl format, but when I try to export it to .apk format it says:

  aapt tool .exe missing error

I downloaded the sdk pakage and it now shows:

  failed to find the android jar

How can I resolve this issue?


texts:
Currently I have a procedurally generated planet using multiple octaves of perlin noise. The thing is, that I don't generate heightmap, but rather get the values of perlin function and apply them directly to vertices.

I'd like to add more surface features. Right now terrain is very rough, there are no flat areas, or rivers.

How can I add those features? Normally there would be some sort of heightmap-filtering, for example voronoi + perlin = good-looking terrain with flat surfaces.

Is it possibile to somehow mix fractal algorithms? If so how, which ones and where can I find more info about it?


texts: How to get a large quantity of photographs in an app while being memory efficient??

texts:
There have been a lot of word games (apps) lately and some use graphics but others use photographs and I was hoping that someone could explain how these games manage to get so many photos in an app without taking up huge amounts of memory?

The easiest example I can give is an app called '4 pics 1 word' it has over 350 levels and obviously 4 pics on each level and the photos are good quality on retina screens but the memory of the app is less than 40mb, if I have remembered correctly. I was curious as to how this works, is it each photo being optimized in photoshop (save for web and devices) (png or jpeg) or is it something to do with the code or something else?

I know this question is quite broad but any answers, help, links to anything would be greatly appreciated.


texts: How do I get the width of a string as it would be displayed on screen?

texts:
What is the best and easiest way to get the width of a String using Slick2D?

I'm working on the achievement interface menu in my game that displays some images. On each image I need to draw a string such as "Reach Level 5.". Only problem is that I don't know how to get the string width to properly center the string on the image.


texts: In Phaser, how should I be managing state?

texts:
I'm quite new to Phaser and JavaScript really confused about state management.

Phaser has lots of documentation and info on the net, but everyone seems to be doing it a different way.

An example:

var game = new Phaser.Game(800,600, Phaser.AUTO, 'phaser-demo',
        {preload: preload, create: create, update: update, render: render});

function preload(){ ... }
function create() { ... }
function update() { ... }
function render() { ... }

Another:

window.game = new Phaser.Game(800, 600, Phaser.AUTO);
// all other states are in different files

module.exports = {
    preload: function(){ ... },
    create:  function(){ ... },
    update:  function(){ ... }
};

I would be grateful for a simple overview of properly handling states.