texts: How to destroy a clone of an effect attached to an object?

texts:
I want to use some particle effects into a bonus object that will be destroyed upon contact with the player object. This object as its name suggests will add a certain benefit for the player for a certain amount of time. I was following a tutorial on Youtube. The code from the Tutorial worked fine but there is one problem I was not able to solve: the explosion will not be destroyed after the object is collided with player and after the script is triggered because it seems that it was cloned into the scene. The instantiation created a clone of the effect's prefab I referenced into the script.
After looking into the internet, I tried to affect the instantiation of the effect into a variable called clone and then destroyed it after the bonus is over but the problem was still present. I researched and I really did not obtain any answer.

bonus.cs
//

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

public class bonus : MonoBehaviour {

public float multiplier=2.0f;
public GameObject pickup_effect;
public float duration = 10;
private GameObject clone;

private void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player")) StartCoroutine( pickup(other));
}

IEnumerator pickup(Collider player)
{
    Debug.Log("You picked a bonus!");
    //spawn cool effect
    clone = Instantiate(pickup_effect, transform.position, transform.rotation);
    //apply effect yo the player
    // our.score_value += 10;
    player.transform.localScale *= multiplier;
    GetComponent<MeshRenderer>().enabled=false;
    GetComponent<Collider>().enabled = false;

    //wait x amount of seconds

    yield return new WaitForSeconds(duration);

    //remove the effect from theplayer
    player.transform.localScale /= multiplier;

    Destroy(gameObject);
    Destroy(clone,4f);

}

}

//

I tried disabling the "loop" option in the effect's particle system options but it gave the same results.

I disabled the "Play on Awake" option and the effect will not play at all.

The script is added directly to the object that is a simple 3D cube with MeshCollider, Mesh Renderer and Box collider.

The effect I used is a BigExplosionEffect taken from Unity Particle Pack 5.x from the Asset Store.

I would like to know what is exactly wrong? Is it probably related to the effect itself rather than the script? Or is there a far better solution?


texts: What are the technologies that makes physics engines so good for raycasting?

texts: again. This question is strictly related to this one so, what is the technology that makes physics engines suitable for raycasting? It is a particular data structure? Has it to do with the engine's internal representation of the objects? If so, how do they represent objects so to be able to make polygon-precise raycasting? Do they hold the whole information about a mesh?


texts:
Any recommendations for a good isometric game engine that is also free?

Should be possible to develop entirely using freely available tools (meaning: no Flash, and no I don't want to learn haXe...)
Works-in-a-browser is a plus, but not required.
Support for 32-bit images is required!
Good performance.
Excellent documentation.

I have looked at FIFE but it is still too unfinished, and the documentation sucks!


texts: "The Object you want to Instantiate is null" But it works, can I ignore the error?

texts:
This has never happened to me so I'm a bit confused.

GameObject someObject = Instantiate (Resources.Load ("Prefabs/Items/" + someName)) as GameObject;

This throws an error but the object is actually instantiated and everything works as intended. The error doesn't stop the program no matter how many times I reproduce this.

Can I ignore this error or is there some problem that I'm not seeing?


texts:
I am creating a game in Unity where the game is rendered while playing. The game is made in a voxel style, and has thousands upon thousands of objects rendered while playing. Of course, this causes a huge amount of lag. Therefor I need to use occlusion culling, to make sure only the objects needed are rendered.

For occlusion culling, you need to bake the area, but I'm planning on creating a huge world. So, any tips on how I could do this?


texts: Optimal solution for storing card values in a multiplayer card game

texts:
I am developing multiplayer turn based card game(Mendikot)

in JAVA.There are four players in two teams, partners sitting opposite
A standard international 52-card pack is used. The cards of each suit rank from high to low A-K-Q-J-10-9-8-7-6-5-4-3-2.
Each player gets random 13 card each.

Now I have two ways to store this data,one is to store the data using data structure as below.

private static String[] suits = { "Hearts", "Spades", "Diamonds", "Clubs"};

private static String[] ranks = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King" };

and then store each combination of "suits and ranks" for each of the four players in a separate list and then update the list after each turn to remove played card.

Secondly I can go a database solution with table like "Players","Card","Moves" etc.
where in the "Moves" tables will store cards own by each player.Which can be cleared after the game is over

I am considering this Portal as multithreaded as many players can form different rooms to play.

Please suggest me the optimal way to store the data considering the concurrent nature of the portal.


texts:
I am trying to use the LibGDX UI Project creator to create LibGDX projects, but it doesn't allow me to choose the Andorid version for the project.  This is a problem for some android features.  For example I want to hide the action bar, so I wanted to set the Theme:

Theme.Holo.Light.NoActionBar.Fullscreen

...but if I do that I get the error message

  @android:style/Theme.Holo.Light.NoActionBar.Fullscreen requires API level 13 (current min is 5).

My idea is to manually set up the projects so I can choose freely the versions and API levels.  But I think I can't choose what I want, because then LibGDX would have problems.

How can I correctly set the android version using UI Project creator?


texts: Calculating wall angle and sliding in 2D

texts:
Got a new project recently where I don't use any physics engine, but it requires some basic phyiscs. Basically it's a 2d "top-down" game type. I would like to add a smooth wall collision which feels better than those "jumping" ones. So here is how bad it looks like, I easily calulated the collision point in this way:

Added the velocity to the player's position.
Checked whether the new position is in the wall or not.
Went backwards at that vector where it "came from" until reached the first non-colliding position.

Now that I have the blue position, I would like to modify the player's vector's angle with that purple angle (I guess). Because I want the next thing to happen when the player reaches that position:

The player gets the wall's angle and walks next to it (of course only if the player still presses the key to move upwards) like in most AAA 3D games. For example TESV:Skyrim. If you are moving toward a wall or an object in a non 90° angle, then the player keeps moving but next to the wall/object.

I have already searched for solutions on Google and here aswell, but none of them fit my needs.
Would appreciate any help. Thanks!

EDIT:

Green Line: Wall (Top one, the bottom one just for help)
Purple Point: Player old position
Blue Point: Player new position (next to the wall)
Red Line: Vector between new and old position

EDIT 2:
Can't get it to work properly, at the edges of the walls the calculations fail. The player keeps teleporting, at the program freezes sometimes. (due the while cycles which are checking for the edges)


texts: What folders can be safely deleted after building UE4 from source?

texts:
What folders, if any, can be safely deleted, after building UE4 from source?
After the build, UE4 files occupy 65 GB of disk space, which is way above comfortable for me, since I only had 72 GB free.
I would like to cut the folder down to size, say at least 25 GB.
Are there any files that are not required to use the Unreal Engine with full functionality? Thanks


texts: How to make a platformer character go DOWN a 315 degree slope?

texts:
Alright, so I got this code I'm trying to write, but the player won't go down the slope, it goes down and up perfectly on the 45 degree slope, but the 315 degree one is a mess. it goes "up" the downward slope, get's stuck and some other stuff. Anyway here's the code:

//you're in a double for loop going through every tile in the map, the int's being used are x, and y

//check if the tile is a slope
if (lv.type[lv.tile[x, y]] == Tiles.SLOPE)
{
   //create a rectangle collision box
    Rectangle tileCol = new Rectangle(x * lv.tileSize, (y * lv.tileSize), lv.tileSize, lv.tileSize + 1);

    //if player collision "col" collides with "tileCol" and you haven't done this before this itteration (only happens once per full double loop)
    if (col.Intersects(tileCol) && !onSlope)
    {
        //get the angle of the tile
        float angle = lv.angle[lv.tile[x, y]];

        //get the x distance of how far away the player's right is inside the tile
        float dist = (col.X + col.Width) - tileCol.X;

        //constructs the opposite of a right triangle
        float opposite = (float)(Math.Tan(MathHelper.ToRadians(angle)) * (dist));

        if (angle < 90)
        {
            //if player's right is less then or equal to tile's right
            if (col.X + col.Width <= tileCol.X + tileCol.Width)
            {
                //place player on slope. this works properly
                pos.Y = tileCol.Y - opposite;
                //tell the program we don't wanna go through this again until the next full loop starts.
                onSlope = true;
            }
        }

        else if (angle > 90){
            if ((col.X + col.Width) >= tileCol.X)
            {
                //this is where the error is. the player goes "up" a slope that's 315 degrees, instead of down it.
                //how do I make the player go down the slope that's 315 degrees!?
                pos.Y = tileCol.Y + opposite;
                onSlope = true;
            }
        }
    }
}

currently using this code, it makes the player move in a 45 degree angle on the 315 degree blocks.

else if (angle > 90)
                            {

                                if (col.X >= tileCol.X)
                                {
                                    pos.Y = tileCol.Y + lv.tileSize + (dist * -1);

                                    onSlope = true;
                                }
                            }


texts: Melee Range trigger collider does not detect object with Player tag

texts:
In my 2D game, I have a Player which has:

a BoxCollider2D with isTrigger=false
a dynamic Rigidbody2D
a Player script

...tagged as "Player" and in the "Player" Layer.
Also I have an Enemy in the scene which has:

a BoxCollider2D with isTrigger=true
an EnemyMelee script

... tagged as "Enemy" and in the "Enemy" Layer.
The Enemy has its own collider because when to handle taking damage or changing colors when shot by the Player's bullets.
The Enemy has an empty child game object following it where it goes, called MeleeRange and it has:

a BoxCollider2D with isTrigger=true
a kinematic Rigidbody2D
an EnemyMeleeAttack script

...tagged as "MeleeRange" and in the "MeleeRange" Layer.
What I want is: When Player is inside of the MeleeRange area, the EnemyMeleeAttack script will detect this and call the Coroutine from the EnemyMelee script.
I want my Enemy to trigger its "attackMove" animation and attack my Player every 1.5 seconds. It has an exit time to the idle animation, and because the Player is still in the MeleeRange collision area, the attack will start again and return to idle again.
The problem is: MeleeRange simply cannot see the Player tag in the area. I put Debug.Log if it detects the player but nothing happened.
EnemyMeleeAttack script:
public class EnemyMeleeAttack : MonoBehaviour {
    public EnemyMelee enemyMeleeScript;

    void OnTriggerEnter2D(Collider2D coll)
    {
        if(coll.tag == "Player")
        {
        Debug.Log("MeleeRange Collision Reached!");
        enemyMeleeScript.anim.SetBool("isRunningBool", false);
        enemyMeleeScript.StartCoroutine(enemyMelee.attackStance());
        }
    }
}

EnemyMelee script:
public class EnemyMelee : Enemy {
    #region Variables
    public bool inRange;
    #endregion

    #region Attack
    public float attackTime;
    public float timeBetweenAttacks;
    #endregion

    #region Movement with AI
    public bool isRunningBool;
    public AIPath aipathScript;
    //public EnemyMeleeAttack emeleeattackScript;
    #endregion

    public override void Start()
    {
        base.Start();
        anim = gameObject.GetComponent<Animator>();
        aipathScript = gameObject.GetComponent<AIPath>();
        aipathScript.OnTargetReached();
    }

    private void FixedUpdate()
    {
        //Code for if Enemy dies, disable all functions attached to Enemy.
        if (health <= 0)
        {
            GetComponent<AIPath>().enabled = false;
            StopCoroutine(attackStance());
        }

        DamageColorUpdate();

        //Reference from A*Pathfinding for following player and running animations when following occurs.
        if (aipathScript.reachedEndOfPath == false)
        {
            anim.SetBool("isRunningBool", true);
            inRange = false;
        }
        else
        {
            anim.SetBool("isRunningBool", false);
            inRange = true;
            //StartCoroutine(attackStance());
        }
    }

    public IEnumerator attackStance()
    {
        if (Time.time >= attackTime)
        {
            anim.SetBool("isRunningBool", false);
            player.GetComponent<Player>().TakeDamage(damage);
            attackTime = Time.time + timeBetweenAttacks;
            anim.SetTrigger("attackMove");

            yield return null;
        }
    }
}


texts:
A description of my game:

When you start the game, you have a few seconds to memorize the arrangement of the grids. By the arrangement, I mean each grid is one of two colors. After the time is up, all the grids are set to the 'off' color. The player must click on the grids to toggle them and put them in their correct color assignments as they were seen before.

Okay so this is part of a game I am developing.Instead of using solid colors, I want use background images but I don't know how to edit the code to do so.
Any help would be welcome.

Dim GridOn As Color = Color.LightBlue
Dim GridOff As Color = Color.DarkBlue
Dim MaxTime As Integer = 40

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    For Each pic As Control In Me.Controls 'For every picture in form1's controls...
        If TypeOf pic Is PictureBox Then   'Then, only picks the pictureboxes, not the buttons, labels, etc.
            AddHandler pic.Click, AddressOf PictureBoxClick 'For each picturebox (grid), add an event handler (PictureBoxClick) to avoid
        End If                                              'typing 16 of them ourselves
    Next
End Sub

    Private Sub PictureBoxClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    If AllowEdit = True Then
        Dim ctrl As PictureBox = DirectCast(sender, Control)
        If ctrl.BackColor = GridOn Then
            ctrl.BackColor = GridOff 'Set the backcolor to either GridOn or GridOff
        Else : ctrl.BackColor = GridOn
        End If
    Else
        'Do not allow the user to change the colors
    End If
  End Sub


texts:
I want to make a simple game where I have some characters fighting on a plane (level). I find the trickiest part as figuring out who should do what here.

I want my terrain to have friction (so you could play on ice).

I also want fairly customizable characters.

At first I was thinking of a mediator pattern where the game gathers information about the current player state and modifies them based on that, but I do not think this offers enough flexibility.

I was thinking more along the lines of each player / character does have some logic.

The Input from the game gives it the command the player pressed, then the character would load the correct animation for this.

As for friction and whatnot, I was thinking that the world would somehow need to multiply the player's velocity vector by its coefficient of friction. Because I don't think the player needs to know about the level (and preferably the level does not know about characters)

It's in these little design aspects that I get a bit confused.

Is this a good design? What could be improved / changed / added given what I want to do?

Thanks


texts: Is it possible to program a game to resume where it left off when you quit in Unity?

texts: I have a game I'm making in Unity and now I'm stuck on saving. Is it possible to program a game to resume where it left off when you quit? Every time I search for this on Google I get nothing. Can anyone tell me if this is possible or not? And if it is how would I do it?


texts: Need to use trig to make a ship point in the right direction

texts:
I'm making a 2D spaceship-shooter game that moves in all directions, (i.e. ( -x, +x ),( -y, +y ) ).

I'm trying to make the spaceship face the direction of the movement according to a virtual joystick. The virtual joystick has it's x and y coordinates working correctly and they are normalized (ie. between -1 and +1) in both x and y.

I'm able to set the angle of the image I'm using by a call to

SetSpriteAngle(spriteNum, angle)

where the angle is in degrees. The problem I'm having is with the trigonometry involved.

I know from trig that calculating the angle is radius*cos(x), and I could be wrong on that, so I tried this:

x = GetVirtualJoystickX(1)
y = GetVirtualJoystickY(1)
r = sqrt(x*x + y*y)

angle = r * cos(x)

SetSpriteAngle(1,angle)

Problem one is, there's no account for the Y direction, so I tried:

angle = r*cos(x) + r*sin(y)

Still a problem, just not working correctly, so I tried arcsine and arccosine:

angle = r*aCos(x) + r*aSin(y)

Now the image is just flipping in what seems like a random direction, and just in case it was calculating, instead of the total angle, perhaps it was the angle from the x intercept, so I tried:

if GetVirtualJoystickX(1) > 0 and GetVirtualJoystickY(1) > 0
    //angle = angle
elseif  GetVirtualJoystickX(1) < 0 and GetVirtualJoystickY(1) > 0
    angle = angle - 180
elseif  GetVirtualJoystickX(1) < 0 and GetVirtualJoystickY(1) > 0
    angle = angle - 270
elseif  GetVirtualJoystickX(1) > 0 and GetVirtualJoystickY(1) < 0
    angle = angle - 360
else
    angle = 0
endif

Now it's only flipping as if angle is close to 0 and moving occasionally in a certain 270 degree position  I believe,

So I guess I'm going to have to admit that my trigonometry skills aren't what they used to be and ask you guys for some help, by the way sin(x) is where x is in degrees and sinr(x) is where x is in radians, so I might be missing it there too, frankly I'm just too confused to get any farther right now.

Thanks guys!


texts:
public class Main {

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Character c = new Character();
        frame.add(c);

        frame.setSize(600, 600);
        frame.setTitle("Keyboard control");
        frame.setResizable(false);
        frame.setVisible(true);
    }
}

character class

public class Character extends JPanel implements KeyListener{

   int posx = 0, posy = 0;

   public void movementX(int i) {
        posx+=i;
    }
   public void movementY(int i) {
       posy+=i;
   }

       public void paint() {
           repaint();
       }

     public void paintComponent(Graphics g) {
        super.paintComponent(g);

        this.setBackground(new Color(0, 0, 0));

        g.setColor(new Color(0, 0, 255));
        g.fillRoundRect(posx, posy, 50, 50, 4, 4);

    }

    public void keyPressed(KeyEvent e) {
        movementX(10);
        paint();
    }

    @Override
    public void keyReleased(KeyEvent e) {

    }

    @Override
    public void keyTyped(KeyEvent e) {

    }
}


texts: Implementing realistic sun reflection on a sea

texts:
I'm drawing a 3d rendered island which has a day / night cycle and a sun that rises and sets over water.

The sea is rendered with a fragment shader derived from this Blinn-Phong tutorial.

http://www.lighthouse3d.com/tutorials/glsl-tutorial/directional-lights-ii/

The sun's position is a represented by a point at its centre which moves over time to simulate a day / night cycle. When the point is over the horizon, the sea shader uses Blinn-phong and a normal map to produce a reflection.

I don't like the way it renders at the moment for a couple of reasons. The most serious issue is light reflection is calculated from a single point at the centre of the sun's disc so that the light flicks on or off in a totally abrupt fashion as the centre of the sun crosses the horizon. See the pictures for what I mean.

The second issue also evident in the picture is the light is a pin prick in the centre of the sun and the reflection on the sea is too focussed. It should spread from the whole disc not just a point in the centre. The Sun's disc btw is just a billboard.

What I want to happen is for the the light levels gradually increase as the sun rises and correspondingly decrease as it sets. I also want the light on the sea to spread from the whole disc rather than a pin point in the middle. This can't be a compute intensive change because the code is destined to run on mobile GPUs on android but it should still be pleasing.

I could potentially move the light point to the top of the sun to make the light appear more early and set later. However that might interfere with the light calculations in an adverse way (now the centre of the light is the top of the sun). Maybe I could start with the light point at the top and slowly move it to the centre as the sun rises (and back again as the sun sets) to counteract this problem. I could also calculate an intensity when the sun is low in the sky based on how much of the sun is showing and gradually increase the intensity to make the light stronger.

I could potentially have a cluster of light sources covering the centre, top, left, bottom and right but this increases complexity a lot and could still look weird.

Does anyone have comments on the feasibility of these ideas or have others ways I could achieve this?


texts: Is it a good idea to use a hash table in an ECS?

texts:
I've had an idea for optimising my ECS engine. Instead of storing components in an array, store components in a hash table as <id> => <component>.
This means that checking whether an entity has a particular component can now be done in O(1) rather than O(n). Just wondering whether there are any drawbacks to this approach?
Since I'm using a managed memory language, cache locality doesn't matter as much.


texts: Transform manipulator for Unity/Oculus Touch game like in Quill, Medium etc

texts:
I'm trying to create a script to manipulate the transform of a gameobject using the Oculus Touch just as in for instance Quill or Medium, with rotation, translation and scaling. Can somebody help me with this? My initial attempt was to focus on rotation and I got it almost working I think. Here's the code:

void Update()
{
  // On button down
  if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
  {
    originalRotation = transform.localRotation;
    originalControllerRotation =
      OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
  }

  // While button is down
  if (OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger))
  {
    var controllerRotation =
      OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);

    var rotation = originalRotation;
    rotation *= Quaternion.Inverse(originalControllerRotation);
    rotation *= controllerRotation;
    transform.localRotation = rotation;
  }
}

This kind of works but the rotation center doesn't look right. I want it to rotate around the center of the right touch controller and it looks to be rotating around the local origo of the gameobject. How do I modify the code so it rotates around the controller instead?


texts: A Quick HLSL Question (How to modify some HLSL code)

texts:
Thanks for wanting to help!

I'm trying to create a circular, repeating ring (that moves outward) on a texture.  I've achieved this, to a degree, with the following code:

float distance = length(inTex - in_ShipCenter);
float time = in_Time;

///* Simple distance/time combination */
float2 colorIndex = float2(distance - time, .3);

float4 shipColor = tex2D(BaseTexture, inTex);
float4 ringColor = tex2D(ringTexture, colorIndex);

float4 finalColor;
finalColor.rgb = (shipColor.rgb) + (ringColor.rgb);
finalColor.a = shipColor.a; // Use the base texture's alpha (transparency).

return finalColor;

This works, and works how I want it to.  The ring moves outward from the center of the texture at a steady rate, and is constrained to the edges of the base texture (i.e. it won't continue past an edge).  However, there are a few issues with it that I would like some help on, though.  They are:

By combining the color additively (when I set finalColor.rgb), it makes the resulting ring color much lighter than I want (which, is pretty much the definition of additive blending, but I don't really want additive blending in this case).
I would really like to be able to pass in the color that I want the ring to be.  Currently, I have to pass in a texture that contains the color of the ring, but I think that doing it that way is kind of wasteful and overly-cumbersome.

I know that I'm probably being an idiot over this, so I greatly appreciate the help.

Some other (possibly relevant) information:

I'm using XNA.
I'm applying this by providing it to a SpriteBatch (as an Effect).
The SpriteBatch is using BlendState.NonPremultiplied.

Thanks in advance!

EDIT: Thanks for the answers thus far, as they've helped me get a better grasp of the color issue.  However, I'm still unsure of how to pass a color in and not use a texture.  i.e. Can I create a tex2D by using a float4 instead of a texture?  Or can I make a texture from a float4 and pass the texture in to the tex2D?

DOUBLE EDIT:  Here's some example pictures:

With the effect off:

With the effect on:

With the effect on, but with the color weighting set to full:

As you can see, the color weighting makes the base texture completely black (The background is black, so it looks transparent).  You can also see the red it's supposed to be, and then the white-ish it really is when blended additively.


texts: Intersection point of two lines with given formula

texts:
I have following formula to check the intersection of two line segments:

Edge is defined like point2-point1 vector.
    bool intersects(const Line2D& line2)
            {
                float s, t;
                s = (-edge.y * (point1.x - line2.point1.x) + edge.x * (point1.y - line2.point1.y)) / (-line2.edge.x * edge.y + edge.x * line2.edge.y);
                t = (line2.edge.x * (point1.y - line2.point1.y) - line2.edge.y * (point1.x - line2.point1.x)) / (-line2.edge.x * edge.y + edge.x * line2.edge.y);

                if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
                    return true;
                }
                return false;
            }

However I´m trying to figure out how to implement the "find the point of intersection" option for this as most of the answers with the same theme are "math based". Thanks for your help.


texts: Programmatically creating a continuous scrolling background in Game Maker: Studio

texts:
I have 15 background images for a 2D horizontal scrolling shooter game and I have been wondering how to insert programmatically those background images in the first level room, as I want them to be displayed one after the other looking as they were one large background image, repeating the last four ones until the boss is defeated.

I have seen that in Game Maker: Studio only 8 background slots are available in each room, so how could I achieve doing what I need here?


texts: JS Canvas - Creating 2D Game lighting effect like Terraria

texts:
I just started working with canvas in HTML5 and with javascript. I'm pretty satisfied with my game so far: http://xenopal.dk/game-v1.1/. But I'd like to implement lighting as well in the style of Terraria or Minecraft
http://www.nerd-age.com/wp-content/uploads/2011/09/Terraria-New-Torches.png
where you can have multiple light sources, even with color, without it being like realistic shadows that gets casted by the light.

I've tried to do per-pixel lighting, but that didn't go so well since it made my whole game lag like crazy and unplayable. I might have done the per-pixel lighting wrong since I'm fairly new to creating games in canvas.

I hope that you're able to help me or maybe pass on some links to other places that might be able to help. Thank you :)

// Edit - Probably forgot to mention that it should of course be a 2D lighting. I've read somewhere that even with three.js and pixi.js I might be able to create this kind of lighting, but I have no idea on how to do it.


texts:
I'm attempting to move from oblique mapping (45 degree angles) to isometric (30 degree angles) in Tiled.

I made a test tile in Photoshop:

Made an isometric map:

But my tile appears completely distorted, and the 'isometric' map just appears as a top-down grid rotated 45 degrees:

How do I create a proper isometric scene using tiled?

Hi, in your example (here), your Tiled grid is angled down. As you can see, mine appears Top down. How do I configure this?


texts:
I'm trying to implement flowfield navigation, as described in http://grail.cs.washington.edu/projects/crowd-flows/
but I can't understand how the Density Function in Figure 4 of the paper is supposed to handle unit radius.

Has anyone ever implemented that and can provide more information?

This is the part in question:

Their algorithm seems to be using only 4 cells, pointing to the lower left of the unit, so is this some kind of kernel that needs to be applied multiple times?

Thanks.


texts: Why can't I import third-party modules I've installed in the python-ogre SDK's interpreter?

texts:
Background Information

I'm using the python-ogre SDK, located here, under Windows 7.  The SDK seems to have its own interface to the python 2.7 interpreter, judging from the fact that the generic interpreter (the one located in C:\python27) must be present in order for the SDK to function.

If the generic python 2.7 interpreter is not installed, the python-ogre interpreter complains that python27.dll is missing.

In addition, modules seem to be highly compartmentalized.  The python-ogre modules are only available under the python-ogre interpreter, and not the generic python 2.7 interpreter.  The inverse is also true.  Modules installed to the generic python installation are not available to the python-ogre SDK interpreter.

I'm not really sure what's going on here, so general clarifications would be helpful.

The Import Problem

I recently installed PyYAML and it imports successfully in the standerd python 2.7 interpreter.  However, when I try to import it from the python-ogre SDK's interpreter, I get an ImportError:  No module named yaml error.

What gives?

This may be a general python issue, but it does seem to relate directly to the python-ogre SDK.

As usual, I will be happy to provide additional information upon request.
Any advice or help would be greatly appreciated!

OK GOT IT!

I just did a sys.path.append('C:\Python27\lib\site-packages').  Apparently all 3rd party modules are installed to this directory.

Is this safe to do?  Do I risk creating conflicts between python-ogre and regular ol' python?


texts:
I know that there are several open-source/free 2D game engines out there; I am just wondering about commercial ones (if any). The idea of wanting of looking for a commercial engine is for support and continual updates.

Off the bat I know that there is DarkBasic, Blitz Basic and Torque 2D. What's else are there?

What I am looking for (technical wise):

Sprites and Animation capability
GUI (menus, dialogs, simple controls)
Math helper for usual math operations -vectors, rotation, turning an entity to face another...
Entity management
Particles
Serialization of game data
Level design tools
Deployment tools

And support wise

Documentation
Examples and Tutorials
Continual update
Support through forum/emails/private channels


texts: How do I test if a circle and concave polygon intersect?

texts:
I have a polygon (sometimes convex, but often concave), and a bunch of circles with different radii. How can I find out if a circle is intersecting/overlapping with the polygon?

I could split my concave polygon into convex pieces. Would that help?


texts:
I have a plane which contain a WebCamTexture and a button to capture the image

script to capture the image

void CaptureAndSave () {
    Debug.Log (Camera_panel_script.webCameraTexture);
    Texture2D snap = new Texture2D(Camera_panel_script.webCameraTexture.width, Camera_panel_script.webCameraTexture.height);
    snap.SetPixels(Camera_panel_script.webCameraTexture.GetPixels());
    snap.Apply();
    Debug.Log (Application.persistentDataPath.ToString());
    System.IO.File.WriteAllBytes(
        Application.persistentDataPath+"/my_image.png",
        snap.EncodeToPNG()
        );
}

this is the resulted image

how can i modify my code to add the image logo to my resulted picture ? so the captured image would look like this :

EDIT:
i tried to do a code to change the pixels in the of the webcameTexture like this :

public static Texture2D CombineTextures(GameObject obj, Texture2D background, Texture2D TodrawLogo)
{
    Vector3 v = obj.transform.position;// obj is TodrawLogo gameobject
    int width = TodrawLogo.width;
    int height = TodrawLogo.height;
    for (int x =(int)v.x; x < width; x++){
        background.SetPixel(x,(int)v.y,TodrawLogo.GetPixel(x,(int)v.y));
    }
    background.Apply();
    return background;
}

but i am out of luck also


texts: How are vertices determined complex geometries in an ever changing game state

texts:
For example say you wanted to draw a 3D cube you can define an array of hard coded vertices using float3, here is an example. http://msdn.microsoft.com/en-us/library/windows/desktop/jj552949.aspx

But you obviously can't define by hand large and complex changing geometry vertices such as you would have in a game. So I am trying to understand the mechanics behind how these vertices are loaded/interpreted into the Engine.

Another example, you could create a model in say Maya and export this vertex data to say an XML file, then load up the model using GL/DX. So Maya is doing all the work determining the vertex data. You could do this for terrain also, any vertex geometry.

However a game state is constantly updating, it is not static, the camera is constantly moving with user input. So what is the mechanics behind constantly re-evaluating new vertex data depending on user input.


texts: How to calcolate moving vector of object by its rotation degress in 2d

texts:
i have object in game which is rotating when i move my joystick , now i need to   calculate its movement vector by its rotation
the object always moving forward and controlled by the joystick , the joystick is only setting its direction by degree .
here is the image which illustrate the scene .
i need some formula of the vector which the object will move .


texts:
I am trying to translate/move a triangle 0.3 to the right. When I run the code below, it moves the triangle, but part of it is cut off, like it is in a set box (shown in images below).

Code to move and draw the triangle:
  Gl.glPushMatrix();
  Gl.glColor3f(c.R, c.G, c.B);
  Gl.glBegin(Gl.GL_TRIANGLES);
  Gl.glVertex2f(0.5f+x, 1.0f+y);
  Gl.glVertex2f(0.0f+x, 0.0f+y);
  Gl.glVertex2f(1.0f+x, 0.0f+y);
  Gl.glEnd();
  Gl.glFlush();
  Gl.glPopMatrix();

x is 0.3f, y is 0 I tried glTranslatef(), but that did the same thing.
The triangle at 0, 0, 0

The triangle at 0.3f, 0, 0


texts:
I want to make a coloring app in unity. I don't need flood filling. THe player will select a color and click the shape to fill that color. The app will have designs as shown below:

Here the problem is, design has to be empty with black outline. One way would be to create textures using the jpg of each shape. However, there are thousands of shapes and each can be colored in about 7 colors. So, i will have to create 7 textures for each shape.Is there any way to create model with black outline so that only inner color can be changed?


texts:
MSDN specifies (link) that when using triangleadj type of input to the GS, it should provide me with 6 vertices in specific order: 1st vertex of the triangle processed, vertex of an adjacent triangle, 2nd vertex of the triangle processed, another vertex of an adjacent triangle and so on... So if I wanted to create a pass-through shader (i.e. output the same triangle I got on input and nothing else) I should return vertices 0, 2 and 4. Is that correct?

Well, apparently it isn't because I did just that and when I ran my app the vertices were flickering (like changing positions/disappearing/showing again or sth like that). But when I instead output vertices 0, 1 and 2 the app rendered the mesh correctly.

I could provide some code but it seems like the problem is in the input vertices order, not the code itself.

So what order do input vertices to the GS come in?


texts:
I try to implement ray-box intersection algorithm given by the following code. However, I'm not really understand for two cases as shown in the following figures. Firstly, when the box is located in front of the ray, why the code give intersection even though the end point of the ray doesn't intersect with the box. A similar observation can be seen from the second case when the ray origin is located inside the box. Is this nature of the algorithm? How can solve this problem?

// r.dir is unit direction vector of ray
dirfrac.x = 1.0f / r.dir.x;
dirfrac.y = 1.0f / r.dir.y;

// lb is the corner of AABB with minimal coordinates - left bottom, rt is maximal corner
// r.org is origin of ray
float t1 = (lb.x - r.org.x)*dirfrac.x;
float t2 = (rt.x - r.org.x)*dirfrac.x;
float t3 = (lb.y - r.org.y)*dirfrac.y;
float t4 = (rt.y - r.org.y)*dirfrac.y;

float tmin = max(max(min(t1, t2), min(t3, t4)));
float tmax = min(min(max(t1, t2), max(t3, t4)));

// if tmax < 0, ray (line) is intersecting AABB, but the whole AABB is behind us
if (tmax < 0)
{
    t = tmax;
    return false;
}

// if tmin > tmax, ray doesn't intersect AABB
if (tmin > tmax)
{
    t = tmax;
    return false;
}

// if tmin < 0 then the ray origin is inside of the AABB and tmin is behind the start of the ray so tmax is the first intersection
if(tmin < 0) {
  t = tmax;
} else {
  t = tmin;
}
return true;


texts: How to draw an image on canvas without html

texts:
I'm trying to add a sprite to the canvas of my game. However, I don't want to use an image tag. However, I haven't found a way to do this no matter how hard I searched. Something like:

var image = 'sample.jpg'
draw(image)


texts: In their official tutorials it is said that to draw graphics on screen, i have to use RenderWindow instead of Window. But when i write sf:: RenderWindow window, error pops up saying that there is no RenderWindow in sf::  . I  copy-pasted the code but it still does not works. What could possibly be the  reason behind this ?


texts:
Using the following to turn a spaceship in a C# FarseerPhysics simulation.

 var turnPower = _Inventory.EngineTurnPower * time;
 body.ApplyTorque(turnPower);

If the user keeps holding in the turn key the ship will go into a superspeed turn och chaos were it eventually is impossible to tell which direction it is facing.

What would be some good way of limiting the turn speed that the user can cause, without limiting the simulation itself.


texts: How can I let the user choose his own background image?

texts: Dear Stackoferflow Fourm I would like to have a function in my Android Game Programming that allows the user to choose his own background image (I would like to let the user change the plane image) Unfortunately I have no idea how I could do that. If someone knows how to do it I would be very happy.!


texts: What is a good length for looping background music in a Tower Defense game?

texts:
We know that the soundtrack is important and expensive for an indie's budget.
I requested a looping background track for for my Tower Defense game, where zombie/monsters attack the player. So, for the entire level, the player will keep hearing this music.
In this kind of game, is 30 seconds good for a looping music track, or I need to increase it?


texts: Interpolating between positions unfeasible at 30 frames per second?

texts:
I am working on a 3D platformer in Unity and I am targeting Android devices. The game consists of a lot of objects smoothly interpolating from the bottom of the screen to the top.

This whole time I've been testing my game at 60 fps and the performance was quite good. However, when I tested the game at 30 fps, the interpolation of the objects was no longer smooth.

I initially thought that I have way too many objects in my scene and this might be affecting the interpolating performance. So I created a new project which only has the interpolation stuff and object pooling (you can download it here). But even then, the interpolation wasn't smooth at 30 fps. Here's the code I'm using for interpolating the object:

void FixedUpdate()
{
   rb.MovePosition(transform.position + transform.up * Time.fixedDeltaTime * speed);
}

I'm using the object's Rigidbody to interpolate it. I've already set the rigidbody to "Interpolate" and I turned on "isKinematic".

I first thought that the interpolation isn't smooth since I'm using Rigidbody. So I ditched the rigidbody and used transform.Translate instead. But even then the interpolation wasn't smooth. Next I tried Vector3.Lerp. Nope. That didn't work either. The stutter was still there. I even tried Vector3.MoveTowards. That didn't work. The interpolating was still laggy. I even tried turning on GPU instancing for the objects being interpolated (since they all use the same material). That didn't do it either.

Next I started playing around with the fixed timestep (in the Time settings). I thought that maybe if I set the timestep to 0.033, then the objects will interpolate smoothly at 30 fps. But that didn't work either.

I think it's really bizarre that a simple interpolation performs so poorly at 30 fps on an Android device. If the interpolation is only for a short distance, then you don't always notice the stutter. But like I said, in my game the objects have to interpolate from the bottom of the screen all the way to the top. In this case, you can clearly see the laggy movement during interpolation.

Is it possible that long distance interpolation is simply unfeasible for Android devices at 30 fps? How do so many Android game developers manage to achieve good performance at 30 fps? Feel free to download the new project I mentioned which only has the interpolation stuff and the object pooling. It is available here. It's a very simple projects. It only has the prefab that should be interpolated, the material for the prefab, the script for interpolating the prefab, the spawning and object pooling system (for spawning the prefab), and the script for setting frame rate to 30. That's it.

Below a gif of the objects' interpolation. It's not as shaky in reality (since I had to use a bad screen recorder and compress the gif) but it's still pretty close to how the objects move at 30 fps.


texts:
As I was working on some art for my project, I decided that I should add an outline around some objects.

So I tried my method; which was to create a second image slightly larger than the first, make it all black, then draw it with a slight offset to the original image.

For a little bit, everything was fine and dandy, but then I went and tried it on some different shaped images, and everything went downhill.

Here are the images for the first outline, the good one:

And then when I tried something irregular, this happened:

So hopefully you can see my problem, but if the image is to small, then I can try describe it. Ok, when I draw an "outline" around my image, it turns out normal. Yet, when I try draw an outline around my more irregular image, the outline doesn't reach all the edges of the image. Only some are visible.

What I want is to be able to have the outline all the way around the edges of the image, like the first image.

Is there a better way to draw outlines? Or is this the best way, if so, what am I doing wrong to get this outcome?

Any help is appreciated,

Thanks!


texts:
I have an flickering problem with rendering tiles.
    Rendering Method.

int tileSize = TileManager.tileSize;

    for(int y = 0 ; y < mapHeight ; y++){
        for(int x = 0 ; x < mapWidth ; x++){
            TileManager.tiles[tileIDs[y][x]].render(x * tileSize + xOffset, y * tileSize + yOffset, g);
        }
    }

TileManager

public static Tile[] tiles = new Tile[256];

public static final int tileSize = 32;

public static void loadTiles(String path){

    Image tileSet = GeneralUtils.getImage(path);

    int row = (int)Math.floor(tileSet.getWidth() / tileSize);
    int col = (int)Math.floor(tileSet.getHeight() / tileSize);

    for(int y = 0 ; y < col ; y++){
        for(int x = 0 ; x < row ; x++){
            tiles[x + y * row] = new Tile(tileSet.getSubImage(x * tileSize, y * tileSize, tileSize, tileSize));
        }
    }

}

Finally Tile

private Image tileImage;

public Tile(Image tileImage){
    this.tileImage = tileImage;
}

public void render(int xPix, int yPix, Graphics g){
    g.drawImage(tileImage, xPix, yPix);
}

If i render like this there is no flickering. I couldnt understand why ?

img = new Image("Res/blabla.png");
----------------------------------------------------
int tileSize = TileManager.tileSize;

    for(int y = 0 ; y < mapHeight ; y++){
        for(int x = 0 ; x < mapWidth ; x++){
            g.drawImage(img, x * tileSize + xOffset, y * tileSize + yOffset);
        }
    }


texts: How do I pause and resume a game in ActionScript 2?

texts:
I'm making a game where the player must avoid random falling objects. I dont know how to implement pausing. I've been stuck on this for 2 days!

I tried using gotoAndPlay and such, but the objects continue to run in the background. When I resume the game, they're still falling and it seems like the frame resets and loads new random falling objects.

(Simple English would be appreciated; English isn't my mother tongue.)


texts:
My experience with Unity in not that in depth. But I am wondering if it possible in unity to split what is being rendered across multiple screens.

It's hard to explain, so here is an image:

So while the middle screen is fine to render, I want to spread the image all around the player. That is both to the side and, the bottom and top of the player.

Is such a thing possible? Has anyone ever done something similar?


texts: Colliders for moving inside a spaceship when the whole spaceship is made of a single mesh (in Unity)

texts:
I've begun to study a unity engine in one purpose: I have a great multi player game idea!
The main essence: In space there are two (or even more) huge spaceships with crew consisted of players (all real humans). Ships are very powerful dreadnoughts with a lot of features (radar system, many weapons, missals, refinery factory, gravity generator, indoor light system, shields generators, engines and so on), but all systems are broken at the beginning of the game. Crew should decide, which systems are more important in battle and repair it. They should extract materials from asteroids and revive their spaceship. Then, they should locate second ship, and try to destroy it. Whose spaceship will be in a whole skin during one minute after destroying another, will be the winners. If there are more then two spaceships, surviving crew from destroyed ship can move to another alive ship.

I've already draw detailed 3d model of spaceship, but I faced with a problem during importing model to unity. The problem with mesh collider. Players should get into a ship and walking in it, HOW can I do that? I can't use non-convex mesh collider in unity 5, and I cannot put one collider to another. It would solve the problem, if I draw ship piece by piece, but not as entire. But ship is really complex, to assembly it from prepared parts take really long time and ship will be messily. Is there another way to solve my problem?


texts: Is it appropriate approach to simulate shadowing via occlusion culling of lights?

texts:
I have own deferred renderer and a scene with both closed and open spaces. I want to prevent light passing though solid objects. For example, there can be a house with a lot of point lights inside. I want to prevent lighting of objects outside the house, but it is not always possible to adjust appropriate falloff distance.
And it seems that creating shadows maps for each of them will require a lot of time and memory. So I could try another approach - create some set of bounding primitives for each light source and perform occlusion culling with all of them to determine whether some space is affected by the source.
Is this method appropriate for the described situation or maybe is there any other methods to simulate shadowing?


texts: Unity editor, horizontal line in inspector

texts: How to draw a horizontal line in the inspector like on the reference image? Kind of separation line.


texts: How is money made from Steam Trading Card Farming Generators?

texts:
in this SidAlpha Video, SidAlpha talks about how Valve may be doing something that could stop or interrupt Steam Trading Card Farming Generators by preventing them from generating keys.

This got me thinking. from my understanding you get Trading Cards either playing the game which gets you only so many, the rest you then need to create booster packs with Gems or buy them from the marketplace with your own funds. but what i don't get is

1) the name for this practice implies using Steam Trading Cards to make money, however i can't see how "developers" can make money as,

you have to originally own the card you're selling on the market place
when it's brought it goes to your wallet which you can't transfer Steam wallet fund off Steam

and i wouldn't think Valve would allow "developers" to create any number of trading cards for their games at will then sell them because this is obviously very easily abused

2) in the video SidAlpha mentions that reducing/blocking Key generation may have an impact to those who use Steam Trading Card Farming Generators, noting that a certain user base is actually worried it. but i'm not sure how key generation fits in to the scam.

So my question is how is money made from Steam Trading Card Farming Generators? and how do Steam Keys fit in to this?


texts:
I'm building a game server for a turn-based RPG game, where the players control their characters through a web interface ( think kind of like a Jackbox Party Pack game, where there's a screen that shows shared info and the players devices let them send their inputs ).

I've got most of the foundation set up: clients can connect, create a game, additional players can join the game using a code, the game server is doing real basic game loop stuff.

I'm starting to work on the actual input & tick handling. Because this is in Go, there's a goroutine that handles the input which is separate from the goroutine that handles the game updating every tick. I've basically got a for loop with multiple selects ( so that a new client doesn't prevent a server tick from getting processed ), kind of like this:

func (g *Game )listen(){
    ticker := time.NewTicker(time.Millisecond * 200)

    for {
        select {
        case nc := <-g.newClients:
            g.acceptNewClient(nc)

        case lc := <-g.closingClients:
            g.unregisterClient(lc)

        default:
        }

        select {
        case u := <-g.output:
            if len(g.players) > 0 {
                for c := range g.players {
                    c.out <- u
                }
            }

        case in := <-g.input:
            g.handleInput(in)

        default:
        }

        select {
        case t := <-ticker.C:
            g.tick(t)

        default:
        }
    }
}

What I'm trying to figure out right now is the best way to handle that player input and how it should update the game state.

For example, the first state the game starts in is character select. All players are able to select one of four character classes, but can't double up ( ie, can't have two fighters -- first come first serve ). The VIP also has the option to start the game, which will randomly assign classes to players who haven't selected, and create AI players if there are fewer than 4 players.

Should the input handler be able to directly modify the game state -- ie, when it gets a message from player 1 saying they want to select a fighter, it modifies the game state to do the right thing, or should it be throwing messages into a queue? For example saying "hey, the VIP says to start the game" or "player 2 selected fighter" and then the tick handler does the appropriate thing?


texts:
I need to patch an animation during LateUpdate.

I'm rotating the "chest" bone according to the mouse delta. This is to mimic aiming a pistol.

During this aiming, the "neck" bone should stay relatively still.
As changing the chest bone's location rotation yaw automatically changes the "neck" bone's local yaw rotation, I store the chest bone's rotation BEFORE I apply a new rotation to it. Then I calculate the difference between the old and the new rotation.
Then I apply this rotation yaw difference to the neck bone.

The inspector gives me nice values to work with.
When I inspect the rotation values by script, I get reprensations that I can not easily work with.

Here is an example:

While the Inspector shows "15.4", the localEulerAngle shows "344.6".

If I use "344.6", the neck rotation goes Berzerk of course.

How should this be solved?

For completeness, here is the entire void:

private void pHandle_LateUpdate_Aim()
{
    Vector3 nOldChestRotation = Chest.localRotation.eulerAngles;

    // Fade old input before capturing new, so we don't dull the freshest data.
    float yawBlend = Mathf.Pow(1.0f - Aim_yawInputFalloff, referenceFramerate * Time.deltaTime);
    // A Lerp toward zero is just the same as a multiplication by the blend factor.
    Chest_yawRate *= yawBlend;
    // Accelerate by mouse movement over the past frame.
    // (May need adjustment for display resolution).
    Chest_yawRate += Input.GetAxis("Mouse X");

    float yawDelta = Chest_yawSpeed * Chest_yawRate * Time.deltaTime;
    float offCenterYaw = Chest_currentYaw - Chest_yawCenter;

    float fDesiredChestYaw = Chest_currentYaw + yawDelta;
    float fHeroRotation = 0f;

    if (fDesiredChestYaw > Chest_rotateRange)
    {
        fHeroRotation = fDesiredChestYaw - Chest_rotateRange;
        //we don't rotate the chest beyond the allowed "Chest_rotateRange", so simply act like the user didn't move the mouse
        Chest_yawRate = 0;
        yawDelta = Chest_yawSpeed * Chest_yawRate * Time.deltaTime;
    }
    else if (fDesiredChestYaw < -Chest_rotateRange)
    {
        fHeroRotation = (Chest_rotateRange + fDesiredChestYaw);
        Chest_yawRate = 0;
        yawDelta = Chest_yawSpeed * Chest_yawRate * Time.deltaTime;
    }

    // If we're moving away from the center, slow down as we approach the edge.
    if (yawDelta * offCenterYaw > 0)
    {
        float extremityYaw = offCenterYaw / Aim_yawMaxRange;
        yawDelta *= 1.0f - extremityYaw * extremityYaw;
    }

    this.transform.Rotate(0, fHeroRotation, 0);

    // Ensure we never overshoot the allowed range.
    Chest_currentYaw = Mathf.Clamp(Chest_currentYaw + yawDelta,
                              Chest_yawCenter - Aim_yawMaxRange,
                              Chest_yawCenter + Aim_yawMaxRange);

    Vector3 nNewChestRotation = new Vector3(Chest.localEulerAngles.x, Chest_currentYaw, Chest.localEulerAngles.z);
    Chest.localRotation = Quaternion.Euler(nNewChestRotation);

    float fChestRotationDifference = nNewChestRotation.y - nOldChestRotation.y;

    //the neck should not rotate with the chest. So I first counter-rotate it against the new chest rotation, then rotate it a little towards the chest rotation
    Neck.transform.localRotation = Quaternion.Euler(0, Aim_NeckYaw - fChestRotationDifference + (fChestRotationDifference * 0.5f), 0);

}


texts: MMORPG Design Question: Best idea for adding PvP(PlayerVsPlayer) in open world MMO?

texts:
Brief Explanation of game: Time Travel, one map, open world MMO called ChronoCraft. If you'd like to know more about the game, you're welcome to check out our twitter where we post some of our development: https://twitter.com/Chrono_Craft

Here are the ideas so far:

1- Safe Zones

Pros: People in major towns are safe and can fight when they leave the safety of the town
Cons: When dealing with NPC's and Quests(Non-instance ones) outside of town, someone can kill you as you are talking to them

2-PvP Zones

Pros: Instead, areas of the map where PvP is possible is limited to the "wilderness" or dangerous areas(Anything that doesnt have Quest-able NPCs)
Cons: Significantly reduces the area of allowable PvP areas

3-PvP Toggle

Pros: This allows players to turn on PvP mode in settings where only other PvP enabled players can fight eachother outside of Safe Zones
(We would make it so if you are hit, you cant turn off PvP mode until a certain time to prevent people escaping death)
Cons: Ambushing is limited, because only the people who are ready to fight will have it enabled

4-Separate servers

Pros: Having a PvE server and a PvP server. Which makes it so the player decides what gameplay he wants.
Cons: Players cant bring items or money between servers so they may have to start from scratch if they change their mind on what type of server they like playing.(This is to protect the player economy from taking all the resources from one server and bringing them to another server)

5-Time Specific

Pros: When night falls, then PvP is enabled for everywhere outside a Safe Zone
Cons: For players wanting to avoid PvP they will be forced to stay in towns half the time which might get boring unless they do fun stuff like running a shop or restaurant.

6-Special Days

Pros: When there is lighting and rain, PvP is enabled which will happen every few minecraft days in the game. Allowing PvPers to fight outside of safe zones. And a HUD display will make this clear.
Cons: Players wanting to avoid PvP will have to stay in town during the inclement weather, which they might not enjoy.

7-Level Specific

Pros: Only players with a similar skill level will be able to fight eachother. So new players dont have to worry about pros slaughtering them early on.
Cons: It would be hard to fight along friends unless you're the same skill level. "John help me kill this guy"-"Sorry cant, he is too low skill for me"

8-Arenas

Pros: Confines the fight to specific spot like a colosseum
Cons: Nearly impossible to wage huge fights like 100v100
(Colosseum will make it into the game at some point, but should it be the only PvP option)

9-PvP Everywhere
Pros: Either (A)Players can figure out their own police/protection system or (B) NPC guards in major towns spawn and nearly guarantee the death of a killer in the town.
Cons: Has alot of potential to be annoying if players dont want to get killed in the middle of business in towns. Might also turn away less PvP focused players.

-What do you think is the best?

-Can I mitigate the cons for the one you choose?

-Is there a better idea entirely?


texts: Has Silverlight got a future in the online Game world?

texts:
We have spent several months planning, testing and developing a new game. We have been trialing a host of Platforms (Java Applet, Desktop Via XNA, Flash etc) and Silverlight was pretty much our prefered choice.

However, the more we get into the game the more problems we face, mainly down to the communication with a server. HTTP Polling is slow and in-efficent yet the socket functionality that is now available in SL4 is only really useful for a Intranet enviroment - Unless we are missing something.

Anyone have any opinions or experiance with this and the future of SL for Online Browser based games.


texts: Why is my text is too large even when scaled to .05f in libGDX?

texts:
I'm trying to scale down my fonts as my game objects are also small.

I'd like to scale them down the same way as my sprites. However, if I scale them below .05, the font disappears!

My attempt at small, smooth text above an orange grid:

The code:

private void initTestObjects() {
        textures = new TextureAtlas(Gdx.files.internal("data/atlas.atlas"));//i am not using atlas params(for now -.-, I cut from texture..)

        //text texture and bitmapfont
        texturesText = new Texture(Gdx.files.internal("data/fonts_0.png"), true);
        texturesText.setFilter(Texture.TextureFilter.MipMapLinearNearest, Texture.TextureFilter.Linear);
        bitmapFonts = new BitmapFont(Gdx.files.internal("data/fonts.fnt"), new TextureRegion(texturesText), false);
        bitmapFonts.setScale(.1f);

        //grid texture and sprite
        TextureAtlas.AtlasRegion grid = textures.findRegion("grid");
        gridSprite = new Sprite(grid);
        gridSprite.setSize(SIZE, SIZE);//4x4
        gridSprite.setOrigin(gridSprite.getWidth() / 2, gridSprite.getHeight() / 2);
        gridSprite.setPosition(0 - gridSprite.getOriginX(), 0 - gridSprite.getOriginY());

        //players' textures
        o = textures.findRegion("o");
        x = textures.findRegion("x");

        line = textures.findRegion("line");
    }

What am I doing wrong?


texts: Where can I find a free dictionary of words?

texts:
Hi
I'm writing a game where the player has to connect a group of letters to form words. Something like bookworm but it will be very different I hope.

The point of the question is that I need to build a dictionary of words.

I made a simple java program that crawls the web and  extracts words, but a lot of trash is mixed with the good words and it's impossible to clean it. I'm talking about 100,000 words.

Is there any dictionary available that can be freely used or anybody has an idea of how to build one?

Thanks!


texts: Precision loss when transforming from cartesian to isometric

texts:
My goal is to display a tile map in isometric projection. This tile map has 25 tiles across and 25 tiles down. Each tile is 32x32. See below for how I'm accomplishing this.

World Space

World Space to Screen Space Rotation (45 degrees)

Using a 2D rotation matrix, I use the following:

double rotation = Math.PI / 4;
double rotatedX = ((tileWorldX * Math.Cos(rotation)) - ((tileWorldY * Math.Sin(rotation)));
double rotatedY = ((tileWorldX * Math.Sin(rotation)) + (tileWorldY * Math.Cos(rotation)));

World Space to Screen Space Scale (Y-axis reduced by 50%)

Here I simply scale down the Y value by a factor of 0.5.

Problem

And it works, kind of. There are some tiny 1px-2px gaps between some of the tiles when rendering. I think there's some precision loss somewhere, or I'm not understanding how to get these tiles to fit together perfectly. I'm not truncating or converting my values to non-decimal types until I absolutely have to (when I pass to the render method, which only takes integers). I'm not sure how to guarantee pixel perfect rendering precision when I'm rotating and scaling on a level of higher precision. Any advice? Do I need to supply for information?


texts: How do I apply a force using the object direction and speed?

texts: I have a 3D object moving and I need to be able to apply forces to it such as gravity. In 2D, I would simply store its movement in dx and dy, but since this is in 3D, I am using a Vector3D direction and a float speed. How can I determine how much to rotate the direction and change the speed when by using something like applyForce(Vector3D force)?


texts:
I'm writing a 2D rigid body simulator. The objects being simulated are convex polygons. My question involves how to decide on the "point" of collision, so that when I apply a response force, I can also calculate torque.

In 2D, the popular method of narrowphase collision detection seems to be the Separating Axis Theorem. However, while this gives you the "are they colliding?" as well as "by how much?", it does NOT give you a reference point (that I'm aware of) at which to apply the response force (and thus calculate torque)*.

The other method (which also interests me more, because it's what's used in 3D, which would be the logical next step) is to calculate the Minkowski difference of the two polygons, and decide that they're colliding if (0,0) is contained in the resulting polygon. But, how do you use this to decide the relative point at which to apply the response force? My hypothesis is that, since each face of this difference effectively corresponds to a face of one of the polygons, the separation distance is the shortest distance from (0,0) to the MD, and you apply this to the corresponding face on the polygon.

As a bonus, how does one do this in 3D?

*As I'm writing this, I just realized that, when using SAT, I could just keep track of which points are overlapping, and apply the force at the "average" of those points. But I would have to decide on which of the several non-separating axes to perform this little trick...


texts:
I have strange problem with drawing skybox texture on Mac. On iPhone everything is going fine. I have tried to change near and far planes value with no success.

It is a skybox of six textures, and for every texture I set this:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

What could be the problem?

Screenshot:

EDIT:

I have tried to set background color to red, to ensure if it is bleeding through the texture

I have also tried to change coords of the texture to this:

float err_corr = 0.5 / TEXTURE_SIZE;

GLfloat vertices[24] = {
        -1.0f - err_corr, -1.0f - err_corr,  1.0f + err_corr,
    1.0f + err_corr, -1.0f - err_corr,  1.0f + err_corr,
    -1.0f - err_corr,  1.0f + err_corr,  1.0f + err_corr,
    1.0f + err_corr,  1.0f + err_corr,  1.0f + err_corr,
    -1.0f - err_corr, -1.0f - err_corr, -1.0f - err_corr,
    1.0f + err_corr, -1.0f - err_corr, -1.0f - err_corr,
    -1.0f - err_corr,  1.0f + err_corr, -1.0f - err_corr,
    1.0f + err_corr,  1.0f + err_corr, -1.0f - err_corr,
    };

And the box is drawn in this order:
GLubyte indices[14] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1};

SOLUTION:

The solution is to set GL_CLAMP_TO_EDGE for the cubemap itself!

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


texts:
I am looking for a good physics engine to use with an Ogre game I'm writing.

I would prefer for it to be free, open source, mature, simple to use, easy to learn, and flexible.

I'm currently thinking of using either Newton, Bullet or ODE.

What are the general pros/cons of each?


texts:
I'm trying to make the player loose one heart then cool down for a second after being hit. For an example

if(a.overlaps(b)) {
p.health--;
}

would lower the health while being touched. In my old game I used a thread algorithm to wait a second, but that took a while. Besides doing some kind of complicated timer method, what can I do to keep to the player hit one at a time?


texts: AI Behaviour design pattern which handles lots of diverse behaviours and mechanics?

texts:
I'm working on an 2D overhead topdown game in Unity3D and I want the enemies to have lots of diverse behaviours.

How should I design the architecture with this in mind?

For example I want:

A simple walking monster, which can move on walkable tilemaps, attack the player on sight.
A spider like creature, which jumps from wall tile to wall tile, and approaches the player in this manner.
I want a snail which walks on a route, and makes a trail (ie by flagging the tiles) behind itself, apart from this, it's unresponsive (like doesn't care if the player attacks itself)
A werewolf, which can smell the player from X tile away. (Like there is a walkable path to the player)
50 more unique behaviours...

Needless to say, I'm not talking about how to implement this, but how could I design a system which will be robust enough for this many behaviours, not really error-prone, low amount of code duplication, etc.

Thanks in advance!


texts: How to make good combinations of xp tables and xp rewards?

texts:
Is there a known step by step (automatable) to define mean xp reward formula/table to bases specific challenges rewards (generically, not only defeating enemies) and total xp table that set character level progression speed? Sounds complicated.
For example, if a character defeats about
\$LevelUpEnemies(Lv) ≈ 120/max(1,6−Lv)!\ +\ 60∗clamp(0,Lv−5,3)\$
enemies like self then character grows up, initial level is 1 and final level is 10 (like WCIII),  characters has about Hp≈(8+2*Lv)², Atk≈(4+Lv)² and Def≈4+Lv, no more data and a attack damage is
\$Damage ≈ Attack_{Attacker}*\sqrt{ Attack_{Attacker} }/( \sqrt{ Attack_{Attacker} }+Defense_{Target} )\$.
How can I calculate the (fair) rewards base formula per level and the total xp table to do this?

Notes:

How can I calculate ==> the step by step text teaching or the algorithm
Fair ==> preferably proportional to the difficulty (if not, nearly, well-reasoned)

In addition, I see big xp tables with a lot of rounded digits with no beat missing, looks closely handwritten (just not). Is there a method or algorithm that besides builds the data also (perhaps) rounds to maximum digits with no kink?


texts: Multiple Input.GetKeyDown happens in low frame rate

texts:
There is a code that needs to be invoke each time user pressed specific button in my game. So I used Input.GetKeyDown to achieve that, but some reason, that code invokes multiple times even I keep pressing the button.

After some tests, I figured out this happens a lot when the game has low frame late. In a very laggy moment, GetKeyDown returns true very many times.

void Update() {
    if(Input.GetKeyDown(KeyCode.RightArrow)) {
        print("Pressed");
    }
}

I saw a similar issue in here but couldn't find any related information.
https://forum.unity.com/threads/problems-with-input-at-low-framerates.16828/

My game is a very input sensitive game, so my code when the user each time pressed a specific button always invoke when they pressed.

I checked my keyboard is something wrong, but there was no problem with my keyboard.

Why does this happen? According to the Unity doc, it said:

  Returns true during the frame the user starts pressing down the key identified by name

If I used wrong way, then how do I check each time user pressed a button?

Using Unity 2019.1.0f2.


texts: Prototyping a puzzle game for solvability of levels

texts:
I am in the prototyping phase of making a puzzle game for iOS. The basic premise of what the player has to do is get from point A to point B by navigating through a maze like setup, while moving blocks out of the way, and avoiding enemies. This is my first approach to a game like this so I am wondering how others have made sure that the levels they create are solvable.

For example take the classic Unblock game where you have to move the red block off the game board by moving the other non red block pieces out of the way. It gets difficult because they are all in a tight space with not much movement to be had.

Has does the creator know that the arrangement of puzzle pieces are placed in a way that makes it possible to solve the puzzle? Do they start with paper prototypes and work from a solvable end state backwards to make the initial game board layouts?


texts: Calculating vertex normals in OpenGL C++

texts:
Does anyone knows a simple solution for calculating vertex normals? I've been looking for this on the internet but i cant find a simple solution, for example, if I have some vertices like this:

GLfloat vertices[] =
{
 0.5f,  0.5f, 0.0f,  // Top Right
 0.5f, -0.5f, 0.0f,  // Bottom Right
-0.5f, -0.5f, 0.0f,  // Bottom Left
-0.5f,  0.5f, 0.0f   // Top Left
};


texts: Scrolling though objects then creating a new instace of this object

texts:
In my game when pressing the right mouse button you will place an object on the ground. all objects have the same super class (GameObject).
I have a field called selected and will be equal to one certain gameobject at a time.
when clicking the right mouse button it checks whats the instance of selected and that how it determines which object to place on the ground. code exapmle:
t is the "slot" for which the object will go to.

if (selected instanceof MapleTree) {
    t = new MapleTree(game,highLight);
} else if (selected instanceof OakTree) {
        t = new OakTree(game,highLight);
}

Now it has to be a "new" instance of the object. Eventually my game will have hundreds of GameObjects and I don't want to have a huge if else statement. How would I make it so it scrolls though the possible kinds of objects and if its the correct type then create a new instance of it...?

When pressing E it will switch the type of selected and is an if else statement as well. How would I do it for this too? here is a code example:

if (selected instanceof MapleTree) {
        selected = new OakTree(game);
} else if (selected instanceof OakTree) {
    selected = new MapleTree(game);
}


texts:
By culling, I mean, only rendering what is currently seen by the camera. In my game, nothing is tile based. Each object has a center point and that is where it is on the screen. The camera is simulated by doing glTranslatef before drawing anything on that layer.

Here are the constraints:

I have 6 layers. Each of these is an array of IRenderableEntity. Each layer has a scalar that it multiplies the camera position by to simulate Parallax Scrolling. Within these arrays, the object itself could be static or dynamic.

I'm not concerned with collision detection since Box2D takes care of this.

How can I only render what I see on the screen in a logerithmic manner (not n^2)

Thanks


texts: Unity, OnMouseOver blocked by another gameobject with a collider in front of it

texts:
I have two gameobjects, both with 2D colliders.

One of them can be behind the other, and because of this its OnMouseOver can be blocked from firing as the GameObject in front blocks it from triggering.

What is a way around this? I really like the ease of using OnMouseOver, and would rather not use raycastAll.

Asked this question on SO, maybe it should be asked here.


texts: Generating Unique Identifiers for Procedural Item Generation

texts:
I have been writing all the necessary code for procedurally generated items within my game. The database mechanism that I have built supports new items at runtime, such as when a player opens a chest. Everything works fine, but I realized a fatal flaw with the way that I generate the "unique" item identifiers. I generate items using a Prefix, such as Fiery, an item type, such as Claymore, and a suffix, such as of Greater Shadow.

I generate the database Identifier using the format of:

Proc_ + Prefix + Type + Suffix + Iteration

As an actual example, the procedural item "Fiery Claymore of Greater Shadow" would then become:

Proc_FCOGS_01

All seems well right? This looks like it could work quite nicely. However, I then realized that I can easily receive identifier clashes. Or as an example: "Freezing Claymore of Greater Striking" would also be created as:

Proc_FCOGS_01

And that's where the problem arises. Because I went through all my affixes, located here and found that a few more of my chosen affixes could also lead to clashing within the database, despite the generated item not actually being the same as the one that is already entered. The routine that I am using to generate these identifiers is as follows:

        public string CreateIdentifier(string prefix, string itemType, string suffix)
        {
            if (!String.IsNullOrEmpty(prefix) && !String.IsNullOrEmpty(itemType) && !String.IsNullOrEmpty(suffix))
            {
                string input = prefix + " " + itemType + " " + suffix;
                string[] segments = input.Split(' ');
                StringBuilder builder = new StringBuilder(segments.Length + 5);
                builder.Append("Proc_");
                for (int i = 0; i < segments.Length; i++)
                {
                    builder.Append(Char.ToUpper(segments[i][0]));
                }
                return builder.ToString();
            }
            return null;
        }

After all of this, I can really only see two options:

Scrap my current Unique Identifier routine and think of another one.
If a collision exists within the Database, simply iterate the generated identifier ending number by 1, check again, and if necessary, iterate the the ending number by 1 again until an unused identifier is found.

As for number 1, that's why I'm here showing you all this. I need ideas about how I can do this in a way that will result in zero clashes unless the item is actually the same thing as previously generated.

And as for number 2, I would really prefer not doing this. I feel as though having fifteen or more database entries of Proc_FGSOTE plus the unique iteration, to be a little silly. Why have fifteen database entries of the same item? Although, I guess that would indeed be putting the iteration value to use...it's just not what I had intended it to be used for and seems like a terrible waste of resources. I really feel as though a better routine is the way to go.

Does anyone know of a better way that I can be generating unique identifiers?

Edit:

Sorry, I fogot to mention that I don't want to use the entire item name as an identifier, even if it's compressed to trim out all the spaces, mainly because the identifiers are still going to be way too long. This seems like an arbitrary limitation, I know, it's just one that I wanted to enforce so that way the Database could be loaded/parsed faster later down the road.


texts: What is causing my 3rd person camera to lose rotation on the z axis?

texts:
I've been working on a 3rd person camera on unity for a couple weeks, but I've pretty much hit a wall, specifically to do with my camera's rotation. When I rotate it on its x and y axis it won't have a problem, but when it gets to the z axis (180 degree's on the x axis), it loses the ability to rotate at all. This is the code I've been using:

void Start()
{
    //controlls camera relevent to player position
    offset = new Vector3(Player.position.x - 3.0f, Player.position.y + 2.0f, 0);
    offset = transform.position - Player.position;
    localtoworldY = transform.TransformPoint(Vector3.left);

}

void Update()
{
    //need to give proper rotation of the camera around the player
    offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offset;
    offset = Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * turnSpeed, localtoworldY) * offset;
    transform.rotation = Quaternion.LookRotation(offset, Vector3.up);

    transform.position = Player.position + offset;
    transform.LookAt(Player.position);

    print(transform.rotation);

    // If the y axis go to 6.4 positive, it should stop but not stop working, same as if the camera hits a mesh or terrain.

    // If the camera changes in any direction regardless of x or y axis,player should be able to move relative to
    // the direction that the player is pressing (IE when the player press left, the Homicida malorum will move left regardless of
    // the angle of the camera).

}

}
Any advice or an explanation as to why this is happening would be much appreciated.


texts: FPS games: don't they have unrealistic one-eyed view? What are the causes?

texts:
I have played many fps games, and noticed that the camera perspective is similar to the 'one eyed view' of the surroundings. It does not feel like bilinear. :/

Is it because of the single flat view of the screen? Or is it the problem that can be fixed by some research?

PS: If you want, try to roam around with only one eye open.


texts: How are realistic 3D faces created and animated in video games?

texts:
I'm interested in being able to create realistic faces and facial expressions for the 3D characters of a game I'm working on. Think something similar to the dialog scenes in games like Mass Effect.

Unfortunately I'm not sure where to begin. I'm sure the faces/animations are created through 3D Modeling software, but otherwise I am lost.

Do facial animations use the same "bones" that normal body animation uses?

Is there any preferred 3D software for realistic faces and animations? Is there a preferred format to export these faces and animations in?


texts: In Unity shaders, how is IN.worldRefl calculated?

texts: I want to know how the world reflection vector in shaders is calculated so that I can manipulate it, but there is no documentation on what it does or how Unity calculates it. How is the reflection vector calculated and exactly what does it do?


texts: Compile cocos2d-x Windows games without Visual Studio

texts:
I want to use cocos2d-x to make a Windows game. I used the cocos console:

cocos compile -p WIN32

And apparently it needs Visual Studio.

Is there an alternative to build the Windows game without Visual Studio? Anything more lightweight? I am hesitant to use Visual Studio because I actually work on many different machines and they all have somewhat limited memory.

Any other smaller IDE would do. Or even better, some sort of command line tool.


texts: Asset Library Class or passing Asset's through constructors

texts:
I am at the point of designing UI-Logic and I was wondering what a good way to pass asset information to these objects would be.

What I was trying as of yet was passing assets to the objects representing UI-elements through their constructors, leading to code where I pass between 1 to 10 assets (like "button idle" "button being hovered" and "button active" etc.) to the objects or having to create "metaclasses" that define the "look and feel" of these objects that need to be passed to the ui-elements to handle the rendering.

A way I thought of handling this in a "dirty" way was to create a singleton "asset database" that is globally accessible. As every button need's it's own callback function on click it can also get it's own rendering function from where the button can pick it's assets from the accessible assets.

What is a common way to handle this?


texts: How do I generate a random curve for landscape (like Worms)?

texts:
Possible Duplicate:
  How do I generate terrain like that of Scorched Earth?
  How can I generate Worms-style terrain?

I must build random curve line for the 2D Game on the BitMap (like in Worms, from the side).

Teacher said that I should do it using Terrain Generation through recourcy
(I work in Delphi 7).
I understand the main principle, but I don't know how to introduce it as code.

All measurements according to the screen resolution.


texts:
I'm trying to work out how to snap shapes together the player may move around on a canvas.

As the square approaches the other object, I want to pull that shape in (given a certain proximity) and have it snap perfectly along that objects edge.

Rules:

Only if the edges are parallel to one another
If a child square (being dragged) is half the size of the parent square (being approached), then the midpoint of the parent square edge can determine if the child snaps either to the left/right/up/down

Has anyone done anything like this? I'm using c# and unity. Cheers.


texts:
I've working on a voxel like game like Minecraft, but I'm not sure how I should handle alpha.  I've got the world split into chunks and I render each chunk, I have things like leaves which have alpha which is either on or off, but if you look through them you can only see other chunks which have already been rendered, here's a picture because I can't explain it.

http://i.imgur.com/EIRLa.png

It also works with leaves from the same chunk, for example if I'm looking through them from one direction to another then I can see the other leaves through the leaves, but if I'm looking the other way I get the same effect.


texts: How do I successfully implement Google Mobile Ads and Google Play Services into my Unity arcade game?

texts:
I have been trying for like a month now to properly implement Google Play Services and Google Mobile Ads into my Unity Android Game. I have had success in getting Google Play Services to work but when I added Google Mobile Ads at first it didn't work. I just didn't see any ads pop up. Now when I build my app it won't open it just crashes. Not exactly sure what I did.
I have configured all the services correctly according to my knowledge and I'm am just using code from the documentation for the ads.
Heres that code:

public static AdManager Instance { set; get; }

public string bannerId;
public string videoId;
public string deviceId;
BannerView bannerView;
InterstitialAd interstitial;

private void Start ()
{
    Instance = this;
    DontDestroyOnLoad(gameObject);
    interstitial = new InterstitialAd(videoId);
    AdRequest request = new AdRequest.Builder().AddTestDevice(deviceId).Build();
    // Load the banner with the request.
    interstitial.LoadAd(request);
}

public void ShowInterstitial()
{
    if (interstitial.IsLoaded())
        interstitial.Show();
}

I am using the correct ad Ids, I double checked that. I don't know what else to do.
I can provide any other information you may need upon request.

Anyone with experience with this would be super helpful! Thanks!


texts:
I am working on an IA (in Python) for small board game, and I need to do a lot of pathfinding per round in order to find the best move I can do (minmax implementation).

My problem is that even if the board is small (9*9), I am able to run it (only) approx. 10000 per second, and I don't know how to speed it. Do you have some advise?

def shortest_path(self, start, goal):
    elements = []
    heapq.heappush(elements, (0, start))

    came_from = {}
    cost_so_far = {}
    came_from[start] = None
    cost_so_far[start] = 0
    current = None
    while len(elements) > 0:
        current = heapq.heappop(elements)[1]
        if goal.is_on_goal(current):
            break
        for next in self.edges[current].neighbors:
            new_cost = cost_so_far[current] + 1
            if next not in cost_so_far or new_cost < cost_so_far[next]:
                cost_so_far[next] = new_cost
                lowest_priority = new_cost + goal.heuristic(next)
                heapq.heappush(elements, (lowest_priority, next))
                came_from[next] = current
    way = []
    if goal.is_on_goal(current):
        reverse_edge = current
        while reverse_edge in came_from:
            way.insert(0, reverse_edge)
            reverse_edge = came_from.get(reverse_edge, None)
    return way


texts: Unable to get object to rotate to looked position?

texts:
I'm trying to get an object to smoothly rotate towards a clicked point in my terrain.

However, my code only yields jittery movements in the other direction.

Any help will be greatly appreciated.

using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour {

    public float rotationSpeed = 5.0f;

    private Quaternion _lookRotation;
    private Vector3 _direction;

    // Use this for initialization
    void Start () {

    }

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

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Ground")
                {

                    Vector3 looker = new Vector3(hit.point.x, hit.point.y, 0); //get x and y point from ray cast.

                    _direction = (looker - transform.position).normalized;

                    _lookRotation = Quaternion.LookRotation(_direction);

                    transform.rotation = Quaternion.Slerp(transform.rotation, _lookRotation, Time.deltaTime * rotationSpeed);

                }
            }
          }

    }
}


texts:
I have a tile which is 512x256 pixels and I'm trying to render it in an isometric fashion.

I have this helper function:

Pos cartToIso(Pos p) {
    xa := p.x - p.y;
    ya := (p.x + p.y) / 2;
    return new Pos(xa, ya);
}

And to render I do this:

// note this is smaller than the image since
// it's being scaled down
const tileWidth = 256;
const tileHeight = tileWidth / 2;

for (int y = 0; y < 32; y++) {
    for (int x = 0; x < 32; x++) {
        int ya = y * tileWidth;
        int xa = x * tileHeight;
        Pos p = cartToIso(xa, ya);

        drawImage(grassTile, p.x, p.y, tileWidth, tileHeight);
    }
}

This nearly works but there is a big black gap around the tiles. It's fixed when
I change the rendering to this:

// note this is smaller than the image since
// it's being scaled down
const tileWidth = 256;
const tileHeight = tileWidth / 2;

for (int y = 0; y < 32; y++) {
    for (int x = 0; x < 32; x++) {
        int ya = y * tileHeight; // <- here!
        int xa = x * tileHeight;
        Pos p = cartToIso(xa, ya);

        drawImage(grassTile, p.x, p.y, tileWidth, tileHeight);
    }
}

But why? This seems to be counter-intuitive compared to what the
isometric 2d tutorials I have read have said.

Is there a flaw to my rendering logic?


texts: Balancing upgraded units vs. non-upgraded ones

texts:
The essence of this question is basically this: consider a strategy, RTS or a tower defence game, where you have the choice to build a new unit or to upgrade an existing one. The upgraded unit is definitely worth more than a non-upgraded one, but by how much?

In designing a upgrade path, how do I design it such that

Upgrading is worth the time and effort
However, upgrading doesn't becomes too über that the player forgo building new units?

For example, in Defence Grid, a glance at a number shows that two Level 1 Gun turrets do less damage output than a Level 2 Gun turret; however there are advantages to having 2 towers over 1 (say, you need to cover two different paths).


texts: 2D collision > rectangles can glitch into each other

texts:
I have implemented a simple rectangle based collsion detection where you can "slide" around the edges on diagonal movement.
Works fine but the thing is, it is somehow possible that e.g. the player (rectangle) glitches into the one of a collision object. It seems, that it appears only when the player "slides" around the corners.
I suspect that if the player walks around the corners that the movement direction (Vector2) cuts off the corner and at some point glitches into the collision rectangle.

I hope I've explained the problem somehow understandable?

The code looks like this:

The UpdateCall recieves the playerMovement from the keyboard input

public void UpdatePlayer(GameTime gameTime, Vector2 playerMovement)
{
    //...
    playerMovement = CalculatePlayerMovement(Vector2.Normalize(playerMovement) * movementspeed);
    if (playerMovement.Length() != 0)
        MoveBy(playerMovement);
    //...
}

The CalculatePlayerMovement-Method checks world bounds, collision objects and so on. Depending on what side the collsion happens, the x- or y-movement will be zeroed.

private Vector2 CalculatePlayerMovement(Vector2 movement)
{
    Rectangle destRect = new Rectangle(BoundingBox.X + (int)movement.X, BoundingBox.Y + (int)movement.Y, Width, Height);
    Vector2 returnValue = movement;
    //...
    foreach (Rectangle r in TileMap.collisionObjects)
    {
         if (destRect.Intersects(r))
         {
             string collsionSide = GetCollisionSide(destRect, r);
             if (collsionSide == "top" || collsionSide == "bottom")
                 returnValue.Y = 0;
             if (collsionSide == "left" || collsionSide == "right")
                 returnValue.X = 0;
         }
     }
    //...
}

Finally the check itself. I took this part from HERE since I was not sure what the best way would be.

private string GetCollisionSide(Rectangle destRect, Rectangle r)
{
    float w = (destRect.Width + r.Width) / 2;
    float h = (destRect.Height + r.Height) / 2;
    float dx = destRect.Center.X - r.Center.X;
    float dy = destRect.Center.Y - r.Center.Y;

    if (Math.Abs(dx) <= w && Math.Abs(dy) <= h)
    {
        float wy = w * dy;
        float hx = h * dx;

        if (wy > hx)
        {
           if (wy > -hx)
                return "top";
            else
                return "right";
        }
        else if (wy < hx)
        {
            if (wy > -hx)
                return "left";
            else
                return "bottom";
        }
    }
    return "";
}

I am not sure where the problem is, but it is probably something I don't see myself.


texts: Score system for "little bit more complex" snake game

texts:
I have created snake game.
I can't think of good score system so that is is fair.

There is only one highscore list for all modes.

Player can choose any size of board
- Let's call that param "Board area", it is defined in cells. One snake segment takes one cell.

Player can choose any speed of snake
- Speed, in cells per second

I don't know how to calculate it so that score is fair for all players.

Firstly I thought of this:
score = length * speed
But is is not fair for players that reach end of board (nearly no free spaces to go, careful planing is needed to survive).

Then I thought that I need somehow award players that can survive for long in small amount of free place. The new formula looks like that:
score = (length/board size) * (length * speed)
But I still don't like it.

My score should reward players for:
Longest snake, tight turning and planning (bigger multiplier when board is full), and speed at which they are playing.


texts:
I have this weird animation bug in Unity that I believe is how Unity handles the frame. I dont know how to show the image so I'll do my best to explain it. So I put a bunch of 2D sprites in a sequential order right and I made a timer in my code to play animation whenever. The weird thing is that it does complete the whole animation but then it goes back to the first frame and ends it. I tried changing the timer to every number possible but it just does the same thing or repeats the animation twice when I increase my timer.

Here's the code :

using UnityEngine;
using System.Collections;

public class PlayerAttack : MonoBehaviour {

private bool attacking = false;//Switches for all attac combo
private bool attacking2 = false;
private bool attacking3 = false;

//attack 1 stats
public float attackTimer = 0f;
public float attackCD = .3f;

public Collider2D attackTrigger;//Referring to our attack collider

Animator anim;

// Use this for initialization
void Start () {
    anim = GetComponent<Animator> ();
    attackTrigger.enabled = false;//Disable our collider at start
}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown ("space") && !attacking)
    {
        attacking = true;//We are attacking
        attackTimer = attackCD;//assign variables

        attackTrigger.enabled = true;//Enabled our trigger collider
    }

    //If we are attacking
    if (attacking) {
        //Check if our timer is greater than zero
        if(attackTimer > 0){
            attackTimer -= Time.deltaTime;//Decrease our timer
        }else
        {
            attacking = false;//We arent attacking anymore
            attackTrigger.enabled = false;
        }
    }
    anim.SetBool ("Attack", attacking);
 }
}


texts:
I tried calling the event Set Destination, simply to make an impression on the game screen:

I did not succeed. I modified the 3 options displayed on the right (consume input / execute when paused / override parent binding), but nothing has changed the result.

Neither change the button that calls the event (from the right to the left or even the middle button).

I created a new input (example):

And I was able to make the impression normally:

Why can not I call the Set Destination?

I need to know a way to send a warning/signal (get reference) when this event is performed.


texts: Ray-Triangle Intersection Detection using Barycentric Coordinates

texts:
I am attempting to convert the algorithm from http://www.cbloom.com/3d/techdocs/fast_ray_tri.txt to java code, but my solution does not function correctly.

The only intentional change I made was for the second point, my method accepts a unit vector instead of the other end of the line segment.

For now, all collision calculations are done in this one method (nothing is pre-calculated).

Any suggestions as to what I may have done wrong?

//collision with barycentric coordinates
boolean checkCollision(Vector3f rayStart, Vector3f rayDirection){

    Vector3f normal=new Vector3f().cross(new Vector3f(point1).sub(point0), new Vector3f(point2).sub(point0)).normalize();

    planeOffset=-normal.dot(point0);

    Vector3f
    edge1 = new Vector3f(point1).sub(point0),
    edge2 = new Vector3f(point2).sub(point1),
    edgePerp1 = new Vector3f().cross(normal, edge1),
    edgePerp2 = new Vector3f().cross(normal, edge2);

    float edgePlaneDist1 = edgePerp1.dot(point0),
                edgePlaneDist2 = edgePerp2.dot(point1);

    {
        float distance1=edgePerp1.dot(point2)-edgePlaneDist1;
        float distance2=edgePerp2.dot(point0)-edgePlaneDist2;

        edgePlaneDist1/=distance1;
        edgePlaneDist2/=distance2;

        edgePerp1.scale(1/distance1);
        edgePerp2.scale(1/distance2);
    }

    //point-plane distance
    float dFm=normal.dot(rayStart)-planeOffset;

    Vector3f rayEnd=new Vector3f(rayStart).add(new Vector3f(rayDirection).scale(30));

    float dTo=normal.dot(rayEnd)-planeOffset;

    float denom=dTo-dFm;

    Vector3f temp=new Vector3f(rayStart).scale(dTo).add(rayEnd.scale(dFm));

    float uTimesDenom = edgePerp1.dot(temp) - edgePlaneDist1 * denom;

    if ( uTimesDenom < 0 || uTimesDenom > denom )
    {
        // off triangle
        return false;
    }

    float vTimesDenom = edgePerp2.dot(temp) - edgePlaneDist2 * denom;

    if ( vTimesDenom < 0 || (uTimesDenom+vTimesDenom) > denom )
    {
        // off triangle
        return false;
    }

    return true;