texts: Cannot use imported image with Unity's UI controls

texts:
I know this question sounds banal but its a problem.

I received a project and opened it.

Now I try to edit it by adding my own images.

I do the import but the image does not show up when selecting images, for example, for a button:

What is the correct folder in this case?


texts:
My scene consists of individual meshes. At the moment each mesh has its associated light map texture, I was able to implement the light mapping using these many small textures.

1) Of course, I want to create an atlas, but how do you split atlases to pages, I mean do you group the lm's of objects that are close to each other, and load light maps on the fly if scene is expected to be big.

2) the 3d authoring software provides automatic uv coordinates for each mesh in the scene, but  there are empty areas in the texel space, so if I scale the texture polygons the texel density of each face wil not match other meshes, if I create atlas like that there will be varying lm resolution, how do you solve this, just leave it as it is, or ignore resolution ?

Actually these questions also applies to other non tiled maps.


texts:
I'm trying to setup a 2d game and have been thrown up an error on vector subscript out of range. I've been trying to look up about it, but have not seen anything that helps. If someone could help and take the time to look at my code and help me fix my error i'd be very grateful. I think it's got something to do with something about that it can't handle more then 0-9 or something but my knowledge/understanding of it is not great and would appreciate the help. I'll paste my code below so you can see what i'm trying to do.

//tile setup
level.loadTexture("gfx/Maptiles.png");
Tile tile;
vector<Tile> tiles;
for (int i = 0; i < 10; i++)
{
    tile.setSize(sf::Vector2f(32, 32));
    tile.setAlive(true);
    tiles.push_back(tile);
}

//sky tile set to false so we don't collide
tiles[0].setAlive(false);
//    X   Y   W   H  of the sprite sheet
/*tiles[0].setTextureRect(sf::IntRect(187, 51, 70, 70));
tiles[1].setTextureRect(sf::IntRect(0, 0, 70, 70));*/
tiles[0].setTextureRect(sf::IntRect(864, 221, 70, 70));
tiles[1].setTextureRect(sf::IntRect(73, 2, 70, 70));
tiles[2].setTextureRect(sf::IntRect(140, 2, 70, 70));
tiles[3].setTextureRect(sf::IntRect(210, 2, 70, 70));
tiles[4].setTextureRect(sf::IntRect(280, 2, 70, 70));
tiles[5].setTextureRect(sf::IntRect(350, 2, 70, 70));
tiles[6].setTextureRect(sf::IntRect(420, 2, 70, 70));
tiles[7].setTextureRect(sf::IntRect(506, 577, 70, 70)); //ground block
tiles[8].setTextureRect(sf::IntRect(560, 2, 70, 70));
tiles[9].setTextureRect(sf::IntRect(630, 2, 70, 70));
//tiles[].setTextureRect(sf::IntRect(630, 0, 70, 70));
//tiles[11].setTextureRect(sf::IntRect(770, 34, 70, 70));
//tiles[12].setTextureRect(sf::IntRect(840, 51, 70, 70));
//tiles[13].setTextureRect(sf::IntRect(910, 0, 70, 70)); //^^ 1st row
/*tiles[14].setTextureRect(sf::IntRect(0, 0, 70, 70));
tiles[15].setTextureRect(sf::IntRect(70, 0, 70, 70));
tiles[16].setTextureRect(sf::IntRect(140, 0, 70, 70));
tiles[17].setTextureRect(sf::IntRect(17, 34, 70, 70));
tiles[18].setTextureRect(sf::IntRect(34, 34, 70, 70));*/
level.setTileSet(tiles);
// Map dimensions
    sf::Vector2u mapSize(25, 19);
// build map
std::vector<int> map = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, //25 X 19
    2, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
//fix tile layout
level.setTileMap(map, mapSize);
level.setPosition(sf::Vector2f(0, 0));
level.buildLevel();

level.render(window);


texts: What are the recommended approaches for an event system in Java?

texts:
What are the recommended approaches for an event system of a turn-based RPG's battle engine?

The system I'm currently working on has a runEvent method that sorts the actions queue based on their priorities. This method should also call the object's (item, player, condition) method according to an eventid, which currently is a String ("TurnStart", "TurnEnd", etc). The different objects may or may not have the same parameters for the same eventid.

In JavaScript, it would be something like the following:

retval = action['on' + eventid].apply(this, args);

I've read about using Java's Reflection to call a method through a String stored in a variable, but some people advise against it because of its security flaws.

I also thought about having a switch (eventid) inside a handler method that would call the appropriate method, but I think that would become impractical, given the substantial amount of different parameters combinations.

So, what is the recommended approach for this kind of situation in Java?

Note: It doesn't need to be based on String passing.


texts: If I accidentally used a trademarked name or word in my title, can I just change it?

texts: I'm closing in on a point in the development of my first game that it's ready for Steam Greenlight. I don't even have a name for it though. My project name is Asteroids, but obviously I can't use that. I have a bunch of other ideas, but I'm scared to death of getting sued. Let's use the Edge Vs EA example. Edge Games tried to sue Electronic Arts because they released Mirror's Edge. They were unsuccessful, but the case aside, couldn't EA have just said, "Oops, sorry mates, we'll come up with something else."? I'm developing because I want to secure a real future for my family, but I make $10 an hour busing tables, getting sued would mean financial ruin, right? I barely manage to pay my bills and feed myself, so a Lawyer isn't an option, and there's no other way I know of to be absolutely sure I'm not infringing on someone else's rights.


texts:
I've been wanting to make a small game engine (relatively. basic features, predefined shaders) to learn that side of game development and I was wondering how game engines export projects to create executables.

I would imagine that they copy over all the necessary code and remove the editor from the code base. Or perhaps they are engineered in a way that completely abstracts the game code and the editor code?

If someone could explain the pipeline of how they export the game, I can do the rest of the research and experimentation myself.


texts:
The first image shows a spotlight shining correctly on the floor.
The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

The third image shows the light "half if and half out"

Can anyone understand what is happening here?

Normal mapping code:

Shader.fs

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}

The model is Sponza by crytek.
Loaded using Assimp Model Loader.


texts: How do I detect pixel-level collision using andEngine?

texts:
I'm developing a game for Android using andEngine, and I need to detect collisions only when two objects visually collide (not in blank space of the image). In J2ME, I'm able to do that using helicopterSprite.collidesWith(buildingSprite, true).

However, andEngine only has helicopterSprite.collidesWith(buildingSprite). What is the equivalent method for andEngine? How do I invoke pixel-level collision?


texts: Where/how should A Star tie breaking occur?

texts:
I've recently written a path finding script that utilizes a basic implementation of the A Star algorithm.  It works fine but is not very fast.  This is due, at least in part, to the fact that it isn't optimized at all.  Through a bit of searching through this site and others I've realized that at least one thing I need is a tie breaking procedure that updates the heuristic values of nodes in the open list.  Currently, whenever the pathfinder function is initiated.  The pattern the finder takes pretty much expands outward in all directions from the point of origin until the target node is found.  I've seen several videos that show A Star almost immediately traveling towards the target node thus eliminating many checks and ultimately speeding up the process.  I believe this is due to a tie breaking procedure.

My question is...  At what point in the process should I be applying the tie breaking procedure and is there a better modifier to add to the heuristic aside from the below code?:

Node.heuristic += (Mathf.Abs((Node.x * endNodeVector.z) - (endNodeVector.x * Node.z)) * 0.001F);

This seems to be the most common that I have found.  However, for some reason, this doesn't seem to effect the algorithm at all.  It still searches in all directions from the origin position. What am I missing to make my A Star favor open list nodes that are closer to the target?


texts: How should I isolate game entities with their concrete Drawable components (in C#)?

texts:
I've designed my game entities using a common pattern of separating the entity from its components.  In my case, I've used the Strategy pattern to give each of my entities an IDrawable component.

I construct my entities using a factory, which constructs the entity and adds an appropriate drawable, e.g.:

public static PlayerEntity CreatePlayerEntity(...)
{
   PlayerEntity playerEntity = new PlayerEntity(...);
   SpriteDrawable spriteDrawable = new SpriteDrawable(...);
   playerEntity.Drawable = spriteDrawable;

   ...

   return playerEntity;
}

Now here's the question: If I later want to update the player drawable in some way (e.g. modify the sprite, change the animation, etc.), how and where should I do this?

My first thought is to have C# events that the PlayerEntity publishes and the Drawable subscribes to, but this gets tricky from a purist standpoint, because it's hard to do this without the Drawable requiring a reference to a PlayerEntity.  My current hacky solution is to subscribe to these events from within the CreatePlayerEntity() method itself, using anonymous delegates, which can take advantage of the fact that you've still got a reference to the concrete IDrawable implementation.  It just doesn't seem right for the factory to have this responsibility, though:

public static PlayerEntity CreatePlayerEntity(...)
{
   PlayerEntity playerEntity = new PlayerEntity(...);
   SpriteDrawable spriteDrawable = new SpriteDrawable(...);
   playerEntity.Drawable = spriteDrawable;

  playerEntity.SomeEvent += new EventHandler((sender, e) => { spriteDrawable.Texture = blah; });

   ...

   return playerEntity;
}

What is a better, approved way to accomplish this communication between concrete implementations?


texts: Using Java on mobile, should I avoid object construction to reduce GC overhead?

texts:
I new to both Java and game development and working on my first LibGDX game targeting mobile systems.

How problematic is the garbage collector in a mobile environment? Should I try to reuse as many class instances as possible (e.g. with the object pool pattern), or only do it for the classes that I use most (like projectiles)?

How what instantiation rate warrants this optimisation? Or is the compiler “sufficiently smart” to effectively nullify this problem?


texts: Coordinate spaces and transformation matrices

texts:
I'm trying to get an object from object space, into projected space using these intermediate matrices:

The first matrix (I) is the one that transforms from object space into inertial space, but since my object is not rotated or translated in any way inside the object space, this matrix is the 4x4 identity matrix.

The second matrix (W) is the one that transforms from inertial space into world space, which is just a scale transform matrix of factor a = 14.1 on all coordinates, since the inertial space origin coincides with the world space origin.

    /a 0 0 0\
W = |0 a 0 0|
    |0 0 a 0|
    \0 0 0 1/

The third matrix (C) is the one that transforms from world space, into camera space. This matrix is a translation matrix with a translation of (0, 0, 10), because I want the camera to be located behind the object, so the object must be positioned 10 units into the z axis.

    /1 0 0  0\
C = |0 1 0  0|
    |0 0 1 10|
    \0 0 0  1/

And finally, the fourth matrix is the projection matrix (P). Bearing in mind that the eye is at the origin of the world space and the projection plane is defined by z = 1, the projection matrix is:

    /1 0 0   0\
P = |0 1 0   0|
    |0 0 1   0|
    \0 0 1/d 0/

where d is the distance from the eye to the projection plane, so d = 1.

I'm multiplying them like this: (((P x C) x W) x I) x V, where V is the vertex' coordinates in column vector form:

    /x\
V = |y|
    |z|
    \1/

After I get the result, I divide x and y coordinates by w to get the actual screen coordinates.

Apparenly, I'm doing something wrong or missing something completely here, because it's not rendering properly. Here's a picture of what is supposed to be the bottom side of the Stanford Dragon:

Also, I should add that this is a software renderer so no DirectX or OpenGL stuff here.


texts:
i'm using the script down below to make my camera look at mouse x and y position, and it has a limitation for my camera rotation.the problem is the way my camera rotates is not smooth at all.is there any way to make it smoothly look at position on x and y?

    rotationX += Input.GetAxis("Mouse X") * sensitivityX;

    rotationX = Mathf.Clamp(rotationX, minimumX, maximumX);

    rotationY += Input.GetAxis("Mouse Y") * sensitivityY ;

    rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

    transform.localEulerAngles = new Vector3(-rotationY , rotationX, 0);


texts: When designing and play-testing a new game, a lot of the time, the people trying out functionality get used to things, and no longer try the "dumb ways" any more. So if the development breaks something, it may be a feature only a new user would bother trying. What are some of the best ways to make sure that your game has its "stupid cases" tested when it's finally released, or after a major update? Methodology, software assistance, maybe even sites where people will play-test for you, et ceteras.


texts:
I'm currently developing a small, cross-platform game for Windows/OSX. I have XInput support working correctly on the Windows version. I've left off Mac controller support until now and I'm struggling to find an analogous library on OS X.

Does something similar to the XInput API exist for OS X or am I on my own for that?


texts: How to create a 2d jelly/soft/blob body?

texts:
I'm a developer looking into game development. I have an idea that requires a 'character' that needs a jelly like body. I've found this video which really demonstrates what I want.

I've looked around and there are libraries/assets that do this (like Jelly Sprites) but none state how they do it, and that's what I'm interrested in.

What I've read so far is that a way of doing it is using multiple rigid bodies joined with joints that don't collide with each other. Witht he common sidenote that it might not perform that well.

I'm hoping anyone has any pointers or tutorials that explain the concepts of jelly/soft/blob bodies. Any pointers towards achieving the effect shown in the video would be awesome.


texts: How to Make Games Faster (Without Sacrificing Quality)

texts:
I posted a similar question on the Programmers SE site. Please read it. I want to know what specific things I can do to help me create games faster.

Already, in addition to whatever I wrote there, I am:

Creating reusable libraries on top of existing engines that I'm using
Creating reusable assets (graphics, sounds, icons)
Finding sites where I can find assets quickly (graphics, sounds, icons)
Using game engines instead of writing code from scratch
Using agile so my game is customer-focused and gets results
Biting off small games (like a vanilla rogue-like)

I feel it's not enough; I'm taking far too long to make games. A simple chemistry puzzle game, for example, took nearly 40 hours -- and that's with only half-decent graphics.

What are your recommendations? How can I get better and faster?


texts: Wait for vSync without swapping buffers with SDL

texts:
I am trying to optimize my SDL rendering loop for an immediate mode GUI application that doesn't need to be redrawn every frame. I have vSync turned on and would like to skip buffer clearing / drawing altogether if the GUI hasn't changed.

The problem is, swapping buffers without redrawing causes flickering because of double / triple buffering. On the other hand, also skipping the buffer swap causes the program to run full throttle because the waiting is effectively done in SDL_GL_SwapWindow.

Ideally I would need some kind of function that waits for vSync without swapping buffers, but I haven't seen one in the SDL documentation. I've tried the following solutions but none are satisfying:

Drawing VBOs every frame even if they haven't been updated. That will reduce load on the CPU but not on the GPU, so not ideal.
Keeping track of which backbuffers are up to date, and only redraw them if they are dirty. This worked in my testing but requires to make some assumptions (the number of backbuffers, and hoping the driver didn't replace them with fresh ones). So not reliable enough.
Manually waiting with a small delay. Probably the most reliable, but still not ideal.


texts: Meshes imported into Unity into Blender always corrupt

texts: I want to import a terrain mesh I made in Blender into Unity, however Unity seems to fail to load it correctly. What could be the reason behind this and how can I fix it?


texts: What advantages does bare OpenGL provide over frameworks/engines to small developers?

texts:
I've noticed a trend of indie developers steering away from frameworks and engines, and moving towards using bare OpenGL, or using it combined with SDL/SFML2. As an indie developer, I can't see what low-level OpenGL can offer over separate engines or frameworks.

Most decent engines and frameworks give the functionality that you need, and never get in your way. They might also open the option to deal with OpenGL directly. Some even offer the functionality to compile cross-platform!

I understand the aspiration to learn what is happening below the hood, but I can't see any upsides that OpenGL might offer to indie developers over engines or frameworks.

Could you explain the reasoning behind building games from scratch using OpenGL?


texts: Why does order matter in constant buffers?

texts:
I have a rather peculiar question remaining after solving most of my own question on StackOverflow. When creating the constant buffers used by my shaders, I've learned that the order of variables between the cbuffer and the struct representing it have to be an accurate match. I am still unsure as to why this is such an issue, and that's why I'm here.

When creating a cbuffer to hold object data, I create the cbuffer and struct like so:

cbuffer ObjectBuffer : register(b0) {
    float4x4 World;
    float4x4 WorldViewProjection;
    float4x4 WorldInverseTranspose;
}
public struct ObjectBuffer {
    public Matrix World;
    public Matrix WorldViewProjection;
    public Matrix WorldInverseTranspose;
}

This way works just fine, but if I reorder the cbuffer variables, or the struct variables and do not reflect the changes in the other, issues arise and I can't even create the buffer.

cbuffer ObjectBuffer : register(b0) {
    float4x4 WorldInverseTranspose;
    float4x4 WorldViewProjection;
    float4x4 World;
}
public struct ObjectBuffer {
    public Matrix World;
    public Matrix WorldViewProjection;
    public Matrix WorldInverseTranspose;
}

In this case, the types are exactly the same and given the fact that HLSL expects constant buffers to be in 16 byte chunks; why does the ordering matter so much?

Aren't float4x4 types the same as Matrix types where it's essentially an array of arrays?

[ 0, 0, 0, 0 ] = 16 bytes
[ 0, 0, 0, 0 ] = 16 bytes
[ 0, 0, 0, 0 ] = 16 bytes
[ 0, 0, 0, 0 ] = 16 bytes
[    TOTAL   ] = 64 bytes

Since a float is 4 bytes on its own, this would mean a float4 is 16 bytes, and thus a float4x4 is 64 bytes. So why does the order matter if the size remained the same?

Update

So I've re-visited the issue and turns out I was wrong about the issue given above. This does allow the objects to be compiled correctly but presents grotesque effects in the shaders since the variables are in the wrong order which is expected.

However, this issue came up because I misread which buffer was causing the issue initially. It was all related to my material buffer in which I have a bool and a float. When I swapped the two on either side without reflecting the changes in the other it failed to create. I presume this is due to the difference in expected types. The cbuffer is in bool-float order while the struct is the opposite. This I expect to cause an issue, but it would still be nice to know what's happening under the hood to cause it to break. Is it because bool is a single byte but perhaps allocated into a chunk of 4 bytes?


texts: How to blend textures with different size optimally?

texts:
I am trying to create a 2D lighting map.

For each light source I have an Color[,] with size less than whole map and a coordinate of center. There can be many light sources and they can intersect (2 or more, so I can't just sum it).

I need to blend all light colors for every map pixel, not override.

Is there a better approach other than to loop over every light for each map pixel, get colors and mix them?


texts: Structure GameObject - States - Visual representation

texts:
Question: What is the best data structure for GameObjects that have different states and thus different visuals?

The situation is:

I'm creating a game for mobiles (written in Kotlin, no Engine used).

My simplified object structure looks like this:

I have 2 GameObjects (e.g. Person and Obstacle)

Each GameObject might have two different states (IDLE and MOVE)

But each state might also have different graphics. For instance depending on the movement direction, the MOVE state might show Bitmap-Left or Bitmap-Right.

  Person -> WALK-State -> Visualisation (WALK, PERSON) -> draw(bitmap_walk_left_person)

My problem is, that I'm really not sure about that structure. Should I make subclasses for each State or a composition? One Visual object for each State (e.g. MOVE, IDLE, TALK) containing all Bitmaps for Person and Obstacle and always showing the right one depending on the parent?

Currently it looks like this:

I have the GameObject. The object has a state that is called in the update() method (e.g. moving a bit to the left).
Every State has a "Visual" object that knows its parent State (State = WALK). It draws itself related to its states type (e.g. WALK) and considers (if needed) the orientation (left or right).

This felt like it keeps structures as abstract as possible but I'm not sure sure thats a good solution because all objects have to keep references to their "parents". So the visuals need a reference to the state (WALK) and to the GameObject (Person) in order to draw the visual for a walking person.
Would it be better to create subclases for each State?
So I have a class "VISUAL_MOVE_PERSON", "VISUAL_IDLE_PERSON", "VISUAL_IDLE_TREE" ... That seems a lot of redundant code and classes.

Is there a common structure for Actions / States and their Visual Representation? Especially since I will have many more objects with at least a few different states (IDLE, MOVE, TALK, ...)

Should the visuals be part of each state? Or are they independent to each other (e.g. GameObjects have a State and a Visuals object) instead of the "chain of references" shown above?


texts: How to make a multiplayer game work reliably behind NAT?

texts:
Even games that are 100% client/server sometimes have issues when the client is behind NAT. Peee-peer games are even a bigger issues. Some games need to use multiple transports (such as UDP and TCP) or multiple connections (such as a different UDP port for voice).

What are some ways to make sure a game works reliably when running behind a NAT router?

Peer-Peer: No centralized server exists. Player A starts a game and Player B wants to join
Client-Server: A centralized server on a well known address (hostname) accepts all incoming connections. Each client only communicates with that server.
Combo: Where the server is just matchmaking, but game updates are peer-peer. Different peers may see each player with a different IP/port potentially (e.g. some clients are behind the same NAT and some are on a different router)


texts: Can LittleBigPlanet2's engine be used for other?

texts: LittleBigPlanet2 just came out. I've worked with the original LBP level editor a bit and really enjoyed it. I've read that LBP2's featureset in the game is much richer; is it possible to use these advanced features to create different sorts of game other than just a regular platformer? I imagine that something along the lines of a Breakout clone would definitely be manageable, but I'm interested in hearing more about the capabilities of the platform.


texts: LibGDX's particle emitter - Multiple particles in the same effect?

texts:
Hello everyone reading this,

I've used the particle editor to edit an effect to put in my game.
Is it possible to have multiple and randomly emitted images (particles) instead of one?

I don't want to create for example 3 particle effects in the same position for having the result I want.


texts: In a visual novel game, What makes a story immersive?

texts:
I am planing to make a Visual Novel Game using RenPy and was wondering, how do I make the story immersive to the players playing?

In this Horror Game, there will be drama, thrill and mystery to solve. You are playing as one character and interacting with a couple NPCs.

So what I am really asking is how do I make the charcter’s in the game likable and hate able to give off that feeling of “you are inside the story and not just watching a movie”. Is it the story, is it the dialogue or is it the graphics? or just something else that I am missing.


texts:
Possible Duplicate:
  Tips for writing the main game loop?

I am attempting to make a game using OpenGL and C++ but i haven't been able to find any good tutorials..or anything that could assist me in setting up my main game loop with some kind of timer/tick system...i would prefer to use as little external libraries as possible...i am using Win32
any help would be appreciated


texts: simple data source on hard disk for android game

texts: i have a big library on my game. its word library. there is no need of it to be on ram.any moment some part of it can be searched so there is no need to make a list or dictionary for it. is there any type of file data that can be added to apk file?


texts: Unity UI Text Font Size changes with the screen resolution Problem

texts:
I am working on a project and now I have a problem . The problem is the font size.
The font size is OK inside the Unity but it is really small when I play the game on a real Android device .

My Canvas has 2 text (a and b) and 1 image .

I created an empty game object to hold that text.

Here is the code attached to empty game object :-

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Text_Script : MonoBehaviour
{

public Text My_Text_1 ;
public Text My_Text_2 ;

// Use this for initialization
void Start ()
{
    My_Text_1.text = "Hello";
    My_Text_2.text = "World";
}

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

}
}

Here are the images :-

Inside Unity

Inside a Android Device (here I uploaded the image from BlueStacks , I didn't use my mobile)

So why this is happening ?

I tried this :-

function Start()
{
     var myText = GetComponent(GUIText);
     // 50 is the fontsize you want to use
     myText.fontSize = Mathf.Min(screen.height,screen.width)/50;
}

but I don't know where to put and on which object should I put those code And I am using Unity 5 and that code is for Unity 4.x .

I don't want to scale the font for a large size as explained in YouTube video (I don't think this is a good method)

So is there any ways to change the font size according to the screen size and resolution .

Please help me

Thanks:)


texts:
I have an animation of traffic. I have 20 cars in road network, each car have a starting node and end node. Each car know how much distance does it need to travel in order to reach the end node. I move cars each 20 ms for 10 px. To move all cars from their start node to end node I need 60 iterations. That is 60*20ms = 1200ms.

Now I want to convert this time, or use data that I have, to a real time where car move 50km/h. How can I do that? Any idea?


texts: Is locking required to implement a seperate rendering thread?

texts:
I have been reading a lot about this, but still not sure about a proper way to implement an independent render thread, using a variable time step and running in parallel to a physics thread, which uses a smaller, fixed time step. I'm familiar with the mechanics of mutexes and locking, when it comes to concurrent write access, but a render function would only read, and never modify.

Would a locking mechanism be required, at all, for using two buffers - a read buffer that is used by the renderer, while the physics engine modified the write buffer, and swapping after it's finished?

Even with only one buffer, I could imagine that you wouldn't even notice when some objects are updated, while rendering, having interpolation anyway and the much higher render frame rate. The only problem I see, with one buffer, is when objects would be deleted from physics and the renderer still trys to access them.

What is the main problem there? I am not talking about, for example, a concurrent physics and AI that both modify - only one additional render thread.


texts: synchronizing character movement in different clients

texts:
i want to synchronize the character movement in different clients,
while i got an problem here.
The script below is attach at the other players' characters,
say if you are player A in client A, then the player B,C,D.....' characters will have the below script.
My problem is that:
When player A in client A moving forward at the same time using a normal attack.
for example, pressing key "up arrow" and "z" (without key up).
In client A, it give me the expected result,i.e. player A standing at the current position and playing the normalatt animation repeatedly without moving.

While when the above data send to the server and receive by player B,
player A character in client B, did play the normalatt animation , but when the animation end, SOMETIMES it will move forward before the animation replay.

How can i correct the script so that player A in client B won't move forward before player A in client A key up the key "z"

an video showing my problem

void Update () {
       if(moving){
         transform.position += transform.forward*speed ;
       }
    }

    //and event which get response from server
    void updatecharactermovement(int playeruid,string command,float rotx,float roty,float rotz){
        //if an character move, change it direction
       if(command=="move"){
         if(playeruid==this.playerid){
          transform.eulerAngles=new Vector3(rotx,roty,rotx);
          moving=true;
         }
       }

       //if a character stop, reset it position
       if(command=="stop"){
         if(playeruid==this.playerid){
          transform.position=new Vector3(rotx,roty,rotz);
          moving=false;
         }
       }

    }

//function which play the character skills
    void updatecharacterskill(int playerid,string skill){
       if(playerid==this.playerid){
         if(skill=="normalatt"){
          animation.CrossFade("normalatt");
          StartCoroutine(attacting(skill));
         }
       }
    }

 // allow the character continue to move until the skill animation end
public IEnumerator attacting(string skill){
         moving=false;
         animation.CrossFade(skill);
         yield return new WaitForSeconds ( (float) animation[skill].length);
         moving=true;
    }


texts:
I want to flip my asymmetric 3d model horizontally in the vertex shader alongside an arbitrary plane parallel to the YZ plane. This should switch everything for the model from the left hand side to the right hand side (like flipping it in Photoshop). Doing it in pixel shader would be a huge computational cost (extra RT, more fullscreen samples...), so it must be done in the vertex shader.
Once more: this is NOT reflection, i need to flip THE WHOLE MODEL.

I thought I could simply do the following:

Turn off culling.
Run the following code in the vertex shader:

input.Position = mul(input.Position, World);

// World[3][0] holds x value of the model's pivot in the World.
if (input.Position.x <= World[3][0])
    input.Position.x += World[3][0] - input.Position.x;
else
    input.Position.x -= input.Position.x - World[3][0];

...

The model is never drawn. Where am I wrong? I presume that messes up the index buffer. Can something be done about it?

P.S. it's INSANELY HARD to format code here.

Thanks to Panda I found my problem. SOLUTION:

// Do thins before anything else in the vertex shader.
Position.x *= -1;   // To invert alongside the object's YZ plane.


texts: Random.range giving me the same value at the same time

texts:
I created a random direction in x and y-axis at where to move, then my problem is when I tried to randomize it sometimes I get the same value at the same time on both x and y-axis. How do I not let this happen, I only want one axis to have a value, not both?

ERROR

HOW I WANT IT TO HAPPEN

CODE

public Vector2 randomDirection;

void Awake()
{
}

void Update()
{
    randomDirection = new Vector2(Random.Range(-1, 2), Random.Range(-1, 2));
}


texts: Bullet prefab gets stuck to target after hitting

texts:
As the title says, I am having an issue with prefabs: I am trying to make a bullet follow a curve and then hit a target using this method:

private IEnumerator BezierShooting()
{
    GameObject shotInstance = new GameObject();
    shotInstance = Instantiate(shotPrefab, transform.position, Quaternion.identity);
    Vector3 currentPosition = new Vector3();
    if (shotInstance != null)
    {
        while (t < 1 && shotInstance != null)
        {
            currentPosition = Mathf.Pow(1 - t, 3) * controlPoint0.position +
                            3 * Mathf.Pow(1 - t, 2) * t * controlPoint1.position +
                            3 * (1 - t) * Mathf.Pow(t, 2) * controlPoint2.position +
                            Mathf.Pow(t, 3) * controlPoint3.position;
            Debug.Log(currentPosition);
            shotInstance.transform.position = currentPosition;
            t += 0.02f;
            yield return new WaitForEndOfFrame();
        }
    }
    else
    {
        currentPosition = transform.position;
        t = 0;
        yield break;
    }

}

Where t is a float variable that I initialised before as well as the transforms controlPoint0, controlPoint1, controlPoint2 and controlPoint3.

The bullet is succesfully following the path that I created, however the problem is that once the bullet hits an object in position (x, y, z) and gets destroyed, if I call the method again the prefab will spawn in the last position it was on. I thought that final else statement would do the trick, but appearantly I am missing something. Can somebody help me please?


texts:
I have been researching this for 2 days now and I cannot seem to find a proper response. I am trying to figure out a good way to store constant variables within my game.

Basically, does it make more sense to create a singleton script that holds all my prefabs inside it so I can easily access them and instantiate through the game? Or does it make more sense to keep all my assets inside the Resources folder and then call Resources.Load throughout the game (or through a Static class that holds references to all the resource paths and loads the resources on start up)

I have the same question regarding variables used within runtime. Would it be better to run through the Static class that is holding all these prefabs through the Resources folder? Or would it make sense to also hold these values inside the singleton.

Thank you!


texts:
I made an animated main menu introducing my game. In the menu there is snow and fog to create a more alive feel to it. Now I want to add a hawk that randomly spawns and flies across the screen in the distance.

Any idea how I'd create a "path" for it to follow? The path would be a curved line or something for the hawk to follow to simulate realistic movement. I have no idea how to design this.

As a side note, I'm writing this game in Löve2D.


texts: Is speed runs ranking mechanism heuristic or statistics based?

texts:
I'm looking to implement some sort of speed run mode in my game.

Let's say I want to assign each level three 'winning' bars, (bronze, silver and gold for example), which are independent of the player, and are based only on the difficulty of the level itself.

I can think of two methods:

Having a heuristic which outputs these three bars, given the level's settings.
Spending some time for testing the game over several players, and collecting statistics (mainly time to completion), in order to determine the bars.

Are both methods considered acceptable? Or is one of them is somewhat "banned"?

I would also like to consider a more limited situation, where there's not a real option to perform a wide-scale statistics collection. Would that completely throw the second method off the windows? Or is small-scaled (for example, having 5-10 players playing a level for a few times) is usually enough in common indie game developer scales?

I guess the answer here should depend on the nature of the game itself, but I wonder if this certain type of test ('winning bars' for speed runs) is considered easy to handle.


texts:
I am trying to write a Python function for Blender(2.66) game engine, that permits me to detect collision between two objects.

I tried to read the documentation, but it's very confusing, and I don't understand it.

Someone have an example how to do it?


texts: How to set the layer texture2d image in unity

texts:
I am working on onscreen arrow indicator. I have placed some sphere on the screen and attached the code below to each gameobject. And also I have a canvas,which consist of a panel.

public Texture2D icon; //The icon. Preferably an arrow pointing upwards.
public float iconSize = 50f;
[HideInInspector]
public GUIStyle arrowIndicator; //GUIStyle to make the box around the icon invisible. Public so that everything has the default stats.
Vector2 indRange;
float scaleRes = Screen.width / 500; //The width of the screen divided by 500. Will make the GUI automatically
//scale with varying resolutions.
Camera cam;
public bool visible = false; //Whether or not the object is visible in the camera.

void Start () {
    visible = GetComponent<SpriteRenderer> ().isVisible;

    cam = Camera.main; //Don't use Camera.main in a looping method, its very slow, as Camera.main actually
    //does a GameObject.Find for an object tagged with MainCamera.

    indRange.x = Screen.width - (Screen.width / 6);
    indRange.y = Screen.height - (Screen.height / 7);
    indRange /= 2f;

    arrowIndicator.normal.textColor = new Vector4 (0, 0, 0, 0); //Makes the box around the icon invisible.

}

void OnGUI () {
    if (visible) {
        Vector3 dir = transform.position - cam.transform.position;
        dir = Vector3.Normalize (dir);
        dir.y *= -1f;

        Vector2 indPos = new Vector2 (indRange.x * dir.x, indRange.y * dir.y);
        indPos = new Vector2 ((Screen.width / 2) + indPos.x,
            (Screen.height / 2) + indPos.y);

        Vector3 pdir = transform.position - cam.ScreenToWorldPoint(new Vector3(indPos.x, indPos.y,
            transform.position.z));
        pdir = Vector3.Normalize(pdir);

        float angle = Mathf.Atan2(pdir.x, pdir.y) * Mathf.Rad2Deg;

        GUIUtility.RotateAroundPivot(angle, indPos); //Rotates the GUI. Only rotates GUI drawn after the rotate is called, not before.
        GUI.Box (new Rect (indPos.x, indPos.y, scaleRes * iconSize, scaleRes * iconSize), icon,arrowIndicator);
        GUIUtility.RotateAroundPivot(0, indPos); //Rotates GUI back to the default so that GUI drawn after is not rotated.
    }
}

public void OnBecameInvisible() {
    visible = false;
}
//Turns off the indicator if object is onscreen.
public void OnBecameVisible() {
    visible = true;
}

the onscreen arrow is getting displayed on the screen

the problem is that ,the arrow mark is getting displayed on the canvas. I need to  display the arrow mark below the canvas.Is there any way to set the layer,so that the arrow is visible below the canvas.


texts:
I've made a simple game but when I tried to load this on chrome its not loading.

I am building for WebGL (HTML 5). I am getting these errors when the page loads.

Unity version - 5.3.1f1   Chrome version - 47.0.2526.106 m

Its working fine on firefox .

XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.jsgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.mem. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.memgz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.DecompressAndLoadFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.data. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.LoadCompressedFile @ UnityLoader.js:1
UnityLoader.js:1 XMLHttpRequest cannot load file:///C:/Users/Public/Documents/Unity%20Projects/Box%20Shooter/HTML5%20Builds/Release/HTML5%20Builds.datagz. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

Why its not loading up on chrome ?


texts: How should I license my game so others may not distribute copies?

texts:
I've created a game and I'm unsure how to license it or what that means.

I've heard of Creative Commons licenses. Should I use that?

I want it so that people that download my game cannot remix or distribute copies, even for non commercial purposes. What should I do in such a case?


texts: Unity Augmenter Reality on Android with Video playing

texts:
Hey sisters and brothers,
So, I created an augmented reality marker, which works perfectly, I was able to display 3 shape on the screen with my Nexus 5.

I would like to replace my shapes with a Video. So, when the user track on the marker, I would like to start to play a video above the marker as a part of the augmented reality (No full screen playing).

I tried to use this video tutorial (https://www.youtube.com/watch?v=YBc3ubr18ks) , but on Android you can't use MovieTexture (they say).

My question(s): how can I display a shape above the marker, with a video on it and what it the video format ? When I trying to build the project with mp4, it failing, but when I do with AVI it's okay, but the app crashing.

Thank you,


texts: How to extend GameMaker Studio's IDE editor, like in Unity?

texts:
Unity allows you to create custom inspectors, custom editor windows and custom property drawers.

Is there a counterpart of this in GameMaker Studio 2.x or isn't it possible yet?


texts:
Say I have a big map for my HTML5 game. And it is drawn with an image repeatedly.
I want my map to be able to resize and respond to player's behaviors.

Now I can resize my map, I just multiply a scale to my maps coordinates (map.x and map.y) and the pattern image will become smaller. However I have two problems that I don't know how to resolve. Let's see what I have got so far.

My Sprite class use paintX and paintY to represent the drawing position. And they are defined as followed:

  get paintX() {
    return map.scale * this.x - frame.x;
  }

  get paintY() {
    return map.scale * this.y - frame.y;
  }

where frame is the view that follows my player when my player moves. In my game my player stays at the middle of the screen and the screen will move with my player. So when the map resizes the player's position will also change but it will stay in the middle of the screen.

In Frame class its x and y coordinates will change when the scale is updated.

init(config) {
  const self = this;
  this._x = config.x;
  this._y = config.y;
  map.on('scale_changed', () => {
      self._x = map.scale * self._x;
      self._y = map.scale * self._y;
  });
}

get x() {
    return this._x;
}

set x(val) {
    this._x = val;
}

get y() {
    return this._y;
}

set y(val) {
    this._y = val;
}

The Problems

1 I have thousands of sprites on the map. After resizing the map some sprites still stay in the same location but they are supposed to render at a scaled location. ( I use very large scale change to test so the change is like 0.2 to 0.3 just to see the result more clearly)

2 If I use very small scale change number such as 0.01 I can still see the change but I can also see some hiccups refreshing the map, then it renders OK again, but overtime it becomes messy and presents problem 1.

Without scaling none of these problems exists. I am scratching my head to find a solution for this resizing problem. Is there a standard and not so complicated solution for this map resizing problem?


texts:
I've received a few instructions on what kind of usage UV maps allows, and currently try to understand how it works. However, I can't figure out what kind of data there is inside a UV map.

Googling around, I found... almost nothing. Maybe this simple example. That was totally unexpected. Is it non standard, with as many possibilities as software vendors ?

Anyway, if that is the case, I'm nonetheless interesting in understanding what kind of data can be found inside an UV map save file, in order to properly complement my understanding of the process, and try to figure out what kind of post-processing would be possible.


texts: Should I move the world or move the player?

texts:
I'm about to start developing a sidescrolling game where the player's goal is to travel as far as he can in the horizontal axis before touching down. Note that I do not need to ever travel back on the horizontal axis.

I'm developing this with the AndEngine for Android which uses OpenGL and Box2d.

Before starting, I need to decide on something important: should I use the world around the player to simulate movement or actually move the player and follow him with the camera features of the game engine?

Both approaches seems to have different strengths and fallbacks, so I don't know which one is considered best. For example, what would make it easier to add power ups along the way and have a nice animated background?

Thanks!


texts: As seen here NiftyGUI has it's own GameState classes, I want to know if for adding UI to one state of my game I need to make that state NiftyOverlayGameState or still a BasicGameState but to add a NiftyOverlayGameState as well.


texts: How can I install SharpDX for my project?

texts:
Unfortunately, as an experienced developer, I can not find the download link for SharpDX's binary files on SharpDX's download page here

https://www.nuget.org/packages/SharpDX/4.2.0

I am very surprised about the high download numbers.

How do I actually download/install this?


texts: Recommended method towards making custom maps for a 2d game?

texts:
I am planning on making a 2D game, however different from my last personal projects I want this one to have enhanced graphics, with custom-designed levels. My previous 2d platformers were tile-based, in which I made a map editor for to create levels.

However, I am wondering the best way to implement custom designed maps? For say, some grass is a litter higher than others, flowers here and there, cool drawings and structures along the way, etc. instead of just the same old tiles over and over again. I am thinking but I just can't grasp the idea of how to implement it. I have seen it done in other games and am interested to see how they accomplish it, but can't get my hands on some source code. :(


texts:
I would like to use Unity's WWW class to send a an HTTP request with POST data. So in my server, my PHP script can do something like

$number = $_POST["NUMBER"];

According to http://docs.unity3d.com/ScriptReference/WWW-ctor.html, I can provide a byte array in the constructor to represent such data.

I'm a bit puzzled - suppose I want to send a mapping from "NUMBER" to 200 - how would I create a byte array compatible with my PHP script in Unity C#?


texts: How do I apply a Isometric tile to a Diamond shaped Div

texts:
I want to be able to apply my isometric tile

To a diamond shaped div

However I can't seem to create the isometric shaped div.

Closest I got to it was this http://jsfiddle.net/P3yKr/2/ but even then thats not going to allow me to apply the image as the background for it.


texts: How to avoid duplication using client-server model

texts:
I am using a client-server model to write a multiplayer-capable game (in Java). Currently the clients and the server are using the same code to run the game logic, in order to enable client-side prediction. This makes sense to me, since I don't want to have to duplicate my entire codebase to make this work.

However, there are certain things that should only be done by the clients (e.g. send user input to the server, update camera position, play sounds, etc.) and certain things that should only be done by the server (e.g. send messages to the clients, remove entities, etc.).

How can I share the same code between my client and server without peppering it with "if client", "if server", etc.?

EDIT: It has been suggested that I should extract all common code into a library and have 2 separate projects - the client and the server - each of which should extend the common code to include custom functionality. But won't this still result in a lot of duplication?

To take an example: let's say I have an Entity class. Whenever an Entity moves, it should play a sound if it's on the client, and send a TCP message if it's on the server. Therefore I create 2 other classes, ClientEntity and ServerEntity, both of which extend Entity. Now all of a sudden my Zombie class, which previously extended Entity, needs to be duplicated across the client and server projects so that the client version can extend ClientEntity, and the server version can extend ServerEntity.

If I have a lot of classes that all extend Entity, then this results in a lot of duplication. What am I missing here? :)


texts:
I'm developing a 3D engine in software, and so I must compute Z sorting manually. I'm currently using the painter's algorithm to sort triangles and then drawing them back-to-front. This causes artifacts that I'm trying to correct.

Would using a dynamic BSP-tree ensure "correct Z sorting" of triangles? Why? Because the bounding volumes of triangles would be similar?
Since I would have a single "world" BSP tree, would I have to remove and re-add any moved/scaled/rotated object into the tree?
Is it possible to add triangles into a BSP tree without the expensive cutting process? Why do you need to cut triangles on the axis planes anyway?
Is it faster to traverse a BSP tree from any angle, than to sort all tris each draw like the painters algorithm?


texts: How can I play an audio source while a key is being held down?

texts:
if (Input.GetKey(KeyCode.A))
        {
            audioSource.Play();
        }

Except this only functions once as the key is held down. Same goes with GetKeyDown. Is there any way I can get this to loop as long as they key is being held down? (Is in Update)


texts: 3ds Max error dialog: "Instancing not supported for this action"

texts:
"Instancing not supported for this action” is the dialog I get. My favorite part is that, according to google and yahoo, apparently i am the only person in the history of mankind to experience these words together in this order, let along get this message from Max. Thanks, autodesk, for putting this dialog in special for me!

So I’ve created my model (nws) and was setting up a Skin Wrap. Selected "Face Deformation", added the base-skin for weight, checked “weight all points”. . . clicked “convert to skin” and got that dialog.

My model doesn’t have a whole lot of elements to it, I had a left and right appendage that came from a base model (skyrim). so, i did a clone>copy of all 3 of my elements, just to be sure nothing was instanced… and VOILA! Same error message. the only other elements are an imported NIF mesh and skeleton.

Any idea where this is coming from or how I can make it go away so that I can export my mesh?


texts: JFrame launcher stays open when I'm finished with it

texts:
I have written a launcher that prompts the user for their name then starts the game when they hit enter. The launcher looks like this:

But when the user hits enter, this happens:

The launcher stays open.

This is the relevant code in the launcher class:

    public void actionPerformed(ActionEvent evt) {
        String text = textField.getText();
        System.out.println(text);
        entered=true;
        Game game = new Game();
        game.start(text);
    }

    public void Launch() {
        //Create and set up the window.

        JFrame frame = new JFrame("Login");
     // maximize the jframe here
        frame.setSize(800,600);
        frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Add contents to the window.
        frame.add(new Launcher());
        //Display the window.
        frame.pack();
        frame.setVisible(true);
        while(entered==true){}
    }

And this is for the main method in the game:

    public static void main(String[] argv) {
        Launcher launcher = new Launcher();
        launcher.Launch();
    }

So how would I go about closing the launcher when the user has no use for it?

I am using a JFrame for the launcher and Lwjgl for the actual game window.


texts: Showing keyboard on SKScene and performing action on a sprite node based on key tapped

texts:
I am trying to learn SpriteKit and play with some simple sample apps.

Currently I am trying to achieve below things:

Show keyboard over SKScene
If user taps 'A', perform some action on a sprite node, if user taps 'B' perform some other action on other sprite nodes

I tried to google 'Showing keyboard over SKScene' but could not get any suitable answer :(

Any clues or suggestions?


texts: Game server for an android/iOS turn-based board-game

texts:
I am currently programming an iPhone game and I would like to create an online multiplayer mode. In the future, this app will be port to Android devices, so I was wondering how to create the game-server?

First at all, which language should I choose? How to make a server able to communicate both with programs written in objective-c and Java?

Then, how to effectively do it? Is it good if I open a socket by client (there'll be 2)? What kind of information should I send to the server? to the clients?


texts:
I'm wondering how to engineer a client server sync of entities in a multiplayer game which is using an ECS.

When the server changes some values of the components of an entity, I thought the best approach is to send a new update message over the network,
which holds some ID or name of the entity. And then on the client site, I'm trying to resolve the client-side-counterpart of that entity.

But, In my ECS solution (ashley) the entities are not held in a list. So I can't just search for a special entity by ID or something.

I was thinking about giving every entity a new component like "NetworkSyncComponent" which holds an ID, but than
I have to iterate over all entities on the target system which are holding such an component. This seems very bad and slow approach for me.

TL;DR
Can you tell me what a better (faster/performance optimized) technique could look like?


texts: How to make healthbar size relative to hp

texts:
Like in most games with healthbars, the units in my game have a hp_bar object which is a frame, with a slightly smaller rectangle inside which should get smaller (and change color) as a unit loses hp, but I'm unsure how to work the math which will make the rectangle size an integer which represents an percentage rather than the actual hp.

Say the hp bar is 40 pixels in width, and hp is some arbitrary integer amount, what is the python magic to convert the hp to hp bar width?


texts: Collision detection problem in monogame C#

texts:
protected virtual void CollisionDetection()
    {
        if (CanGoRight() == false) pos.X -= velocity;
    }

    protected bool IsTouchingLeft(Basic2d asset)
    {
        return pos.X + dims.X / 2 > asset.pos.X &&
               pos.X - dims.X / 2 < asset.pos.X &&
               pos.Y + dims.Y / 2 < asset.pos.Y + dims.Y &&
               pos.Y - dims.Y / 2 > asset.pos.Y;
    }

    protected bool CanGoRight()
    {
        foreach (Basic2d asset in Globals.GameAssets)
            if (IsTouchingLeft(asset) == true) return false;
        return true;
    }
}

That's my code(just starting) for collision detection. All of this code is in Character class which has also methods for moving and updating and displaying character.

I struggle with collision detection. I have all my assets(blocks) in the list of objects which is in the class named Globals. Class character is a subclass of a Basic2d class(this is class for all bricks assets).

So I check if a character is overlapping with any of bricks from the list. Criteria for checking left side overlapping is in the IsTouchingLeft method and it doesn't work. I cannot see what is wrong with this code, but every time I change sth it works differently but not well.

What should I change?

And the object of Character class has an origin point in in the center of the texture, but the object of Basic2d class has origin point in the bottom left corner.


texts:
I am making a multiplayer game in Unity, with a socket.io server in NodeJS.
I am using a globe, with a texture to represent the world in Unity.

Let's say something similar do this.

Now, there I am stuck with some algorithm.

I would like to generate equally distant point, on the lands, where user can build stuff.

Something similar to this :

I saw this post here post and I would like to generate the map in the server, create from the generate map a mongoDB collection of point. When a user connect, he get back a list of point (that are already generated and can interact with those).

I get stuck on the generation. How do I make the server generate point based on a map that I will show to client, but that the server do not have idea of ? How would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point ?

Basically, I don't know where to start to make this algorithm. I just would like some idea on how you would achieve this, so I can inspire myself to find my solution.


texts: TileEntitySpecialRenderer only renders from certain angle

texts:
I'm developing a Minecraft mod with Forge. I've added a tileentity and a custom renderer for it. The problem is: The block is only visible from sertain angles. I've compaed my code to other peoples code and it looks pretty much like them.

The block is opaque and not to be rendered and the renderer is registered normally so the fault must be in the renderer.

Here's the renderer code:

public class TERender extends TileEntitySpecialRenderer
{
    public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)d, (float)d1, (float)d2);
        HeatConductTileEntity TE = (HeatConductTileEntity)tileEntity;
        renderBlock(TE, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, mod.EMHeatConductor);
        GL11.glPopMatrix();
    }

    public void renderBlock(HeatConductTileEntity tl, World world, int i, int j, int k, Block block)
    {
        Tessellator tessellator = Tessellator.instance;
        GL11.glColor3f(1, 1, 1);
        tessellator.startDrawingQuads();
        tessellator.addVertex(0, 0, 0);
        tessellator.addVertex(1, 0, 0);
        tessellator.addVertex(1, 1, 0);
        tessellator.addVertex(0, 1, 0);
        tessellator.draw();
    }
}


texts: Stencil Buffer not working as expected in OpenGL ES 2.0 (Android)

texts:
I'm trying to get to grips with the stencil buffer.

Apart from setting up viewport, camera, etc, my OpenGL ES 2.0 initialisation code is:

GLES20.glDisable(GLES20.GL_CULL_FACE);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glEnable(GLES20.GL_STENCIL_TEST);

GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glClearColor(0.2f, 0.8f, 1.0f, 0);
GLES20.glClearStencil(0);

My main code is below.

        GLES20.glEnable(GLES20.GL_STENCIL_TEST);
        GLES20.glColorMask(false, false, false, false);
        GLES20.glStencilFunc(GLES20.GL_NEVER, 1, 0xFF);
        GLES20.glStencilOp(GLES20.GL_REPLACE, GLES20.GL_KEEP, GLES20.GL_KEEP);

        GLES20.glStencilMask(0xFF);
        GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);

        // draw sprites
        player.draw();

        GLES20.glColorMask(true, true, true, true);
        GLES20.glDepthMask(true);
        GLES20.glStencilMask(0x00); // don't effect the stencil buffer
        GLES20.glStencilFunc(GLES20.GL_EQUAL, 0, 0xFF);
        // draw where stencils value is 0 if we want...

        GLES20.glStencilFunc(GLES20.GL_EQUAL, 1, 0xFF);
        // draw where stencils value is 1 if we want...

        level.draw();

        GLES20.glDisable(GLES20.GL_STENCIL_TEST);

However, this doesn't work. As expected this code does not draw the payer. The player (or the filled square surrounding the player) should be drawn to the stencil buffer. The next part of the code should draw the level, which should be clipped to the boundary of the player (or the square boundary of the player). What this code actually does is draw the whole level.

Why is the code not clipping the level to the profile of the player, or at least the square bounding the player ?


texts: Accessing DualShock 4 motion sensor in Windows (ideally Unity)

texts:
I'm trying to use a DualShock 4's IMU as a motion controller in Unity, under Windows 7.

So far I've tried:

DS4Windows (1.5.11): reads motion sensor data, but does not expose them to Unity as axes unless I map them to the left & right sticks. This is not enough since I lose use of the sticks, I can only fit 4 of the 6 channels of data, and the values coming through are clipped into a narrow range.
Motioninjoy (0.7.1001): does not appear to detect the DS4 as a controller (latest docs refer only to DS3 and prior)
GlovePIE (0.43): after following instructions for using the DualShock 3 with LibUSB-Win32 (a long shot), SixAxis properties are all blank.

In the past I've used external programs like GlovePIE to capture Wii remote motion sensor data and pass it to Unity via OSC messages, so I'd be open to an approach like this if I can't get Unity to read the controller's sensors directly through its Input system.

Anyone had luck with this?


texts: Unity [MenuItem] disappears when `priority` is 100

texts:
Create these classes:

public class MyTestComponent : MonoBehaviour
{
}

-

[CustomEditor(typeof(MyTestComponent))]
public class MyTestComponentEditor : Editor
{
    [MenuItem("GameObject/XXX/DoTest", false, 100)]
    private static void DoTest()
    {
        Debug.Log("DoTest");
    }
}

save, and check if there is a new menu item in the context menu and it won't be there. Now change the priority parameter to 10 or 1 and try again - it won't appear anyway. Sometimes even commenting/uncommenting and reloading the editor doesn't help.

Is this a bug or am I doing something wrong?


texts: textelFetch returns black value with sampler2D when level is greater than 0

texts:
I am trying to write a code for rendering a object with material properties (diffuse and specular). I am trying to use textures to pass float data to the vertex shader (I am accessing the textures in vertex shader). I have two textures with 7 miplevels each to pass data pertaining to specular reflections. I am using texelFetch to access the data. But if the level of the texture is greater than 0, then the value returned by texelFetch is invariably 0. Here is the code used to setup the textures in c++.

glGenTextures(1,&textures[1]);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
for(int mipLevel = 0; mipLevel < 7; mipLevel++)
{
    glTexImage2D(GL_TEXTURE_2D, mipLevel, GL_R32F, 129, 129, 0, GL_RED, GL_FLOAT, specularTextures[mipLevel]);
    delete[] specularTextures[mipLevel];
}

As one can see I am using only the Red channel to pass the data. Now in vertex shader code I access the texture.

#version 450 core
layout (location = 0) in vec4 aVertex;
layout (location = 1) in vec4 aNormal;
layout (location = 2) in vec4 diffuseAlbedo;
layout (location = 3) in vec4 specularAlbedo;
layout (location = 4) in ivec4 brdfIndices[5];
layout (location = 9) in vec4 brdfWeights[5];

out vec4 ourColor;

uniform mat4 projection;
uniform mat4 view;
uniform vec3 camCenter;

uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture1;
uniform sampler2D specularTexture2;

int main()
{
    gl_Position = projection * view * aVertex;
    float value = texelFetch(specularTexture1, ivec2(10,10), 1).r;
    ourColor = vec4(vec3(value),1);
}

No matter what index I use to access the texture with level greater than 0 ( 1 in this case) I get value = 0. But if the level is 0 I am getting correct value. I tried to look online but no one was facing the similar problem, so I am guessing it is some kind of silly mistake.

Note: I am binding the textures everytime I am rendering.


texts:
In my tower defense game and every tile has its own mouse event listener. I am wondering, would it be better to use one event listener (MouseEvent.CLICK) and then when it runs the function, should I just use evt.target to determine what was clicked, and then run an appropriate function?

I am programming the game for web and phone and I started to notice some lag on my phone so I am trying to optimize my code. Any other tips to speed up code would help too.


texts:
I have a texture and vertex which are needed to create a set of closed polygons. For this purpose I use these functions:

Code for create texture:

CCSprite* spr = CCSprite::spriteWithTexture(mShape->getTexture());

spr->setPosition(ccp(spr->getTextureRect().size.width/2, spr->getTextureRect().size.height/2));
spr->setFlipY(true);

CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight(mShape->getTextureRect().size.width, mShape->getTextureRect().size.height);

texture->beginWithClear(1, 1, 1, 0);
spr->visit();

glColor4f(0, 0, 0, 1);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);

for(int i=0; i < innerBorders.size(); i++) {
    std::vector<Vector2d> sitePoints = innerBorders.at(i);

    for(int n=1; n < sitePoints.size(); n++ ) {
        Vector2d origin = sitePoints.at(n-1);
        Vector2d destination = sitePoints.at(n);

        drawSmoothLine(ccp(origin.GetX(), origin.GetY()), ccp(destination.GetX(), destination.GetY()), 0.25f);
    }
}

glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glColor4f(1.0, 1.0, 1.0, 1.0);

texture->end();

drawSmoothLine method:

drawSmoothLine(CCPoint pos1, CCPoint pos2, float width){
GLfloat lineVertices[12], curc[4];
GLint   ir, ig, ib, ia;
CCPoint dir, tan;

width = width*8;
dir.x = pos2.x - pos1.x;
dir.y = pos2.y - pos1.y;
float len = sqrtf(dir.x*dir.x+dir.y*dir.y);
if(len<0.00001)
    return;
dir.x = dir.x/len;
dir.y = dir.y/len;
tan.x = -width*dir.y;
tan.y = width*dir.x;

lineVertices[0] = pos1.x + tan.x;
lineVertices[1] = pos1.y + tan.y;
lineVertices[2] = pos2.x + tan.x;
lineVertices[3] = pos2.y + tan.y;
lineVertices[4] = pos1.x;
lineVertices[5] = pos1.y;
lineVertices[6] = pos2.x;
lineVertices[7] = pos2.y;
lineVertices[8] = pos1.x - tan.x;
lineVertices[9] = pos1.y - tan.y;
lineVertices[10] = pos2.x - tan.x;
lineVertices[11] = pos2.y - tan.y;

glGetFloatv(GL_CURRENT_COLOR,curc);
ir = 255.0*curc[0];
ig = 255.0*curc[1];
ib = 255.0*curc[2];
ia = 255.0*curc[3];

const GLubyte lineColors[] = {
    ir, ig, ib, 0,
    ir, ig, ib, 0,
    ir, ig, ib, ia,
    ir, ig, ib, ia,
    ir, ig, ib, 0,
    ir, ig, ib, 0,
};

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, lineVertices);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, lineColors);
glDisable(GL_TEXTURE_2D);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 6);
glEnable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);}

I need to get the texture of the contour (without the main texture on the background.) How can it be done using openGL ES 1.1?


texts: How do I get the id of an object that created a point in a path?

texts:
I'm making a rollercoaster tycoon type game. As the title says, I need to get the id of an object that created a path point. These points are currently greated by the rail pieces. I need this because each rail type (down, up, corners, etc) decides how fast the cart is going to go. The cart follows a path, with points created when a new rail is created. Normally, I would just use instance_place, but since the coaster has multiple levels (defined by z), I can't use this because some rails will overlap other. If you have any suggestions, I will be very grateful! For more information just ask and I will respond. Thank you for your time.

Here's a screenshot of the game for reference (the blue thing is the cart, the white numbers are the added or subtracted speed for that particular rail type):


texts: Hi i am trying to build screen animation like flickering, interlace, color separation similar to old style malfunctioning Amiga screens. The intended effects are shown in this  video. I am using libgdx and I already discovered the universal tween engine, which helps a lot to build transitional animations, but how should I approach those blending effects, any suggestions? I will specify my question once I learned more about libgdx, but maybe you could give me some hints already. Thanks!


texts: this.BoundingBox.Intersects(Wall[0].BoundingBox) not working properly

texts:
I seem to be having this problem a lot, I'm still learning XNA / C# and well, trying to make a classic paddle and ball game. The problem I run into (and after debugging have no answer) is that everytime I run my game and press either of the movement keys, the Paddle won't move. Debugging shows that it never gets to the movement part, but I can't understand why not?

Here's my code:

    // This is the If statement for checking Left movement.
    if (keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.A))
        {
            if (!CheckCollision(walls[0]))
            {
                Location.X -= Velocity;
            }
        }

    //This is the CheckCollision(Wall wall) boolean
    public bool CheckCollision(Wall wall)
    {
        if (this.BoundingBox.Intersects(wall.BoundingBox))
        {
            return true;
        }
        return false;
    }

As far as I can tell there should be absolutely no problem with this, I initialize the bounding box in the constructor whenever a new instance of Walls and Paddle is created.

   this.BoundingBox = new Rectangle(0, 0, Sprite.Width, Sprite.Height);

Any idea as to why this isn't working?

I have previously succeeded with using the whole Location.X < Wall.Location.X + Wall.Texture.Width code... But to me that seems like too much coding if a simple boolean check could be done.


texts: gl_VertexID values when calling glDrawElements

texts:
I am struggling a bit to understand the values that gl_VertexID primitive contains when the vertex shader is executed.

I have the standard modern rendering pipeline, in which after setting up shaders, buffers, etc I call the code below to render a mesh

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, auxMesh->indicesBuffer);
    glDrawElements(GL_TRIANGLES, auxMesh->numIndices, GL_UNSIGNED_INT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

In the vertex shader I want to manually access to the current vertex being rendered retrieving it from the original buffer (I know this sounds nonsense, but I need to do this for a reason), therefore I pass the vertex buffer as the texture buffer u_tbo_tex and I access to the actual coordinates as follows:

vec3 vertex_1 = texelFetch(u_tbo_tex, gl_VertexID + 0).xyz;
vec3 vertex_2 = texelFetch(u_tbo_tex, gl_VertexID + 1).xyz;
vec3 vertex_3 = texelFetch(u_tbo_tex, gl_VertexID + 2).xyz;

And the values of these vertex vertex_1, vertex_2, vertex_3 make perfect sense.

However, I can't really understand what values gl_VertexID got in each iteration. Is gl_VertexID sequentially assigned following the range of [0...auxMesh->numIndices].  Or are the values increased +3 at every iteration because I am drawing triangles?

I need to understand this because I am interested in calling textureFetch(u_tbo_tex, i) where i is a arbitrary triangle in my mesh (or whatever i needs to be to access an arbitrary triangle), but I can't find the right way to access to it.


texts:
I'm using WWW class to sent a WWWForm to an asp.net server.
it used to work in unity 5.3.x but since I migrated to 5.6.3f1, it is not working and sending Send failed since rewinding of the data stream failed message.
I tried doing it with the UnityWebRequest but it couldn't send the data in the form and I would get null values in the server side.
here is my code:

        WWWForm WF = new WWWForm();
        WF.AddField("UserID", ServerProperties.user.UserID);
        WF.AddField("UserEmail", ServerProperties.user.Email);
        WF.AddField("UserPassword", ServerProperties.user.Password);
        //I'm sending some json as strings. I don't need to do anything to the json data on the server
        WF.AddField("PlnFile", Export);
        WWW www =new WWW(ServerProperties.ServerAddress + "/Unity/SaveDesign", WF);
        while (!www.isDone)
        {
            yield return www.progress;
        }
        if (www.error != null)
            debug.Log(www.error);
        else
            debug.Log(www.text);

And I'm getting this request with [HttpPost] on the server.

        [HttpPost]
        public ActionResult SaveDesign(DesignViewModel _Design)

I'm reaching a deadline and I really need this, any ideas is appreciated.


texts: Open GL ES 2.0 Android Texture,Shader, etc... loading

texts: I have gotten texture's to load along with shader's however it seems that I can only create shaders and textures in onSurfaceCreated in my implementation of the render interface. Is this truly the only place one can create shaders, textures, ...?


texts:
I'm wondering what is more performance friendly:

1) Rendering a texture (in a seperate RenderTarget2D) and reuse it. (That will use multiple spriteBatch.End() / spriteBatch.End() calls, every drawing cycle)

2) Rerendering the texture multiple times (directly on the default rendertarget), but using only a single spriteBtach Begin/End call.

I think it is pending on how many times I'm going to redraw that texture, but calling spriteBatch.End() / spriteBatch.End() is taking really much performance...

So what should I use, when the redrawing count is pending on the user?


texts:
I'm making a simple top down (like this) tile based game (using JavaScript, for reference)

I use Tiled for making maps. I have sprites that are more than one tile high, and so whenever they are in front or behind of some objects more than one tile high tiles will be displayed in front of the player. I am looking for a way to give certain tiles 'height' such that only characters of that height could appear in front of those tiles.

Here is a screenshot showing my problem (the sprite is doge because it was the first image I found):

The same tiles don't always equate to the same height, so I can't give tiles set height. I've thought of one way to give tiles height, and that is to have a (hidden) layer that describes the height level certain tiles are at.

However, that solution would be slow and painful to implement. I'm wondering if there's a better way to do it.

A few other potential ideas I've had: Have a tile layer for each height, hackily guess the height of a tile at runtime based on tiles below (would be buggy) but I think that there would surely be a better way to do it.


texts:
I got this photo from mixamo.com — I want to draw grid lines similar to this on my floor.

I'm sure this is easy by using textures, but I'm trying to avoid using textures as much as possible. Is there a way to implement these floor patterns in OpenGL 3.3?


texts: does glBindAttribLocation silently ignore names not found in a shader?

texts:
Does glBindAttribLocation silently ignore names that are not found? For example, in a shader:

// Some vertex shader
in vec3 position;
in vec3 normal;
// ...

And in some set up code:

// While setting up shader
GLuint program = glCreateProgram();
glBindAttribLocation(program, 0, "position");
glBindAttribLocation(program, 1, "normal");
glBindAttribLocation(program, 2, "color"); // What about this one?
glLinkProgram(program);


texts:
I think this isn't possible, but I just want to check this:

Is it possible to create a face in opengl that has two normals?

So: I want the inside and outside of some cilinder to be drawn, but I want the lights to do as expected and not calculate it for the normal given. I was trying to do this with backface culling off, so I would have both faces, but the light was wrongly calculated of course. Is this possible, or do I have to draw an inside and an outside? So draw twice?


texts: How do you make bullets move at an angle in different angles using delta

texts:
I'm having trouble making my bullets move at a steady pace using delta. I have the formula I used outside of slick2d, but it doesn't take delta into account. My bullets fly fast. How do I make them go slower.

x = x + (int) (length * Math.cos(this.angle));
y = y + (int) (length * Math.sin(this.angle));


texts: OpenGL 3.3 tilemap rendering techniques?

texts:
I'm trying to draw regular 2D tiles to the screen from a single texture but there are a few ways to accomplish this and I don't feel like I know enough about rendering to assess the trade-offs properly.

First of all, I have potentially a lot of tiles to render. Each tile is 8-32px (depending on zoom factor) and on a Full HD monitor that's over half a million tiles (and over a million triangles) per layer, and I have two layers. While I'm not going to go out of my way to support massive screens that are zoomed all the way out, I do want a solid reliable experience for players with screens up to 2048x2048px at any zoom, which ends up being about a quarter of a million triangles (before non-tile sprites, effects, and HUD elements are added on top).

I've been getting a lot of conflicting advice on what is good and what is bad to do with regard to tilemapping... What's been the nicest method so far to work with is instancing 6 points, two triangles in a square configuration, and giving each instance a position and texture position. But now I'm told instancing with less than 100 vertices creates a lot of overhead... Using a geometry shader to produce vertices is also crazy expensive and impracticable for hundreds of thousands of triangles, apparently. Sometimes I'm told triangle strips are the say to go, but you have to add in messy degenerate triangles when you have tilemap gaps. Other times triangles are said to be better.

Do all roads lead back to a static baked in array of all corners of each tile for efficiency?

Also, when you move left, right, up, down... you need to add in more tiles to the side... but how? Is there a way to do this that isn't messy and complicated?


texts:
Is there a good algorithm that simulates falling snow? I'm particularly interested in snow that falls slowly, so it doesn't quite fall in a straight line but deviates a bit. Maybe even including simulation of flurries (drafts of wind), variable size, etc. Are there any papers or articles on an algorithm that mimics real-life snow movements or simulates it in the context of a game?

I'm particularly interested in a 2D algorithm, but I imagine any algorithm can be taken to 3D easily.


texts: i'm drawing a text using a spritefont and the draw.string function of the spritebatch object. in some point, i need to augment the size of the text, so i use a variable to scale it. all this is working fine, but i need to find the center of the text to use as origin to make the effect look like i want. how can i find that center point of a text? when i use textures its easy because i just take half the texture width and height, but with a spritefont, i dont have any idea of how to proceed. Thanks.


texts: Calculating the resulting velocity after a reflection

texts:
I am trying to do a simple reflection of a point entity off of an arbitrary surface that contains it. It doesn't have to be physically correct but essentially the goal is to do the following:

if (isOutsideOfContainer()) {
   placeOnNearestEdgeOfContainer()
}
float2 container = getContainerNormal();
float2 newVelocity = f(velocity, container);

So essentially I am placing the out of bounds point on an edge of the container, getting the normal of the edge at that point on the container, and using that to calculate the new velocity vector.

How exactly do I do this?

I am doing this so that particles can "bounce" off of the edge of the screen as computationally cheaply as possible. Sometimes the screen will be a boring rectangle but other times it might be an iPhone X, or have half of its corners rounded. No-matter what the screen I want to properly simulate its bounce.


texts:
I'm creating an infinite terrain engine, which generates the terrain either with fractals or noise. How can I make dynamic shadows for the sun on this terrain, if I don't know in advance what will be rendered in front of the sun.

My terrain:
The sun is the only light, it is directional, my terrain is generated on a plane which is positioned before the camera, frustum culled and fits the size of the viewing frustum.
It is height mapped with generated noise texture, and using tessellation shaders on it.

Video:http://www.youtube.com/watch?v=tk6yFwYusOs
Dynamic shadows with the infinite terrain.


texts: How to implement object velocity as a vector

texts:
I'm working on a Breakout game, and want to change the ball's movement code from how I currently do it, to something based on vectors (as I feel learning and implementing movement based on vectors will help me in the long run).

Currently I am doing something like this (Pseudocode):

if(ball.Y < HEIGHT)
    ball.Y += 1; // I actually save a direction as well,
                 //and multiply this by the direction (1 or -1)
else
    ball.Y -= 1;

if(ball.X < WIDTH)
    ball.X += 1;
else
    ball.X -=1;

Anyway, you get the gist of it. My current code is actually much more verbose, but handles collisions well. Basically I am just using screen coordinates, and I find that this is probably not the best way to be doing this.

How would you implement a more correct, extensible (to other projects), way to move objects?

EDIT:
I am not looking to use a 2D Vector library; more-so I am looking for an explanation of how vectors are used for movement in games, and how I can implement them myself.


texts: How to make sure there's always a walkable path for enemies in a tower-defense game?

texts:
I am making a 2D tower defense game. So far I have a 2d array which acts as a grid for my game. I'm able to place towers on it, run enemies and some dragging and tower firing stuff.

Now I am facing a problem in tower placement logic. I want that there's always a walkable path for enemies, meaning that the user should not be able to block the way completely by placing towers. Eg. if the user places towers vertically on a map, the algorithm must prevent the placement of a tower that will complete the vertical line. Or in any other way there must be at least one free (walkable) space so that the enemy can escape.

My current logic checks in all directions whenever tower has placed. If there is a tower upwards it calls the same function again on that upper tower until it hits a wall. It returns 1 for upward wall and 5 for downward wall and returns function(up/down tower) if there is a tower. here is the code:

int checkCollision(tower)
{
    if( there is a  tower up)
    return checkCollision(up tower);

    if(there is a tower down)
    return checkCollision(down tower);

            ......all directions.....

    if( there is a wall on UP )
        return 1;

    if( there is a wall DOWN )
        return 5;

        ....all walls......

    return 0;
}

Now what I want is, simultaneously check if there is a northern wall and southern wall or check any other directions with any other possibility (like up-down, up-diagonal, down diagonal... and so on) to not let the user place a tower as there should be one place left for enemy.

I am unhappy with my code at the moment. I mean my code tells me that a wall is found but how can I check that a wall is found in one direction and a wall also found in another direction? I dont want to go into possibilities like:

if(checkCollision(tower) == 1 && checkCollision(tower) == 5)
  "You cannot place"

I want something like:

    if( any combination of more than 2 wall found and there is entry/exit point in between)  //so it is wall to wall
    "You cant place"

I have also tried pre-calculating flags if there are walls on two sides (like up-down, up-diagonal etc.) then don't let the user place the tower but that still doesn't work.


texts:
There's nothing quite like the routine of tweaking a variable, compiling code that takes a few minutes, executing the code, realizing that your tweak was in the wrong direction and repeating the process all over again.

I would like to start interacting with my game logic while a session is in progress. What are some of the ways you've handled doing this?

I would be open to hear solutions for iOS, C/C++ and C#/XNA.


texts: Audio not playing until after button release when it should be playing while it's pressed

texts:
I am trying to play the sound of a car accelerating while a user has a certain button pressed, however, the audio clip isn't playing until after that button is released.  Can anyone explain to me where I'm going wrong?

C#

using UnityEngine;
using System.Collections;

public class MoveCar:MonoBehaviour{
    //Car's idle speed
    private float idleSpeed = 0.0f;
    //Car's current speed
    private float speed = 0.0f;
    //Car's top speed
    public float topSpeed = 165.0f;
    //Car's acceleration rate
    public float acceleration = 10.0f;
    //Car's braking power
    public float deceleration = 15.0f;
    private Rigidbody playerCar;

    void Start(){
        playerCar = GetComponent<Rigidbody>();

    }

    void Update(){
        if(Input.GetKey(KeyCode.W)){
            AudioSource accelerate = playerCar.GetComponent<AudioSource>();
            float horizontal = Input.GetAxis("Horizontal");
            float vertical = Input.GetAxis("Vertical");
            if(speed <= topSpeed){
                accelerate.Play();
                speed = speed + (acceleration * Time.deltaTime);
                Vector3 movement = new Vector3(vertical, 0.0f, horizontal);
                playerCar.AddForce(movement * Mathf.Clamp(speed, idleSpeed, topSpeed));
                Debug.Log(Mathf.Clamp(speed, idleSpeed, topSpeed));
            }
            else{
                speed = topSpeed;
                Debug.Log(Mathf.Clamp(speed, idleSpeed, topSpeed));
            }
        }
    }
}

Here's my editor windows


texts: Time based events separate from the game loop

texts:
How can set up time elapsed based events separate from the game loop?

I want the character to heal over real time rather than per cycle of the game loop.  How might i do that?


texts: How to keep track of players nearby other players in an MMO

texts:
I'm confused how to handle the players in my MMO server (using Socket.IO but I think this should apply to any MMO).

Suppose there are 2 players in my server that are far away from eachother. I will call them A and B in this example.

The server launches. No clients are connected.

A joins and is added to the server's active playerlist.

Every second A gets a list from the server with the active players nearby to update their positions. Since there are none online currently, the list is empty.

B joins, far away from A. The server adds B to the active playerlist.
Since A cannot see B yet, the list that A receives from the server is still empty.

B is moving towards A and comes within visual range.

What to do now for A? Send an event to A that B has come within range? How can the server know that A was informed of B being nearby? Does this mean I have to maintain a list on the server which player can see another?

Here's what I was doing before with my previous project: I never told the clients that a player was in range, instead the server just sent a list every second of players that are nearby and let the client do the rest. This way, the client keeps track which unit is added and which is not. Is this the best approach, or am I missing something?


texts: Enable SteamVR hand collision for when holding objects

texts:
Just getting started on a game project with SteamVR in Unity. I've run into an issue with the collisions though. The hands and the objects that can be held collide with everything in the scene as they should. But when an object is picked up, the hand and the object stop colliding with everything.

How would I go about fixing this? I could leave it as is, but if an object is let go of inside another, it gets flung out of the object it was inside.

The other odd behavior happens after you let an item go. The hand that was holding it continues to not collide with anything until you move the hand away. After that it'll collide with everything normally again.


texts:
I am at the beginning of the creation of a space 4x and first of all i need to generate a galaxy of stars linked by connecting lines that changes in each new game, I'll add a few pictures to show what i want

So how can i have a simple 2d map with connected points like these images ? I thought to program each line with a random length and a random angle or program polygons by polygons but it is still unclear.


texts:
For this project I am using GLFW, glad and glm.
My window looks like this:

The dimensions of the window are correct, but the viewport is stretched, making my square into a rectangle.
How do I use a 16:9 resolution (1280x720) without my viewport stretching?

This is what the window should look like:

I have a projection matrix set up in my code, and sent to my shader:

projection = glm::perspective(glm::radians(camera.fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f);
glUniformMatrix4fv(glGetUniformLocation(basicShader.ID, "projectionMatrix"), 1, GL_FALSE, glm::value_ptr(projection));

EDIT:
So I update the viewport everytime the window is resized, to it's correct dimensions. But now, even with a 1:1 (600x600) aspect, the square remains a rectangle. So I guess it isn't the viewport's fault? So something else is causing the stretch, as far I know the vertices aren't at fault, seeing as they're correct:

std::vector<GLfloat> vert {
         1,  0,  0,   1.0, 0.0,
        -1,  0,  0,   0.0, 0.0,
        -1,  1,  0,   0.0, 1.0,
         1,  1,  0,   1.0, 1.0,
        -1,  1,  0,   0.0, 1.0,
         1,  0,  0,   1.0, 0.0
};

And the modelMatrix is set up correctly, without any changes being made to it.

My vertex shader:

#version 330 core
layout (location = 0) in vec3 Pos;
layout (location = 1) in vec2 TexCoord;

out vec2 texCoord;

uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;

void main() {

    gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(Pos.x, Pos.y, Pos.z, 1.0f);
    texCoord = TexCoord;
}


texts: In Unity, I'm trying to understand what code gets generated when I attach scripts to GameObjects

texts:
I'm trying to observe any file changes that happen when I attach a script to a GameObject.
I am able to attach a script to a GameObject, and verify that it was attached by looking at the console log. (In my case I attached MainPlayer to some random GameObject like WeaponCamera.)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainPlayer : MonoBehaviour
{
    public string myName;
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("I am alive and my name is " + myName);
    }

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

    }
}

However, I don't see any actual code change (eg: line additions) to any files in my unity project (using git status or git diff). I would think that something would get updated in my repo, unless I'm misunderstanding how attachment works? For example, if someone else were to copy my repo and try it on their computer, shouldn't they have the attachment I just made?


texts: Programming a game onto multiple platforms

texts:
I just had a pretty good idea for a mobile game and I'm having a little trouble selecting what tools or languages to use for the job.

I have experience with flash and AS3 and I know I can put that onto mobile devices via Adobe Air. What I found kind of frustrating was that I have 5 games on my Samsung galaxy tablet and they all look like they were made in flash, but they didn't use Air. The only game that required Air on my tablet was my game that I made in flash. Anyways, how do you guys think/know they are programmed?

A simple game like angry birds... is that programmed in pure java or something or do they use some kind of engine. I've heard of Unity and it looks pretty cool, but now I just found ShiVa and that also looks pretty sick. I'm trying to make a Castle Crashers type game. Side scrolling/2D type of thing. Thanks in advance


texts: Why can't UObject derived objects call BlueprintFunctionLibrary functions?

texts:
My question is a very simple one.

Why can't UObject derived classes (direct inheritance) call functions from Blueprint Function Libraries?

__

Edit:

My question relates to Blueprints only.

An Object derived Blueprint seems to be incapable of calling functions from an editor-created BlueprintFunctionLibrary


texts: MonoGame - Get the 2D area of a 3D object

texts:
I'm writing a 2d game, but decided to make some 3d objects that my 2d character can pick up.

I've got them displaying on the screen - but can't work out how to get the 2d area that the 3d object is displayed at (so I can do 2d collision detection).

Here's the code that draws my 3D objects - I can see that there's a projection object and have been poking around in there. But no luck so far ...

    foreach (var mesh in Model.Meshes)
    {
        foreach (BasicEffect currentEffect in mesh.Effects)
        {
            currentEffect.EnableDefaultLighting();
            currentEffect.World = (transforms[mesh.ParentBone.Index] * GetMatrix());
            currentEffect.View = viewMatrix;
            currentEffect.Projection = projectionMatrix;

        }
        mesh.Draw();
    }


texts: Loading next scene when counter is down to 0

texts:
I am trying to let my Unity project load next scene when the counter I have is down to 0. However I am unable to do that for some reason. The way I am trying to do it by :

    int i = SceneManager.GetActiveScene().buildIndex;

    void Update () {
     if (GameObject.FindGameObjectsWithTag("Birds") == null)
        {
            SceneManager.LoadScene(i + 1);
        }
    }

In the editor I have created a folder where I have made 3 scenes. Have called them Level 1, Level 2 etc.

What am I doing wrong?