texts: Minimum hardware requirements for developing for iOS and Android with Unity, Cocos2d-x and GameSalad on a Mac

texts:
I intend to create iOS and Android games. My main priority is to create 2D games. The software that I’m planing to use are Unity, Cocos2d-x and GameSalad.

I am a bit interest in the Mac Mini, because it is cheap compared to other Apple machines. What are the minimum hardware requirements for an Apple machine?


texts:
I'm building a game in Unity using Wwise as the audio engine. I'm on a Mac and whenever I build the game, there is no audio. Apparently this is because the sound banks are not in the correct folder. They should be in Assets/StreamingAssets/Audio/GeneratedSoundBanks/ followed by a sub-folder with the name of whatever platform you are using. I should have a Mac folder located here however there isn't one. Instead my sound banks just sit in the GeneratedSoundBanks folder which works when i test the game in unity, however there is no audio when I build the game. Apparently this has something to do with environment variables or a python path but I have no idea how to fix or edit these as I am new to coding as well as Wwise and Unity. If I build the game for web player I get an error CS0246: The type of namespace name 'AKRESULT'  could not be found. Web GL says it doesn't work for the unity wise integration package I have either (and going to an older one just messed my whole projects audio up completely). If anyone could give me any help at all, it would be very much appreciated. Thank You.

I'm using: Unity 5.3.5.1f, Wwise v2016.1 (32-bit), WwiseUnityIntergration_v2016.1_Mac.unitypackage.


texts: OpenGLES 2.0 batching method and do not draw inactive object

texts:
I am researching about "batching" objects for one big VBO and reduce draw call.

These are what I am doing now:

Create interleaved VBO based on texture or render state (like Blending)

So, for example, there will be two separate VBO and draw call if I want only some object has blending

For more batching, add unused vertex data.

eg) Object "A" doesn't need to have color data, but I added white empty color, so can be batched in interleaved array

For hiding object, set vertex positions to 0.0. So, stay on the array, but cannot see.

eg) if it is quad, set to [0.0, 0.0, 0.0, 0.0]

These are my questions:

Should I create one Giant VBO, and use draw call based on offset??

If I do that, then is there any limitation on glbufferData?? (or performance drop, if too much data in)
Is there any method that vbo can contain different types of interleaved vertex?
Is multiple "offset" draw call not affect performance unlike single draw call?

Should I bind multiple texture atlas to each unit, and use uniform?

Currently, I am only binding one texture per draw.

Is there correct way for above #3 method?? (Feels like not correct)
I am updating "All" vertices every frame, even though some object doesn't need to be updated. (glBufferData) Should I do multiple update call??

Sorry for my wording, but please point me anything that I am doing something wrong.

Thank you.


texts:
I tried to use the FBX SDK (2011.3.1) to load FBX files and save them as Collada files in order to be able to import FBX files in Panda3D.
Unfortunately the resulting Collada files are not usable for several reasons, among them:

There's a Maya specific extra technique

diffuse

<diffuse>
    <texture texture="Map__2-image" texcoord="CHANNEL0">
        <extra>
            <technique profile="MAYA">
                <wrapU sid="wrapU0">TRUE</wrapU>
                <wrapV sid="wrapV0">TRUE</wrapV>
                <blend_mode>ADD</blend_mode>
            </technique>
        </extra>
    </texture>
</diffuse>

It assigns a texcoord channel name that isn't referenced anywhere else in the file (in the previous code sample, no geometry uses "CHANNEL0"...)
Every polygon is exported twice, a first time with a basic material (only diffuse color, specular color, etc.) and a second time with a textured material --> this doubles the number of polygons of each model without any valuable reason

Anyway, the resulting Collada file cannot be opened correctly either with OpenCOLLADA or Panda3D's "dae2egg".

Anyone has any experience on how to "fix" it and make it understandable by common and well-reputed Collada importers such as OpenCOLLADA?


texts: Why I am I told "Color0 is missing" when I run the following code?

texts:
In the code below, I want to draw a box on my screen. But when I run it, there is an error message:

  The current vertex declaration does not include all the elements
  required by the current vertex shader. Color0 is missing.

Here is the code in question:

    private SpriteBatch _sb;
    private Vector3 _position;

    public Vector3 Position
    {
        get { return _position; }
    }
    private Matrix _world;

    public Matrix World
    {
        get { return _world; }
    }
    private Texture2D _image;
    private VertexPositionColor[] _vertices;
    private short[] _indices;
    private Game _game;
    private IndexBuffer _ib;
    private VertexBuffer _vb;
    private BasicEffect _basicEffect;
    private BoundingBox _boundingBox;

    public BoundingBox BoundingBox
    {
        get { return _boundingBox; }
    }

    public Blackhole(Game game, Vector3 position, Matrix view, Matrix projection)
    {
        _game = game;

        _vertices = new VertexPositionColor[4];
        _vertices[0] = new VertexPositionColor(new Vector3(-100, 100, 0), Color.Red);
        _vertices[1] = new VertexPositionColor(new Vector3(100, 100, 0), Color.Green);
        _vertices[2] = new VertexPositionColor(new Vector3(100, -100, 0), Color.Blue);
        _vertices[3] = new VertexPositionColor(new Vector3(-100, -100, 0), Color.Yellow);

        _indices = new short[6];
        _indices[0] = 0; _indices[1] = 1; _indices[2] = 2;
        _indices[3] = 0; _indices[4] = 2; _indices[5] = 3;

        _vb = new VertexBuffer(game.GraphicsDevice, VertexPositionColor.VertexDeclaration, 4, BufferUsage.WriteOnly);
        _vb.SetData<VertexPositionColor>(_vertices);

        _ib = new IndexBuffer(game.GraphicsDevice, typeof(short), 6, BufferUsage.WriteOnly);
        _ib.SetData<short>(_indices);

        game.GraphicsDevice.SetVertexBuffer(_vb);
        game.GraphicsDevice.Indices = _ib;

        _basicEffect = new BasicEffect(game.GraphicsDevice);
        _basicEffect.View = view;
        _basicEffect.Projection = projection;
        _basicEffect.World = _world;
        _basicEffect.VertexColorEnabled = true;
        _basicEffect.TextureEnabled = false;

        RasterizerState newState = new RasterizerState();
        newState.CullMode = CullMode.None;
        game.GraphicsDevice.RasterizerState = newState;
        _boundingBox = new BoundingBox(new Vector3(_position.X, _position.Y, -1), new Vector3(-_position.X, -_position.Y, 1));
    }

    public void Update(GameTime gt)
    {
        _world = Matrix.Identity * Matrix.CreateTranslation(_position);
    }

    public void Draw(Matrix view, Matrix projection)
    {
        _basicEffect.View = view;
        _basicEffect.Projection = projection;

        foreach (EffectPass f in _basicEffect.CurrentTechnique.Passes)
        {
            f.Apply();

            _game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
        }
    }

What is the cause of my error?


texts: SFML image extension for best performance

texts:
I am using SFML library in my 2D game.

The Texture Class has a method to load an image from file:

Texture.loadFromFile("image.*")

Which file extension should I use to achieve best performance?


texts: Algorithm to shoot at a target in a 3d game

texts:
For those of you remembering Descent Freespace it had a nice feature to help you aim at the enemy when shooting non-homing missiles or lasers: it showed a crosshair in front of the ship you chased telling you where to shoot in order to hit the moving target.

I tried using the answer from https://stackoverflow.com/questions/4107403/ai-algorithm-to-shoot-at-a-target-in-a-2d-game?lq=1 but it's for 2D so I tried adapting it.

I first decomposed the calculation to solve the intersection point for XoZ plane and saved the x and z coordinates and then solving the intersection point for XoY plane and adding the y coordinate to a final xyz that I then transformed to clipspace and put a texture at those coordinates. But of course it doesn't work as it should or else I wouldn't have posted the question.

From what I notice the after finding x in XoZ plane and the in XoY the x is not the same so something must be wrong.

    float a = ENG_Math.sqr(targetVelocity.x) + ENG_Math.sqr(targetVelocity.y) -
            ENG_Math.sqr(projectileSpeed);
    float b = 2.0f * (targetVelocity.x * targetPos.x +
            targetVelocity.y * targetPos.y);
    float c = ENG_Math.sqr(targetPos.x) + ENG_Math.sqr(targetPos.y);
    ENG_Math.solveQuadraticEquation(a, b, c, collisionTime);

First time targetVelocity.y is actually targetVelocity.z (the same for targetPos) and the second time it's actually targetVelocity.y.

The final position after XoZ is

    crossPosition.set(minTime * finalEntityVelocity.x + finalTargetPos4D.x, 0.0f,
                minTime * finalEntityVelocity.z + finalTargetPos4D.z);

and after XoY

    crossPosition.y = minTime * finalEntityVelocity.y + finalTargetPos4D.y;

Is my approach of separating into 2 planes and calculating any good? Or for 3D there is a whole different approach?

sqr() is square not sqrt - avoiding a confusion.


texts: How to play a movie on top of a webcam texture

texts: I've been through the Unity docs, searched here, and on stackoverflow; I have not found any good information about using the WebCamTexture for my purposes. So here goes, how do I play a movie asset such as an mp4 clip so that it appears to be on top of the captured webcam image? Lets assume the movie is semi-transparent.


texts: How to make footsteps sound sync with animation (FMOD/Wwise/similar)

texts:
How do you pros out there implement footstep sounds in so that they're synced with character animation?

I have an idea in mind: an FMOD event that has two footstep playback triggers, and a parameter that controls how fast each plays back in sequence, and the event is triggered as soon as the animation is on a frame (assuming the programmer handling animation will post an event or update a param for this) where you could reasonably assume the character's foot has hit the ground.

Is this overkill, or assuming too much accuracy out of an engine?

This is not a specific project, but I am working on integrating FMOD Designer support into an existing engine and am thinking of some general effects to implement while the audio spec is being figured out. Also, I mention FMOD since that's what we're using, but if anyone's done similar syncing tasks in Wwise, XACT or anything else (or heck, even if you hand-coded it) and could share their experiences that'd be great to hear as well.


texts: How does Apple use App Store image banners?

texts:
I am about to publish my very first iOS game and was reading the Apple iTunes Connect guide (pages 237 till page 240). I understand that they require a PSD file of dimension 3200x600 pixels. I also understand that this image will be cropped in order to fit the desktop, iPad and iPhone store aras, along with a "minimal view" version.

How, what I don't understand is:

Do they ever scale the image? I've never seen a high resolution banner in the iPhone Editor's choice images. The iPhone specs are about 640x960 or 640x1136 pixels and the width of the iPhone image area in the guide seems much higher, so that's why I assume the rescale it.
How do they obtain the "Extreme Skater" 150px300px image on the left, below? Is that simply the title rescaled on a portion of the background? There is no mention of how they do this in the guide.

I imagine that the one on the right is the one obtained from the iPhone area of the editor's choice banner creation guideline, but haven't found any specs on how to obtain the other image.

How does the Apple measuraments relate to the view I can see here (it is taken from an iPod touch 4th generation with retina display and measured using the rectangle selection on the Mac OS X Preview tool)


texts: How I get the value from different class

texts:
i get error , i cant get the value from different class..

public class First1 : MonoBehaviour {
    private List<IFirstListener> listeners = new List<IFirstListener>();
    public int watt;
    void OnTriggerEnter2D(Collider2D theCollider)
    {
        try {
            CharacterA characterA = theCollider.GetComponent<CharacterA>();
            this.watt += characterA.watt;
            for (int i = 0; i < listeners.Count; i++) {
                listeners[i].OnBaterryPluggedIn(this, characterA, characterA.watt);
            }
        }
        catch { /*On error do nothing*/ }
    }

    void OnTriggerExit2D(Collider2D theCollider) {
        try {
            CharacterA characterA = theCollider.GetComponent<CharacterA>();
            this.watt -= characterA.watt;
            if (characterA != null) {
                for (int i = 0; i < listeners.Count; i++) {
                }
                    listeners[i].OnBaterryPluggedOut(this, characterA, characterA.watt);
            }
        }
        catch { /*On error do nothing*/ }
    }

i want to get the value var watt and assign to tott.. (tott = watt)

public class Second2 : MonoBehaviour {
    private List<ISecondListener> listeners = new List<ISecondListener>();
    public int tott;

    public void cek (){
        tott = watt; /* <--- how i can get the value from var watt at class First() to var tott?? */
    }


texts: Do I need real socket connections to create AI Bot players in a multiplayer web game?

texts:
I have built a realtime multiplayer web game using WebSocket protocol.

In my game I create about 100 AI bot players to simulate playing the game with the real players. Every time a bot is dead the server will create a new one. I wonder if I need to simulate the Websocket connection and implement Websocket listeners like what I am doing at the moment.

I understand that creating new Websocket connections will use a lot of resources and maintaining the connections eat up resources on the server too. As I don't need to send anything to bot players I probably don't need to create real connections on the server.

The game is working fine. But I am looking for ways to improve. Let me know what you think.


texts:
I am making an iphone shmup and am trying to decide what type of game loop to use. I want to use either semi-fixed timestep or fully-fixed timestep.

With semi-fixed timestep I will make zero or more update(FIXED_INTERVAL) calls followed by one update(dt) call where dt <= FIXED_INTERVAL per game loop. As I understand it the drawbacks with this method are that my physics update(dt) logic is going to be more difficult to program because I basically have to assume a variable dt for every update. And then I've also heard that each run of my game will be slightly different due to floating point values not being the same every time.

Then with fully-fixed timestep I am making zero or more update(FIXED_INTERVAL) calls followed by one interpolation(dt/FIXED_INTERVAL) call where dt < FIXED_INTERVAL per game loop.

So it seems like the big decision I really have to make is: do I want to tackle the challenge of implementing an update(dt) with a variable dt or do I want to tackle the challenge of implementing interpolation?

Now from what I've read the majority of people are saying to use fully-fixed and do the interpolation. But when I think about implementing interpolation it seems like I'd be a lot more complex than an update(dt) with variable dt. This is because if I use interpolation I have to remember both the previous state and the current state. So if I want to use interpolation I have to come up with an additional layer of indirection that abstracts out entire individual game states. Whereas with semi-fixed timestep where I don't have to use interpolation I don't have to come up with a game state abstraction because there's always only one game state and it's simply the "global arrays" that represent my enemies, and enemy bullets etc.

So what's the more practical choice: do I implement it semi-fixed knowing that my physics updates could get complicated with the variable dt. Or do I use fully-fixed and try to come up with a game state abstraction so that I can keep track of previous state and current state in order to perform interpolation?


texts: Strategies to Defeat Memory Editors for Cheating - Desktop Games

texts:
I'm assuming we're talking about desktop games -- something the player downloads and runs on their local computer. Many are the memory editors that allow you to detect and freeze values, like your player's health.

How do you prevent cheating via memory-modifiation? What strategies are effective to combat this kind of cheating?

For reference, I know that players can:
- Search for something by value or range
- Search for something that changed value
- Set memory values
- Freeze memory values

I'm looking for some good ones. Two I use that are mediocre are:

Displaying values as a percentage instead of the number (eg. 46/50 = 92% health)
A low-level class that holds values in an array and moves them with each change. (For example, instead of an int, I have a class that's an array of ints, and whenever the value changes, I use a different, randomly-chosen array item to hold the value)

The game is offline, free and single-player.

Edit: for posterity, I solved this (in C#) and posted my solution here, on my blog.


texts:
I'm currently working on an HTML5 top-down simple RPG game, and as a learning experience I'm building my own little engine from scratch. After reading around a little I decided to go with the Entity Component System pattern because I like the flexibility and reusability it brings.

I have a few questions I hope you could help me with:

First, there seems to be some disagreement as to what an ECS actually is - some articles have it that components are just containers for data and subsystems handling all the logic, and other articles have it that components contain methods in them and communicate via some sort of shared memory or messaging system. What's the most widely accepted model of an ECS?

Secondly, I've been wondering about in-game events. I'll explain:

So I started developing an engine that follows the "components are only data containers" rule, and subsystems operate only on the entities that match their requirements (for example, subsystem A takes all entities that have "physics" and "render" components, and subsystem B takes all entities that have "physics" and "health" components).

I'd like the game to be easily scriptable, so that in the yet-to-exist level editor, I could link a particular item (e.g. vase) to another (e.g. mob spawner) and create some sort of correlation (e.g. when vase is broken the spawner spits out a monster). With that in mind, I added the following to my Entity class (which, until now, was just a container for components):

Event Trigger - has a "name" field, "predicate" field, and a "data" field. There would be a special subsystem that goes through all entities that have event triggers, check the predicate, and send the event, along with its data if the predicate evaluates to true, to anyone who's listening.
Event Listener - has a "name" field and a "callback" field. If the
entity receives an event it is listening to, it will invoke the event
listener's callback (which will be able to do something like changing
the "spawner" component to be ready to spawn a monster the next time
the appropriate subsystem looks at it).

This pretty much solves the problem I described above (vase + spawner, also allows for scripting events with relative ease). I don't like, however, that there are two ways to "change" components (subsystems and/or events). I usually like that there's only one way to do things, and that one way should be the best way. What do you guys think?

Now, the next problem deals with a different type of event. Say I have a player swinging his sword at a monster; when the "physics" subsystem recognizes that the sword collided with the monster, it should notify the "health" subsystem and the "sound" subsystem of the event, so that health could be decreased for the monster and so that a hit sound could be played.

So the obvious, brute force solution would be to have subsystems sending events to all other subsystems (which is what some ECS articles suggested). The physics system would send an event "entity-A collided with entity-B" every time two things would collide to all other subsystems. Then the health subsystem would check whether it cares about the event and do something about it.

I'm worried about this approach because it seems very computationally intensive and might be a hit for performance. Also, HTML5 doesn't have threads (except web workers but meh...), which would make this easier. I'm just afraid that the sheer amount of messages going between subsystems would be enormous. Also, this approach makes my engine have two completely distinct type of events (one that is inter-entity and one that is inter-subsystem) which is yucky.

What do you guys think? Any suggestions would be very welcome.

Thanks,
Xaan


texts: Rotating an object about a point (2D) using box2d

texts:
i just started developing using box2d on flixel and i realise the pivot point of the rotation of an object in box2d is set to the center of an object.

i had read on forums and i found out that SetAsBox can change the pivot point of the object, however, i cannot seem to get it work to rotate about a point.

what i would like to achieve is to rotate an object about a point like earth revolving around the sun. any one can help me with it? really thanks a lot and sorry for the bad english


texts: How to make it so the game waits on player input for a dialog system in Godot?

texts:
So i have most system set up im just at loss on make it so that the player has to click through the dialog. Currently all the dialog is stored in text files that are read into dictionary's like so.
var dic = {}

func test():
    var index = 1
    popup_centered(Vector2(0,2000))
    var line = dic[str(index)]
    $Text.set_text(line)

#loads file into dictionary
func load_file(filepath):
    dic = {}
    var file = File.new()
    file.open(filepath, 1)
    var index = 1
    while not file.eof_reached():
        var line = file.get_line()
        print("the line:")
        print(line)
        dic[str(index)] = line
    index += 1
    file.close()
    print(dic)
    test()

Where the test function is like i said above i want the code to wait for the players input and print the next line in the dictionary and then close when the dictionary is empty. Being new to Godot i dont know if there is a simple way to do this. Any help is appreciated and thank you in advance.
Also aside, i know there are a lot of plug-ins for Godot that can handle dialog if i download them, but i want to build this myself so i can learn, so please don't just say use a plug in.


texts: Problem when texturing triangles using glVertexPointer()

texts:
I'm having a problem for displaying a single quad, here is how i do :

//note: this code is only for 2 triangles, while on picture there is 4 triangles
float tex_coord[] =
{
   0.0, 0.0, //3
   0.0, 1.0, //2
   1.0, 1.0, //0
   1.0, 1.0, //0
   1.0, 0.0, //1
   0.0, 0.0  //3
};

int indexes[] =
{
    3, 2, 0, 0, 1, 3
}

 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 glEnableClientState(GL_VERTEX_ARRAY);
   glVertexPointer(3, GL_FLOAT, 0, vertexes);
   glTexCoordPointer(2, GL_FLOAT, 0, tex_coord);
   glDrawElements(GL_TRIANGLES, 2, GL_UNSIGNED_INT, indices);
 glDisableClientState(GL_VERTEX_ARRAY);
 glDisableClientState(GL_TEXTURE_COORD_ARRAY);

The result :


texts:
I am recreating flappy bird as a quick project to help me understand the ins and outs of unity. However I have hit a road block. When the bird collides with the pipe or ground it is not kicking off the void onCollisionEnter2D(Collision2D target)

The Bird, the pole, and the ground are not triggers. They are all tagged correctly. Here is my code for the onCollisionEnter2D function.

    void onCollisionEnter2D(Collision2D target)
{
    Debug.Log("Entered 2D Collision");

    if (target.gameObject.tag == "Ground" || target.gameObject.tag == "Pipe")
    {
        if (isAlive)
        {
            isAlive = false;
            anim.SetTrigger("Bird Died:");
            audioSource.PlayOneShot(deadClip);
        }
    }
}

Even my debuging code is not being reached. So I am stuck as to why this function isn't being executed when the bird collides with the pole or ground. They both all have 2D collision boxes on them.


texts:
I have a need to dynamically load textures from the player's filesystem. WWW provides the functionality I need, but I can't get the example code to compile.

"yield www" causes my code to not compile. Here, the code is short:

    private List<Texture> LoadTextures (String prefix, int numTextures)
    {
        List<Texture> textures = new List<Texture> ();
        for (var i = 0; i < numTextures; i++ )
        {
            var www = new WWW(prefix + i);
            yield www;
            textures.Add(www.texture);
        }
        return textures;
    }

Why doesn't yield work here, like the code sample on the Unity docs suggests?

EDIT:

In response to Lasse:

    private IEnumerable<Texture> LoadTextures (String prefix, int numTextures)
    {
        for (var i = 0; i < numTextures; i++ )
        {
            var www = new WWW(prefix + i + ".png");
            yield return www.texture;
        }
    }

The above compiles, but I now get this error:

  You are trying to load data from a www stream which has not completed
  the download yet. You need to yield the download or wait until isDone
  returns true.

It's as if it is not even yielding. What gives? The file does exist in this directory. I tried prepending "file:///" but that didn't do anything. Do I need to provide an absolute path, or is relative OK?


texts: Advantage of Using Addressable Over Asset Bundles in Unity

texts:
I have a project that already uses asset bundles. I download assets when the game starts and show them to the user when needed.
I see that Unity provides addressables as new solution for asset management. As its new (not very new as its accessible from 2018.2, but official docs dont say a lot) there is not so much about it on the web.
From what it seems, in addressables you dont need to care about the bundle version, or which asset is in which bundle. In addresables, Unity automatically uploads assets to your host, and Unity automatically correctly manages local caching or downloads from a server, so objects behave like they are in the main game package but you have to check if they are loaded or downloaded. Am I right?
Are there any other features that addressables offer?


texts:
I want to know how to destroy object copies.

    public GameObject sparks;

void Update() {

}

void OnTriggerEnter(Collider bulletv) {

    if (bulletv.gameObject.CompareTag("enemy"))
    {
        Destroy(this.gameObject);
        Instantiate(sparks,transform.position,transform.rotation);
        // destroy sparks copies after 2 seconds !!!
    }
}


texts:
I have a Rectangle and a Vector2 position, my sprite is being drawn at this position. The rectangle is meant to be a collision system with the cursor, when I rotate my sprite around the origin and stuff in a draw call

public virtual void Draw(SpriteBatch spriteBatch)
{
    spriteBatch.Draw(texture, position, null, Color.White, rot, Origin, SCALEFACTOR, SpriteEffects.None, 0f);
}

It works fine, my object is rotated, at it's centre, by Pi/2, or whatever I put in.
However, rotating the rectangle isn't as easy, I read almost every stack overflow question on this problem and still haven't found a fix. I then followed a youtube guide, this is the resulting code for rotating a rectangle.

private void RotateItem(float rotation)
{
    rot += rotation;
    UpdateRectangle();
}

private void UpdateRectangle()
{
    Vector2 tl = Vector2.Transform(Vector2.Zero, transform);
    Vector2 tr = Vector2.Transform(new Vector2(scaledWidth, 0), transform);
    Vector2 bl = Vector2.Transform(new Vector2(0, scaledHeight), transform);
    Vector2 br = Vector2.Transform(new Vector2(scaledWidth, scaledHeight), transform);

    Vector2 min = new Vector2(FindSmallest(tl.X, tr.X, bl.X, br.X), FindSmallest(tl.Y, tr.Y, bl.Y, br.Y));
    Vector2 max = new Vector2(FindBiggest(tl.X, tr.X, bl.X, br.X), FindBiggest(tl.Y, tr.Y, bl.Y, br.Y));

    rectangle = new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y));
}

private void UpdateTransformMatrix()
{
    transform = Matrix.CreateTranslation(new Vector3(-Origin, 0))
                * Matrix.CreateRotationZ(rot)
                * Matrix.CreateTranslation(new Vector3(position, 0));
}

The width + height don't seem to change until I click on the box (which isn't even drawn properly over the sprite because Origin + and doesn't seem to rotate at all tbh)... I'll show you an example https://gyazo.com/c045b844f306a0ea25f48a0d45127f21

And this is my full draw code + including the rectangle's rectTex

public virtual void Draw(SpriteBatch spriteBatch)
{
    spriteBatch.Draw(texture, position, null, Color.White, rot, Origin, SCALEFACTOR, SpriteEffects.None, 0f);
    if (ShowRectangle)
        spriteBatch.Draw(rectTex, rectangle, null, Color.White, rot, Vector2.Zero, SpriteEffects.None, 0f);
}


texts: How to project spherical coordinates to canvas

texts:
I have objects with coordinates in a spherical coordinate system (altitude alt and azmiuth az). I want to project those to my canvas with a given size (128 x 128 pixels²) and resolution (about 6 px/°).

The canvas looks at the sphere from the inside and can be rotated in alt, az and around its normal. The canvas normal direction is known in the same coordinate system as the objects, and the view is centered around that canvas' center.

How do I find an object's x and y position on the canvas? I know this is almost the same as an orthogonal (or similar) map projection, but the examples I found all have a view fixed at alt = 0. That's not what I have here, and I'm having difficulties figuring this out.

I can not use any ready-made projection tools, as I'm programming an embedded system. The existing questions here at gamedev seem to be centered around frameworks that provide such functionality.

As DMGregory pointed out, I need a simple perspective projection matrix for a gnomonic projection. Wikipedia also has an article about perspective (camera) projection, I'll try to implement that and see if it does what I need.


texts: How do I move a sprite by clicking other sprites in the stage?

texts:
I am new to the LibGDX environment; how do I move a sprite by clicking other sprites in the stage?

As you can see, I have an object I wish to move by clicking on arrow keys. Here are my current scripts:

public class MyGdxGame extends ApplicationAdapter {

    Stage stage;

    @Override
    public void create () {
        ScreenViewport viewport = new ScreenViewport();

        stage = new Stage(viewport);
        Gdx.input.setInputProcessor(stage);

        Myactor actor = new Myactor();
        stage.addActor(actor);
    }

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

        stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();
    }

    @Override
    public void dispose () { }
}

public class Myactor extends Actor {

    Texture texture = new Texture(Gdx.files.internal("ball.png"));
    Sprite sprite = new Sprite(texture);

    Texture Tsol = new Texture(Gdx.files.internal("left.png"));
    Sprite Ssol = new Sprite(Tsol);

    Texture Tsag = new Texture(Gdx.files.internal("right.png"));
    Sprite Ssag = new Sprite(Tsag);

    @Override
    public void draw(Batch batch, float parentAlpha) {
        sprite.setPosition(Gdx.graphics.getWidth()
                - sprite.getWidth() - 50, Gdx.graphics.getHeight() / 2);
        sprite.draw(batch);

        Ssol.setPosition(Gdx.graphics.getWidth() - sprite.getWidth(), 0);
        Ssol.setRotation(90f);
        Ssol.draw(batch);

        Ssag.setPosition(Gdx.graphics.getWidth()
                - sprite.getWidth(), Gdx.graphics.getHeight()-sprite.getHeight());
        Ssag.setRotation(90f);
        Ssag.draw(batch);
    }
}


texts: Input of mouseclick not always registered in XNA Update method

texts:
I have a problem that not all inputs of my mouse events seem to be registered.
The update logic is checking a 2 dimensional array of 10x10 .
It's logic for a jewel matching game.
So when i switch my jewel I can't click on another jewel for like half a second.
I tested it with a click counter variable and it doesn't hit the debugger when i click the second time after the jewel switch. Only if I do the second click after waiting half a second longer.
Could it be that the update logic is too heavy that while he is executing update logic my click is happening and he doesn't register it?

What am I not seeing here :)? Or doing wrong. It is my first game.

UPDATE :
I changed to Variable time step, then i saw after the reindex of my jewels (so after the switch) i see the elapsedgametime was 380ms. So I guess that is why he doesn't catch the short "Press" of my mouseclick because update method is still busy with executing the reindexing code. Anyone knows how I can deal with this .. Or do I have to start using threads because my update of reindex takes too long?

SOLVED :
The problem was that in my reindexing code I got out of bound exceptions which I catched and then continued. That catching of exceptions caused a massive lag each time a reindex happened. Now everything runs smoothly and I do not have to worry about a slow Update. But I'm still asking the question.. what should you do If you have really heave update logic where the time to process the logic takes almost a 0.5 second? I guess you need to execute your game logic in multiple threads to reduce the update time? I'm also thinking i'll never have to worry about this for a jewels game :p. It's more for a problem for a heavy physics game with alot of game objects ?

My function of the update methode looks like this.

 public void UpdateBoard()
        {
            currentMouseState = Mouse.GetState();
            if (currentMouseState.LeftButton == ButtonState.Pressed &&
                prevMouseState.LeftButton != ButtonState.Pressed)
            {
                debugCount++;
                if (debugCount == 3)
                {
                    int a = 4;
                }

                leftButtonPressed = true;
            }
            if (this.IsBoardActive() == false)
            {
                UpdatingLogic = true;
                if (leftButtonPressed == true)
                {
                    // this.CheckDropJewels(currentMouseState);
                    this.CheckForSwitch(currentMouseState);
                    if (SwitchFound == true)
                    {
                        reIndexSwitchedJewels = true;
                    }
                    this.MarkJewel(currentMouseState);
                }
                if (CheckForMatches == true)
                {
                    if (this.CheckMatches(5) == true)
                    {
                        this.RemoveMatches();
                        reIndexMissingJewels = true;
                    }
                    else
                    {
                        CheckForMatches = false;
                    }
                }

                UpdatingLogic = false;
                if (currentMouseState.RightButton == ButtonState.Pressed &&
                    prevMouseState.RightButton != ButtonState.Pressed)
                {
                    this.CheckMatches(5);
                }

                this.ReIndex();
                leftButtonPressed = false;
            }

            prevMouseState = currentMouseState;
            this.UpdateJewels();

        }


texts: TextureRegions and TextureAtlases in AndEngine

texts:
This is my first android game, sorry if my code is bad, any advice will help. I am trying to find ways to improve performance on a game of mine, I'm using AndEngine GLES2. I have a basic question about how to actually load sprites.

I have 6 player sprites that actually use the same jpg as it's image, the way I've been loading them is like this:

private void loadLinebackers(String imageResource, int i) {
    this.playersTextureAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.BILINEAR);
    this.playersTextureRegion[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.playersTextureAtlas[i], this, imageResource, 0, 0);
    this.playersTextureAtlas[i].load();
}

private void loadWideReceivers(String imageResource, int i) {
    this.wrsTextureAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.BILINEAR);
    this.wrsTextureRegion[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.wrsTextureAtlas[i], this, imageResource, 0, 0);
    this.wrsTextureAtlas[i].load();
}

Do I have to create an atlas and a region for every player that I have? Or can I somehow use the same resource?

All the players are viewable simultaneously within the camera. I run these load* functions via a for loop, passing in i each time.

Each set of players is performing different actions (SequenceModifiers) and I make the Sprite arrays like this:

private void makeLinebackers(Scene scene, float posX, float posY, int i, int spaceBetween) {
    this.olineman[i] = new Sprite(posX + (spaceBetween * i), posY, this.playersTextureRegion[i], this.getVertexBufferObjectManager());
    this.olinemenPhysicsHandler[i] = new PhysicsHandler(this.olineman[i]);
    this.olineman[i].registerUpdateHandler(this.olinemenPhysicsHandler[i]);
    scene.attachChild(this.olineman[i]);
}

private void makeWideReceivers(Scene scene, float posX, float posY, int i, int spaceBetween) {
    this.wideReceivers[i] = new Sprite(posX + (spaceBetween * i), posY, this.wrsTextureRegion[i], this.getVertexBufferObjectManager());
    this.wrsPhysicsHandler[i] = new PhysicsHandler(this.wideReceivers[i]);
    this.wideReceivers[i].registerUpdateHandler(this.wrsPhysicsHandler[i]);
    scene.attachChild(this.wideReceivers[i]);
}

I made each of these 2 different arrays, because generally each player from each array are doing similar animations and actions. For example, I make all the wide-receivers "run" at once.


texts: Do I need a rendering system in my engine?

texts:
I am planning to create a cRPG game engine that would allow to easily create games like Baldur's Gate. I already tried to do that once, but my knowledge was vastly insufficient at the time. I settled for C++, SFML and TGUI (a GUI library), as this is what I have most experience with. I've read this article on game engine architecture, and I have decided to follow that system's architecture (event/message driven), because I know how much of a unworkable hairball my previous attempt was.

I am mindmapping the concept and its architecture for the past few days now (something I didn't do at all previously); and I came up to the point of how I want to divide (or do I?) the gameplay and rendering. The rendering part is actually very simple, as SFML does bulk of the job. I concluded that I don't even know what I could place in the rendering system apart from drawing sprites. I also can't seem to find more resources about game engine systems, because every time I search for that I get system requirements for unity and unreal.

If I decide to go with the rendering system, what would be the best way to store and send sprites? I suppose that I need to make a sprite resource manager. If so, how is the best way to send them to the render system without coupling things too much? Or perhaps the sprite resource manager should reside in the render system itself?

EDIT:
As of current, the planned architecture is divided into 6 systems (Input, Audio, Logging, GUI, Gameplay, Render). I will use Events for decoupling. The problem with this design is that i will have at least 3 direct connections between GUI, Gameplay and Render. Those are:

Between GUI and Render. The TGUI library introduces a TGUI Window class that inherits from SFML one, and can be used as one. In my case, it will be a part of the Render system. Hovewer, the GUI system will need to have a pointer to the Window to register GUI widgets.
Between Gameplay and Render. Where applicable, Actor class will have a AnimatedSprite, which i will implement on my own. It will be a part of the Gameplay system, and will have a pointer to the sprite in resource manager (in the Render system); it will just cut it depending on animation/frame. In some cases, when animations are not required, the Actor class will just have pointer to a normal sprite. To get those pointers a function in resource manager will be called from the Gameplay system.

The latter of two is the major problem; as the function could be called at any time. But, it would be a simple function like sf::Sprite * getResource(std::string name) so i think it wont present all those big bad problems of coupling.


texts:
Im making a game that is getting pretty big and sometimes my thread has to skip a frame, so far I'm not using deltaTime for setting the speed of my different objects in the game because it's still not a big enough game for it to matter imo. But its getting bigger then I planned, so my question is, how important is delta Time?

If I should use delta time there is a problem, since speedX and speedY are integers(they have to be for eclipse to let you make a rectangle of them), I cant add delta time very functionally as far as I understand, but might be wrong?
Ive tried adding deltaTime to the code below, and sometimes my enemies just not move after spawn, they just stand there and run in the same place

Will add an some code for how I set / use speed:

     public void update(int dx, int dy) {
        double theta = 180.0 / Math.PI * Math.atan2(-(y - controls.pointerPosition.y), controls.pointerPosition.x - x);

        x +=dx * Math.cos(Math.toRadians(theta));
        y +=dy * Math.sin(Math.toRadians(theta));
    currentFrame = ++currentFrame % BMP_COLUMNS;
}

     public void draw(Canvas canvas) {
    int srcX = currentFrame * width;
    int srcY = 1 * height;
    Rect src = new Rect(srcX, srcY, srcX + width, srcY + height);
    Rect dst = new Rect(x, y, x + width, y + height);
    canvas.drawBitmap(bitmap, src, dst, null);
}

So if someone with some experience with this has any thoughts, please share. Thank you!

Changed code:

    public void update(int dx, int dy, float delta) {
        double theta = 180.0 / Math.PI * Math.atan2(-(y - controls.pointerPosition.y), controls.pointerPosition.x - x);
        double speedX = delta * dx * Math.cos(Math.toRadians(theta));
        double speedY = delta * dy * Math.sin(Math.toRadians(theta));
        x += speedX;
        y += speedY;
    currentFrame = ++currentFrame % BMP_COLUMNS;
}

     public void draw(Canvas canvas) {
    int srcX = currentFrame * width;
    int srcY = 1 * height;
    Rect src = new Rect(srcX, srcY, srcX + width, srcY + height);
    Rect dst = new Rect(x, y, x + width, y + height);
    canvas.drawBitmap(bitmap, src, dst, null);
}

with this code my enemies move like before, except they wont move to the right (wont increment x), all other directions work.


texts:
I'm tinkering with a unity2D sidescroller, and am trying to make a player controller to jump. However, when I tell my character to jump, it sometimes jumps twice the distance, and I don't know why. Below is my controller script:

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

public class PlayerMovement : MonoBehaviour
{

    public float playerSpeed = 10;
    public float jumpForce = 20;
    private bool ableToJump = false;
    public GameObject groundCheck;  // place an empty object slightly below the character where it will collide with any ground

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("space") && ableToJump)
        {
            ableToJump = !ableToJump;
            GetComponent<Rigidbody2D>().AddForce(new Vector3(0,1,0) * jumpForce);
        }
        if (Input.GetKey("a"))
        {
            transform.Translate(-playerSpeed * Time.deltaTime, 0, 0);
        }
        if (Input.GetKey("d"))
        {
            transform.Translate(playerSpeed * Time.deltaTime, 0, 0);
        }

        // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer.
        ableToJump = Physics2D.Linecast(transform.position, groundCheck.transform.position, 1 << LayerMask.NameToLayer("Wall"));
    }
}

Here is the glitch as it appears when I am previewing the game (watch how the third jump seems to be twice as high). There is no consistency to when it occurs, but it has occurred any time between two in a row and 10-12 between times it happens. I have tried long versus short presses of the jump key (space bar), moving versus standing still, and jumping on different locations. I have also tried disabling animations and waiting between presses versus pressing and holding space, versus pressing space rapidly. The only consistent thing is that sometimes I jump about three blocks (200 x 200px each) high, and sometimes I jump about six blocks high. Any tips are appreciated. Thanks!


texts: Is it efficient to only store interface pointers for components in an entity-component system?

texts:
Let us say that I have a simple architecture, and I have implemented event-based communication between the objects and the components. In this architecture, Game has GameObjects, and the GameObjects have Components.
GameObjects have reference to Game and Components have reference to the GameObject.

There is no shared interface between these objects. Is it worth making an interface to implement Update() and ReceiveMessage(), and then only store these interface pointers?

For example, should I store Component pointers in a GameObject, or I should make an EventListener interface with Update() and ReceiveMessage(), and store EventListener pointers? I think this is a good way to force modularity, but maybe I am over complicating it.


texts: What kind of game is prisonblock? Any open source that I can learn the math behind it?

texts: What kind of game is prisonblock?  Any open source that I can learn the math behind it for user actions/gameplay?


texts: Simulating pressure in a grid based liquid simulation

texts:
I have a 2D grid based water system in my XNA game, we have a method using cellular automata to simulate water falling and spreading.

Example of water flowing down a slope:

Each tile can contain a mass of 0 to 255 values of liquid, stored in a byte. I do not use floats, the old water system I had did, however it added complications and had a performance hit.

Each water tile updates itself with a simple set of rules:

If the tile below has space in it, move as much as possible from the current tile to the bottom one (Flow Down)
If the 2 sides aren't the same and aren't zero and both are passable, we get the sum of the 3 tiles (left + current + right) and divide it by 3 leaving the rest on the middle (current) tile
If the rule above gave a number of 2 as sum, we should divide the tiles into the two sides (1, 0, 1)
If rule 2 gave 1 as the sum, choose a random side to flow into
If rule 2 failed, we should check if one side is passable and the other isn't. If that is true, we split the current tile in half for the 2 tiles

How can I expand this logic to include pressure? Pressure will make liquids rise over "U-Bends" and fill in air pockets.

Example on how this currently fails:

The water should flow and equalize on each side of the U-Bend. Additionally, I have created methods to find out how far down a water block is, and therefore how much pressure it is experiencing. Now I need to be able to take these numbers and apply them to the other areas to equalize the pressure.


texts: What should "own" the battle state in combat between the player and NPCs?

texts: I have a Map, a Tile, NPCs and the Player. When a player enters a tile in the map, a moveTo event is fired, which calls for any NPCs associated with that tile to be "activated". Those NPCs may be antagonists, and wish to start a battle. The battle state (rounds, initiative, alive/dead, add and removing combatants) seems like it should all belong to the Tile, but that seems too tightly coupled... maybe it should belong to the Map? Thoughts on that?


texts: How can I achieve this top-down water effect in Unity?

texts:
I want to create a virtual fish pond similar to this in Unity (full video):

The ocean floor and fish are not a problem, but the effect of moving water that displaces the content below the surface is a mystery to me. I have googled and looked at the Unity asset store, but most water assets and questions are regarding more general oceans in 3D games, and not this type of top-down clear water effect. My research has led me to believe that the effect can be achieved with shaders, however I don't know much about shaders.

What I need:

Top-down clear transparent water, where the content below the water is displaced by the moving waves
The waves need to reflect light (highlights on the wave fronts)
Ripples in the water based on collision, so touches will create ripples in the water

How can I achieve this in Unity? Are there any existing assets / tutorials / open source projects that do this, or do I need to write my own shader for it? And if so, what components do I need to include in that shader?


texts:
I'm using C# and trying to get hardware mouse position. First thing I tryed was simple XNA functionality that is simple to use

Vector2 position = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

After that i do the drawing of mouse as well, and comparing to windows hardware mouse, this new mouse with xna provided coordinates is "slacking off". By that i mean, that it is behind by few frames. For example if game is runing at 600 fps, of curse it will be responsive, but at 60 fps software mouse delay is no longer acceptable. Therefore I tried using what I thought was a hardware mouse,

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out POINT lpPoint);

but the result was exactly the same. I also tried geting Windows form cursor, and that was a dead end as well - worked, but with the same delay. Messing around with xna functionality:

GraphicsDeviceManager.SynchronizeWithVerticalRetrace = true/false
Game.IsFixedTimeStep = true/fale

did change the delay time for somewhat obvious reasons, but the bottom line is that regardless it still was behind default Windows mouse. I'v seen in some games, that they provide option for hardware acelerated mouse, and in others(I think) it is already by default. Can anyone give some lead on how to achieve that.


texts: D3DXLoadSurfaceFromResource failed to load bitmap image

texts:
I'm working on a small DX9 game project for learning purpose. I'm current dealing with resources manager file (*.rc) which I'm not used to (I have only worked with direct file until now).
If I use D3DXLoadSurfaceFromFile, it worked fine, the image was drawn on windows. When I changed to D3DXLoadSurfaceFromResource, I think it can not load the image, only a black screen & the Hresult that it returns is S_FALSE.
This is the create surface function :
bool Surface::CreateSurface()
{
    if (FAILED(m_Device->CreateOffscreenPlainSurface(
        m_Width,
        m_Height,
        D3DFMT_X8R8G8B8,
        D3DPOOL_DEFAULT,
        &m_Surface,
        NULL
    )))
        return false;

    if (FAILED(D3DXLoadSurfaceFromResource(
        m_Surface,
        NULL,
        NULL,
        GetModuleHandle(NULL),
        MAKEINTRESOURCE(m_RsSymbol),
        NULL,
        D3DX_DEFAULT,
        0,
        NULL
    )))
        return false; // S_FALSE and return false while debug
    return true;
}

This the render function :
void GWindow::Render()
{
    Surface Hello_Brown(146, 146, m_lpD3DV, IDB_SAMPLE); // IDB_SAMPLP will be assigned to m_RsSymbol
    LPDIRECT3DSURFACE9 backbuffer;
    if (NULL == m_lpD3DV)
        return;

    m_lpD3DV->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);

    m_lpD3DV->GetBackBuffer(
        0,
        0,
        D3DBACKBUFFER_TYPE_MONO,
        &backbuffer
    );

    m_lpD3DV->StretchRect(
        Hello_Brown.GetSurface(),
        NULL,
        backbuffer,
        NULL,
        D3DTEXF_NONE
    );

    m_lpD3DV->Present(NULL, NULL, NULL, NULL);
}

Where I am wrong and how do I fix it?
Resource file : link
I linked the file above, because it too long to post here.


texts: Is there anyway I can make OpenGL ES 2.0 to accept coordinates (for Vextex for example) in int meaning the pixels instead of the default float system? Also how can I set the point (0,0) to be at the top left corner of screen instead of the default one at the exact middle of the screen (to make using the pixel coordinates system easier)?


texts: How do I get a Rigged 3D Model made in blender to display and animate on the iPhone?

texts:
I have a rigged model in blender of a man walking, I would like to know how to get this to display and animate on the iPhone and if their is a good free game library out their that lets me do it (even if it means saving as another format).

I've tried Cocos3D with no luck as the convertor from collada to Pod is crap (for lack of a better word)


texts:
I'm making a topdown 2d game, and I've made a decent entity system so far.
But I want to do the following with it:
I want to have drawing depth, so if, for instance, a tree is above another tree, then it should be drawn underneath the other tree. Here is basically a picture of what I mean.
This is what I'm trying to avoid:

Instead of that I want something like this:

If you have any idea how to do this, please tell me. If you need any code, here's basically what I do:
In my main class I call a generate entities class. In that then I add Tree class-es to an arraylist through which it renders them.
Thanks.


texts: Firing particle systems on prefab objects

texts:
In my game, I Instaniate several of the same prefabs for a group of player controlled characters.  The prefab contains child objects with particle systems attached.  For example one of the particle systems is a flame for the characters jet pack.  The problem I'm having is that whenever one characters jet pack is in use, all of the Instantiated prefab particle systems are fired simultaneously.

void Start()
{
    mainThrust = this.GetComponentsInChildren<ParticleSystem> ();
    foreach (ParticleSystem jetPack in mainThrust)
    {
        jetPack.enableEmission = true;
        if (jetPack.isPlaying)
        {
            jetPack.Stop ();
        }
    }
}

private void MoveWithJetPack()
{
    foreach (ParticleSystem jetPack in mainThrust)
    {
        if (jetPack.isStopped)
        {
            jetPack.Play ();
        }

    }
}

private void killJetPack()
{
    foreach (ParticleSystem jetPack in mainThrust)
    {
        if (jetPack.isPlaying)
        {
            jetPack.Stop ();
        }

    }
}

How can I make this work for only the currently "jet packing" character.  Also an explanation of why this code effects all of the characters that this script is attached to would be great.  I thought that every script attached to a game object was considered a unique instance.


texts: How can I handle a touch event in cocos2d for Android? And how to move a sprite using ccTouchesMoved?


texts: Unity Animator not properly following animation transitions

texts:
I have an Animator that has 3 different states. Walking, Climbing, and End of Climb.
The diagram is shown below:

I have 2 bools, isClimbing and isWalking. When isClimbing is set to false it transitions to End of Climb. Then when I set isWalking to true, it transitions to Walking. However, when I do this, for some reason the animator starts back at Climbing then moves to End of Climb then moves to Walking.
It seems everytime I change a parameter, it completely  restarts the state machine back to the default Climbing state and then moves forward.
I do not have code, and have been triggering this through the UI.
What am I doing wrong?


texts: Calculate visible points in grid in 2D game

texts:
I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can mean many things and I had to figure it out:

I call a point visible point if lines from refference point's centre to two closest point's corners do not intersect with any occupied point. On image bellow, illustration shows invisible in orange, visible in green.

By this definition, we can make a map like this:

Legend:

 - visible pixel
 - partially visible pixel
 - occupied pixel
 - player

I'm not interested in partially visible pixels, but I need to find out which pixels are visible. I don't know where to start. My only idea was to loop angles, but that doesn't work on larger map, where one iteration skips many actual pixels.
How do I check the visible pixels, or ideally, only the furthest visible pixels, as on this map:

And looping through all pixels must be probably avoided, that would eat up too much performance.


texts: What is the difference between these two shaders in terms of performance?

texts:
I have implemented a two pass Gaussian blur shader in GLSL like this:
...
const float[] weights = float[](0.382928, 0.241732, 0.060598, 0.005977, 0.000229);
vec2 offset = vec2(1.0f) / vec2(textureSize(image, 0));
vec3 result = texture(image, vec3(io_textureCoordinates, layer)).rgb * weights[0];
if(horizontal) {
  for(int i = 1; i < weights.length(); i++){
    result += texture(image, vec3(io_textureCoordinates + vec2(offset.x * float(i), 0.0f), layer)).rgb * weights[i];
    result += texture(image, vec3(io_textureCoordinates - vec2(offset.x * float(i), 0.0f), layer)).rgb * weights[i];
  }
} else {
  for(int i = 1; i < weights.length(); i++){
    result += texture(image, vec3(io_textureCoordinates + vec2(0.0f, offset.y * float(i)), layer)).rgb * weights[i];
    result += texture(image, vec3(io_textureCoordinates - vec2(0.0f, offset.y * float(i)), layer)).rgb * weights[i];
  }
}
...

Where variable horizontal and layer are uniforms (the image is a texture2DArray, but this is not that important). I use a 9x9 kernel (variable weights, the first weight is the center) and first I blur the image horizontally, then I change the horizontal uniform to false and rerun the shader to blur the image vertically. It works fine, but the performance is really bad. I don't know why, because I don't do anything special. The variable horizontal is a uniform, so it remains the same for every pixel in a draw call, so each shader core executes the the same path for every pixel.
Then I changed the code a little bit, like this:
...
const float[] weights = float[](0.382928, 0.241732, 0.060598, 0.005977, 0.000229);
vec2 offset = vec2(1.0f) / vec2(textureSize(image, 0));
vec3 result = texture(image, vec3(io_textureCoordinates, layer)).rgb * weights[0];
vec2 ofs = horizontal ? vec2(offset.x, 0) : vec2(0, offset.y);
for(int i = 1; i < weights.length(); i++){
  result += texture(image, vec3(io_textureCoordinates + ofs * float(i), layer)).rgb * weights[i];
  result += texture(image, vec3(io_textureCoordinates - ofs * float(i), layer)).rgb * weights[i];
}
...

It's almost the same, I just use horizontal in another place, but the performance is much better. Can someone explain what is the difference between the two shaders what causes a big difference in performance? I thought that maybe the first version executes both sides of the if-else, which means two times more texture sampling, however the second version is much faster even if I execute it two times more.
I'm using WebGL 2 and Nvidia GTX 1050M.


texts:
I've seen this many times, but I have no idea what's the best way to achieve it. I am looking for something close to, for example, this: Lonely Tree Live Wallpaper

I have two approaches in mind: one would be to make an animation in, say, Blender and then export the resulting images & create a spritesheet animation out of it. This is very straightforward, but creating a 120-frame spritesheet out of 512 x 512 or 1024 x 1024 images (for larger screens) seems overkill.

The second approach would be to cut my tree into a few separate textures and then move them simultaneously in such a manner that it gives the impression they form a single image of a tree swaying in the wind.

Any other approaches?


texts: Java - Trouble with recursion and rectangle placement

texts:
I am using Android API's and using the RectF class for rectangles. I have a list of blocks that are on the screen at one time. Each block is given a random position, and then I go through all of the tiles previous, to check if there is an intersection. If there is, it recursively calls the method again to get a new random position and check it against all the other tiles.

I feel like this should work perfectly, except for one thing that may be affecting it. Since recursion opens up so many instances of a method, it needs to finish them off, so I don't know if the rectangle is just being drawn at the initial position, and the rest of the calls are doing nothing?

I have tried quite a few different methods and this seems to be the closest, but something weird is happening and I cant figure it out.

Start method:

    private void start() {

    timerTask = new TimerTask() {
        @Override
        public void run() {

            if(Game.STATE == Game.State.Playing) {
                removeFailedTiles();

                Random deathRate = new Random();
                int i = deathRate.nextInt(100);
                if(i % 10 == 0) {
                    System.out.println("Death tile");
                    activeDeathTiles.add(new DeathTile(getRandomPosition()));
                    //System.out.println(activeDeathTiles.toString());
                } else {
                    System.out.println("Normal Tile");
                    activeTiles.add(new Tile(tileLifetime, getRandomPosition()));
                }

            }

            if(Game.STATE == Game.State.Lost) {
                timerTask.cancel();
                timer.cancel();
            }
        }
    };

    timer.schedule(timerTask, 1000, tileDelay);

}

Get Random Position method:

private RectF getRandomPosition() {
    int screenWidth = (int) Game.SCREEN_WIDTH;
    int screenHeight = (int) Game.SCREEN_HEIGHT;

    RectF pos = new RectF();

    Random random = new Random();
    int maxX = (int) (screenWidth - (Tile.TILE_WIDTH * 1.5f)), minX = (int) (Tile.TILE_WIDTH / 1.5f);
    int maxY = (int) (screenHeight - (Tile.TILE_HEIGHT * 1.5f)), minY = (int) (Tile.TILE_HEIGHT / 1.5f);

    pos.top = random.nextInt(maxY - minY) + minY;
    pos.left = random.nextInt(maxX - minX) + minX;
    pos.bottom = pos.top + Tile.TILE_HEIGHT;
    pos.right = pos.left + Tile.TILE_HEIGHT;

    if(isOverlap(pos)) {
        return getRandomPosition();
    } else {
        return pos;
    }
}

Helper methods:

private List<RectF> getAllTiles() {
    List<RectF> allTiles = new ArrayList<RectF>();

    for(RectF t : activeDeathTiles)
        allTiles.add(t);
    for(RectF t : activeTiles)
        allTiles.add(t);

    return allTiles;
}

private boolean isOverlap(RectF position) {

    for(RectF r : getAllTiles()) {
        if(RectF.intersects(position, r)) {
            return true;
        }
    }

    return false;
}

If someone could please help me figure out what is going wrong here that would be stellar!


texts: Why does the size/extents of a bounding box of a BoxCollider in Unity show the Z element being double what it is?

texts:
As you can see from the picture below, I fetch the BoxCollider inside CollisionHandler and Debug.Log() it to the screen.
In this case, I'm logging the size, but the same thing happens with extents. There are 4 logs because I have 4 instances of the object in the scene.
The Z value of the Vector3 is double what it should be, whereas the other values are, for the most part†, normal. Also, it seems that each object prints a slightly different value for extents.z. Most stay around 1.3, but one gave me 1.07~.
Additionally, it inverts the order for 2 of the objects. I don't know why.
None of the objects are scaled and all use the exact same values for their collider.

I tried drawing a cube with the same size as the BoxCollider's bounding box, and here's what I got:

I'm not entirely sure if the misalignment with the Collider in the scene is a sign of a problem or just how Gizmos.DrawCube() works. Here's the code that does this:
private void OnDrawGizmosSelected() {
    Vector3 origin = coll.bounds.center + transform.TransformDirection(new
    Vector3(0f, 0f, 0.675323f + skinWidth));
    // The hardcoded number above is Z extent of the box.
    Vector3 direction = transform.TransformDirection(Vector3.forward) * 2;

    Gizmos.color = Color.red;
    Gizmos.DrawRay(origin, direction);
    Gizmos.DrawCube(origin + direction, coll.bounds.size);
    // Where coll is a reference to the BoxCollider, cached in Awake().
}

Unity version 2019.3.15f1.
† For the X value of 2.286476, it rounded to 2.1 in the 3rd log for some reason. And in the first log, it rounded the doubled value of Z to 2.4 rather than 2.6...


texts:
Sorry for my clumsy question.
But I don't know where I am wrong at creating view matrix.

I have the following code:

 createMatrix(vec4f(xAxis.x, xAxis.y, xAxis.z, dot(xAxis,eye)),
 vec4f(  yAxis.x_, yAxis.y_, yAxis.z_, dot(yAxis,eye)),
 vec4f(-zAxis.x_, -zAxis.y_, -zAxis.z_, -dot(zAxis,eye)),
 vec4f(0, 0, 0, 1)); //column1, column2,...

I have tried to transpose it, but with no success.
I have also tried to use gluLookAt(...) with success.
At the reference page, I watched the remarks about the to-be-created matrix, and it seems the same as mine. Where I am wrong?


texts: Question-Answer Game with coin rewards, how to validate answer?

texts:
I'm making a game that is basically a typical question-answer type. With coins as reward per answered question.

Stacks and requirements:

UI frameworks of iOS and Android, no game engine.
REST API.
No offline feature.

I'm a newbie in making games, and so my questions are:

Is it okay if I let the client side validate the answer and let it decide how much coins to add in the database?
Or do I make the client side ask for validation of the answer in the server? But I'm thinking this is not ideal because in the game, when you choose an answer, and if the answer is right, the congratulations screen must be instantly popped out.


texts:
I'm working on a turn based game in Unity. I need to perform field/grid analysis(2D grid) when i'm iterating trough each unit "entity". The A.I. should be able to plan ahead and therefor needs to consider the components each unit have. Not every unit will have the same ability. These abilities are defined as components.

I want to make it flexible in the sense that I can plug in new abilities and my A.I. will take it into consideration.

While user control is somewhat implemented, A.I. hasn't even been written. So I'm open to any suggestion.

Q : What is a way for the A.I. system to collect all abilities of one unit and make decisions depending on each component?

edit:
I know there is the "null" checking method to see if the gameobject contains a component. But this is highly inflexible because you are hard coding a stack of if else. Something I want to prevent.


texts: Can I replace the source image of slices by script?

texts:
I have a Unity2D prefab that uses several slices from a single PNG. (in it sprite renderer, and in its animation clips). If I replace that PNG in the Finder, all slices taken from that PNG are automatically updated, which is great.

But I want to do this by script: just replace the PNG where all slices are taken from, with another PNG. This is so that each of my prefabs instances can all use a different spritesheet PNG source for its slices.

Is this possible in Unity?


texts: Shader registers for different graphics card

texts:
The title is not very explicative, so i'll try to make myself clear.
I have two "working"(on which i work on) PCs : a desktop that runs an NVIDIA GT440 an a laptop with a RADEON HD 4650. I have a shader for multipass rendering that uses both POSITION0 and POSITION1 registers for the vertex shader output :

struct VS_OUT
{
    float4 Position : POSITION0;
    float4 WorldPosition : POSITION1;

   // More variables for normal mapping and more
};

This code works just fine on my desktop, but when i run it on my laptop the rendering is screwed. I finally tracked down the problem to the POSITION1 output parameter, if i change it to TEXCOORD0 it works. Now ... i don't like to do things i do not understand, so i'd like to understand WHY it happens.

It's something GPU related for sure, but i'd be glad if you could link me some papers, articles or anything that explains how the registers work, and why not... even something in-deep about the programmable pipeline.

Thank you for your time and happy coding!


texts: System function in entity component architecture

texts: I started working with ECS and I am not completely sure that I understand it correctly. As I see it now - systems can implement logic for collision, movement, similar things like that. But would it be correct to dedicate a system for digging game logic only? It has a method for dig action, it also sets animation component to play "dig" animation and listens for event about animation completion after which it executes dig action. Am I doing it right?


texts: How can I make a gameObject jump quick at first then start slowing down after a while? It definitely has something to do with deltaTime.


texts: Need advice concerning the creation of open world game in Unity 3D

texts: I just wanted to ask for advice those being an expert in Unity 3d and overall in game industry about how it is possible to create an open-world game by means of Unity 3D, that is, I already tried to combine several tiles of terrains, 4 to be exact, and their respective size is 500x500. However, once I started to add the fifth terrain to those terrains, Unity stopped working. Moreover, another problem that I faced was with light mapping in Unity, that is, the more terrain I add to the scene the more it is difficult to bake the light mapping. The question is if I am doing correctly by adding terrains to each other and how open-world games are actually created. Yes, I heard of chunk loading but is it possible to code it on my own without using ready plugins. Lastly, Is it possible to combine tiles of terrains just manually without using any tools like Terrain Slicing kit or Gaia please I really need your help Thank you for your attention))).


texts: According to Wikipedia many games have been using so far voxel engines for modelling landscape. Why is it only used for landscape and not characters etc?


texts: Why am I having trouble, combining color attachments to implement bloom?

texts:
I'm trying to implement bloom in the same manner as this tutorial, but I am having difficulties. I have the blur buffer blurring correctly, but I can't seem to combine the two images.

Below, you will find my code. The commented-out lines just render one or the other buffer to the screen, so I know these are correct. For now, I am just trying to combine them together; not fix them with HDR. I just add together both textures, but no matter how I change things around, all I get is the one on the left.

blurShader.use();
glUniform1i(glGetUniformLocation(blurShader.program, "horizontal"), true);
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[1]);

long blurCount = 5;

for(long i=0; i<blurCount; i++)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glActiveTexture(GL_TEXTURE0);

    // bind texture of other framebuffer (or scene if first iteration)
    glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i%2]);

    RenderQuad();
    glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i%2]);
}

glUniform1i(glGetUniformLocation(blurShader.program, "horizontal"), false);

for(long i=0; i<blurCount; i++)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glActiveTexture(GL_TEXTURE0);

    // bind texture of other framebuffer (or scene if first iteration)
    glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[(i+1)%2]);

    RenderQuad();
    glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[(i+1)%2]);
}

glBindFramebuffer(GL_FRAMEBUFFER, 0);

//renderScreenQuad(colorBuffers[0]);
//renderScreenQuad(pingpongColorbuffers[1]);

// 2. Now render floating point color buffer to 2D quad and tonemap HDR colors
// to default framebuffer's (clamped) color range
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
bloomShader.use();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, colorBuffers[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[1]);
glUniform1i(glGetUniformLocation(bloomShader.program, "bloom"), bloom);
glUniform1f(glGetUniformLocation(bloomShader.program, "exposure"), exposure);
RenderQuad();

#version 330 core
out vec4 FragColor; in vec2 TexCoords;

uniform sampler2D colorTexture; uniform sampler2D bloomTexture;
uniform bool bloom; uniform float exposure;

void main() {
    vec3 firstColor = texture(colorTexture, TexCoords).rgb;
    vec3 secondColor = texture(bloomTexture, TexCoords).rgb;
    FragColor = vec4(firstColor+secondColor, 1.0f);
}

#version 330 core
layout (location = 0) in vec3 position; layout (location = 1) in vec2 texCoords;

out vec2 TexCoords;

void main() {
    gl_Position = vec4(position, 1.0f);
    TexCoords = texCoords;
}

Basically, what happens is that the first image bound goes through, and is accessible. Then, the second is the same as the first! If I change the order in which I bind the images, then the other image becomes the one sent in.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[1]);
glUniform1i(glGetUniformLocation(bloomShader.program, "bloom"), bloom);
glUniform1f(glGetUniformLocation(bloomShader.program, "exposure"), exposure);
RenderQuad();

The above code is the section I'm talking about. Each of the pingpongcolorbuffers is attached to its own FBO. I am trying to send those in. Is there some reason that would limit me to sending in only one?

Here is the combined result, before HDR:


texts: Pointer deleted by object manager on next frame

texts:
I have a class named GameManager, which job is to manage GameObject allocation and deallocations. The thing is, every GameObject can interact with each other, so there's a possibility that a pointer to another GameObject in a GameObject's script becomes deleted by manager the next frame. (Something like a missile, the missile's target may be already destroyed by another object)

I can't use shared pointer because there are times where a GameObject should be removed, but can't be removed because a GameObject won't release. What is a good design pattern to tackle this problem? Or should GameObject check for null each time?


texts: Does Unity 5.4.3 supports backward compatibility with Unity 5.4.2?

texts:
I'm currently using Unity 5.4.2 for my video game project, however my friend who assists me in the project uses Unity 5.4.3 instead.
Does Unity 5.4.3 supports backward compatibility with projects made with the previous version, in this case, Unity 5.4.2?

NB: This is the first time I'm asking in Stack Exchange forum. I'm apologize for any mistakes in this question.


texts:
I've spent more time than I should trying to get my ray picking program working. I'm pretty convinced my math is solid with respect to line plane intersection, but I believe the problem lies with the changing of the mouse screen touch into 3D world space.

Heres my code:

    public void passTouchEvents(MotionEvent e){

        int[] viewport = {0,0,viewportWidth,viewportHeight};
        float x = e.getX(), y = viewportHeight - e.getY();

        float[] pos1 = new float[4];
        float[] pos2 = new float[4];
        GLU.gluUnProject(   x, y, 0.0f,
                            mViewMatrix, 0,
                            mProjectionMatrix, 0,
                            viewport, 0,
                            pos1, 0);

        GLU.gluUnProject(   x, y, 1.0f,
                            mViewMatrix, 0,
                            mProjectionMatrix, 0,
                            viewport, 0,
                            pos2, 0);
    }

Just as a reference I've tried transforming the coordinates 0,0,0 and got an offset.  It would be appreciated if you would answer using OpenGL ES 2.0 code.


texts: XNA Further faces are shown through closer faces

texts:
I'm trying to draw a 'axis' model named 'XYZ'. The problem is that it is rendered wrong (screenshot below).

You can see that the blue face can be seen through the red face. The black, green and red faces have no problem.
Here is my code for drawing the axis.

protected override void Initialize()
    {
        this.IsMouseVisible = true;
        this.Window.Title = "3DRadSpace -Editor- 3dradspace.org";
        Tools Toolz = new Tools();
        Toolz.Show();
        // TODO: Add your initialization logic here
        base.Initialize();
        RasterizerState stat = new RasterizerState();
        stat.CullMode = CullMode.None; //Does nothing, the default does the same thing
    }
protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            MS = Mouse.GetState();
            if (MS.X < 120 && MS.Y < 120 && MS.X > 0 && MS.Y > 0 && MS.LeftButton == ButtonState.Pressed)
            {
            }
            KB = Keyboard.GetState();
            if (KB.IsKeyDown(Keys.Left))
            {
                Cam = new Vector3(Cam.X -= 1, Cam.Y, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Right))
            {
                Cam = new Vector3(Cam.X += 1, Cam.Y, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Up))
            {
                Cam = new Vector3(Cam.X, Cam.Y, Cam.Z+=1);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Down))
            {
                Cam = new Vector3(Cam.X, Cam.Y, Cam.Z-=1);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.Q))
            {
                Cam = new Vector3(Cam.X, Cam.Y+-1, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            if (KB.IsKeyDown(Keys.E))
            {
                Cam = new Vector3(Cam.X, Cam.Y+= 1, Cam.Z);
                view = Matrix.CreateLookAt(Cam, new Vector3(0, 0, 0), Vector3.UnitY);
            }
            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(75,75,255));
            DrawModel(axis, world, view, projection);
            spriteBatch.Begin();
            spriteBatch.Draw(MovX,new Vector2(0,0), Color.White);
            spriteBatch.End();
            // TODO: Add your drawing code here
            base.Draw(gameTime);
        }
        private void DrawModel(Model model, Matrix world, Matrix view, Matrix projection)
        {
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = world;
                    effect.View = view;
                    effect.Projection = projection;
                }
                mesh.Draw();
            }
        }


texts:
So heres some straight up code for you:

BoundingBox b  = new BoundingBox(
  Vector3.Up   + Vector3.Right    + Vector3.Forward,
  Vector3.Down + Vector3.Backward + Vector3.Left);
BoundingBox bb = new BoundingBox(
  Vector3.Up/2   + Vector3.Right/2    + Vector3.Forward/2,
  Vector3.Down/2 + Vector3.Backward/2 + Vector3.Left/2);

Debug.GraphicsManager.DrawLine(b, Color.Purple);
Debug.GraphicsManager.DrawLine(bb, Color.Yellow);

if (bb.Contains(b) == ContainmentType.Disjoint)
  Debug.DisplayVariable("Disjoint", "");
if (bb.Contains(b) == ContainmentType.Contains)
  Debug.DisplayVariable("Contains", "");
if (bb.Contains(b) == ContainmentType.Intersects)
  Debug.DisplayVariable("Intersects", "");

What this does is create two bounding boxes, that /obviously/ intersect.
DrawLine is a function that accepts a bounding box and draws it.
Math and visuals tells us that these intersect and contain.

But all I get is disjoint.

So I started a new blank fresh clean project and only added this to the update code:

BoundingBox b = new BoundingBox(
  Vector3.Up + Vector3.Right + Vector3.Forward,
  Vector3.Backward + Vector3.Left);
BoundingBox bb = new BoundingBox(
  Vector3.Up / 2 + Vector3.Right / 2 + Vector3.Forward / 2,
  Vector3.Backward / 2 + Vector3.Left / 2);

if (bb.Contains(b) == ContainmentType.Disjoint)
  System.Console.WriteLine("Disjoint");
if (bb.Contains(b) == ContainmentType.Contains)
  System.Console.WriteLine("Contains");
if (bb.Contains(b) == ContainmentType.Intersects)
  System.Console.WriteLine("Intersects");

if (bb.Intersects(b))
  System.Console.WriteLine("intersex");

and this has the same problem.

So I'm stumped. Does XNA just not have good bounding box collison code?
Or am I doing something wrong?
should I write my own collison code?

Thanks for reading, no this is not debug for me, I simply don't understand.

edit: I also have mouse picking set up and it can identify and pick
all my "models" based on Ray.Intersects(model.boundingbox) no problem.


texts:
I'm loading a simple model, which is composed of vertices that have position, normal and UV texture coordinates.

The thing is, displaying that model using DirectX 9 or 10 shows that the UV coordinates are wrong. In fact, if I manually edit the texture using Paint and flip it vertically, the result is ok.

Is something wrong with my loading routines? Using Visual Studio Graphics Debuggers shows that both the model and the texture are correctly loaded.

Do I have to flip the texture vertically when I load it, or just transform the UV coords with:

u = u;
v = 1 - v;

Also, as far as I know, OpenGL differs from Direct3D for the UV coordinates system. Would those coordinates be ok with OpenGL without any transformation?


texts:
I have the main game loop in libGDX. On the touch() event I want an animation to be executed. So I will have a variable which will store the value which will be updated each frame and further rendered side by side each frame.

The problem:
I want an another animation to take place after the first one finishes. How do I update variable to do so? Because it should take place after first. I can't place two statements in loop one after another. Is there a way to create an another game loop inside first so that when inner runs the outer is paused?


texts: 2D side scroller - How to implement X/Y movement?

texts:
I'm currently writing a small 2D, side-scroller-ish kind of game.

I have a simple camera that follows the player around and the physics are ready.

I'm using 32x32 tiles that build out the world, they are all stored in a 2D array, something along this:

[ 0, 0, 0, 0,
  0, 0, 0, 0,
  1, 1, 0, 1,
  1, 1, 1, 1  ]

The 1s are land and 0s are air.

Now the world is dynamic and I want it to be quite large (1 big world) around 1000x800 tiles total.

My biggest issue atm is how to implement the "scrolling effect".
Also keep in mind that the player can go in any direction (up/right/left/right).

Thanks


texts: Android Game - Screen Flickers When an Entity Removed From The List

texts:
I am using Canvas in my android game. When I remove a no longer displayed entity in my entity list, all other entities are flickering for a brief time. When it's not removed, there is no such problem. But since I am not a big fan of memory leaks, that's not an option.
The canvas rendering system is already double-buffered by design and I have utterly no idea how to fix such a problem.
I have thought maybe it is because the list is sorting itself after the item removal and tried changing it to a Set, but that didn't work either.
Does anyone have any idea why this might be happening and how to fix it?
Structure of the code:
private val gameObjects: List<GameObject> = mutableListOf()

    fun update(deltaTime: Long)
    {
        gameObjects.forEach {
            it.update(deltaTime)
    }

 fun render(canvas: Canvas)
    {
      gameObjects.forEach {
         when (getVisibilityStatus(it.virtualY))
         {
            VisibilityStatus.VISIBLE -> it.render(canvas, virtualToPhysicalY(it.virtualY))

            VisibilityStatus.BELOW_SCREEN ->
            {
              if (virtualToPhysicalY(it.virtualY) > screenSizePairXY.second)
                gameObjects.remove(it)

            }
         }
    }


texts: What causes player box/world geometry glitches in old games?

texts:
I'm looking to understand and find the terminology for what causes - or allows - players to interfere with geometry in old games.  Famously, ID's Quake3 gave birth to a whole community of people breaking the physics by jumping, sliding, getting stuck and launching themselves off points in geometry.

Some months ago (though I'd be darned if I can find it again!) I saw a conference held by Bungie's Vic DeLeon and a colleague in which Vic briefly discussed the issues he ran into while attempting to wrap 'collision' objects (please correct my terminology) around environment objects so that players could appear as though they were walking on organic surfaces, while not clipping through them or appear to be walking on air at certain points, due to complexities in the modeling.

My aim is to compose a case study essay for University in which I can tackle this issue in games, drawing on early exploits and how techniques have changed to address such exploits and to aid in the gameplay itself.  I have 3 current day example of where exploits still exist, however specifically targeting ID Software clearly shows they've massively improved their techniques between Q3 and Q4.

So in summary, with your help please, I'd like to gain a slightly better understanding of this issue as a whole (its terminology mainly) so I can use terms and ask the right questions within the right contexts.  In practical application, I know what it is, I know how to do it, but I don't have the benefit of level design knowledge yet and its technical widgety knick-knack terms =)


texts:
The Animations done is 3ds max works great and smooth as they should be, problem happens when i import them to unity, they seems to be glitching and noncontinuous at some parts, all i did was splitting the animations based on the frame sheet given by the animator.
Maybe I'm missing somethings ?


texts:
I'm working on a project in LibGDX.
It's a 2d platform game; you can say it's like Super Mario.

So this is how I move my player to the right:

if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)){
    player.b2body.applyLinearImpulse(
               new Vector2(0.1f, 0),
               player.b2body.getWorldCenter(),
               true);
}

When I release the key, the player is still moving a bit. (It still has a "Linear Impulse" force on its physical body, I think).

How can I make it stop?

My question could be simple as:
What is the best way to move a physical body on LibGDX in one direction while holding a key. When I release the key, the body stops immediately.

I have tried with "setTransform" and it's causing issues when the body is touching other objects - plus the shape comes "before" the rest of the game in the screen (you can see it on debug)

Thanks.


texts: ARMv7 vs FAT in Unity Android Build Settings (release multiple valid APKs)

texts:
If I select ARMv7 instead of FAT (ARMv7+x86) in the Android Build Settings of Unity5-Free, the APK binary drops to half size.

FAT => ~20MB
ARM => ~10MB

(Tested with an empty scene, no assets, nothing, just the core libraries).

I've seen the "official stats" of the CPU usage are here:

http://hwstats.unity3d.com/mobile/cpu.html

So not a lot of business to loose as for the date of publishing this question. But x86 seems to be an increasing trend.

Questions:

Is there any way to publish a binary to the ARM users and another version to the x86 users but with the same product-id so if they change the mobile phone, the software gets properly downloaded (but still each one gets a small footprint)?
Does this CPU correlate with WinPhone? Or is an othogonal measure? In other words: Are all Androids ARM? Or there are ARM and x86 Androids?

Thanks!


texts:
recently I decided to implement in my game the drawing of a silhouette of the player when he is behind objects (the top layer of the map). Found a similar question here, but it doesn't matter to me to understand anything. Can someone please explain how it all works? I will be very grateful to you! Specifically, I'm interested in the issue of creating the Vertex and Fragments of the shaders? And why is only one shader passed to two setSheader methods.
Code that I do not understand:
// Rendering the upper map layer:
// Simple "if (gl_FragColor.a == 0.0) discard;" fragment shader
renderer.getBatch().setShader(shader);

//Rendering the silhouettes:
// "gl_FragColor = vec4(0.0, 1.0, 1.0, 0.2) * texture2D(u_texture, v_texCoord0).a;"
batch.setShader(shader);

EDITS:
I tried adding this code and this is what I got:
Java code:
//above render the normal player texture outside the shader code

mapRenderer.render(lowerLayer);
player.update(mapMgr, game.batch, delta, world);
mapRenderer.render(upperLayer);

Gdx.gl20.glClear(GL20.GL_STENCIL_BUFFER_BIT);

Gdx.gl20.glEnable(GL20.GL_STENCIL_TEST);
Gdx.gl20.glStencilFunc(GL20.GL_ALWAYS, 0x1, 0xFF);
Gdx.gl20.glStencilOp(GL20.GL_REPLACE, GL20.GL_REPLACE, GL20.GL_REPLACE);

mapRenderer.getBatch().setShader(shader);
mapRenderer.render(upperLayer);
mapRenderer.getBatch().setShader(null);

Gdx.gl20.glStencilFunc(GL20.GL_LEQUAL, 0x1, 0xFF);
Gdx.gl20.glStencilOp(GL20.GL_KEEP, GL20.GL_KEEP, GL20.GL_KEEP);

game.batch.setShader(shader);
player.update(mapMgr, game.batch, delta, world);
game.batch.setShader(null);

Gdx.gl20.glDisable(GL20.GL_STENCIL_TEST);

Fragment GLSL code:
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;

void main() {
  vec4 c = vec4(.5, .5, .5, texture2D(u_texture, v_texCoords).a);
  if (c.a == 0.0) {
    discard;
  }
  gl_FragColor = c;
}

It didn't work out that way. In addition to the fact that the color of the top layer changes, the player is also completely painted, regardless of whether he is under the top layer or not.
I think the problem is in some of this:

This part of the code does not work. Because even if you remove it, nothing changes.
Gdx.gl20.glClear(GL20.GL_STENCIL_BUFFER_BIT);
Gdx.gl20.glEnable(GL20.GL_STENCIL_TEST);
Gdx.gl20.glStencilFunc(GL20.GL_ALWAYS, 0x1, 0xFF);
Gdx.gl20.glStencilOp(GL20.GL_REPLACE, GL20.GL_REPLACE, GL20.GL_REPLACE);
Gdx.gl20.glStencilFunc(GL20.GL_LEQUAL, 0x1, 0xFF);
Gdx.gl20.glStencilOp(GL20.GL_KEEP, GL20.GL_KEEP, GL20.GL_KEEP);
Gdx.gl20.glDisable(GL20.GL_STENCIL_TEST);

Fragment shader is not written correctly

I spent all day solving this problem. Nothing works. I hope someone will figure it out! Thanks.


texts: How to work with different artists sequentially?

texts:
Making games is a hobby for me and I don't always have consistent time to do it. Also, I'm terrible at art, so I plan to hire an artist. However I am concerned that after a job is done, if I want to return to the project and add more content, the same artist will not be available for any number of reasons. What can be done to help a new artist maintain the style of the previous?

Should I hire the original artist to create a graphic bible? Or is referencing the original art enough? Or is there an entirely different approach that would be better?

Note that this is not a duplicate of this question, where multiple artists are coordinating simultaneously. In this case, one artist has done their work and is gone, unavailable for contact or future work, and a new artist is expanding the assets.


texts: Why does reading my depth texture in GLSL return less than one?

texts:
I've created a depth texture in OpenGL (using C#) as follows:
// Create the framebuffer.
var framebuffer = 0u;

glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);

// Create the depth texture.
var depthTexture = 0u;

glGenTextures(1, &depthTexture);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 800, 600, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);

Later, I sample from the depth texture as follows:
float depth = texture(depthTexture, texCoords).r;

But even when no geometry has been rendered to that pixel, the depth value coming back is less than 1 (seems to be very slightly above 0.5). This is confusing to me since, per the documentation on glClearDepth, the default value is 1. Note that this is not a problem of linearizing depth since I'm attemping to compare depth directly (using the same near and far planes), not convert that depth back to world space.
Why is my depth texture sample returning <1 when no geometry has been rendered?


texts: Single player game into Multiplayer game(Not online)

texts:
How difficult is it to do this?(Like, do you need to so skilled that you aswell might have created the game yourself) Do you need to change a lot of the code? For example, if I have a single player chess game, where one plays vs the computer. How dooes one make this avaible to play to players offline? Since I no very little about programming, I was hoping that one basically can remove the part controlling the computer, and replace it with a copy of the code for the first player.

Well, for an example:

http://ninjakiwi.com/Games/Tower-Defense/Play/Bloons-Tower-Defense-5.html

To make the question less open, is there likely that making a change like this will require less than 50 hours of work?


texts: Is there a way to apply euphoria physics (ragdoll) to rigged Sprites in Unity2D?

texts: With euphoria physics I mean the realistic object interaction and freefall as seen in most games like recent GTAs. But I want to do that in 2D. (I am a beginner :P).


texts:
I have issue regarding speed in air. When i jump and move simultaneously that time speed of player increase.For jump i am using impuls and for movement i am using force.I want to slow speed when player is in air.

Thanks in advance

Following is my update method ih HUDLayer

-(void)update:(ccTime)dt :(b2Body *)ballBody :(CCSprite *)player1 :(b2World *)world
{

    if (moveRight.active==YES)
    {
            ballBody->SetActive(true);
        b2Vec2 locationworld=b2Vec2(maxSpeed,0);
        double mass=ballBody->GetMass();
        ballBody->ApplyForce(mass*locationworld, ballBody->GetWorldCenter());
      //  ballBody->SetLinearDamping(1.2f);
    }
    else if(moveLeft.active==YES)
    {
            ballBody->SetActive(true);
        b2Vec2 locationworld=b2Vec2(-10,0);
        double mass=ballBody->GetMass();
        ballBody->ApplyForce(mass*locationworld, ballBody->GetWorldCenter());
    //    ballBody->SetLinearDamping(1.2f);

    }

}
Following is jump

-(void)jump:(b2Body*)ballBody:(ccTime)dt:(BOOL)touch
{
    if (touch)
    {

        if (jumpSprte.active==YES)
        {
            ballBody->SetActive(true);
            b2Vec2 locationWorld;
        //locationWorld=b2Vec2(0.0f,98.0f);
            locationWorld=b2Vec2(0,32);
//        double mass=ballBody->GetMass();
            ballBody->ApplyLinearImpulse(locationWorld, ballBody->GetWorldCenter());
      //  ballBody->ApplyForce(mass*locationWorld, ballBody->GetWorldCenter());
            ballBody->SetLinearDamping(1.2f);

        }
    }
}

So where i apply logic??


texts:
My roguelike generates a number of circular rooms. I quite like the current results, which look something like this:

It's generated by carving out random circles in a filled space.

I have one main problem with it: several circles are completely unconnected. I cna't quite figure out what algorithm to use to connect them.

I tried "for each circle, find the nearest circle, and tunnel to its center (horizontally then vertically)," but I get something horrible instead (same map as above):

What seems to be the right fit is something like "for each self-enclosed space, find the nearest empty space and tunnel to it." That seems complexity-hard though (for each circular enclosed space, compute the distance to every other space) and will probably be slow (running on Ruby too)

Is there a simple solution to this problem?


texts: AssetBundles for sprites, or download the images from my server?

texts:
I need to host several sprites in my server, and then have Unity download and use them. I have tested two methods:

AssetBundles

If I pack my sprites into an AssetBundle, the bundle is about 4MB. It works fine.

Download the images

If I download the image bytes from my server, you can use those bytes to create a Sprite. Curiously, this is much, much smaller than an AssetBundle (just like 1.5MB).

Both methods work. It seems pretty obvious that the second one offers an advantage due to reduced memory size. My questions are:

Why is the second method so much smaller?
Is there any reason I'd rather use AssetBundles?