texts: Recursive method causes an OutOfMemory error

texts:
If a GameObject in my game has a special ability it triggers it, but I want all the special GameObjects that this GameObject affects to also trigger their abilities, for example if a bomb hits some objects, if these objects are also bombs, trigger them too. I though this would be easy by calling the method that handles all the special abilities recursively, but it wasn't. Basically what happened is a chain reaction of bullcrap that caused Unity to show an OurOfMemory error. Also makes my PC freeze completely while politely turning all the screens off.

The question is, how can I make it so it triggers all the affected cubes' special abilities, without everything going nuts?

Code:

     //Triggers the cube's special ability, if it has any
    private void TriggerSpecialCubeAbility(GameObject specialCube) {
        switch (specialCube.tag) {

            //Destroy all cubes in a radius from the special cube
            case "Bomb":
                TriggerBombAbility(specialCube);
                break;

            //Destroy all cubes of the same color as the special cube
            case "Lighting":
                TriggerLightingAbility(specialCube);
                break;
            default:
                break;
        }
    }

    private void TriggerBombAbility(GameObject specialCube) {
        var nearbyColliders = Physics2D.OverlapCircleAll(specialCube.transform.position, explosionRadius);
        Instantiate(particles[0], specialCube.transform.position, specialCube.transform.rotation);
        Instantiate(particles[1], specialCube.transform.position, specialCube.transform.rotation);

        foreach (var collider in nearbyColliders) {
            if (collider.tag == "Indestructible")
                return;

            var affectedCube = collider.gameObject;
            TriggerSpecialCubeAbility(affectedCube);
            Destroy(affectedCube);
        }

        destroySelectedCubes = true;
    }


texts: How can I reuse objects without depending on prefabs?

texts:
I have several "frames" in a scene, each frame holds a different image.

These frames all hold the same scripts and are in a way instances of the same concept, but the image is different in each frame.

I want to find a solution for reusability. If I make a change in the hierarchy or add a script to the frame, I don't want to have to go through all the frames and make the same change.

The prefab system works for this case in all ways but one:

There are desirable differences between the frames that I want to keep (the image for instance). But if I make a change to one frame, and click the "Apply" button, all the settings of the current frame will apply to all other frames, including the ones that are desirable.

Is there a solution for this other than "Be careful not to click the Apply button" ?


texts: What is DirectX 11's equivalent of D3DCAPS9::MaxVertexIndex of DirectX 9?

texts:
I'm porting a DirectX 9 program to DirectX 11. How do I get the value in DirectX 11 that is retrieved using

D3DCAPS9::MaxVertexIndex

in DirectX 9?

Thanks in advance.


texts: Objects disappear when zoomed out in Unity

texts:
Ignore the palm trees here.
I have some oak-like trees when I'm zoomed in:

They disappear when I zoom out:

Is this normal? Is this something to do with draw distance? How can I change this so my trees don't disappear?
The reason I ask is because my installation had a weird terrain glitch. If this isn't normal I'm going to reinstall right away because I'm always thinking 'is that a feature? Or a glitch'?


texts: How does Windows GDI work compared to DirectX/OpenGL?

texts:
OpenGL and DirectX, if we are talking about graphics, are somehow built into a graphics card and you can access them using appropriate environment and draw some graphics.

After reading wiki, I came to a thought that even though GDI doesn't use hardware directly as DirectX/OpenGL, it still get its access to a graphics card after some manipulations.

What is GDI and how does it work in compare to these two?


texts:
I have a game in play store and trying to get it to the upper places on the search engine. As I read, the package name should be similar to the game title. What is the effect of it in the searches?

I also made a lot of keyword research and added the relevant keywords to the title and description. Hovewer, I still can not see my game in a good place when I make a search.

What other things are necessary for my game to be at a better point in search results?

Thank you very much for your answers and suggestions.


texts: How can I solve the jerky images when camera positions were calculated and sent from another computer?

texts:
I'm working on a simulator project. Computer A which uses a stick as a controller to produce operation data and calculate simulate data which will be sent to computer B as camera positions to render the 3D scene. They both run on 60FPS averagely.

The problem is that I found that the frame time cannot be 16.66ms strictly which produces the jerky images. For example, computer A sends the camera position at 15ms (which is means where the camera should be at 15ms). Then computer B receives the data successfully and start to render that frame, but the render time is 18ms (not because the render was too slow I use vSync to limit the FPS but it cannot be strict for every frame). Then the image was swapped at 18ms which should be swapped at 15ms. More importantly, the frame time float around 15ms-18ms, although the average FPS was 60.

Now I'm using interpolation to solve this problem. It has great help, but cannot fix this problem perfectly. Is there a better solution? Thank you for helping me out.

This is part of my code about interpolation.

long long nowTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
long long time = firstReceiveTime + nowTime - firstRenderTime;

CameraParamterNode* current = head;
while ((current->next->next != nullptr) && current->next->data->frameTime < time)
{
    current = current->next;
}

double diff = static_cast<double>(time - current->data->frameTime) / (current->next->data->frameTime - current->data->frameTime);

pos = (current->next->data->pos - current->data->pos) * diff + current->data->pos;
dir = (current->next->data->dir - current->data->dir) * diff + current->data->dir;
up = (current->next->data->up - current->data->up) * diff + current->data->up;


texts:
I'm trying to generate a macbeth chart using the compute shader, but there seems to be an issue with the output image.

here is the glsl code:

#version 430 core

layout (local_size_x = 32, local_size_y = 32) in;

layout (rgba32f, binding=0) uniform image2D data;

uniform int factor = 2;

const float colorMatchingFunc[3][72];
const float spectralData[24][36];
void spectrumToXYZ(uint colorIndex, out vec3 XYZ);

const mat3 XYZ_TO_RGB;
const float gamma = 1;

void main(void){

    uvec2 dim = gl_NumWorkGroups.xy/factor;
    uvec2 ij = gl_WorkGroupID.xy/factor;
    uint i = ij.x + dim.x * ij.y;

    vec3 xyz;
    spectrumToXYZ(i, xyz);

    vec3 rgb =  max(vec3(0), XYZ_TO_RGB * xyz);
    rgb = pow(rgb, vec3(1/gamma));

    imageStore(data, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1));
}

and here is the c++ setup

static int factor = 4;
static int patchSize = 32;
int width = 192 * factor;
int height = 128 * factor;
glActiveTexture(TEXTURE(_id));
glBindTexture(GL_TEXTURE_2D, _buffer);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, width, height);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDispatchCompute(_width / (patchSize), _height / (patchSize), 1);

This setup and glsl code makes sure I get a 6 * 4 macbeth chart.

I'm assuming regardless of which invocation/workgroup I end up in I should always generate the correct color for the patch I'm currently on. but I seem to have som aliasing especially on the bottom row and its very noticable all rows on lower resolutions.

Low resolution image:


texts: Can project.json jsList accept folder names?

texts: Using cocos2d for the web/js, it seems every script file must be explicitly added to project.json. Is there a way to give it a path instead, and it will load all scripts in the folder (and sub-folders too)?


texts: How to compare different states of my game? (rpg)

texts:
I'm working on a rpg, the battle system. I want to compare different scenario with each other.

For example, what if I play move A then move B ? or two times move A ? or ...?

I'm using a tree-structure to generate all possible scenario that can happen during the battle. There is no movement involved, I'm using a battle-system as in FF7, only skill choice matters. 4vs4 units

Trick is, the battle is turn based but not static. There is an Action Point bar for each unit (filling at different speed based on the unit's stats) and the unit with the most Ap (only if > 100) can play. If no unit is > 100, a "turn" will happend and all unit will gain some AP based on their speed. If no unit can play, a new turn will happen...until a unit is > 100 ap.

Each skills takes a different amount a AP to use. At turns 0 for example, we may have a unit with 140 AP that will play two times in a row for 2 actions of 20 AP each. Then other units at 100 AP may play.

It means that when I'm running a simulation of all possible outcome of a battle for my AI, I will have states (node in the tree), that will have a number a turns very different from other and from nodes at the same depth.

I dont know how to compare these nodes at all.

I was using Hp at first, but it is not enought. To prove it, consider the example: 1 vs 1 match. Unit A (opponent of AI) has only 1 move, a small attack that requieres 20 ap. Unit B (AI) has two moves : a small attack that takes 40 ap (and overall hit for very low damage compared to the opponent attack) and a second move that does nothing but consume 20 ap and that move can only be used during the 1st turn.

I will then have to compare two states :

•State 1 : AI use its attack . Opponent his attack. Units are at 60/80 ap respectively. 20 game turns passes and they are now at 80/100 ap. Opponent use his attack. 20 game turs passes and they are at 100/100 again and we are at turn 40.

•State 2 : AI use his move that does nothing. Opponent his attack. Units are at 80/80 ap. 20 games turns passes, they are now at 100/100 and we are at turns 20.

If I compare only HP, In state 1, AI will have an overall score a lower than in state 2 since it got attacked twice in state 1 and 1 times only in state 2.

If I only compare by Hp difference between AI & its opponenent, I would choose state 2 since AI lost less Hp than in state 1.

Running the simulation after state 1 and 2 will continue to show the same difference since after that point, both unit can only use one attack.

In the end, it makes my AI choose a stupid move because she thinks she is less likely to loose selecting it. Granted both move will eventually result in the defeat of the AI since its main attack is weak but I'd like my AI to nonetheless select as its first move, her attack skill and not a skill that does nothing.

I've tried weithing the overall gradient of score between the root state and the state I'm simulating by the number of turns but it does not work in all cases (it greatly depends on the number of turns and the difference between the root).

I was thinking of adding Ap ratio to my evaluation of states but in that example, we can see that in State 1 & 2, units are at the same AP anyway so it doesnt provide extra informations.

Anyone got ideas on how to compares my states from different turns ?


texts: android game change background image at every level?

texts:
I want to be able to have a different background image at each level of my game. Presently I have only one. There is no layout folder shown in Android Studio and all info I have searched shows how to do it with the layout xml.

I have found this code in GameLayer.java of my game. Actually I am reskinning the game so everything is already there, I just need to know how to have different bg images now. Code:

// background
CCSprite bg = new CCSprite("game/game_bg.png");
bg.setPosition(G.displayCenter());
addChild(bg);


texts:
So my 2D characters turn by setting flipX on Sprite Renderer.
I'm trying to turn them on other clients, but sprite is turning only on local client. And only host turns for all clients.

Here's my code:

RpcTurnChar(GetComponent<SpriteRenderer>().flipX, this.gameObject);

. . .

[ClientRpc]
void RpcTurnChar(bool flip, GameObject plr)
{
    plr.GetComponent<SpriteRenderer>().flipX = flip;
}

What am I doing wrong?


texts: Can we measure the distance between and AR marker and camera?

texts:
I'm in the middle of developing a game in Augmented Reality using Unity and ARToolkit plugin. I wanted to measure the approximate distance between the AR marker and the position of camera.
Can anyone help me with a solution to this problem?
Thanks in advance.


texts:
I'm making a top-down tiled game in Java, and now I'm coding the collision test, but it doesn't work. This collision function work only for top and left side of the blocks, and when I'm colliding, the player moves up without I do anything.

What is my mistake?There are better collision system? Thank you!

My code:

  public void update() {
        collide();

        if(up) y -= vely;
        if(down) y += vely;
        if(right) x += velx;
        if(left) x -= velx;
    }

    private void collide(){
        for(int i = 0; i < handler.objects.size(); i++){
            GameObject obj = handler.objects.get(i);
            if(obj.id() == ID.Block){
                if(getBounds().intersects(obj.getBounds())){
                    x += -velx;
                    y += -vely;
                }
            }
        }
    }

// is the same in all the classes
public Rectangle getBounds() {
    return new Rectangle((int)x,(int)y,width,height);
}


texts: Games development with a game loop that's abstracted away

texts:
Most game development happens with a main game loop.  Are there any good articles/blog posts/discussions about games without a game loop?  I imagine they'd mostly be web games, but I'd be interested in hearing otherwise.

(As a side note, I think it's really interesting that the concept is almost exclusively used in gaming as far as I'm aware, perhaps that may be another question.)

Edit:
I realize there's probably a redraw loop somewhere.  I guess what I really mean is a loop that is hidden to you.  Frames are something you as the developer are not concerned with as you're working on a higher level of abstraction.  E.g. someLootItem.moveTo(inventory, someAnimatationType) and that will move from the loot box to your inventory using the specified animation type without the game developer having to worry about the implementation details of that animation.

Maybe that's how "real" games end up working, but from reading most tutorials they seem to imply a much more granular level of control is used, but that might just be an artifact of being a tutorial.

Edit2:
I think most people are misunderstanding what I'm trying to ask, likely because I'm having trouble describing exactly what I'm trying to ask.  After some more thinking perhaps what I'm referring to is more along the lines of what I believe is referred to as "scripting" where you're working at a very high level and having some game engine take care of the low level details.

For example, take custom maps in Starcraft II or Warcraft III.  Many of the "maps" have gameplay that deviates enough from the primary game that they could be considered a separate game written on the same engine.  What I'm referring to then is along those lines.  I may be wrong because I only dabbed in the Warcraft III editor, but as far as I remember no where in the map editor do you control the game loop, and yet you can create many different games out of it.  In my mind, these are games in their own right.  If you're playing DotA you don't say you're playing Warcraft III, you say you're playing DotA because that's the actual game you're playing.

Such a system may impose limitations that don't exist if you're creating a game from scratch, but it greatly reduces development time because much of the "hard" work has already been done for you.

Hopefully that clarifies what I'm asking.  Another example of what is I mean, is when you write a web app, of course it communicates through sockets and TCP.  But does the average web developer doesn't explicitly write code for connecting sockets.  They just need to know about receiving a request and sending a response.  There are unique scenarios where you do occasionally need to use raw sockets, but it's generally rare in web development.

In a similar fashion, it's very possible to write a game without directly using the game loop, even though one is used behind the scenes.  Probably not a AAA title, but there must be hundreds of smaller scale games that can and possibly are written this way.  Are there any good resources on writing these "simpler" games?


texts:
Are there methods of automated testing of games?

Specific experiences are appreciated, with relevant information about the project such as platform and type of game if that helps with clarification.


texts: HLSL: An array of textures and sampler states

texts:
The shader must switch between multiple textures depending on the Alpha value of the original texture for each pixel. Now this would word fine if I didn't have to worry about SamplerStates. I have created my array of textures and can select a texture based on the Alpha value of the pixel. But how do I create an Array of SamplerStates and link it to my array of textures? I attempted to treat the SamplerState as a function by adding the (int i) but that didn't work. Also I can't use Texture.Sample since this is shader model 2.0.

//shader model 2.0 (DX9)
texture subTextures[255];
SamplerState MeshTextureSampler(int i)
{
    Texture = (subTextures[i]);
};

float4 SampleCompoundTexture(float2 texCoord, float4 diffuse)
{
    float4 SelectedColor = SAMPLE_TEXTURE(Texture, texCoord);
    int i = SelectedColor.a;
    texture SelectedTx = subTextures[i];
    return tex2D(MeshTextureSampler(i), texCoord) * diffuse;
}


texts: Should I draw directly on a CCLayer or a CCSprite?

texts:
Now I am a little confused in my cocos2d-x cpp project. I want to draw lines with user's finger touch. Following the screenshot of a CCScene:

In the screen, there are two squares. I want show an animation in the first square and let the second one draw lines with user touch.

Now these two squares are CCSprite. And I can draw dots in the second one on the CCLayer. But I am little confused that I should draw lines on the Sprite or on the Layer.

Or are there other ways to organize the code?


texts: What do I need to implement a side-scrolling screen, like in classic platformer games?

texts:
I'm working on a game in Allegro for C++. I'm stumped about how to scroll the screen.

I'm trying to make the screen scroll with the player, as it does in classic side-scroller games such as Super Mario Brothers. What is the approach I should take to implement such behavior?


texts:
I am trying to get the colors of the top left pixel in an image, I use this code:

 using (FileStream stream = File.OpenRead(animationFile))
 {
     animation = Texture2D.FromStream(graphicsDevice, stream);
 }

 Color[] animationData = new Color[1];
 animation.GetData<Color>(animationData, 0, 1);

When i run it I get an System.Argument exception saying: The date passed in is too large or too small for this resource"

Anyone know what I'm doing wrong?

Edit: Added code where i load the texture, I have also tried using the Content.Load method, but the result was the same.


texts: What makes a computer opponent feel alive?

texts:
Are there any recommended blogs or whitepapers that talk about making the AI in an RPG game feel more real? (Specifically in turn based combat.)

I know something must be out there, but I am only finding papers that talk about algorithms  behind the AI. I am looking more along the lines of "this is what makes a computer opponent feel alive". Taking risks, going easy, retreating, etc....

So many awesome answers, and I wish I could accept several of them. Thanks everyone!


texts: How can I implement scrolling endless road in XNA?

texts:
I am developing XNA game like following screenshot.

I created my 3D objects and camera so I have models. But how can I implement scrolling road in XNA?


texts: Can I make tilemaps in HTML without using Canvas?

texts:
Because of sheer experimentation, I'd like to make a game that contains a tilemap - without using the Canvas API provided for HTML5. Instead, I'd rely on CSS and Javascript (with jQuery).

Is there any chance that I can create it? If yes, how?

I have some ideas, such as placing lots of <img> tags and changing their sources constantly, but there might be better methods out there.


texts: Can I create cocos2d animations without using Xcode?

texts:
I need to have someone do animation work for an iOS game I'm developing (using cocos2d), however this person does not have a Mac and as such cannot run Xcode.

Is there a way for them to create animations for me without the use of Xcode?


texts: Running advanced floating point calculations on the GPU?

texts: I want to learn how to use AMD Stream and NVIDIA CUDA (PhysX) to calculate things such as locations. I have not yet found where to get the SDK for these (I can't test the CUDA things because I have a AMD graphics card but it's plenty of power for advanced game dev). So do any of you people know where to get these? Or even better a single library to control both platforms in the same way so I don't have to learn two different platform libs. I would also like to say that I will be using DX11.


texts: I am looking for a simple tutorial for sprite animation in android

texts:
Possible Duplicate:
  What's the best way to create animations when doing Android development?

I saw a couple of them on the internet but they are beyond my level of understanding ...I need to start with basics in a simpler way if possible...can anyone guide me to some good online resources for this


texts: Generating different maps using Perlin Noise with a seed

texts:
I am developing a 2D game in python and I could get Perlin Noise working with this code:

import timeit
import noise

POSITIVE =  10
NEGATIVE = -10

BLOCK = "#"
BLOCK_LIMITS = (POSITIVE, 0.3)

WATER = "-"
WATER_LIMITS = (0.3, -0.4)

GRASS = " "
GRASS_LIMITS = (-0.4, NEGATIVE)

oct = 1
outputString = str()

def GENERATE_MAP():
    global outputString

    for y in range(1000):
        outputString += "["
        for x in range(165):
            i = round(noise.pnoise2(x / 15, y / 15, octaves = oct), 5)
                if i > 0.4:
                    outputString += BLOCK
                elif i < -0.5:
                    outputString += WATER
                else:
                    outputString += GRASS
        outputString += "]\n"

time = timeit.timeit(GENERATE_MAP, number = 1)
print(outputString)
print("time = " + str(time))

But this creates the same terrain every time, so I thought to use seeds, but I don't know how to do that.
I am using python 3.6 with noise.


texts: Changing the position of a Gravity Controller - Farseer

texts:
I'm trying to create mini black holes for my XNA game using farseer physics.

Problem is I can not get the gravity source to stick to the Body I've attached it to, as it scrolls across the screen, the gravity source simply stays in the same position. This is the code I've used.

Body blackHoleBody;
blackHoleBody = BodyFactory.CreateBody(world);
CircleShape ballShape =
new CircleShape(ConvertUnits.ToSimUnits(imageItemList[i].texture.Width / 2f), 1f);
Fixture ballFixture = blackHoleBody.CreateFixture(ballShape);

blackHoleBody.BodyType = BodyType.Static;
blackHoleBody.Position = ConvertUnits.ToSimUnits(imageItemList[i].Position);
blackHoleBody.Restitution = 0.0f;

blackHoleBody.CollisionCategories = Category.All;
blackHoleBody.CollidesWith = Category.All;

//Create the gravity controller
GravityController gravity = new GravityController(10f);
gravity.DisabledOnGroup = 3;
gravity.EnabledOnGroup = 2;
gravity.DisabledOnCategories = Category.Cat2;
gravity.EnabledOnCategories = Category.Cat3;
gravity.GravityType = GravityType.Linear;

world.AddController(gravity);

gravity.AddBody(blackHoleBody);

ballBodyList.Add(blackHoleBody);

My guess is that I need to get in the GravityController inside world, and update it's position there, but when I look I can only find the world global gravity.

If anyone could point me in the right direction it would be much appreciated.


texts:
I have a 2D platformer with each platform having a PlatformEffector2D component. I want to create a crate that can be pushed.

When I jump into the edge of the crate, my player gets stuck, so I added PlatformEffector2D to the crate. But when the crate has a PlatformEffector2D component it falls below the platform.

I can remove the component and add a Physics2D Material with zero friction to prevent the player from getting stuck in the crate's edge, but I can't walk above the crate (because the zero friction). The images below illustrate it.

Player getting stuck in the edge of the crate that don't have PlatformEffector2D.

If it has a PlatformEffector2D it will fall below the platform.

My objects have the following components (when the player gets stuck at the edge of a crate):

Player (BoxCollider2D, Rigidbody2D)
Crate (BoxCollider2D, Rigidbody2D)
Platform (EdgeCollider2D, PlatformEffector2D)

What should I do so my player can push the crate and walk above the crate? Would anyone happen to have a sample script?

FYI: I use Physics2D.OverlapCircle to detect the ground. (Unity 5.4.0)


texts:
New to Unity and C#, though, I got the code from the official doc page for Character Controller and thought that should work by default.
When pressing the Jump button here it doesn't always work. When checking if the player is grounded the variable groundedPlayer not always provides true when idle/not moving. Instead, the value is constantly changing between true and false.
Below is my current code which was modified a little:
public class PlayerController : MonoBehaviour
{
  private CharacterController controller;
  private Vector3 playerVelocity;
  private bool groundedPlayer;
  private float jumpHeight = 1.0f;
  private float gravityValue = -9.81f;

  private void Start()
  {
    controller = gameObject.AddComponent<CharacterController>();
  }

  void Update()
  {
    groundedPlayer = controller.isGrounded;
    //this will constantly return both false and true while idle
    print(groundedPlayer + ", " + playerVelocity + ", " + gameObject.transform.position.y.ToString("f8"));
    if (groundedPlayer && playerVelocity.y < 0)
    {
      playerVelocity.y = 0f;
    }

    if (Input.GetButtonDown("Jump") && groundedPlayer)
    {
      playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
    }

    playerVelocity.y += gravityValue * Time.deltaTime;

    controller.Move(playerVelocity * Time.deltaTime);
  }

}

It's just that I feel dumb since basic jumping is this difficult to implement for me. I feel like I'm missing something very obvious. I found 1 working solution for me which is implementing coyote time, but it looks like a workaround and might provide more glitches in the future. I also could try working on creating my own character controller, though that's a whole different field.
Anyone had this issue before? How did you fix it?


texts: Do Game-Maker scripts save the variables or are they deleted after excecution?

texts:
When i make a script that excecutes at the beggining and has a var ammo and that finishes excecution, will i be able to call the var ammo in other scripts or it will be deleted? If it will not be deleted, will I be able to change its value on other scripts?

Thanks in advance.


texts: Transfering an inertia tensor from local coordinates to another one

texts:
If we have an inertia tensor in local coordinates with a basis matrix B and we want to transform it to other local coordinates with basis matrix A, is it right to do the following:

A* inv(B) *Inertia Tensor

Where my idea is to shift the inertia tensor to world coordinates by multiplying it by the inverse of B, then from the world coordinates to the A coordinates by multiplying it with A matrix?


texts: How to code the animations of attacks in RPG game

texts:
I have an attack class that has the basics like damage and cost and works in the game. Originally I slapped it together to the the ai targeting algorithm so you choose your attack and you see the enemy take damage.

The problem is now I want to animate the attacks I find they don't conform to a single pattern like the other graphics.
If you thing of a final fantasy game there is attacks the shoot fire balls so a single image would move across the screen. attacks that are like laser beams so an image would grow as it moves across the screen. attacks the would have things come from the top of the screen is a variety of manners.

I thought of making the class i have now a abstract class with an animation method and deriving several types of attack class from it but im worried about all the extra complexity that would add.
I could override the animation method but that would make the attack class huge and waste memory.

Does anyone have any advice on what I can do ?


texts: TModLoader reports a file to be missing when its not

texts:
I'm Making a terraria Mod that adds all sorts of Junk, but one single issue keeps hitting me: It Thinks one of the Items needed does not exist.

The error I seem to be getting is:

 The item Copper Shortsword Stack of twenty does not exist in the mod GrandFinale.
If you are trying to use a vanilla item, try removing the first argument.
   at Terraria.ModLoader.ModRecipe.AddIngredient(Mod mod, String itemName, Int32 stack)
   at GrandFinale.Items.OmegaHeadbutt.AddRecipes() in c:\Users\sjpar\Documents\My Games\Terraria\ModLoader\Mod Sources\GrandFinale\Items\OmegaHeadbutt.cs:line 32
   at Terraria.ModLoader.RecipeHooks.AddRecipes()

Even Though The item exists here (full code)

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace GrandFinale.Items
{
    public class TwentyStack : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Copper Shortsword Stack of twenty";
            item.width = 40;
            item.damage = 1;
            item.melee = true;
            item.height = 40;
            item.toolTip = "This is a modded sword.";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 10000;
            item.rare = 2;
            item.autoReuse = true;
            item.UseSound = SoundID.Item7;

        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient("Copper Shortsword", 20);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

And Is Being Called By this Other Item:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace GrandFinale.Items
{
    public class OmegaHeadbutt : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Omega Slash";
            item.damage = 10000;
            item.melee = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "The Sword Of The Ancients. Using it deals 499 Damage to the user, to deal 10,000 Base Damage";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 1;
            item.knockBack = 6;
            item.value = 10000;
            item.rare = 12;
            item.UseSound = SoundID.Item7;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "Copper Shortsword Stack of twenty", 2);
            recipe.AddIngredient("Flask of Poison", 2);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

(The Null on the line beginning tells of recipe.AddIngredient tells TModLoader that the item needed for crafting belongs to a Mod (not vanilla))

Any Help?


texts: An object reference is required to access non-static member UnityEngine.Material.GetTextureOffset(string)

texts:
I am watching a tutorial where it seem to work. But in my case, I am getting this error. I get it that non-static members have to have an object. But, I don't know much about how to fix this error.

using UnityEngine;
using System.Collections;

public class AnimatedTexture : MonoBehaviour {

    public Vector2 speed = Vector2.zero;

    private Vector2 offset = Vector2.zero;
    private Material material;

    void Start(){
        material = GetComponent<Renderer> ().material;

        offset = Material.GetTextureOffset ("_MainTex");
    }

    void Update(){
        offset += speed * Time.deltaTime;

        material.SetTextureOffset ("_MainTex", offset);
    }
}


texts: How do you exit a game when you hit an enemy?

texts: I have a game where you are going to dodge the enemies. I want to implement a feature where the game exits when the player hits an enemy. How can I do that?


texts: Why can't I put a source image in my Image component?

texts:
I can't put an image here as source image, and I have trouble figuring out why.

What did I miss?


texts: zoom, scale, pan etc in an application and printing

texts:
I have a C# windows application where I display photos for editing. The displayed
image is scaled to fit the screen. I allow pan, zoom, rotate, crop operations. Once
the editing is done, I would like to print. Now since the displayed image is scaled
before any of these operations, how can I print the photo correctly?

one option is to do the operations on the original image and then scale it and display it.

Is it what is normally done?


texts: What is the most efficient way to add and remove Slick2D sprites?

texts:
I'm making a game in Java with Slick2D and I want to create planes which shoots:

int maxBullets = 40;
static int bullet = 0;
Missile missile[] = new Missile[maxBullets];

I want to create/move my missiles in the most efficient way, I would appreciate your advise:

public void shoot() throws SlickException{
    if(bullet<maxBullets){
        if(missile[bullet] != null){
            missile[bullet].resetLocation(plane.getCenterX(), plane.getCenterY(), plane.image.getRotation());
        }else{
            missile[bullet] =
            new Missile("resources/missile.png", plane.getCenterX(), plane.getCenterY(), plane.image.getRotation());
        }
    }else{
        bullet = 0;
        missile[bullet].resetLocation(plane.getCenterX(), plane.getCenterY(), plane.image.getRotation());
    }
    bullet++;
}

I created the method resetLocation in my Missile class in order to avoid loading again the resource. Is it correct?

In the update method I've got this to move all the missiles:

if(bullet > 0 && bullet < maxBullets){
    float hyp = 0.4f * delta;
    if(bullet == 1){
        missile[0].move(hyp);
    }else{
        for(int x = 0; x<bullet; x++){
            missile[x].move(hyp);
        }
    }
}


texts: Why does my ship look like it's going backwards instead of fowards?

texts:
I'm making an Asteroids-clone based on this tutorial. I'm stuck on the 5th part of the tutorial.

For some reason my ship is going backwards instead of forward or it looks like its going forward, but in the tutorial the ship gos toward the asteroid.
In the debug log, the z axis increments in a positive value. so I assume it is going forward but for some reason the ship it self doesnt go towards the asteroid like it does in the tutorial. The ship itself is an fbx export from Maya 2014.

Here's an annotated screenshot:

Full size version

It's probably something really stupid, but I just can't figure out why this is happening.


texts:
I have a problem with bandings using andengine. When painting a picture on PC and uploading it to my phone, they look exactly the same. But as soon as I use that bitmap (PNG) in Andengine, I have bandings (big color steps).

Now I know that my display is capable of displaying the image right and I know how to us dithering but it bothers me. Does anyone know how to disable this quality reduction in Andengine?


texts:
In my opinion, games that are most entertaining to watch and play implement fake physics, the difficult issue is how to implement the fake physics and still allow it to appear realistic. Most popular car driving games implement this really well.

Question
Anyone has any tips or know of anywhere I can learn more about how these are implemented?

Long Story
For example, Need For Speed is entertaining when the player car crashes into the computer car, but it would not be fun if we land off the track each time the player collide. In the game, it is obvious that some game logic is in place to steer or land the player car upright, face correct direction and on track most of the time even after a massive collisions. The game instead causes the computer car to suffer heavier damages like flying of the screen after many spins etc to enhance effects.

As another example, suppose at a time instance, a speeding player car is driving at the close rear left of a computer car and real physics dictates in the next time instance the player will definitely bump into the computer and lose speed and control. Then at this point, the player could steer right to avoid the car, or steer left to bump into its rear. In an entertaining game, we may still want the player to avoid the front car completely if he steers away and experience an exciting near miss.

In NFS, this experience appears to be implmented in a few ways such as player auto-steer avoidance, scraping pass and rebound to right of computer, computer car steer away to avoid, computer gets hit but lose control and spin off track to give way to player.

On the other hand, it the player steers to engage in a collision, we want to add excitement to spin the computer very badly but still keep the player on track with a good speed.

In NFS, these fake collisions and steering are not easily noticeable as they feel very realistic even though if we study them closely, it looks almost like the are scripted. One method I have tried is to determine the final state of collision and then compute the path backwards. But this only ensures the car is in a desired final state, does not address the realism.


texts:
I'm studying a good number of articles about this topic and seems to me that there is just one way to do this: a signal/slot design.

I was also looking at some more complex async examples but I don't think I will adopt this, the tradeoff is not convenient in my opinion.

The classic C++ code that I have read until now is done with a template design and adopt a signal/slot logic, now my question: there is a better way to handle the input from the user? Is there a good pre-packed library for this?

I'd like to handle a broad range of different inputs: mouse, keyboard, gamepad, maybe also touch screen gestures, on several different platforms. My system should also be user-configurable.


texts: How to convert Maya shaders and Renderman shaders to GLSL?

texts:
I know this 2 products but i have never used them for production, since I have a bunch of cool shaders i would like to use them under OpenGL with GLSL but i don't know where to start.

If it's not possible to convert them directly, where i can learn the Renderman syntax for the shaders?


texts: In a multiplayer game, should everything that is not user input be done server-side to prevent cheating?

texts:
I've heard this said before, but it seems somewhat unrealistic.

These are the two scenarios I'm working with:

  User Presses move key, moves themselves, and tells the server -> server tells other clients

or

  User presses move key, and tells the server -> server calculates if the user is allowed to move there -> server tells all clients

It seems like option one would make the users movements feel very floaty and delayed. Do most multiplayer games use a combination? (user moves itself, gets confirmation from the server, and moves itself back if it was an illegal move.) Maybe it's a non-issue and I'm overthinking it.


texts: Difficulty understanding integration of Lua with C++ Game Engine

texts:
I'm starting work with the Allegro C++ library to get some lower level game development experience after working mostly with Unity. I've read about how Lua is a popular scripting language choice for game developers, but I have never used it before. I've been trying to work through how Lua might be integrated with a game engine in my head, and I've ran into some conceptual problems.

I imagine the simple scenario where I have a block that I want to move to the left at a certain speed for 2 seconds. I imagine that something like the Draw() method would sit nicely in the game engine in C++, where the actual command to move the block, being a fairly specific one, would originate in Lua.

I have trouble imagining where the transition between the languages is. I've read that calling to Lua every frame of the Game Loop isn't very performant, so that means that unless Lua can keep track of the movement timer asynchronously and interrupt C++ execution when the timer runs out, I would have to track the timer in the C++ engine. I would need a method like MoveForSeconds(direction, time) implemented in C++. At that point, Lua calling my MoveForSeconds() method is little more than a passthrough, and seems to defeat the purpose of using a scripting language.

What am I misunderstanding here? Or is my example too myopic, and the uses of Lua become more evident on a larger scale?

Thanks


texts: How to synchronize actions like jump in multiplayer?

texts:
I am a newbie game developer and I have been researching about multiplayer games. I observed that there's always some latency, the players always get updates from past actions. But there are techniques like dead reckoning to handle the latency. I can predict the movement and make movements smooth. But how would I make actions synchronize like jumping, stopped walking, etc.

Suppose, client A was moving, he was at 100m at 10.2 time with 100m/sec velocity and sended this information. Client B would receive this information somewhat later, let it be 10.4. So at client B, I can use prediction and place client A at 120m. But what if, client made a jump at 110m at 10.3. I can't predict that and since I have been using prediction I can't show client A jump in past.

I may deal with this problem by not sending jump action at all. But what if my game has some voids where players can fall and die. So, If I don't sync jump actions, other players will observe that one player was running then he falls in void and then again appear on the screen destroying the visual engagement.

Jump is just an example, there might many scenarios where prediction can't work. So, How do deal with them. One such example can be Multiplayer Online battle arena games like Awesomenauts.


texts: How do I prevent loop that moves character to run twice? (Javascript)

texts:
I managed to make a simple loop to move my character, onmousedown I move the character diagonally to where the user clicked. It's working but my problem is that I don't know how to prevent more loops to start over the first if the user clicks more than once.

Right now if you click more than once the character moves faster and faster since more loops are running at the same time.

This is the loop:

(function move() {
    if(cframes<frames) {
    cframes = cframes+1;
        character.style.left=parseInt(character.style.left)+pxsecx;
        character.style.top=parseInt(character.style.top)+pxsecy;
        setTimeout(move, 20);
}
})()
}

How do I prevent this loop from starting if it already has? or stop it and start another?
Thanks


texts:
Understand where I'm coming from - I've been taught that a game is implemented something like this (pseudocode):

while (!win_condition)
{
   waitforinput();
   updategraphics();
   //etc..
}
exit();

Is there another way to implement the "game loop" without limiting the game to finite "turns"?

This

while (true)

business seems to eat a lot of CPU, especially for how simple a game I'm making!


texts:
Lots of new games use Resolution Scaling as an option. At first I thought it was just Super-sampling but it does not appear to remove aliasing so I'm assuming there is more to it than that.

I guess my question is, how are developers implementing this? I'm assuming it means multiplying the width and height of the various rendertargets, and then what?


texts: how to place object relative to parent at x distance specified - Unity

texts:
First of all sorry if the question is incomplete or irrelevant, I'm new to Unity so all informations are messed up in my head, I'll provide any additional informations if necessary. Second of all sorry for the long post, I tried to provide everyting in order to be a clear question. ^^

My application in two words:

Place furnitures or construction objects (doors/windows) in scene. Everything is fine utill i touch the construction objects subject, since the application is mobile, it will be hard for user to place the door at the exact place so I decided to help and put a little menu where he can specify where to put it:

and the scene (room in this case ) looks like this:

Some implementation details:

The walls are a prefab instantiated 4 times:

 GameObject wall_N = Instantiate(wallPrefab);
 wall_N.gameObject.name = "Wall_N";
 wall_N.GetComponent<Transform>().position = new Vector3(center_W, 50, center_H + z / 2);
 wall_N.transform.SetParent(room.transform, false);
 wall_N.GetComponent<Renderer>().material.color = myColor;
 wall_N.gameObject.transform.localScale = new Vector3(x, y, 0);

and so on for each wall.  x, y, z are the values introduced by user and transformed into int

int x = Int32.Parse(xInput); // width
 int z = Int32.Parse(zInput); // length
 int y = Int32.Parse(yInput); // height

and Center_W and Center_H are screen points:

private int center_W = Screen.width / 2;  // 960
 private int center_H = Screen.height / 2; // 540

In the above image i've introduced  x, y, z as 200, 200, 200

Question:

In what coordinates I must work in order to place the door at A dimension specified?  I'm not even sure if this approach is correct, the main idea is to put the door at the correct position in room.

What I've tried

The first idea that came in my mind was to find the bottom-left coordinates from Wall_N and place the door at point + A but then I realised that the bottom-left is represented in different coordination sistem then A. I've search about it and I tried to see the values from screenPoint in different coordinates:

var screenPoint = new Vector3(center_W, 50, center_H + z / 2);

 var worldPos = Camera.main.ScreenToWorldPoint(screenPoint);
 var screenToViewport = Camera.main.ScreenToViewportPoint(screenPoint);
 var viewpointToWold = Camera.main.ViewportToWorldPoint(screenPoint);
 var worldToViewport = Camera.main.WorldToViewportPoint(screenPoint);

 Debug.Log("wallN - screen point " + screenPoint + " to worldPos " + worldPos);
 Debug.Log("wallN - screen point " + screenPoint + " to viewPortPos " + screenToViewport);
 Debug.Log("wallN - viewPort " + screenPoint + " to worldPoint " + viewpointToWold);
 Debug.Log("wallN - world " + screenPoint + " to viewport " + worldToViewport);

but unfortunalelly they didn't tell me anything, I just don't know how to solve this. If my logic is incorrect and/or you have another idea how to implement this, please help me. If the information is not enough, feel free to ask, I'll try to explain as much as I can. If the question title is incorrect or do not represent my question, I'll change it.

Thanks in advance,
Maria


texts: Bitmap font rendering, UV generation and vertex placement

texts:
I am generating a bitmap, however, I am not sure on how to render the UV's and placement. I had a thread like this once before, but it was too loosely worded as to what I was looking to do.

What I am doing right now is creating a large 1024x1024 image with characters evenly placed every 64 pixels. Here is an example of what I mean. I then save the bitmap X/Y information to a file (which is all multiples of 64).

However, I am not sure how to properly use this information and bitmap to render. This falls into two different categories, UV generation and kerning. Now I believe I know how to do both of these, however, when I attempt to couple them together I will get horrendous results.

Now for the algorithm. I am doing my letter placement with both GetABCWidth and GetKerningPairs. I am using GetABCWidth for the width of the characters, then I am getting the kerning information for adjust the characters.

Does anyone have any suggestions on how I can implement my own bitmap font renderer? I am trying to do this without using external libraries such as angel bitmap tool or freetype. I also want to stick to the way the bitmap font sheet is generated so I can do extra effects in the future.

Rendering Algorithm

for(U32 c = 0, vertexID = 0, i = 0; c < numberOfCharacters; ++c, vertexID += 4, i += 6)
{

    ObtainCharInformation(fontName, m_Text[c]);

    letterWidth = (charInfo.A + charInfo.B + charInfo.C) * scale;

    if(c != 0)
    {

        DWORD BytesReq = GetGlyphOutlineW(dc, m_Text[c], GGO_GRAY8_BITMAP, &gm, 0, 0, &mat);
        U8 * glyphImg= new U8[BytesReq];
        DWORD r = GetGlyphOutlineW(dc, m_Text[c], GGO_GRAY8_BITMAP, &gm, BytesReq, glyphImg, &mat);

        for (int k=0; k<nKerningPairs; k++)
        {
            if ((kerningpairs[k].wFirst == previousCharIndex) && (kerningpairs[k].wSecond == m_Text[c])) {
                letterBottomLeftX += (kerningpairs[k].iKernAmount * scale);
                break;
            }
        }

        letterBottomLeftX -= (gm.gmCellIncX * scale);
    }

    SetVertex(letterBottomLeftX, 0.0f, zFight, vertexID);
    SetVertex(letterBottomLeftX, letterHeight, zFight, vertexID + 1);
    SetVertex(letterBottomLeftX + letterWidth, letterHeight, zFight, vertexID + 2);
    SetVertex(letterBottomLeftX + letterWidth, 0.0f, zFight, vertexID + 3);
    zFight -= 0.001f;

    float BottomLeftX = (F32)(charInfo.bitmapXOrigin) / (float)m_BitmapWidth;
    float BottomLeftY = (F32)(charInfo.bitmapYOrigin + charInfo.charBitmapHeight) / (float)m_BitmapWidth;

    float TopLeftX = BottomLeftX;
    float TopLeftY = (F32)(charInfo.bitmapYOrigin) / (float)m_BitmapWidth;

    float TopRightX = (F32)(charInfo.bitmapXOrigin + charInfo.B - charInfo.C) / (float)m_BitmapWidth;
    float TopRightY = TopLeftY;

    float BottomRightX = TopRightX;
    float BottomRightY = BottomLeftY;

    SetTextureCoordinate(TopLeftX, TopLeftY, vertexID + 1);
    SetTextureCoordinate(BottomLeftX, BottomLeftY, vertexID + 0);
    SetTextureCoordinate(BottomRightX, BottomRightY, vertexID + 3);
    SetTextureCoordinate(TopRightX, TopRightY, vertexID + 2);

    /// index setting

    letterBottomLeftX += letterWidth;

    previousCharIndex = m_Text[c];

}


texts:
Im back again with yet another problem :( My current problem is with my billboard effect.  Im having trouble trying to get the depth correct so that billboards that are closer to the player are infront of the things that are actually behind them (like in the real world). Here is a screenshot of  what the problem looks like:https://www.dropbox.com/s/rvgdsp0mw4kheak/Screenshot%202015-02-24%2018.47.32.png?dl=0

You can see that the grass that is positioned in front is actually behind the one that is actually positioned in front. I have tried using...

        Globals.device.BlendState = BlendState.Opaque;
        Globals.device.DepthStencilState = DepthStencilState.Default;
        Globals.device.RasterizerState = RasterizerState.CullNone;

but it didnt work. Thanks in advance! Any ideas?


texts:
In some games, when you miss a pickup, you can never get it again unless you restart the game, and those pickups count in your collection. (therefore, you must restart the game to finish the collection, if you made any mistakes).

In Pokémon, you have only one Master Ball, limited supply of Ethers and legendary Pokémon appear once per game. Trading fixes all of those problems.

For a more radical perfectionist, they demanded all dialogs, background music, and even items to be revisitable. Some games, like Naruto Ninja Council, satisfied all of those needs.

Is it always a good practice to make things revisitable? Even cutscenes and music? When is it not a good practice to do so?


texts: A decent design for handling large creation/deletion of random objects?

texts:
So I was attempting a 'Hit the X' game (e.g Toss the turtle, spank the monkey) in which an uncontrollable object travels across the screen in hopes of hitting certain objects and avoiding others.

My dilemma is how to efficiently create and destroy these objects with respect to the character - that is, if the player is at, say, (90,34), all objects whose x position is less than 90 are garbage collected while more objects are generated at x > 90 or 100.

The only solution I could think of was to: randomly populate a tree that organizes by X values at the start of each round and to simply trim off the leaves at every so frames - if the player hits a certain spot, in which the tree is looking scrawny, start adding some more random objects on.

But this seems inefficient and unwieldy.  Does anyone have any suggestions?


texts:
I'm working on a 2D game using SFML and many textures (which I'm loading from PNG files, created with Gimp) I use are appearing blurry. They're being drawn without any kind of scaling and transformation, and I have confirmed that smoothing is not enabled for the textures, so I'm not sure what would be causing this or how to fix it.

The image I'm trying to draw is on the left, and what I'm seeing instead is on the right (both are heavily zoomed in).

How can I make SFML draw exactly the contents of the images and not apply this effect?

Edit: Here's a minimal example of what I'm doing:

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(){

    sf::RenderWindow window(sf::VideoMode(128,128), "Minimal example");

    sf::Texture* tex = new sf::Texture;
    tex->loadFromFile("img/bg/0.png");

    sf::Sprite s;
    s.setTexture(*tex);

    window.draw(s);
    window.display();

    while(window.isOpen()){
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
    }
}


texts: Unity: When attaching my custom camera script camera shakes when player starts to move fast

texts:
Here is my player code.

Rigidbody rb;

Vector3 currMovement;
public float jumpSpeed = 10;
public float moveSpeed = 10;
public float rotSpeed = 180;

float distToGround;

public float posSmoothTime = 0.5f;
float currPos;
float targetPos;
float posVel;

public float rotSmoothTime = 0.5f;
float currRot;
float targetRot;
float rotVel;

void Start()
{
    rb = GetComponent<Rigidbody>();
    distToGround = GetComponent<Collider>().bounds.extents.y;
}

bool isGrounded() { return Physics.Raycast(transform.position, Vector3.down, distToGround + 0.1f); }

void Update()
{
    Move();
}

void Move()
{
    // Rotation smoothing.
    targetRot = Input.GetAxisRaw("Horizontal") * rotSpeed * Time.smoothDeltaTime;

    if (targetRot > 360)
        targetRot -= 360;
    if (targetRot < 0)
        targetRot += 360;
    currRot = Mathf.SmoothDampAngle(currRot, targetRot, ref rotVel, rotSmoothTime * Time.smoothDeltaTime);

    transform.eulerAngles += new Vector3(0, currRot, 0);

    // Movement smoothing.
    targetPos = Input.GetAxisRaw("Vertical") * moveSpeed;

    currPos = Mathf.SmoothDamp(currPos, targetPos, ref posVel, posSmoothTime * Time.smoothDeltaTime);
    currMovement = new Vector3(0, 0, currPos);
    currMovement = transform.rotation * currMovement;

    if (isGrounded())
    {
        if (Input.GetButtonDown("Jump"))
            rb.velocity += Vector3.up * jumpSpeed;
    }

    rb.position += currMovement * Time.smoothDeltaTime;
}

I have a Rigidbody attached to my player. I think the problem is with my camera script. Here is my camera script.

public Transform player;
Quaternion targetLook;
Vector3 targetMove;
public float smoothLook = 0.5f;
public float smoothMove = 0.5f;
public float distFromPlayer = 5, heightFromPlayer = 3;
Vector3 moveVel;

void LateUpdate()
{
    CameraMove();
}

void CameraMove()
{
    targetMove = player.position + (player.rotation * new Vector3(0, heightFromPlayer, -distFromPlayer));
    transform.position = Vector3.SmoothDamp(transform.position, targetMove, ref moveVel, smoothMove);

    targetLook = Quaternion.LookRotation(player.position - transform.position);
    transform.rotation = Quaternion.Slerp(transform.rotation, targetLook, smoothLook);
}

}

The player is not an parent of my camera. When I parent the player to my camera the shake stops. But I want a custom smooth camera movement with my custom scirpt, so I can't make the player a parent of the camera.


texts: How to finish a sprite animation before going back to default animation?

texts:
I want to run a animation until it has gone through all the frames, even when the activation key is no longer held. After the animation is completely finished, it goes back to walking state. I also want to force the animation to finish first before the player can trigger the new animation.

     if (mCurrentState == State.Walking)
        {
            action = "stand";
            Update_Stand(gameTime);

            if (aCurrentKeyboardState.IsKeyDown(Keys.Left) == true)
            {
                action = "run";
                feetPosition.X += MOVE_LEFT;
                effect = SpriteEffects.None;

                Update_Run(gameTime);

            }
            else if (aCurrentKeyboardState.IsKeyDown(Keys.Right) == true)
            {
                action = "run";
                feetPosition.X += MOVE_RIGHT;
                effect = SpriteEffects.FlipHorizontally;

                Update_Run(gameTime);
            }

            if (aCurrentKeyboardState.IsKeyDown(Keys.Z) == true)
            {
                mCurrentState = State.Hitting;
            }
        }

        if (mCurrentState == State.Hitting)
        {
            action = "hit";

            Update_Hit(gameTime);

            mCurrentState = State.Walking;
        }

My Update_Hit(GameTime gameTime) method is something like that.

// Amount of time between frames
TimeSpan frameInterval_Hit;
// Time passed since last frame
TimeSpan nextFrame_Hit;

 public void Update_Hit(GameTime gameTime)
    {
        // Check if it is a time to progress to the next frame
        if (nextFrame_Hit >= frameInterval_Hit)
        {
            // Progress to the next frame in the row
            currentFrame_Hit.X++;

            // If reached end of the row advance to the next row, reset to the first frame
            if (currentFrame_Hit.X >= sheetSize_Hit.X)
            {
                currentFrame_Hit.X = 0;
                currentFrame_Hit.Y++;
            }

            // If reached last row in the frame sheet, jump to the first row again
            if (currentFrame_Hit.Y >= sheetSize_Hit.Y)
                currentFrame_Hit.Y = 0;

            // Reset time interval for next frame
            nextFrame_Hit = TimeSpan.Zero;
        }
        else
        {
            // Wait for the next frame
            nextFrame_Hit += gameTime.ElapsedGameTime;
        }
    }


texts: Simple Java 2D Game : Player Doesn't Move

texts:
I'm a beginner at java and I'm trying to make a simple 2D game as a practice, and i have a problem here with the player, I've tried a lot to make it move but it didn't work. These are the classes that contain the player.

Game Class :

package game;

import game.input.Controller;
import game.input.KeyInput;
import game.objects.Player;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;

public class Game extends JPanel implements ActionListener{

  Timer loopTimer;
  //Objects
  Player p;
  Controller c;

  public Game(){
    addKeyListener(new KeyInput(p));
    setFocusable(true);

    loopTimer = new Timer(10, this);
    loopTimer.start();

    p = new Player(300,200);
    c = new Controller();
  }

  public void paint(Graphics g){
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;
    g2d.setColor(Color.white);
    g2d.fillRect(0, 0, 640, 480);
    p.draw(g2d);
    c.draw(g2d);
  }

  public void actionPerformed(ActionEvent ee){
    p.update();
    c.update();
    repaint();
  }
}

Player Class :

package game.objects;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;

public class Player extends GlobalPosition {

  private String playerimage = "/images/marioR.png";

  int velX = 0;
  int velY = 0;

  public Player(int x, int y) {
    super(x, y);
  }

  public void draw(Graphics2D g2d){
    g2d.drawImage(getPlayerImage(), x, y, null);
  }

  public Image getPlayerImage(){
    ImageIcon i = new ImageIcon(getClass().getResource(playerimage));
    return i.getImage();
  }

  public void update(){
    x += velX;
    y += velY;

    // Collision with outside
    if(x < 0){
      x = 0;
    }
    if(y < 0){
      y = 0;
    }
    if(x > 640){
      x = 640;
    }
    if(y > 480){
      y = 480;
    }
  }

  public void keyPressed(KeyEvent e){
    int c = e.getKeyCode();
    if(c == KeyEvent.VK_LEFT){
      velX = -10;
    }
    if(c == KeyEvent.VK_RIGHT){
      velX = 10;
    }
    if(c == KeyEvent.VK_UP){
      velY = -10;
    }
    if(c == KeyEvent.VK_DOWN){
      velY = 10;
    }
  }

  public void keyReleased(KeyEvent e){
    int c = e.getKeyCode();
    if(c == KeyEvent.VK_LEFT){
      velX = 0;
    }
    if(c == KeyEvent.VK_RIGHT){
      velX = 0;
    }
    if(c == KeyEvent.VK_UP){
      velY = 0;
    }
    if(c == KeyEvent.VK_DOWN){
      velY = 0;
    }
  }

  public void keyTyped(KeyEvent e){
  }
}

KeyInput Class :

package game.input;

import game.objects.Player;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class KeyInput extends KeyAdapter{

  private final Player p;

  public KeyInput(Player p){
    this.p = p;
  }

  public void keyPressed(KeyEvent e){
    p.keyPressed(e);
  }

  public void keyReleased(KeyEvent e){
    p.keyReleased(e);
  }
}

.


texts: Why does 'InvalidCastException: Specified cast is not valid.' occur for ARKitFaceSubsystem?

texts:
Why does 'InvalidCastException: Specified cast is not valid.' occur for ARKitFaceSubsystem in the snippet below?
    var faceManager = FindObjectOfType<ARFaceManager>();
    if (faceManager != null)
    {
        m_ARKitFaceSubsystem = (ARKitFaceSubsystem)faceManager.subsystem;
    }


texts:
I have problem, when i override a Coroutine loop from the base code. But it seems that it only execute once. While on the base code it does what it suppouse to do and that is execute forever.

protected virtual IEnumerator OnThink(float interval)
{
    while (true)
    {
        yield return new WaitForSeconds(interval);
    }
}

protected override IEnumerator OnThink(float interval)
{
    Debug.Log("Execute");
    yield return StartCoroutine(base.OnThink(interval));
}


texts: What kind of culling does XNA do for me?

texts:
Which kinds of culling and clipping does XNA do for me as default, and which kinds does it not?

Z-culling? Backface culling? etc.


texts: Practical Way to Store and Communicate Data for a Multiplayer Game Like This

texts:
I am working on my first multiplayer game, as I have become bored with my single player indie games. However, I have a question. Players will be placing items on a map which is arranged in a grid, what is the best way to store this data on a server?

UPDATE:
So essentially this is what I need to do. I currently have a database with player money, etc. I need some way of once the player places something on the map, for the server to check my database for how much it costs, so it can see if the player is cheating or not. My issue is I don't know the best way to communicate this data to the server and have it store it (the location of different things on the map, etc)

I was originally thinking to serialize the map, send it to my server, and store it in my database, but to query the database EVERY SINGLE TIME that the user changes something on the map seems to be a little ridiculous.


texts: How to identify a Tile without using its name attribute

texts:
In the newly added Tilemap system, the TileBase and Tile have no tag attribute and it is then not possible to identify them by anything else than their name attribute which is not very practical. It is however said in the documentation of TileBase :

  Inherit from this to implement your custom tile to be placed in a Tilemap component.

I guess it can be used to create our own tile system but then I can't find a way to use this new class in the tilemap instead of the basic Tile class. How can I use this inheritance to create my own Tiles ?


texts:
Is it best to have a renderer class in which you have a seperate function for each object you wish to draw? Or is it best to give each object a render function?

class Renderer {
    ...
}

Renderer::renderPlayer(Player *player)  {
    ...
}

vs

class Player  {
    ...
}

Player::render()  {
    ...
}


texts: What is the line between a serious game and an application with points?

texts:
Gamification has become a buzz word lately and is being applied to everything from applications to meetings.  In many cases it is being done as an afterthought and sort of game-washing.

What are the key differences between something having real game dynamics and simply being a superficial gamification layer?  Where is the line between a serious game and an application with points?


texts: Tracking Object Position - Firing on a Trajectory

texts:
How can I calculate the position of an object after "firing" it from a fixed point?

I am to create a small game - most likely with canvas (pure HTML, JS based) or Adobe Flash - in which the player fires objects at other obstacles in order to clear them.


texts: Why can I sometimes access Static objects' elements and sometimes not?

texts: I'm making a game in Unity and I learned to make my Player object static for reference by other objects quickly and easily. So I have a "public static Player player." I remember when I first made this and began referencing it, some scripts were telling me that I could not access certain things without a local instantiation. So I made a Player p and set it equal to Player.player and it then allowed me to reference its functions and variables. It seemed like I could have some kind of access like reading not writing or just accessing variables but not function calls without a local reference, but I later found I could access anything without the local reference. I was then able to get rid of the local references completely in scripts that were originally not able to access the elements without it. I have no idea what changed. Now, however, I'm making a static SaveData object and I'm running into the same issue. Things I'm accessing with Player.player is not working with my SaveData.saveData. What is going on? What could possibly be different? When can I and can't I access this stuff without a local reference?


texts: Categorized and ordered weapon switching system

texts:
I am creating a weapon switching system for my game. The weapons have specific categories and positions. And players will select them accordingly. Note that positions can be negative too, it just works as an order for which weapons in the category. And currently, there are only 9 categories, and I don't aim to change that in the future.

I will have several functions that will handle the weapon selecting but each of them in a different way:

Select the next weapon
Select the previous weapon
Select the next weapon in a certain category
Select the specific weapon (which is the easiest one to implement)

I have my categories as a class:

class WeaponCategory
{
    Dictionary<int, Weapon> weapons = new Dictionary<int, Weapon>();
}

I am using a dictionary at the moment since that was the one I thought would be the most appropriate for what I am doing. Dictionary keys represent the positions of the weapons. I am creating 9 WeaponCategory in my other script as an array, like this:

WeaponCategory[] categories = new WeaponCategory[9]

Say, I have a Pistol which is positioned at category 1 and position -2, a Shotgun positioned at category 1 and position 3, an SMG positioned at category 2 and position 1. (SMG's position doesn't matter because, in its category, there is only itself). And image the player is currently using the weapon Pistol, so while their current category is 1, their current position is -2. So when I want to select the next weapon (function #1) it should go the Shotgun whose position is higher than the Pistol. And after that, when I am using Shotgun now; if I wanted to select the prev weapon, it should go back to the Pistol again, but instead, if I select the next weapon, it should go to the SMG whose category is higher than that. The actual thing starts from here, imagine I am currently using the SMG which is the highest positioned weapon; if I select the next weapon, it should go to the weapon whose position is the lowest in the hierarchy. Function #2 does pretty much the same thing, except the reverse.

So for function #3, it is going to be a similar one above but it will happen only in the certain category the weapon is located at. Imagine I am using the Pistol if I select the next weapon in the category it will basically go to the Shotgun, and when I am using the Shotgun, and if I do that again, it should go to Pistol.

If you are familiar, that is the same system in the game CS:GO or alike.

It'd be so cool if you guys give me some code to handle that if not, a code block would do too. Thanks a bunch.


texts:
I've just started using MonoGame (which pretty much seems to be an open implementation of XNA) and I'm trying to figure out on how to work with framerate independant calculations. Usually what I found in all the other game engines / libraries I've used before its some kind of field called "delta time" which I only had to multiply to all the values to make them framerate independant.

I understood the logic between that and I'd like to continue working with delta time values. But as I couldn't find something like that in MonoGame I made some kind of workaround myself. Here's what I did:

protected override void Update (GameTime gameTime) {
    deltaTime = gameTime.ElapsedGameTime;
    float delta = deltaTime.Milliseconds;
    delta = delta / 1000;

    //(...)

    //And now I can use delta to apply movement like this:
    position.X += SpeedX*delta;
}

Is that a good workaround? Does it have any overhead I might be overlooking at? Is there a pre-built value for what I'm looking for?

Thank you very much


texts:
I got interested in studying graphic programming so the obvious entry point was to learn OpenGL. But gathering scattered information around forums and sites, it seems that a pure OpenGL implementation is fading out since most things pre-3.0 are being deprecated and quoting a review on Amazon, "since 3.0 it's all about the shaders". Also of the books that I've seen, looks like only the superbible covers the newer version, but only partially because a good portion of the book teaches deprecated functions, and there are books specifically to GLSL.

This is where I ran into my first problem, some hardwares do not support GLSL, including the notebook with intel integrated graphics that I had planned on using. The function

GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);

causes a segmentation fault and from the looks of it my driver does not support shaders

So my question is, what is the viability of making a game only in OpenGL? will I be missing irreplaceable good features from the shader language? And what kind of hardware (old gen i3, i5, i7, old VGAs) can I expect to run a game with shaders properly?


texts:
I made the shadow of Solider in my game using Unity pro shadows feature.

http://docs.unity3d.com/Documentation/Manual/Shadows.html

The performance of my game becomes very slow after adding these shadows. I used light map for buildings shadows but I cant use this thing for solider. I want to ask what technique should I use to make both real and optimize shadow of my solider.


texts: What has your experience been with Torque products?

texts:
I'm most interested in your experience with Torque-X, the Managed XNA version of their engine.

How did it perform in your use case? (also info on your use, would be helpful)
What was the usability of the tools?
What did you build with it? 2D, 3D, both?
Did you find any "gotchas" that you had to work around?

If you have used both Torque and Torque-X, I'd be very interested to hear your thoughts contrasting the two engines. On the website, there are some pretty amazing screensshots for the Torque engine; yet the screenshots of Torque-X look kinda cheesy. At this point I don't have the 3D artist expertise to build some of the amazing 3D scense they demoed, but I'm wondering if this would even be possible on Toreque-X engine.

As always, any thoughts are greatly appreciated.


texts:
I use a Sobel filter to generate normal maps from procedural height maps. The heightmaps are 258x258 pixels. I scale my texture coordinates like so:

texCoord = (texCoord * (256/258)) + (1/258)

Yet even with this I am left with the following problem:

As you can see the edges of the normal map still proves to be problematic. Putting the texture wrap mode to "clamp" also proved no help.
EDIT:
The Sobel Filter function by sampling the 8 surrounding pixels around a given pixel so that a derivative can be calculated in order to find the "normal" of the given pixel.

The texture coordinates are instanced once per quad (for the quadtree that makes up the world) and are created as follows (it is quite possible that the problem results from the way I scale and offset the texCoords as seen above):

Java:

for(int i = 0; i<vertices.length; i++){
        Vector2f coord = new Vector2f((vertices[i].x)/(worldSize), (vertices[i].z)/( worldSize));
        texCoords[i] = coord;

    }

the quad used for input here rests on the X0Z plane. 'worldSize' is the diameter of the planet. No negative texCoords are seen as the quad used for input for this method is not centered around the origin.

Is there something I am missing here?
Thanks.


texts:
I've been working on how to build some of my game systems using components and systems. I'm having a little trouble following the approach that components should just be bags of data and systems should implement the logic. It'd seem for this to be true you have to limit the complexity of the components or somehow make the system aware of all possible complexity.

For example, I have equipment in my game that characters can equip. Equipment has an "Item" component that has an item name, description, value etc. and allows me to identify it as an item for the purpose of character inventory, etc. That's simple enough.

Here's my problem though. Equipment also needs to be "equippable". Originally, I implemented it as something like this:

class EquipComponent : public Component
{
public:
     virtual bool equip(Entity* character) = 0;
     virtual bool unequip(Entity* character) = 0;
};

then I'd export this class to my scripting engine, and I'm free to have equip/unequip do whatever I want to the character they're being equipped too.

When I try to implement this component as just a bag of data, it just seems so limited. If I want the equipment to increase stats, I can add an array of stat adders/multipliers. If I want to have equipment add status effect resistances, I can add a table for that. If a piece of equipment has different effects for different weatrers, now I have to add data on a per user basis. Suddenly my simple bag of data has gotten massive. I could split it into seperate components, but now my system needs to be aware of every possible component that can change how an item is equipped.

I can see problems like this popping up in a lot of potential components/systems, so I was wondering how one can decouple the components and systems? Am I thinking too rigidly that most component logic should be handled by systems? As much as this is a learning experience, I would like to have something I can use for more than one project and that has good scalability.

Any insight or advice would be appreciated!


texts: IAP consumable stuck with reason DuplicateTransaction

texts:
I've implemented Unity IAP. I have succesfully implemented it before and all went well.
Now at the moment, everything goes well except for 1 consumable. When I try to purchase it, i get the PurchaseFailureReason with value DuplicateTransaction.

After some googling, I found out that it probably is because the transaction was cleared by Google, but the callback was never invoked inside the app. So somehow and somewhere, a flag is set indicating that this transaction is still pending or something? (The purchase on the - now not working consumable - had also indeed been made before and the callback was NOT called, so this seems to be correct.)

All other consumables work fine. They are configured exactly the same, just with another reward on the callback. (Same method, different parameter. I'm 100% sure this has nothing to do with the bug).

So now I want to try and fix this product.

I tried reverting the purchase (even though it is a test purchase) inside Google Play.
I tried manually adding a restore button and clicking it.

Some info:

I am using Unity Codeless API.
Game is only available on android as of yet.
The bug originates from when I tried making a purchase, but (due to bad wifi) i managed to navigate to another screen before the GooglePlay popup came. This disrupted the callback somehow and probably flagged the purchase as "purchased but not completed" or something.
I store receipts from the products in my database so I can compare/ provide support for clients when purchases go sour. The purchase in question never arrived in my database. All corresponding purchases on the same product ID now fail with reason DuplicateTransaction
Consumable products are configured in Google play, online unity monetization console, in editor iap catalog. All are configured exactly the same 100%
The game is still in Alpha, soon going to Beta (once I fix this :)).


texts:
This is not about generating plane geometry and then applying a shader on it. Instead, I want a big single flat plane, then apply a shader on it.

The vertex shader has a uniform vec3 realPlanePosition and calls a height calculation function:

// Vertex shader code

uniform vec3 realPlanePosition;

varying vPosition;

float heightCalculation(vec2 verticePosition) {
    // Just for pseudo-code (more black magic append here).
    return magicNoise2D(verticePosition.x, verticePosition.y);
}

void main(void) {
    vec3 vPosition = position;
    vec2 verticePosition = vec2(vPosition.x + realPlanePosition.x,
                                vPosition.y - realPlanePosition.z);

    vPosition.z = heightCalculation(verticePosition);

    gl_Position = projectionMatrix * modelViewMatrix * vec4(vPosition, 1.0);
}

In my plane update code, I just change realPlanePosition with player position, for example. The plane moves on (x, z) (X rotation: -PI/2.0). The only thing the vertex shader updates is the z (due to plane rotation) value of gl_Position.

Is this good practice? Also, how do I detect collisions with it? And finally, how can I control other terrain objects' generation (rocks, trees, ...)


texts: Shadow map shimmering, indexing outside the shadow map

texts:
I have tried to reduce the shadow shimmering/flickering using the technique described here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx

It works as I want and shimmering is reduced but sometimes I have artifacts. It looks like my code tries to index space outside the shadow map. The article above writes about it but I didn't find a solution.

When I played with the code I also got black strips on the corners.

Code:

// reduce shadow shimmering/flickering
Vector2 vecWorldUnitsPerTexel = Vector2(D.x() / (float)D.shadowMapSize(), D.y() / (float)D.shadowMapSize());

// get only x and y dimensions
Vector2 min2D = min.vector2(),
                max2D = max.vector2();

min2D /= vecWorldUnitsPerTexel;
min2D = Round(min2D);
min2D *= vecWorldUnitsPerTexel;

max2D /= vecWorldUnitsPerTexel;
max2D = Round(max2D);
max2D *= vecWorldUnitsPerTexel;

min.set(min2D, min.z);
max.set(max2D, max.z);

// crop matrix based on this article https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html
Vector scale;
Vector offset;
scale.x  = 2.0f / (max.x - min.x);
scale.y  = 2.0f / (max.y - min.y);
scale.z =  1.0f / (max.z - min.z);

offset.x = -0.5f * (max.x + min.x) * scale.x;
offset.y = -0.5f * (max.y + min.y) * scale.y;
offset.z = -min.z * scale.z;

Matrix4 m;
m.x = Vector4(scale.x, 0, 0, 0);
m.y = Vector4(0, scale.y, 0, 0);
m.z = Vector4(0, 0, scale.z, 0);
m.w = Vector4(offset.x, offset.y, offset.z, 1.0f);

I think that I should store in the depth map a slightly larger area but I'm not sure how to do this. I tried to change the scale of the crop matrix but it doesn't help.

EDIT:
It seems I've found a solution. When I'm rounding (or flooring) min and max values I subtract one from the min value and add one to the max value. This makes the shadow map contain a slightly larger area and I don't see any artifacts.


texts: Detect collision with bullet physics, to make a character controller

texts:
I inherited from btCollisionWorld::ContactResultCallback but I really have no idea how to use this virtual function:

btScalar addSingleResult(btManifoldPoint& cp,
        const btCollisionObjectWrapper* colObj0Wrap, int partId0, int index0,
        const btCollisionObjectWrapper* colObj1Wrap, int partId1, int index1)

I thought about using btCollisionWorld::ConvexResultCallback instead but there is no method in btCollisionWorld to use it.

For now my only goal is to move a btCollisionObject around and detect collision with walls, to adjust the position and movement.

I would just need the collision normal, some collision point, or anything else...


texts: Rendering up close, OpenGL performance issues

texts:
I have been developing a massive RTS during the past 18 months, which is comming together nicely!

Now i have an issue i can't really wrap my head around.

If i render 100 models from a distance where the camera can see them all, everthing works perfectly. If i then render them when there camera is up close, my GPU goes to 100% and of course everything starts to lag. I don't really get the difference, the math is the same.

Works on Nvidia m1000m and burns on AMD RX5700.
OpenGl version 4.1.

CPU, memory and GPU memory stays the same so i don't suspect any leaks.

I have tried debugging with glGetError() and CodeXL, no luck.

Am i missing something simple in OpenGL?


texts:
Does anyone here have experience making games with streaming economies? I am working on a game and am looking for a better way to handle the economy.  I feel like there must be a better algorithm than what I am using.

Background:

ResourceBin objects contain resources
Settlement objects contain ResourceBin objects
Settlement objects have three queues of Building objects in arrays (Low, Medium, and High priorities)
Building objects have a nextTick() method that accepts a ResourceBin and modifies it

Right now on every tick the Settlement class will loop through all of the Building arrays starting with High and working towards Low.  On each Building object it calls the nextTick() method and passes its ResourceBin.  After making sure that the transforms won't cause any Resource to become negative, the nextTick() method modifies the ResourceBin and exits. If any of its transformations would cause a Resource to become negative it just exits.

The issue with this is that the entire system depends heavily on the order in which the buildings are processed.  I also can't have it proportionally affect the resource transformations if you are low on resources (like what is done in Total Annihilation).

Does anyone know how other games implement streaming economies?  Is there a better way to do this?

Also let me know in the comments if a code example would be useful. I can pastebin one if need be.


texts: How can I convert between float3 and float2 in HLSL?

texts:
I want to offload some 3D calculations to the GPU without raising my requirements to DX10.  Specifically, I am generating densities in 64x64x64 3D blocks, which fit nicely into 512x512 2D textures.  I would like to be able to convert my float2 texture coordinates to float3 values, so I can offset them, convert back to float2, perform lookups against my randomness texture, and interpolate the results manually.

This has been easy to do with integer values on the CPU side, but the GPU's texture coordinates are all floating points.  Is there an easy way to do this?  Or is there a way to coax pixel shader 3.0 into using something similar to 3D textures, so I can take advantage of automatic interpolation?

Another caveat is that I am using the Vector4 image format for my render targets (need better resolution in each channel) in XNA, so I am restricted to Point sampling.


texts: Compare two x and y if they are in a valid range

texts:
Today my mind is a little foggy, the right thing was for me to do it the other day, but I will not, I will continue today. XD I need some help to think and find a way that works without bugs.

What I'm trying to do is compare two vector2 which are nothing else in my implementation in javascript/nodejs than an array with two floats.

I want to be able to compare if oldVector2 has any of its float x or y values in a range much different from floats x and y values of newVector2.

Example:

// When newVector2 is in a valid range less than 10
oldVector [0] = 1.55; // This is x
oldVector [1] = 0.22; // This is y

newVector2 [0] = 2.55; // This is x
newVector2 [1] = 1.55; // This is y

// When newVector2 is not in a valid range less than 10
oldVector [0] = 1.55; // This is x
oldVector [1] = 0.22; // This is y

newVector2 [0] = 21.55; // This is x
newVector2 [1] = 1.55; // This is y

if (the x and y of newVector2 is in a valid range less than 10 compared to the x and y of the oldVector?) {
     // You are in a valid range
} else {
     // Not in a valid range
}

My question is this: and when there are signs? Negative and positive numbers, how would this comparison compare?

what I'm trying to do here I already use abs(), I've done this before, but I did differently, because it was in unity3D that I did once, it was like this:

var distance = (a-b).magnitude;

where a and b are two 2D vectors, here is what magnitude does https://docs.unity3d.com/ScriptReference/Vector2-magnitude.html.

Then he compared

if(distance> 10)...

I'm confused at why I did it that way.

And the Vector2 are the position of an entity, I want to verify that it is not going faster than the permitted.


texts: Cocos2d-x supporting multi-resolution using density independent pixels

texts:
Is there a way to use Density Independent pixels(dp) in cocos2d-x?

I am developing an Android game using Cocos2d-x 3.0.

The Android reference http://developer.android.com/guide/practices/screens_support.html tells me not to use pixels in code but use dp when supporting multi-resolution support. It also tells me to provide different images for different screen size groups and different density groups.

However, cocos2d-x tutorials use pixels for multi-resolution support. If I were to use pixels, I think it means I need to have images for all these different resolutions:

240x320, 240x400, 240x432
320x480
480x640, 480x800, 480x854
600x1024
640x960
1024x600, 1024x768
1280x768, 1280x800
1536x1152
1920x1152, 1920x1200
2048x1536
2560x1536, 2560x1600

Even if I don't support every screen resolutions, I think this requires more work than following the Android reference's best practice.

Am I missing something on how supporting multi-resolution works or do I indeed do need to do much more work using cocos2d-x?


texts: GLSL: can i use matrix transformation functions in vertex shader?

texts:
I have a working OpenGL code where i render a terrain with some trees.

I am doing all the matrix mathematics on the client side.
Because of which the frame rate of my app is very low, around 25-30 [its not LOW but, i used to get 60 before the calculations]

If i were to do all these matrix transformations on server side, in say vertex shader, or even better a geometry shader, are there functions in GLSL which translate, rotate, ans scale?

for example, what would the following client side code look on server side?

        model   = tes_terr.glm_model; //get the current camera movement matrix
        model   *=  glm::translate( glm::mat4(1.0f),  glm::vec3(tvec.x, tvec.y, tvec.z))
                  * glm::rotate   ( glm::mat4(1.0f), -90.0f, glm::vec3(1, 0, 0))
                  * glm::scale    ( glm::mat4(1.0f),  glm::vec3(scaleFactor));

Or do i have to  write these function in vertex shader separately.


texts: Can I make an entire game in Unity 3D for the iphone?

texts: Can I make an entire game in Unity 3D for the iphone without using any Objective - C or Cocoa?


texts: My mesh has holes in it. How do I make those invisible faces show?

texts:
I have a mesh. A perfectly normal mesh, without any artefacts at all.

However, when I import it into Unity, there are holes in it.

After going through my UV mapping and normals, they are all mapped, have no faces with the normals going the wrong way (facing inwards) and have non-transparent textures over each mapped UV face.

Oddly enough, this mesh hasn't been split, despite its poly count and is one whole object, but yet - It has missing polygons. Is there any way to get Unity to recognise these faces?

Also, it is worth noting that these holes happen to be all the tris faces on this model, and are all (mostly) along the UV seames.

Question

How do I make the invisible faces show? What's going on?


texts:
I'm writing a simple Minecraft like game to test out a few world gen algorithms and to learn more about OpenGL. My first render code was glBegin() ... glEnd() style. Very ineficient and slow. I started learning VBOs for a heightmap project but using VBOs will force me to update the whole VBO of the chunk if something is added or removed due to it's size changing. That also sounds ineficient. The most plausable theory so far I can think of is instancing but even this isn't good due to multiple render types.

When I've been modding Minecraft all the render code i've seen there (and written my self) has been glBegin() ... glEnd() style. Is it really that? It just feels so wrong since it can render 64 chunks 20 fps no problem on an Intel intergrated GPU.


texts: How does the change ID increment in the Path of Exile API?

texts:
Does any body know how the next change ID increments on the POE API?

I think I have figured out the the API returns the latest, system wide next_change_id for the latest stash changes.. but in between refreshes the incrementations are a bit all over the place.

So these are the change id's reported within seconds of updates

97021553-101802592-95624331-110373614-103027614
97021579-101802666-95624405-110373692-103027683
97021579-101802668-95624405-110373695-103027694
97021579-101802668-95624405-110373710-103027694

It looks like a GUID but it is not a GUID by any means.. when the game started these numbers where allot lower.

I have tried searching forums for a more in depth breakdown of how the API works. The game site has limited information, Reddit has some insight and source code links.. but no proper break down.


texts: What's the best way to create animations when doing Android development?

texts:
I'm trying to create my first Android game and I'm currently trying to figure out (with someone that will do the drawings and another programmer) what the best way to create animation is. (Animations such as a character moving, etc.)

At first, the designer said that she could draw objects/characters and animate them with flash so she didn't have to draw every single frame of an action. The other programmer and I don't know Flash too much so I suggested extracting all the images from the Flash animation and making them appear one after the other when the animation is to start.

He said that would end up taking too much resource on the CPU and I tend to agree, but I don't really see how we're supposed to make smooth animations without it being too hard on the hardware and, if possible, not have the designer draw every single frame on Adobe Illustrator.

Can an experienced Android game developper help me balance this out so we can move on to other parts of the game as I have no idea what the best way to create animations is.


texts: How to avoid cost comparison each and every frame?

texts:
I'm toying around with a ticker(incremental game) for JavaScript.

The basic idea is that you have buttons that represent buildings, each building provides a certain amount of resource per 'tick'.

Each building can cost an arbitrary amount of resource types and amounts (a farm can cost wood, food and labor for example). The game is intended to have several dozens of buildings, units, technologies etc.

I would like to disable the buttons of buildings that you can't currently afford.

My concern: I prefer not to loop over every item and every cost within it to see if we have enough to build it every single tick (a tick is 50ms~).

Is there a 'smart' way that I missed that solves this issue without brute force?

EDIT :
I decided to approve the answer that basically says "Just ignore the problem".
The reasoning behind it is as follows :

Tests indicated that while the theoretical problem is interesting, it's of little consequence in a reality, the performance hit is extremely minimal.
This website is about solving problems, and as "sam hocevar" suggested, The answer needs to be as clear as possible(and the reason behind it).
While the answers are clever and very interesting to read as a theoretical background , they all address the "number of checks", while some answers reduce that number by some fraction, non actually mitigate the amount by any performance-altering number.
Following on 3, It seems that if you've come to a point where you need to implement any of the suggested, over-engineered, solutions to save performance, It seems that the gain from those solutions will be so minimal that performance will still be an issue even after implementation, making the entire game model not viable anyway.

TL;DR - If it doesn't work by ignoring the problem, it probably won't work with over-tweaking it either.


texts: How do I implement "prewarming" in particle engines?

texts:
How is prewarming in particle engines made?

I have a particle engine and need to support this, which is a feature I have already seen in Unity.

Is it done at compilation, like informations stored somewhere? or pre-processed at launch? or is there a way to simulate a particle system when it is created?

Considering it is time based, I don't see how I could for example simulate 15 seconds of life for a particle system without actually using 15 seconds


texts: Text not instantiating under a canvas (unity)

texts:
Below is my code for a text I want to spawn under a canvas. Both spawn and I no longer get errors, but the text isn't spawning under the canvas.

        Instantiate(canvasparent);
        Text savescore = Instantiate(score) as Text;
        savescore.transform.SetParent(canvasparent.transform, false);


texts: Why doesn't this ContentLoader project (VS2010 e) recognize Microsoft.Build.dll?

texts:
I am working with an XNA content loader sample. In the references for the project (VS 2010 Express) there are:

Microsoft.Build
Microsoft.Build.Framework

//as well as the standard XNA framework and graphics references

To emulate this project, I am trying to first add a reference to Microsoft.Build.dll. But Visual Studio warns me that it cannot load the .dll. I looked at MSDN and the document referenced Microsoft.Build.Evaluation. This is suppose to be available in the Microsoft.Build.dll and then I'll have access to the Project class.

Has anyone had any experience with this?


texts: Unity download image from Firebase database

texts:
I am currently trying to download an image using Google Firebase.

The database stores a URL to an image on Firebase storage, Unity pulls the URL from the DB and uses Unity WWW to download it. However the texture shows up as a red question mark texture.

If I use a http URL from another website however it works, is Unity able to download from https addresses?

This downloads the URL from Firebase and stores it in the data_url variable:

void DownloadViaURL()
{
    Debug.Log("Called DownloadViaURL");
    FirebaseDatabase.DefaultInstance
   .GetReference("test_image")
   .GetValueAsync().ContinueWith(task => {
       Debug.Log("Default Instance entered");
       if (task.IsFaulted)
       {
           Debug.Log("Error retrieving data from server");
       }
       else if (task.IsCompleted)
       {
           DataSnapshot snapshot = task.Result;

           string data_URL = snapshot.GetValue(true).ToString();

           //Start coroutine to download image
           StartCoroutine(AccessURL(data_URL));
       }
   });
}

This uses Unity WWW to download from the URL:

IEnumerator AccessURL(string url)
{

    //Debug.Log("Accessing texture URL in database");
    using (WWW www = new WWW(url))
    {
        yield return www;
        Renderer r = GetComponent<Renderer>();
        r.material.mainTexture = www.texture;
        Debug.Log("Texture URL: " + www.url);
    }
}


texts: What do these Google Play Buildbox settings mean?

texts:
I am using Buildbox to design my first game to put on Google Play store, however I am having some issues. The game is finalized now. But I have a few questions.
The settings in Buildbox ask for my

Bundle ID
Name on Device
Review Link
Leaderboard ID
Share Message
License Key
Google Play ID
Version Code

Where do I find some of this information? Also is the share message just what I want to have said when the player shares my game?