texts: For making an online multiplayer browser-based game, what tech would be more efficient to use?

texts:
I asked a partial question on stackoverflow, and then realized that this would be the place to get a better answer because this is the game dev website, and you all may know more than the programmers over at stackoverflow about this subject.

So my question is: for making an online multiplayer game that runs in the browser, what would be more efficient to use? flash, javascript, html5, or anything else? Also take into consideration that whatever language is used will be using PHP to access databases and such.

Edit

Efficient as in up to date: what is used today by most people, what should be used by a group of people who aren't that experienced in programming (AKA easy, well documented) this isn't really a yes or no question, more of an opinionated answer. Some people hate flash but others love it, I'm unsure of what I should use for a Browser MMO RTS and would like your opinions on it.

Just to clear this up to people who don't know: an MMO RTS usually means its a game with not too much movement, but nifty animations when you scroll over pictures. Also has pretty nice art (dealing with pixel art or whatever will be an issue...).

Also, should I use Javascript+Flash? Say most of the game was written in javascript, but certain fight animations or something were written in flash... is this plausible? Or should it be entirely done with a certain language (the visual aspect).


texts: How to properly scale from natural coordinates to screen coordinate system in OpenGL?

texts:
I am working on a Physics Engine, and I have been using opengl to visualize what it's doing.  I think I have a scaling issue when going from natural coordinate system to the opengl screen coordinate system, which is between -1 and 1.  I am saying that 1 is 150 meters and -1 is -150 meters.  Therefore, to get to scale I should be able to take the natural coordinate system point say <0,100>, and scale to screen by doing <0,100/150>, which is approximately <0,.667> screen coordinates.

When I watch a 1 kg ball fall from 100 meters, it seems too be falling to slow, as if it's falling under water (see https://www.youtube.com/watch?v=KiZODHIvJ4A for reference).  The physics engine seems to be correct.  I think it has something to do with the coordinate system translation (just dividing by 150 scalar right now).  Does anyone know if I am doing this correctly?


texts: How are the following 3D effects mocked in Myst 4? (link)

texts:
Superficially, I thought 'all' that would be required to make a myst style game would be to place the camera inside a 3D sphere, with the sphere's inner surface textured with an appropriately-distorted (to account for the concave nature of the sphere), 2D rendering of a 3D world.

The only thing that I can't really work out is how are some elements of the game alive and moving?

In this video, the sea waves are moving:
http://www.youtube.com/watch?v=ju0lACSm7Us

In this one we have some pretty cool particle effects involving clouds, as well as lighting, thought I think the lightning is pre-rendered:
http://www.youtube.com/watch?v=_CidCIDHFL4

I doubt these effects are actually 3D; I think they are 2D looping movie files. However I could be wrong.

To clarify, how do you think they've achieved such gorgeous 3D effects regarding the water, clouds and lightning?

Are they looping movies? How are these movies presented to the user and integrated so well?


texts: Get all images from peristent data path and save them to a Texture2D array

texts:
So i managed to make a working script that downloads images from firebase in this situation and saves them to Application.persistentDataPath. Now what i would like help in doing is getting all those images "*jpg" and assigning them to a Texture2D array for later use.
So far i have mananged to open one of those images by name and assign it to a single texture.
    public Texture2D image;

 private void Awake()
    {
        string dirname = "levelNature";
        string path = Application.persistentDataPath + "/" + dirname + "/" + "nameofImage.jpg";

        LoadSprite(fileName);

    }

    private void LoadSprite(string path)
    {
        if (string.IsNullOrEmpty(path))
            Debug.Log("null or empty");

        if (File.Exists(path))
        {
            byte[] bytes = File.ReadAllBytes(path);
            Texture2D texture = new Texture2D(1024, 1024, TextureFormat.RGB24, false);
            texture.LoadImage(bytes);
            image = texture;
            Debug.Log("success");
        }
    }

With just one image i can assign it to a texture but since later on in the gameplay i'm using a texture2d array to assign those images to the gameplay , which now are set through the inspector , i would like to load all images in a particular folder to a Texture2D array which later on i will be using to show each image index in a specific level.
I did try it out like this but it isn't successful.
    public Texture2D[] source;

        var fileNames = Directory.GetFiles(Application.persistentDataPath + "/" + dirname + "/" + "*.jpg");

        source = new Texture2D[fileNames.Length];
        int index = 0;
        foreach (var fileName in fileNames)
        {
            source[index] = LoadSprite(fileName); // i get the error here that it cant convert void to texture2D
            index++;
        }

Hopefully once all images are loaded i could see in that array in the inspector all the images and then use that for the rest of the game. Thank you!


texts:
Possible Duplicate:
  How can I prevent cheating on global highscore tables?

So, I create a game in Flash and I want to keep a hi-score table for people to compete in.

After a player has finished playing a game, the game needs to transmit the score (& player's name etc) back to a central server, to store the results in a database, probably via a PHP web page for simplicity.

All this is fine, but at this point nothing is stopping some 'clever' individual from sending a their own customised message directly to the PHP page and entering their own values directly into the hi-score tables, therefore cheating the data without even playing!

So, what can I do to ensure that the data being sent is only validated if it comes from the game itself?


texts: How to filter list of all objects in Unity project, by their type?

texts:
I want to filter the list of project objects in unity, and view all objects of specific type in the project. (by type, not by name)
How can I do that?


texts:
I have a server set up for my game with Lidgren, and it works well when I have it set up on one machine, but if I try to run the server on another machine, I am unable to connect from other machines.  I checked my port when running the server, and it says it's closed, despite the lidgren server running.  I set the NetPeerConfiguration localaddress to be my ipv4 address and made sure my router was forwarded at this ipv4 address at the port I was running the server on, but still no luck.  Here is the relevant server code-

NetPeerConfiguration config = new NetPeerConfiguration("Platformer");
IPAddress[] ipv4Addresses = Array.FindAll(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork);
config.LocalAddress = ipv4Addresses[0];
config.Port = 8888;
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
NetServer server = new NetServer(config);
server.Start();

The server says it's being started at the local ip with the right port, and everything is forwarded correctly on the router.  What is going wrong here?


texts: How to have random and different colors on multiple objects with one material?

texts: I want to have one material applied to multiple objects that has a random color on each object. How can I achieve this so that I don't need to use a different material for every object? This is in Unity 5 by the way.


texts:
I'm working on a 2d game and am looking to make a sprite move horizontally across the screen in XNA while oscillating vertically (basically I want the movement to look like a sin wave). Currently for movement I'm using two vectors, one for speed and one for direction. My update function for sprites just contains this:

Position += direction * speed * (float)t.ElapsedGameTime.TotalSeconds;

How could I utilize this setup to create the desired movement? I'm assuming I'd call Math.Sin or Math.Cos, but I'm unsure of where to start to make this sort of thing happened. My attempt looked like this:

    public override void Update(GameTime t)
    {
        double msElapsed = t.TotalGameTime.Milliseconds;
        mDirection.Y = (float)Math.Sin(msElapsed);
        if (mDirection.Y >= 0)
            mSpeed.Y = moveSpeed;
        else
            mSpeed.Y = -moveSpeed;
        base.Update(t, mSpeed, mDirection);
    }

moveSpeed is just some constant positive integer. With this, the sprite simply just continuously moves downward until it's off screen. Can anyone give me some info on what I'm doing wrong here? I've never tried something like this so if I'm doing things completely wrong, let me know!


texts: XNA drawing textures on random positions

texts:
I'm trying to reproduce this tutorial, but each time I try to implement it into my code, I always get a lot of errors. Now I finally managed to code something like this, the game runs, but nothing happens at all, my screen remains black without any texture drawn on it, and I just can't figure out what am I doing wrong here.
Here's my background class:

public class background
{
    public Vector2 position;
    public Texture2D texture;
    private List<Star> stars;
    private Random _Random;

    private int MaxX;
    private int MaxY;
    private int _Intensity;

    public background(ContentManager content, int Intensity)
    {
        this.texture = content.Load<Texture2D>("star2");
        _Intensity = Intensity;
        this.MaxX = 1280;
        this.MaxY = 720;
        stars = new List<Star>();
        _Random = new Random(DateTime.Now.Millisecond);

        for (int i = 0; i < Intensity; i++)
        {
            int StarColorR = _Random.Next(25, 100);
            int StarColorG = _Random.Next(10, 100);
            int StarColorB = _Random.Next(90, 150);
            int StarColorA = _Random.Next(10, 50);

            stars.Add(new Star(new Vector2(_Random.Next(MaxX / -2 - 1280, MaxX / 2 + 720), _Random.Next(MaxY / -2 - 1280, MaxY / 2 + 720)),
                new Color(StarColorR / 3, StarColorG / 3, StarColorB / 3, StarColorA / 3)));

        }
    }

    public void Update(GameTime gameTime)
    {

    }

    public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        foreach (Star s in stars)
        {
            spriteBatch.Draw(texture, s.Position, s.Color);
        }
        spriteBatch.End();
    }

}

And the stars class:

class Star
{
    public Vector2 Position;
    public Color Color;
    public Star(Vector2 Position, Color Color)
    {
        this.Position = Position;
        this.Color = Color;
    }
}

As you can see I'm not using the exact same Star class as it is in the original code. First, I'm just trying to achieve the stars to appear on the game screen in random positions.


texts:
I was trying to figure out how perspective projection matrix works, and somehow I ended up in this rabbit hole of depth buffer precision.

It seems to be some interest in a depth buffer where the precision is evenly distributed through the visible space, so people started using 32 bits float depth buffers in range [0, 1], where 0 is the farthest and 1 is the closest, as described in this article.

Some old sources also talk about W-buffer, where the visible space is evenly spread in a 16 or 24 bits integer buffer, but they also say that it is inefficient and lacks hardware support.

But in modern OpenGL and hardware, what prevents me from using a 32 bits integer buffer and write in gl_FragDepth some value that, when divided by W, will yield a linear distribution of the visible space in the integer depth buffer? And, if it works, why it is worse than using float?


texts: How can I resolve collisions a little better?

texts:
I'm currently developing a physics engine and I'm not sure the best way to go about resolving my problem. I have a little box, that I can move around with in my scene.

When I'm resolving collisions, I take in the two bodies that are colliding, determine what both of their normal forces are and apply it to them (I also multiple it by a small number, if I don't I can't continue to walk around the scene).

Anyways, while I'm resolving the collision I do this:

a.Position -= a.Velocity;
b.Position -= b.Velocity;

I know this isn't a very good way to resolve the collision, but I'm just not sure how to do it correctly.

How should I go about resolve collision correctly?

Also, here is the whole method I use to resolve collision at the moment:

    private void ResolveCollision(Body a, Body b)
    {
        // Calculate normals forces (N = M * G)
        Vector2 normalForceA = this.CalculateNormalForce(a);
        Vector2 normalForceB = this.CalculateNormalForce(b);

        // Resolve collision, which is super buggy and obviously a bad idea.
        a.Position -= a.Velocity;
        b.Position -= b.Velocity;

        // Apply normal forces
        a.ApplyForce(-normalForceA * 11);
        b.ApplyForce(-normalForceB * 11);
    }

EDIT:

This is for a 2D game.

EDIT

Here is a video of what's going on when I applied TomTsagk's answer.

The video is here


texts: How to raise funds for game developement

texts:
Creating a game can be a costfull process, if you are working on it full time with around 4 people for 2 years (buidling from scratch) you need about €400.000 for salaries alone.
(An average medior skilled employee will easily cost €50.000 a year)
(I want to work with skilled people that are available 24/7, not hobby programmers etc. that just do it on the side for fun. I need 100% dedication and motivation)

Is using crowdfunding like kickstarter usefull for small game developers?
Can this really get you the required amount of money?

Most projects on (for eaxmple) kickstarter that are started by well known names in the industry collect a lot of money (sometimes over a million).

As a small team being 'unknown' anyone can start a project, but how can you get enough funding? I don't see myself collecting about €400.000 using sites like kickstarter.
Not even with the best idea in the world, because people simply don't know you and will not invest in anything they don't believe can be accomplished.

I would prefer not to need investors since they will have the biggest share in your company and you need to do what your told by them, thus loosing all sorts of freedom in the development process. Also they will need a some sort of guarantee about how you are planning to earn money with the game, which of course you don't know about at the start.

In the Netherlands it is possible to get funds from the government for this sort of stuff, but that's still a really small portion of what is needed.

So my real question is: what is the best way to gather the required amount of money to start game developing full time?


texts: Shader program compiles fine on Ati, fails on other vendors

texts:
Got a real annoying problem here.

My shader program compiles fine on my Ati Radeon HD card, but on Nvidia and Intel it failes to compile.

Vertex shader:

#version 120
attribute vec3 in_position;
 attribute vec3 in_normal;
 attribute vec3 in_texcoord;

 uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projMatrix;

varying vec2 texture_coordinate;
varying vec3 normal;

void main()
{
gl_Position = (projMatrix * viewMatrix * modelMatrix) * vec4(in_position, 1.0);
normal = in_normal;
texture_coordinate = in_texcoord.xy;
}

Fragment shader:

#version 120
varying vec2 texture_coordinate;
varying vec3 normal;

uniform sampler2D gColorMap;

 void main()
 {
   gl_FragData[0] = vec4(texture(gColorMap, texture_coordinate).xyz, 1.0f);
   gl_FragData[1] = vec4(normalize(normal), 1.0f);
}

Any ideas? I checked the shader for errors, but I can't find anything. Thanks.


texts: Is there a name for turn based combat that uses a speed attribute like ATBs but doesn't involve waiting?

texts:
I've seen this in a number of games now - for me, I think the first (and one of the better examples) was Blue Dragon - where characters take turns in an order determined by their speed attribute such that a fast character will not only go first, but also take turns more often than a slow character.  This is much like an ATB (Active Time battle) (with Wait=true) BUT the turns still take place immediately after one another (as opposed to each character having a time-bar that runs down in real time).  And in the example of Blue Dragon, a number of tokens appear in a queue to indicate probable turn order (this would fluctuate if a character used a quicker or slower than normal action).

Is there a name for this turn-based-with-time-simulation-combat in games?

Edit: The closest I've come to a satisfactory term for this is a Combatant Cooldown System (https://tvtropes.org/pmwiki/pmwiki.php/Main/CombatantCooldownSystem) with a Visual Initiative Queue (https://tvtropes.org/pmwiki/pmwiki.php/Main/VisualInitiativeQueue)  I like these but both came from TV Tropes and don't appear to be (commonly) in use elsewhere...


texts: How to deallocate/release/delete of a glTexStorage2D?

texts:
I tried to find this but found nothing.

Does anyone know how to 'deallocate' textures/mipmap from glTexStorage2D once you don't need it anymore?


texts:
I'm doing research to implement a shadow algorithm for omnidirectional soft shadows in a real-time 3D renderer. I've read about PCF but to me it doesn't look very realistic since it doesn't "fade" with the distance to the blocker like PCSS would.

The problem is PCSS uses the penumbra radius to simulate the "fade" effect which omnidirectional lights don't create. Therefore, only lights that do produce a penumbra (like area lights) are natively supported by the algorithm.

So I'll break this question into 2:

Can I still use PCSS on omnidirectional lights by "cheating" and applying a tweaked constant value as the light area parameter?
Is there another algorithm that produces this "fade" effect and does work with omnidirectional lights?


texts: Should components have sub-components in a component-based system like Artemis?

texts:
I am designing a game using Artemis, although this is more of philosophical question about component-based design in general. Let's say I have non-primitive data which applies to a given component (a Component "animal" may have qualities such as "teeth" or "diet").  There are three ways to approach this in data-driven design, as I see it:

1) Generate classes for these qualities using "traditional" OOP. I imagine this has negative implications for performance, as systems then must be made aware of these qualities in order to process them. It also seems counter to the overall philosophy of data-driven design.

2) Include these qualities as sub-components. This seems off, in that we are now confusing the role of components with that of entities. Moreover out of the box Artemis isn't capable of mapping these subcomponents onto their parent components.

3) Add "teeth", "diet", etc. as components to the overall entity alongside "animal". While this feels odd hierarchically, it may simply be a peculiarity of component-based systems.

I suspect 3 is the correct way to think about things, but I was curious about other ideas.


texts:
I have a question regarding the pausing/freezing a game while a window/pausemenu will appear at center of the screen. I've already created a pausescreen class which will be called each time the back key is being pressed.

My problem is that I don't know how to freeze or put the game to pause, this becomes a problem because whenever i tried to click on the outsides of the pause window the player could move around.


texts: How do I make the screen shake when the player takes damage?

texts:
I am making a 2D game and I'd like a visual cue when the player gets hurt. Currently, I have a simple blinking red dot that shows up for 2 seconds after damage, but it's not very immersive.

Many games shake the screen to indicate damage. How could I implement such an effect?


texts: Is the new windows 8 sdk usable with visual c++ express 2010 on windows 7?

texts:
This is inspired by and related to Is the June 2010 DX SDK really the latest? asked recently but it's a different question.

I won't likely be purchasing the full visual studio 2012 for C++, I intend to use the free visual c++ express 2012 that targets desktop applications when it is released so for now I'm using visual c++ express 2010 running on windows 7.

The latest directx11 sdk is the one included in the windows 8 SDK now, it's not a separate release any more.

So my question is, can I use the windows 8 SDK to build directx11 programs that work on windows 7 using visual studio express 2010 running on windows 7. Or do I need to stick to the final DirectX SDK release for now?


texts: How could I expose the engine API for text-adventure games?

texts:
While developing an engine for text-adventures I'm still unsure how to expose the API it provides to the developers/writers. My two concepts for now are:

Running a small JS engine which executes JS script files (in comparison to a full DSL) where devs/writers can access a well-defined subset of functions and classes.
Parsing XML files which define levels, objects, entities, ... so that no real programming knowledge is necessary if the devs/writers stick to the conventions concerning the structure of these files.

Which of these approaches (or even other ones I haven't thought about yet) is more likely to be recommended?


texts: How to make a death screen without making it a new state?

texts:
You must be confused by the question, let me explain. In some games, when you die, it shows a death screen but the background is sometimes transparent and shows the game play. how to do that. here are a few pictures to help out:
And sorry for advertising


texts: Can't use SFML sprite drawing and OpenGL rendering at the same time

texts:
I'm using some SFML built in functions to draw sprites and text as an overlay on top of some OpenGL rending in an SFML RenderWindow. The opengl rendering appears fine until I add the code to draw the sprites or text. The sprite or text drawing causes the OpenGL stuff to disappear.

The follow code show what I'm trying to do

sf::RenderWindow window(sf::VideoMode(viewport.width,viewport.height,32), "SFML Window");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0,viewport.width,0,viewport.height,0,1);

while (window.pollEvent(Event))
    {
    //event handling...

    //begin drawing
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_TRIANGLES);
    glColor3f(col.x,col.y,col.z);
    for(int i=0;i<3;i++)
        glVertex2f(pos.x+verts[i].x,pos.y+verts[i].y);
    glEnd();

    // adding this line causes all the  previous opengl triangles not to appear
    window.draw("Sometext");

    window.display();
}


texts: Is a voxel engine appropriate for a Minecraft-like game?

texts: Why does Minecraft use polygons to draw the world terrain instead of voxels?  Would a voxel based rendering engine be appropriate for a fully destructible game world built out of cubes like Minecraft?  Would it be more efficient than using polygons?


texts:
For my current game I'm working on I've decided to implement a custom model class to store my models in. Reasons being is that I want to make adding new models as painless as possible for the rest of the team without needing to go through the XNA/Monogame content pipeline (Them having VS + Dev framework installed just to compile a few models, or passing them onto me to compile every time a change is made would just get tedious further on, not to mention different timezones when testing slowing things down)

To this end I've been looking at the model structure of different frameworks, XNA/Monogame, SharpDX and AssImp.NET being the main ones. The structure for XNA/MG and SharpDX is Model->MeshCollection->MeshPartCollection, whereas Assimp only has Scene->MeshCollection.

From previous experience in XNA, MeshParts seem kinda redundant. None of my meshes ever had more than one, and a lot of the XNA examples I've seen only ever had one mesh part per mesh.

From everything I've experienced and seen, MeshParts seem redundant, surplus to requirements and just makes for an extra level of complexity (Should I use a loop, or just hardcode it to use the first element in the collection?). Is there some useful aspect of them that I am not aware of, or a particular use case or scenario where they are actually useful?


texts: How Can I Make These Collisions Work Outside Of Unity's Built-In? (C#)

texts:
I'm having some trouble working out what's wrong with my code. Basically I want to have my player be able to collide with obstacles it's flying through.

So I have an obstacle, and a pathway or two for the player to go through, if they don't make it into the pathway and hit the obstacle, they'll die, but if they do make it in, I need the floor and roof of the path to stop my player from going through it.

Here is what I've got so far (sorry for the copious amounts of code, I've tried to compress it down to the bare essentials for you but it's still a lot):

void OnTriggerEnter2D(Collider2D obstacles) {

    if (obstacles.gameObject.tag == "Obstacles") {
        playerInObstacle = true;
    }

    if (obstacles.gameObject.tag == "Path") {
        playerInPath = true;
        path = obstacles;
    }
}

void OnTriggerExit2D(Collider2D obstacles) {

    if (obstacles.gameObject.tag == "Obstacles") {
        playerInObstacle = false;
    }
    if (obstacles.gameObject.tag == "Path") {
        playerInPath = false;
    }
}

void Update() {

    playerY = transform.position.y;

    if (playerY > Y_Max) {
        aboveClouds = true;
    } else {
        aboveClouds = false;
        hasJumped = false;
    }

    if (aboveClouds == false) {

        if (Input.GetKey (KeyCode.UpArrow)) {

            ySpeed += horizontalSpeed * Time.deltaTime;
        }
    }

    //a bunch of other movement stuff is actually in this section, if you need that, let me know and I'll post it.

    if (timer >= jumpTime) {
        hasJumped = true;
        timer = 0;
    }

    if (aboveClouds == false) {
        hasJumped = false;
    }

    if (ySpeed > ySpeedLimit) {
        ySpeed = ySpeedLimit;
    } else if (ySpeed < -ySpeedLimit) {
        ySpeed = -ySpeedLimit;
    }

    transform.position += Vector3.up * ySpeed * Time.deltaTime;

    //floor collisions (this one works)

    if (playerY < Y_Min) {
        floorOn = true;
        ySpeed = noSpeed;
    } else {
        floorOn = false;
    }

    //path & obstacles collisions (this one doesn't work)

    if (playerInObstacle == true) {

        if (playerInPath == true) {

            if (playerY > path.bounds.max.y) {
                ySpeed = noSpeed;
            } else if (playerY < path.bounds.min.y) {
                ySpeed = noSpeed;
            }
        }
    }

    playerY = transform.position.y;

}

Also, I originally tried having the onTriggerEnter2D's as separate entities for both the obstacles tag and the path tag, but apparently you can't do that, so maybe I'm doing this part wrong too..

All help is greatly appreciated, thank you!


texts: Unity3D: Simple animations ending with a bit of offset

texts:
I'm trying to make a simple game with some cubes rotating 90º when the user clicks on them.

I've setup an empty game object, a simple cube nested, an animator, and two animations: RotateClockWise, RotateCounterClockwise.

The idea is: User clicks, the nested cube rotates 90 degrees, then comunicates the new translate component to the wrapper and the wrapper updates its transform (I'm doing this so I can have only two animations). So far, so good.

The thing is that I've noticed that, even though the animation is "90º", once I've clicked enough times, a small offset begins to accumulate and ends up, yeah, rotating 90ºm but starting on 20º, so I got a not aligned cube.

The "dirty" trick I've thought is doing a manual round to the closest quarter on each turn, but that seems something I shouldn't be doing, given how advanced is supossed to be this system.

Any idea of what's going on?

EDIT: This is the math on teh "endAnimation()" function that updates the parent object with the rotation of the child:

        float newX = _rootGameObject.transform.rotation.eulerAngles.x + gameObject.transform.localRotation.eulerAngles.x;
        float newY = _rootGameObject.transform.rotation.eulerAngles.y + gameObject.transform.localRotation.eulerAngles.y;
        float newZ = _rootGameObject.transform.rotation.eulerAngles.z + gameObject.transform.localRotation.eulerAngles.z;
        _rootGameObject.transform.rotation = Quaternion.Euler(new Vector3(newX, newY, newZ));


texts: Double vision with Google Cardboard in Unity

texts:
I am working on a VR app.

I have a terrain and some cube placed in the terrain.Even I have added the Reticle to point at the cube and display some message when the user gaze at the cube.

I have set the distortion to "None".

The problem I am facing here is,when I run the app the cubes and the pointer(reticle) is seeing as double in the scene.What will be the reason for it.Can anybody help me out please.


texts:
I'm developing a little game engine for the Android platform and I'm trying to improve the performance of this one. (I'm not an OpenGL expert)
I can see a framerate drop sometimes, when using DDMS method profiling, I can see that the cause is a longer GLImpl.gldrawelements : the first one right after the eglSwapBuffers.

So my questions are : Do you have an idea why sometimes this call is longer?
It seems that GLImpl.gldrawelements is waiting for something, am I right?

Why the first GLImpl.gldrawelements call (between two eglswapbuffers calls) is longer than the followings?


texts: Can world depth be achieved in a side scroller?

texts:
I tend to build games with strong stories, which usually involves quite an indepth world environment. Typically I develope typical 2.5 over head view JRPG style (think Zelda, Final Fantasy 3, etc) because I have it stuck in my head that you can only achieve world depth using this style.

This question is limited to the 2D environment. Can this be achieved in a 2D side scroller? Can a user experience the world when only seeing it from the side? Can he/she explore villages in this manner? Any examples would be great.

The closest thing that comes to my mind at the moment is Castle Crashers.


texts: How can I create a character design that maintains a fixed rotation body, while allowing the body's "arm" to rotate 180 degrees?

texts:
I am attempting to create a 2d shooter in Farseer Physics on the Xbox360.

I have a player body which has a fixed rotation, as I do not want the body to rotate at all during gameplay. I am now looking to add an arm/weapon to the player's body, which should be able to rotate when the player moves the thumbstick on the controller.

This arm should have the following features:

Does not react to gravity
The position does not change by itself
The only time the angle should change is when the player tells it to do so, and I should be able keep it at a fixed angle when the player decides to stop moving it.

Originally, I thought I could get this done using a fixture. Unfortunately, I don't see a way to rotate a fixture on a body after it has been added.

I assume the correct approach is to create a seperate body for the arm of the player, and attach them using a joint. I cannot for the life of me figure out which joint to use, and which characteristics to apply it. I feel like I have tried all of them, but I'm sure there are just a few variables that I am unfamiliar with that are giving me unwanted results.


texts: Is it more efficient to encode rotation in a spritesheet or rotate at runtime?

texts:
I'm developing a game with JavaScript and HTML5 and I'm wondering about the performance implications of sprite rotations. There are two ways that I know to rotate a sprite:

Rotate the actual sprite based on its rotational speed and velocity, as it travels along it's trajectory.
Pre-compute the rotations and store them as frames within the sprite sheet to give the illusion that it's spinning when it isn't.

On one hand, I can see how rotating some sprites in a spritesheet would be efficient because it's one image that is loaded, split into frames, and re-used.  But on the other hand, I'm not sure the calculations involved for rotating the sprite based on its velocity and rotational speed are really anything for current browsers (on computers and mobile devices) to worry about.

In my game, the canvas area is 800 x 600, and the game is using 32 x 32 sprites for everything. The "map" isn't tile-based. Of the two options above, which would be more efficient for runtime performance?


texts:
I'm unsure as to what people prefer when it comes to HUDs, and scaling them. What would you say is the best practice when it comes to sizing the HUD? I'm thinking there's really two options: Scale up, or use the same area (in pixels) to display it on a higher resolution.

The problems I see with each are with scaling, I may have a huge blurry mess in the corner, but if I don't, it could be hard to see from a distance. Any guidance?


texts: Unity - can i make children of a moving platform also work as moving platforms?

texts:
I have a moving platform that is a kinematic body, moving by a script, which is working as expected.

I tried to parent it to another kinematic body, and make the child also function as a moving platform (the script only moves the parent), but it seems that the friction is ignored for the child object, and the carried object slips behind it and falls down when the child platform moves. The child platform is the same physical material as the parent.

Is there any way i can make the child's friction work too, while having the script only move the parent?

This is important, because in my real application the child moves and rotates inside a couple nested levels of transformations (basically the fork
teeth of a fork truck).

here is a simple abstraction of my question:

https://youtu.be/U854IcS96-Y

Thanks!


texts: How and when to split draw calls in OpenGL and OpenGL ES

texts:
My application (with a modernish OpenGL >= 3.0 and an OpenGL ES 2.0 backend) renders more or less streaming data with up to millions of vertices with different vertex layouts and sizes (some simple, some quite big). Some data is indexed, some is not. I'm currently hitting the problem of draw calls and buffers (index and/or vertex) becoming too large, so I need to split them. I have a hard time understanding when and how I should correctly split draw calls. My questions:

The limits GL_MAX_ELEMENTS_VERTICES and GL_MAX_ELEMENTS_INDICES, according to the docs, tell the application the maximum value for well-performing glDrawRangeElements calls. Why is this ONLY for glDrawRangeElements, why not glDrawRangeElementsBaseVertex or even glDrawElements?! This does not make sense to me, because glDrawRangeElements is more or less glDrawElements after all. Also I've see a couple of OpenGL implementations reliably crash when rendering indices above that limit, even with glDrawElements. On the other hand some stackoverflow answers say that the limits are not relevant anymore... What else should I use to decide how to split my draw calls then?
What about glDrawArrays? Is there an upper limit (e.g. GL_MAX_ELEMENTS_VERTICES)?
For the OpenGL ES 2.0 backend I require the extension "GL_OES_element_index_uint" to use indices above the 65k limit. What limits should I choose there for draw call size?
I have decided to limit my IBO and VBO sizes to a certain limit (max. 64MB), as there's no way to ask OpenGL about what buffer size I can allocate, else than checking for GL_OUT_OF_MEMORY. That means I have to additionally split according to that buffer size (both IBO and VBO). Is there a better way to check buffer limits?
What should be the preferred way to split draw calls? Make them small in the application already, then batch them when rendering? This will lead to lots of duplicate vertices in some case, which is not ideal.
Splitting them in the render code can be complicated, because index data has to be analyzed, indices changed or memory copied, but in the end it is the only place where you can be sure all limits are respected...

I'd prefer reliable, stable solutions even if they provide lower performance. I'm targeting OpenGL Desktop hardware newer than ~2010 and Angle as a conversion layer from OpenGL ES 2.0 -> Direct3D in case of Remote Desktop connections.


texts:
I am working on a graphics project I want to make a city using opengl with c++ anyway in the last few days I have been trying to load a texture but it didn't work with me in any way I have tried many codes and tried to follow some tutorials but it didn't went ok

here is my load texture function:

int LoadTexture(char *filename,int alpha)
{
    int i, j=0; //Index variables
    FILE *l_file; //File pointer
    unsigned char *l_texture; //The pointer to the memory zone in which we will load the texture

    // windows.h gives us these types to work with the Bitmap files
    BITMAPFILEHEADER fileheader;
    BITMAPINFOHEADER infoheader;
    RGBTRIPLE rgb;

    num_texture++; // The counter of the current texture is increased

    if( (l_file = fopen(filename, "rb"))==NULL) return (-1); // Open the file for reading

    fread(&fileheader, sizeof(fileheader), 1, l_file); // Read the fileheader

    fseek(l_file, sizeof(fileheader), SEEK_SET); // Jump the fileheader
    fread(&infoheader, sizeof(infoheader), 1, l_file); // and read the infoheader

    // Now we need to allocate the memory for our image (width * height * color deep)
    l_texture = (byte *) malloc(infoheader.biWidth * infoheader.biHeight * 4);
    // And fill it with zeros
    memset(l_texture, 0, infoheader.biWidth * infoheader.biHeight * 4);

    // At this point we can read every pixel of the image
    for (i=0; i < infoheader.biWidth*infoheader.biHeight; i++)
    {
            // We load an RGB value from the file
            fread(&rgb, sizeof(rgb), 1, l_file);

            // And store it
            l_texture[j+0] = rgb.rgbtRed; // Red component
            l_texture[j+1] = rgb.rgbtGreen; // Green component
            l_texture[j+2] = rgb.rgbtBlue; // Blue component
            l_texture[j+3] = alpha; // Alpha value
            j += 4; // Go to the next position
    }

    fclose(l_file); // Closes the file stream

    glBindTexture(GL_TEXTURE_2D, num_texture); // Bind the ID texture specified by the 2nd parameter

    // The next commands sets the texture parameters
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // If the u,v coordinates overflow the range 0,1 the image is repeated
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // The magnification function ("linear" produces better results)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //The minifying function

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECR );

    // Finally we define the 2d texture
    glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);

    // And create 2d mipmaps for the minifying function
    gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);

    free(l_texture); // Free the memory we used to load the texture

    return (num_texture); // Returns the current texture OpenGL ID
}

I call the function in init section

textureID = LoadTexture("Building.bmp",255);

and in the display section I wrote :

glBindTexture(GL_TEXTURE_2D,textureID);
    glBegin(GL_QUADS);
            //front
            glTexCoord2f(1,0) ;         glVertex3f(1,-1,0);
            glTexCoord2f(1,1) ;         glVertex3f(1,1,0);
            glTexCoord2f(0,1) ;         glVertex3f(-1,1,0);
            glTexCoord2f(0,0) ;         glVertex3f(-1,-1,0);
    glEnd();


texts: When should I be implementing XML documents

texts:
I often struggle with the question of when to use XML docs. Does anyone have a good rule of thumb when it comes to deciding to use them or deciding not to use them.

At the moment I am working on a project that has a lot of name, attributes, textures and even maps that are randomly selected when an object is created. Should I be harnessing XML here?

Thanks for your time!


texts: Voronoi graph - traversing from vertex to vertex

texts:
I'm working on a Unity Project in C#

I've built a 3D Voronoi Diagram using the csDelaunay library from PouletFrit
and using the X and Y values from a 2D diagram to instead setup some Vector3's with something like (x,0,y)

Example:

My current task is to build a river, as a List of Vector3's

I've so far been able to figure out most of the library code, and  build/retrieve lists of:

The north-most Vertices, South-most, East and West
All Edges, and for each their left vertex (green) and right end vertex (red)
All Sites / Seeds

To start the river I've picked one vertex at random from the North-most list and then pick a suitable opposing vertex on the south list.

I've been at this for many hours now, getting nowhere really, but I think my main problem is I can't focus. So I'm going to avoid splines, meshes, etc. for now and keep this simple, I just want to get a list of points the river will go through.

as advised by 'Arcane Engineer' on a previous question (too broad), I'll just use the Voronoi cell boundaries for this, but I need to find the shortest or best path between my north river point and my south point.

I've been assuming that either Dijkstra's Algorithm or A* are the best way to do this but I'm really struggling now, and A* seems to be more built for open space and determining the route around obstacles, rather than shortest path through fixed nodes ?

as Dijkstra's would need a graph data structure (among other things), would I be correct in saying that The Voronoi class in the library I'm using is already a type of graph data structure ? or would I need to augment it a bit to perform Dijksta's algorithm

My background is mainly in Java, and I hope I have a decent understanding of all the OOP principles I need here, and I have some data structure knowledge, at least at a high level. but if possible i'd like to use pre-written stuff. I found a Priority Queue class from Microsoft that may help me in implementing Dijkstra's ?

I tried working on a "simpler" recursive algorithm that checks from the first point (north-most), what edges are connected, and then what direction vector they are going in and compares the angles for each edge vs the target direction, and the smallest angle wins. I haven't got it working yet.
But I also get the feeling this is NOT the best way to do this.

Any advice you could give is much appreciated!


texts: SDL2 C++ Program Behaves Badly if FullScreen Mode

texts:
I'm making an app with SDL2.
I've gotten everything to work so far, including SDL_TTF. When I run my program in a normal window, everything works great!

However, now I'm trying to add fullscreen functionality... and I've run into the problem. On fullscreen mode ONLY, the program APPEARS to look fine at first, however, one of my functions (A text rendering function) causes problems. On fullscreen, this function momentarily removes or "flickers" the image behind it, revealing the previous image underneath. Why would this function cause an error on fullscreen vs. regular window sizing? I assume it's some kind of strange sizing issue...

void drawDialog(const char* content) {
//Draws a dialog box with set text
TTF_Font* font = TTF_OpenFont("assets/times.ttf", 30);
SDL_Color textColor = { 255, 255, 255 };
SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
SDL_Texture* dialogTex;
SDL_Rect destRect;

destRect.x = 50;
destRect.y = 730;

destRect.w = 300;
destRect.h = 30;

dialogTex = SDL_CreateTextureFromSurface(renderer, message);
SDL_FreeSurface(message);
SDL_RenderCopy(renderer, dialogTex, NULL, &destRect);
SDL_RenderPresent(renderer);

}

Any help would be super! Thanks!


texts: How can I solve niche collision cases between circles and insides/outsides of AABBs or arcs?

texts:
I am trying to create a game with some interesting geometry. Literally all the geometry that is involved are the circles that move large distances per frame, and the edge of an iPhone X display, which I am going to approximate using the following shapes:

It is worth noting that instead of the inside quarter eclipse one could do another "outside of AABB" and another "inside of quarter-circle"

Here's the problem: These collision detections are very niche and I can't find anyone doing them anywhere. In fact I can't even find the algorithm to collide these fast moving circles with the outside of an AABB let alone the inside of one. And no formulas for circle collisions allow for a quarter circle collision to be calculated. Everything needs to be hyper efficient so I think using Bézier curves/complex shapes is really not an option.

How do I develop or find the algorithms to do these types of collisions?

Have I perhaps overthought everything? Would Bézier or some other spline curve be easier here? I suppose I made a bit of an assumption that that would be expensive to calculate. But maybe is that the answer?

Keep in mind whatever I do needs to work for over 1 thousand entities to collide with this shape in real time.


texts: setting a time delay between two frame when animation a sprite sheet

texts:
this is my jsfiddle :http://jsfiddle.net/Z7a5h/

As you can see the animation of the sprite sheet when the player is not moving is too fast so i was trying to make it slow by declaring two variable lastRenderTime: 0,RenderRate: 50000

but my code is not working and it seem i have a misunderstanding of the algorithm i am using so can anyone lay me a hand to how can i fix it ?

 if (!this.IsWaiting) {
                    this.IsWaiting = true;
                    this.Pos = 1 + (this.Pos + 1) % 3;

                }
                else {
                    var now = Date.now();
                    if (now - this.lastRenderTime < this.RenderRate) this.IsWaiting = false;
                    this.lastRenderTime = now;

                }


texts: how to make sure a developer is working effectively?

texts: Let's say I hire some developer or an artist for a project, and that I pay him hourly. How am I supposed to know how many hours he worked for the content he provides to me ?


texts: What tools/software are used to make the environments/levels/maps in games?

texts:
This question has probably been answered before but I've not been able to find the answer, since I'm not able to frame the question with brevity.

So the whole question is :- The worlds/levels that you see in games like Crysis, Assassin's Creed, etc, what do the designers and developers use to create them? Do they use the tools present inside the engine (whether proprietary or in-house) or a separate software that exports these worlds as an importable object for the game engine to use to load models into it, etc?

I know this is a very general question but I have been curious regarding this for some time. I have used Unity in the past and it had a terrain toolkit that could be used to make the terrain, and I'm pretty sure it had completely to do with my lack of skill but I wasn't even close to making an environment that looked like the ones you see these days.


texts: Touch taps only on very short flicks on Win7 with Monogame

texts:
I have an application on win7 which needs to support touch and mouse input using monogame. But reading touch taps proves to be a very hard thing.

The TouchPanel is initialized like this:

TouchPanel.EnableMouseTouchPoint = true;
TouchPanel.EnabledGestures = GestureType.Tap | GestureType.DoubleTap | GestureType.Hold | GestureType.Pinch |
                             GestureType.FreeDrag | GestureType.DragComplete | GestureType.Flick | GestureType.HorizontalDrag |
                             GestureType.VerticalDrag;
TouchPanel.EnableMouseGestures = true;

Without EnableMouseTouchPoint and EnableMouseGestures there is no reaction from the touchscreen. Enabling both will at least get me touch locations and gestures on drag moves (this already makes me think that there is something essential missing here).

I have the following code to read input which is called on every Update:

private void GetInput(GameTime gameTime)
    {
        var gesture = default(GestureSample);
        MouseState mouseState = Mouse.GetState();

        TouchCollection touchCol = TouchPanel.GetState();
        foreach (var touch in touchCol)
        {
            Console.WriteLine(touch.Position);
        }

        while (TouchPanel.IsGestureAvailable)
        {
            gesture = TouchPanel.ReadGesture();
            Console.WriteLine(gesture.GestureType);
            if (gesture.GestureType == GestureType.Tap)
            {
                DoHitTest(mouseState.X, mouseState.Y);
            }
        }
     }

The touch collection will remain empty until the finger is dragged across the screen. Taps are not showing up. To get an actual tap i have to do a very short flick. In this case, there is a touch in the touch collection.

What am i missing? Am i doing something fundamentally wrong here?


texts: Unity3D: Lightmap bleeding in standalone build

texts:
I'm running into an issue about some lightmap glitches made of black seams lines occuring only in the standalone build of our game, and it does only affect certain scenes.
below is attached a screenshot of both editor and .exe build of the same scene.

I'm also attaching below the current Lighting settings for that current scene, but before, our second UV Channel is not generated inside Unity3D but authored in 3DSMAX :

Now, even if the generated lightmaps are 4096, their texture inspector shows a max size of 2048 and no compression (tried a build with a max size of 4k with no change), i also discovered that Mip Maps are enabled by default (might be the problem ?).

Above all, my build settings are Windows standalone x86, although the game is VR Only wouldn't be better to make it x86_64 only and would it solve this issue ?

Current Unity Version and infos:
 - Unity 5.6.0f3
 - Oculus Utilities 1.14
 - Build settings for windows: Auto graphics API - Static/Dynamic Batching - GPU Skinning - VR supported (Oculus + OpenVR) - MultiPass Stereo Rendering - Optimize Mesh Data enabled.

Mesh import infos:

Mesh compression off - Read/Write enabled - Optimize Mesh Enabled - Normals: Import

i would also state that we had a previous gearVR build (with 2048 resolution lightmaps) and this issue was never encountered

Thank you.


texts: Smoothness & performance issues of new game

texts:
I've written the basics of a new game which just includes a game loop that can update and render basic game objects so far.

I want to ensure that what I've written so far is as good as it can be and provides me with the best & most flexible foundation to build a game on top of. Really don't want to discover something fundamental later which causes a massive re-write.

Even though the game is running at a very decent frame rate the game objects are not moving entirely smoothly. I'm seeing stuttering and what looks like skipped frames, especially when the game objects bounce off the walls.

I'm not sure if this is a problem with my game loop or how I'm updating the game objects, or something else?!

If I increase the number of game objects from 5 to 100 the performance does not seem to change so I don't think it's a processing issue.

The project is only small at the moment - https://github.com/arrwhidev/java2d


texts: Updating an XML Document to Match New Save Data?

texts:
The Problem

I'm developing a game and using the XmlSerializer to store some user data.

While it isn't an immediate problem, I'm trying to conceptualize what would happen if I needed to update Save Data to a newer version of my game. Since the XmlSerializer reads as a Type, if I update my class with more variables, the save file becomes unreadable.

After doing some research, I discovered the XmlDocument class, which is able to read XML files as that type. This allows the data stored to be arbitrary, allowing me to read and write data accordingly.

What's confusing me is how exactly I would go about this. Is there an easy way to populate an XmlDocument with the Nodes/Elements of a custom class? And how can I detect when data is missing and needs to be added to the XML file?

Example

If you were confused by the question, here's a simple example of what I would like to accomplish:

<FileData version="Original File">
  <foo>14</foo>
</FileData>

Several versions later, I update my class to look like this:

class FileData {
    var foo = 14;
    var bar = 4;
}

Now I need the XML file to look like this before I can use XmlSerializer:

<FileData version="Updated File">
  <foo>14</foo>
  <bar>4</bar>
</FileData>


texts: how to check if an array element is defined? (Game-maker studio)

texts:
The code is this:

if is_undefined(A_SA[V_X,V_Y])=false and A_SA[V_X,V_Y]=0
{
//actions from the "if" statement
}

The error message is this:

Push :: Execution Error - Variable Index [0,10] out of range [10,10] - -1.A_SA(100006,10)
 at gml_Object_objt_Canvas_StepNormalEvent_2 (line 25) -         if is_undefined(A_SA[V_X,V_Y])=false and A_SA[V_X,V_Y]=0

Why is this happening and how can I stop game-maker from trying to check the value of a variable outside of an array?


texts: Is allowing the server to remotely execute code on a client a security risk?

texts:
My game uses scripts that can be edited by the player and I'm trying to figure out how to handle multi-player, while still allowing custom scripts. What I am thinking about doing is having the server send it's scripts' source code over to the clients and have the clients execute that. So if a client joins a modded server, the client can use those mods, and this prevents the client from easily cheating by editing scripts.

What can I do to prevent the scripts from being abused? Or is this just an all-around bad idea?


texts:
So I made a scaling system for different resolutions, and I got very weird results.

I have an old "scaling" system where you can choose which scaleSize you want (for testing with the old 800 x 450 resolution) and you can choose between 1 and 2. I made a new scaling system after this that makes a scale with a matrix.

(old scaling system with scaleSize is just for making the textures/collision boxes bigger/smaller, not resolution dependent)

int currentWidth;
int currentHeight;
int preferredWidth;
int preferredHeight;
float scaleWidth;
float scaleHeight;

public Matrix scale;
GameWindow Window;
ContentManager Content;
GraphicsDeviceManager Graphics;
GraphicsDevice GraphicsDevice;

public ScreenSize(GraphicsDevice graphicsDevice, GraphicsDeviceManager graphics, ContentManager content, GameWindow window)
{
    Window = window;
    Content = content;
    Graphics = graphics;
    GraphicsDevice = graphicsDevice;
    LoadContent();
}

public void LoadContent()
{
    Graphics.PreferredBackBufferWidth = 1920;
    Graphics.PreferredBackBufferHeight = 1080;

    currentWidth = GraphicsDevice.Viewport.Width;
    currentHeight = GraphicsDevice.Viewport.Height;

    preferredWidth = 800;
    preferredHeight = 450;

    scaleWidth = currentWidth / preferredWidth;
    scaleHeight = currentHeight / preferredHeight;

    scale = Matrix.CreateScale(scaleWidth, scaleHeight, 1.0f);

    this.Graphics.IsFullScreen = false;

    Graphics.ApplyChanges();
}

I add the scale to my spriteBatch.Begin() and the textures are scaled. It works fine when the scaleSize is 2 but not when the scaleSize is 1.

The ScaleSize scales the collision box and the textures (not with the resolution, but just when you need (for example) a texture that's 2x bigger, then you use the scaleSize of 2. See an example below.

public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch, Color color, float scaleSize)
{
    spriteBatch.Draw(textureImage, position, new Rectangle(
    (currentFrame.X * frameSize.X),
    (currentFrame.Y * frameSize.Y),
    frameSize.X, frameSize.Y),
    color, 0, Vector2.Zero, scaleSize, SpriteEffects.None, depth);
}

But the problem is that, when I use the scaleSize of 1, then the pixels in-game are not the same size (for resolutions that are not the default resolution (800 x 450)). But they are when scaleSize is 2. In my first code block I use the resolution 1920 x 1080. When the scaleSize is 2, then it looks good. When the scaleSize is 1, then it looks bad (in fullscreen it looks good for some reason).

example: (left is good, right is wrong)

I ask this question because I want the textures in-game smaller. (scaleSize = 1)

EDIT: scaleSize 2 doesn't look good on some resolutions (like 1440 x 900). Do I need another preferredWidth and preferredHeight?

example:

summary: Everything looks/works fine with scaleSize 2, but doesn't with 1.
-> edit: scaling doesn't work well.


texts: Blender Object Appearing Gray when all Lights are Off

texts:
I have an issue with Blender where, when I turn my only light off (a sun lamp) and render the image my object appears gray rather than black (and thus, not appear to the camera).  I can't figure out why this is happening.

Here's what I just did in my scene:

Added a new UV Sphere mesh (to make a total of two spheres), made it visible to the camera, turned off the sun lamp (by setting energy to 0), and rendered.  The result I obtained is below.

I discovered this when attempting to render the first sphere with a material/texture on it and it was too bright.  The material on the spheres (which are different) are very basic, there's no emit, diffuse and specular are at default values.  Could there be an issue with the way my camera is setup?  Thanks in advance!


texts:
I'm trying to make a Grid who will be easily convertible between 2D and 3D and I'm having a problem with overlapping prefabs in the case of the 3D generation.

The thing is, the DataObjects (Tiles) actualy have inside them the prefab of the thing who must be in that tile, but the prefab is bigger than the Tile.

As you can see in the image, i have 3 Tiles selected, Each Tile have a prefab and all of them have the same kind of prefab, they are in the scene highlighted by the orange borders right now in the image.

Then you could imagine than, if the prefabs are equal between the 3 of them they should all have th same size, and that's exactly the case (i.e. in fact they have the same size) but the thing is they are overlaping each other, have that in consideration when looking at the image.

So the question will be...

How to make sure two Tiles not overlap each other?

Based on a suggestion on working not with scale but pixels with units, I don't exactly how to do that, but searching on google make me try this, which actually doesn't work:

tile.tile_GO.GetComponent<Renderer>().bounds.size = thisPrefab.GetComponent<Renderer>().bounds.size;

It doesn't work because "bounds" is read only.

Do you know a work around to solve this? Is there another way to achieve what I'm looking for?

The idea is stop the overlapping, if you know a way to make one next to the other one, or even leave a gap between them in runtime, it will be also consider a valid answer.

Thanks in advance.

PS: I'm using Unity 2017.1.0f3, scripting in C#.


texts: How can I make the player "look" to the mouse direction? (Pygame / 2D)

texts:
Here's my code:

import sys
import pygame
pygame.init()

screen_width = 640
screen_height = 480
screen = pygame.display.set_mode((screen_width, screen_height))
running = True

class Actor:

    def __init__(self, x, y, w, h):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.surface = pygame.image.load("GFX/player.png")
        self.rotated_surface = self.surface.copy()
        self.rect = self.surface.get_rect()

class Player(Actor):

    def __init__(self):
        Actor.__init__(self, 0, 0, 32, 32)
        self.directions = [False, False, False, False]
        self.speed = 0.1

    def rotate(self, angle):
        rot_image = pygame.transform.rotozoom(self.surface, angle, 1)
        rot_rect = self.rect.copy()
        rot_rect.center = rot_image.get_rect().center
        self.rotated_surface = rot_image

    def move(self):
        if self.directions[0]:
            self.y -= self.speed
        if self.directions[1]:
            self.y += self.speed
        if self.directions[2]:
            self.x -= self.speed
        if self.directions[3]:
            self.x += self.speed

    def draw(self):
        screen.blit(self.rotated_surface, (self.x, self.y))

player = Player()

def redraw():
    screen.fill((75, 0, 0))
    player.draw()
    player.move()
    pygame.display.flip()

while (running):
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            sys.exit()
        elif e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE:
                sys.exit()
            if e.key == pygame.K_w:
                player.directions[0] = True
            if e.key == pygame.K_s:
                player.directions[1] = True
            if e.key == pygame.K_a:
                player.directions[2] = True
            if e.key == pygame.K_d:
                player.directions[3] = True
        elif e.type == pygame.KEYUP:
            if e.key == pygame.K_w:
                player.directions[0] = False
            if e.key == pygame.K_s:
                player.directions[1] = False
            if e.key == pygame.K_a:
                player.directions[2] = False
            if e.key == pygame.K_d:
                player.directions[3] = False
        elif e.type == pygame.MOUSEMOTION:
            mouse_x = pygame.mouse.get_pos()[0]
            mouse_y = pygame.mouse.get_pos()[1]
            angle = math.atan2(mouse_y - player.y, mouse_x - player.x)
            angle = angle * (180 / math.pi)
            player.rotate(angle)

    redraw()

Here's the image:

The blue arrow represents the "weapon" / "eyes" of the shooter, and the green arrow represents the mouse cursor. How can I use the transform module to rotate the image "in the direction" of the mouse cursor?


texts: JME3 Transparent Image Shows Geometries Behind

texts:
I'm using jME3 (JMonkeyEngine). I’m setting a geometry (a box with a bullet hole material/texture) to show transparency using

material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
geometry.setQueueBucket(Bucket.Transparent);
geometry.setMaterial(material);

I guess it works, but this happens:

Basically, instead of the transparent part of the image (bullet hole) showing iron man’s (first model) red armor, it shows the ninja’s green clothing, which is in the same position but behind the iron man model. This happens even when the geometry is in front (between the camera and the both models) of the models, so idk what’s happening. Any help is appreciated!


texts:
I'm currently working on a dynamic 'door' creator, and I'm trying to decide which is more efficient. Not much experience with 3D render speeds, so I'm asking before I choose which direction to go because its a lot of work either way. (The doors will be able to open/close.)

So I came up with two possibilities.

I generate all the triangles (as in the left picture), and go on my way.
I generate only two triangles, then create and save a whole new texture that is filled only  with pixels that are not 'covered' by the door (the others are marked as transparent). I would then dynamically add the texture to a texture atlas. Then when the outside portion (gray) of the door is drawn, it would appear as in the right picture.

Hence, more vertices, or more textures? Before I start down one road, any advice on this? Or any other suggestions?

Thoughts: Creating a new texture for each instance would eventually take up too much memory, but they would be reusable. My gut says this would be better for a small game world with not many unique doors, so maybe I should just implement both and let the user decide.


texts:
I'm trying to do bump mapping, and I'm getting fairly close at achieving my goal.  I miss one crucial piece of my puzzle to have bump mapped effect in my scene; I need to transform the normals from my bump map to match the direction my faces are pointing.

This is my scene rendered with my vertex normals:

This is my scene rendered with the bump map:

The last image is wrong, because all samples from the bump map are rendered relative to as if they are pointing upforwards from the ground.  What I need to do, is transform the samples from the bump map to be relative to the face normals.

Now, I have tried researching how to achieve this for a while - I've been told that if I create a TNB matrix, and multiply the sample with it - things should behave like I want.  This is however not the behaviour I am getting.

This is my vertex shader:

uniform mat4 u_projectionMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_modelMatrix;
attribute vec3 a_position;
attribute vec2 aTextureCoord;
attribute vec3 aNormalCoord;
attribute vec3 aTangentCoord;
attribute vec3 aBitangentCoord;
varying vec2 vTextureCoord;
varying vec3 vNormalCoord;
varying vec3 vVertexCoord;
varying mat3 vTNBMatrix;

void main()
{
    vec4 pos = vec4(a_position, 1.0);
    vTNBMatrix = mat3(
        aTangentCoord,
        aNormalCoord,
        aBitangentCoord
      );

    gl_Position = u_projectionMatrix * u_viewMatrix * pos;
    vTextureCoord = aTextureCoord;
    vNormalCoord = aNormalCoord;
    vVertexCoord = a_position;
}

And this is my fragment shader:

varying vec2 vTextureCoord;
varying vec3 vNormalCoord;
varying vec3 vVertexCoord;
varying mat3 vTNBMatrix;

uniform sampler2D mytex;
uniform sampler2D mynormal;

void main()
{
    vec3 nt = normalize(texture2D(mynormal, vTextureCoord.st).rgb * 2.0 - 1.0);

    vec3 lightpos = vec3(15.0, 26.5, 0.5);
    vec3 L = normalize(lightpos - vVertexCoord);

    vec3 finalNormal = nt * vTNBMatrix;

    vec3 ld = vec3(1.0, 1.0, 1.0) * max(dot(finalNormal, L), 0.0);

    ld = clamp(ld, 0.0, 1.0);

    gl_FragColor = vec4(texture2D(mytex, vTextureCoord.st).rgb * ld, 1.0);
}

Which are giving me the following, undesireable result:

Would anyone be so kind and give me some pointers at what I'm doing wrong?

Update:

These are the textures I'm using for this

Normal map:

Texture:


texts: How to create heat haze effect in Libgdx?

texts:
I would like to create a heat haze effect for a 2D game I am making.

Do You have ideas or suggestions, how to get that effect. I am using Libgdx(OpenGL 2.0).

Thank You in advance!


texts: Handling early/late/dropped packets for interpolation in a 3D multiplayer game

texts:
I'm working on a multiplayer game that for the purposes of this question, is most similar to Team Fortress.

Each network data packet will contain the 3D position of the target moving object. (this object could be another player) The packets are sent on a fixed interval, and linear interpolation will be used to smooth the transition between packets. Under normal circumstances, interpolation will occur between the second-to-last packet, and the last packet received.

The linear interpolation algorithm is the same as this post:

Interpolating positions in a multiplayer game

I have the same issue as in that post, but the answers don't seem like they will work in my situation. Consider the following scenario:

Normal packet timing, everything is okay
The next expected packet is late. That's okay, we'll just extrapolate based on previous positions
The late packet eventually arrives with corrections to our extrapolation. Now what do we do with its information?

The answers on the above post suggest we should just interpolate to this new packet's position, but that would not work at all. If we have already extrapolated past that point in time, moving back would cause rubber-banding.

The issue is similar in the case of an early or dropped packet.

So I believe what I am looking for is some way to smoothly deal with new information in an ongoing interpolation/extrapolation process.

Since I might be moving on to quadratic or even cubic interpolation, it would be great if the same solutiuon could be applied to those as well.


texts: How does one organize AI interactions with Local and Remote Players?

texts:
Scenario: In a first-person multiplayer game, an AI monster grabs a player. (This would be first-person player on the client's local machine, and a third-person remote player on the master and other client machines)

I'm trying to weigh the merits of different implementations of how these interactions could be organised.

In this scenario, I can think of a couple different ways of implementing but I'm not sure what assumptions they might make which could result in a problem down the line:

The Monster could, in its grab function, have a test IsFirstPerson and then perform the FirstPerson specific or ThirdPerson specific grab mechanics, or
The Monster could talk to an IGrabbable interface on the Player (remote or local), which would return whether it is FirstPerson or ThirdPerson and then perform the specific grab mechanics, or
The Monster could talk to an IGrabbable interface on the Player (remote or local), which would return/dictate the full details of how the Monster should grab.

(And for clarity - differences in implementation of FirstPerson or ThirdPerson would be where the hands are or headlook - in first person it would look directly into the camera, but in third person it'd look at where the eyes are; differing struggle animations, etc)


texts: How should I set up UDK with Git and CruiseControl?

texts:
For a new project in UDK, I'd like to set up a Git repository for version control and a CruiseControl.NET-based continuous integration solution. The good news is that he first part seems easy enough and CruiseControl.NET can work off Git repositories. The bad news is that according to my searches, nobody has ever tried to do this.

Ideally, I'm looking for a step-by-step guide on how to set up such a development environment assuming more than one development computer, one central repository for the "master" branch, and one machine for building and packaging the binaries via CruiseControl.NET.

Related:

Version control system for game development with UDK?
Options for UDK and version control repositories?
CruiseControl.NET and Git


texts:
I'm trying to learn how to develop games in Unity and my base is tiled games, I would like to know if a simple tile is an image (sprite in 2D) or a game object in 3D.

Since I'm trying to do some kind of 3D tiles with interaction with the user like press to do something + an animation, I would like to know how it works.


texts:
Under Windows 8, what is the alternative to this code:

technique11 Light0Tex
{
    pass P0
    {
        ...

technique11 Light1Tex
{
    pass P0
    {
        ...

And:

Light1Tech    = mFX->GetTechniqueByName("Light1");

...

Light1Tech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);


texts: How to reproduce this triangle filling scanline effect using a shader?

texts:
I'm writing a renderer for an old DOS game in which 3D polygons were rendered in software. I'd like to simulate, using a shader, the following material/effect, used for filling a triangle:

The fist pixel of each scanline starts with a given color (here purple) and progressively fades to another color (amber). It's like each scanline is a gradient

In a shader, is it possible to have a value between 0 and 1 which tell the position of the pixel regarding the scanline bounds? (start and end, which are S0 and S1 in the example)


texts: How can I create a resizeable 2D camera with parallax scrolling?

texts:
I want to create a Windows Phone jump-and-run game with parallax scrolling. The character should always be in centered in the viewport.

I use the following camera so that the viewport looks on every resolution the same:

Vector2 vp, gameWorldSize = new Vector2(800, 480);
vp = new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
ScaleX = vp.X / gameWorldSize.X;
ScaleY = vp.Y / gameWorldSize.Y;
Scale = Math.Min(ScaleX, ScaleY);
Vector2 PlayerPosition;
Vector2 Viewport;
float Scale;

public Matrix GetMatrix(float scrollingspeed)
{
  return Matrix.CreateTranslation(new Vector3(-PlayerPosition.X, -PlayerPosition.Y, 0) * scrollingspeed)
   * Matrix.CreateScale(Scale, Scale, 1)
   * Matrix.CreateTranslation(Viewport.X / 2, Viewport.Y / 2, 0);
}

I draw the sprites like this:

spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.GetMatrix(0.8f));
  BackgroundLayer1.Render(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.GetMatrix(1.0f));
  Player.Render(spriteBatch);
spriteBatch.End();

//in the Player class:
batch.Draw(Playertex, new Rectangle(400, 240, Playertex.Width, Playertex.Height), null, Color.White, 0, new Vector2(Playertex.Width / 2, Playertex.Height / 2), SpriteEffects.None, 0f);
//in the BackgroundLayer1 class:
batch.Draw(Background1tex, new Rectangle(400, 240, Background1tex.Width, Background1tex.Height), null, Color.White, 0, new Vector2(Background1tex.Width / 2, Background1tex.Height / 2), SpriteEffects.None, 1.0f);

The camera is working fine and the player is always in the center of the viewport, but I don't know how to implement Parallax Scrolling. What is the best way to implement Parallax Scrolling?

How can I create a resizeable 2D viewport that follows the player and supports parallax scrolling?

UPDATE1:
In addition, the background sprites shouldn't repeat in a loop, because I have ten 800x480 pixel sprites that are drawn one after another. For example, the first sprite is drawn at (0,0), the second at (800,0), the third at (1600,0), …
The last sprite(number 10) is the end of the level. The player can move back but not further. I will create more than one layer of sprites, but every layer with a different speed factor to create the Parallax Scrolling.

How can I add the speed factor so that the background sprites move slower than the player sprite?

UPDATE2:
If I draw "BackgroundLayer1" with a scrolling speed of 1.0f, the sprite is drawn on the correct position, but if I change the scrolling speed to another value(for example 0.8f), then the sprites of "BackgroundLayer1" aren't drawn on the correct position.

Why are the sprites of "BackgroundLayer1" not drawn on the same position if I change the scrolling speed? What is wrong? The sprites should be drawn on the same positions, even if I change the scrolling speed.

In these two pictures, you see the differences if I change the scrolling speed of BackgroundLayer1:

scrollingspeed = 1.0f

http://s1.directupload.net/images/140505/qdi6cqwz.jpg

scrollingspeed = 0.8f

http://s1.directupload.net/images/140505/56ferzuv.jpg


texts: The type or namespace name `OpenCVForUnity' could not be found

texts:
I am working on face traching in unity3D

I have downloaded and imported the sample project on "FaceTracker Sample using OpenCV for Unity".

But when I tried to runned the project,its showing me the error.Below is the screen shot of the error

What will be the issue?can anybody help out please?

I am using unity(5.0.0f4(64 bit))


texts:
times came when i had to implement some culling into my engine. I started by reading some stuff and so far so good. I managed to create an octree which can effectivly divide my geometry's vertices (per mesh)  into an octree. But here i have some Questions:

Currently i am using immediate mode to test if the culling works. And it does work, i am recursivly traversing the tree's nodes and testing against the node's bounding box if the frustum intersects with it. Repeat untill leaf is found and render that leaf's geometry (with immediate mode for testing) But now i would like to use VBO/VAO's to render the geometry in the leaves and here i see two options:
- 1.Each time the i traverse the tree push the leaves that intersect with the frustrum into a list then get the vertices out of them and construct a VBO and send it to be rendered.
- 2.Pre build a VBO for each leaf then just rebind for each visible leaf and render.

Anyway, which is the better option rebuilding a new vbo each time the frustum changes, or just rebinding multiple vbos (which is also expensive).
Also is this even the right approach , maybe i am missing something.

bool view_Culling(CFrustum& frusrum, COctree *node)
{
if (!node)
    return false;

if (frusrum.CubeInFrustum(node->GetCenter().x, node->GetCenter().y, node-       >GetCenter().z,(node->GetWidth()/2.0f)))
{
    if (node->IsSubDivided())
    {
        view_Culling(frusrum, node->OctreeNodes()[TOP_LEFT_FRONT]);
        view_Culling(frusrum, node->OctreeNodes()[TOP_LEFT_BACK]);
        view_Culling(frusrum, node->OctreeNodes()[TOP_RIGHT_BACK]);
        view_Culling(frusrum, node->OctreeNodes()[TOP_RIGHT_FRONT]);
        view_Culling(frusrum, node->OctreeNodes()[BOTTOM_LEFT_FRONT]);
        view_Culling(frusrum, node->OctreeNodes()[BOTTOM_LEFT_BACK]);
        view_Culling(frusrum, node->OctreeNodes()[BOTTOM_RIGHT_BACK]);
        view_Culling(frusrum, node->OctreeNodes()[BOTTOM_RIGHT_FRONT]);
    }
    else
    {
        //use prebuilded vbo here
        //or push these vertices here in a list later build a dynamic vbo
        //from them
        node->DrawOctree(node);
        return true;
    }
}
return false;
}


texts: How can I get what key was pressed in Unity?

texts:
Description
I'm working on a chat that will immediately record input when any (compatible) key is pressed, so I need to record the keys pressed and turn them into a string.
Attempted Solutions
1) Listen to every key-press with a script and push it inside a Text component
I like this one most, because the chat is simple enough that I'm better off with a custom Input Field component, and I get all the control I need.
However, I don't know how to get what key was pressed in a frame, short of checking for every single one (and the shift modifier, too). This is inefficient both for me, the developer, and the computer.
2) Automatically focus an Input Field when any key is pressed
Unity has a handy Input.anyKey boolean field that's true whenever any key is pressed, but I need to save that first key press and insert it manually into the Input Field or else it will be lost, as the Input Field only listens for key-presses once it's in focus.
That means I need a way to record key presses, and then we're back to solution #1.


texts: Is it possible to use Windows Forms in an XNA project?

texts:
Is it possible to keep a Windows Form inside a XNA project? I tried it but without success.

Below I'm showing how my main file is.

using System;

namespace JogoSuecaOnline
{
#if WINDOWS || XBOX
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            MainMenu menu = new MainMenu();
            menu.Show();
        }
    }
#endif
}


texts:
I have a game with two scenes, menu and maingame. I have uploaded the game to googleplay. However when I open the game and click on the play button in the menu scene, the next scene (maingame) takes about 4-5 seconds to load. Is there any way to load the maingame along with the menu so that there is no delay in loading?
EDIT
I have added code to the MainMenu.cs file so that when the game starts the LoadSceneAsync function is called and allowSceneActivation is set to false. Once the "play" button is pressed, the activation is set to true. The first time the game loads, there is still a bit of delay however if the player dies and I go the main menu and press play again, there is no delay.
AsyncOperation async;

void Start()
{
    async = SceneManager.LoadSceneAsync(1);
    async.allowSceneActivation = false;
}

public void PlayBtnPressed()
{
   async.allowSceneActivation = true;
   AudioManager.audiomanager.Play("PlayButton");
}


texts: Class design for instantly switching between free-roaming world to/from battle world?

texts: I plan to have an isometric world, which can be freely roam around. However, I desire the system to instantly apply the grid onto isometric world for battling system on any random encounter. Therefore, from what I expect, I should have a class of character that can generally switch between free-roaming and battle system. However, because I am still new to game programming, I do not know how should I approach this. If I make my character class such that I could abruptly derived it into either Free-roaming or Battle system, it may sound convenient, but I will have to implement this feature for all other class too (enemy, object, etc.). If I use Interface, then I won't have flexibility to add extra function to certain special class of object (maybe boss?). Or should I have a set of hierarchy of interface to tackle this problem? If so, it would be too complicated. Therefore, any suggestion?


texts: How to deal with differences between 2D screen coordinates and Cartesian coordinates

texts:
Most 2D screen/bitmap coordinate systems have the positive Y axis pointing down (with the the origin in the upper left corner).
This is counter to how most people think geometrically with the positive Y axis pointing up (with the origin in the center).

How do most games manage the two different 2D coordinate systems? There are two main types of coordinates (screen vs. Cartesian), but there could be many different coordinate spaces: sprite space, world space, view space, screen space, etc...

Background:

I originally made the world coordinates in my game match the 2D screen coordinate convention. This made it very natural to use the graphics drawing routines, but subtle issues arose when using trigonometric functions like atan2(). The results of feeding atan2() 2D screen coordinates are very confusing because atan2() assumes the positive y axis points up.

So I changed my world coordinates to follow the classic Cartesian coordinate system (with the origin at the bottom left of the screen). Reasoning with atan2() is much more straight-forward, but now it is harder to do other types of reasoning:

If I click the screen here, what sprite is underneath?
Where did I click on that sprite?
If a sprite is drawn in the wrong location, what was calculated incorrectly? The screen coordinates or the world coordinates?

I realize conversion from screen to Cartesian coordinates involves simply scaling the y value by -1 with an optional translation of both (x,y) values. I'm more interested in best practices for game design:

Do most games just stick with the screen coordinate convention and change their thinking about how things like atan2() should work?
When/how are coordinate system conversions done? (Using matrices, OOP abstraction, etc)
Are sprite locations stored as the center of the sprite or one of the corners? The sprite's height/width going in the "wrong" direction seems to be a common problem when I draw them.

Although my question is mainly about 2D games, it seems OpenGL uses a coordinate system where the Y axis points up. OpenGL must eventually project those 3D coordinates onto a 2D screen coordinate system. Perhaps some guidance could be found in OpenGL's method...


texts: relationship between the model and the renderer

texts:
I tried to build a simple graphics engine, and faced with this problems:

i have a list of models that i need to draw, and object (renderer) that implements IRenderer interface with method DrawObject(Object* obj). Implementation of renderer depends on using graphics library (opengl/directx).

1st question: model should not know nothing about renderer implementation, but in this case where can i hold (cache) information that depends on renderer implementation? For example, if model have this definition:

class Model
{
public:
    Model();

    Vertex* GetVertices() const;

private:
    Vertex* m_vertices;
};

what is the best way to cache, for example, vertex buffer of this model for dx11? Hold it in renderer object?

2nd question: what is the best way for model to say renderer HOW it must be rendered (for example with texture, bump mapping, or may be just in one color). I thought it can be done with flags, like this:

model->SetRenderOptions(RENDER_TEXTURE | RENDER_BUMPMAPPING | RENDER_LIGHTING);

and in Renderer::DrawModel method check for each flag.

But looks like it will become uncomfortable with the options count growth...


texts: Loading Textures in Background Cocos2d Objective C loading CCScene

texts:
I am allocating a few CCScene subclasses, but when I do this, it takes more than 10 seconds. What I am trying to achieve is to perform a small CCAmimation, such as a loading logo glowing. My question is: how do I load those CCScene subclasses in the background and perform this animation.

I am able to perform these things separately, but I want to do them together.


texts: What is the most efficient way to render a 2D scene objects?

texts:
What is the most efficient way to render scene objects according to the current position of the camera (which will follow the player position)?

A friend told me that since processors are powerful these days, it is okay to set up everything virtually and then just update the surface according to what is inside the camera position, after a loop inside the sprites filtering only what should be rendered by the GPU.

But seems to me that this is taking more processing power from the CPU. Why process objects that aren’t visible by the player? What if I need to target mobile devices? What if I want to make my game available in a raspberry pi or very old computers?


texts: Implementing a camera / viewport to a 2D game

texts:
What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this:

<map>
   <tile obj="ground" x="0" y="555" />
   <tile obj="ground" x="16" y="555" />
   <tile obj="ground" x="32" y="555" />
   ...
</map>

All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

In the picture:

Camera is either 800x600 or 640x480
Blocks and sprites are 16x16 pixels.
World size may vary
The coordinates probably should be normalized relative to the world, not to the screen?
Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this video).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.


texts:
The Havok games SDK is cross platform and supports android according to this link http://www.havok.com/solutions/mobile-game-developers

I want to explore the sdk but don't know from where to begin, didn't find any resources on how to use Havok with Android.

can anybody provide me with links,books, resources on how to start.

thanks


texts: LibGDX - ShapeRenderer as principal game entity renderer

texts:
I am trying to make a 2D game that is just a bunch of default figures like circles, arcs and quadrilaterals with no textures (similar to Super Hexagon), and for that I was using C# and XNA long time ago, but recently I move my code to Java and LibGDX mostly using the ShapeRenderer library.

The problem appears when, reading in internet, I found that render this figures is a more computational cost task than just draw a texture or sprite. But by the nature of this project I just can't use sprites or similar, mostly because I will drastically scale this entities in the game, and when I scale an image the result is just not nice, blurry and/or pixelated.

What I asking for is if is a bad idea to render pure shapes for a game (no images, except maybe the background and text)? is ShapeRenderer a good approach? Do I should try with another way to manage this "not-affected-by-scale"-entities?

I have read some answer from here (like this or this) but they are focused on sprites, not just pure shapes.

For now, I got acceptable results and the game run smootly even when I create a lot of shapes, but in the future I plan to use effects and so, and I don't know if render shapes is the best answer or if this will affect the performance of my game (the game is focus for PC platform). I'm not limited only to Java, and if exist another language/framework that manage this with better result, I'm opened to learn it.

Thanks!.


texts: Interpolation using a sprite's previous frame and current frame

texts:
Overview

I'm currently using a method which has been pointed out to me is extrapolation rather than interolation.  As a result, I'm also now looking into the possibility of using another method which is based on a sprite's position at it's last (rendered) frame and it's current one.

Assuming an interpolation value of 0.5 this is, (visually), how I understand it should affect my sprite's position....

This is how I'm obtaining an inerpolation value:

public void onDrawFrame(GL10 gl) {
   // Set/re-set loop back to 0 to start counting again
   loops=0;

   while(System.currentTimeMillis() > nextGameTick && loops < maxFrameskip) {
       SceneManager.getInstance().getCurrentScene().updateLogic();
       nextGameTick += skipTicks;
       timeCorrection += (1000d / ticksPerSecond) % 1;
       nextGameTick += timeCorrection;
       timeCorrection %= 1;
       loops++;
       tics++;
   }

   interpolation = (float)(System.currentTimeMillis() + skipTicks - nextGameTick) / (float)skipTicks;
   render(interpolation);
}

I am then applying it like so (in my rendering call):

render(float interpolation) {
    spriteScreenX = (spriteScreenX - spritePreviousX) * interpolation + spritePreviousX;
    spritePreviousX = spriteScreenX; // update and store this for next time
 }

Results

This unfortunately does nothing to smooth the movement of my sprite.  It's pretty much the same as without the interpolation code.  I can't get my head around how this is supposed to work and I honestly can't find any decent resources which explain this in any detail.

My understanding of extrapolation is that when we arrive at the rendering call, we calculate the time between the last update call and the render call, and then adjust the sprite's position to reflect this time (moving the sprite forward) - And yet, this (Interpolation) is moving the sprite back, so how can this produce smooth results?

Any advise on this would be very much appreciated.

Edit

I've implemented the code from OriginalDaemon's answer like so:

@Override
public void onDrawFrame(GL10 gl) {

    newTime = System.currentTimeMillis()*0.001;
    frameTime = newTime - currentTime;
        if ( frameTime > (dt*25))
            frameTime = (dt*25);
    currentTime = newTime;

        accumulator += frameTime;

        while ( accumulator >= dt )
        {
            SceneManager.getInstance().getCurrentScene().updateLogic();
            previousState = currentState;
                    t += dt;
            accumulator -= dt;

        }

        interpolation = (float) (accumulator / dt);

        render();
}

Interpolation values are now being produced between 0 and 1 as expected (similar to how they were in my original loop) - however, the results are the same as my original loop (my original loop allowed frames to skip if they took too long to draw which I think this loop is also doing).

I appear to have made a mistake in my previous logging, it is logging as I would expect it to (interpolated position does appear to be inbetween the previous and current positions) - however, the sprites are most definitely choppy when the render() skipping happens.

Edit

I was saving my object's old position during rendering when it should have been saved during logic updating like so:

 render(float interpolation) {
    drawSpriteAtX = (spriteScreenX - spritePreviousX) * interpolation + spritePreviousX;
    drawSprite(drawSpriteAtX , spriteScreenY);
 }

updateLogic(){

     spritePreviousX = spriteScreenX; // update and store this for next time
     moveSprite();

}


texts: c++ RPG - Handling buffs / equipment stats

texts:
I'm trying to develop a character calculator for a RPG, and it could evolve into a turn based combat / text based RPG. One of my concerns is how to handle the equipment stats / buff system.

Currently each of my buffs / equipment object and my character object itself has a member bonusstats, which is a struct containing a (potentially) very large amount of possible modifiers (attributes, misc_skills, protections, secondary_stats, etc and their multiplier versions).

struct BonusStats {
    int attribute[8], misc_skill[30], protection[9], HP, MP, ... ;
    //define constructor, operator+=, reset function
}

And everytime an actualize call is requested every stat is recomputed:

Character::Actualize() {
    this->bonusstats.reset();
    for /*iterate through vector of buffs and equipped items*/ {
        this->bonusstats += item->getBonusStats();
    }
}

While this is a rather simple approach I am concerned about two things mainly:

1.- Is it performance-wise acceptable? I get the feeling that having to sum two structs containing 100 elements just to add a buff is not a very good practice. Would there be any practical advantage in using a function like Character::ApplyStats( std::function<void(BonusStats*)> itemstats) instead?

2.- How could I implement more complex buffs than stat modifiers? For example, reflecting x% damage when blocking a melee attack. The thing that comes to my mind is to create complex stats like percent_damage_reflected_on_melee_block and check its value everytime conditions are met. Is it a good approach?


texts:
I'm making a first person shooter, and I've seen questions like this before, but the answer is either overly complicated or they're using SDL, GLFW, GLUT, or something else. I'm not using any of that. OpenGL, C++, and GLEW for me.

I am just a little confused on how to do a framerate counter, so if I could get pseudo-code or some code-snippets that would point me in the right direction, that would help.


texts: My collision detection is not working when I rotate my mesh in three.js

texts:
I am trying to move a ball mesh through a maze. The maze belongs to a parent object3d. My issue is that when I move the ball I can't detect collision right well because in the rotation, the axis relative to the ball are changing and for some reason I can't control the collisions with the wall. Here is my code:

//This function detects collisions
function collisionControl() {
  var colision = false;

  //Checking collisions with the ball
  var originPoint = bola.position.clone();

  //I get the position of the ball relative to the maze(=puzzle)
  var globalPositionPoint = originPoint.applyMatrix4(puzzle.matrix);

  for (var vertexIndex = 0; vertexIndex < bola.geometry.vertices.length; vertexIndex++) {
    var localVertex = bola.geometry.vertices[vertexIndex].clone();
    var globalVertex = localVertex.applyMatrix4(bola.matrix);
    var directionVector = globalVertex.sub(bola.position);

    var ray = new THREE.Raycaster(globalPositionPoint, directionVector.clone().normalize());
    var collisionResults = ray.intersectObjects(collidableMeshList);

    if (collisionResults.length > 0 && collisionResults[0].distance < directionVector.length()) {
      if (collisionResults[0].object.name == "fin") {
        location.reload();
      }

      // Si encontramos una colision, la bola vuelve a su lugar origen
      colision = true;
      break;
    }
  }

  return colision;
}

The function RotacionEje

// Function to rotate the ball
function RotacionEje(object, axis, radians) {
  var rotWorldMatrix = new THREE.Matrix4();
  rotWorldMatrix.makeRotationAxis(axis.normalize(), radians);
  rotWorldMatrix.multiply(object.matrix);
  object.matrix = rotWorldMatrix;
  object.rotation.setFromRotationMatrix(object.matrix);
}

So when I press the Up arrow for example it executes, the following function:

function moveUp() {
  bola.position.z -= 0.5;
  RotacionEje(bola, ejeX, -0.1);
  camera.translateY(0.5);
  if (collisionControl()) {
    bola.position.set(47.5, 0, 50);
    camera.position.x = 47.5;
    camera.position.y = 0;
    camera.position.z = 100;
    camera.lookAt(bola.position);
  }
}

I have to say that collisions works fine if I don't use the function RotacionEje.

What am I doing wrong?


texts: Why doesn't MoveBy work in this example?

texts:
I'd like to run an action on a sprite using the MoveBy action. After lots of attempts, I can't achieve the goal... I have issues with the MoveBy in 2 different projects, so maybe I'm missing something in the setup... But I can't figure what!

The instruction is like this:

this.platform1Sprite.runAction(cc.MoveBy.create(1, cc.p(200, 0)));

I don't get any error, simply it doesn't work. platform1Sprite is a Sprite. But even with a LabelTTF it doesn't work:

var MoveToAction = cc.MoveTo.create(2.5, cc.p(size.width / 2, size.height / 2));
this.creditLabel.runAction(MoveToAction);

For this last snippet, you can view my complete code here: http://pastebin.com/fGbW4LLH.

The code I linked is somehow similar to the helloHTML5World official example, line 112 has the runAction method applied to a LabelTTF. The official example works, mine doesn't... I can't understand what's the difference!


texts:
I've made it so that all entities have complex box colliders for hit detection purposes. These entities also have character controllers on them. The problem? Gravity, or lack thereof. When the character controller is of a certain size, gravity doesn't work. However, if you set it to a bigger size, one way too big to be usable, suddenly gravity works as expected.

I'm looking for one of two things: either a way to make character controllers work, or a way to replace character controllers and everything that they're dictating (movement, as well as gravity.)  I've looked into using Rigidbodies, but the character falls to the ground (woo) and flops about on the floor on its back (not such a woo moment.)

I'm open to using Rigidbodies if that's the only alternative, but if you could point me to a good guide on how exactly to use them for players, I would appreciate it.