texts: Unity 5.3.5 - Blurry UI text after switching canvasses - until text is refreshed by turning visibility off/on or changing resolution

texts:
I have multiple scenes in my project where the canvas are switched between, each canvas having UI text included on it.

The project was originally created in version 5.0 and I have just updated to version 5.3.5 and I am now encountering the following issue -

The canvas that is active when the scene first loads displays all UI text just fine, but as soon as I switch to another canvas with the exact same text on, the text on the new canvas is blurred. As soon as I turn the text object off/on (via a button click) it appears to refresh it and it all displays fine again.  It is also rectified by changing the display resolution in the editor play window.

It appears as though unless it has a 'refresh' through clicking something else, or is on screen when the scene first loads, it appears blurry.

The font is 'Open Sans Bold' and I am switching canvasses via a raycast script.

I have read issues of text blurriness in 5.3, but most instances appear to be down to the size of the text being in odd numbers which mine isn't.

Screenshots attached. The settings shown are the same for all canvasses and text.

Any help would be appreciated.

Thanks in advance


texts:
I have an application which uses openGL and i have to port it to DirectX.
To sum up my issue : How can I port rotation matrix based on a right-handed coordinate system to a left-handed coordinate system ?
I hardly found some documentation on the internet.

This is what i found on MSDN:

Flip the order of triangle vertices so that the system traverses them
clockwise from the front. In other words, if the vertices are v0, v1,
v2, pass them to Direct3D as v0, v2, v1.
Use the view matrix to scale world space by -1 in the z-direction. To    do this, flip the sign of the _31, _32, _33, and
_34 member of the    D3DMATRIX structure that you use for your view matrix.

This is work fine except i can not flip easily my vertices because i got an 3D model from CATIA which is not a primitive, so i can't use it.

(I'm aware of row-major and column-major difference, it does not matter)

Do you know how i can port my rotation matrix from openGL to DirectX ?

Thanks a lot


texts:
I want to generate circles every 2 seconds, in this case 5 but I can't get it. Instead of creating a circle every 2 seconds, the app wait 10 seconds and draw the 5 circles together. What am I doing wrong?

public class Juego extends SurfaceView{

boolean isItOK = false;

Paint paint;
int CantidadDeEsferas = 5;
int radio, alto, ancho;

public Juego(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);

    paint = new Paint();
}

public void onDraw(Canvas canvas){

    paint.setColor(Color.WHITE);
    canvas.drawRect(0, 0, getWidth(), getHeight(), paint);

    paint.setColor(Color.BLACK);

    for (int i=0; i<CantidadDeEsferas; i++) {

        Random r = new Random();
        alto = r.nextInt(canvas.getHeight());
        ancho = r.nextInt(canvas.getWidth());
        radio = r.nextInt(101 - 50) + 50;
        canvas.drawCircle(ancho, alto, radio, paint);
        run();
        isItOK = true;
    }
}

public void run(){
    while (isItOK){
        try
        {
            Thread.sleep(2000);
            isItOK = false;
        } catch (InterruptedException e) {

            e.printStackTrace();
        }

    }
}

}


texts: How to avoid game objects accidentally deleting themselves in C++

texts:
Let's say my game has a monster that can kamikaze explode on the player. Let's pick a name for this monster at random: a Creeper. So, the Creeper class has a method that looks something like this:

void Creeper::kamikaze() {
    EventSystem::postEvent(ENTITY_DEATH, this);

    Explosion* e = new Explosion;
    e->setLocation(this->location());
    this->world->addEntity(e);
}

The events are not queued, they get dispatched immediately. This causes the Creeper object to get deleted somewhere inside the call to postEvent. Something like this:

void World::handleEvent(int type, void* context) {
    if(type == ENTITY_DEATH){
        Entity* ent = dynamic_cast<Entity*>(context);
        removeEntity(ent);
        delete ent;
    }
}

Because the Creeper object gets deleted while the kamikaze method is still running, it will crash when it tries to access this->location().

One solution is to queue the events into a buffer and dispatch them later. Is that the common solution in C++ games? It feels like a bit of a hack, but that might just be because of my experience with other languages with different memory management practices.

In C++, is there a better general solution to this problem where an object accidentally deletes itself from inside one of its methods?


texts: SMFL C++: IntRect intersection not working?

texts:
I'm trying to find free space to place rectangles, but even though I check for a collision using .intersects() it still places them through each other and somehow doesn't see the intersection happening while it's blatantly there.

This is my code at the moment:

#include "dungeonGenerator.h"

std::map<int, dungeonGenerator::dungeon_room> dungeonGenerator::newDungeon(int x, int y, int n)
{
    srand(time(NULL));
    std::map<int, dungeon_room> rooms;
    bool canPlace;

    for (auto i = 0; i < n; ++i)
    {
        canPlace = false;
        dungeon_room dungeon_room;
        while (!canPlace)
        {
            int height = rand() % x;
            int width = rand() % y;

            int pos_x = rand() % 512;
            int pos_y = rand() % 512;

            sf::RectangleShape room;
            room.setSize(sf::Vector2<float>(height, width));
            room.setFillColor(sf::Color(rand() % 255, rand() % 255, rand() % 255));
            room.setPosition(sf::Vector2<float>(pos_x, pos_y));
            dungeon_room.image = room;
            dungeon_room.collider = sf::IntRect(pos_x, pos_y, width, height);

            if (!rooms.empty())
            {
                auto i = 0;
                for (auto& room : rooms)
                {
                    std::cout << ++i;
                    canPlace = canPlaceRoom(&dungeon_room, &room.second);

                    if (canPlace == false)
                    {
                        break;
                    }
                }
            } else
            {
                canPlace = true;
            }
        }
        rooms[i] = dungeon_room;
    }
    return rooms;
}

bool dungeonGenerator::canPlaceRoom(dungeon_room* room, dungeon_room* target)
{
    if (room->collider.intersects(target->collider))
    {
        return false;
    }
    return true;
}


texts:
I'm using a grid map for a top-down RTS, and using a* for pathfinding. Specifically, I've found one implementation which is heavily optimised, and I've been using it for a while, but now I've realised I only checked it with infantry and not with vehicles, which take more map space, and so I can't rely on the algorithm - what would be "hugging a cliff" for infantry would be passing through it for a vehicle.

So, I'm trying to decide what to do. I see three options.
a. The obvious thing is write my own A* implementation, but this is both very time consuming and I presume I won't reach near the optimised speed of the algorithm I found.
(rewriting the algorithm is out of the question - I just don't have the time to try to read it and understand it).

b. corrections - read the path generated by the algorithm, and either correct it at every step or when receiving the path recalculate it for width.

c. Hold variable sized maps, that are different representations of the free space on the map, on account of size.

Option C sounds to me the simpolest, but is likely to be too memory heavy, even if there're only three-four size categories.
Between options a & b, I'm not sure what is likely to take more calculation time - a non-optimised A*, or running over & correcting a path.


texts: How can I create a persistent seed for each chunk of an infinite procedural world?

texts:
I'm coding a chunk-based 2D game.

I generate chunks as the player explores the world. Chunks follow a procedural generation algorithm (with only one biome implemented at the minute, but I'll introduce more).

When the player leaves a chunk however and it's unloaded, that chunk is lost for good (unless they modified the chunk; if that is the case, I save it). This is because with each new chunk I generate, I generate a new random seed for it.

I introduced a world seed into my world. My chunks also have 'world coordinates', ie the first chunk you spawn in is at (0, 0) and the chunk to the right is at (1, 0), etc, in world coordinates.

I was thinking about ways I can combine the world coordinates and world seed in order to obtain a chunk seed. That way, since I always know the world seed and always know the world coordinates, I could obtain the same chunk seed in order to make sure the same chunk comes back after the player leaves it (and the chunk is unloaded) and then returns to that location in the world when it has to be reloaded.

Some of the ways I thought of were as follows:

Use a simple equation like abs(world seed * world_coordinate_x * world_coordinate_y) where the absolute value function enforces a postive chunk seed.

This would not be an acceptable equation to use as the equation would give the same chunk seed for the world coordinates (x, y), (y, x), (-x, -y), (x, y), etc, resulting in a pretty dodgy pattern to the world.

I know games like Minecraft accomplish this, but I cannot find a way to obtain a chunk seed based off of the world coordinates and world seed without there being a weird symmetry in my world generation.

What seed generation method can I use to avoid these symmetries or obvious correlations?


texts: Creating and joining a multiplayer game over a LAN

texts:
I'm trying to create and join a multiplayer game that has been created from a custom UDK installation.

It works correctly when two (or more) instances of the game are created on the same computer and are connected over localhost by running the following commands:

udk.exe server map_name
udk.exe 127.0.0.1

The problem comes when trying to connect to the game server over a LAN (with the command udk.exe server_ip_address); the clients are unable to connect and the default map is loaded. The server log reports a client disconnection from the computer trying to connect. The client log reports the error, Error: Can't start an online game that hasn't been created.

Both computers are able to ping each other, as well as both having their firewalls disabled. Many combinations of the command-line arguments for starting the server have been tried. Creating an installer from the server machine and installing a fresh copy of the game on the client has also been tried.

Any solutions on how to solve this issue would be appreciated.


texts: How to prevent clicking through object in GameMaker

texts: I've been making my first, simple game in Game Maker. You have to click a moving ball (obj_ball), each time you click it, it wil start moving faster. I wanted to add a way to lose the game: if you would miss a ball, it would redirect you to another room. I tried creating a new object (obj_gameover) covering the whole backgroud and adding a 'left pressed' event with a proper execute line to it, but whenever I click on a obj_ball, it also clicks on a obj_gameover, executing events from both objects. Is there any way to fix my problem?


texts:
sorry for my english.
Im relative new to flash game development,
Im creating a game and I need some big size mp3 files.
If I add them into flash, .swf file will be too big.
I guess I need to host mp3 files somewhere and use URL Request?
Where can I upload mp3 files so they are always ready for use?


texts: d3d11 black texture when manually creating from image (Rust)

texts:
I am trying to create a ID3D11Texture2D from a RgbaImage loaded from a .jpg. The below code produces no errors. However, the texture is black when it is actually rendered. I know the standard way to load textures is through the DirectXTex library, but I was having issues linking with it and can't find any premade Rust bindings.

Should the below code/settings work to create a working ID3D11Texture2D?
Is there a way to view the contents of a ID3D11Texture2D in order to debug?
Are there DirectXTex bindings for Rust?

fn load_resource_from_file(device: &Device, path: &Path) -> error::Result<Texture> {
    unsafe {
        let image = Reader::open(path)?.decode()?.to_rgba();

        let mut sample_desc = dxgitype::DXGI_SAMPLE_DESC::default();
        sample_desc.Count = 1;
        sample_desc.Quality = 0;

        let mut desc = d3d11::D3D11_TEXTURE2D_DESC::default();
        desc.Width = image.width();
        desc.Height = image.height();
        desc.MipLevels = 1;
        desc.ArraySize = 1;
        desc.Format = dxgiformat::DXGI_FORMAT_R8G8B8A8_UINT;
        desc.Usage = d3d11::D3D11_USAGE_DEFAULT;
        desc.SampleDesc = sample_desc;
        desc.BindFlags = d3d11::D3D11_BIND_SHADER_RESOURCE;
        desc.CPUAccessFlags = 0;
        desc.MiscFlags = 0;

        let mut data = d3d11::D3D11_SUBRESOURCE_DATA::default();
        data.SysMemPitch = (image.sample_layout().width_stride * mem::size_of::<Rgba<u8>>()) as u32;
        let buffer: Vec<u8> = image.into_raw();
        data.pSysMem = buffer.as_ptr() as *const _;
        data.SysMemSlicePitch = buffer.len() as u32;

        let mut texture = ptr::null_mut();
        device.as_ref().CreateTexture2D(
            &desc,
            &data,
            &mut texture,
        ).result()?;
        let texture = NonNull::new(texture).ok_or(null_ptr_err!())?;

        drop(buffer);

        let mut resource_view = ptr::null_mut();
        device.as_ref().CreateShaderResourceView(
            &**texture.as_ref() as *const d3d11::ID3D11Resource as *mut _,
            ptr::null(),
            &mut resource_view,
        ).result()?;
        let resource_view = NonNull::new(resource_view).ok_or(null_ptr_err!())?;

        Ok( Texture(Arc::new(TextureInner {
            texture,
            resource_view,
        })))
    }
}


texts: How Would I create alternate players (Turn base Event)

texts:
The picture above shows 2 players.  Each containing 3 characters.  I want to know how to make a Turn based event starting with player 1 alternating turns with player 2.  And in every alternation each character gets a turn.  If a character dies, the next character on the same team goes, and so on.

How would I create this?  Is there a tutorial?  I haven't made any turn-based games so I don't know how to program these kinds of stuff.


texts: OpenGL - Updating VAO array buffer range

texts:
I am trying to stream data to a buffer which I have bound to a VAO vertex buffer binding point that I want to access through vertex attributes in the shader.

Usually I stream to buffers which I have bound as GL_UNIFORM_BUFFERs and I do it like this:

//create an immutable data storage
glNamedBufferStorage(uboID, capacity, data, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);

//map entire storage forever
mappedPtr = glMapNamedBufferRange(uboID, 0, capacity,  GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);

//bind buffer to target(GL_UNIFORM_BUFFER) binding point
glBindBufferBase(GL_UNIFORM_BUFFER, uboBinding, uboID);

//bind shader interface block to target binding point
glUniformBlockBinding(shaderProgramID, blockIndex, uboBinding);

Now the uniform block can be accessed in the shader program and i can stream to it like so:

//copy data to mapped pointer at stream offset
memcpy(mappedPtr + uploadOffset, &uploadData[0], uploadSize);

//This is the important part: tell the shader which range of the buffer to use
glBindBufferRange(GL_UNIFORM_BUFFER, uboBinding, uboID, uploadOffset, uploadSize);

//increment offset
uploadOffset += uploadSize;

If I bind a buffer to a VAO and access its data as vertex attributes in the shader, I don´t know how to give the shader the range in which the updated data can be found. I can give an offset when binding a buffer to a VAO when calling glVertexArrayVertexBuffer, but it has a few more parameters and does not seem like the right thing to call every frame. I have not gotten it to work with it, too.

Is there something like glBindBufferRange for vertex buffers bound to VAOs?


texts:
I am attempting to make a 2d side-scrolling platformer where the player collects other characters as they advance through the levels, like you would in a classic top down rpg. However, I am having a huge issue in getting the other members of the party to actually follow the leader's direct path. I can get them to follow smoothly, however, I want them to follow the players direct path at an offset from the player.

Most codes I have found tutorials or any advice over seem to only address following the player smoothly, however, it doesn't work very well for platformers, where the party members should do exactly as the player does, slightly delayed. Is there anyone who has advice for achieving this behavior? It's been killing me for the past few days trying to make it work, in all honesty.


texts: AABB test does not consistently detect edge-to-edge contact when bounds are very different in size

texts:
My function compares two AABBs for collision detection, and when they are around the same size it works fine, but I noticed that if I greatly decreased the size of one of them (or augmented the size of the other), then the collision wouldn't be detected correctly; I would have to have them intersect for a collision to be registered, rather than having it register when they are at least in direct contact, which is the intended behavior.

Below is my code:

local function DetectCollision(a, b) -- AABB to AABB
  local collisionX = (a.Position.X + a.Size.X) >= b.Position.X and (b.Position.X + b.Size.X) >= a.Position.X
  local collisionY = (a.Position.Y + a.Size.Y) >= b.Position.Y and (b.Position.Y + b.Size.Y) >= a.Position.Y
  local collisionZ = (a.Position.Z + a.Size.Z) >= b.Position.Z and (b.Position.Z + b.Size.Z) >= a.Position.Z
  return collisionX and collisionY and collisionZ
end

To be more specific, the issues start to occur when I cut the size of one of the AABBs in half. For instance, if I had two cubes where one's size is 12 on all axes and the other is 6 on all axes, then the collision will not register. Upon debugging, I noticed that only one of the collision bools will become false. This seems to depend on what axis the smaller bounding box moves from in relation to the bigger one, so if I moved the smaller AABB away from the bigger one on the y-axis, then collisionY will be false.


texts: Creating the Animations in C++ from 3DS Max

texts:
I'm reading from the FBX format and I'm using Bones to animate an object, and I'm at the point where I have to decide on the code that actually moves the vertexes.

So far I thought on two methods:

Create a bone class that has an array of XYZ and an array of vertexes addresses and the weight. The array of XYZ (and rotations' values) will be filled from their positions/rotations at every frame.
My model object will have an array of this bones class, and at each call I'll update the vertexes by multiplying the bones' XYZ for the vertexes, something like:

for(int i = 0; i < object->bonesCount; i++)
{
    for(int j = 0; j < object->bones[i]->vertexesCount; j++)
    {
        object->bones[i]->vertex[j].xyz *= object->bones[i].xyz; //plus rotation
    }
}

And the second method is having an array of vertexes * amount of frames, I do something like the above code and I save each vertexes' positions at every frame in the array, so I don't have to call the loop above (I think it might impact performance), but I'd have much more arrays to work with.

So my questions are, (1) which is the best approach for this, and (2) is there another method I didn't think of?
Any info related to this is appreciated, as I have nothing done yet and I'm still elaborating on how it should be before I start coding (I try to avoid doing the first thing I come up with so there's less chances of needing to recode it later).

Thanks!


texts: Implementing a game in Unity without Unity Networking

texts:
I have been programming in Unity for a while, and ever since I started I could not wrap my head around the Unity Networking system. I understand on a whole how it works, I even made a small project using it, but it has always seemed to me like I did not have much control over the system (e.g. managing the streams of data, the lack of documentation about more advanced topics). Therefore, I would like to try to implement a peer-to-peer game without Unity Multiplayer.
My current project has a lot to do with movement ( take for example a fighting game, a brawler), where there is real-action constantly being streamed. It is important that when something gets hit, killed, crashed into, the players get the update immediately. I know a few basic thing about socket programming and I am ready to learn even more. I imagine the system being based on byte arrays messages, that trigger specific actions on each player. For Remote Procedural Calls (RPCs), this looks like a good solution, but what about streaming the constant position of a player? How can I stream it fast and easy without overloading the network channel?

I would like to hear different approaches to this problem.


texts: drawing meshes so that they respect the position in space (doesn't draw on top of another mesh if behind it)

texts:
How can i make my meshes be drawn taking in account which one is in from of another? i.e. if i have a mesh that is farder than another it should be drawn behind the second.

Is there a way to do this in xna that is more standardized or do i have to calculate for each mesh myself? If i have to calculate for each mesh by myself, from which point do i calculate the distance to the mesh? the camera position?

Here is how i draw them :

        Matrix[] transforms = new Matrix[gameobject.model.Bones.Count];
        gameobject.model.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (ModelMesh mesh in gameobject.model.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.Projection = camera.projectionMatrix;
                effect.View = camera.viewMatrix;
                effect.World = transforms[mesh.ParentBone.Index] * gameobject.orientation;
           }
            mesh.Draw();
        }


texts:
I am building a game using Monogame 3.6 and Visual Studio Community 2017. Up until this point I have been serializing the data using BinarySerialization and created a custom ContentImporter and ContentProcessor.

My question is what is the standard used for saving game data and where is it saved? I attempted to use the IntermediateSerializer class, but that was stored in XML and is easily modified. I would like to store the game data in a file that is more difficult to tamper with, which is why I chose binary serialization.

I would also like to see an example of code that uses the standard for file paths when saving to the file system. On my development system, I can save anywhere because I am Administrator. But I would like to understand which parts of the framework are available for me to get file path information and save the data.


texts: How does browserquest handle tiles above players

texts:
How does browserquest handle tiles above an player?

For example:

When the player stands in front of the tree. the player will be displayed on top of the tree.

When the player stands next to the tree, the tree will be displayed on top of the player.

When the player stands behind the tree, the tree will be displayed on top of the player.

How is this possible? If possible give an example in javascript.


texts: What organic traffic can I expect from publishing on Google Play, without other marketing?

texts:
I've just published a new Android game on Google Play. It has been a bit over 48 hours.  It's active in the store, and I can search for it by name to get to it.  However, I've had 0 organic downloads thus far, only a couple from my friends. As far as I know, it has not been shown in the "new games" list yet, and the only store listing views in the stats are the ones from myself and friends.

Is there some time by which I can expect some "organic" exposure, or will I ever?  Is promoting my game by other channels the only option?

I'm not asking for advice on promoting my game. I'm only asking about what organic exposure I can expect on Google Play.


texts: How can SDL tell what Xbox360 controller is what player?

texts:
I init my controllers like this:

if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 1)
    return;
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);

int nJoysticks = SDL_NumJoysticks();
numGamepads = 0;
for (int i = 0; i < nJoysticks; i++)
    if (SDL_IsGameController(i))
        numGamepads++;

if (numGamepads > 0)
{
    for (int i = 0; i < numGamepads; i++)
    {
        SDL_GameController* pad = SDL_GameControllerOpen(i);
        if (SDL_GameControllerGetAttached(pad) == 1)
            joysticks.push_back(pad);
        else
            cout << "SDL_GetError() = " << SDL_GetError() << endl;
    }
    SDL_GameControllerEventState(SDL_ENABLE);
}

and I poll events like this:

SDL_Event sdl_Event;
while (SDL_PollEvent(&sdl_Event))
{
    switch (sdl_Event.type)
    {
    case SDL_CONTROLLERDEVICEADDED:
        cout << "DEVICEADDED cdevice.which = " << sdl_Event.cdevice.which << endl;
        break;
    case SDL_CONTROLLERBUTTONDOWN:
        cout << "BUTTONDOWN cdevice.which = "<< sdl_Event.cdevice.which << endl;
        HandleGamepadButtonsDown(sdl_Event);
        break;
    case SDL_CONTROLLERBUTTONUP:
        HandleGamepadButtonsUp(sdl_Event);
        break;
    case SDL_CONTROLLERAXISMOTION:
        HandleGamepadAxis(sdl_Event);
        break;
    case SDL_QUIT:
        _quit = true;
        break;
    default:
        break;
    }
}

With this I have currently two Xbox 360 controllers connected. On these pads there is a LED indicating if it is player 1, 2, 3, or 4.

When I run this my poll loop prints out this when I press a button on this controller:

When I hit a button on the controller with the player 2 LED it prints:

So that is wrong. How can I from inside the code find out what controller corresponds to the controller with the right LED light on?

Also, when I first start it then it prints:

So the controllers are 0 and 1 when I add them but 1 and 2 when I run the game.


texts: How to split a screen in half using LibGDX without scaling?

texts:
I am currently working on a racing game with libGDX and I need to split the screen in half for a two-players mode. (Player 1 in first half and Player 2 in second half).

I already have Camera1 that will follow Player 1's car, and Camera2 that will follow Player 2's car.

Basically, I want the first half to show Player 1's car and the second half to show Player 2's car.

I have been searching for a while online for a way to split screens with LibGDX and found how to split the screen in two with this code:

/*Left Half*/
Gdx.gl.glViewport( 0,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() );

/*Right Half*/
Gdx.gl.glViewport(Gdx.graphics.getWidth()/2,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() );

However, it squeezes the screen into the right half, which is not what I want.

Is there a way to split the screen without squeezing it?


texts: How can I verify if there is no object between 2 others?

texts:
I have 2 characters in my 2D game, I would like that if both of them are on the same Y axis, and there is no collider/object between them, for an animation to happen. I can't figure out how to check for the last one though... Thanks for the help!

EDIT :

Hello, I have used MrCranky's code and it seemingly looks like it should work, but I am having a problem with the syntax I think. Physics.Raycast((x,y) of the 1st player, new Vector3 (1,0,0), distance between them -2) So this code, if there is nothing between the player and the other character, it should give me a false. And it worked, but the problem is, even after I added an object between them, it stayed on false through every update, could you assist me with what am I doing wrong please?


texts: I have mice looking and walking in my game, but they are very slow and hard to use. I think it's because I'm using fixed speed. I heard that in big projects developers use delta time. How do I calculate delta time in glut? How do I calculate speed using delta time?


texts:
I'd love for my partner, the artist, to be able to animate using flash movieclips and timelines.  Then I, the programmer, would like to read the raw Flash info and re-program it into my engine of choice (which happens to be Torque2D).  The data I'd want is

the bitmap images that were used in Flash, like the head and body
the links between the images, like where the head connects to the body
the motion data from the flash animation, like move, rotate (at what speed), shear, etc. for the head or arms or whatever.

Is there any way to get this data?

Here's what I know so far.

There are tools like SWFSheet and Spriteloq that convert the entire flash animation into a frame by frame sprite animation (in a sprite sheet).  This would take too much space in my case, so I'd like to avoid that.  Re-animating on the fly would take much less texture memory.
There is a PDF that describes the SWF file format but NOT the individual components like the movieclips.

So anyone know of a library I can use, or how I can learn more about the movieclip components and whatnot?

(more better tags: transform, export, convert)


texts:
I'm making a 2D Server/Client game, I have very little to no problems with the server but now I want to work on the client side code.
I'm thinking about using a JFrame and all the other GUI classes/methods.
My question is how do I change the GUI and all things that are displayed.
For example if the user opens the client I want him to login or register, if they logged in I want the client to display the game. Do I just display the new elements and delete the old or is there a other solution? I don't want to use 2 frames.


texts: Ledge Detection with Plane Intersection?

texts:
i am working on a ledge climb system and I am currently refactoring it to make it more reliable.

I am tracing with a sphere towards infront of my character. If it found something, I trace downwards. However, with steeper angles, this produces non-reliable results.

I searched the Web a lot and it looks like that a Plane Intersection algorithm seems the best method, however I am not sure how to implement this.

My idea was to first trace towards the wall again and define a plane out of the point and the hitnormal.
Then I trace downwards again and do the same.
I then use the cross-product of both normals to retrieve the direction of the Plane Intersection.

And now I am lost on how to go further.
I am not sure how to implement the actual plane intersection in Blueprints.

I want to avoid using traces alone because I want to have small cracks that need to be grabbed without any additional collision hints etc.

Does someone have a clue for me how to implement this?
(Not a genius in maths, some tips would be nice though)


texts: Unexpected behaviour after adding animator and Unity editor crash

texts:
I have realy strange problem which accured after adding animator(I suppose) to prefab Object. Situations looks like follow:

I had object which have only sprite renderer, collider2D and script (movement behaviour) attached. It worked perfect on editor mode, ramote or any kind of platform (PC/Mobile).
Then I added animator controller and some animations. Everything looked good until I made build for android.

First problem occured and it manifested as follows: when I spawn prefabObject described above game stuck and reset player position to 0,0 (by the way this object spawn at 0,0). The strange thing is that this bug occur onyl on android build. In editor mode, remote and PC build game works perfect.
First thing first I though that prefabObj is broken or damaged...so I create new one with same settings and components. Nothing has changed. Situation looks the same.

The second strange thing is that I have another objects with animator and they work properly. But is not over...
I updated Unity to newest version to check if its not problem with software. After that it was even worse. Console show me tons of error like: Invalid AABB a and so on. Fortunately I found solution to that. I was problem with particle system attached to some objects. I turn off all particles and I have no more errors...but it makes Unity editor unusalble. Everytime after press play button Unity crash with following message:

  unity the memory file is corrupted  position out of bounds.

Only way to make unity usable again it was to replace project's file with backup one (with particle system turned on).

After all it does change anything. With old or new Unity version, with or without particle system, problem with game build on android stayed unchanged.

I tried several things like:

anmation with exit time and witout
with animation event and without
with script support

It always looks the same: stabile on editor, remote or PC build but stuck on mobile.

At this moment I totally have no idea what is wrong and how to solve it.

I will be very grateful for any advice, or hint

P.S I don't belive it is a problem with performance. There is no more than 10 objects in one time on screen (2D) and animation is like change scale from zero to one.


texts:
Setting

I am designing a 2d game in which a \$1/r^2\$ force acts between moving charged particles, and the number \$n\$ of particles is very large. To calculate the force between all pairs of particles is about \$n^2/2^2\$.

Questions

How well does this scale in practice when there are hundreds or
thousands or particles? (And considering that graphical output is simple, so that we want to compute the positions of all particles ~60 times per second.)
If scaling is bad, how can I simplify the game design such that – in practice – it's not an issue any more? (For example, I have thought of constraining all particles to a lattice of discrete sites, but then I don't know how movement in arbitrary directions would work).


texts: How can I load another form containing a new level when my player reaches the current level's exit?

texts:
I am coding a very basic side-scrolling game in C#, using Windows Forms.

I want to connect my game's levels with 'exit points'. When the player touches an exit point, a new form should be loaded immediately. How can I do this?


texts: How to change the mesh of the character in UE4?

texts:
I made a Bellsprout mesh in Blender, exported it as an FBX file, and imported it into UE4.

I can insert it in the stage without problem, but I would like to use this Bellsprout mesh to replace the mesh of the built-in character.

Even clicking and dragging will not replace the mesh:

I've looked into importing between blender/UE4: https://wiki.unrealengine.com/Static_Mesh_from_Blender

And also about mesh editing: https://docs.unrealengine.com/en-us/Engine/Content/Types/StaticMeshes/Editor

I also looked at some questions in this forum: Changing rendering in UE4 and Making only parts of a mesh destroy in UE4

To see if the question had not already been asked.


texts: How can i draw a curve in modern Opengl?

texts: OpenGl is capable of rendering points, lines, triangles and quads;  but what if i want to draw a bezier curve? I read online you should use something called GL_STRIP, but the solutions were using either legacy Opengl, or they were not explaining well the process. The question is: How can i render bezier curves in Modern Opengl? I'm using C++.


texts: Drawing behavior when a fragment is written to multiple times in a single pass

texts:
This seems really basic, but I'm confused and can't find a clear answer anywhere.

What happens to a target fragment of a rendertarget if the fragment is written to multiple times within one pass (e.g. by drawing two identical triangles above each other), assuming depth and stencil testing is disabled?

Does this just use the behavior specified with the current blend state? If not, can I modify this behavior?


texts: How do I combine mesh to all move together with an armature?

texts: I can't figure out how to make all these parts move together. I joined them, however, they are still separate? How do I make my model move its parts together?


texts: What are the pros. and cons. of different representations a custom geometry format for a mobile based engine?

texts:
I am trying to create 3D model importer for my mobile based engine.

These are what I am considering:

Convert .obj file to text based structure like JSON or custom.

So, basically, convert .obj file to structure to fit my engine, so, it could be a little bit faster for loading time.
Pros: Easy, and cross platform.
Cons: This is text file, and maybe could be slow for parsing and string manipulation?

Convert .obj file to Binary that fits to my engine.

Use serialization and save with specific structure to binary format
Pros: Faster
Cons: It may painful for multi-platform like Java and Objective-c?

Convert .obj file to .java or .h(.m) file, and attach to source code.

Export .obj file as .java and .h(.m), so I can use inside of code
Pros: Easy and Faster(?)
Cons: (?)

First time, I didn't know about #3 method, but I found some article that people doing this for simple small game. And my game is also small too, so I am considering more #3 method.

Which method is popular and is there more pros and cons ?


texts:
Hey I'm trying to get a smooth animation for my player movement. Earlier I changed my frames to render at fixed time(1/60 sec). Well that makes my player now run at a constant speed but the animation now appear to be choppy and it seems like the player jumps from one point to another instead of smoothly transitioning between them.
Below is my code and an gif animation of player movement. How do I make the animation appear smooth?

float deltaTime = 0;
float oldTime = 0;

//The direction in which the player will move
int playerX = 0;
int playerY = 0;

//callback method for keyboard events
void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
    if (key == GLFW_KEY_W && action == GLFW_REPEAT) {
        playerX = 0; playerY = 1;
    }
    if (key == GLFW_KEY_S && action == GLFW_REPEAT) {
        playerX = 0; playerY = -1;
    }
    if (key == GLFW_KEY_D && action == GLFW_REPEAT) {
        playerX = 1; playerY = 0;
    }
    if (key == GLFW_KEY_A && action == GLFW_REPEAT)
    {
        playerX = -1; playerY = 0;
    }
}

//update player's position
void update() {
    player->move(playerX, playerY, TIME_PER_FRAME);
}

//set up glfw keyboard callback function and other stuff
void init() {
    glClearColor(0, 0, 0, 0);
    player->bindVertexAttributes(shader.getAttributeLocation("position"));
    glfwSetKeyCallback(window->getGLFWWindow(), keyboard_callback);
}

//wait logic
float expected_frame_end = glfwGetTime() + TIME_PER_FRAME;
void wait() {
    while (glfwGetTime() < expected_frame_end) {

    }
    expected_frame_end += TIME_PER_FRAME;
    playerX = playerY = 0;
}

//rendering function
void render() {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    player->setUniformMatrixLocation(shader.getUniformLocation("projectionMatrix"), shader.getUniformLocation("transformationMatrix"));
    shader.useProgram();
    update();
    player->render();
    wait();
    shader.stopProgram();
}

//main function
int main(int argc, char** argv) {
    init();
//main loop
    while (!glfwWindowShouldClose(window->getGLFWWindow())) {
        render();
        window->swapBuffers();
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}


texts: How do I get URL parameters from a Flash game (developed with Unity3D)?

texts:
I made a simple Flash game in C# using Unity3D. It interacts well with a web page: There is a textbox for the player to type their name and that name is used in-game.

Now I want to pass the player's name into my game as a URL parameter. How can I read URL parameters from within a Flash game?


texts:
I've looked at this technique, but it strongly sounds like he has to do some ugly hacks involving branching in his lighting shaders just to correctly draw a skybox. This seem awfully wasteful.

How can I most efficiently implement a skybox with a renderer that uses deferred shading?


texts: Why are there no in game time subscription options?

texts:
Many games employ a monthly subscription to play a game. However, this makes coming back to a game pretty difficult, as you are most likely unsure of whether you will be playing the game for a few months or a few days.

Why are there no games where you subscribe for in game time (or why is it not common practise)? That would allow returning players to either have some game time left when they return, or not feel so bad for buying more game time in the case they end up playing the game for only a couple of days. I believe a monthly subscription could exist alongside an in game time subscription. Currently, this is stopping me from playing a couple of games.


texts: How do I detect collision with isometric walls?

texts:
I will use game called "Project Zomboid" as an example. Here is a pic how does it look >

How should I handle player's collision with walls constructed like that? It's easy to handle walkable and not walkable tiles for player, but this is different and I have no ideas how to solve this problem. Any tips?


texts:
I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.

This is the texture part of my OpenGL code:

glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);

glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
    brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);

Here is the fragment shader:

uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;

void main() {
    vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
    gl_FragColor = vec4(tex, 1.0);
}

I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?


texts:
I'm new to programming and game programming.
I've reading something about vectors and math, but I have a question - where do I use vectors in game programming? Maybe anyone can give a simple example where you are using vectors (in 2D)?

I've found examples but mostly they are in the console where they output numbers, and big examples which I don't understand.


texts: Is it reasonable to write a game engine in C?

texts: Even though C++ appears to be king, from what I've been told C is still widely used in games, especially on the consoles. However, would writing an entire game engine in C be unreasonable today? What are, if any, some advantages that C has over C++? Why would someone possibly want to use C over C++?


texts:
Is there a known good way to have a "computer" opponent play a Match 3 game? It doesn't have to be fancy, or even considered fair. If the AI always takes the best move on the board that would be OK with me. Note that a valid move is one that doesn't make a match.

Edit:
What I am currently doing is a brute force approach. I look at every tile on the board, and see what the best move that tile can do. I add it to a collection and give it a score (based on how many it will match 3 or 4). Once I have traversed the entire board I use the move with the  best score. In the event of a tie I pick one.

If a 5 match combo is found I short circuit out to that one. 5 is the highest combo you can get)

I may not be able to improve it, but it feels like this should have been solved already.


texts:
I'm inexperienced and I'm trying to understand the mechanism for using a ladder with my character or climbing over small walls.
To move I use a Rigidbody, not Kinematic, but with AddForce. I tried to create an object to simulate a ladder to climb on. To get my character into contact with the ladder I inserted a Collider trigger on the ladder and called the OnTriggerStay function.
After working a bit, I used a bool such that  my character can go up or down the ladder when he's close enough, but I don't understand some things.

First of all, is the script better to put on the character or create one on the ladder?
The second thing is once you get to the top how do I insert a function correctly and make my character complete the climb, making it arrive above the object where the staircase is located?
Do I have to get to the top, destroy the game object and respawn at a point just above the ladder? What is the best way to do this?

Here's my code:
private Rigidbody rb;
public bool ladderClimb = false;
void Start()
    {
     rb = GetComponent<Rigidbody>();
    }

 void Update()
    {
     if(ladderClimb){
directionRot = new Vector3(0, 0, 0);  //direction of rotation
movement = new Vector3(0, Input.GetAxisRaw("Vertical"), 0).normalized; //object movement
  rb.useGravity = false;}
   else rb.useGravity = true;
}

    void OnTriggerStay(Collider collider){
     if(collider.gameObject.tag == "ladder"){
     if(Input.GetKeyUp(KeyCode.E)) ladderClimb = !ladderClimb;}}

void OnTriggerExit(Collider collider){
   if(collider.gameObject.tag == "ladder") ladderClimb = false;}


texts:
I am very confused by the PUN implementation of the Photon networking engine. It looks like I don't have to write a separate server so I'm very curious how this works. I have done quite some KryoNet developing and fiddled around with LidGren, these libraries require you to create a server and client.

The client sends minimum data to the server.
The server verifies this data and runs the gameplay logic from it.
The server sends back minimum data so the client can update to the current server state.

Since PUN does not allow me to write my own server how does PUN work? I believe there is a server behind PUN but if it's the clients job of verifying the data this is a vulnerability.

So whats the deal with Photon? Can a competitive game make use of PUN?


texts: How to capture image from camera with post effects? Mysteriously only get emission(?) pass

texts:
I have a separate camera from my main camera, whose purpose is to take screenshots, or render a "live feed" of the action, at different angles.  Hierarchy as such:

The game object labeled as "main camera" captures the 3D scene just like a normal main camera would, including post-processing components.

The GUI camera captures just the UI layer.
The canvas and image are simply a watermark, rendered by the GUI camera.  I have removed this and it has no bearing on the issue at hand.

I point both the main camera and GUI camera to the same target render texture.  The result of the render texture appears to be correct in the inspector.

One way or another, it appears that I can only get access to the "bloom," and nothing else:

(On black so it's easier to see.)
If I assign the render texture onto a Raw Image canvas element, it only shows the "bloom."
If I try to convert the render texture to a regular texture, it also only shows the "bloom."
RenderTexture.active = renderTexture;
destination.ReadPixels(new Rect(0f, 0f, renderTexture.width, renderTexture.height), 0, 0);
destination.Apply();

(I have also tried AsyncGPUReadback.  Its resulting texture looks like a flat gray without variance in the inspector.)
I have found if I disable post-processing, everything works as intended, no changes required.  Of course, I am missing the post processing, which I want!
Somehow, somewhere, Unity is getting data external of the texture itself, depending on context:

Using Unity's ReadPixels method only picks up the "bloom."
Using Unity's EncodeToPNG method only picks up the "bloom."
Putting the RenderTexture on a Raw Image only picks up the "bloom."
If I use a separate PNG encoder using the same Color32 data, I get the final correct image.
The inspector successfully renders the final correct image.

I have actually run into this issue multiple times, and never found a proper solution, and definitely never a real-time solution, which I now desperately need.


texts:
For my opengl video player app, I am using surface texture bound to GL_TEXTURE_EXTERNAL_OES

source : https://github.com/crossle/MediaPlayerSurface/blob/master/src/me/crossle/demo/surfacetexture/VideoSurfaceView.java

In my fragment shader, I want luminance value to be taken for 3x3 block.

vec2 tex00 = vec2(vTextureCoord.x-xmargin, vTextureCoord.y-ymargin)
vec4 p00 = texture2D(sTexture, tex00)

... etc for 3x3

and then calculate luminance of each texel : ie: p00 by doing dot of p00.rgb with vec3 of (0.3,0.59,0.11).

Instead is it possible to directly use p00.y ? Will it give luminance value?


texts: Libgdx app closes immediately after opening

texts:
I have a libGdx app, and I am running it using android studio.

It closes immediately after starting it and I see no error report.
Could anyone help?

Starfield.java

public class Starfield extends ApplicationAdapter {

    private static final float STAR_DENSITY = 0.01f;
    ShapeRenderer shapeRenderer;
    Array<Vector2> stars;

    @Override
    public void create() {
        // Initialize a shapeRenderer
        shapeRenderer = new ShapeRenderer();

        // Call initStars
        initStars(STAR_DENSITY);

    }

    public void initStars(float density) {
        // Figure out how many stars to draw. You'll need the screen dimensions,  which you can get using
        // Gdx.graphics.getWidth() and Gdx.graphics.getHeight().
        int screenHeight = Gdx.graphics.getWidth();
        int screenWidth = Gdx.graphics.getHeight();

        // Create a new array of Vector2's to hold the star positions
        stars = new Array<Vector2>((int) (screenHeight * screenWidth * density));

        // Use java.util.Random to fill the array of star positions
        Random random = new Random();

        for (int i = 0; i < stars.size; i++) {

            int x = random.nextInt(screenWidth);
            int y = random.nextInt(screenHeight);

            stars.add(new Vector2(x, y));

        }

    }

@Override
public void resize(int width, int height) {
    shapeRenderer = new ShapeRenderer();
    initStars(STAR_DENSITY);
}

@Override
public void render() {
    // Make the night sky black
    Gdx.gl.glClearColor(0, 0, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Begin a shapeRenderer batch using ShapeType.Point
    shapeRenderer.begin();

    // Loop through the star positions and use shapeRenderer to draw points
    for (Vector2 vec: stars) {

        shapeRenderer.point(vec.x, vec.y, 0);

    }

    // End the shapeRenderer batch
    shapeRenderer.end();

 }

    @Override
    public void dispose() {
        // Dispose of our ShapeRenderer
        shapeRenderer.dispose();
        super.dispose();
    }
}

Here is the gradle log

Run build   1s 241ms
Run init scripts    33ms
Configure settings  1ms
Configure build 327ms
Project :   326ms
Resolve dependencies :classpath 200ms
Resolve dependencies :android:classpath 0ms
Calculate task graph    26ms
Project :desktop    15ms
Project :core   3ms
Run tasks   824ms
:core:compileJava   82ms
Resolve dependencies :core:compileClasspath 5ms
:core:processResources  3ms
:core:classes   1ms
:core:jar   16ms
:desktop:compileJava    73ms
Resolve dependencies :desktop:compileClasspath  14ms
:desktop:processResources   2ms
:desktop:classes    0ms
:desktop:run    642ms
Resolve dependencies :desktop:runtime   3ms

EDIT: I got an error, dumb me, I did not see the console.

Exception in thread "LWJGL Application" java.lang.IllegalStateException:    autoShapeType must be true to use this method.
at com.badlogic.gdx.graphics.glutils.ShapeRenderer.begin(ShapeRenderer.java:198)
at gamedev.starfield.Starfield.render(Starfield.java:87)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:215)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)

Thanks, any help would be appreciated.


texts: Specular light flickering with high specular power

texts:
I'm having some issues with specular lights, to be more specific, the specular color seems to be flickering when I set high power, like 512 (I set the specular color to green, so you can see better):

http://i.imgur.com/PY0cmJA.gif

And when a power like 32 is used, everything seems ok:

Pixel shader hlsl:

pin.NormalW = normalize(pin.NormalW);

float3 toEyeW = normalize(gEyePosW - pin.PosW);

// Start with a sum of zero.
float4 ambient = float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 spec    = float4(0.0f, 0.0f, 0.0f, 0.0f);

// Sum the light contribution from each light source
float4 A, D, S;

ComputeDirectionalLight(gMaterial, gDirLight, pin.NormalW, toEyeW, A, D, S);

ambient += A;
diffuse += D;
spec    += S;

float4 litColor = ambient + diffuse + spec;

litColor.a = gMaterial.Diffuse.a;

return litColor;

ComputeDirectionalLight function:

void ComputeDirectionalLight(Material mat, DirectionalLight L,
  float3 normal, float3 toEye,
out float4 ambient,
out float4 diffuse,
out float4 spec)
{
      // Initialize outputs.
      ambient = float4(0.0f, 0.0f, 0.0f, 0.0f);
      diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f);
      spec = float4(0.0f, 0.0f, 0.0f, 0.0f);

      // The light vector aims opposite the direction the light rays travel.
      float3 lightVec = -L.Direction;

      // Add ambient term.
      ambient = mat.Ambient * L.Ambient;

      // Add diffuse and specular term, provided the surface is in
      // the line of site of the light.

      float diffuseFactor = dot(lightVec, normal);

      // Flatten to avoid dynamic branching.
      [flatten]
      if (diffuseFactor > 0.0f)
      {
          float3 v = reflect(-lightVec, normal);
          float specFactor = pow(max(dot(v, toEye), 0.0f), mat.Specular.w);

          diffuse = diffuseFactor * mat.Diffuse * L.Diffuse;
          spec = specFactor * mat.Specular * L.Specular;
      }
  }

I'm using DirectX 11.


texts: In GameCenter realtime multiplayer how to identify who is host?

texts: In GameCenter real-time multiplayer how to identify who is a host?


texts: How to Detect Collision Between Entity and Viewport

texts: I am using Crafty.js. I want the player to die when they hit the side of the viewport (they need to keep moving to stay alive). How do I detect a collision between the player entity and the side/edge of the viewport? I have looked at Crafty.viewport, but have not been able to find anything useful.


texts: How to generate a random tunnel consists of series of two line paths

texts:
I have a 2D path that follows series of lines thru points p1 p2 p3 p4.

Like this:  ___/\__/\___

I want to make a tunnel out of this path, so I need to split this path in two sideways and make a hole inside of it.
Like this:

     ________
____/        \_____
     _______
____/       \_____

How do I do that?

I actually want to just generate a random tunnel it doesn't have to follow a path.


texts: POST JSON method does not work when project has been exported to WEBGL and uploaded to firebase hosting

texts:
I have a database set up on firebase and when i run my game in the unity edtitor and as a standalone exported Windows .exe file, the call gets made correctly to the database and JSON data gets posted correctly. However when I export the exact same project to WEBGL and upload it to my firebase hosting server, the JSON call does not work. Here is my code, could someone please help?

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

 public class GameOverMenu : MonoBehaviour
{
 public InputField nameInputField;

 public void MainMenu()
 {
     SceneManager.LoadScene("Menu");
 }

 public void SubmitScore()
 {
     StartCoroutine(SendScore());
     SceneManager.LoadScene("Menu");
 }
 // Use this for initialization
 void Start()
 {

 }

 // Update is called once per frame
 void Update()
 {

 }

 public IEnumerator SendScore()
 {
     Scoreboard s = new Scoreboard(nameInputField.text, PlayerPrefs.GetInt("Score"), PlayerPrefs.GetInt("Seed"));
     Dictionary<string, string> headers = new Dictionary<string, string>();
     headers.Add("Content-Type", "application/json");
     Hashtable data = new Hashtable();
     data.Add("name", s.Name);
     data.Add("score", s.Score);
     data.Add("seed", s.Seed);

     UnityHTTP.Request postRequest = new UnityHTTP.Request("post", "https://alexclearythesisgame.firebaseio.com/Scoreboard.json", data);
     postRequest.Send();
     yield return postRequest.isDone;
 }

}


texts: How to generate interresting procedural terrain

texts:
I work on a voxel-like game, and I have finally managed to create some basic terrain generation using simplex noise. Heres what it looks like:

Sure I can generate different kind of terrains (more or less hilly/aggressive), but there wont really be any variation.

At the moment I only know one way to make it more interesting, and that would be to add stone blocks under the grass (I would simply check the above block).

So my questions are: What techniques would I need to use, to generate different kind of terrains, which still kind of blended together at the edges. And how would I go about caves and rivers? And lastly how would I make a better variation of blocks?

If any could lead me in the right directions, I would appreciate it a lot.

Ps. It's not a valid answer to say that I just need to mix a lot of noises, to generate it. How?


texts: My FlxGroup does not change it's visibility status

texts:
So, I found I needed a different type of button for my game, which I am making using Haxe, OpenFL and HaxeFlixel. After sometime fliding with Haxe, I got following button done, which works just fine. It's not the most sophisticated button, but it gets the job done.

class ArrowButton extends FlxGroup
{
    private var spriteUp:FlxSprite;
    private var spriteDown:FlxSprite;
    private var onClick:Void->Void;
    private var x:Float;
    private var y:Float;
    private var traced:Bool;

    public function new(x:Float = 0, y:Float, up = true, onClick:Void->Void = null)
    {
        super();

        this.x = x;
        this.y = y;
        this.onClick = onClick;

        if (up)
        {
            spriteUp = new FlxSprite(x, y, Assets.getBitmapData("assets/ArrowUp.png") );
            spriteDown = new FlxSprite(x, y, Assets.getBitmapData("assets/ArrowUpPushed.png") );
        }
        else
        {
            spriteUp = new FlxSprite(x, y, Assets.getBitmapData("assets/ArrowDown.png") );
            spriteDown = new FlxSprite(x, y, Assets.getBitmapData("assets/ArrowDownPushed.png") );
        }
        add(spriteDown);
        add(spriteUp);
        buttonUp();
    }

    private function buttonDown():Void
    {
        if (pressed != true)
        {
            spriteUp.visible = false;
            spriteDown.visible = true;
            pressed = true;
        }
    }

    private function buttonUp():Void
    {
        if (pressed = true)
        {
            spriteUp.visible = true;
            spriteDown.visible = false;
            pressed = false;
        }
    }

    private function isClicked():Void
    {
        //trace("Mouse X:Y" + FlxG.mouse.screenX + ":" + FlxG.mouse.screenY + ", button X:Y " + x + ":" + y);

        if (onClick != null && FlxG.mouse.screenX > x && FlxG.mouse.screenX < x + 16 && FlxG.mouse.screenY > y && FlxG.mouse.screenY < y + 16)
        {
            buttonUp();
            onClick();
        }
    }

    override public function destroy()
    {
        super.destroy();
    }

    override public function update()
    {
        if(FlxG.mouse.justReleased())
        {
            isClicked();
        }

        if (FlxG.mouse.pressed() && FlxG.mouse.screenX > x && FlxG.mouse.screenX < x + 32 && FlxG.mouse.screenY > y && FlxG.mouse.screenY < y + 32)
        {
            buttonDown();
        }
        else
        {
            buttonUp();
        }

        super.update();
    }

}

Now, I got problem: I can't hide the button. I add this button as a member of another FlxGroup, called systemView. I got several views that I hide and show, depending what menu player is in. So when I move out of systemView, I call function called hideStuff()

private function hideStuff():Void
{
        sideMenu.setAll("visible", false, true);
}

now, this works fine for everything else, EXCEPT my own button. That one it misses, for some reason. Any ideas why this happens and how to fix it?


texts: How to reconcile depth ordering with minimal shader context changes?

texts:
We generally want to minimise shader-program switches (glUseProgram and all associated context changes) for the sake of performance. AFAIK it is not uncommon to render by shader program, i.e. group draw calls of all mesh instances that use the same set of shaders - or vertex shader at least (i.e. that have the same set of vertex attributes), for this reason.

How then do we go about doing both depth ordering and shader program changes, quickly? Because it seems to me one either orders primarily by program (thus minimal program context changes), or primarily by depth (frequent context changes), and that they're mutually exclusive in terms of maximising performance.

PS. In my current work I'm not using the hardware Z-buffer, instead I'm using the painter's algorithm prior to making all draw calls... If this affects the answer to the question at all, I'd be happy to hear solutions for both sorts of depth-ordering.


texts: Execute cloud build from script in Unity

texts:
Want to make cloud build functionality in Unity.
How can I do it in Unity from script(in EditorWindow)?
Update: Found Pre- and post-export methods, but still can't find the way to execute cloud build...


texts: Understanding Screen Position Node in Unity Shader Graph

texts:
I'm struggling to understand what exactly the Screen Position node outputs in Unity's Shader Graph.
I'm using the screen position with scene depth to calculate the distance between two objects.
Every tutorial I saw (like Brackey's forcefield one) is using the alpha channel of the Screen Position output:

I read that the Screen Position node outputs the mesh vertex screen positions.

Does it means the 2D position on the screen projection?
Or the vertex 3D position from the eye space?
And more importantly, what is exactly the apha channel of this output? (I have the feeling this is related to the "clip space W component" in the documentation)


texts:
I'm developing a game (in Ogre3D) that, in short, consist in a vehicle that moves along a terrain and leaves a colored trail behind it. The trails are basically quads (a), these quads changes their color accordingly to the vehicle's speed.
My challenge now is that I need to subdivide these quads into 5 (or more) sub-polygons (b) and each one of them should have a different color accordingly to others vehicle's properties. When moving around for a while these quads start to accumulate on screen and the render process starts to heavily lag and thus fps count is sub optimal.

Some considerations:
 - All quads are appended to a single mesh that belongs to a single entity sharing the same material, so batching should be optimal.
- Tried adding LOD for this mesh but I had no luck to make it work in Ogre1.9.

So, my main question is how can I optimize the rendering of this polygons??
Can I delegate this task by somehow to the gpu via shader programming?

Edit: My goal would be to avoid having to draw each one of those sub-quads in (b) (only draw the big quad (a)) but by somehow being able to colorize each  one of those sub-quads.


texts:
I'm trying to make a simple Fog of War effect for my 2d game, similar to these:

.

I want to have a sprite layer of black and then have a sprite to cut out itself from the black layer, leaving a part of the black sprite transparent. And if I have two cut out sprites they will blend like the image I linked.

Anyone got any ideas?


texts: Are there established conventions for naming "directions" (width,height) in 3D?

texts:
I want to create a 3D game world where the players can modify the environment. I would like to bring it to the point where a power-user could even create "game objects" inside the application using some kind of very simple 3D modeling UI. So I decided to write this UI first, as I can then use it to create the game content. I spent some time in the last two months trying to learn Blender, and decided that this was a total overkill for what I want to create.

Anyway, I have the classes representing the 3D "concepts" mostly worked out, but I have problems with the "unwrapping" code, that is, mapping the graphic primitives, triangles and rectangles, to a texture file.

The 3 points representing a triangle are in 3D, but I need to work in 2D for the texture mapping. How should I best choose which of the 3 points to use as the "origin" of that triangle in the texture file, and how do I define some "reliable" concept of width and height that make sense, when I am in 3D?

I can think of several methods, but if one is most commonly used, I would like to know, so that my code also make sense to other people.

[EDIT] It seems I did a very bad job of explaining what I want. I understand how unwrapping works. I sweated blood going through a Blender unwrapping tutorial. But now I'm trying to write code that can automatically create a basic unwrapping of simple objects (boxes, wedges, pyramids, ... and composition thereof). My idea was to group primitives that are 1) in the same plane, and 2) touch each other in (flat) "boxes" and map those boxes to the first free spot on the texture file that is big enough (under the assumption that all primitives have the same scale). Far from optimal, but good enough to get going. Later, the user could have refined the unwrapping as necessary, for example, by mapping several "boxes" to the same coordinates, if they look the same. The box would have a width and a height, and the unwrapping would map the "origin" of the box (say top left corner) to the coordinate in the texture file where it should be mapped.

But, for me, width is the length is along the X axis, and height is the length along the Y axis. So how do I decide what is the width and the length when the box is in the X-Z plane, instead of the X-Y plane, for example? And which vertices is the "top left" when all vertices have the same "Y" or "X" coordinate (but vary in Z)? Unlike the real world, there is no "obvious" "up and down", "left and right" ... in computer 3D. Anything can be in any direction. Things don't "fall down" because there is no down.

Hopefully I now made clear my problem. How can I consistently define "top", "left", "width", and "height" when I am in 3D, instead of in 2D, and when a primitive might, for example look like an horizontal line from user point of view because it stretches in Z (which traditionally "comes out of the monitor") instead of Y?

My code can only make sense if I can define all concepts clearly, and unequivocally. I first need a way of defining those concepts that always apply, for any 3 points in 3D space. Only then can I look at any piece of my code, and decide whether it is correct or not. What I cannot define clearly, I cannot program correctly.

What I really want to know is what I asked in the title. I only talked about unwrapping to explain why I need to know this.


texts:
I am currently trying to create 2d shmups. I am trying to:

Generate a random number of enemies to appear on screen
Whatever number is generated will then be added to my List (the list is used to keep track of enemies). to load that number of textures.
I would also like to keep a collection of Vectors to determine the positions the enemies will spawn randomly.

This is what I have done so far:

 List <Enemies> enemies = new List<Enemies>();
 Random rnd = new Random();
 int numberOfEnemies = rnd.Next(1,5); // I would like to generate between 1 and 5.
 if (enemies.count < numberOfEnemies){
     enemies.Add(new Enemy(Content.Load<Texture2D>("alienship");// one of the vectors from the collection of vectors will go here
 }


texts:
I am working on a top-down, 2d cell-based RPG game. I would like to implement a cell based lighting system, something like this and this.

I basically have several light sources and light deteriorates on every cell in every direction. Something like the below (numbers represent the level of light in each cell):

1 1 1 1 1 0 0 0 0 0 0
1 2 2 2 1 0 0 1 1 1 0
1 2 3 2 1 0 0 1 2 1 0
1 2 2 2 1 0 0 1 1 1 0
1 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 0 0 0 0
0 0 0 0 1 2 1 0 0 0 0
0 0 0 0 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0

So basically I insert a source of light of "strength" x at a given spot. I then set the surrounding cells' light strength to x-1 and so on until I reach zero (or a set global minimum value). I am looking for an efficient algorithm to implement and generate such a lightning grid based on my light sources and any tips regarding such implementation.

I am currently not looking into field of view algorithms, just an efficient way of generating the above. Any help will be much appreciated.

EDIT: Just to clarify, this should handle movement of light sources (e.g. player walking with a torch).

EDIT2: Ok, I've solved my problem myself based on the simple distance suggestion by Jari (thus I'll accept his answer although I'm still looking for a more efficient way of generating such array). If anyone's interested here is a demo of what I came up with (multiple light sources with alpha compositing)


texts:
I have the following dialog, semi circle shape. I want to position  buttons in it.

        dialog.button(closeButton, false);
        dialog.getContentTable().add(buttonS);
        dialog.getContentTable().add(button);
        dialog.getContentTable().add(hwTo);

The only way I am able to move a button is by using for a example

    dialog.getContentTable().add(hwTo).pad(300);

But I don't want to pad anything, since it affects other buttons, I tried align, button.setPosition and whatnot, nothing works.

I was told to remove the table and ise Custom WidgetGroup. I removed the table, still having the same problem, nothing works except padding.


texts:
I have my general understanding of K-Dops for collision detection.

I understand how to calculate them. I also understand the super slow way of recalculating them.

Example: I have a simple model of a character. Pre-process calculate k-dop bounds. Let's say his right leg. The second he bends his leg, let's say for a jump. I have to recalculate his k-dops to make sure the collision system is checking properly.

Now the way I think of doing it is: Animate the vertices and, now that they are in their new proper location, recalculate the K-dops.

I feel like that's super slow. Because if that leg is made up of many triangles, that process is just drastically slowed down. At that point I might as well just use a simplified geometry model instead of k-dops for collision testing.

Does anyone have know ways to speed up the K-Dop recalculation process? Especially if it were to happen dynamically and occasionally. Not just pre-processed.


texts: Handling Origin/Anchor Points in a Scene Graph

texts:
I'm trying to implement a simple scene graph on iOS using GLKit but handling origin/anchor points is giving me fits. The requirements are pretty straightforward:

There is a graph of nodes each with translation, rotation, scale and origin point.
Each node combines the properties above into a single matrix (which is multiplied by it's parent's matrix if it has a parent).
Nodes need to honor their parent's coordinate system - including the origin point (i.e. a child's origin should line up with the parent's origin)

So the question is:

What operations (e.g. scaleMatrix * rotationMatrix * translationMatrix, etc.) need to be performs and in what order so as to achieve the proper handling of origin/anchor points?

P.S. - If you are kind enough to post an answer please mention whether your answer is based on column or row major matrices - that's a perennial source of confusion for me.


texts: How can I move a sprite in the direction it is facing?

texts:
I'm using Java/Slick 2D. I'm trying to use the mouse to rotate the sprite and the arrow keys to move the sprite. I can get the sprite to rotate no problem, but I cannot get it to move in the direction it is supposed to. When I hit "forwards", the sprite doesn't necessarily move towards the mouse. Actually, it will only move towards the left of the screen really. I'm sure there has to be some standard code for this since many games use this style of motion. Can anyone help me out with what the trig is supposed to be? Thanks

EDIT: Here is the rotation code (which does something else weird: https://stackoverflow.com/questions/12610320/why-is-my-image-rotating-off-center)

int mX = Mouse.getX();
        int mY = HEIGHT - Mouse.getY();
        int pX = sprite.x;
        int pY = sprite.y;
        int tempY, tempX;
        double mAng, pAng = sprite.angle;
        double angRotate=0;

        if(mX!=pX){
            mAng = Math.toDegrees(Math.atan2(mY - pY, mX - pX));
            if(mAng==0 && mX<=pX)
                mAng=180;
        }
        else{
            if(mY>pY)
                mAng=90;
            else
                mAng=270;
        }

        sprite.angle = mAng;
        sprite.image.setRotation((float) mAng);

And the movement code. I can only move towards the left of the screen...

double ang = sprite.angle;
            Input input = gc.getInput();

            if(input.isKeyDown(sprite.up)){
                sprite.x += Math.cos(ang)*sprite.moveSpeed;
                sprite.y += Math.sin(ang)*sprite.moveSpeed;
            }if (input.isKeyDown(sprite.down)){
                sprite.x += -1*Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
                sprite.y += -1*Math.sin(ang*Math.PI/180)*sprite.moveSpeed;
            }if (input.isKeyDown(sprite.left)){
                sprite.x -= Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
                sprite.y += Math.sin(ang*Math.PI/180)*sprite.moveSpeed;
            }if (input.isKeyDown(sprite.right)){
                sprite.x += Math.cos(ang*Math.PI/180)*sprite.moveSpeed;
                sprite.y -= Math.sin(ang*Math.PI/180)*sprite.moveSpeed;
            }


texts:
I am a beginner at Unity. I want to make a game like Lightbot, but in 2d (without the z axis movement) with some obstacles. Before making the function system of the Lightbot, I want to make the in-game character move on a grid by the set of key inputs (e.g. WASD) by the player. But I'm stuck here. I searched on Tilemap which makes a grid, but I have no idea how to save the set of input keydowns and move my character on this grid at once. Suppose my character is on the (0, 0) square for example. After the player taps WWDD, then my character should move to the following squares, in the following order:

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

How can I achieve my goal?


texts: How does one develop a first person shooter with a one man team?

texts:
I have an idea for a first person shooter game and I have plenty of free time to work on it.

I know java and objective-c very well and I also know autodesk inventor (which is similar to 3ds max).

How would I go about starting to develop a small fps? What programming language should I use? What modeling/animation software should I use?


texts: Handle Entities & Collision in large numbers

texts:
I am creating a simple 2D maze game and I am a little confused about entities & collision detection.

At the moment, my entity class is an abstract class containing position, velocity, sprite and a booolean named shouldRender, as well as a tick and render method. Should I go with this or lean towards a component based entity system? If so, how would I implement that in java?

Also, when I update and render my entities I have a class named Level, which holds an arraylist with all entities. When updating and rendering my entities, I iterate through this list and render the entities that are visible in the camera, via the shouldRender boolean. However, all entities are updated, which makes the FPS drop.

Also, when checking for collisions: should I use a Rectangleand loop through all entities in the list and check if the current entity is colliding with any other entity? Or should I lean more towards stuff like quadtrees etc? (And how would I implement those?)

Because when every entity has to check for collisions with all other entities on the map the game runs at 10-20FPS, which is not too good.

So, if anyone could explain this to me, I would be very thankful!


texts: How to make Scriptable Objects derive from other Gameobejcts?

texts:
I encountered a problem where I want to make a Scriptable Object that derives from another class, but C# does not support multiple inheritance. Further, I do not think it would not make sense to make interfaces for this example. There is a lot of duplicate code within methods that only an abstract class could contain implementations of.

Basically, I want an abstract class that models "anything that can take a turn." I call it a TurnTakeable. But I also want the TurnTakeable to be split into friend and foe derived types, as the two are slightly different. Yet they mostly have the same behavior.

Is there a workaround, or do I have to make an interface? :(


texts: Has anyone had any trouble implementing multitouch on-screen controls in libGDX, such as multiple joysticks? I've tried and I can't seem to get libGDX to play nice with multitouch/multiple pointers on screen at once. I am currently using a Stage with my joystick class extending Actor and they are detecting hits just fine, but when I touch one it interferes with the other. Any examples, or tips? I should note, that when I am using just one of the joysticks that they work as intended.


texts: Positive Evaluation Function - Territory AI Help

texts:
I am trying to implement some positive evaluation into my game. Let me explain.

I have a series (anywhere from 5 to 25 (might vary)) of circles (three sizes, big medium small). And each player starts with a main circle which gains 1 every turn (like risk the circles gain at different speeds, the big one gains the fastest and the small one gains the slowest). You can use these numbers to take over other circles, if the "enemy" is on this circle it does a risk thing (you fight to see who takes it over, who ever has more wins most of the time, I'm not getting into this logic as it is rather irreverent).

So this is a very basic overview of what occurs, now what I need some help with is how I can create an AI which will look at all available (and taken) circles and determine where it wants to move to. There would be circles closes to it, and circles in the enemies area and circles available and circles taken over. And it would need to determine where to move it's forces too next, and so on and so forth.

So after some research I read a lot about Positive Evaluation, which it takes all possible moves and determines the best one.

So I am wondering if anyone could help me out or give me some direction as to where to go from here. I think what I need to do is take all the circles with any forces on them, throw them into a table/array with the cords of each circle and determine which would be best, then I would need to determine how many forces I want to send and where from.

Help!

ADDITION:

Allow me to explain a bit, http://imm.io/4Xwy see that diagram lets assume the circles are sections of forces, and you gain a new force each "time interval" and lets say I want to take all my forces (I'm pink) the circle directly below me and capture it, well the AI would need look at all available circles and pick for example the big green on in the top right (since big would make more troops and its close to the "main"). I'm assuming what you said would still work? Weighted options?


texts: Texture with D3DUSAGE_RENDERTARGET failing to release before IDirect3DDevice9::Reset

texts:
Creating the texture:

IDirect3DSurface9 *bbsurf;

if (SUCCEEDED (Device->GetRenderTarget (0, &bbsurf)))
{
    D3DSURFACE_DESC desc;

    if (SUCCEEDED (bbsurf->GetDesc (&desc)))
    {
        Device->CreateTexture (
            desc.Width,
            desc.Height,
            1,
            D3DUSAGE_RENDERTARGET,
            desc.Format,
            D3DPOOL_DEFAULT,
            &GAndCRT,
            NULL);
    }

    // don't leak
    SAFE_RELEASE (bbsurf);
}

Before Resetting the device:

GAndCRT->Release ();
GAndCRT = NULL;

I've commented out all other code that refers to this texture but the texture still fails to Release and the device Reset fails.  To be clear: the above is the minimum complete example to reproduce the problem.

Commenting out the CreateTexture call and obviously the device will succeeed to Reset.

There are about 4 other textures also created with D3DUSAGE_RENDERTARGET which Release OK.

I know there's no magical incantation that will say "please really Release this texture, so what I'm looking for is information and/or advice on how to best go about troubleshooting this further, rather than an actual answer.


texts: Converting signed normalized integer to unsigned normalized integer image format

texts:
Given I have my texture data in client memory as signed normalized integers.

I want the samples in the shader in the range [0,1]. Can I simply specify:

format = GL_RGBA;
internalFormat = GL_RGBA8;
dataType = GL_BYTE;

Does this work as expected or does it convert it to [-1,1] and then do the clamp which is certainly not what I want?


texts: How do I sense when the player collides with a door in a GameController script?

texts:
I want to be able to sense when the player collides with a door from my GameController script. The player is a public GameObject and doors are tagged as such. Here is psuedo code for what I'm looking for:

public class GameController : MonoBehaviour
{
   public GameObject player;

   void Update()
   {
      if(player collides with game object tagged "Door")
         do something
   }
}


texts: Is 2 lines of push/pop code for each pre-draw-state too many?

texts:
I'm trying to simplify vector graphics management in XNA; currently by incorporating state preservation. 2X lines of push/pop code for X states feels like too many, and it just feels wrong to have 2 lines of code that look identical except for one being push() and the other being pop().

The goal is to eradicate this repetitiveness,and I hoped to do so by creating an interface in which a client can give class/struct refs in which he wants restored after the rendering calls.

Also note that many beginner-programmers will be using this, so forcing lambda expressions or other advanced C# features to be used in client code is not a good idea.

I attempted to accomplish my goal by using Daniel Earwicker's Ptr class:

    public class Ptr<T>
    {
        Func<T> getter;
        Action<T> setter;

        public Ptr(Func<T> g, Action<T> s)
        {
            getter = g;
            setter = s;
        }

        public T Deref
        {
            get { return getter(); }
            set { setter(value); }
        }
    }

an extension method:

        //doesn't work for structs since this is just syntatic sugar
        public static Ptr<T> GetPtr <T> (this T obj) {
            return new Ptr<T>( ()=> obj, v=> obj=v );
        }

and a Push Function:

        //returns a Pop Action for later calling
        public static Action Push <T> (ref T structure) where T: struct
        {
            T pushedValue = structure; //copies the struct data
            Ptr<T> p = structure.GetPtr();

            return new Action( ()=> {p.Deref = pushedValue;} );
        }

However this doesn't work as stated in the code.

How might I accomplish my goal?

Example of code to be refactored:

    protected override void RenderLocally (GraphicsDevice device)
    {
        if (!(bool)isCompiled) {Compile();}

        //TODO: make sure state settings don't implicitly delete any buffers/resources
        RasterizerState oldRasterState = device.RasterizerState;
        DepthFormat oldFormat = device.PresentationParameters.DepthStencilFormat;
        DepthStencilState oldBufferState = device.DepthStencilState;
        {
             //Rendering code
        }
        device.RasterizerState = oldRasterState;
        device.DepthStencilState = oldBufferState;
        device.PresentationParameters.DepthStencilFormat = oldFormat;
    }


texts: Fog Of War - Is looping over every tile inefficient?

texts:
I'm trying to optimize my static FOW code for my 2D tile-based game and the bottleneck seems to be in the rendering of the fog (rather than the circle drawing algorithm or other aspect of the code).

It's a fairly simple implementation - there are two steps.

First, the game renders everything normally as if there is no fog. Then after the fact, the FOW code loops over every row and every column of tiles and if the tile is "hidden" behind fog, it draws black over the tile.

Everywhere on the web I see that this is the method most used - but to me it seems like it'd be much more efficient to set all of the tiles black, and only show through the tiles which are visible.

Although this sounds logical, in my case it turned out to be not very efficient either.

The Fog grid's tile size is different than the actual game's tile size, which provides some special challenges.

Are there any better methods for generating the Fog of War?

(The game's implementation is in Java, I can provide pseudocode if you'd like.)

Any help is appreciated.

EDIT: I've tried 2 circle-drawing algorithms, and there was little difference in performance (the original proved a little faster).

When I moved the fog code into the level drawing loop, I saw a notable performance increase, but it isn't a lasting solution because my fog grid size is larger than my map grid size.

EDIT 2: Here's the pseudocode - I don't feel comfortable posting the real code, as it isn't mine to post.

Level.render

for all x
    for all y
        if {x,y} is in view of camera
            render tile

for all visible entities
    if entity is in view of camera
        render entity

call FOW.render()

FOW.render

for all x
    for all y
        if {x,y} is in view of camera
            if tile is hidden by fog
                 render fog


texts: Calculate the rest length of a box2d distance joint

texts:
Given the length of a distance joint along with its frequency and the mass of the bodies involved, is it possible to determine the final rest length?
I'm only interested in the vertical axis if that makes the formula simpler.

E.g. Imagine the simple case of a dynamic body of mass=1 sitting vertically atop another similar body and attached via a distance joint with length=1 and frequency=1 and gravity=10.
What would the rest length be? I.e. What would the final distance be between those two bodies?

I'm currently just trial and error fudging the frequency values I need in my game but I really need a formula to compute this as every time I change the masses, I have to re-fudge everything.

Thanks.


texts: Implications of variable run speeds in 2D

texts:
I'm getting my feet wet trying to design and implement a 2D action platforming game. Combat will be a big focus, so I want to have tight ground and air control so players can be precise and express mastery. For now, I don't think I want high acceleration and deceleration times, as I think they detract from a 'tight' feeling control scheme, but feel free to correct me if there's data or examples saying otherwise.

I'm taking a lot of combat inspiration from, and want it to feel like, a fighting game. From a surface level analysis, in many fighting games, most notably smash brothers, there are usually two (or more) speeds of horizontal movement - a walk and a run, a run and a sprint, and so on. Naively, I thought 'well fighting games have it so if I want this to feel like a fighting game I need to have it as well' but thinking about it some more, I'm not sure if its worth implementing. Primarily because I don't understand the implications of having a sprint mechanic or not.

One thing I'm rapidly discovering is that any design question can boil down to 'it depends,' especially on the game itself and what I want to accomplish. If you need more context, my initial idea is to more closely marry the feelings you get when you pull off a new combo or link or discover new ways to use a system mechanic in a fighting game with that feeling of discovery from cracking open a game world in a Metroidvania. So a 2D metroidvania with action/fighting game level combat. My initial thought is sprinting would open up opportunity for dash attacks, maybe some cancels, and make moving around the world easier. It also means more implementation work, because I'm mostly out of buttons, so I'd have to do some sort of double tap or smash-attack-like analog input to work it in.

My main example of two run speeds in a non-fighting game is in some Kirby games, where you can start a dash by double tapping a direction. In the context of Kirby, what does having the dash do for the game as a whole? Would it be better to have a faster base walk speed and no dash? What opportunities would open up if I had a sprint, and what would become closed off from me?

Perhaps a better example, though not in 2D, is Raiden's Ninja Run from Metal Gear Solid Rising Revengeance. It helped him get from encounter to encounter faster, and served as a way to close gaps while under fire.

Initial reaction says that my players will just use sprint to run from encounter to encounter and will miss stuff I put in they might not if they're taking their time. I'd have to put in stuff that encourages the player to slow down, and be intelligent about it so as to not feel like I'm mangling whatever pacing the player is at. I think 'go as fast as I'm allowed to' is the default mode for most players, and that having a variable run speed doesn't actually add much of a choice. I think going fast, especially going fast-er by comparison, is fun, but is it a worthwhile tradeoff? I could offset this with a stamina system just for sprinting or some other artificial limiter, but I think that opens up a whole new set of implications I even further don't fully grasp.

TL;DR

What are the benefits and downsides of having a sprint?


texts: How can I test on a device I don't have?

texts:
I received a report that my application fails to run on a specific device (smartphone).

However, not only I don't have access to that device, but they're also quite rare, and I'm not going to buy one just to fix this problem.

Unfortunately, it is imperative that I support that device, as it is a requirement to get published on a store I need to publish on.

Do you guys have any ideas on what can you do when you need to test on a device you don't and can't have?


texts: How can I make it not possible to type after reaching a max number of lines in my textarea?

texts: I have a EditorGUI.TextArea that is 300x100 in size. How can I make it impossible to type after reaching a max number of lines in my textarea (no wrapping)?


texts: Pathfinding towards a moving target in 2D Platformer

texts:
I have an enemy in my 2D platformer that chases the player around the level.

I implemented a modified version of A* that works with gravity as described here: https://gamedevelopment.tutsplus.com/tutorials/how-to-adapt-a-pathfinding-to-a-2d-grid-based-platformer-theory--cms-24662

But for a moving target I would have to calculate a new path whenever the target moves. Of course I'm going to run the pathfinding on a separate thread and only once a second or something like that, but it's still a waste to calculate the path from scratch.

So I found this algorithm for transforming the old path to the new path with the new start and target position called FRA* http://idm-lab.org/bib/abstracts/papers/ijcai09b.pdf

However the platformer version of A* has a kind of 3D grid where nodes with different jump values in the same 2D location has a different z-coordinate.

Is it possible to use FRA* when jump values comes into play? Do I have to recalculate jump values?


texts:
I have a problem with Mouse interaction and Stage3D.

The only way I found to register to listen to mouse clicks and interact with Stage3D, is to add a mouse eventListener directly to the .stage.

However this will result in any time i click anywhere in the flash application the mouse click will fire, even if there is an overlaid 2D menu where the user intended to click.

IE I have a 3D application running in the background, which listens to clicks, and I have some floating User Interface elements in the foreground, and ideally if I clicked a button in the foreground, then that would NOT fire a click event that the Stage3D would register.

Any idea how to solve this problem?


texts: How is Unity's [Command] supposed to behave?

texts:
Here's a very simple class/call hierarchy:

public class NetworkPlayer : NetworkBehaviour {
    public static NetworkPlayer localPlayer {
        get;
        private set;
    }

    [Command]
    public void CmdTurnDone() {
        Debug.Log("Turn done! isServer "+isServer+" isClient "+isClient+" isLocalPlr "+isLocalPlayer);
    }
}

public class SomeMonoBehaviour : MonoBehaviour {
    void Update() {
        NetworkPlayer.localPlayer.CmdTurnDone();
    }
}

When Update() gets executed on the host, it outputs as expected:

  Turn done! isServer True isClient True isLocalPlr True

Now, when Update() is executed on the remote client it outputs the following at the remote client's log only. However, the message does not appear at the server's logs:

  Turn done! isServer False isClient True isLocalPlr True

What puzzles me is why the message appears at the remote client's log only.

If I'm not mistaken, calling CmdTurnDone() at the remote client should execute it on the server. But why does the log message appear at the remote client's log instead of on the server's logs - where it is executed? Is it valid to call CmdTurnDone() from a MonoBehaviour?
Do you have any ideas why it's behaving like this? Is this the intended behavior? Thank you.


texts:
I read this playfulJS post, about ray-casting:
http://www.playfuljs.com/a-first-person-engine-in-265-lines/

It looks really interested, so I decided to look at his javascript. I am no expert in javascript, so I quickly got lost.

It's the game loop "object" that really gets me.
I simply don't understand how it works.
From the code:

function GameLoop() {
        this.frame = this.frame.bind(this);
        this.lastTime = 0;
        this.callback = function() {};
      }

      GameLoop.prototype.start = function(callback) {
        this.callback = callback;
        requestAnimationFrame(this.frame);
      };

      GameLoop.prototype.frame = function(time) {
        var seconds = (time - this.lastTime) / 1000;
        this.lastTime = time;
        if (seconds < 0.2) this.callback(seconds);
        requestAnimationFrame(this.frame);
      };

var loop = new GameLoop();

      loop.start(function frame(seconds) {
        map.update(seconds);
        player.update(controls.states, map, seconds);
        camera.render(player, map);
      });

Now, what really confuses me here, is this bind stuff and how this actually loops.

I am guessing, that if less than 0.2 seconds have passed, since the last time the loop was run, it simply goes back to re-check the time. If more than 0.2 seconds have passed, it leaves the frame function, and executes the 3 lines in the loop.

But, if this is true, then how does the loop.start() get called again?
And what on earth is the meaning of this.frame = this.frame.bind(this);?

I've looked up prototypes bind() but I really don't understand it.