texts: Objective-C Moving UIView along a curved path

texts:
I'm not sure if I am approaching this the correct way. In my app, when a user touches the screen I capture the point and create an arc from a fixed point to that touch point. I then want to move a UIView along that arc.

Here's my code:

ViewController.m

//method to "shoot" object - KIP_Projectile creates the arc, KIP_Character creates the object I want to move along the arc

...

//get arc for trajectory
    KIP_Projectile* vThisProjectile = [[KIP_Projectile alloc] initWithFrame:CGRectMake(51.0, fatElvisCenterPoint-30.0, touchPoint.x, 60.0)];
    vThisProjectile.backgroundColor = [UIColor clearColor];
    [self.view addSubview:vThisProjectile];

...

 KIP_Character* thisChar = [[KIP_Character alloc] initWithFrame:CGRectMake(51, objCenterPoint-5, imgThisChar.size.width, imgThisChar.size.height)];
    thisChar.backgroundColor = [UIColor clearColor];
    thisChar.charID = charID;
    thisChar.charType = 2;
    thisChar.strCharType = @"Projectile";
    thisChar.imgMyImage = imgThisChar;
    thisChar.myArc = vThisProjectile;
    [thisChar buildImage];
    [thisChar traceArc];

in KIP_Projectile I build the arc using this code:

- (CGMutablePathRef) createArcPathFromBottomOfRect : (CGRect) rect : (CGFloat) arcHeight {

    CGRect arcRect = CGRectMake(rect.origin.x, rect.origin.y + rect.size.height - arcHeight, rect.size.width, arcHeight);

    CGFloat arcRadius = (arcRect.size.height/2) + (pow(arcRect.size.width, 2) / (8*arcRect.size.height));
    CGPoint arcCenter = CGPointMake(arcRect.origin.x + arcRect.size.width/2, arcRect.origin.y + arcRadius);

    CGFloat angle = acos(arcRect.size.width / (2*arcRadius));
    CGFloat startAngle = radians(180) + angle;
    CGFloat endAngle = radians(360) - angle;

    CGMutablePathRef path = CGPathCreateMutable();
    CGPathAddArc(path, NULL, arcCenter.x, arcCenter.y, arcRadius, startAngle, endAngle, 0);

    return path;

}

- (void)drawRect:(CGRect)rect {

    CGContextRef currentContext = UIGraphicsGetCurrentContext();

    _myArcPath = [self createArcPathFromBottomOfRect:self.bounds:30.0];

    CGContextSetLineWidth(currentContext, 1);
    CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
    CGContextSetStrokeColor(currentContext, red);
    CGContextAddPath(currentContext, _myArcPath);
    CGContextStrokePath(currentContext);

}

Works fine. The arc is displayed with a red stroke on the screen.

In KIP_Character, which has been passed it's relevant arc, I am using this code but getting no results.

- (void) traceArc {

    CGMutablePathRef myArc = _myArc.myArcPath;

    // Set up path movement
    CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.calculationMode = kCAAnimationPaced;
    pathAnimation.fillMode = kCAFillModeForwards;
    pathAnimation.removedOnCompletion = NO;
    pathAnimation.path = myArc;
    CGPathRelease(myArc);

    [self.layer addAnimation:pathAnimation forKey:@"savingAnimation"];

}

Any help here would be appreciated.


texts: How can I create a walking zone logic for my player?

texts:
First I will show a screenshot and explain the logic I think of and what I'm trying to do :

In the diagram the circle is the player the big rectangle is the zone area for increase/decrease speed movement of the player and the small black rectangle is the target.
What I'm trying to do is to add some rules for this case.
I'm controlling the player in third person movement with the keys WSAD and the mouse to rotate around looking around. This is the player structure screenshot in the Hierarchy :

There are few rules I'm trying to set for the player in this specific situation in the game and I want to make it generic so I can add the rules or create this behaviour in any place in the game when I need to.
The idea is when the player is getting inside the green zone rectangle facing the target make the player slow down to stop smooth. The green zone is the distance from the target to start slow down only if the player is facing the target.
If I rotate the player back facing away from the target in the green zone at any time increase the player speed back to normal speed.
The idea is that if in the green zone I rotate the player at any time and move hi he will decrease/increase the movement speed. Facing target decrease slowly to stop facing away from target increase the speed slowly to normal.


texts:
Well, guys. I'm in a Game Design class at school. Before you ask "WHY ARE YOU USING 3.1 INSTEAD OF 4" -- I would like to point out that C# 2008, and .NET framework 3 is NOT my preferred environment, nor is Blender 2.49.

I have gotten a pretty decent grip on Blender so far, I think. At least, for what I've figured out how to do. ( Applying textures, exporting to .fbx, and bone-weights ).

Now, I've seen various mentions of using "Skinned Models" in xna 4.0, and I've noticed that 3.1 has no such distinction, so I assume anything you do in 4 with skinned models means alternative methods in 3.1. I have also found nearly NO documentation on 3.1. All of them seem to have actually been updated to cover 4.0 ( Seriously, since when do people update their outdated tutorials? ;_; )

I'm asking around to see if there's any way to play animations stored in .fbx files ( if so, how to do it ), so that I don't waste my time understanding the animations and what not in Blender. ( Or better yet, is there something else that I SHOULD be doing instead? )

If it's not achievable, then I can obviously just use a bunch of constants or some work-around system to apply bone transformations, but it would be really nice if I didn't need to do that.

Some other things -
I've noticed that ALL models I load seem to have semi-transparent textures. Can anybody offer an immediate explanation for this? To see what I'm talking about, here's a video.

Also, could somebody give me advice as far as loading an environment and multiple models?
I think I would use the same camera and projection matrix, and then simply give a new "World" matrix to all of the items, but for some reason, I don't think that's quite right. I read somewhere that the purpose of the Matrix type was to avoid storing position information for every individual model, and store it collectively instead. ( Which, makes sense, really. Especially when some games probably load a gajillion models x3 Vector3's. That could add up fairly quickly, I'm sure. )

I know this is fairly generic / vague, but since I haven't written any code with bugs, I can't exactly ask specific questions, I guess.

If you have a resource that is still rele


texts: World coordinates on vertical grid game for different aspect ratios (Unity)

texts:
new to game development and unity so hopefully someone can help.

I want to make a 2D portrait mobile game that will have a grid of constant size where units can move on in Unity.

This should support different aspect ratios. To do that I was thinking to cut sections at the top and bottom of the screen for smaller aspect ratios.

Additionally, I would like the coordinate system to be natural to the grid, so coordinate (0,0) would be the bottom left tile in the grid, (1,0) would be the tile to the right of that,... To illustrate this concept I drew something quickly:

I tried with a script that resizes the size of the orthographic camera to fit the content horizontally. Problem I had with that is that I couldn't get a good coordinate system on the grid after the camera gets resized depending on the aspect ratio since the number of horizontal world units varies depending on the aspect ratio.

Any thoughts on what would be the best way to do this? Thanks!


texts:
I'm having trouble binding tiles with Rect. I've successfully bound other objects (such as the player, trees, etc) in my game with rectangles but I'm unable to do the same with the tiles and I don't know where I'm going wrong. Here's my tile class:

public class Tile {
    private float x, y;
    private int type;
    private static int VelX;
    private static int tileSpeed = -200;
    private static Rect tileRect;
    public Bitmap tileImage;

    public Tile (float x, float y, int typeInt) {
        this.x = x * 50;
        this.y = y * 50;
        type = typeInt;
        tileRect = new Rect();

        if (type == 2) {
            tileImage = Assets.grass;
        } else if (type == 1) {
            tileImage = Assets.dirt;
        }
    }

    public void update(float delta) {
        x += VelX * delta;
        tileRect.set((int) x, (int) y, (int) x + 50, (int) y + 50);
    }

    public static void accel() {
        VelX = tileSpeed;
    }

    public static void stop() {
        VelX = 0;
    }

    public float getX() {
        return x;
    }

    public float getY() {
        return y;
    }

    public int getType() {
        return type;
    }

    public static Rect getTileRect() {
        return tileRect;
    }

    public Bitmap getTileImage() {
        return tileImage;
    }
}


texts: Update movement actor with collisions in 2D game

texts:
I have the algorithm for moving an actor.
The actor has:

4 states: Stay, Move, Jump, Fall and direction vector x,y.
The direction vector can be -1.f and 1.f or 0.f in both directions.
Boolean value onGround.
currentJumpVelocity
startJumpVelocity

Algorithm:

if (direction.x != 0.f) {
    // move X
    // check collision X by direction = true
    //// move to difference
}

if (onGround == true) {
    // check collision down == false
    //// state = state == State::Jump ? State::Jump : State::Fall
    //// direction.y = state == State::Jump ? -1.f : 1.f
    //// currentJumpVelocoity -= state == State::Jump ? deltaTime*startJumpVelocity : currentJumpVelocity
    //// onGround = false
}

if (state == State::Jump) {
    // doJump -> when press Space currentJumpVelocity sets from startJumpVelocity
    // check collision up
    //// move to difference
    //// state = Fall
    //// direction.y = 1.f
    //currentJumpVelocity -= state == State::Jump ? deltaTime*startJumpVelocity : currentJumpVelocity
}
else if (state == State::Fall) {
    // doFall
    // check collision down
    //// move to difference
    //// state = direction.x != 0.f ? State::Move : State::Stay
    //// onGround = true;
    //// direction.y = 0.f
    //// currentJumpVelocity = 0.f
}

Is this correct algorithm?


texts: How to figure out what's moving my GameObject?

texts:
I have a GameObject as part of a complex scene with a handful of interconnected parts, that's moving when it shouldn't be.  I've tried running under the debugger and setting breakpoints on all of the script points that are supposed to move its Transform, and ensured that none of them are firing.  There seems to be some "spooky action at a distance" going on, some rogue script doing something I don't want it to be doing, but I can't for the life of me figure out where it is.

What I'd really like is some way to set a "breakpoint" on the object's Transform that will break me into the debugger when it gets moved by any script, but that doesn't appear to be supported.  Is there any way to figure out exactly what it is that's moving my object around when it shouldn't be?

(And before anyone says "trial and error, disable components and see when it stops moving," I already know exactly which component to disable to make it stop moving.  Unfortunately, that isn't helping track down the problem because the movement isn't coming directly from that component's MonoBehaviour script.)


texts:
For someone with some background in maths, what is a good book about:

The core mathematics for game development
How these techniques are applied to common problems in game development

In particular, I am going to finish my degree in Physics & Computer Science this summer, and afterwards will start an MSc. in Games Development. So I am looking for an informative read over the summer.

I know that there are a lot of books about this out there. However, I am particularly looking for a book that does not waste 300 pages on re-explaining what Trigonometry, Vectors or Matrices are...

Is there any book that is written for people like me with some background in maths? Something that explains the less-obvious techniques and how to apply them to solving problems in game development? Topics could include for example 3D Maths, Collision Detection / Physics, AI.


texts: Unity3d CarController character positioning issue

texts:
I use the unity standard asset components CharacterController and Car and put an empty gameobject onto the car where the camera should be placed when i am inside the car. The empty gameobject is called "Driver". The character controller has an empty called "Head" where its head is.

When i get in the car i perform the following operation

GameObject car = GameObject.Find("Car");
transform.position = car.transform.Find("Driver").transform.position + Vector3.up*1;
transform.parent = car.transform.Find("Driver").transform;
Camera.main.transform.position = car.transform.Find("Driver").transform.position;
Camera.main.transform.rotation = car.transform.Find("Driver").transform.rotation;

and to get out of it, i use the following

GameObject car = GameObject.Find("Car");
transform.position = car.transform.position;
transform.parent = null;
transform.rotation = Quaternion.identity;
Camera.main.transform.position = transform.Find("Head").transform.position;

My problem is when i get into the car and out again, the character is positioned at the position where i have entered the car, so it doesnt seems to update its position with the car movement.

What am i doing wrong?

Thanks in advance


texts: Is there a memory read/write or performance difference when applying affine transformations on a movieclip rather basic elementary math

texts:
I am using Actionscript 3.0 to make games and I fall into the category of programmers who use ball.x+=5;
ball.y+=5;
in order to move a ball by 5 pixels horizontally and vertically.

Well, now i seem to have an issue with a game I am making, it has a 3-body vehicle and each has its own translation and rotation. The three bodies: front, back1,back2 exist inside the top movieclip called vehicle. So each of them has a different coordinate system compared to the top movieclip. Well, when the vehicle crashes onto an obstacle in my game, I have to reset the movieclip, this is done by taking apart all the x,y,rotation of each movieclip into an array at the beginning of the game and restoring it to the beginning position after crash.

Well , but ,now  I have stumbled upon this

  transform.matrix

feature in flash, which allows me to perform mathematical transformations on the movieclip's transformation matrix, and now on applying mathematical transformations on the top level movieclip, all the inside movieclips are affected, It is a huge advantage to me.

But, I would like to know, IF i use this technique by breaking apart my whole code written as of now and re-writing it into using transformation matrices for every single horizontal, vertical or rotation of the vehicle. Will it affect my performance?

Thank you.


texts: Friction using delta time returns inconsistent result

texts:
Slowing down a character using the following formula returns different results depending on the frame rate:

this.y += this.yVel * delta;
this.yVel *= Math.pow(0.99, delta);

Is there a better way to decelerate a player using delta time to allow for consistent movement across several framerates?


texts:
The problem with OnCollisionEnter2d is that it only gets called when there is a collision but what I wanted is to get the current speed of object at the moment of impact until the object stops moving. So that I if the object stops moving after impact I will call another function.

void OnCollisionEnter2d(Collision2D collision){
   Debug.Log(speed); //problem this will only give the speed at the moment of impact
   if(speed <= 0){
     blah blah
   }
}

I also tried putting speed variable on the Update()

void Update(){
     var currentVelocity = player_rb.velocity;
     speed = currentVelocity.magnitude;
}


texts: Realistic intensity of a sun in Unity to match the outside world

texts:
I am creating an ARCore application in Unity where I want to make lighting shadows that match the real lighting outside.

For this, I have made a rotational directional light that simulations the real sun. The suns altitude and azimuth angles is found from the phones GPS coordinates. In combination with the rotational sun, I will also have a hemisphere of directional lights simulation the sky. These directional lights will have different colors and intensities. The color and intensity of these I have found using the model presented by Preetham in the paper A Practical Analytic Model for Daylight. I need to properly scale the intensity of the sun and these sky lights to make the lighting conditions look as realistic as possible.

In order to make the Augmented objects have the same lightning conditions as the real objects, I need to make the intensity of the sun in Unity similar to the real sun. The Unity documentation reads that for light intensity:

  The value can be between 0 and 8.

I have been told that parameters like these in Unity have no coloration to the real world conditions. Are you aware of any good practices for setting the intensity of a sun in Unity or do you know of scientific method for this?


texts: libGDX : Paint And Remove Color From Actor with touchDragged

texts:
I created two-dimensional array of Button actor, then I added new ClickListener() {
touchDragged } as the following code:

buttons = new Button[3][3];

for (int row = 0; row < buttons.length; row++) {
    for (int col = 0; col < buttons[0].length; col++) {

buttons[row][col] = new Button(drawable);

buttons[row][col].addListener(new ClickListener() {

                @Override
                public void touchDragged(InputEvent event, float x, float y, int pointer) {
                    for (int row = 0; row < buttons.length; row++) {
                        for (int col = 0; col < buttons[0].length; col++) {
                            if (buttons[row][col].isOver()) {
                                buttons[row][col].setColor(Color.GREEN);
                            }
                        }
                    }
                }
   }
}

the code inside touchDragged method if the buttons isOver the buttons colored GREEN (it works fine) as shown in image

Now, How can I remove Color.GREEN i.e. (Color.WHITE) from buttons in the same calling touchDragged method, I mean undo GREEN to WHITE ??

this image clear my question :

like Alphapetty Game from king company, if you know it :).

Sorry, For bad English


texts: cocos2d-js displays only one type of tile from a tmx file

texts:
I am using Tiled to produce a tmx which I use in my code using cocos2d-js.
The problem is that when I run it on the browser, a wrong tile gets displayed, the first one of the image (0,0) and repeats for the whole map.
The relevant js code is this:

this.farm = new cc.TMXTiledMap(res.farm_tmx);
this.addChild(this.farm);

where res.farm_tmx the path to the tmx file.

What could be the source of the problem? And how do I fix it? It seems to me that it is specific to my code. I do not find any other reports of the same problem.


texts: Is there an all inclusive C++ game engine that is free

texts:
I would like to know if there is a C++ game engine that I can use for free to prototype some ideas I have.

I have experience in C++ and have spent some time now playing around with different rendering engines such as Ogre3d and irrlicht. I don't want to re-invent the wheel and spend the time building my own engine.

I have some ideas for a game that I would like to prototype and would be looking for a free engine to experiment with. I would be open to paying for the engine if I can make my idea work but as I don't have a great deal of time or resources I would need the engine to not have a time limit on free use.

By all inclusive I mean: I would rather not have to get a whole bunch of separate dependencies for physics, sound etc. I would prefer the one engine to have those things in it.

It might be a big ask as well but some of my ideas are of a more advanced nature so ideally not free because it limits the features for free use. I want something I can use to prototype some ideas and would be happy to pay for if the project went past the prototype stage.


texts: 2 Images, same object: tone difference and alignment

texts:
I would like to know a software which helps in post-production to calculate the general color/tone difference of 2 images. The images contain the same object, but arn't shot from the same position. One image might be sunny, the other cloudy, so one is more orange/yellow, the other more grey/blue, but the same object.

How would you align the tone of the image?

Background info: i shoot a couple of hundreds of images to produce textures for my models, the objects are outside, so weather conditions can change at any time, shooting must continue. I do photogrammetry, so I use the images to project them on the geometry and bake them in a UV Map. So in general I have a chunk of images made in sunny condition and another in cloudy. I would like to apply a tone to all cloudy images, having similar tone like in the sunny images.

It's not about HDR.


texts:
I saw this video: Video
And now I am curious about the following: How can you achieve dynamic forms like they are shown in this video.
What I mean is: Do you need to have some "base" models which can be just linked together? Or is it possible to generate these 3D models "on the fly"?

If yes: How could that be done?
And: Is something like that as well possible in 2D?

And: How can you do animations, like (some) in the video? Because it seems as if the body parts of the creatures work together more or less correctly. As well here is the question: Would this be possible in 2D?


texts: I want to pause my game when the battery warning on Android pops up. How do I do this? I have a method that pauses the game but how do I call it when the battery warning pops up?


texts: Unity - "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3)

texts:
I'm using Unity5 right now. I got this error when try to setDestination.

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.NavMeshAgent:SetDestination(Vector3)
CompleteProject.EnemyMovement:Update() (at Assets/_CompletedAssets/Scripts/Enemy/EnemyMovement.cs:30)

My code.

using UnityEngine;
using System.Collections;

namespace CompleteProject
{
    public class EnemyMovement : MonoBehaviour
    {
        Transform player;               // Reference to the player's position.
        PlayerHealth playerHealth;      // Reference to the player's health.
        EnemyHealth enemyHealth;        // Reference to this enemy's health.
        NavMeshAgent nav;               // Reference to the nav mesh agent.

        void Awake ()
        å{
            // Set up the references.
            player = GameObject.FindGameObjectWithTag ("Player").transform;
            playerHealth = player.GetComponent <PlayerHealth> ();
            enemyHealth = GetComponent <EnemyHealth> ();
            nav = GetComponent <NavMeshAgent> ();
        }

        void Update ()
        {
            // If the enemy and the player have health left...
            if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
            {
                // ... set the destination of the nav mesh agent to the player.
                nav.SetDestination (player.position);
            }
            // Otherwise...
            else
            {
                // ... disable the nav mesh agent.
                nav.enabled = false;
            }
        }
    }
}

Please advice. Thank you.


texts: How can I can I reduce the write load on a database for an MMO?

texts:
I am considering using MySQL as a database for storing the character states or the world for that matter.

The thing is if I will save the character data on an interval, thus giving rest to the mysql database, it means that if the server crashes some game time would be lost.

So I was planning to save everything as it happens and make the database the real source of the states.

But the problem is, this would mean thousands of write per second. How can I alleviate that performance problem?

Additional info:

This is a MMORPG
2000 simultaneous players (so far in beta)
3D world


texts: Polygons requirement on mobile devices, around 3000 vertices?

texts:
I read on the unity documentation that a character should be between 300 to 1500 "polygons" on mobile devices to have good results. In Blender, we have "tris" or "faces", does "polygon" stand for the "face" here?

Also, my character will have around 2800-3000 vertices, with 10-12 bones. Considering the requirement for 1500 vertices was written some years ago, should I trust in the power of the new mobile devices and continue like this, or should I make a new retopology to reach the 1500 vertices in total? I will not have more than 2 characters on screen.

Thanks


texts: Why do old platformers typically scroll to the right?

texts:
Lots of old platformers are only left-to-right-ish and they don't allow you to move viewport left.

I'm interested was it just a game design choice or it's due to some limitations back then.

I have a lot of possible reasons in my head, but I'm interested in actual one, so please consider reply with citation.

Not sure I'm in correct community with this question, sorry in advance.


texts: Reconstruct Quaternion from 48 bit rotation data

texts:
I'm trying to reverse an animation file from a commercial multiplayer game, whose format was recently updated. The problem lies within joint rotation information, which changed from a 128bit format to a 48 bit format.

The old format actually was using a quaternion representation with 32 bit floats for each component (32 * 4 = 128 bit)

The new format was probably added for quantization purposes (serving better multiplayer performance). I played around trying to apply an euler angle representation (3 x 16 bit integers or 3 x 16 bit half floats) but i failed miserably so I think it should be still a quaternion representation of some sort.

I have located a model which has not changed at all structurally but obviously the model files have been updated to the newest format.

So I do have the byte data, I know the correct rotation angles (again from game data) that correspond to those values as well as the quaternion values from the old version of the files.

New Format Bytes       Rotation(deg) X,Y,Z       Quaternion
41 ED 3F ED 41 6D      0, 90.0, 89.99             0.5, 0.5, 0.5, 0.5
85 F7 2C A0 85 77      59.64, 90, 0               0.3516, 0.61347, -0.351634, 0.61347
AE CE FF BF FF 3F      -180, 0, 18.54             0.98 0.16 0 0
40 ED BE 92 BE 12      0,-90,90                   0.5, -0.5, -0.5, 0.5
DE 40 DA 42 CA 3C      -1.017, -3.633, 4.091      -0.009633918, -0.03154902, 0.03542599, 0.9988277

I'm currently searching the web for quaternion quantization techniques and I'm experimenting with different stuff, so if I find anything I'll make sure to update. Thanks in advance


texts: How to make multiple levels game in XNA game studio 4.0?

texts: I am doing 2D game using XNA framework 4.0. I'd like the game to have multiple levels. Where do I store the levels and how do I implement a scoring system for the game? Can I use XML for storing data for that levels and scores? Finally, is there any code samples for a multiple level game in Windows phone 7 using XNA 4.0?


texts: What is the difference between genre and game mechanics?

texts:
In some local vacancies I read something like "a genre = match3", or like "a game mechanics = adventure". I thought, a game mechanics is match3, or any sequences of operations that do something to solve something. A verb. For example, to connect three candies of one color in a line.

And genre is just a structure about what elements should be in a story. Like in "The Hero with a Thousand Faces". For example, an adventurer + an artifact + a map (or any key) to find it + competitor (or a let) = adventure.

Am I wrong?


texts: Objects World Matrix Issue in Direct3D11

texts:
I have an issue with the transform matrix of my cube. When I change its position (world matrix) and rotate the camera, it is getting deformed.

Here's my shader update code:

void IShader::UpdateShader()
{
    XMMATRIX view= XMLoadFloat4x4(&m_viewMtx);    //The camera's view matrix (using XMMatrixLookAt())
    XMMATRIX persp = XMLoadFloat4x4(&m_perspMtx);    //The camera's perspective matrix
    XMMATRIX world = XMLoadFloat4x4(geo->GetWorldMatrix());    //Here, get the cube's world position (it is updated using keyboard input in another class)
    // GetWorldMatrix() returns m_worldMtx

    XMMATRIX m = view * persp * world;

    m = XMMatrixTranspose(m);

    VERTEX_BASIC_CONSTANT_t k;
    k.mWorldViewPersp = m;    //The vertex shader only contains one float4x4 in the cbuffer...

    D3D11_MAPPED_SUBRESOURCE map;
    memset(&map, 0, sizeof(map));

    ID3D11Buffer* context = sh->GetVSCBuffer();
    m_pD3DCtx->Map(
        context,
        0,
        D3D11_MAP_WRITE_DISCARD,
        0,
        &map
    );

    memcpy(map.pData, &k, sizeof(k));

    m_pD3DCtx->Unmap(
        context,
        0
    );
}

Here is how I update the cube's position:

void Geo::UpdatePos(VEC3 offset)
{
    XMMATRIX t = XMMatrixTranslation(offset.x, offset.y, offset.z);

    XMStoreFloat4x4(&m_worldMtx, t);
}

This deformation issue only affects the cube, not the floor.


texts: Using Blueprint to spawn objects at runtime in Unreal Engine 4

texts: Using UE4's "Blueprint" visual scripting system, how can I dynamically spawn objects at runtime?


texts:
I realise other posts exist with this topic yet none have gone into enough detail for me. I am attempting to create a 2D game in Unity using C# as my scripting language.

Basically I have two objects, player and bomb. Both were created simply by dragging the respective PNG to the stage.

I have set up touch controls to move player left and right; gravity of any kind is not needed as I only require it to move x units when I tap either the left or right side of the screen. This movement is stored in a script called playerController.cs and works just fine.

I also have a variable health = 3 for player, which is stored in healthScript.cs.

I am now at a point where I am stuck. I would like it so that when player collides with bomb, health decreases by one and the bomb object is destroyed. So what I tried doing is using a new script called playerPhysics.cs, I added the following:

void OnCollisionEnter2D(Collision2D coll){
        if(coll.gameObject.name=="bomb")
        {
            GameObject.Destroy("bomb");
            healthScript.health -= 1;
        }
}

While I'm fairly sure I don't know the proper way to reference a variable in another script and that's why the health didn't decrease when I collided, bomb never disappeared from the stage so I'm thinking there's also a problem with my collision.

Initially, I had simply attached playerPhysics.cs to player. After searching around though, it appeared as though player also needed a rigidBody attached to it, so I did that. Still no luck. I tried using a circleCollider (player is a circle), using a rigidBody2D, and using all manner of colliders on one and/or both of the objects. If you could please explain what colliders (if any) should be attached to which objects and whether I need to change my script(s), that would be much more helpful than pointing me to one of the generic documentation examples I've already read. Also, if it would be simple to fix the health thing not working that would be an added bonus but not exactly the focus of this question.

Bear in mind that this game is 2D; I'm not sure if that changes anything.

Thanks!


texts: What's the minimum viable product to present a game to a publisher?

texts: I am currently working on a puzzle game. I am aiming in the future to ask a publisher to publish it. What do you think could be the minimum viable product to reach before sending it. I am talking about the completeness of the work (number of levels, graphic details etc)


texts: Most efficient way to calculate angle between two line-segments that do not necessarily touch each other

texts:
Although I found answers on calculating angles from vectors, I didn't find a specific way to calculate angles between line-segments that do not necessarily touch each other (I say "not necessarily because I will apply to different cases).

See the figure below:

Consider that I know the 2D position of all 4 red points. I am using C# here. What would be the cheapest way of calculating the angles formed by line-segments that do not touch each other, such like the ones above?


texts: which state to add main menu for simple browser game with phaser

texts:
In which state should I add the main menu, or should i make it into another separate state?
My main confusion here is how I manipulate states properly. Im a phaser/gamedev noob and I dont know how to start a game from the main menu syntax and mechanics-specific.

My idea for a main menu would be a simple background picture with a start button. But then, how do i jump start the game when the start button is clicked?

just for details, Im showing you this :

var game = new Phaser.Game(800,600, Phaser.AUTO, 'phaser-demo', {preload: preload, create: create, update: update, render: render});


texts: Touch sides of tablet, moves that direction

texts:
I am making a game where the player flies a balloon through a cavelike structure.

I am having trouble making him fly correctly when I try it out on my android tablet, seeing as it requires different input to move.

How can I make the player move towards the touched side? By creating a ray? through touched objects? :)


texts: Monogame / XNA - Multple 2D Cameras (Rectangle) on screen

texts:
I recently started building a simple 2D roguelike game using Monogame 3.4. I was keen on building the game "engine" myself as I saw it as a fun learning curve. Monogame was pretty much the best option for me to get started as I'm a C# dev by profession.
After getting my sprite to run around on the screen, I figured I probably need a proper level to continue with the more interesting stuff. So I decided to build a level builder for the game.

I've been struggling and digging around tutorials regarding building a 2D Camera.

I used this camera tutorial and I preferred this specific implementation.
My only problem is, currently, I have two Rectangles (Cameras) on my screen.

The Rectangle on the left represents a scrollable panel with all the available sprites but is also a sort of overlay. Underneath it, the level "map" is drawn.
My question is simply, how would I enable my level Rectangle to scroll past the overlay to view the left-hand side of it, which is currently being obscured by the panel.

Relevant code files are here

I would appreciate all the help I can get.
Thanks!


texts: How to fix model matrices colliding in vertex shader?

texts:
I am new to OpenGL programming and I'm writing some basic code to display a few objects onto a screen.

I have a pyramid shape that I'm displaying, as well as a box shape that I am displaying. The pyramid shape is a class (C++), and each pyramid object creates it's own VBO (storing the points/colours). The same thing goes for the box.

The problem I'm having is that I have two shapes, and the shapes use the same vertex shader. Since I apply a model matrix for each object in the shader, the model matrix gets set for one object, but then when the other object goes to display itself it overwrites the model matrix for the previous object with it's own. So only one object has the correct model matrix after they are all done their display method.

I am also using hierarchical transformations to attach objects to each other. I have the root object storing the view/projection matrices, and the children of the hierarchy tree storing their individual model transformations. When a child wants to display itself, it walks up the tree to compute all the transformations it needs to do to itself. The problem also applies here, since the last child to be displayed will be the one whose model matrix is applied in the vertex shader.

I can't seem to figure out how to differentiate in the shader which MVP matrix to apply to which vertex. I think I'm missing something very basic here but I can't seem to figure it out... Any help would make my life a lot easier!

Edit: Is it possible that the shader is overwriting the MVP matrix in between glDrawArrays()/glDrawElements() calls?


texts: Can a MonoBehaviour be a private inner class?

texts:
I want to use a private inner class MonoBehaviour as part of the internal implementation of a class (also a MonoBehaviour). Reduced to the essentials:
public class OuterClass : MonoBehaviour {
  public void SomeMethod(GameObject go) {
    go.AddComponent<InnerClass>();
  }

  private class InnerClass : MonoBehaviour {
  }
}

This appears to be all working absolutely fine, with no errors or warnings. But it also appears to violate the statement in the Unity documentation that:

The class name and file name must be the same to enable the script
component to be attached to a GameObject.

Is this a problematic violation of that rule? If so, what are the problems? I am aware that it means the script is not visible in the Editor, but that's exactly what I want: it should never be added by anything other than its enclosing class.


texts: Accelerometer input for player movement is too sensitive

texts:
I am designing an endless runner style game like temple run. I need to move the player left and right based on the accelerometer input (tilting). The problem is that the accelerometer input is very sensitive. In other words the player is moving left even if the phone is held straight. I want to make the player to move smoothly like temple run game. (Player has a Rigidbody component attached to him.). Here is my initial code:
if (Input.acceleration.x < 0)
{
    this.transform.Translate(-0.3f, 0, 0);
}
else if (Input.acceleration.x > 0)
{
    this.transform.Translate(-0.3f, 0, 0);
}

Then I tried:
// Player is running in negative direction
// Input.acceleration > 0 moves the player right
if (Input.acceleration.x < -0.2)
        {
            // this.transform.Translate(-0.3f, 0, 0);
            Vector3 dir = Vector3.zero;
            dir.x = Input.acceleration.x;
            if(dir.sqrMagnitude > 1)
            {
                dir.Normalize();
            }
            dir = dir * Time.deltaTime * horizontalMoveSpeed;
            transform.Translate(dir.x, 0 ,0 );
        }

        else if (Input.acceleration.x > 0.2)
        {
            // this.transform.Translate(0.3f, 0, 0);
            Vector3 dir = Vector3.zero;
            dir.x = Input.acceleration.x;
            if (dir.sqrMagnitude > 1)
            {
                dir.Normalize();
            }
            dir = dir * Time.deltaTime * horizontalMoveSpeed;
            transform.Translate(-dir.x, 0, 0);
        }

The problem in the edited new code is that the player moves only to the left even if the phone is tilted right. What is the mistake in my code?
I know that this question will get lots of down votes because this is a basic question. But unfortunately I am new to Unity and I cannot figure it out. What is the mistake?


texts:
All I could find about it is this question, but GraphicsMode alone doesn't enable anti-aliasing:

using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

class Program
{
    static void Main()
    {
        using (var window = new GameWindow(800, 60, new GraphicsMode(32, 24, 0, 8)))
        {
            window.Resize += (sender, e) => { GL.Viewport(window.Size); };
            window.RenderFrame += (sender, e) =>
            {
                GL.Clear(ClearBufferMask.ColorBufferBit);
                GL.Color3(Color.Red);
                GL.Begin(PrimitiveType.Triangles);
                GL.Vertex2(-1, 1);
                GL.Vertex2(-1, 0);
                GL.Vertex2(1, 0);
                GL.End();
                window.SwapBuffers();
            };
            window.Run();
        }
    }
}


texts: Balance an RTS to make a unit twice as good

texts:
I am modifying an RTS game (Rise of Nations) and want to make a unit twice as good and expensive as it's previous version so the balance is unaffected.

When I try to do it, I assumed that if I doubled the attack and health it would live twice as long and deal twice as much damage per second giving a total of four times as much damage so instead went for 1.4 times of each.

When I tested this however the modified version could defeat two of the original with little trouble.

I assumed after the first original is killed the damage would be halved. How can I calculate this correctly?


texts:
I'm working on a multiplayer turn-based project in unity 5.4 and Unity Networking. I'm trying to learn Networking and one thing I am wondering is when to use [Command] and [RpcClient].

I know the difference between both :

Command are executed by the server, and client are synced with it (I.E.: player X fired a bullet, send the command to the server, calculated the trajectory, and sync it with the clients).
RpcClient are command sent to the client (I.E. Player died?)

When I write a function, what question do I need to ask myself to know if it's a Command or a Remote Procedure Call.


texts: Does Game Maker use use intrinsic or extrinsic rotations?

texts:
I have a pretty difficult problem on my hands. My 3D character moves through space and rotates. I do not know the angle of rotation at any given time, but I do have three X, Y, Z unit vectors serving as basis vectors for the character's coordinate system.

I see that in the Euler angle page on Wikipedia there are three formula for extrinsic rotation. My problem is that they do not seem to work in any manner whatsoever. Either my reading of that page misled me, or game maker does not use extrinsic rotation.

Do Game Maker's rotation transformations always rotate globally in 3D space, or does it use the current set of transformations and rotate around the current X, Y, or Z axis?


texts: What game design/game theory resources should I watch for a "TCG-like" game?

texts:
Me and my friend are building a "simple" trading card game - in the beginning we would have 20 cards and two resources, mana and health. This, along with a working multi-player is the minimum viable programm. The programming and graphics are not a problem - not of course literally, but since we're in the design state, we have other questions before coming to this two topics. Currently we have 10 cards, some basic mechanics and a short draft of ideas/comments/etc that I call the Design document. What I'm unsure now is how to continue developing the game, so I guess what I need are resources for game theory/game development so we at least don't reinvent everything.

Edit: To answer the questions below and keep them more visible:

This is the game in it's current form (made for iPad but works on Desktop computer if you use A S D J K L): http://app.planetofsnail.com/game.html
As you can see, this is not a trading card game (or anything more than the bare skeleton of the idea :) The reason I called it a TCG is because of the way you play the game: you tap combinations to create magic symbols that translate into spells. When you break it down, it's like playing Magic the gathering, but instead of collecting and tapping lands, you make some hand gestures :) You have spells and monsters and two mana cast cost translates into two cast combinations (not exactly, but this is good enough without going into unnecessary details).

So to sum it up, from M:TG it uses literally spell names, mana costs and the fact two players play the game. The actual mechanic is different (you don't collect lands, every turn you have a fixed amount of mana that replenishes etc.)

BerndBrots' link to a game balancing article and actually the whole series is what I'm looking for - how to design a game (preferably TCG since TCG is the closes to what we're doing).


texts: Unity 2D sprite animation keep in sync after setting inactive

texts:
I am creating a 2D sprite-based game and the tile map contains many animated background tiles (such as water). The map contains many areas that can be transitioned between in a Zelda style (camera scrolls to new area). After scrolling, I set the previous area to inactive. Setting the area to inactive pauses the animations (which is what I want), but when I reenter a previous area the animations start from where they left off. Therefore, any animated tiles adjacent to each other between screens are out of sync and cause an obvious seam. I would like for all the background tile animations to run on the same time value even after they've been paused. The animations use an Animator Controller attached to each animated tile GameObject with an Animation that changes the sprite from an atlas.

Another idea I had would be to have a separate class modify my texture atlas (maybe using setpixel) to update the tiles to their next frame of animation (since I want all tile animations to be in sync and run at the same speed), but I'm not sure how updating the texture will affect performance.

I would like to hear people's ideas for any solutions to this problem.


texts: How do I store destructible terrain that characters can walk on?

texts:
I'm trying to make a 2d game like Worms (in JS, if it's important). I found 2 possible ways of implementing destructible terrain:

Bitmap. Store every pixel in a huge 2-dimensional array
Represent the terrain as a f(x, y) function somehow and use the marching squares algorithm with linear interpolation.

But I still don't  quite understand how should I calculate worms' movements. When a worm is standing on the ground and is walking in a certain direction, how do I calculate its next position?

I have an idea for how to do it with a bitmap, but I don't think its the best one:

Before the match find pixels where the worm can stand
When the worm starts walking find some nearby standable pixels with standablePixelsX = wormX + direction, where direction = -1 or +1 based on which direction the player is moving (left or right)
And check those selected standable pixels with an areConnected(pixel1, pixel2) function which determines whether a worm can move form pixel1 to pixel2 (checks for blocking ceilings and stuff)

Which way should I implement destructible terrain and whats the best way to calculate worms' movements?


texts:
Do video games often use numerical solutions in their calculations, such as you might generate using software like MATLAB or Mathematica?

Perhaps for making formulas for AI, or for game physics implementations?


texts: Objects do not stop when colliding each other while using mouse drag

texts:
I work on a 2D game and I have multiple objects that the player can control.

The objects each have a RigidBody2D and a Collider, and a method OnMouseDrag() with which I can drag the objects.

I want the dragging to stop when the objects hit each other.

I tried by using this:

rigidbody2d.velocity = Vector3.zero;
rigidbody.isKinematic = true;

But the objects do not stop.

I want exactly like this video.
I tried this but it isn't work too.

https://www.youtube.com/watch?v=ZfjVR-0ZFHU&t=270s

using UnityEngine;
 using System.Collections;
public class NewBehaviourScript1 : MonoBehaviour
{

bool allowDrag = true;
void OnCollisionEnter(Collision collision)
{
    allowDrag = false;
}

void OnMouseDrag()
{
    if(allowDrag)
    {
    float distance = 7;
    Vector3 mousePosition = new Vector3 (Input.mousePosition.x, Input.mousePosition.y , distance);
    Vector3 objPosition = Camera.main.ScreenToWorldPoint (mousePosition);
    transform.position = objPosition;
        if ((transform.position.x <0))
            {
            Vector3 _tmp = transform.position;
            _tmp.x = 0;
            transform.position = _tmp;
            }
            if ((transform.position.x > 4.5f))
            {
            Vector3 _tp = transform.position;
            _tp.x = 4.5f;
            transform.position = _tp;
            }

    }
}
void OnMouseUp()
{
    if ((transform.position.x > 0) && (transform.position.x < 0.375f))
        {
        Vector3 _tr = transform.position;
        _tr.x = 0;
        transform.position = _tr;
        }
    if ((transform.position.x > 0.375f) && (transform.position.x < 1.25f))
        {
        Vector3 _fs = transform.position;
        _fs.x = 0.75f;
        transform.position = _fs;
        }
    if ((transform.position.x > 1.125f) && (transform.position.x < 1.875f))
        {
        Vector3 _tr2 = transform.position;
        _tr2.x = 1.5f;
        transform.position = _tr2;
        }
    if ((transform.position.x > 1.875f) && (transform.position.x < 2.625f))
        {
        Vector3 _tr4 = transform.position;
        _tr4.x = 2.25f;
        transform.position = _tr4;
        }
    if ((transform.position.x > 2.625f) && (transform.position.x < 3.375f))
        {
        Vector3 _tr6 = transform.position;
        _tr6.x = 3;
        transform.position = _tr6;
        }
        if ((transform.position.x > 3.375f) && (transform.position.x < 4.125f))
        {
        Vector3 _tr7 = transform.position;
        _tr7.x = 3.75f;
        transform.position = _tr7;
        }
    if ((transform.position.x > 4.125f) && (transform.position.x < 4.875f))
        {
        Vector3 _tr8 = transform.position;
        _tr8.x = 4.5f;
        transform.position = _tr8;
        }
}
void Start ()
{
}
void Update()
{
}

}

Please help!


texts: Gravity and Jumping in Clickteam Fusion 2.5

texts:
So I'm currently building a bare-bones functioning game that involves simple platforming. Quite literally a box moving left and right and jumping.
I'm using Clickteam Fusion 2.5, and I know there's an option to assign platforming movement to an active object, but I honestly do not enjoy implementing that feature one bit.

So instead I'm opting for simply adding or subtracting from the X and Y coordinates of the player object while the left and right arrow keys are held down for side-scrolling movement.

However, I have yet to figure out how to use this same method for jumping and gravity. I know being able to jump would be running an event that occurs after hitting a certain key, which takes in the current Y-coordinate of the player and runs it through a parabolic formula. And then gravity would simply be constantly subtracting from (or I guess in Fusion's case, adding to) the current Y-value of the player object while the frame is running.
So the question simply is where and how do I implement these things in order to create jumping and gravity. I figure there's a correct syntax for a parabolic formula when creating an event after "jump" is pressed, but for the life of me I can't figure it out. As for gravity, I'm completely lost. I have managed to get down stopping movement when colliding when another object so that is not an issue.

Thanks and appreciation in advance.


texts: Common ways to keep up with character state in a 2D game?

texts:
I am currently developing a 2D Blockdude clone for learning purposes and am wondering about storing character state in the game. For example, the character can be facing either right or left. What are some common ways of handling character state? Unfortunately, the question is so broad none of my searches have come up with anything (or maybe I'm searching for the wrong terms). Should I be using a state machine?

How I'm doing it now using the "character facing" example (code is Java):

enum CharacterFacing {
    RIGHT, LEFT
}

class Character {
    CharacterFacing facing;

    Character() {
        // start with the character facing right
        facing = CharacterFacing.RIGHT;
    }

    // called when the player hits the left arrow
    void moveLeft() {
        facing = CharacterFacing.LEFT;
    }

    // called when the player hits the right arrow
    void moveRight() {
        facing = CharacterFacing.RIGHT;
    }
}

Because the "facing" state is so simple, I've also thought about just a boolean:

class Character {
    boolean facingRight;

    Character() {
        // start with the character facing right
        facingRight = true;
    }

    // called when the player hits the left arrow
    void moveLeft() {
        facingRight = false;
    }

    // called when the player hits the right arrow
    void moveRight() {
        facingRight = true;
    }
}


texts: How to place objects/entities randomly in JS?

texts:
I'm making a game and I have a script (running it with Node) on the server that currently just randomly places things on the map... I'd like to change that. I saw something about Perlin noise but I'm not sure if that's the thing I want and I'm even less sure how to implement it...

I want something like this, green dots represent trees, red ones represent enemies and grey ones represent rocks. Where can I get a simple JS algorithm to achieve this?


texts:
Tiled terrain. User wants to build a structure. He presses build and for each tile there is an "allow" or "disallow" tile sprite added to the scene. FPS drops right away, since there are 600+ tiles added to the screen. Since map equals screen, there is no scrolling. I came to an idea to make an allow grid covering the whole map and mask the disallow fields.

Approach 1:

Create allow and disallow grid textures.
Draw a polygon on screen.
Pass both textures to the fragment shader.
Determine the position inside the polygon and use color from allowTexture if the fragment belongs to the allow field, disallow otherwise

Problem: How do I know if I'm on the field that isn't allowed if I cannot pass the matrix representing the map (enum FieldStatus[][] (Allow / Disallow)) to the shader? Therefore, inside the shader I don't know which fragments should be masked.

Approach 2:

Create allow texture.
Create an empty texture buffer same size as the allow texture
Memset the pixels of the empty texture to desired color for each pixel that doesn't allow building.
Draw a polygon on screen.
Pass both textures to the fragment shader.
Use texture2 color if alpha > 0, texture1 color otherwise.

Problem: I'm not sure what is the right way to manipulate pixels on a texture. Do I just make a buffer with width*height*4 size and memcpy the color[] to desired coordinates or is there anything else to it? Would I have to call glTexImage2D after every change to the texture?

Another problem with this approach is that it takes a lot more work to get a prettier effect since I'm manipulating the color pixels instead of just masking two textures.

varying vec2 TexCoordOut;

uniform sampler2D Texture1;
uniform sampler2D Texture2;

void main(void){
    vec4 allowColor = texture2D(Texture1, TexCoordOut);
    vec4 disallowColor = texture2D(Texture2, TexCoordOut);

if(disallowColor.a > 0){
    gl_FragColor= disallowColor;
}else{
    gl_FragColor= allowColor;
}}

I'm working with OpenGL on Windows. Any other suggestion is welcome.


texts: resizing directx control so that more of my object's environment is visible

texts:
I'm very new in 3D. I have a DirectX control which I want to be able to resize. A 3D object is shown in the control. On resize, I would like that object to stay the same size, only more of its environments should be visible. As I understand, I only need to change the FOV for this, and I tried to deduce how from the second image here http://msdn.microsoft.com/en-us/library/windows/desktop/bb206341(v=vs.85).aspx.

My "solution" is:

    float newFov = (float)(2 * Math.Atan((height / prevHeight) * Math.Tan(fov / 2)));
    projection = Matrix.PerspectiveFovLH(fov, width / height, zNear, zFar);

(fov is the vertical fov here before the resize, height is the control's NEW height, width is its NEW width)

Problem is, this is not working, if I change the control's width only it looks OK (but then FOV really doesn't change, only aspect ratio), but if I change the height too my object is scaled. I'm starting to think that something in my thinking is fundamentally wrong. I would appreciate any help from you 3D gurus out there.


texts:
i try to learn Xna, but now i have problem:

In my simple 2D game i have tile engine, using

    SpriteBatch.Draw(Texture2D, Rectangle, Nullable<Rectangle>, Color, Single, Vector2, SpriteEffects, Single)

to extract tiles from TileSet (1 big texture). This works nice.

But then i wanted to merge all displayed tiles into one big texture, instead of many small tiles  (something like THIS).
Problem is that, i cant use  SpriteBatch.Draw()  with 2 different overloads at same time.

So, is there any way to use GPU for (1.) extracting tiles from tileSet and (2.) merge tiles together (and render them as 1 texture) ?

thanks for ideas


texts:
I am working on a 2D top-down game inspired by Prison Architect.
What I just can't wrap my head around is recognizing rooms built by the player.

The game is built on a tilemap, meaning the map is always a rectangle, while the rooms can be of any shape. I'd like to be able to detect whenever walls & doors create a new wall, like in the example below.

Since I have no formal education in CS (yet), I can't think of any algorithm or class of algorithms that might be of use here and also can't figure out one by myself. So if you have any ideas, suggestions or resources, I'd be very thankful!

In case this is relevant, I am using a custom implementation of a tilemap using Monogame, a reimplementation of XNA and Nez.


texts: Is it possible to tile box colliders without causing "false" collisions in Unity3D?

texts:
This is in regards to something like a sidescroller where you have a tiled map where each tile uses a 2d box collider.

If you use a 2d circular collider as an example for your character, as it rolls across a series of tiled 2d box colliders, it will occasionally collide with the seams between tiles rather than rolling smoothly across them.

In my scenario here, the tiles are 1x1 units snapped directly adjacent to each other. When rolling a 2d circular collider across a row of tiles, it goes mostly smooth but the more force applied, the greater chance of the circle flying up into the air rather than it's y staying the same as it rolls across them.

The obvious conclusion I had was to use edge colliders instead which works fine, but I'm hoping to find a way to completely eliminate this problem even with just 2d box colliders.

Thanks,
Tim


texts:
The thread between the tree and the spider here is a LineRenderer.

When the BackgroundLandscape or the Tree objects are selected it has this blur around the thread between the tree and the spider.

When anything else is selected, it renders correctly.

It always renders correctly in the Game view.

What's causing this?


texts: Slope polygon collider 2D causing box collider 2D to 'bump' while sliding on it

texts:
I'm doing procedural terrain generation. So far I've created the mesh, and attached a 2D polygon collider to it. The terrain is made up of hills going up and down.

After doing so, I put a 2D rigid body, along with a 2D box collider to represent the player. When I put  the player on top and let him slide all the way down, sometimes he doesn't slide properly, and instead bumps on the hill, jumping all of a sudden on his own as if he tripped on something (even though there's nothing there). What's weird is that it doesn't happen all the time, just sometimes. Even when I make him slide on the same spot he bumped before again, he wouldn't do it again except on rare occasions.

What could be causing this?


texts:
This article describes in general, how to draw sharp OpenGL 2D graphics, using fixed function pipeline.

http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL

Because OpenGL ES 2.0 has some ES 1.x functions not available (such as: glOrtho()), their functionality must be substituted in Fragment/Vertex shaders.

My question is, how to setup the following 2D projection in programmable function pipeline?

const XSize = 640, YSize = 480
glMatrixMode (GL_PROJECTION)
glLoadIdentity ();
glOrtho (0, XSize, YSize, 0, 0, 1)
glMatrixMode (GL_MODELVIEW)

How Fragment and Vertex shaders must be configured to fully substitute the above mentioned fixed function 2D projection setup?


texts: Outsourcing mobile app development, but royalty-based?

texts:
Terribly sorry if this is in the wrong StackExchange site, but it looked closest to my question.

I have an idea or two floating around in my programmer's brain for mobile apps on Android or iOS. Thing is, I can't spend months programming it after my day job just to see someone else go to market first. In the same vein, I don't want to dump tens of thousands of dollars to pay someone to do it outright. I know that in other industries, you can often get paid by offering up the idea as intellectual property, allowing another company to do the work while you collect royalty checks for coming up with the idea in the first place, assuming the developing company went ahead with it and it became successful.

Does such a thing exist in the mobile application development world? If so, any recommendations for trustworthy companies? Let's assume that it actually IS a decent idea, is well vetted out and planned, and does not exist in the marketplace yet.


texts: Prefabs were modified even it doesn't updated when commit

texts:
Me and my co-workers uses Git for saving the developing game. But sometimes, some co-worker push the commit, it contains modified prefab that he never did.

Prefabs are binary files so I can't see what is changed until pull. The big problem is that those prefabs are already used other scenes so updating it's property might be cause unexpected behaviour.

Also if I do something work with one of that prefabs, that could be overwritten(or maybe not. git refuse the commit because of conflicts).

Anyway, my co-worker said he didn't touched any property of prefabs, even he didn't clicked it at all, but it still modified from his computer.

In this case, what makes those prefabs modified? How do I avoid those weird situation?


texts: How to create 2D platformer maps without a game engine's editor?

texts:
I've been developing a 2D shooting platform videogame for the Sony PSP console using only the ONELua interpreter for the Lua programing language (since there is not any game engine for it). Despite its many useful modules, it doesn't come with tools to create platformers, because ONELua is not a game engine itself.
So I need to figure out how to implement my camera, maps and some other stuff myself. Since Lua is a scripting language, I've been applying best practices and an OOP approach in order to make it scalable and maintainable.
Despite researching a lot, all I'm finding is about Unity, GameMaker, Godot or any other already invented wheel:

How would you make a 2D platformer map so that it interacts with environment (other objects, enemies, etc.)?

Is the map represented by a matrix (kind of RPG map)?

The objects should be hardcoded, I mean, do they have a fixed position?
This last question is because I've read the code form another very similar project but the code has been hardcoded so I consider it as not very maintainable and scalable (since it has more than 1k lines of code in just one script), however at the end it could be hardcoded using some creational map tools, couldn't it? If so, I guess all above questions would be answered.

Based on the code that I've read, I surmise that I would put every object at a fixed position using a level editing tool, applying physics to move those physical objects and so on. Then, if the player "moves" (it would stay in the center of the screen simulating moving, just with a walking animation) then move the whole world (objects and environment) would approach the player, but I think it wouldn't be the best approach for performance.


texts: XNA: "TextureCoordinate0" missing, but I'm not using textures

texts:
I'm trying to create a voxel game using XNA, but I'm getting a somewhat bizarre error when calling DrawIndexedPrimitives():

InvalidOperationException was unhandled
The current vertex declaration does not include all the elements required by the
current vertex shader. TextureCoordinate0 is missing.

Which makes some sense, as it's true my vertex data structure (VertexPositionColorNormal as shown in this Riemers tutorial) does not contain texture data.

However, the effect shouldn't require texture data - I made it a point to set drawingEngine.TextureEnabled = false; in my graphics setup method.  So why is this exception being thrown?  And what can I do about it?

For some context, here's my draw method:

public void Draw(SpriteBatch drawer)
{
    drawingEngine.View = player.createViewMatrix();

    Vector3 direction = player.getDirection();

    for (int x = 0; x < mapSize; x++)
    {
        for (int z = 0; z < mapSize; z++)
        {
            Chunk drawee = map.get(new IntVector3(x, mapCenter, z));
            if (drawee == null)
                continue;
            if(drawee.isTransparent())
                continue;
            #region chunkdrawer

            DynamicVertexBuffer vertexBuffer = drawee.getVertexBuffer();
            int numVertices = drawee.getNumVertices();
            DynamicIndexBuffer indexBuffer = drawee.getIndexBuffer();
            int numIndices = drawee.getNumIndices();

            graphics.SetVertexBuffer(vertexBuffer);
            graphics.Indices = indexBuffer;

            foreach (EffectPass p in drawingEngine.CurrentTechnique.Passes)  //Not sure I entirely understand this
            {
                graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numIndices / 3);
            }
            #endregion chunkdrawer
        }
    }
    drawer.End();
    drawer.Begin();
}

And here is the graphics setup method:

void graphicsNonsense()
{
    drawingEngine = new BasicEffect(graphics);

    drawingEngine.World = world;
    drawingEngine.Projection = projection;

    drawingEngine.TextureEnabled = false;
    drawingEngine.VertexColorEnabled = true;

    drawingEngine.EnableDefaultLighting();
    drawingEngine.SpecularColor= new Vector3(0, 0, 0);
}


texts: Testing spheres without extracting planes

texts:
I am currently a bit stuck. On OpenGL I am attempting to do view frustum culling,
so far I managed to do it by using a PCM.
Where center is the world position of the mesh.

bool shouldRenderMesh(mat4 VP, vec3 center, float radius)
{
    vec4 transformedCentre = VP * vec4(center, 1);
    vec3 PCN = vec3(
        transformedCentre.x / transformedCentre.z,
        transformedCentre.y / transformedCentre.z,
        transformedCentre.z / transformedCentre.z
        );
    if( abs(PCN.x) > 1 || abs(PCN.y) > 1 || abs(PCN.y) > 1 )
    {
        return false;
    }
    return true;

The problem is, while the approach works, items will disappear too soon, as the testing is based on the centre point of the mesh, rather than the bounding box.

Is it possible to test a sphere or box without extracting planes?

Thanks


texts: I'm looking for a good resource to start learning 3d modeling. I'm looking for something that starts with the basics (e.g. terminology; what are quads, triangles etc.) before/while going into the actual modeling. Book, website, video,  anything will do. I'm only concerned with the quality of the tutorials, how thorough they are. I have experience with texturing, level design and so on - but I've never created anything more than simple shapes/editing existing assets.


texts: Buggy behavior on basic hinge joint (pinball flipper)

texts:
I'm trying to make a pinball flipper, but before I begin working on the script to incorporate user controls, I want to get the rotational movement working. Basically it rotates in a circle around the left-most point.

Clearly one option is to make half the flipper invisible. This is the easiest way but it leaves me still not really understanding how to work with rotation. For example:

<======o======>

where o is the midpoint.

I want it to rotate along the same axis, but without the left half of the shape:

       o======>

I have tried watching this video a couple times but am coming short of understanding how the hinge joint works. I attached one my left flipper and set the axis to 0,1,0 so it rotates along the y axis (remaining parallel to the playfield). I also moved the anchor to the leftmost position. I have left the rest of the hinge joint at its default configuration. Here is some evidence:

the placement of the hinge joint (it's the little yellow arrow at the left of the flipper)
the hinge joint config
The buggy behavior
The left paddle's rigid body (it is locked on all position and all rotation except y)

What I'm really trying to do is have the flipper rotate from it's leftmost point as the origin. I just want it to free-rotate when the ball hits it.


texts: I am new to working with Unity3d, I need to navigate between several inputField, for this I have looked at the solution that is in: tab-between-input-fields, but always the FindSelectableOnUp() or FindSelectableOnDown() returns null, so my next is always null and always ends in: next = Selectable.allSelectables[0];


texts: Is it a good idea to implement a MVC pattern into my LibGDX 2D RPG-style game?

texts:
For example I currently have a Player object that contains it's textures/animations and how to render these (I'd consider this as the view). Player also has an update() method which controls where the player is going to move, if it's going to lose health etc. (controller). Finally Player also has all it's attributes like runspeed, health, max health, inventory items etc.

The Player class is starting to look very cluttered and unorganized and serializing the complete Player class isn't really possible, so I made a separate PlayerState class which basically contains all it's attributes that could be changed while playing (This could actually be turned into the PlayerModel). I was wondering if it would be a good idea to split the Player up using a MVC pattern. I would have a Player, PlayerController and PlayerRenderer. Serializing the Player would be easy and it would be easier to keep the rendering separate from the updating and make sure rendering only happens when everything for the next frame has been updated.

This seemed like a good idea, however then I would also want to do this for GameMap. A GameMapRenderer that renders the map and it's textures to the screen. A GameMap model that contains what animals and hostiles are in the map and other various attributes the map might have. And of course a controller that controls everything that happens in that map.

I could go even further and say a Pig may need a model since it has attributes that can change, a renderer to render it's texture and a controller to control movement etc. but this seems a bit excessive. However, I don't like only implementing the MVC pattern to the player and then ignoring it for other classes like Pig. But the way I'm working currently is very badly structured imo and it's frustrating to work with.


texts:
I'm working on a multiplayer game and it's currently set up like this. It accepts packets from the client on the fly and does whatever processing it needs to. There is also a main game tick which is set up like so:

for every online player
    update every player in the region

for every online player
    reset flags

The problem I see that can happen is that since it handles packets on the fly, it may modify something between the updating and the flag reset, which could cause it to completely ignore something. I don't think it's possible to synchronize it using the actual synchronize block since it can't update and reset flags at the same time - it needs to reset flags after it updates every player.

The only solution I see is not processing packets on the fly and doing it in the main loop, but this could hurt performance. Is this the best solution, or is there another option I'm not considering?

Thanks


texts:
I'm trying to detect where approximately an enemy in my game has been hit.
I have added a box collider with a height of 1.8 metres to the enemy.

When the player then shoots, I use a RaycastHit to check if the enemy has been hit.
This works fine.

My code is this:

GameObject nHit = _LaserScript.hit.collider.gameObject;

if (nHit != null)
{
    Vector3 nHP = _LaserScript.hit.point; //"hit" is a RaycastHit
    Debug.Log("hit at x: " + nHP.x.ToString() + ", y: " + nHP.y.ToString() + ", z: " + nHP.z.ToString() + "\n");
}

I can relatively easy determine if the enemy has been hit at the head by checking

if (nHP.y > 1.5f)
{
    //headshot detected
}

However, I'm not sure if these coords have to be converted to "local" coordinates.

I tried to determine if I shot the enemy at the left side of his body or on the right side.

To my surprise, the "x" coord of the raycast was always around 1.2, and I have no idea why. I was expecting the x value of the hit to be somewhat between 0 and 0.5f as the collider is not wider than 0.5f.

Basically, I would like a hit at the left "border" of the enemy to have an x value between 0 and 0.1f.

Do I have to convert these hit coordinates (of which the docs say they're world coords) to "local" coords?


texts: How do I have an arrow follow different height parabolas depending on how long the player holds down a key?

texts:
i'm trying to throw an arrow in my game, but i'm having a hard time trying to realize how to make a good parabola.

What I need:
The more you hold "enter" stronger the arrow goes.
The arrow angle will be always the same, 45 degrees.

This is what I have already have:

    private float velocityHeld = 1f;
    protected override void Update(GameTime gameTime)
    {
 private void GetKeyboardEvent()
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !released)
            {
                timeHeld += velocityHeld;
                holding = true;
            }
            else
            {
                if (holding)
                {
                    released = true;
                    holding = false;
                    lastTimeHeld = timeHeld;
                }
            }
        }

        if (released && timeHeld > 0)
        {
        float alpha = MathHelper.ToRadians(45f);
        double vy = timeHeld * Math.Sin(alpha);
        double vx = timeHeld * Math.Cos(alpha);

        ShadowPosition.Y -= (int)vy;
        ShadowPosition.X += (int)vx;
        timeHeld -= velocityHeld;
        }
        else
        {
            released = false;

        }
       }

My question is, what do I need to do to make the arrow to go bottom as it loses velocity (timeHeld) to make a perfect parabola?


texts: How to send data from libgdx project to web?

texts:
I would like to work on moving the json data from libgdx to my web server, but I am not sure how to do it. The method below was created by referring to libgdx's documentation.

private void httpPostJson(){
    final Json json = new Json();
    final String requestJson = json.toJson(requestObject);
    Net.HttpRequest request = new Net.HttpRequest("POST");
    final String url = "http://localhost:8080/data";
    request.setUrl(url);
    request.setContent(requestJson);

    request.setHeader("Content-Type", "application/json");

    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            String responseJson = httpResponse.getResultAsString();
            Gson gson = new Gson();
            data = gson.fromJson(responseJson, Person.class);
            //'Person' is just sample class. data is class Person's object.
            data.StoreData("",1);//successed to receive json data from web server.
            //StoreData is just getter method.
        }

        @Override
        public void failed(Throwable t) {
            Gdx.app.log("failed!");
        }

        @Override
        public void cancelled() {
            Gdx.app.log("cancelled!");
        }
    });
}

It is possible to receive data transmitted from a web server.
But, this method can't send data to web server.
Can you tell me how to move data from libgdx project to web server?


texts:
Searched for a while thinking this would have some obvious tutorials but I can't find anything... which makes me think I must be using the wrong wording because it seems obvious.

Anyway, when I create my project, I have have a constant resolution of 800x600 set. This is used to set up:

my window
buffer description
swap chain description
depth stencil description
viewport

So, if I want to change my resolution to 1920x1080 what do I need to do?

Do I need to re-describe all of these things each time I change resolution and re-create them? Do I need to do it for just some of them? (I know resizing the window itself isn't a big deal)

Either way it seems like a lot of things use your window size so I was hoping there would be something that updates them all or a function for each that's used when you are changing resolution and nothing else.


texts: Stack based state design for isometric character movement, am I doing it right?

texts:
I have been reading around about stack-based FSM, and I found it to be perfect for my game. However, when a character moves, it consequently have to face in some direction (and animation of each direction will be different), now the problem that I am facing in my state machine design is the scope of each state.

For example, should I divide the state into MOVE_LEFT, MOVE_RIGHT, MOVE_UP, MOVE_DOWN or should I create one MOVE state with some direction argument in it. Now, the latter seems to be better, however, if I am to trigger direction change, how would I do it for a one-state MOVE? I could directly change the direction argument and manually change the animation sequence, which will destroy the whole purpose of state machine (State machine should change animation sequence OnEnter() state). Else, I would have complicate the state machine into hierarchy of states (Sub-states,etc.), and this seem unconvincing for me.

Or maybe I should implement some type of multiple, simultaneous states ---- Character's State (Jump, Move, Idle, Attack, etc) and Direction's State (Up down left right), then make it works concurrently, and apply stack-based architectue on Character's State only.


texts: There is almost always a player class in a game. The player can generally do a lot in the game which means for me this class ends up being huge with a ton of variables to support each piece of functionality the player can do. Each piece is fairly small on its own but combined I end up with thousands of lines of code and it becomes a pain to find what you need and scary to make changes. With something that is basically a general control for the entire game how do you avoid this issue?


texts:
When constructing an orientation matrix, are the rows of the matrix the axis?

The matrix is row-major and I'm multiplying vectors on the right (Mv).  So, the matrix looks like

r0c0 r0c1 r0c2
r1c0 r1c1 r1c2
r2c0 r2c1 r2c2


texts:
I have a public void

Public void patreononclick(){Application.OpenURL("http://www.patreon.com/HubakaGs");}

Which supposed to open my patreon page when a button is tapped.
But when i tap the button in the built application, nothing happens.
I have assigned the function to the On Click() section of Button (Script).
I am building the game for android patform and i use Unity 2017.1.0p4 Personal.
How can i make the button to function properly?

Update:
I changed the function to
public void patreononclick(){
        Debug.Log ("the game should open patreon");
        Application.OpenURL("http://www.patreon.com/HubakaGs");
    }
But when the button is clicked, there is no message at the console.


texts: Network without Server: NAT punchthrought

texts:
How do i make 2 players connect and play together ?

Assumptions:

1) Game has no server.
2) Player only has 1 computer.
3) Player cannot configure his router or open a port.
4) Player does not want to share his PC for multiplayer.
5) Reasonable delay is allowed: up to 1 hour per packet / player action.
6) Ipv4 internet is used
7) Players can connect to any website.

Solutions I considered but cannot get them to work:
1) Posting in a random forum you don't own. Soon the thread that 10 million players use, approaches 60gb data per hour and gets closed by a moderator. Gameover.

2) Sending Data by Email.
  a) I know no email api.
  b) players will risk their email credentials.

3) Having an external server manage the initial connection.
  a) I know none that are free.
  b) I am not paying money.

More specific :
I am using unity, i am willing to port solutions if you find a free site or solution that works.


texts: 2d metaballs with shader to give blobs of water effect?

texts: I want to simulate blobs of water in a 2d game in Unity3d. One possible way of doing it is to use 3d metaballs moving in a 2d plane though this is very processor intensive. Do you think it would be possible to make 2d metaballs, so I end up with a 2d meshes something like in the picture (In this case its 2 metaballs in conjunction) and then apply some kind of shader to make it look like they are bulging out and refracting the texture behind them like drops of water? I ask because I dont have much experience with shaders and am not sure what is possible.


texts: How to add a sound that an enemy AI can hear?

texts:
Given:

a 2D top down game
Tiles are stored just in a 2D array
Every tile has a property - dampen (so bricks might be -50db, air might be -1)

From this I want to add it so a sound is generated at point x1, y1 and it "ripples out". The image below kind of outlines it better. Obviously the end goal is that the AI enemy can "hear" the sound - but if a wall is blocking it, the sound doesn't travel as far.

Red is the wall, which has a dampen of 50db.

I think in the 3rd game tick I am confusing my maths.

What would be the best way of implementing this?


texts: How to animate child from parent in the Animation view?

texts:
For some reason I can't change the value of the scale properties.

The scale properties belong to a child object, and I added them with "add Property".

What I'm trying to do is, adding an Animation to an empty parent object, which is going to animate a few of the child components for an menu opening animation. I need the animation on this parent object.


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

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

Code:

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

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

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

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

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

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

        destroySelectedCubes = true;
        //          Physics2D.gravity *= -1;
        //          Physics.gravity *= -1;
    }


texts: How do I rotate a sprite so that it is 'pointing' in the direction it is moving?

texts:
I have a sprite, e.g a missile, heading in a certain direction (using a velocity vector).
How do I figure out its how much to rotate it so that it gets drawn 'pointing' in the direction it is heading?


texts:
Guys if I have two sprites placed on the same spot. How can I show the half of each Sprite instead of the one on top? The sprites are basic circles

All sprites have basic colors, no textures.


texts: Is there a way to make collision necessary?

texts:
This code I have for my player movement. Now I want to make the player (2d circle) stick to the path. I tried OncollisionEnter2d but it's detection wans't an obligation.

using UnityEngine;
using System.Collections;

public class player : MonoBehaviour {

    public float speed;

    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis ("Horizontal");
        float moveVertical = Input.GetAxis ("Vertical");
        transform.Translate (new Vector2(moveHorizontal,moveVertical)*Time.deltaTime*speed);
    }
}


texts: Unity "Convert To Entity" does not work (Render) with "Skinned Mesh Renderer" for Animations

texts:
I'm trying to make a game with Unity's ECS and Job System.

I came across the issue where, Convert To Entity does not support Skinned Mesh Renderer. It does not render the mesh. I need it for animations.

On the bright side, Game Object Entity does render Skinned Mesh Renderer. The downside is that, it does not support Physics Shape and Physics Body. Convert To Entity does.

I am using Physics Shape and Physics Body for physics.

Would anyone mind telling me what options are open to me?


texts:
Can someone please explain me what is the purpose of IncrSat and DecrSat?

Currently I know that they increment/decrement the current value in the buffer and they make sure the value is between 0 and 255, but I want to know how can I use them.

Could you please give a simple example and explain how IncrSat or DecrSat can help?


texts:
I am making a simple game right now and am struggling with collision response. My goal is to someday be able to turn it into a 2D platformer but I have a long way to go. I am currently making this in JavaScript and using the canvas element so (0,0) is in the top left and positive X is to the right and positive Y is down.

I read a helpful post on StackExchange that got me started on this but I can't seem to get the algorithm 100% correct. How to deal with corner collisions in 2D?

I can detect the collision fine but I can't seem to get the response right. The goal is to detect which side the player hit first since minimum displacement doesn't always work. The X response seems to work fine but the Y only works when I am far from the corners. Here is a picture showing what happens

Here is the code

var bx = box.x;
var by = box.y;
var bw = box.width;
var bh = box.height;

var boxCenterX = bx + (bw/2);
var boxCenterY = by + (bh/2);

var playerCenterX = player.x + player.xvel + (player.width/2);
var playerCenterY = player.y + player.yvel + (player.height/2);

//left = negative and right = positve, 0 = middle
var distanceXin = playerCenterX - boxCenterX;
var distanceYin = playerCenterY - boxCenterY;

var distanceWidth = Math.abs(distanceXin);
var distanceHeight = Math.abs(distanceYin);

var halfWidths = (bw/2) + (player.width/2);
var halfHeights = (bh/2) + (player.height/2);

if(distanceWidth < halfWidths){
    //xcollision
    if(distanceHeight < halfHeights){
            //ycollision
            if(player.xvel == 0){
                    //adjust y
                    if(distanceYin > 0){
                            //bottom
                            player.y = by + bh;
                            player.yvel = 0;
                    }else{
                            player.y = by - player.height;
                            player.yvel = 0;
                    }
            }else if(player.yvel == 0){
                    //adjust x
                    if(distanceXin > 0){
                            //right
                            player.x = bx + bw;
                            player.xvel = 0;
                    }else{
                            //left
                            player.x = bx - player.width;
                            player.xvel = 0;
                    }
            }else{
                    var yTime = distanceYin / player.yvel;
                    var xTime = distanceXin / player.xvel;

                    if(xTime < yTime){
                            //adjust the x it collided first
                            if(distanceXin > 0){
                                    //right
                                    player.x = bx + bw;
                                    player.xvel = 0;
                            }else{
                                    //left
                                    player.x = bx - player.width;
                                    player.xvel = 0;
                            }
                    }else{
                            //adjust the y it collided first
                            if(distanceYin > 0){
                                    //bottom
                                    player.y = by + bh;
                                    player.yvel = 0;
                            }else{
                                    player.y = by - player.height;
                                    player.yvel = 0;
                            }
                    }
            }
      }
}

And here is a JSFiddle if you would like to see the problem yourself. http://jsfiddle.net/dMumU/

To recreate this move the player to here

And press up and left at the same time. The player will jump to the right for some reason.

Any advice? I know I am close but I can't seem to get xTime and yTime to equal what I want every time.


texts:
Is C++ necessary to learn if I ever want to get a job in the game industry? I am extremely familiar with C# and have a basic mastery of making 2D games in XNA 4.0. Right now I am only 13 years old and love making games, and hope to someday get a game programming job. I have heard a lot of people say that C++ is the 'industry standard' and that it will hurt your career not knowing it. I am also trying to target more platforms than just windows and  i am aware of Monogame but for some reason i am having lots of trouble with the visual studio templates, and i find many bugs with monogame. Since i technically can't get a job yet, and probably couldnt get a programming job until i am like 22 or something (unless im self employed). And in that 9+ year time-span the game industry will most likely change a lot. So here is some questions

Will not learning C++ hurt my chances at getting a programming job?
By the time i can get a job will C++ still be the 'industry standard' programming language
If i am an indie developer does it really matter whether i learn C++ or not, and stick with what i know?
Should i even start learning it now seeing as i have many years before i can even get a job?

I am also having a worry that even though i am familiar with object oriented programming, i may spend lots of time on C++, and get very frustated and confused then just quit learning it, and by this time i've forgotten lots of XNA and i have to learn everything all over. So in short: Should i learn C++ if i ever want a programming job?

UPDATE

Thank You All For Your Answers And Suggestions. Recently I Picked Up SFML and C++ and it is going pretty good. I am getting the hang of C++, and starting to open my eyes to not worrying about learning new things because i was able to transfer all my C# knowledge into making C++ easier to learn. Thank You All Once Again.


texts: What algorithm can I use for handling two types of HP, one of which may be undefined?

texts:
In my game, each unit has two types of HP: Hard and Soft. Soft represents the human part of the unit, while hard represents anything mechanical. For example, a regular rifleman would have 100 softHP, and 0 hardHP. Another example would be the Tank which has 100 soft and 1000 hard (subject to balancing).

Now, the problem I'm facing is the fact that it should be enough for one of these types of HPs to be =< 0 for the unit to die - a Tank can't work without its driver, and it needs its gears, nuts, and bolts to function properly.

At first I was thinking of setting the soft and hard values for a unit, but leave, for example infantry, with an undefined value for hard HP, but this becomes an issue when a weapon hurts a unit: A weapon can hurt both hard and soft. A check for undefined value also becomes an issue, as many other things can affect HP as well, thus necessitating this check to be done many places, which to me seems very redundant.
Another thing I was thinking of would be to set the hard HP for infantry abnormally high, to the point where it would "never" reach 0, but this is bound to bite me at a later point, I'm sure.
I could easily overcome this hurdle some other way, but I would love some fresh eyes on this, in case there are any obvious solutions that I'm missing.

Any suggestions? Pseudo-code would be appreciated.


texts: What's the difference between Pygame's Sound and Music classes?

texts: What are the key differences between the Sound and Music classes in Pygame?  What are the limitations of each?  In what situation would one use one or the other?  Is there a benefit to using them in an unintuitive way such as using Sound objects to play music files or visa-versa?  Are there specifically issues with channel limitations, and do one or both have the potential to be dropped from their channel unreliably?  What are the risks of playing music as a Sound?


texts: How to make a road terrain for unity game?

texts:
im making a FP game in low poly style. I want to make some terrains for my game, with roads, trees, rocks, buildings and e.t.c. Unity terrains are not as good as i thought. They allow a good tool for placing multiple objects (like tree-to-sprite tools, trees mesh copy for perfomance), but the terrain building tool itself is very poor, so i cant use 3d terrain, because there will be no great tools for placing surroundings.

So my plan is - make low poly mountains, trees, rocks in Blender, then make a simple terrain with hills in unity and just place my surrounding objects on it. I have some troubles, for example - roads. I have a road elements, and by connecting & banding them i can get a really nice road. But how can i make a road on Unity's terrain?

For example it could be useful to export unity terrain as a 3d mesh to Blender, then make my roadways and export them in Unity.


texts:
I am making a multiplayer coop FPS game. I have created the first monster with it's AI. I have worked out the A* algorithm for the level based on the triangles of the walkable mesh.
So I can already find a path from point A to point B in the level. The question is, how would I implement a random wander algorithm?

The simple wander and evade obstacle steering behavior will not do, I think. I probably need to use the Path finding data.

What kind of algorithm do you suggest?


texts: What technique should I use to facilitate communication between XNA GameComponents (or between components of any type in a game)?

texts:
I'm starting out on my first 'proper' game project, and I've inevitably hit a block trying to decide how game components in XNA should communicate.

From previous (Java) GUI programming events, handlers and listeners seemed like the way forward. So I'd have some kind of event bus which accepts event registrations and classes subscribed to those events, with handlers to deal with them. For example (pseudocode):

class SpriteManager
    Update(){
        if(player.collidesWith(enemy)
             // create new 'PlayerCollisionEvent'
    }

class HUDManager
    onPlayerCollisionEvent(){
        // Update the HUD (reduce lives etc)
    }

However, I'm not sure of the code setup (in C#) that would be required to fully accomplish this. What keeps track of events (some kind of bus?), and how is it structured?

There also seems to be a lot mentioned about on Game Services, whereby you can register a GameComponent in your main Game.cs class, then fetch it from anywhere in your code that has a reference to the main 'Game' object. I've tried this with my SpriteBatch object and it seems very easy.. however, I can't see this being as flexible as an event model.

Take for example when an enemy dies. We want to update the game score. Using services I can get a reference to my StateManager object created in Game1 and added as a service, then set 'score' to the new value. I would of thought a 'onEnemyDeath' event, which can be handled differently by a multitude of classes, but initiated by 1 line of code in the relevant 'enemy death detection' section, would be better than individually casting each required GameComponent then calling whatever methods are required.

Or are these inferior strategies to something else?

I realise this is partly my poor C# knowledge as much as game communication paradigms, but I'd really like to get this fundamental thing right.

Update

Having looked at Services is more detail I'm less convinced - it's basically passing a global variable around (from what I understand).

Update 2

Having had a look at this basic tutorial on event handling and testing the sample code it seems events would be a logical choice for what I'm discussing. But I can't much of it in use in the samples I've seen. Is there some obvious reason why one shouldn't?