texts:
I'm trying to move two objects away from each other at a proportional distance, but on different scales. I'm not quite sure how to do this. Object A can go from position 0.1 to 1. Object B has no limits. If object B is decreasing, then Object A should be decreasing at rate R. Likewise, if Object B is increasing, then Object A increases at rate R. How can I tie these two Object positions together so that in an update loop, they automatically update their positions?

I tried using:

ObjA.Pos.X +=  0.001f * ObjB.VelocityY; //0.001f is the rate

This works but there's an error each time it runs. ObjA starts off at its max position 1 but then the next time it will stop at 0.97, 0.94, 0.91 etc.. This is due to the 0.001f rate I put in. Is there a way to control the rate, yet not end up with the rounding error?

EDIT - To clarify the scenario:
The user can provide a force to  Object B in a vertical motion (2D game). Gravity will bring the object back down once the user lets go of the up/down button. As the object moves up or down, I want object A to move left and right on the X axis. Maximum distance to the right can be '1', and to the left can be '0.1'. Therefore, if the user keeps holding up forever,object A will still only be at 0.1.

  Object A at max 1 = Object B at position 4.5 (this is the starting
  position)

  Object A at min 0.1 = object B at position +/- 9.9

Obejct B does take the game time into account.


texts: WP 8.1 XNA custom game loop (render when dirty?)

texts:
I need to know whether it's possible to create a XNA game for Windows Phone 8.1 (which I've already) using monogame with a custom game loop.

OpenGL ES has this possibility (GL_RENDERMODE_WHENDIRTY or sth. like that).

Is there anything like that RenderMode for XNA/MonoGame on WP 8.1

Note: I'm new to Windows phone game programming.


texts:
I have an implementation currently that stores each letter as it's own separate texture, usually only a couple pixels in width and height. So this has some problems as i am unable to do a batch render, i can only batch render the same characters. I am stuck with this format, all i can do is try and process it into something better at runtime. I was thinking of creating a single larger texture from all the little ones instead.

What algorithm can i use to sort the small images into a larger one?

How big can this texture get without losing pixel precision with single floating point precision UV mapping (texture width/height normalization into percent 0.0 to 1.0)?


texts: How different is Java for JRE vs Java for Android?

texts:
I'm new to all this game developing, and I'm starting to learn java because I was told it was a great way to start. I want to later on create games for the android market, and want to get a good view from you guys, so I know what I'm dealing with exactly.

I DO realize that Android development has different architectures and whatnot (that a good way to say it?)

Thanks!


texts: What is the name of the phenomenom where faces get stretched to the middle of the screen?

texts:
I'm trying to make my own 3D view in java without the use of any imported libraries. It has been going really well for me except for the fact that if I'm positioned in a certain way some of my edges get stretched to the middle of the screen. a reference image:

The gun render's completely fine in the front part, but when I'm looking at it from this angle it looks like some of my edges get stretched to my viewto point. I want to google information on what other people have done to fix it, but I have no idea what this phenomenom is named.

I'm not looking for an answer on how to fix it, but on the name of the phenomenom because I'm trying to learn as much as possible by myself.

I'm pretty sure this is a wellknown problem and I just can't remember the name of it.


texts: Multiple Texture Coordinates Per Vertex (DirectX11)

texts:
The models my artists are making in maya have multiple different texture coordinates per vertex depending on what face the vertex happens to be a part of.

Originally, to fix this problem, I duplicated each vert every time it appears in a face so each vert can have its own texture coordinates / face normals. This worked out well for a while until I started working on skinned skeletal animation.

I could not seem to get skinned skeletal animation working with this duplicate vertex method. There would be serious gaps in the mesh as it animated. In order to try and fix this, I switched back to indexed drawing, where faces share verts instead of each face having its own unique copy of a vert.

This fixed my skinned animation but now I'm at a loss as how to encode the multiple texture coordinates / face normals that are associated with verts. I was hoping there might be a way to use the index buffer and an array of face normals / uvs to fix this issue. Basically, I figure I can easily add an array of normals/tex coords to each vert but I have no idea how to instruct the gpu to properly index into it.


texts: Why doesn't this formula double the value properly?

texts:
Making a clicker game: Amount awarded per click not increasing based on how many increasers purchased.

I have a few global variables set up.

global.ramen_1 = 1

This part says how many ramen makers I have,
or what my cursor level is, if you purchase another one it goes to 2, then 3 etc...

global.ramen_1_bonus = (global.ramen_1 * 2)

This is the formula that I want to work. If I own 10 ramen makers. Every time I click the ramen picture it is going to increase based on the value of global.ramen_1 times by two. So in theory the more I buy, the higher it should go up when I click it.

I made the ramen image and clicking on it does the following code.

//Increases the amount of money by clicking the ramen
global.money += global.ramen_1_bonus

I have the object that you click that does this code which subtracts from the amount of money you have, but increases the amount of ramen makers you have. And for the time being I just have a static price, nothing that increases yet.

if (global.money >= 10) {
    global.money -= 10;
    global.ramen_1 += 1;
}

This works perfectly, ramen_1 goes up by one, the money goes down by ten when you have enough.

BUT

After I have 2 ramen makers or global.ramen_1 = 2. The formula does not work.

When I click on the ramen bowl, my money doesn't go up 4 like it's supposed to, it still only goes up by two. Why not?


texts: Turning a Java single player game into a multiplayer game

texts:
I recently built a game with libgdx for my desktop. I would like now to make it a multiplayer game.

How could I do this? I was thinking about using node.js but there are some problems: I use Box2D and other Java libraries to help me making the game simulation and this would be hard to write all over again in Javascript.

The other option would be to write a Java server. Honestly I never used sockets or anything related to networks in Java (I have always been a C++ guy). So, what would you guys recommend? What would be the best option?

Also I would like to consider the performance since Box2D simulations are a bit heavy and with Java I am able to use multi-threading while node.js doesn´t allow me to do that. (I also think Java itself is a bit faster than Javascript).

Just one more note. As I said before I never done anything network related with Java, so if you think Java is the best option could you also recommend some technologies and/or java libraries and/or articles about networking or server creation in Java?

Thanks for your time!


texts:
I am thinking of adding a special achievement in my game where if the player reaches a certain score in my game forum ( my forum is kind of like SE where you get score instead of rep when answering questions ) he then gets a reward in the game. I just want to know if it is even possible to do such thing as I want more players to participate in the forum.
Thanks!


texts: Why do games have different ports for different maps?

texts:
A little old example for that would be Metin2, this is the only game I know which have that, but there may be more.
In Metin2 there are maps which are accessable through other ports.
I'm not a network specialist, but I think then it is needed to connect to an other port on an map change.

So would it not be possible todo all that on one port? Are there any benefits from that?

Could it be that there is a limit on port connections on a server, that this would be something for loadbalancing?


texts: Handling different version clients in a multiplayer game

texts: What are various ways of handling different version clients in multiplayer games? For example, when there's an update, some games allow you to play with people who have a different version of the client. How is this handled?


texts: OpenGL ES 2.0: Converting GL_TRIANGLES into GL_TRIANGLE_STRIP

texts:
I export my 3D geometry from a 3D authoring application. It is possible to export the vertex coordinates as full triangle arrays.

On ther other hand, triangle strips are more efficient for the OpengGL to render. This is especially true for OpenGL ES, which is very sensitive for performance.

Is it therefore possible to convert GL_TRIANGLES arrays into GL_TRIANGLE_STRIP, please?

Could anybody provide me with working algorithm? Thank you.


texts:
I am using Unity's 2D Mathf.PerlinNoise(x, y) function and I would like to make it distorted. What I mean is described with this picture I made:

How can I do that? What transformations should I apply to Mathf.PerlinNoise(x, y) to achieve this effect?


texts: Cocos2d Box2d Problem, Follow doesn't work in the physical world

texts:
bool TestImageLoaderScene::init()
{
    if (!Scene::init())
        return false;

    bgLayer = Layer::create();
    this->addChild(bgLayer);

    BasicRUBELayer::init();

    playerNode = new PlayerNode;

    playerNode->addSprite();
    playerNode->addBodyToWorld(m_world);
    playerNode->addCircularFixtureToBody(0.2f);
    this->addChild(playerNode);

    bgLayer->runAction(Follow::create(playerNode));

    return true;
}

bgLayer is the layer that contains the background.
The background has a static body and is 3500 x 2700 in size.

PlayerNode is an arbitrary class created to manage sprites and bodies together, and inherits node.

class PlayerNode : public cocos2d::Node
{
public:
    void addSprite();
    void addBodyToWorld(b2World* world);
    void addCircularFixtureToBody(float radius);

    void createFixture(b2Shape* shape);

    cocos2d::Sprite* getTextureSprite() { return playerTexture; }

protected:
    cocos2d::Sprite* playerTexture;
    b2Body* playerBody;
};

Any idea why it is not working?
I am making a top-down view type game, and the phenomenon of not following the player's movement is very fatal.

please answer me.
bad engilsh so sorry...


texts:
I'm trying to make some basic animation, but I ran into this problem. Whenever I move with WASD, it teleports instead of doing the walking animation. Also the idle plays only one time, then it stops:
https://i.imgur.com/zZY6w7J.gifv

My animator setup and the console:

The code:

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

public class AppleInput : MonoBehaviour
{
private Animator animator;
// Start is called before the first frame update
void Start()
{
    animator = GetComponentInChildren<Animator>();
}

// Update is called once per frame
void Update()
{
    animator.SetFloat("Horizontal", Input.GetAxis("Horizontal"));
    animator.SetFloat("Vertical", Input.GetAxis("Vertical"));
}
}

Update:

Forgot to mention, that my character can't move further away, when I release the W key for forward, it comes back to its original place just like in gif.


texts: Calculate future 3D Position of object(Unit)?

texts:
I've looked around and almost all examples is see have a velocity vector which I do not have, or at this point am unable to figure out. Im trying to find the 3D position where i can launch a trap in game to land in the targets path of movement assuming constant speed.

What I do Have

Two Coords: Initial and a second set of X,Y,Z after 1 frame.
Unit speed as a number from the game, hoping i can calculate a better number based on the one frame difference above.
The speed of the trap - 25yards/s
The time between frames 1/ Games current FrameRate

This works on still targets but I cannot find out how to get the units speed into the calculation:

function PredictTrapPosition(unit)
unit = unit or 'target'
local x1, y1, _ = UnitPosition(unit) --forget z assume they are running on flat ground.
C_Timer.After(1/GetFrameRate(), function() -- after one frame
    local x2, y2, z = UnitPosition(unit)
    local px, py, _ = UnitPosition('player') --My position
    local distance = math.sqrt((x2 - px)^2 + (y2 - py)^2)
    local trapSpeed = distance / 25 -- trap travel time.
    local angle = atan2(x2-x1, y2-y1)
    local x = x2 + cos(angle) * trapSpeed
    local y = y2 + sin(angle) * trapSpeed
    WorldClick(x, y, z)
end)

end

Hopefully a math guru can chime in and help me fix this probably simple formula.


texts: Unity: How to cut out a transparent area from a RenderTexture?

texts:
After rendering onto a RenderTexture, is there a way to make areas of the RenderTrexture transparent again? I.e. cutting out a transparent window to see what's behind the RenderTexture?

The scene's setup looks like this:

RenderTexture with Color Format set to ARGB32.
Dedicated camera to render onto the RenderTexture.

Clear Flags is set to Solid Color
Background is set to a color with 0x00 Alpha.

The RenderTexture is mapped onto a GUI Panel using a RawImage component.

This works pretty well. The content of the RenderTexture is composed every frame and shown at the GUI Panel. The only difficulty is how to delete/clear parts of the RenderTexture to expose what's behind it.

Ideal would be using an image as mask - where every opaque (or transparent - either one is fine) pixel from the mask gets deleted (fully transparent) on the RenderTexture. Do you have any ideas how this can be done?


texts: How can I reference C# objects in GDScript (and vice versa)?

texts:
I am using Godot Engine 3.0.6 Mono for Windows x64.
I am prototyping the majority of my project in C# before I rewrite the game in C++ for release. I installed this plugin mostly to help with testing and debugging value-sensitive functionality. To make this possible however, I will need to be able to make references to my C# classes from GDScript (or vice versa) for binding commands. I could not find any instructions on how to do this in the official documentation.
Can this be done currently in either direction?

Note: If the references are made from C# to GDScript classes, I need to be able to cast the Nodes respectively to make function calls.


texts: How do you create a grid using a wire-frame shader?

texts:
So I'm having trouble going about creating an 80s neon color grid wire-frame, like the examples.

How would you go about making the floor into an 80s styled grid floor? I'm just looking for square grids.

Here is what I'm currently using

Shader "Custom/Grid" {
  Properties {
    _GridThickness ("Grid Thickness", Float) = 0.01
    _GridSpacingX ("Grid Spacing X", Float) = 1.0
    _GridSpacingY ("Grid Spacing Y", Float) = 1.0
    _GridOffsetX ("Grid Offset X", Float) = 0
    _GridOffsetY ("Grid Offset Y", Float) = 0
    _GridColour ("Grid Colour", Color) = (0.5, 1.0, 1.0, 1.0)
    _BaseColour ("Base Colour", Color) = (0.0, 0.0, 0.0, 0.0)
  }

  SubShader {
    Tags { "Queue" = "Transparent" }

    Pass {
      ZWrite Off
      Blend SrcAlpha OneMinusSrcAlpha

      CGPROGRAM

      // Define the vertex and fragment shader functions
      #pragma vertex vert
      #pragma fragment frag

      // Access Shaderlab properties
      uniform float _GridThickness;
      uniform float _GridSpacingX;
      uniform float _GridSpacingY;
      uniform float _GridOffsetX;
      uniform float _GridOffsetY;
      uniform float4 _GridColour;
      uniform float4 _BaseColour;

      // Input into the vertex shader
      struct vertexInput {
          float4 vertex : POSITION;
      };

      // Output from vertex shader into fragment shader
      struct vertexOutput {
        float4 pos : SV_POSITION;
        float4 worldPos : TEXCOORD0;
      };

      // VERTEX SHADER
      vertexOutput vert(vertexInput input) {
        vertexOutput output;
        output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
        // Calculate the world position coordinates to pass to the fragment shader
        output.worldPos = mul(unity_ObjectToWorld, input.vertex);
        return output;
      }

      // FRAGMENT SHADER
      float4 frag(vertexOutput input) : COLOR {
         if (
          frac((input.worldPos.x + _GridOffsetX)/_GridSpacingX)
            < (_GridThickness / _GridSpacingX)
             ||
          frac((input.worldPos.z + _GridOffsetY)/_GridSpacingY)
            < (_GridThickness / _GridSpacingY)) {
          return _GridColour;
        }
        else {
          return _BaseColour;
        }
      }
      ENDCG
    }
  }
}


texts: Scan for water in 2D procedural terrain locale

texts:
In my 2D-sideview game, I have certain biomes, each one having a unique sea level, or water height, (depending on the humidity of the biome). The terrain is composed of stacks of blocks, each being a type of land or being water. I want the height map to look something like this:

Terrain height does not always correlate to water height. It does so here for demo purposes.
Each lake must have a constant water height across.
What I've tried: To calculate if there is water in a region, I want to know the minimum water height of all biomes in that region. That will be the lake's water height.
However, I don't know how far the region extends on each side, so I can't find the minimum water height. If the water height was global/constant, I would search in both directions until I found a block above sea level (or a maximum distance was reached), but I don't know the water height, because I can't search for it, because I need the other water heights to search for this water height!
Some ideas that seem inefficient:

Search for the endpoints of a potential lake at each biome water level, and choose the smallest water level to generate the lake.
Find the smallest biome level in a max distance on each side, and choose the smallest water level to generate the lake.

Please tell there is a better way!
Edit:

Terrain stacks (columns) are generated individually, then loaded into memory. When the player reaches a certain distance from the stack, it will get unloaded, and then regenerated again when the player is near. Every time a terrain stack is generated it must be exactly the same.
For querying stack heights over and over again for calculating whether water should be on a stack, I cache the height and biome of some stacks beyond the loaded stacks in each direction; thus, it is not considered loaded (so entities can't move), but the basic information does not have to be recalculated.


texts:
Have problems with rendering moving character using ShapeRenderer, it twitches while moving, and I don't understand where from comes the problem - bad game structure (do I need to override draw method from my actor,or just draw all entities in Stage's draw method) or troubles with movement logic.I'll add information if needed.

MainClass:

public class MFightGame extends Game {

@Override
public void create() {
    setScreen(new GameScreen());
}

@Override
public void render() {
    super.render();
}}

GameScreen:

public class GameScreen implements Screen {

private GameStage stage;

@Override
public void show() {
    stage = new GameStage();
}

public GameScreen() {

}

@Override
public void render(float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    stage.draw();
    stage.act(delta);
}

@Override
public void resize(int width, int height) {
    // TODO Auto-generated method stub
}

@Override
public void pause() {
    // TODO Auto-generated method stub
}

@Override
public void resume() {
    // TODO Auto-generated method stub
}

@Override
public void hide() {
    // TODO Auto-generated method stub
}

@Override
public void dispose() {
    // TODO Auto-generated method stub
}}

GameStage:

public class GameStage extends Stage {
private Creature creature;
private final float TIME_STEP = 1 / 300f;
private float accumulator = 0f;
private ShapeRenderer renderer;
private OrthographicCamera camera;

public GameStage() {
    creature = new Creature(100,100);
    addActor(creature);

    camera = new OrthographicCamera(800, 600);
    camera.position.set(camera.viewportWidth / 2f,
            camera.viewportHeight / 2f, 0);
    camera.update();
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(camera.combined);
    Gdx.input.setInputProcessor(new InputHandler(creature));

}

@Override
public void act(float delta) {
    super.act(delta);
    accumulator += delta;
    while (accumulator >= delta) {
        accumulator -= TIME_STEP;
    }
}}


texts:
this has got me stuck badly: my project is in 2.5D. Jumping and crouching not implemented yet.

Making use of Axis Mapping Input from the project settings, where numpad 4= 1 and numpad 6= -1 to control my movement, the follow problem poses itself:

I have a blendspace with a horizontal axis which is MovementDirection from -1 to 1 divided in 2.The upward axis is a MovementSpeed from 0 to = 200 = Max Walk Speed on my CharacterMovement asset.

In this Blendspace I go from idle in the bottom middle, to WalkForward and WalkBackward in the upper outer extremes.

However, when in my Level Blueprint I get my MovementSpeed and MovementDirection variables from my "BP_Player" Anim Instance, in order to print them, I can see that my MovementSpeed goes all the way to my max which is 200, while in the other direction it's stuck around 0,01.

I thought it would go -200 but it doesn't, which is messing up my WalkForward blendspace part, only blending very slightly into it.

However in the blendspace I have positioned my WalkForward and WalkBackward animations correctly.

Any idea where I could have gone wrong?


texts: How does one measure and reward social aspects in virtual worlds?

texts:
Well this sounds like a pretty vague question but please bear with me.

I know of how Gaiaonline gave gold to people who participated in forum posts.

I'm curious if in theory these could be applied to social aspects of games like Second life or Sims Online.

The question what would be specific quantifiable actions/interactions could be measured tracked for rewards and achievements that would help build a community?

(this'll probably end up as community wiki though)


texts: Looking for a GUI library for OpenGL, or tips for my own (MetroUI)

texts:
I am making an OpenGL graphics accelerated FPS, and I need to find a library to handle GUI correctly. My current GUI handler just wont do!

Yes, as in the title says, the UI of the game is Metro (ZuneHD, WP7, etc).

So the UI contains little to NO images, just fonts.


texts: Unreal Engine 4 DefaultInput.ini mappings not showing in editor

texts: The mappings from DefaultInput.ini are not showing up in the editor. I had originally added them in the editor project settings, but it lost the mappings except for 2 of them Jump and Reset VR. They still show up in the DefaultInput.ini file. How do I get the editor to recover them (or read them from the .ini file?


texts: Designing MMORPG with secret quests that can remain secret for a while

texts:
First of all, I know how difficult it is to design and build MMORPG game. I do not plan to do it anytime soon, this is more of an exercise to stretch my design muscles. Just a thought experiment exploring how this game mechanic could be implemented. It's not about why it's good/bad idea or why it can't work, but about how to go about implementing it.

Imagine your run of the mill MMO a'la WoW. They have a ton of quests and even more guides on how to find them, how to finish them, what's the loot and all the stuff. I would like to introduce secret quests that function pretty much in same way as normal quests do, with the exception that you can't see them highlighted in any way and you need to do specific action/talk to specific NPC at specific place/time or something along those lines to to trigger them. Let's forgo for a moment if this is good idea from gameplay point of view, I am more interested in knowing if it is possible to keep them secret so that first few people who find them won't run to internet and tell everybody and their grandpa and ruin the experience for everybody else.

I came up with only two solutions so far and neither is good or feasible.

First, the bad one, is to randomly disable/enable them so even if somebody hears about them, they won't be likely to find it doing same steps. This has a huge downside of frustrating players and doesn't really fulfil secret-ness requirement.

Second, complicated one. Generate tons of one-time quests  (or limit how many people can get it to some very small number (dozens, perhaps)), with reasonably random triggers. This has boatload of difficulties (making sure they are interesting, completable, and rewards are intriguing) and probably impossible to do in a way that wouldn't look broken very quickly. On the other hand, it would do exactly what I want it to do.

I have my experience with designing games, so I have an idea about how things work, what players want and what makes them come back and have fun. The idea might be bad from this point of view, but I find it very intriguing and worth investigating bit further. What I am looking for is some out of the box ideas how to deliver sense of great reward when finding such secret quest but not make it frustrating to people that don't find them


texts: How to track/identify amorphous blobs in 2D or 3D space

texts:
In doing HTML/DOM work, you are working with concrete nodes which you can visibly touch and have a defined shape and boundary.

What I'm wondering though is like with a cloud like structure, or like a viscious fluid that is spraying like a geyser into the air and has big droplets of water, or maybe even like ocean waves.

A cloud doesn't have a clear boundary, it is more like a blend from one state to the next. But in your game you might say "hey there is a cloud right there" or "I just walked into a cloud". I don't see how the game can do that, how it identified something without a concrete, discrete ID! Likewise, an ocean wave doesn't have a clear boundary the same way a machine or a human being has a "boundary". A wave blends into the main water, and splashes away stuff, and is evaporating and all kinds of stuff. But you can still say in your game "there is a wave over there".

The question is, how that wave or that cloud is actually identified in the game. I would've thought initially to just create a "wave object" or a "cloud object", and have it move through the water or move through the sky. And maybe add some sort of sensor like stuff to it so it seemed like it was more amorphous than it's discrete representation under the hood.

But the thing is, a cloud or more generally a blob can subdivide/split/merge with others/etc. So it's so-called discrete identity is very... fluid. There's not really a centralized identity, there's just these blobs that come and go and change shape and stuff.

So I'm wondering how these sorts of things are treated in games that handle more advanced use cases. I'm new to quad-/octrees but maybe they are used somehow here. It seems like object motion tracking might have some insight but I'm not sure and most stuff I've seen is on clearly distinct objects like moving cars or people rather than clouds or waves or "blobs".

I am wondering because it's so far unclear to me how one might "iterate" through "a list of blobs". What counts as an "identity". (Not talking about things like FPS caring about individual pieces of glass or droplets of water, but maybe a puzzle game about blobs or something, or some scientific game). The blobs can merge and split and divide and such, then I wonder how often we are tracking their changes in shape. Or maybe there's ways to be notified when a "major event" occurs. I don't know.

Basically I'm wondering where I could look to learn more about how to handle amorphous "structures" in 2D or 3D worlds that are changing regularly like described. I am not sure if (so to speak) these blobs are given "unique IDs" and treated like database records, or if they are less structured (or if they can be this structured in some way).


texts:
I have custom low poly model ,the thing is it is not receiving shadows.

Unity's default plane do receive the shadow but not my low poly plane.

Here is image that demonstrate more,


texts: How to Procedurally generate a mesh with animation for Creamy Effect in Unity (mobile supported)

texts:
I want this cream effect in Unity

I have checked OBI Fluid which seems to be the best fluid simulation pack so far in Unity but I am not sure if I really need that for this scope. Maybe vertex shaders? Any suggestions on how this reference mechanics would've been implemented and how I can re-create it as I am in love with that creamy feeling.


texts: Detecting internet Connection on Unity connection to serve ads

texts:
How can you detect someone's Internet connection in Unity? I see a lot of forums where people make a request to any site (mostly google.com) to check it, but it does not seem to be an elegant solution.

With 3G/4G connections to serve Unity ads or admob interstitial, it takes a lot of time and crashes the game.

Regards!


texts: Response to form triggers creation of zero or more duplicate scenes

texts:
I've got two scenes, one with room 1 and one with room 2.

In room 1 I've got one table with two 3D assets on top of it. This room also has a door that connects to room 2 through a door but it's closed.

Once going near the 3D assets a dialog pops up saying to click "E". This pops up a 2D form one needs to fill.

Only after filling both forms I'm able to go into room 2.

Now what I would like to do is, depending on the response in the form, one or more duplicate room 2 scenes should be created and dynamically added to the scene. If with scenes isn't possible, what's the way to do such thing?

Know about SceneManager.CreateScene but this creates an empty scene, not exactly what I want to.


texts: Tile based platformer, using larger tiles?

texts:
So for my tile based platformer, It has a grid of tiles Occupying 1x1 block for each one.

However, What if I want larger tiles? Maybe doors, tables, etc. They wouldnt fit in a 1x1 tile, so what I need is a way to let any method trying to access my tile array, know that a tile could be occupying a larger space.

I can already render larger objects correctly, But I simply am looking for a method to let evrything else know a larger tile is there, So I can perform collision on it, and so other tiles cant be placed on it.


texts: PlayerPrefs.SetInt Stops code below from running

texts:
This is the code...

void storeStarData()
{
    // Code to store star data in PlayerPrefs...
    Debug.Log("Writing to PlayerPrefs");
    PlayerPrefs.SetInt("totStars", NumOfStars);
    int i = 0;
    Debug.Log("test");
    while (i < NumOfStars)
    {
        PlayerPrefs.SetString("starID" + i, StarIDID[(i)]);
        PlayerPrefs.SetString("starName" + i, StarName[(i)]);
        PlayerPrefs.SetString("starHIP" + i, StarIDHIP[(i)]);
        PlayerPrefs.SetString("starHD" + i, StarIDHD[(i)]);
        PlayerPrefs.SetString("starHR" + i, StarIDHR[(i)]);
        PlayerPrefs.SetString("starGL" + i, StarIDGL[(i)]);
        PlayerPrefs.SetString("starBF" + i, StarIDBF[(i)]);
        PlayerPrefs.SetString("starRA" + i, StarRA[(i)]);
        PlayerPrefs.SetString("starDec" + i, StarDec[(i)]);
        PlayerPrefs.SetString("starMag" + i, StarMag[(i)]);
        PlayerPrefs.SetString("starCI" + i, StarCI[(i)]);
        Debug.Log("star " + i + " complete");
        i++;
    }
    PlayerPrefs.Save();

    i = 0;
    int ok = 0;
    while (i < NumOfStars)
    {
        if (PlayerPrefs.GetString("starID" + i) != null)
        {
            ok++;
        }
        i++;
    }
    Debug.Log(ok);
}

And this is the Debug.Log output that I am getting...

As you can see, the program gets up to the First Debug Log Debug.Log("Writing to PlayerPrefs"); But then stops before the Debug.Log("test");.

After removing PlayerPrefs.SetInt("totStars", NumOfStars); The program gets to the Debug.Log("test");. So it is the PlayerPrefs.SetInt causing the issue.

How do I fix this?


texts: Unknown build errors when building for Android

texts:
I'm experiencing the following errors when I try to Build + Run to Android and have no idea what to do about them. Can anyone help?

Observed package id 'tools' in inconsistent location 'C:\Users\X\AppData\Local\Android\Sdk\tools.new' (Expected 'C:\Users\X\AppData\Local\Android\Sdk\tools')
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Already observed package id 'tools' in 'C:\Users\X\AppData\Local\Android\Sdk\tools'. Skipping duplicate at 'C:\Users\X\AppData\Local\Android\Sdk\tools.new'
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Transform component could not be found on game object. Adding one!
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
GameObject has multiple Transform components! Merged into single one.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
CheckConsistency: GameObject does not reference component MonoBehaviour. Fixing.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Transform component deleted: GameObject pointer is invalid
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Error building Player: 3 errors
Build completed with a result of 'Failed'
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x0021f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:187
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:94
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()


texts:
I've been working on a game for awhile and I am developing it with RPG Maker VX. I came to a point where I needed to... I guess for lack of better explanation... Limit the key items to just 1. So I started looking through my scripts and found (in Game_Party):

  #--------------------------------------------------------------------------
  # * Get Maximum Number of Items Possessed
  #--------------------------------------------------------------------------
  def max_item_number(item)
    return 99
  end

and added below it:

  #--------------------------------------------------------------------------
  # * Get Maximum Number of Key Items Possessed
  #--------------------------------------------------------------------------
  def max_key_item_number(item)
    return 1
  end

and right below that is:

  #--------------------------------------------------------------------------
  # * Determine if Maximum Number of Items Are Possessed
  #--------------------------------------------------------------------------
  def item_max?(item)
    item_number(item) >= max_item_number(item)
  end

So I changed the last one too:

  #--------------------------------------------------------------------------
  # * Determine if Maximum Number of Items Are Possessed
  #--------------------------------------------------------------------------
  def item_max?(item)
    if key_item? == true
      item_number(item) >= max_key_item_number(item)
    end

    if key_item? == false
      item_number(item) >= max_item_number(item)
    end
  end

Now this seemed to not affect anything (that I could tell). I tested it and its still the same as before I touched anything. I am new to developing games and relatively new to scripting for them. Is this approach even close to what I want to do? Any help is greatly apprecieated!


texts: How to inplement a save-system for a complex nested list of character classs?

texts:
This is the situation I'm in:

I'm developing a game with C# using unity. In the game I have characters which is either locked or unlocked, and they're pretty much the same. For every character, they have their respective rank, level, type and race (provides additional effects), HP and MP as well as some stats, unique abilities with arbitrary effects to the game suited to them.

Then, the complication comes in as there's also a "Inventory" with predefined "Items", which every one of them holds arbitrary effects, can be either passive or active, as well as another set of rank and level for every item.

So, now I have to do planning. I want all the parameters for the characters to be in a single file (for obvious reasons), where the character class should read these file, retrieve the relevant part, and apply it to the character.

The game will be updated with new characters/items, or changed abilities/stats/effects. My saving system has to generate save data that persist from all versions too. (Say, a character is added. Then the old save should still load fine, with the new character initialized at locked and basic stats)

And I'm not sure what should be used to implement it with such a multi-layered nested structure, which still has to persist. My idea is to make the whole character structure a list with each character being the element, but then I can't see how to make a flexible system when there are apparently lists of lists of lists of lists, which is basically a mess to work with. I need some way to store the structure in a abstracted way that allows me to save all the parameters in all the nested stuff of a list of characters in a save file, and then also be able to read them (and fill those missing parts with initialized value).


texts: My world is represented by a 3D density field, where a positive density means solid ground and a negative (or zero) density means air.  How can I generate a navmesh from that voxel data, with surfaces with a slope of 45 degrees or less being "walkable"?


texts: How to calculate a direction vector for camera?

texts:
I have a vector that describes change in movement, and I have a 3d-vector, m_rot, that describes a rotation given to an object.
I want to calculate a direction vector using both this data.
How to achieve that?

I tried to multiply the components of a direction vector onto sin and cos of m_rot values, but that gave me nothing.

direction.x = direction.x * ::cosf(m_rot.x);
direction.y = direction.y * ::sinf(m_rot.y);
this->camera_world_pos += direction;

But after that my camera still walks into a simple directions, and not a direction that it looks at.


texts: What are the most-valuable research fields to explore nowadays concerning game AI?

texts:
I'm having some troubles coming up with a subject for my master's degree thesis. I'd like to know what areas of research are valuable at this time (and the near future) so I can narrow my search and idea-creation.

Thanks in advance.


texts: How to store a Transform[,] grid in an ArrayList?

texts:
I am new to Unity game dev and trying to expand my knowledge of data structs. I'm building a match-3 game, and I currently have a multi-dimensional ArrayList holding transform coordinates on a grid of x width and y height. I have game objects tied to these coordinates in world space, with the grid syncing the data back in game space. I am attempting to push these coordinates into the nested list (familyList) to be deleted pending 3 or more units being added to familyArrayList (seen below).

Here's the abridged code:

private static Transform[,] grid = new Transform[width, height];
public static ArrayList familyArrayList = new ArrayList();

// Go through game grid line by line and add game objects from game space into family ArrayList
for (int y = height - 1; y >= 0; y--)
        {
            for (int x = 0; x < width; x++)
            {
                if (grid[x, y] != null)
                {
                    // Add grid[x, y] to familyArrayList
                    familyArrayList.Add(grid[x, y]);
                    Debug.Log(familyArrayList[0]);

Output:

Green Unit(Clone) (UnityEngine.Transform)

How can I get familyArrayList to properly story the grid coordinates and not the game object the grid coordinates are referencing?
i.e. familyArrayList[0] == '3,4'
Should I instead use a nested list? At a later point in the code, I want to clear the game object from the board in world space as well as set the grid[x,y] to null:

// Loop through all family array and destroy game objects
foreach (var x in familyArrayList)
{
    Destroy(familyArrayList(x).gameObject);
}
// Loop through all family array and set their values to null in grid as well
foreach (var x in familyArrayList)
{
    familyArrayList(x) = null;
}

But I get errors like "Argument 1: cannot convert from 'object' to 'int'" and "Non-invocable member 'Piece.familyArrayList' cannot be used like a method" which I can imagine are explained by my above problem of not storing the grid coordinates properly and instead storing the referenced game object. I'm truly stumped on this problem and thank anybody in advance who can point me in the right direction to solving this.


texts: Load large quantities of data in Unity3D

texts:
I'm building an Android app using Unity3D where users can visualize data immersively.

The data is immutable and stored using a MySQL database hosted on cPanel.

When the user clicks a button in the environment, it starts the creation of a chart. First, contacts a .php file present in the server responsible to query the database, fetching the data and make it available to the Unity controller which then adds the points to the chart. This works fine for small quantities of data.

To increase performance, thought of exporting from MySQL as CSV and transform to one JSON, instead of querying a database or try to make MySQL transform to JSON, but I'm afraid this won't be enough.

Could also extract as CSV and use a 3rd party for reading it.

How would you load the data in such case to have the best performance?


texts:
I have been working on a way to do collision detection forever, and just can't figure it out. Here's my simple 2D array:

for (int x = 0; x < 16; x++) {
           for (int y = 0; y < 16; y++) {
              map[x][y] = AIR;
              if(map[x][y] == AIR) {
                 air.draw(x * tilesize, y * tilesize);

              }

           }
        }

    for (int x = 0; x < 16; x++) {
           for (int y = 6; y < 16; y++) {
              map[x][y] = GRASS;
              if(map[x][y] == GRASS) {
                 grass.draw(x * tilesize, y * tilesize);

              }

           }
        }
    for (int x = 0; x < 16; x++) {
           for (int y = 8; y < 16; y++) {
              map[x][y] = STONE;
              if(map[x][y] == STONE) {
                 stone.draw(x * tilesize, y * tilesize);
              }

           }
        }

I want to do it with rectangles, and using the intersect() method, but how would I go about adding rectangles to all the tiles?

Edit:

My player moves like this:

if(input.isKeyDown(Input.KEY_W))
    {
        shiftY -= delta * speed;
        idY = (int) shiftY;

        if(shift == true)
        {
            shiftY -= delta * runspeed;
        }

        if(isColliding == true)
        {
            shiftY += delta * speed;
        }
    }

    if(input.isKeyDown(Input.KEY_S))
    {
        shiftY += delta * speed;
        idY = (int) shiftY;

        if(shift == true)
        {
            shiftY += delta * runspeed;
        }

        if(isColliding == true)
        {
            shiftY -= delta * speed;
        }
    }

    if (input.isKeyDown(Input.KEY_A)) {
        steve = left;
        shiftX -= delta * speed;
        idX = (int) shiftX;

        if(shift == true)
        {
            shiftX -= delta * runspeed;
        }

        if(isColliding == true)
        {
            shiftX += delta * speed;
        }
    }

    if (input.isKeyDown(Input.KEY_D)) {
        steve = right;
        shiftX += delta * speed;
        idX = (int) shiftX;

        if(shift == true)
        {
            shiftX += delta * runspeed;
        }

        if(isColliding == true)
        {
            shiftX -= delta * speed;
        }
    }

(I have tried my own collision code, but its horrible. Doesn't work in the slightest)


texts:
I am trying to get a GameObject to be able to be controlled to move freely around a sphere using a virtual on-screen joystick. I am building this for iOS and Android in Unity. I am using the standard Joystick script that comes with the Standard Assets (Mobile) package. I can get the object to turn around it's forward vector using the joystick by this code:

if (moveJoystick.IsFingerDown())
{
    // Rotate the ship according to the joystick angle
    currentAngle = moveJoystick.getAngle();
    thisTransform.RotateAroundLocal(Vector3.forward, Mathf.DeltaAngle(lastAngle, currentAngle)*Mathf.Deg2Rad);
    lastAngle = currentAngle;
}

That rotates the ship around it's local axis correctly. My problem is trying to get the joystick to move the object around the sphere based on the axis that the joystick is on. This would mean the object moves in the angle it is pointing but staying at the same radius from the center of the sphere which is located at (0, 0, 0). Then I also need to have the camera follow the object as it moves. Any ideas?

Edit:
I got the orbit to work based off of the joystick using the code below. But the rotations seem to get messed up as soon as it gets to a certain point. Around 180 degrees? Also what is the correct way to have the camera follow the ship? I tried to make the camera a child of the ship in the hierarchy and that is when I really notice the messed up rotations and the ship doesn't respond correctly to my joystick. Also now the joystick doesn't rotate the ship around it's local axis anymore. Hmmm.

   if (moveJoystick.IsFingerDown())
        transform.RotateAround(Vector3.zero, Vector3.up, -moveJoystick.position.x * SPEED * Time.deltaTime);
        transform.RotateAround(Vector3.zero, Vector3.right, moveJoystick.position.y * SPEED * Time.deltaTime);
    }


texts: How to control JavaFX's animations execution order when animations "queue" is being altered in run-time?

texts:
What is the proper way of handling synchronization between GUI animations' execution order and the user's dynamic input?

More specifically, I would like to know how to enforce some logical conditioning on the execution's order, while remembering, that the user's input cannot be foreseen.

For instance, a greatly simplified example:

9 rectangles are shown on a screen.
A click on a rectangle fades it out.
The user clicks whichever rectangle he wants in whatever order he likes and as fast as he feels is right.
The condition here breaks into two simple ones:

The rectangles must not fade out simultaneously.
The rectangles' fade out effect occurs in the same order as their clicks.

I would assume a simple FIFO methodology here where threads would register themselves in some ordered queue and be allowed to enter the critical code only on their turn would be sufficient.

A slightly more complicated scenario:

8 rectangles are shown on a screen - the 9th is an invisible rectangle.
A click on a rectangle that is a neighbor of the invisible one, activates a translate animation that swipes between the two.
The user clicks whichever rectangle he wants in whatever order he likes and as fast as he feels is right.
A "shuffle" button is shown on the screen - shuffles the rectangles in a legal manner, i.e., by randomly moving the rectangles many times.
The conditions:

The rectangles must not get swiped simultaneously when clicked directly, their animations must be played in the order they were clicked.
The rectangles must get swiped simultaneously when the "shuffle" button is clicked. Meaning, the user must only see each rectangle move to its final position.

Some constraints:

Each rectangle has a Coordinate field that itself contains xCoordinate & yCoordinate.
Checking if the clicked rectangle is a neighbor of the invisible one will be done by comparing the rectangles' Coordinates and not their positioning on the screen, i.e., translateX, translateY.
If they are neighbors: the rectangles swipe places.
Else: the rectangle shows a nudge animation (as in invalid move).
Only after the animation is finished, rectangles' Coordinates can be swiped.
Each process (containing the needed steps after a click) apart from the animation itself, should be handled in a different thread.

A question: If the Coordinates can be swiped only after the animation is done, meaning each click activates a thread that holds all other threads(clicks that came after) until it is done so it can swipe the coordinates so the next thread's neighbor check is based on correct data, how would it be possible to allow the "shuffle option" without creating an entirely different execution path, i.e., by reusing most of the already written code and leveraging the Java & JavaFX's strengths?

What if we add a constraint that only every second click should be executed?

My point being, these problems can appear in various ways. There must be someone who thought of providing some kind of framework or an abstract solution to this kind of problems. Or is it each case for itself?


texts: Pathfinding for a lot of units, mostly random movement

texts:
I'm using a uniform cost eight-directional grid as a map, with buildings that represent unpassable terrain - the map tries to simulate a top-down flat city. I'm trying to fill the city with randomly walking citizens, and with player units with controlled paths.

So far, for the random walking I've just chosen a direction and set a direct line on it ( using berensham's line algorithm), until the unit strikes a wall, but even this slows down the game with 200 units, and that's before more complex routes are looked for by the player.

So, I need:

An algorithm to quickly compute a lot of simple routes.
A good pathfinding algorithm - so far I've read about HPA* and A* with JPS, but to both I haven't managed to find an implementation, which is a problem because the articles are a bit too theoretical for me.

For illustration, the situation is somewhat similar to the movement in Atom Zombie Smasher - there are uncontrolled civilians that walk randomly / run away from a threat, and few player units that walk on prescribed paths, only in my game the player can't affect the path mid-walk.

So, to summarize - I'm looking for a system for pathfinding for a couple of hundred of units which is as quick as possible.


texts: Multiplayer Game Data Serialization Problems

texts:
I want to create a simple game that can be played with one to two player. I plan on using TCP sockets, Farseer Physics, XNA, a BinaryFormater and a Memorystream.

as far as i know i can't do the physics on both clients, or you'll end up with everything out of sync. So my Idea was to do the physics on the host side then send the Farseer World data to the other client, however it is un-serializable and I also realized this was a lot of data to send every tick.

I could just send the players movements back to the server and send a Texture2D to the client to be drawn, however a Texture2D is un-serializable as well. it has dawned on me i must be doing this completely wrong.

But this is how i am attempting to send the data:

[Serializable()]
class ServerData
{
    public Texture2D Test;

    public Vector2 Test2;
}

    static void SendData()
    {
        byte[] DataBuffer = null;

        MemoryStream stream = new MemoryStream();
        BinaryFormatter formatter = new BinaryFormatter();
        NetworkStream netStream = PlayerOneSocket.GetStream();

        ServerData ServerDataToSend = new ServerData();

        formatter.Serialize(stream, ServerDataToSend);
        DataBuffer = stream.ToArray();
        netStream.Write(DataBuffer, 0, DataBuffer.Length);
        netStream.Flush();
    }

what am i doing wrong or how do i do it right.

I've done basic server stuff before with custom classes and serialization, I'm just at a loss on how to make a multiplayer game.

Thanks for the help


texts:
I am developing an Android game, in which a ball (bitmap) translates( is in motion). So I have provided motion equations for the ball. I have checked my app on Samsung galaxy S2 whose actual density is roundly 252 dpi, and It works fine on that. So my question is that Does these motions of bitmaps in surfaceView, depends on actual density of phone( i.e 252 dpi for S2) or generalized density(i.e 240 dpi).

I am confused whether if I run this app on 235 dpi smartphone, So will it have the same performance of motion as it is on Galaxy S2( with 252 dpi) or it would be little slow ?

Any help will be appreciated.

Let me elaborate it with coding. For example a linear motion of a ball is defined as with this equation x=x+4;
Now If I run this app, on Samsung galaxy S2(252dpi, and hdpi), So It will give me a particular speed motion, let say P is the speed of the ball.
Now If I run this application on Samsung Galaxy S3(300+ dpi, xhdpi), So the ball speed gonna be slow on this density, meaning less than the speed P.

So I will need the same speed on xhdpi density phone.
So will use these conversion formulas ;
dx= (x*160)/240;
px= (dx*320)/160;
 Hence the speed will be either exact or little different from P.(This is my confusion). That Whether the speed will be as same as it was on S2.

So my Question at this point is that my app worked on Samsung Galaxy S2 with the speed p, that I desired. As S2 is of 252 dpi, So Should I Include 240(Generalized density or 252 (Actual density) in my this line of coding ?
    dx= (x*160)/240;

Thanks !


texts:
In this RPG.SE post a long-lost page with several online generators is mentioned.
I'm particularly curious about the way towns were generated. Take this image for example:

Although a lot of things could be improved graphics-wise, it was very good considering the tools available at the time (mid to late 90s):

The road layout seems fairly organic (even considering all roads are placed in an orthogonal manner).
Not all roads are necessarily connected, but it feels right.
Buildings are placed in believable spots.
Even trees seem to be placed in logical spots.

I think it would be fun to give it a shot and try it myself. Especially since my previous attempts have been too "blocky":

You'll notice that I'm describing many of the qualities with not-quite-measurable adjectives (seems, feels, believable, etc) so I'm having a hard time translating them to instructions and ultimately to an algorithm.
Are there any tried-and-true algorithms for town generation?
I understand this seems to be too broad, so consider this: If I asked for an algorithm for generating maps of continental land masses, I'd get references to Perlin and other noise algorithms right away; closely followed by Voronoi.
I've seen questions like this one but they seem to have a more concrete idea already in mind (ie: 2x2 houses, fixed number of houses, canal and road placement restrictions).
What I'd like to have is something less constrained. Except maybe for the grid layout, which should be a lot easier for a first attempt than, say, L-system.


texts: How to detect collision between two directed object?

texts:
I'm currently writing a game which is like Battle City game. But right now I'm facing a trouble involved to checking collision between two objects. This is the code that I wrote:

//-------------------------------------------------------------------------------------------
//  check collision between a tank and another object
//
bool GameController::checkTankMeetsObject(Tank tank, GameObject ob)
{
    int obX = ob.getCoord().getX();
    int obY = ob.getCoord().getY();

    // calculate area of obstacle: bottom left (X1, Y1), top right (X2, Y2)
    int obX1 = obX - SQUARESIZE / 2;
    int obX2 = obX + SQUARESIZE / 2;
    int obY1 = obY - SQUARESIZE / 2;
    int obY2 = obY + SQUARESIZE / 2;

    int tankX = tank.getCoord().getX();
    int tankY = tank.getCoord().getY();

    switch (tank.getDir())
    {
    case UP:
        if ((tankX < obX2 + SQUARESIZE / 2 && tankX > obX1 - SQUARESIZE / 2) &&
            (tankY + SQUARESIZE / 2 > obY1 && tankY + SQUARESIZE / 2 < obY2))
            return true;
        break;

    case DOWN:
        if ((tankX < obX2 + SQUARESIZE / 2 && tankX > obX1 - SQUARESIZE / 2) &&
            (tankY - SQUARESIZE / 2 > obY1 && tankY - SQUARESIZE / 2 < obY2))
            return true;
        break;

    case LEFT:
        if ((tankX - SQUARESIZE / 2 < obX2 && tankX - SQUARESIZE / 2 > obX1) &&
            (tankY > obY1 - SQUARESIZE / 2 && tankY < obY2 + SQUARESIZE / 2))
            return true;
        break;

    case RIGHT:
        if ((tankX + SQUARESIZE / 2 < obX2 && tankX + SQUARESIZE / 2 > obX1) &&
            (tankY > obY1 - SQUARESIZE / 2 && tankY < obY2 + SQUARESIZE / 2))
            return true;
        break;
    }

    return false;
}

This code does well with normal circumstance, but in special ones like which I describe below, it doesn't work.

The white squares are obstacles and the grey square is the tank. Current direction of the tank is RIGHT. In this situation, I can not move the tank RIGHT or LEFT, only direction I can go is DOWN. Is there any solution to optimize my code?


texts: Why are leaderboards often separated between platforms?

texts:
I noticed that many games (if not most or all) are employing different leaderboards for different platforms. For example, different leaderboard for iOS and Android. Different leaderboard for Xbox and PS.

I can't see the logic behind that. After all, let's say iPhone and Android are sending the data to a single service/system.

Is it a business decision?


texts: How to generate a navmesh from a set of 3D meshes from scratch

texts:
I've found a great article on how to build a constrained delaunay triangulation that can be used to create a simple navmesh from cutout geometry. However, this does not seem sufficient to generate a high quality navmesh from any arbitrary set of level geometry from scratch.
One of the problems is that it only deals with triangles in XZ space. But how should I handle situations where an arbitrary 3D mesh is intersecting another arbitrary 3D mesh? Within their intersection, each triangle would need to retriangulated in some way.


texts:
I'm working on a small management game. The player manage his hospital where he can collect items and new characters. Each player can visit others players hospital and gives collected entities.

I would like to save game state on the server side to allow this "multiplayer" part and check data to avoid cheating players.

I'm a little bit curious about the server side. Should I send all the game save file to the server then parse it to check his integrity?

My game will call specific routes to update the amount of data each 30 seconds/1 minutes.

I have made few games by the past but without the network part.


texts:
Currently, I have a 2D platformer game, and I want to implement a function that can make the player die and go back to the start or a checkpoint when he interacts with a weapon or trap.
What I have in my scene is a sprite with a Rigidbody on it and a trap sprite with a BoxCollider2D on it which is set to trigger.
How can I make my player go back to the start when he hits the trap?


texts:
Some years ago, if you wrote in C and some subset of C++ and used a sufficient number of platform abstractions (via SDL or whatever), you could run on every platform an indie could get on - Linux, Windows, Mac OS of various versions, obscure stuff like BeOS, and the open consoles like the GP2X and post-death Dreamcast. If you got a contract for a closed platform at some point, you could port your game to that platform with "minimal" code changes as well.

Today, indie developers must use XNA to get on the Xbox 360 (and upcoming Windows phone); must not use XNA to work anywhere else but Windows; until recently had to use Java on Android; Flash doesn't run on phones, HTML5 doesn't work on IE. Unlike e.g. DirectX vs. OpenGL or Windows vs. Unix, these are changes to the core language you write your code in and can't be papered over without, basically, writing a compiler. You can move some game logic into scripts and include an interpreter - except when you can't, because the iPhone SDK doesn't allow it, and performance suffers because no one allows JIT.

So what can you do if you want a really cross-platform portable game, or even just a significant body of engine and logic code?

Is this not a problem because the platforms have fundamentally diverged - it's just plain not worthwhile to try to target both an iPhone and the Xbox 360 with any shared code because such a game would be bad? (I find this very unlikely. I can easily see wanting to share a game between a Windows Mobile phone and an Android, or an Xbox 360 and an iPad.) Are interfaces so high-level now that porting time is negligible? (I might believe this for business applications, but not for games with strict performance requirements.)

Is this going to become more pronounced in the future? Is the split going to be, somewhat scarily, still down vendor lines? Will we all rely on high-level middleware like Flash or Unity to get anything cross-platform done?

tl;dr - Is porting a problem, is it going to be a bigger problem in the future, and if so how do we solve it?


texts:
I've read this document about HLSL registers, but it's more of a syntax description and not a purpose explanation.

What are registers in HLSL, actually? How and when do I use them? What happens if I don't (what's the default)?


texts: What would be a fast way of detecting collision between 2 2d rotated rectangles?

texts:
Currently I am following this tutorial here for 2D collision detection:
http://www.gamedev.net/page/resources/_/technical/game-programming/2d-rotated-rectangle-collision-r2604

I have found that the way of converting the projected vectors to a scalar value doesn't seem to be correct and there are false reports of collision. I tried to only take the projected x value and using that as a scalar however this runs into the rare corner case of when the axis is pointing up the x values are all 0.

If there is a way to solve this problem it would be great. All help is appreciated.


texts: I am making game that will be completely free and I want to publish it. The publishing platform have to be free and it can be done without any contract or specific license. I simply upload my files make my game page and that’s all. Thanks for help, Maratonec.


texts: Algorithm for approximating sihlouette image as polygon

texts:
Possible Duplicate:
  Is there any heuristic to polygonize a closed 2D raster shape with n triangles?

I want to be able to analyze a texture in real time and approximate a polygon to represent a silhouette.  Imagine a person standing in front of a green screen and I want to approximately trace around their outline and get a 2D polygon as the result.  Are there algorithms to do this and are they fast enough to work frame-to-frame in a game?

(I have found algorithms to triangulate polygons, but I am having trouble knowing what to search for that describes my goal.)


texts: Creating Saving and Loading Materials in Runtime

texts:
I'm trying to create a material during runtime like this:

In my Assets I have a Render Texture and one Material
I created an Script where I attach the Render Texture to Material
I save in my project a PNG Image File for later use

public void CreateAndSaveMaterial(){

RenderTexture.active = _renderTexture;
Texture2D tex = new Texture2D(_renderTexture.width, _renderTexture.height, TextureFormat.ARGB32, false);
tex.ReadPixels(new Rect(0, 0, _renderTexture.width, _renderTexture.height), 0, 0);
tex.Apply();

File.WriteAllBytes(Application.dataPath + url, tex.EncodeToPNG());

tempObject.mainTexture = tex;
RenderTexture.active = null;

}

*The PROBLEM:

1.The Material works in rutime, after quit playing, the Material resets :(
2.The created PNG File not working only if the file is reimported in Unity, I tried with:

AssetDatabase.CreateAsset(obj, fileName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

But unsuccessfully, works only in Editor not in build app :(

Any suggestions?
Thanks in advance!


texts: LibGDX - Best way of scrolling background

texts:
I'm new to LibGDX and i'm trying to implement a screen where i have a guy running and the ground under him scrolling to give impression he is really running in a sidewalk for example.

The ground should be interactive meaning it will not only change his colors or Texture but there will also be holes in it and so on.
As you can see from the picture below each brick is a Block Object and i'd like to keep it this way.

Do you think in this case the best thing is to move the camera so i can show the screen ahead or try to scroll the background elements editing their position?

Update

So to be more clear, each block is separated from the others so it is impossible to "scroll the background" since there is no a real background, also each block will have different properties, it means it can be a block or a hole or whatever, basically i see the possibility of the  scrolling camera as only solution.


texts: How to keep triangles from connecting across voxel mesh

texts:
I am working on a voxel engine and have just started learning webgl. I have generated a list of Vertices and Indices by using Array.concat() on a template array and adding a value based on my position in loop.

var verticesTemplate = [
    // Front face
    -0.5, -0.5,  0.5,
     0.5, -0.5,  0.5,
     0.5,  0.5,  0.5,
    -0.5,  0.5,  0.5,

    // Top face
    -0.5,  0.5, -0.5,
    -0.5,  0.5,  0.5,
     0.5,  0.5,  0.5,
     0.5,  0.5, -0.5,

    // Right face
    0.5, -0.5, -0.5,
    0.5,  0.5, -0.5,
    0.5,  0.5,  0.5,
    0.5, -0.5,  0.5,

    // Bottom face
    -0.5, -0.5, -0.5,
     0.5, -0.5, -0.5,
     0.5, -0.5,  0.5,
    -0.5, -0.5,  0.5,

    // Left face
    -0.5, -0.5, -0.5,
    -0.5, -0.5,  0.5,
    -0.5,  0.5,  0.5,
    -0.5,  0.5, -0.5,

    // Back face
    -0.5, -0.5, -0.5,
    -0.5,  0.5, -0.5,
     0.5,  0.5, -0.5,
     0.5, -0.5, -0.5,
];
var indicesTemplate = [
    0, 1, 2,      0, 2, 3,    // Front face
    4, 5, 6,      4, 6, 7,    // Back face
    8, 9, 10,     8, 10, 11,  // Top face
    12, 13, 14,   12, 14, 15, // Bottom face
    16, 17, 18,   16, 18, 19, // Right face
    20, 21, 22,   20, 22, 23  // Left face
];
var WorldVertices = [];
var WorldIndices = [];
var IndexLoopIndex = 0;

function generateMeshData() {
    for(var x = 0; x < 4; x++) {
        var blockVertices = [].concat(verticesTemplate);
        addToX(verticesTemplate, blockVertices, x);
        for(var y = 0; y < 4; y++) {
            addToY(verticesTemplate, blockVertices, y);
            for(var z = 0; z < 4; z++) {
                var block = blocks[x][y][z];
                if(block.isActive === true) {
                    // adds a value of 1(The blockSize) to all z coordinates in verticesTemplate and adds to end of WorldVertices
                    addToZ(verticesTemplate, blockVertices, z);
                    WorldVertices = WorldVertices.concat(blockVertices);

                    var indices = [].concat(indicesTemplate);
                    addToXYZ(indicesTemplate, indices, 24*IndexLoopIndex);
                    WorldIndices = WorldIndices.concat(indices);
                    IndexLoopIndex++;
                }
            }
        }
    }
}

The problem is that the triangles are skewed after the mesh is rendered using gl.drawElements. And I can't figure out why. So how can I keep triangles from being drawn that connect cubes?


texts: Game Asset Storage - Graphics, 3D Models, Sounds

texts:
I've recently started completing games and accumulating "assets" -- graphics, sound effects, textures, 3D models, etc. that I can build on and reuse from game to game.

Is there a great, free place I can store an unlimited amount of this content? Ideally, I would like to categorize my content (by game) and tag it (eg. icons, characters, sound-effects, soundscapes). Unlimited storage is key, because I want everything stored in one place.

Also, most of my content is strange file formats; graphics are vector done in Flash (.FLA), or in GIMP (.XCF); I don't know what 3D model formats I'll use. Sounds will be .MP3.

Where can I store this stuff?

Edit: Not quite 100% dupe, but quite similar to Assets Management, database or versioning system?


texts:
I am attempting to expose glm vector functions/data to luabridge like so:

    .beginClass<glm::mediump_vec3>("vec3")
    .addConstructor<void(*)(const float&, const float&, const float&)>()
    .addData("x", &glm::mediump_vec3::x)
    .addData("y", &glm::mediump_vec3::y)
    .addData("z", &glm::mediump_vec3::z)
    .addData("r", &glm::mediump_vec3::r)
    .addData("g", &glm::mediump_vec3::g)
    .addData("b", &glm::mediump_vec3::b)
    .endClass();

but I am struggling with the operators, such as addition, as they do not seem to be directly attached to the class, and are in a mess of templates. I'm wondering if I should put in a layer of indirection, and have some kind of simpler, non template version of the vec3 in order to make exposure of methods simpler, or if there is a way to register the operators cleanly. Does anyone know how to do this?


texts: How can I improve or replace my programmer art?

texts: Say I'm a programmer who has done his own sprites or 3d models which would fall into programmer-ish kind of art. What steps can I take in order to improve or replace my own art?


texts: Creating an efficient 2D mobile game background

texts: I am working on a 2D unity mobile game and would like some advice on how to save as much MB's as possible with my background images. I can either create 15 600 x 1000 png images through an image manipulation program and import them into unity, each image is roughly 300 kB's before building the project. Or I can import a base background image that i would use multiple times, and also import a sprite sheet with scenery, and just place the sprites on the background layer of my game scene. Note, if i choose the second option there will be 30 - 100 tree sprites, along with enemy and player game objects in view of the main camera at a time. I'm not sure if this second option will bog down the game, because of all the individual sprites on the screen at once.


texts: Which is better practice in Unity? GetComponent() or making the variable public?

texts:
There are two main ways I am aware of to modify an attached component.
Say, the component attached to an object is  of type Animator and the name is animator.

So, in the script, I can write

private Animator animator;

and then call the function

animator = GetComponent<Animator>();

Or, I can define the variable as public

public Animator animator

and then, drag&drop in the Unity UI.
Which one is the better practice?


texts: Suggestions on how to achieve circular "hole" in environment

texts:
I'm working on a 2D Sidescroller and I'm wanting to achieve a object that when activated it creates a port-hole to the sprites underneath, giving the appearance of the object "cleansing" the area.

Edited image showing the desired effect

At this point I have no idea how to achieve this and am after suggestions, thanks!


texts: Playerbody is turning, but not moving in direction turned

texts:
So, I have a simple WASD script, and I've added a part so when Mouse X is moved, the playerBody (character) rotates in that direction, so, when W is pressed (to go forward) the player does not move in the direction turned, but it moves in the same direction. Although the playerBody has turned, the player still moves in the same direction.... why?
using UnityEngine;
using System.Collections;

// This script moves the character controller forward
// and sideways based on the arrow keys.
// It also jumps when pressing space.
// Make sure to attach a character controller to the same game object.
// It is recommended that you make only one call to Move or SimpleMove per frame.

public class Move : MonoBehaviour
{
    CharacterController characterController;

    public float speed = 6.0f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;
    public Transform charBody;
    private Vector3 moveDirection = Vector3.zero;

    void Start()
    {
        characterController = GetComponent<CharacterController>();
    }

    void Update()
    {
        if (characterController.isGrounded)
        {
            // We are grounded, so recalculate
            // move direction directly from axes

            moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));
            moveDirection *= speed;

            if (Input.GetButton("Jump"))
            {
                moveDirection.y = jumpSpeed;
            }
        }

        // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
        // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
        // as an acceleration (ms^-2)
        moveDirection.y -= gravity * Time.deltaTime;

        // Move the controller
        characterController.Move(moveDirection * Time.deltaTime);

        float MOUSEY = Input.GetAxis("Mouse Y") * speed * Time.deltaTime;
        float MOUSEX = Input.GetAxis("Mouse X") * speed * Time.deltaTime;

        charBody.Rotate(Vector3.up * MOUSEX);

    }
}

Thanks


texts: How to make colliders for a darts board in Unity?

texts:
I was wondering how to make a darts board in Unity?

Of course it doesn't make triangular objects, or non symmetrical boxes as far as I know, so I would make the board mesh in Blender or something like this.

But how would I be able to detect where a dart had hit the certain area? Until now I have only used box, sphere and capsule colliders


texts: Lib-GDX GWT build will not load without Flash on some browsers

texts:
I am trying to load my LibGDX application. Using Firefox without Flash on a  freshly installed Ubuntu system, it does not load.

I get this printed in the console:

SoundManager: No Flash detected. Trying HTML5-only mode. soundmanager2-jsmin.js:32:357
SoundManager V2.97a.20130512 (AS3/Flash 9) + HTML5 audio soundmanager2-jsmin.js:32:357<br/> SoundManager 2: soundManager: Fatal error: Flash is needed to play some required formats, but is not available. soundmanager2-jsmin.js:32:357
SoundManager 2 HTML5 support: mp3 = false (using flash), mp4 = false (using flash), ogg = true, opus = true, wav = true soundmanager2-jsmin.js:32:357
soundManager: No Flash response within expected time. Likely causes: Flash blocked or JS-Flash security error. soundmanager2-jsmin.js:32:357
soundManager: Waiting indefinitely for Flash (will recover if unblocked)...

And this on my screen:

I am assuming this is because of the lack of Flash and the fact that these audio formats are not supported in this version of Firefox. However, I am not using any audio in my game at all.

In my LibGDX HtmlLauncher, I have:

public GwtApplicationConfiguration getConfig () {
    GwtApplicationConfiguration config
        = new GwtApplicationConfiguration(getWindowInnerWidth(), getWindowInnerHeight());
    config.preferFlash = false;
    return config;
}

This did not fix anything. I am on the latest version of LibGDX, and the latest GWT SDK version. How do I fix this?


texts: Forcing one projectile to follow close behind an initial projectile

texts:
I'm shooting out a projectile and I want another projectile to closely follow it. I can't simply shoot out the second projectile at a slightly lesser time because the first projectile may change trajectory.

All I want is the second projectile to be closely following behind the first projectile.

My first idea was to plot the points every frame to follow the first projectile. However, as the speed of the first projectile increases, the following projectile lags behind.


texts: What are the advantages/disadvantages of using a polar coordinate system in a video game?

texts:
Would it ever be a good idea to represent an object's position as a magnitude at some angle relative to a reference point, instead of the typical x, y, z coordinates?

What sort of effect would it have on performance?

Clearly there are many disadvantages to this, such as having to convert into x, y, z coordinates when rendering, and possibly suffering from gimbal lock, but would there ever be a circumstance where it would be a better solution to use polar coordinates?


texts: Learning To Use C# In Both VisualStudio And Unity's Monodevelop Frameworks

texts:
I apologize if this has been asked and answered, but I can't find it.  I know the framework is different in MonoDevelop and Visual Studio 2010 Express.  For instance, if I want to use Write.Line, I need to change the code to Debug.Log.  Is there a source for crossover syntax?  I found this but it doesn't seem to answer the question.

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            string name;

            Console.WriteLine("Hello, what is your name?");
            name = Console.ReadLine();
            Console.WriteLine("Your name is  " + name);
            Console.ReadLine();
        }
    }
}

For instance, where would I find a resource to translate this code to MonoDevelop?  I know Unity doesn't use static void, namespace, Console.ReadLine();, etc.  Thanks for the help!


texts: HDR / Tone Mapping - choosing parameters

texts:
I implement HDR in my graphics engine (deferred rendering) based on this document: link I save a luminance in a texture (RGBA16F) this way:

const float delta = 1e-6;
vec3 color = texture(texture0, texCoord).xyz;
float luminance = dot(color, vec3(0.2125, 0.7154, 0.0721));
float logLuminance = log(delta + luminance);
fragColor = vec4(logLuminance, logLuminance, 0.0, 0.0);
// first channel stores max luminance during a minification process

Then I can calculate an average luminance and find a max luminance.

The delta = 1e-6. Is that a good choice ?

Can I calculate "a" (equation 2) dynamically to achieve better results ?


texts: How to use the Vulkan graphics backend in the Stride game engine?

texts:
What do I have to do in order to run my Stride game on the Vulkan graphics platform?

The documentation section seems to be outdated, the drop-down doesn't exist anymore:
https://doc.stride3d.net/latest/en/manual/platforms/index.html#set-the-graphics-platform


texts:
I'm learning how to program simple two-dimensional games in C++ using SFML, I've done a relatively simple pong game already I would like to ask how I could go about creating the physics for a curved edge such as one on an air hockey table Such as this:

Do I have to code a type of reflection of xVelocity/yVelocity for every single point or what? How do I even add a curved edge such as that in the first place?


texts: I made my game using libgdx which is a cross-platform framework which supports desktop, Android and html5 (using Google Web Toolkit). What could be a possible route to port my game to iOS?


texts: Networking a fast-paced game (2D) - Forced Movement - Server / Client

texts:
I started a new project, a fast-paced online game (some sort of 2D MOBA). I encountered a problem with the part of netcode about client prediction & server reconciliation.
Game Mechanics: 2D - Platformer (MOBA)
Movement: WASD (jump / left / down / right)
Abilites & Autoattack: J/K/L
Architecture: Client/server (authoritative)
My netcode is using these techniques:

Client-side prediction & server reconciliation

Server is sending position & data to the player, the player is replaying the last unprocessed inputs
Client is sending input each frame at a fixed timestep (60 times/sec) which are processed on the server-side

Other entities are interpolated
Bullets/abilities are extrapolated (Dead reckoning)

So far, this is working good on clients. My question is, how to handle some sort of forced movement?
For example, another player stuns or slows down you, on the server, you will be slowed down or stunned, but you will not know it before the packet arrives, since you are predicting the next state, it will teleport you back because your speed was changed to 0 or lower (in case of slow), it will immediately turn you back (teleport).
What is a good way to handle this technique? I was thinking about interpolating between the current position and the position on the server, but it is not working well for me.


texts: Sorting array of points in clockwise order

texts:
Is there such an algorithm to sort an array of 2D points in clockwise order?
I'm specifically dealing with right triangle in my case so only 3 points.

However I'm interested in knowing if such an algorithm exist, if not what is a simple way to return the 3 points of my triangle in clockwise order?

Edit: I am trying to compute the points clockwise relative to the centroid of the polygon, which  is convex.

Update:
This is the implementation I ended up using based on the chosen answer, it's not performance critical and only happens once in a while so it works out.

ArrayList<PVector> pointList = new ArrayList<PVector>();
pointList.add(A);
pointList.add(B);
pointList.add(C);
Collections.sort( pointList, new TriangleVectorComparator(origin) );

return pointList;

// Comparator
package triangleeditor;

import java.util.Comparator;

import processing.core.PVector;

public class TriangleVectorComparator implements Comparator<PVector>  {
    private PVector M;
    public TriangleVectorComparator(PVector origin) {
        M = origin;
    }

    public int compare(PVector o1, PVector o2) {
        double angle1 = Math.atan2(o1.y - M.y, o1.x - M.x);
        double angle2 = Math.atan2(o2.y - M.y, o2.x - M.x);

        //For counter-clockwise, just reverse the signs of the return values
        if(angle1 < angle2) return 1;
        else if (angle2 < angle1) return -1;
        return 0;
    }

}


texts: Crash due to removal of Elements like CCSprite from NSMutableArray

texts:
So, here's how it goes.

I am currently working on Cocos2d game, which consists of many Obstacles. One obstacle gets added on the screen at an interval of 10 seconds like this.

ObstacleSprite* newObstacle = [ObstacleSprite spriteWithFile:@"Obstacle.png" rect:CGRectMake(0, 0, 20, 20)];
newObstacle.position = ccp(mainPlayer1.position.x,10);
[self addChild:newObstacle];

[self.arrayForObstacles addObject:newObstacle];

Now, I insert these obstacles into the arrayForObstacles because I also want to keep checking whether the Obstacles and MainPlayer don't collide.

I check it with the help of this function.

- (void) checkCollisionWithObstacle
{
    if(mainPlayer1.playerActive)
    {
        for(int  i = 0; i < [self.arrayForObstacles count]; i++)
        {
            ObstacleSprite* newObstacle = [self.arrayForObstacles objectAtIndex:i];
            if(newObstacle != nil)
            {
                if(CGRectIntersectsRect([mainPlayer1 boundingBox], [newObstacle boundingBox]))
                {
                    mainPlayer1.livesLeft--;
                }
            }
        }
    }
}

THE ISSUE

Problem is when I get to certain score, one of the Obstacles gets deleted. Removal of Obstacles works as in First In-First Out (FIFO) mode. So, to delete obstacles, I write the following method :

- (void) keepUpdatingScore
{
    //update new score
    mainPlayer1.score+=10;
    //remove obstacle when score increases by 5k
    if(mainPlayer1.score > 5000 && mainPlayer1.score > 0)
    {
        mainPlayer1.playerActive = NO;

        if([self.arrayForObstacles count] > 0)
        {
            CCLOG(@"count is %d",[self.arrayForObstacles count]);
            ObstacleSprite* newObstacle = [self.arrayForObstacles objectAtIndex:0];
            [self.arrayForObstacles removeObjectAtIndex:0];
            [self removeChild:newObstacle cleanup:YES];

            CCLOG(@"count is %d",[self.arrayForObstacles count]);
        }
    }
    else
    {

    }
}

It crashes when score crosses 5000 mark!

UPDATE

Crash happens when it again goes to the method checkCollisionWithObstacle.

This is the THREAD Look.

THis is the line Which crashes.


texts:
I am currently trying to make a snake game with Java FX, I read several posts about it and I understand on theory how to move the snake body (for each part of the snake reference the previous one and move it to its former location) but I am facing some issues, my snake is not able to turn around properly:

I would just like it to react as a normal snake, when the head steers into a direction then the other body parts follow one by one.

In my case I created a vector class to store positions and velocity (I use velocity to be able to move all the part at the same speed and therefore be able to keep the 3 pixel gap between them).

I usually trying my best to resolve issues but this time I've spent almost 3 hours knowing the theory and groping for a proper way to do it but without any improvements.

I tested different approaches but this one seems to be the clearest and the nearest to the solution to me:

I got 2 simple classes that are Vector (only holding reference to X and Y) and Block that holds references such as Position, Velocity for the current motion, nextVelocity to anticipate steering, Previous for the previous block in the snake body.

I initialize my snake like that :

    public Snake(){
    this.head = new Block(250,250);
    for(int i = 0; i < 5; i++){
        if(i == 0){
            body.add(i, new Block(new Vector(head.getPosition().getX() - 18 , head.getPosition().getY())));
            body.get(i).setPrevious(this.head);
        }else{
            body.add(i, new Block(new Vector(body.get(i-1).getPosition().getX() - 18, body.get(i-1).getPosition().getY())));
            body.get(i).setPrevious(body.get(i-1));
        }
    }
    this.head.setPrevious(body.get(0));
}

Then there are my steer() method for the head as well as my follow() method for the other body parts.

I used the variable nextVelocity that stores the velocity of the previous part if this one is different from the current one, in this case nextVelocity is passed to velocity at the next frame to avoid that the whole body moves at the same time in the direction taken by the head (which apparently doesn't work):

public void steer(Vector velocity){
    this.velocity = velocity;
    this.position.add(velocity);
    this.shape.relocate(this.getPosition().getX(), this.getPosition().getY());
}

public void follow(Block previous){
    if(this.velocity == null) {
        this.velocity = new Vector(previous.velocity);
    }else if(this.nextVelocity != null) {
        this.velocity = new Vector(this.nextVelocity);
        this.nextVelocity = null;
    }else if(this.previous.velocity != this.velocity){
        this.nextVelocity = new Vector(this.previous.velocity);
    }
    this.position.add(this.velocity);
    this.shape.relocate(this.getPosition().getX(), this.getPosition().getY());
}

And finally my move() method handling the whole snake moves:

public void move(Vector direction){
    this.head.steer(direction);
    for(int i = 0; i < body.size(); i++){
        if(i == 0){
            body.get(i).follow(this.getHead());
        }else{
            body.get(i).follow(body.get(i-1));
        }
    }
}

If anyone could point me into the right direction or just let me know where I am mistaking it would be amazing.


texts:
Does anyone know how the particles behave in the following picture?

Let me explain,before the particles join they seem to be just simple textures of blood drops with a black border around them ,when they start to overlap the border disappears giving the illusion that its all one single blood drop.Is this some kind of shader?


texts: Use ARCore to detect marker and show information

texts:
I'm new to AR, and am trying to use Google's ARCore to build a simple AR prototype. Basically if a logo is detected, I like to place some real-time charts or text information on the screen. Similar to this demo for placing a car on a logo using other SDKs.

Am I able to do this in ARCore (with Android Studio)? Is there any samples or examples showcasing similar concept?


texts: Controls become inverted after a collision

texts:
I'm just prototyping a simple project. I'm moving a sprite on screen using the Xbox gamepad:

public override void Update(GameTime gameTime)
    {
        gamePad = GamePad.GetState(PlayerIndex.One);
        GetPlayerRotation();
        base.Velocity = new Vector2(vSpeed.X * gamePad.ThumbSticks.Left.X, -vSpeed.Y * gamePad.ThumbSticks.Left.Y);
        base.Update(gameTime);
    }

    private void GetPlayerRotation()
    {
        leftThumb = gamePad.ThumbSticks.Left;
        base.Rotation = -(float)Math.Atan2(leftThumb.Y, leftThumb.X);
    }

This works fine to move the sprite in the correct direction (Dependent on the angle of the joystick).

However, the problem is, when I try to do a collision with a simple test object that is just a sprite, with a rectangle:

        public virtual bool Collision(Entity entity1, Entity entity2)
    {
        if (entity1.Rectangle.Intersects(entity2.Rectangle))
        {
            Debug.WriteLine("Collision");
            return true;
        }
        else
            return false;
    }

            foreach (TestBlock block in blockList)
        {
            block.Update(gameTime);
            if(player.Collision(player, block))
            {
                player.vSpeed = -player.vSpeed;
            }
        }

Whilst this does work, and the speed is inverted, when the bool returns to false after the collision, the control scheme becomes inverted (I.e, pressing the thumbstick up moves the sprite down).

I was trying to achieve a simple bounce effect off the block.


texts:
I made a car game with coins and power up but i wrote a code for magnet power up but in start work fine but after i get power up magnet all coin in surface i collect but after this don`t spawn coin any more and show me this error: Picture 1. And here my code:

//Car script
//PowerUp Magnet Sector
    public bool magnetPowerUp = false;
    public float MagnetDuration;

     private void OnCollisionEnter2D(Collision2D col)
    {
        //Magnet
        if (col.gameObject.tag == "Magnet")
        {
            col.gameObject.SetActive(false);
            StartCoroutine(Magnet());
        }
     }

     IEnumerator Magnet()
    {
        magnetPowerUp = true;
        yield return new WaitForSeconds(MagnetDuration);
        magnetPowerUp = false;
    }

    //CoinScript

    using UnityEngine;
using System.Collections;

public class CoinSpaws : MonoBehaviour
{
    public carController car;
    public GameObject player;
    public GameObject[] coins;
    int coinNo;
    public float maxPos = 1.7f;
    public float delayTimer;
    float timer;

    // Use this for initialization
    void Start()
    {

        timer = delayTimer;

    }

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

        timer -= Time.deltaTime;
        if (timer <= 0)
        {

            Vector3 coinPos = new Vector3(Random.Range(-1.7f, 1.7f), transform.position.y, transform.position.z);
            coinNo = Random.Range(0, 2);
            Instantiate(coins[coinNo], coinPos, transform.rotation);
            timer = delayTimer;

        }

        if (car.magnetPowerUp)
        {
            coins = GameObject.FindGameObjectsWithTag("coin");
            foreach (var treasure in coins)
            {
                treasure.transform.position = Vector2.MoveTowards(treasure.transform.position, player.transform.position, 5.0f * Time.deltaTime);
            }
        }
    }

}


texts: Why are the sprites in my AssetBundles ending up as Texture2Ds instead of Sprites?

texts:
I packed some sprites into an AssetBundle and uploaded it to my server. The sprites are set to type Advanced, so I can check the read/write enabled box.

When my game downloads it I want to initialize a sprite:

Sprite sprite = (Sprite)Instantiate(bundle.LoadAsset("1.png"));

This is not possible because apparently the asset is not a sprite (but it is...) - it seems like, for some reason, the asset is a Texture2D object rather than a Sprite one (why?). So I have to do something like this:

Texture2D tex = ((Texture2D)Instantiate(bundle.LoadAsset("1.png")));
Sprite sprite = Sprite.Create(tex,new Rect(0,0,tex.width,tex.height));

And that's fine. But I have the feeling this is not how it's supposed to be: why is my asset a Texture2D and not a Sprite already? Why do I need to create a brand new Sprite?


texts: I want to get back into 2D games programming

texts:
I used to develop games in the late 80's / early 90's and would like to look at getting back into it these days.

I have seen online there are so many options and libraries etc, so just thought I would try asking on here to see if anyone could offer some advice/a path to take.

I only really want to do 2D games as I did many years. I have seen things like Unity and other javascript libraries and it looks a bit of a minefield.

Ideally I would like to target Android / IPhone games.

I know c#, some c++, javascript/html5

Any info greatly appreciated.

C


texts: iOS persistant storage with update function

texts:
im developing a game which has different levels and i need to store all levels and its elements (position, image, sounds,..) into a file/database. The levels will be updated so i need a function that checks online for a update and downloads a database dump and additional files.

I was planing to store all the persistent data into a SQLLite database, but not quite sure how to do the update part - to pack the database dump and the files together (in a .zip or with a xml). Can this be done any other way (as secure as possible)?

thanks!


texts:
I came across a way to create the vertices of a sphere, located here: https://gamedev.stackexchange.com/a/150293/62793
I converted this to the following C# example:
public static GraphicsMesh GenerateSphere(Device device, int numLatitudeLines, int numLongitudeLines, int radius)
        {
            // One vertex at every latitude-longitude intersection,
            // plus one for the north pole and one for the south.
            // One meridian serves as a UV seam, so we double the vertices there.
            int numVertices = (numLatitudeLines * (numLongitudeLines + 1)) + 2;

            Vector3[] positions = new Vector3[numVertices];
            Vector2[] texcoords = new Vector2[numVertices];

            // North pole.
            positions[0] = new Vector3(0, radius, 0);
            texcoords[0] = new Vector2(0, 1);

            // South pole.
            positions[numVertices - 1] = new Vector3(0, -radius, 0);
            texcoords[numVertices - 1] = new Vector2(0, 0);

            // +1.0f because there's a gap between the poles and the first parallel.
            float latitudeSpacing = 1.0f / (numLatitudeLines + 1.0f);
            float longitudeSpacing = 1.0f / numLongitudeLines;

            // start writing new vertices at position 1
            int v = 1;
            for (int latitude = 0; latitude < numLatitudeLines; latitude++)
            {
                for (int longitude = 0; longitude <= numLongitudeLines; longitude++)
                {

                    // Scale coordinates into the 0...1 texture coordinate range,
                    // with north at the top (y = 1).
                    texcoords[v] = new Vector2(
                                      longitude * longitudeSpacing,
                                      1.0f - ((latitude + 1) * latitudeSpacing)
                                   );

                    // Convert to spherical coordinates:
                    // theta is a longitude angle (around the equator) in radians.
                    // phi is a latitude angle (north or south of the equator).
                    float theta = (float)(texcoords[v].X * 2.0f * Math.PI);
                    float phi = (float)((texcoords[v].Y - 0.5f) * Math.PI);

                    // This determines the radius of the ring of this line of latitude.
                    // It's widest at the equator, and narrows as phi increases/decreases.
                    float c = (float)Math.Cos(phi);

                    // Usual formula for a vector in spherical coordinates.
                    // You can exchange x & z to wind the opposite way around the sphere.
                    positions[v] = new Vector3(
                        (float)(c * Math.Cos(theta)),
                        (float)Math.Sin(phi),
                        (float)(c * Math.Sin(theta))
                      ) * radius;

                    // Proceed to the next vertex.
                    v++;
                }
            }
            //Converting it to a Vertex
           Vertex[] vertices = new Vertex[positions.Length];
            for (int i = 0; i < positions.Length; i++)
            {
                vertices[i] = new Vertex(positions[i]);
            }
            return new GraphicsMesh(device, vertices);
        }

And it does indeed create all the vertices of a sphere; here's a picture:
My question now, is how do I take those vertices, and create triangles out of them? Or in other words, how do I link said vertices together to form triangle faces?


texts:
I see many applications which have world-clock map, and I would like to make my own to enhance some of my mobile apps. I wonder if anybody has any knowledge where to start, how to draw a curved shadow representing the dawn and the sunset on the globe. See the example:

http://aa.usno.navy.mil/imagery/earth/map?year=2012&month=6&day=19&hour=14&minute=47

I think that this curve goes up and down and creates an artic day/night etc
Perhaps there is some acceptable approximation formula without a need to load data for each our and each global parallel and meridian...


texts: How to keep text on top of openGL in a perspective projection

texts: I have a game that has a score, I found out how to render text in a ortho projection but I can find a way to mix the two, or have text stay in the same position on the screen at the same time as camera movement. Would I need to constantly change the position and depth of the text to keep it on top of everything and on the screen at the same time?


texts: How to display text for 3 seconds in pygame

texts:
I am trying to print "You Crashed" when car hits wall(or blocks) for 3 seconds and then again start game loop.

I tried using time.sleep(3) but it's not working.

def crash():
    crash_font = pygame.font.Font('freesansbold.ttf',115)
    crash_text = crash_font.render("You Crashed!",True,black)
    game_display.blit(crash_text,((display_width/4 - 100), (display_height/4 + 100)))
    pygame.display.update()

    time.sleep(3)
    game_loop()

if x > display_width - car_width or x < 0:
        crash()

When I run this it blinks "You Crashed" for fraction of second and starts game_loop()

If anyone wants to see full code http://pastie.org/10940745