texts: How to differentiate between colliding objects in Box2D?

texts:
I need to differentiate between different points of contact in my racing game.

I currently have staticSensors which determine if the car is on the track or not, but I have created a second sensor to act as the 'finish line' but I am not sure how to differentiate the contact between the 'checkeredFlag' and all of the other sensors?

Any help would be appreciated! Here is my code:

include "contactListener.h"

void ContactListener::BeginContact(b2Contact* contact)
{
    b2Body* bodyA = contact->GetFixtureA()->GetBody();
    b2Body* bodyB = contact->GetFixtureB()->GetBody();

bool isSensorA = contact->GetFixtureA()->IsSensor();
bool isSensorB = contact->GetFixtureB()->IsSensor();

Wheel * wheel = (Wheel*)bodyA->GetUserData();
CheckeredFlag * flag = (CheckeredFlag*)bodyB->GetUserData();

if (isSensorA)
{
    StaticSensor * sensor = static_cast<StaticSensor *>(bodyA->GetUserData());
    sensor->action();
    Wheel * wheel = static_cast<Wheel *>(bodyB->GetUserData());
    wheel->offRoad();
    return;
}

if (isSensorB)
{
    StaticSensor * sensor = static_cast<StaticSensor *>(bodyB->GetUserData());
    sensor->action();
    Wheel * wheel = static_cast<Wheel *>(bodyA->GetUserData());
    wheel->offRoad();
    return;
}

if (typeid(CheckeredFlag).name() == typeid(bodyA).name())
{
    if (typeid(Wheel).name() == typeid(bodyB).name())
        {
        flag->action();
        return;
        }
}


texts: Shader with soft shadows and cel shading

texts:
I need help understanding what type of shader can create this type of soft shadow:l, where you can barely see that it is low poly:

With standard lit shader you get this type of shading which I rly don’t like:

My problem is that I don’t even know what to search for, what is this type of shader called?


texts: how to make coins explode out of monster in phaser?

texts:
I am trying to make coins explode out of a monster when it is killed.
the explode would be similar to this example: http://phaser.io/examples/v2/particles/diamond-burst

I also want the coins to be clicked individually similar to this example:
http://phaser.io/examples/v2/groups/call-all-input

I am confused as to how to incorporate the two above examples together. Is emitting particles the way to go? I am also confused as to how to set each coin to have a different value depending on the monster.

Any help is appreciated.


texts: Line segment / circle intersection - X value seems wrong?

texts:
Major Edit

I'm making a Breakout clone, and having difficulty with collision detection between a circle and line segment.

Apologies, my earlier question was a result of frustration and no sleep :)

Having read this post on collision detection I've re-written my collision code to the following:

    // Takes 2 points on a line, a circle centre, and a circle radius
    // Returns true is collision, false otherwise
    public Boolean DoesCollide(Vector2 a, Vector2 b, Vector2 c, float rad)
    {
        // First up, let's normalise our vectors so the circle is on the origin
        Vector2 normA = a - c;
        Vector2 normB = b - c;

        Vector2 d = normB - normA;

        // Want to solve as a quadratic equation, need 'a','b','c' components
        float aa = Vector2.Dot(d, d);
        float bb = 2 * (Vector2.Dot(normA, d));
        float cc = Vector2.Dot(normA,normA)-(rad*rad);

        // Get determinant to see if LINE intersects
        double deter = Math.Pow(bb, 2.0) - 4 * aa * cc;
        if (deter > 0)
        {
            // Get t values (solve equation) to see if LINE SEGMENT intersects
            double t = (-bb - Math.Sqrt(deter)) / (2 * aa);
            double t2 = (-bb + Math.Sqrt(deter)) / (2 * aa);
            Boolean match = false;

            if (0.0 <= t && t <= 1.0)
            {
                // Interpolate to get collision point
                Vector2 collisionPoint = c + Vector2.Lerp(normA, normB, (float)t);
                match = true;
            }
            if (0.0 <= t2 && t2 <= 1.0)
            {
                Vector2 collisionPoint2 = c + Vector2.Lerp(normA, normB, (float)t2);
                match = true;
            }
            return match;
        }
        else
            return false;
    }

However, I'm getting strange results for the X components of the collision points found 'on hit' - see the following debug output:

Coll at {X:1033.931 Y:620}, t1 = 0.203759334390812, Normalised = {X:0.8576241    Y:0.5142772}
Coll2 at {X:1052.069 Y:620}, t2 = 0.409877029245551, Normalised = {X:0.8615275 Y:0.5077109}
Circ cent = {X:1043 Y:610}, rad = 13.5

As you can see, the X components are 10px either side of the circle centre, but the Y component (620) is the very topmost pixel of the top of the Breakout paddle. Surely here the X points can't be 20 pixels apart, given the location of the Y point?


texts:
I'm trying to figure out how I can make the input which looks like this :

    // Checks if player is pressing movement keys, if is applies force to specified direction
    if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
    {
        //rigid.AddForce(new Vector2(-speed * Time.deltaTime, 0));
        rigid.AddRelativeForce(Vector2.left);
    }

    if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
    {
        //rigid.AddForce(new Vector2(speed * Time.deltaTime, 0));
        rigid.AddRelativeForce(Vector2.right);
    }

    if (Input.GetKey(KeyCode.UpArrow) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.W) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.Space) && groundCheck.isGrounded == false)
    {
        groundCheck.isGrounded = false;
        //rigid.AddRelativeForce(new Vector2(0, jumpPower));
        rigid.velocity = new Vector2(rigid.velocity.x, jumpPower);
    }

Always move according to the maps rotation.

So, even if the map were to rotate the player doesn't get inverted inputs (player is children of map, so it rotates too) :

Right now A is always to left, according to the players position, but if the player would rotate 90 degrees the input would be wrong, Left would be up/down, but I want it to still be left.

Here's a picture example : (Sorry for the horrible painting, I blame mouse :> )

I do want the physics in the world to not change when I rotate the world.

So if the player is rotated 90 degrees it should fall to the side instead of down. :D


texts:
I've been trying to build a 3D camera system in SDL2 with OpenGL so that I can use the mouse to look around. With glfw it's possible to trap the mouse in the window, and keep it centered with a library call, so I was looking for something equivalent in SDL2.

In order to process mouse events in the main loop I'm checking for SDL_MOUSEMOTION.
Searching around the web, I've found that SDL2 allows for mouse trapping with the call to SDL_SetRelativeMouseMode(). With this call, though, the mouse is trapped and limited to move within the window, and not just at the center. This causes the mouse to be able to move from the top left corner at (0,0) to the bottom right corner at (WIDTH,HEIGHT), and not any further.

I've tried to fix this by repositioning the cursor position with SDL_WarpMouseInWindow(), but this generates a SDL_MOUSEMOTION event as well, basically resetting any movement I might've tried to do.

How can I fix this?


texts: How do I convert a 2D movement (from mouse) to a displacement along a 3d axis?

texts:
I'm making a small 3D scene editor (that only allow to modify objects positions).

Each object is draw with a 3d X/Y/Z axis :

How it works : user choose an axis (X, Y or Z) by left clicking on it, then, while holding left click, he move the mouse (to move object in the axis direction)
.
picking is already ok, but i'd like to know how much the object should be translated for the selected axis, depending 2D mouse movement.

For the example, on this picture, selecting X axis and moving mouse left-right should give a bigger displacement than moving it up-down (almost zero for this one)

It must be really simple but i cannot figure it out.

Input should be : mouse displacement since first left click(2D vector), selected axis vector (3d vector), modelview / projection matrix.

Output : amount (float or double)


texts: What model file formats are supported in XNA?

texts: What model extensions are valid in XNA? I know it supports .fbx, for example.


texts: How do MMO servers communicate with players who are behind a NAT?

texts:
I'm now planning to develop a real-time mmo in the future using udp as the transmission protocol since it has lesser overheads than tcp... I understand that between the client and the server, they have to do 2 basic things, the client needs to send server updates such as character positions..movements..hitting a monster..etc, and the server needs to update all the clients connected to render the changes on their screen...

For the client updating the server, I'll most probably do it by sending fast UDP packets to the server, but however for the server to update client, the server will send UDP packets to client containing the updates, however what if a client is behind a NAT? How do the server "push" udp packets to clients connected to a NAT-based network?

I plan to write the server in Java, I've also read about NAT hole-punching with various techniques like STUN..TURN..ICE.. however I can't seem to find a good framework/solution for it..

I also wonder how MMOs today like Maple Story..WOW..League of Legends implemented it..


texts: Mathematics help. Preliminary grid checking assistance. (Supercover Z)

texts:
Problem outline: A ray passes through a gridcell. The gridcell's max z's must be compared to the ray segment's min z. This is the preliminary check, so it must be quick.
2 values must be obtained, the 2 points on the ray segment which are directly outside of the grid.
To determine the z values, the distance of the ray from these 2 points must be obtained.
The red shows the points (and distance) of the ray of z values that must be checked as max and min.

The sloppy solution
Instead of getting the points directly touching, calculate the hypotenuse and offset it doing various calculations. I tried this way and there are a lot of operations to be done. I am not sure if this is the best way.
(cant upload more than 3 pics)

The sloppiest (and possibly best) solution
The best sloppy solution would be to create a line offset by the hypotenuse, and have it congruent to the main line then use line_line_collision to determine the distance for point 1 then subtract that distance by hypotenuse*2 for point 2.

The streamlined solution
The best way would have the z's directly retrieved as part of the actual supercover algorithm.
Unfortunately retrieving the n values or error values in tandem with n values couldn't actually yield me the intersection points of the line and grid. My brain is utterly fried at the moment.
My code is here, possibly someone can find an inherent method to retrieve the intersection points of the line and grid.

iX=0 iY=0 s=16 res=8
repeat (res*res)
{
draw_rectangle(iX*s,iY*s,(iX+1)*s,(iY+1)*s,1)
iX+=1;
if iX>res-1
    {iY+=1; iX=0}
}
if mouse_check_button(mb_left) direction+=5

xfrom=mouse_x/s yfrom=mouse_y/s l=300

vecx=lengthdir_x(l,direction)/s vecy=lengthdir_y(l,direction)/s
direction=point_direction(0,0,vecx,vecy)
xto=xfrom+vecx yto=yfrom+vecy

draw_line(xfrom*s,yfrom*s,xto*s,yto*s)
x0=xfrom y0=yfrom x1=xto y1=yto it=0

{
    dx = abs(x1 - x0);
    dy = abs(y1 - y0);

    x = floor(x0);
    y = floor(y0);

    n = 1;
    var x_inc, y_inc;
    error=0;

    if (dx == 0)
    {
        x_inc = 0;
        error = 1000000;
    }
    else if (x1 > x0)
    {
        x_inc = 1
        n += (floor(x1)) - x;
        error = (floor(x0) + 1 - x0) * dy;
    }
    else
    {
        x_inc = -1
        n += x - (floor(x1));
        error = (x0 - floor(x0)) * dy;
    }

    if (dy == 0)
    {
        y_inc = 0;
        error -= 1000000;
    }
    else if (y1 > y0)
    {
        y_inc = 1
        n += (floor(y1)) - y;
        error -= (floor(y0) + 1 - y0) * dx;
    }
    else
    {
        y_inc = -1
        n += y - (floor(y1));
        error -= (y0 - floor(y0)) * dx;
    }
mn=n
    for (n=n; n > 0; n-=1)
    {

   draw_set_color(merge_color(c_red,c_white,it))
   draw_rectangle(x*s, y*s,x*s+s,y*s+s,1)
        it+=1
        draw_set_color(c_green)
        draw_circle((xfrom+lengthdir_x(it+.5,direction))*s,(yfrom+lengthdir_y(it+.5,direction))*s,2,0)draw_set_color(c_red)
        draw_circle((xfrom+lengthdir_x(it-.5,direction))*s,(yfrom+lengthdir_y(it-.5,direction))*s,2,0)
draw_set_color(c_black)
        if (error > 0)
        {
            y += y_inc;
            error -= dx;
        }
        else
        {
            x += x_inc;
            error += dy;
        }
    }
}

There are some other stuff I would like to know...such as 3d triangle/line collisions, but I don't want to boggle the thread down with too much information at the moment...


texts: User-friendly scripting when using an ECS?

texts:
I am currently creating a small hobby project to get back into game development, and I have decided to structure my entities using an ECS (Entity Component System). This implementation of an ECS is structured like so:

Entity: In my case it's a unique int identifier that is used as a key to a list of components.
Component: Holds only data, e.g. the Position component holds an x and y coordinate, and the Movement component holds a speed and direction variable.
System: Handles components, e.g. it takes the Position and Movement components and adds the speed and direction to the position's x and y coordinates.

This works fine, but now I wish to implement scripting into my games, in the form of a scripting language. In previous projects I've used an OOP implementation of game objects, which meant that scripting was pretty straight forwards. For example, a simple script could look something like this:

function start()
    local future = entity:moveTo(pos1)
    wait(future)

    local response = entity:showDialog(dialog1)
    if wait(response) == 1 then
        local itemStack = entity:getInventory():removeItemByName("apple", 1)
        world:getPlayer():getInventory():addItemStack(itemStack)
    else
        entity:setBehavior(world:getPlayer(), BEHAVIOR_HOSTILE)
    end
end

However, when using an ECS, the entity itself does not have any functions like moveTo or getInventory, instead the above script written in ECS style would look something like this:

 function start()
    local movement = world:getComponent(MOVEMENT, entity)
    movement:moveTo(pos1)

    local position = world:getComponent(POSITION, entity)
    local future = Future:untilEquals(position.pos, pos1)
    wait(future)

    local dialogComp = world:getComponent(DIALOG, entity)
    local response = dialogComp:showDialog(dialog1)

    if wait(response) == 1 then
        local entityInventory = world:getComponent(INVENTORY, entity)
        local playerInventory = world:getComponent(INVENTORY, world:getPlayer())
        local itemStack = entityInventory:removeItemByName("apple", 1)
        playerInventory:addItemStack(itemStack)
    else
        local entityBehavior = world:getComponent(BEHAVIOR, entity)
        local playerBehavior = world:getComponent(BEHAVIOR, world:getPlayer())
        entityBehavior:set(playerBehavior, BEHAVIOR_HOSTILE)
    end
end

This is a lot more verbose compared to the OOP version, which is not desirable when the scripting is aimed towards mostly non-programmers (players of the game).

One solution would be to have some sort of wrapper object that encapsulates an Entity and supplies functions such as moveTo directly, and handles the rest internally, although such a solution seems sub-optimal since it takes a lot of work to cover all the components, and every time a new component is added you would need to change the wrapper object with new functions.

To all game developers that has implemented scripting in an ECS before - how did you do it? The main focus here is usability for the end user, with as little "maintenance" cost as possible (preferably you don't need to change it every time you add a component).


texts: Unity, positioning with ints instead of floats

texts: I round my transform.position to the nearest integer at the end of every frame so it's never a decimal number. I would like to know if there's a way to make unity store the position in ints instead of floats to prevent floating points precision problems.


texts: How do I make my main character move towards an object? LibGDX/Java

texts:
What I want to happen is for my player to bounce from spring to another. For example take the illustration below:

Here's my code (what I've tried to do so far). This gets called in an update()method

public void springCollision(Box containsSpring) {
        // player object
        Player player = ((Player) this.object);
        // first spring
        Spring boxSpring = containsSpring.getSpring();
        // second spring
        Spring platformSpring = containsSpring.getPartnerPlatform().getSpring();
        // if player collides with first spring
        if (player.getRect().overlaps(boxSpring.getRect())) {
            // distance in x between first & second spring
            float dx = platformSpring.getxPos()
                    + platformSpring.getSprite().getWidth()
                    - boxSpring.getxPos() - player.getSprite().getWidth();
            // distance in y between first & second spring
            float dy = platformSpring.getyPos() - boxSpring.getyPos();
            Vector2 directionToSpring = new Vector2(dx, dy);
            // normalise vector then set player speed
            player.setxSpeed(directionToSpring.nor().x);
            player.setySpeed(directionToSpring.nor().y + player.getGravity());
        }
    }

What currently happens is that when he jumps onto a spring his jump just continues but in slow motion for some reason. Can anyone see why my algorithm doesn't work? Let me know if the comments are unclear


texts:
I am developing a little game, where I need an A* path-finding algorithm for enemies who follow the player. I have already learned and tested a path-finding algorithm, but it only works with fixed-size array.

How can I turn an open world into a fixed-size array? I am developing with Irrlicht engine 1.6 version. I know that it is a quite old, but it is the only engine which works for me, on Windows XP.

Here is my A star path-finding code that works on a 2D grid. Additionally , if needed, Here there is a link to a walking person I have created with Irrlicht. You must place the media folder in your local drive.


texts: What is the difference between a Facebook Canvas and Facebook Web project?

texts: I am making a game on cocos2d-JS for Facebook. What is the difference between Facebook Canvas & Facebook Web project. From what I can tell, Facebook Canvas ask for the secure url and Web ask for the site URL.


texts: Why is interpolation passed into the rendering routine when the position and speed are related to the update routine?

texts:
I've read this in several well known articles, including this one:

http://www.koonsolo.com/news/dewitters-gameloop/

Under the Interpolation and Prediction subheading is the description of the formula. I'm currently using the suggested game loop from the article (without passing in the interpolation). I get why interpolation is used, but I'm having trouble understanding why it is applied during rendering, and how it relates to my game.

I'm presently using pure tile based movement for 32x32 tiles. So my player moves from tile A to tile B so long as tile B can be occupied, and at a fixed rate of 1 pixel per 10ms. The state is "walking" until the player moves the full 32 pixels, at which point the state is "stopped". This all happens in a standard timer, but all during my update routine. My rendering routine simply takes the player's position and renders it onto the map. There is no "speed" per say in that equation that is accessible. So how would I use interpolation?


texts: How does a point squared equal the radius squared?

texts:
I am working on a simple ray tracer but I don't understand some of the formulas.

One that is bugging me at the moment is this:

  If a sphere is centred at origin, a point p lies on a sphere of radius r2 if
  p*p = r2

Now, as I understand it, 'p' is a point in 3D space, (x,y,z), so how is it possible to square the point and have it equal the radius squared?

For what it's worth, I'm reading this article on calculating the intersection of a ray and a sphere.


texts: Select motion path from curve in Maya Python

texts:
I need to obtain the motion path attached to a curve in maya using Python.
This is the situation as shown in the editor:

I want to obtain motionPath1 by calling a method on curve3 since they look like they are related.

However, I have tried pleny of list methods (listAttr, listHierarchy, etc) but they only return the curveShape3.

What is the command, if it exists at all, to get the name of the motion path in Python knowing the object curve3?


texts: Ini files only work on my computer. How to create ini files in a directory on another computer?

texts:
I am creating a game that requires the use of ini files.
The game works perfectly on my computer.
When I create and executable, the executable even uses the ini files when I am programming/testing the game on the engine.
Directory where the ini files are located:
D:\Users\BonecoSinforoso\AppData\Local\Brasmotor_1

The problem occurs when a person from another computer tries to play. The game does not create any ini files.
Even placing the ini files in the zipped file that I put the game on, it gives an error. Because the ini files don't go to a directory that the game can read.
I would like to know how to make my executable create or move the ini files to a directory where the files can be read.

EDIT 1
How do I create the ini files:
ini_open("config.ini");
    arkivoIdioma=ini_read_string("jogoIdioma","arkivoIdioma","");
    dadosNum=ini_read_real("dadosNum","dadosNum",1);
    paradaModo=ini_read_string("paradaModo","modo","automatico");
    paradaPorcAutomatico=ini_read_real("paradaPorcAutomatico","porcentagem",10);
    paradaPorcAviso=ini_read_real("paradaPorcAviso","porcentagem",10);
ini_close();

Searching about, I found something explanatory about the directory:

The ini files get created. Probably you are not looking in the right
place for it. The ini file get created in
%AppData%/Local/"YourGameNameHere" folder, that's where you'll find
all the files you save.

BY JM DG.
LINK:
https://www.reddit.com/r/gamemaker/comments/5d6pf0/how_do_i_create_a_new_ini_file/
Error obtained by a user:

A little earlier, I made a change to the line of this script. I will wait for this user to test again to see if the error has been resolved.


texts: Algorithm to see if two voxels are interconnected

texts:
I'm looking for a good algorithms for the following problem: Given a 3D grid of voxels (which may be either empty or filled), if I pick two non-adjacent voxels, I want to know if they are connected to each other by other voxels.

For example (to illustrate the situation in 2D), where # is a filled square:

  1 2 3
a # # #
b # #
c # # #

If I pick a3 and c3, I want to determine as quickly as possible if they they are connected; if there is a path between a3 and c3 through filled pixels. (The real situation is in a 3D voxel grid, of course.)

I've looked at floodfill algorithms and path finding algorithms, but I'm not sure which to choose. Both do unneccesary work: Flood fill tries to fill all voxels, but this is not needed. Path-finding algorithms are usually concerned with finding the shortest path, which is also not necessary. I only need to know if there is a path.

What algorithm should I be using?

Edit: based on the comments, I think should add the following: the content of the voxels are not known in advance, and also, the algorithm is needed to detect if removal (emptying) of a voxel would cause the group of voxels to break into two or more smaller groups.


texts: Why is my collision code blocking the player's movement in XNA?

texts:
I have the following code to check for collisions in my game, but this code doesn't work it as should. For example:

I go from up to down and if collision is detect I can't turn right;
if I go from right to left and collision is detect I can't turn down.

What is wrong with this code and how could I improve it?

foreach (var o in ObjectList) {
    previousPosition = player.Position;
    if (player.CollisionRectangle.Intersects(o.Rectangle) && o.isCollision == true) {
        if (o.ObjectUpdateLeftRight(player, o.Position) == 0) player.CanRight = false;
        if (o.ObjectUpdateLeftRight(player, o.Position) == 1) player.CanLeft = false;
        if (o.ObjectUpdateUpDown(player, o.Position) == 2) player.CanUp = false;
        if (o.ObjectUpdateUpDown(player, o.Position) == 3) player.CanDown = false;
    }
}

and ObjectUpdateLeftRight and UpDown:

public int ObjectUpdateLeftRight(Player.Player player, Vector2 objectToCheck) {
    if (player.Position.X < objectToCheck.X) return 0; // right
    if (player.Position.X >= objectToCheck.X) return 1; // left
    return -1;
}

public int ObjectUpdateUpDown(Player.Player player, Vector2 objectToCheck) {
    if (player.Position.Y >= objectToCheck.Y) return 2; // up
    if (player.Position.Y < objectToCheck.Y) return 3; // down
    return -1;
}


texts: Setting time for a particular action to be happened-LibGdx

texts:
In my LibGdx game,enemies are coming in to the screen one by one.

I want to make enemeies appear at a particular time after the game starts.

How can I do it efficiently?


texts: Why doesn't my Pygame game scroll properly?

texts:
When I am clicking the arrow keys, in order to scroll my ground and my lucky block, I cant just press the key and it keeps on going scroll. So I need to press the key every second to get a kinda smooth scroll.

from os import environ
environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
import pygame
import config
import spriteSheetLoader as sSL

# Some standard setup variables
scr = config.SCREEN_SIZES[:]
capt = config.CAPTION
clock = pygame.time.Clock()

# load image
sheet = pygame.image.load('img/tiles.png')
sheet = pygame.transform.scale2x(sheet)
tiles = {
    "brown-broken-wall": sSL.loadTileInfo(0, 0),
    "brown-wall": sSL.loadTileInfo(0, 1),
    "lucky-block": sSL.loadTileInfo(0, 24)
}
ground = []
tiles_pos = []
setted = False

pygame.init()

# Setting up our window
win = pygame.display.set_mode((scr[0], scr[1]))
pygame.display.set_caption(capt)

def setup_ground():
    for i in range(15, 22):
        for j in range(0, 50):
            ground.append([j * 32, i * 32, tiles["brown-broken-wall"]])
    tiles_pos.append([14*32, 10*32, tiles["lucky-block"]])
    tiles_pos.extend(ground)

def draw():
    global setted

    win.fill((62, 152, 255))
    if not setted:
        setup_ground()
        setted = True
    for i in tiles_pos:
        win.blit(sheet, (i[0], i[1]), (i[2][0], i[2][1], 32, 32))

    pygame.display.update()

while True:
    clock.tick(40)
    keys = pygame.key.get_pressed()

    draw()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()
        elif keys[pygame.K_RIGHT]:
            for i in tiles_pos:
                i[0] -= 15
        elif keys[pygame.K_LEFT]:
            for i in tiles_pos:
                i[0] += 15


texts: How to stop camera from rotating in 2.5d platformer

texts:
I'm stuck with a problem: I can not make my camera stop rotating after character.

What I already have tried: using empty game object with rigid body and locked rotation and make it parent of camera, while player being the parent of object.
Also, I've tried using few scripts from web, that did not help.

Right now I'm bad with using JS in Unity (can handle JS on website, but I dont know how to integrate it for now) and practicing the basics, making easy 2.5d platformer with basic features, so I can not write code for now.


texts: Player stats include additional attribute

texts:
I am currently running a role-playing game called DNDBBS and would like to know: If there is stats for Strength, Intelligence, Wisdom, Dexterity, Constitution, Piety, should there be one for Charisma? Is this standard DND?

Edited: 07/31/2018 11:00:00 CST:

The DNDBBS is a Modem (POTS) oriented multi-node text based Adventure game. It can be found on google or http://www.filegate.net/pdnbasic/

Edited: 08/03/2018 21:25:00 CST:

I decided to also add Beauty and Glamour for Lady class.


texts:
I am trying to do a snake game in XNA but I have some little problems...

I explain :

The Snake has a direction (Enum Type : Haut(=up), Bas(=down), Droite(=right), Gauche(=left))
When the player press a direction key this funcion is used :

public void SetDirection(Direction newDirection) // Teste les directions impossibles => impossible de faire un demi tour
{
    if (_direction == Direction.Haut && newDirection == Direction.Bas)
    {
        return;
    }
    else if (_direction == Direction.Bas && newDirection == Direction.Haut)
    {
        return;
    }
    else if (_direction == Direction.Gauche && newDirection == Direction.Droite)
    {
        return;
    }
    else if (_direction == Direction.Droite && newDirection == Direction.Gauche)
    {
        return;
    }
    _direction = newDirection;
}

In theory, the snake can't make a U-turn.
But it does not work properly (I will try to explain why) :

The snake moves each 100ms. while these 100ms, the snake is waiting for a direction.
BUT if the snake goes up for example, and if the user presses {Droite(=right), Bas(=down)} or {Gauche(=left), Bas(=down)} while these 100ms, the snake makes a U-turn, and die because he cuts himself.

As a consequence, the user loose the game...

I can't see how to solve this problem.

If I am not clear or if you need any other information, please let me know.

Thanks in advance for your help

PS : I am sorry for the grammar faults but I don't speak perfectly english... :)

PPS : Here is the call to setDirection :

case GameState.Infini:
    if (newKeyboardState.IsKeyDown(Keys.Escape))
    {
        CurrentGameState = GameState.Pause;
    }
    else if (newKeyboardState.IsKeyDown(Keys.Up))
    {
        _snake.SetDirection(Direction.Haut);
    }
    else if (newKeyboardState.IsKeyDown(Keys.Down))
    {
        _snake.SetDirection(Direction.Bas);
    }
    else if (newKeyboardState.IsKeyDown(Keys.Left))
    {
        _snake.SetDirection(Direction.Gauche);
    }
    else if (newKeyboardState.IsKeyDown(Keys.Right))
    {
        _snake.SetDirection(Direction.Droite);
    }


texts: Force Unity To not use computer gpu for testing purpose

texts: I want to check that how my game behaving in GPU less pc. For this reason, i want to ask that is there any way to test it? Currently, i am using two pc for this purpose. One is without the GPU. Can i use my same pc and force unity to not use GPU?


texts: Why am I having these weird framerate issues with OpenGL on Windows?

texts:
I'm using OpenGL on windows (have been for a while now), and I've come across a strange issue.

Once every so often, the rate at which frames are presented on the screen drops to roughly 10 fps. However, my framerate counter stays at the usual framerate (2000fps in the menu, 300fps in game).

My framerate counter is based on the time between draw calls, so the graphics card is definitly rendering 2000 frames a second.

What is the problem? How can I fix it?

EDIT: I forgot to mention, this only happens when running in windowed mode.


texts: how to prevent a ball from bouncing only vertically

texts: I am trying to make a ball bounce off (and also sideways) when it gets into contact with another object. I am having an issue shown in the image below, where the ball rests on the triangle instead of falling off sideways. I tried playing round values for the bounciness and friction, but that didn't solve my issue. How can I solve this issue. I've added the inspector settings on the ball.


texts: Is it more efficient to render full size with AA, or scaled down with no AA?

texts:
Which is more resource-efficient (given a typical modern 3D game scene):

Rendering it at 100% scale with anti-aliasing, or
Rendering it larger and scaling it down to fit the screen, but without AA?

The idea is that anti-aliasing is a really expensive operation and avoiding it makes things faster. Is this the case?

I haven't had the opportunity to try it, since I work almost exclusively with 2D games.


texts: Correct way to handle path-finding collision matrix

texts:
Here is an example of me utilizing path finding.  The red grid represents the grid utilized by my A* library to locate a distance.  This picture is only an example, currently it is all calculated on the 1x1 pixel level (pretty darn laggy).

I want to make it so that the farther I click, the less accurate it will be (split the map into larger grid pieces).  Edit:  as mentioned by Eric, this is not a required game mechanic.  I am perfectly fine with any method that allows me to make this accurate while still fast.  This isn't the really the topic of this question though.   The problem I have is, my current library uses a two dimensional grid of integers.  The higher the number in a cell, the more resistance for that grid tile.  Currently I'm setting all unwalkable spots to Integer Max.

Here is an example of what I want:

I'm just not sure how I should set up the arrays of integers of the grid.  Every time an element is added/removed to/from the game, it's collision details are updated in the table.

Here is a picture of what the map looks like on my collision layer:

I probably shouldn't be creating new arrays every time I have to do a path find because my game needs to support tons of PF at the same time.

Should I have multiple arrays that are all updated when the dynamic elements are updated (a building is built/a building is destroyed).

The problem I see with this is that it will probably make the creation and destruction of buildings a little more laggy than I would want because it would be setting the collision grid for each built in accuracy level.  I would also have to add more/remove some arrays if I ever in the future changed the map size.

Should I generate the new array based on an accuracy value every time I need to PF?

The problem I see with this is that it will probably make any form of PF just as laggy because it will have to search through a MapWidth x MapHeight number of cells to shrink it all down.

Or is there a better way?  I'm certainly not the best at optimizing really anything.  I've just started dealing with XNA so I'm not used to having optimization code really doing much of an affect until now... :(

If you need code examples, please ask.  I'll add it as an edit.

EDIT:

While this doesn't directly relate to the question, I figure the more information I provide, the better.  To keep your units from moving as accurately to the players desired position, I've decided that once the unit PFs over to the less accurate grid piece, it will then PF on a more accurate level to the exact position requested.


texts: Keep player within screen bounds, top down shooter

texts:
I am using x and z axis to go left/right ; up/down respectively. The Camera is on the y-axis.

I have the following code so far -

private float playerWidth;
    private float playerDepth;

private Vector2 screenBounds;

// Other Variables and Initiators

// Start is called before the first frame update
void Start()
{
    playerRigidbody = GetComponent<Rigidbody>();
    screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
    //gives x and y values that will be half the screen value. Screen coordinate system is reversed, so these will be negative values
    playerWidth = transform.GetComponent<BoxCollider>().bounds.size.x / 2;
    playerDepth = transform.GetComponent<BoxCollider>().bounds.size.z / 2;
    // we need half the size as we already are at the center of the object, using clamp
}

Tutorials are using SpriteRenderer as this would make more sense in a 2D game, however I am working in 3D space, creating a 2.5D effect.

private void LateUpdate()
    {
        withinScreenBounds();
    }

private void withinScreenBounds()
{
    // check if player does not exceed camera view, else stop all movement.
    Vector3 viewPos = transform.position;
    viewPos.x = Mathf.Clamp(viewPos.x, screenBounds.x + playerWidth, screenBounds.x * -1 - playerWidth);
    viewPos.z = Mathf.Clamp(viewPos.z, screenBounds.y + playerDepth, screenBounds.y * -1 - playerDepth);
    transform.position = viewPos;
    // the above will work with the center of the tank.
}

The tank is currently jittering between screenpoints, not sure if this has to do with the boxcollider itself.


texts: Handling player/background movements in 2D games

texts:
Suppose you have your animated character controlled by the player and a 2D world (like the old 2D side-scrolling games). When the user presses right on the keyboard, the background is moved to the right. If the path is always horizontal, this is simple to do (incrementation/decrementation of the x-coordinate).

But suppose that the path is instead a polygonal chain. My questions are:

How do you move the background?
How do you move the background if the game objects are managed with a physics engine like box2D?

Note.

What I wanted to ask is, how do you move a 2D character in a side-scroller?
For example, consider the following path:

A---------B     C'--------D'
           \
            \C__________D

You start from A, move horizontally to B, then move diagonally to C, then move horizontally to D OR, from B, jump on C' and continue till D' and so on.


texts: Programmers/Designers: working with artists

texts:
Expanding on this question, what information do I need to communicate my artistic goals for a game to a professional artist?

Assuming I'm an indie programmer. and I've found or hired an artist to for my game, how to I go about setting a template or a brief for the look and feel of my game?


texts: Making a backup of my game and it says it can't find the UnityLockfile?

texts:
I am trying to make a backup copy of my game that I have been working on for the past 3 years and I have it saved on an external hard drive and I want to put a copy onto my desktop.

The files and game is copying just fine until it reaches the same issue:

"Item not Found.
Could not find this item
This is no longer located in F:/Gamefolder/Gamename/Temp. Verify the item's location and try again."

I follow the path and don't see any folder called Temp and I don't recall one being there either but what also bothers me is when I tried it earlier, it said it couldn't copy it because it was open in Unity, long after I close it(and I checked task manager to be sure)

Does anyone know what this file is or what it does? Also I've put the metadata on so that the game opens normally without me having to set up everything again. Does anyone know if this is necessary to do that?

I'm not a beginner but I'm not a pro, I learn as I go so if any screenshots could be provided they would be a massive help :)


texts: Custom Physics: Preventing objects from losing velocity in certain situation

texts:
Illustration:
http://s22.postimg.org/7agd30vap/Untitled.png

So the little box is my character. The red arrow shows the current velocity(Some force to right + gravity).
Below it are 2 blocks which has the same height. The problem is that my algorithm would false solve the collision normals.(You can see them in green).
These would mean that my character would not slide, but will stop in one place.

I'm following this tutorial: http://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331

Is there something I miss and how can I fix this problem?


texts: Persisting high score table in flash game without a network. (Featuring: HttpListenerException)

texts:
this question is very programming-centric, but it's for a game so I figured I might as well post it here.

I'm doing polishing work on a GGJ '11 game because it will be shown at an indie arcade tomorrow afternoon, and they're expecting our final build in the morning.

We'd like to have a high score table that displays during attract mode, but since it's Flash (Flixel) it would require some networking, Mochi, or something to keep a record of these scores. Only problem is the machine we'd be running on probably won't have network access.

As a quick solution, I thought I'd just write up a dinky little high score server in C#/.NET that could take basic GET requests for submitting scores and getting the score list. We're talking REAL basic, like blocking while waiting for an incoming request, run & forget console app, etc.

There's no guarantee that our .swf won't get reloaded, and we'd like the scores to persist, so this server would pretty much exists to keep a safe copy of the scores that the game can add to and request, and occasionally the server will write the scores to a flat text file.

But, HttpListener is giving me Error Code 87 'The parameter is incorrect.' Have any idea what I'm doing wrong? Or better yet, am I barking up the wrong tree and missing an obviously simpler solution?

This is all I've got so far in my Main():

HttpListener listener = new HttpListener();
listener.Prefixes.Add("http://localhost:66666/");
listener.Start();

The exception happens at listener.Start(); and the stack trace is:

   at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at WOSEBCE_ScoreServer.Program.Main(String[] args) in C:\Users\Michael\Documents\Visual Studio 2010\VS2010 Projects\WOSEBCE_ScoreServer\WOSEBCE_ScoreServer\Program.cs:line 24
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()


texts: UNET Performance of (many) Kinematic Rigidbodies

texts:
I am building a game in Unity in C# using the UNET networking elements.

I am trying to figure out what is the performance cost of kinematic rigidbodies?

My understanding is that, when kinematic, rigidbodies are outside the physics system and therefore are not as resource-heavy as non-kinematic rigidbodies.

For my game, I will need to use a lot of kinematic rigidbodies in the scene, because they are used to detect collisions between player-placed objects (with box colliders) and the rigidbodies. All the objects instantiated in the scene will therefore need a kinematic rigidbody to allow this collision checking to take place.

Thanks very much for your help.


texts: Microsoft and media - using the new stuff

texts:
Over the past 5 or so years, Microsoft has released APIs / that is intended to replace older APIs:

(2006) Direct3D10
(2009) Direct3D11
(2008) XAudio2 / deprecates DirectSound
(2006) Windows Media Foundation / replaces DirectShow

But 66% of Windows users are still on Windows XP as of Oct 2010.

Win XP doesn't and won't have:

Windows Media Foundation
Direct2D
DirectWrite
D3D10
D3D11

There's a lot of cool stuff in these API's!  My question is is there any point, as a game dev, in migrating to the newer technology while you still have to support the old technology and provide a similar gaming experience?

Microsofts refusal to support D3D 11 on XP means there are some cool shader FX that are only supported on Windows 7 machines, such as geometry shaders

http://knol.google.com/k/-/-/2lijysgth48w1/8oyyfu/image2.png

But its generally not that acceptable to say something like "Hey those cool geometry shader FX only show up if you're running Windows 7!"  Suddenly you as a game developer are part of the angry microsoft upgrade push.

UPGRADE YOUR SYSTEM SO YOU CAN PLAY THE GAME!

love,
Microsoft

My point is, if I write code for D3D11, and then I'm going to have to double-up and dupe the rendering code on D3D9 and work extra hard to manually reproduce the stuff that APIs like DirectWrite do for me so easily, why should I bother learning D3D11 at all?


texts: Unity HDRP transparent material back-face rendering/front face culling

texts:
I try to render an object with 2 different transparent materials. One should only render the back faces (higher opacity/more color) and one only the front faces (lower opacity/less color). The purpose is to show another object inside the mesh better, while keeping the more saturated color on the back faces.
I tried to only render the back faces using a  shader graph, but it seems to be impossible to only render back faces with TRANSPARENT material. With opaque materials, it was not a problem to isolate the back faces.
Is there a way to only render back faces of a transparent material, and overlap them with another material that only renders front faces?
(btw. this is the model, I need it for. The bones should pretty much preserve their details/color, while the jello is a rich green (screenshot from blender))

Any help is very appreciated!
Thank you!


texts: What is scripting, and what is a scripting API? Is scripting the process of writing the game program, and is the scripting API (such as the Unity scripting API) the API provided by the game engine, which we use to create games?


texts: RTS Unit AI: When to let the unit stop (due to local avoidence)

texts:
I am developing an RTS-like game, that have units that move and attack.
I implemented path-finding and local-avoidance.

One problem is when multiple units being ordered to the exact same position, they can never reach the position due local-avoidance and collision.

Only this will make the units scratch each other, this will also cause the unit not able to STOP, as the unit might be still far from the target position.
And whether stopped or not is important for battle (unit can only attack when stopped).

I studied how SC2 handles this, it appears that the units will stop after a few seconds of scratching.

PS, I have used group formation to avoid the situation, but it can not be avoided, when the group are ordered to goto some impossible position, and they would cluster at the edge of the valid navmesh.


texts: vec4 for vec3 multiplication while calculating the specular value

texts:
I'm following this tutorial to calculate the specular color of a vertex.

I use OpenGL 2.1 with GLSL version 120.

This is the formula that I apply:

  spec= (R*eye)^s * Ls * Lm

With:

  L= direction vector light-vertex;
  N= vector normal;
  eye= direction vector vertex-eye;
  R= -2N * (L*N) + L;

Now the problem is that following this way I need to multiply a vec3 for a vec4.

This is what I tried to do:

vec4 L= normalize(gl_LightSource[0].position - gl_Position);
vec3 N= normalize (gl_NormalMatrix * gl_Normal);
vec4 eye= normalize(-gl_Position);
vec4 R= -2.0*N*(L*N)+L;  // Syntax error: N is a vec3
vec4 spec= (R*eye)* gl_LightSource[0].specular;

I wouldn't get a vec3 result when calculating the specular value, this value I would be ignoring the alpha value. How do I go around this?


texts: How to perform efficient 2D picking in HTML5?

texts:
I'm currently using an R-Tree for both picking and collision testing. Each entity on screen has a bounding box for collisions and a separate one for picking. Since entities may change position very frequently, both trees must be updated/reordered once per frame.

While this is very efficient for collisions, because the tree is used in hundreds of collision queries every frame, I'm finding it too costly for picking, because it only gets queried when the user clicks, thus leading to a lot of wasted tree updates.

What would be a more efficient way to implement picking without as much overhead?


texts:
I was doing an OpenGL display, where I render in an opengl context (GLUT).

But now I would like to integrate it into a big project that does not use the Qt OpenGL API at all (QGLWidget, QOpenGLWidget, …).

So I would have to display on QWidget for example using the function glTexImage2D () because it can take a Qimage input ((GLvoid *) Qimage.bits ())


texts: Animation conversion failed: transform for bone not found?

texts:
I'm trying to animate my first humanoid, and the animations in the Standard Assets pack (HumanoidIdle etc) work really well right out of the box. However, when I try to use other fbx files, like those in Unity's "Raw MoCap Data" pack, I get errors.

I import the animations, select one, go to "Edit…" and go to "Rig", select "Humanoid", copy the avatar definition from the character I'm trying to animate (e.g. Robot Kyle), and under "Animations" I will get an error like "Imported file RunBackward conversion failed: Transform 'Left_Thigh_Joint_01' for human bone 'LeftUpperLeg' not found". When I compare the avatar of the character I'm trying to animate with the avatar that comes with the animations, they have the same bones defined, just with different names (which shouldn't matter, right?), so it's not that bones are missing. Using the animation with the default avatar also doesn't work, I get no error but my character goes into the first frame of the animation but then freezes. I've tried this with the standard models Ethan and Robot Kyle to the same effect.

Does anyone know how to handle this import error?


texts: Why is my spherecast returning an incorrect hit on mesh collider?

texts:
I have a mesh collider that is largely a flat plane facing up. Any SphereCast against that surface should return a normal of Vector3(0, 1, 0), but that isn't always happening. When near an edge on the mesh, the cast will penetrate the face and register the hit against the edge as if it was a corner when it's really just a polygon edge on a flat surface This is giving me inaccurate hit points and normals.

Hopefully the image above is interpretable. The light blue circle is where the SphereCast should stop and the pink circle is where it seems to be stopping. Instead of hitting the face (horizontal black line) and returning the proper normal (green line), it's ignoring the face and hitting the tri's edge (diagonal black line) and returning a lerped normal (red line) as if it were a corner.

Is the SphereCast that inaccurate against mesh colliders, or am I doing something wrong? Is there anything I can do to fix this?

Edit: I've added a screenshot to illustrate exactly what's happening. The black line/sphere are the cast, the green line is what the normal should be, the red line is the normal the SphereCast is returning. The normals differ by as much as 0.05m. The mesh is the default plane mesh. It seems like when the cast hits near a polygon edge, it snaps to the edge, giving an incorrect hit point and normal.


texts: Vector problem: which one is the left / centre / right one?

texts:
In aviation, runways are named according to their magnetic orientation seen from the pilot's perspective. For example: a strip of asphalt oriented along the east-west axis will be named 9 for the pilot coming from west (east is at 90° from North) and 27 for a pilot coming from east (west is 270° from North).

When several runways have the same orientation, the naming convention uses letters L/C/R for distinguishing between the Left/Centre/Right ones (look at the 22 runways in the capture above).

In the game I'm coding, I chose to describe runways by the following three attributes:

Orientation (between 0° and 180°).
Position of their geometrical centre relative to the aeroport one.
Length

With this data I'm able to generate all the touchdown points and give them the correct number, but I can't find a straightforward method to assign the correct letter, as I could not think to a straightforward way to mathematically determine which one is "left/centre/right" from a "landing pilot's perspective".

So the question is:

  Is there a simple, straightforward vector formula that - given two
  parallel vectors pointing in the same direction - will return the
  leftmost (or rightmost) one?

Please note that this question is really about the straightforwardness of the formula, as I already found a non-straightforward way to get the result, but I would like to find a more elegant way to solve the problem.

Many thanks in advance for your expertise and contributions!


texts:
So in unity I have some weird squares on surfaces of certain objects, which are buildings represented by planes:

I don't know what causes it, I tried changing some settings in lighting and material, but couldn't fix it. This only occurs with one object which is a few planes representing buildings temporarily. The lighting is baked (one directional light).
 Here's the screenshots of lighting and materials tab:

Does anyone know what could be the problem and how I can fix it?
Ask for more information if needed.
Thanks.

EDIT: The buildings were imported from blender.


texts: When should I use OnPointerClick vs. Input.GetMouseButton?

texts:
In all games I wrote so far, I used Input.GetMouseButton or Input.GetMouseButtonDown inside Update to detect mouse clicks.
Now I learned that there is another way - I can make my component implement IPointerClickHandler, and implement the method OnPointerClick.
What is the difference between these two input methods? When is it recommended to  use one vs. other?


texts: Map and fill texture using PBO (OpenGL 3.3)

texts:
I'm learning OpenGL 3.3 trying to do the following (as it is done in D3D)...

Create Texture of Width, Height, Pixel Format
Map texture memory
Loop write pixels
Unmap texture memory
Set Texture
Render

Right now though it renders as if the entire texture is black.

I can't find a reliable source for information on how to do this though. Almost every tutorial I've found just uses glTexSubImage2D and passes a pointer to memory.

Here is basically what my code does... (In this case it is generating an 1-byte Alpha Only texture but it is rendering it as the red channel for debugging)

GLuint pixelBufferID;
glGenBuffers(1, &pixelBufferID);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelBufferID);
glBufferData(GL_PIXEL_UNPACK_BUFFER, 512 * 512 * 1, nullptr, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 512, 512, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);

glBindTexture(GL_TEXTURE_2D, textureID);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelBufferID);
void *Memory = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
// Memory copied here, I know  this is valid because it is the same loop as in my working D3D version
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

And then here is the render loop.

// This chunk left in for completeness
glUseProgram(glProgramId);
glBindVertexArray(glVertexArrayId);
glBindBuffer(GL_ARRAY_BUFFER, glVertexBufferId);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 20, 0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 20, 12);
GLuint transformLocationID = glGetUniformLocation(3, 'transform');
glUniformMatrix4fv(transformLocationID , 1, true, somematrix)

// Not sure if this is all I need to do
glBindTexture(GL_TEXTURE_2D, pTex->glTextureId);
GLuint textureLocationID = glGetUniformLocation(glProgramId, "texture");
glUniform1i(textureLocationID, 0);

glDrawArrays(GL_TRIANGLES, Offset*3, Triangles*3);

Vertex Shader

#version 330 core

in vec3 Position;
in vec2 TexCoords;
out vec2 TexOut;
uniform mat4 transform;

void main()
{
    TexOut = TexCoords;
    gl_Position = vec4(Position, 1.0) * transform;
}

Pixel Shader

#version 330 core

uniform sampler2D texture;
in vec2 TexCoords;
out vec4 fragColor;

void main()
{
   // Output color
   fragColor.r = texture2D(texture, TexCoords).r;
   fragColor.g = 0.0f;
   fragColor.b = 0.0f;
   fragColor.a = 1.0;
}


texts:
I want to create something like a game but I am going to use Direct2D and GDI for drawing API.My problem is that I want to separate drawing code from objects. For example lets say I have conduit objects and pumps.Each one might have different color and vector shape. I mean problem here is that drawing a pipe wont be a texure but a series of commands like drawline , drawrectangle etc.The only way I can think of having a Renderer class that would have drawing logic for each one.But in case I want it to be extendable from another developer then in order to add a new object they should extend renderer.
My question is  since I am not going to use classic game things like sprites,textures etc how can drawing complex vector objects be abstracted? And how can I make it extendable ?


texts: How to check if an GameObject exists in Unity2D? (Javascript)

texts: Im making an AI that checks if the player exists or not. How do I check if a certain object exists and put it in a boolean variable?


texts:
I have a problem, my camera is parented to the FPS Controller prefab, then there is a script I wrote for the rotation of the player horizontally by mouse movement, it all works but the rotation is very choppy and not smooth. How can I have the camera rotating smoothly or should I not parent my camera to the FPS Controller at all and make the rotation through scripting if so then how?

here's the script of character rotation:

void Update () {
    float rotationY = Input.GetAxis ("Mouse X") * 50f;
    transform.Rotate (0, rotationY, 0);

}


texts: 2D games on Unity and collision detection performance

texts:
I'm developing a 2D game for the iOS platform. I have seen a lot of packages on asset store that makes 2D asset creation for unity easier.

I have narrowed my selection to just 2, 2d toolkit and ex2d. I have to test them and see with fits my workflow better (if anyone has an useful opinion I'm all ears). But my main concern is how to do the collision detection in unity for this kind of games.

My game is a side scroller and I want it to have slopes. I have done this in my own engines using tile height maps, etc... but unity doesn't support all this, but it has a physic engine. Do you think unity own physics engine will be ok for a game like this? I really need a good control on player collision to achieve a nice playability, so, I'm a bit sceptic if I will be able to do it using the physic engine, perhaps, because of my poor knowledge on this subject.

I have thought about rolling my own 2D cuad collider and do my own collision detection on the fixed update call but not sure either if it will be faster that the built-in physics engine because unity3d could be just optimised to use its own collision system.

What do you think?


texts: How do I use the Steamworks API to check if a DLC is installed?

texts:
I've developed a game through Unity and now I'm stuck with making DLC work. I want to distribute additional scenarios for a game as a DLC and from the various comments I've seen the best way seems to be to add the scenarios pack to the game through an update and then activate it only for those players who bought the DLC. I have installed Steamworks.NET. I am distributing through Steam and I found the following in Steamworks:
static bool IsDlcInstalled( AppId appid )

I would assume that the script that would go into a script that manages the various scenarios would look something like this:
 void CheckIfDlcInstalled()
 {
    if (!SteamManager.Initialized)
    { return; }
    if(something something something == true)
       DLCScenarios.SetActive(true);
 }

I though that the following would go into the if-statement, but I get an error message:
  if (SteamApps.BIsDlcInstalled(534270))   error: "cannot convert from int to Steamworks.AppId_t"

Or am I completely on the wrong path here?
I have also looked at asset bundles - but that doesn't really work because the scenarios include scripts and you can't add those to an asset bundle.


texts: How often should I do a spatial partition over a top down MMO 2D game?

texts: I am writing an top down 2D game like agario/diep.io and I am using spatial hashing for detecting on screen objects. However I find it is too expensive to do a spatial partition a few times a second. (I do it at an interval of 250ms) I have about 5000 objects on the map and 150 objects on screen on average at the same time. I find a post by agario developer on reddit.com which mentioned that we can do spatial partition less often by tracking the player's position and do object insertion on a specific node (using quadtree). I wonder if this can be done using spatial hashing too.


texts: How to deal with overlapping black parts of Light mask textures?

texts:
I am using this masking texture for a dynamic lighting effect in my game:

It looks beautiful until two lights begin to overlap:

This is obviously because the textures are overlapping when I draw them to the light map FrameBuffer.

lightFbo.begin();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            g.begin();

                for(Entity ent : entities){
                    if(ent instanceof Fireball)g.draw(light,ent.x - tlightSize / 2.5f,ent.y - tlightSize * 0.25f, tlightSize, tlightSize);
                }
            if(p instanceof FireCharacter){
                g.draw(light,p.x - lightSize / 2.5f,p.y - lightSize * 0.25f, lightSize, lightSize);

            }
g.end();
lightFbo.end();

I use the buffer texture from this map when I draw my actual game:'

g.setShader(lightingShader);
g.begin();
lightFbo.getColorBufferTexture().bind(1); //u_lightmap
light.bind(0)//u_texture
//draw things
g.end();

I don't want these to overlap, I want the light circles to merge without the border cutting in front of them. I tried making the black transparent in GIMP on the light texture but that made no difference. Here is the lighting shader:

Vertex Shader

attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 vColor;
varying vec2 vTexCoord;

void main() {
    vColor = a_color;
    vTexCoord = a_texCoord0;
    gl_Position = u_projTrans * a_position;
}

Fragment Shader

#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif

varying LOWP vec4 vColor;
varying vec2 vTexCoord;

//texture samplers
uniform sampler2D u_texture; //diffuse map
uniform sampler2D u_lightmap;   //light map (frame buffer texture)

//additional parameters for the shader
uniform vec2 resolution; //resolution of screen
uniform LOWP vec4 ambientColor; //ambient RGB, alpha channel is intensity

void main() {
vec4 diffuseColor = texture2D(u_texture, vTexCoord);
vec2 lighCoord = (gl_FragCoord.xy / resolution.xy);
vec4 light = texture2D(u_lightmap, lighCoord);

vec3 ambient = ambientColor.rgb * ambientColor.a;
vec3 intensity = ambient + light.rgb;
vec3 finalColor = diffuseColor.rgb * intensity;

gl_FragColor = vColor * vec4(finalColor, diffuseColor.a);
}

My only ideas are using Gdx.gl.glSetBlendFunc(); and changing the blending source and dest values.


texts: Sprites with same position rendered in different places on screen

texts:
In LibGDX I have few sprites that all have set position (0,0). So in theory they all should render in one place on top of each other but what ends up happening is that all the sprites are being rendered in different spot on screen. For all sprites objects all I do is:

Sprite sprite = new Sprite(new Texture("texture.png"));
sprite.setOriginCenter();
sprite.setScale(1/PPM);

And then when rendering it:

batch.begin();
sprite.draw(batch)
...
batch.end();

And here is what I get:

rocket sprite is in completely different place than fire sprite and some other sprites I couldn't even find. I marked "real" 0,0 point with yellow circle.
So why are does sprites in different spots? I've heard that it could be because of scaling but since I am setting sprite's origin to center it shouldn't be a problem, right?


texts: How do you categorize graphic designers for game development?

texts:
I have hired a graphic designer locally and she is good at drawing things (cartoons, characters, etc.) and good at using Photoshop and Illustrator.

However, when we come to game UIs (such as the dialogs, buttons, etc.), she is not doing ok.

For game development, do you categorize graphic designers? Do you need more than one kind of graphic designer? especially for a small team (4-5 people)?


texts: Keeping balance between widely different character classes

texts:
So I've been theory-crafting an idea for a game I think would be interesting, but I'm trying to work out the kinks in my idea. Here's my dilemma:

Let's say a player can choose between two classes, being a foot soldier or piloting a large vehicle like a tank. To keep gameplay diverse, there needs to be some players as foot soldiers and some as tanks. In games such as BF4, the individual soldier has so many anti-vehicle weapons that vehicles are actually somewhat weak. Is there a good way to balance classes such that an endgame infantry unit is equal(not inferior or superior) to a vehicle such as a tank or ship?

I was also thinking of an AI squad mechanic, where the player can command a small number of AI foot soldiers, so this might be worked into the balancing. I'm just trying to think of a way to have all classes be appealing to the player.


texts: Accesing child GameObjects of GameObject

texts:
I have already tried really much with all "GetChildren" and similar functions, but I haven't found out how to do it yet.

I have a GameObject named "koffer".
I have added several other GameObjects as children to it.

I have added a script to "koffer" in which I try to retrieve the children.
In this script I have stated this line:

    string sThis = this.name; //just for testing. "sThis" becomes "koffer", so it looks perfectly fine.
    foreach (GameObject g in this.GetComponentsInChildren<GameObject>()) // doesn't retrieve anything. So obviously I'm not doing it correctly.

However this doesn't retrieve anything.
Is this not the correct function for such a case?

Is there any built-in function to retrieve theses game obects?

I have found several custom made functions from some years ago, and I don't know if they are still needed or if Unity has integrated some functions for that.

What really bothers me is that there are so many custom-made functions that deal with "Transform" instead of "GameObject". Why would somebody need Transform instead of GameObject?

Thank you.


texts:
I want to start learning how to make games in XNA, but I have no idea where to start! If someone could advise me on what pieces of software I need and some good books or tutorials to look at, that would be most helpful.

As for my current coding knowledge, I have some good experience with Javascript (in conjunction with HTML5 canvas). I'm pretty sure I would also need to learn C# to code with XNA, so keep that in mind.


texts: I created a preview of my player camera with another camera but when disabling the main menu it show no cameras exist why?

texts:
I created a Render Texture named it : GUICameraRenderTexture

This is a screenshot of the Player camera :
I assigned to the Target Texture the new GUICameraRenderTexture :

Then on the bottom of the hierarchy I have a Main Menu > Camera :
The new Camera I changed the Clear Flags to Don't Clear and Culling Mask to Nothing :

Then there is a Canvas the Canvas Render Mode is set to Screen Space - Overlay

And last the Raw Image I assigned to the Texture the GUICameraRenderTexture :

The problem is either in the editor mode or in runtime where the game is running if I disable the new GUI Camera the camera under Main Menu it give error that there is no cameras to render even if the Player camera is enabled.

I want to start the game with the Player camera and then on escape key to switch to the main menu gui camera.

Screenshot if I'm disabling the main menu gui camera :


texts: How do I align the matrix used in SpriteBatch and the matrix used in BasicEffect?

texts:
I'm writing a Windows tool that uses XNA and allows the user to place textures on the screen.
I'm using a 'camera' for the SpriteBatch used to draw the textures, e.g:
Matrix matrixForSpriteBatch = Matrix.CreateTranslation(
    -_cameraPosition.X, -_cameraPosition.Y, 0.0f) *
Matrix.CreateRotationZ(_rotation) *
Matrix.CreateScale(_scale) *
Matrix.CreateTranslation(
     GraphicsDevice.Viewport.Width / 2,
     GraphicsDevice.Viewport.Height / 2, 0.0f);

This is working fine - the user can drop a texture onto the canvas and move, rotate and size it. They can also move the camera around to see more things.
What I now want to do is let the users click around to define points of a polygon.  These points are then sent to my DrawPolygonFilled method:
public void DrawPolygonFilled( SpriteBatch spriteBatch,
        Vector2[ ] worldPoints,
        Color color )
{
    Matrix matrixForVertices =
        Matrix.CreateTranslation( _cameraPosition.X, -_cameraPosition.Y, 0.0f ) *
            Matrix.CreateRotationZ( -rotation ) *
                Matrix.CreateScale( camera.Scale ) ;

    Vector2[] transformedPoints = worldPoints.Transform( matrixForVertices ) ;

    var vertices = new VertexPositionColor[ transformedPoints.Length ] ;

    for (int i = 0; i < transformedPoints.Length; i++)
    {
        vertices[ i ] = new VertexPositionColor( new Vector3( transformedPoints[ i ], 0 ), color ) ;
    }

    Vector2[ ] outputVertices ;
    short[ ] outputIndicies ;
    Vertices.Triangulate( transformedPoints, Vertices.WindingOrder.Clockwise, out outputVertices, out outputIndicies ) ;

    if (outputIndicies.Length > 0)
    {
        foreach( EffectPass pass in _basicEffect.CurrentTechnique.Passes )
        {
            pass.Apply( ) ;

            spriteBatch.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList,
                vertices,
                0,
                vertices.Length,
                outputIndicies,
                0,
                outputIndicies.Length /3 ) ;
        }
    }
}

This isn't displaying anything as the client space for BasicEffect is 0,0 at top-left, and 1-1 at bottom-right.
So I added this to BasicEffect:
_basicEffect = new BasicEffect( GraphicsDevice )
    {
        VertexColorEnabled = true
    } ;

_viewMatrix = Matrix.CreateLookAt(
    new Vector3( 0, 0, GraphicsDevice.Viewport.Width ),
    Vector3.Zero,
    Vector3.Up
    ) ;

_projectionMatrix = Matrix.CreateOrthographic(
    GraphicsDevice.Viewport.Width,
    GraphicsDevice.Viewport.Height,
    .1f,
    GraphicsDevice.Viewport.Width ) ;

_basicEffect.Projection = _projectionMatrix ;
_basicEffect.View = _viewMatrix ;

With this, the polygon is displayed but it's upside-down.  Also, when the position of the polygon changes (the user can drag the polygon around with the mouse), the polygon goes up when the user moves the mouse down!
I'm a bit thick (but trying to become less thick) when it comes to matrices and geometry.  Am I missing something?  I tried changing Down to Up in CreateLookAt but it still didn't draw correctly and now when the user mouses left, then polygon goes right!
Here's a screen-shot when drawing a polygon at 0,0:

The points on the white path are where the user clicked (and are drawn with SpriteBatch) and the yellow polygon is what's drawn by my method above.
Here's another screen-shot that show what happens when I move the polygon to 20,20:

The white path is drawn starting from 20,20, but the filled polygon is starting from 20,-20 and is drawn upside-down
I think this is a matrix issue between the matrix used by the SpriteBatch (to draw the white paths) and the matrix used by the BasicEffect (to draw the filled polygon).


texts: Working hours and productivity expectations for game artists and programmers

texts:
I have a startup with a limited budget and have recently hired a programmer and an artist. Before they started the project, I set down a project roadmap with a lot of good documentation on what needs to be done and deadlines.

Both were asked to produce a timeline as to how these deadlines would be met. For the artist, I mentioned that if the workload was too much, it might be possible to hire an additional contractor for a month or two while they need help.

I have already started hearing things like, "well, I might need some extra help with this," and "I'm not exactly sure how long it will take me right now, so these timelines are just very rough estimates." And I get it, they're trying not to set themselves up for failure, but as a manager, I also need to know what the heck is going on.

So, there are two questions here:

I frequently see both my hires using non-company Slack, answering phone messages, and doing life admin on my watch. They've turned up late more than once in the first week, when I have a company policy of being in at 9. Maybe this is unorthodox, but we're working on a big project, and the last thing I want is them turning around and accusing me of under-scoping the project. On the other hand, I realize that this might be the norm elsewhere, in larger companies. What can generally be expected from artists/programmers in terms of working style and productivity? What's the difference between flexibility and being lazy?
My artist has already started to refuse other work (work for marketing assets, etc) on the basis that they have a lot of work on their plate already and need to manage expectations. I could deal with this if I didn't see them coming in late, answering messages on Slack, and generally doing things that don't relate to work. On the other hand, I don't know if this is normal/necessary for creatives. Is it?

If it can help:

The studio is situated in Europe.
I have no written policy, but working hours are contractual obligations.
We're using agile project management.
We are 3 people working on the project. Both are "leads" so they make decisions related to their own fields – art and code


texts:
I am trying to capture the game play and store it on local memory without using any third party sdk's. I tried This Video Capture Script but i didn't get the recorded file even i don't know whether it's recording or not.

anybody please help me to complete the task. Thanks in Advance


texts: How can I generate 3D noise in chunks for terrain?

texts:
I'm trying to create a voxel engine that uses marching cubes to create smoothed terrain. I have most of it implemented, but I'm struggling with how I should create a noise function in three dimensions. I have a 2D Perlin noise generator implemented (or I could use the Unity built-in one, I guess). What can I use for 3D?

I'm also interested in the noise function being usable in chunks with uniform output. That way, with one seed, I could create a level in parts that would still all work properly.


texts: Trying to understand the XNA fixed time step game loop logic

texts:
I came across the blog post Understanding GameTime, and after lots of reading on fixed time steps in game loops this is the approach I would like to take. In summary, this is the logic from the post:

Set the desired time spent in Update + Draw as 1/60 of a second (fixed 60 fps).
If time elapsed since last Update + Draw is exactly 1/60 of a second:

Call Update
Call Draw
Tick (Game loops.)

If time elapsed since last Update + Draw takes less than 1/60 of a second:

Call Update
Call Draw
Look at the Clock (Time left over? Wait.)
Tick (Game loops.)

If time elapsed since last Update + Draw takes more than 1/60 of a second?

Call Update (Until we catch up.)
Call Draw
Tick (Game loops.)

I guess the two parts I'm having trouble understanding is in #3, how would the waiting be accomplished since thread sleeps are often not accurate enough, and what does it mean in #4 to call update until we catch up? Catch up to what since the time elapsed is already greater than our target 60 fps?


texts:
I created a simple scene, with a box that serves as the ground, and a capsule that serves as the player. I added to the player a RigidBody, and a component that should move it using AddForce:

private void FixedUpdate() {
    rb = GetComponent<Rigidbody>();
    float horizontal = Input.GetAxis("Horizontal");
    rb.AddForce(new Vector3(horizontal * forceSize, 0, 0), ForceMode.Force);
}

However, instead of moving straight along the ground, my capsule rolls over its head:

I tried to mark the checkbox near Freeze Rotation: Z in my RigidBody component, but then the capsule stopped moving altogether.

What is the correct way to apply force to the capsule?

EDIT: Initially, the physic material on both the player's collider and the ground collider was None. Now, I changed it to a new material with dynamic friction and static friction 0, and it moves straight (even with gravity and without freezing the Z rotation). However, if I even slightly increase either type of friction in either one of the materials, the player falls on its face again. Why does friction have this effect on the player? And how can I move the player correctly when there is positive friction?


texts: OpenGL ES 2.0: Highly variable time spent in GLES20.glDrawArrays(). How to find the cause?

texts:
How can I debug why the time take to issue exactly the same GL commands to render a frame, especially the call to GLES20.glDrawArrays(), is highly variable even when there is no garbage collection and no change in the scene? I'm developing for Android using Android Studio.

The slowest part of my render loop consists of rendering ~ 175 rectangles (2 triangles each) that are each transformed by a different matrix and each have a different texture. I'm using a VBO for the rectangle vertices and texture coordinates, however I load the matrix for each rectangle separately when I draw it. Since the images are up to 512x512 pixels each, I haven't bothered combining them into texture atlases. I could probably save memory bandwidth by mipmapping, but haven't done that yet.

All rectangles are currently draw using texture unit 0 (cycling through them doesn't seem to make a difference).

The main part of my onDrawFrame() code is:

for (int i = 0; i < images.length; i++) {
  int textureId = images[i].textureId;
  float[] modelMatrix = images[i].modelMatrix;
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
  GLES20.glUniformMatrix4fv(modelMatrixId, 1, false, modelMatrix, 0);
  GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 6);
}

I narrowed the variability down using System.nanoTime() measurements and found that the GLES20.glDrawArrays() call is the one with the most (but not all of the) variability: For a frame (175 calls), it averages about 3msec total but goes up to 8msec a couple of times per second, and 13msec every couple of seconds.

How can I find the cause of this variability?

My render loop doesn't allocate any objects, so there is no garbage collection. I also don't think it can be the data bandwidth between CPU and GPU because the glUniformMatrix4fv() call executes super quickly (always < 2msec).

I don't know how asynchronous the CPU-GPU communication is so I don't know how directly I can attribute slowness to particular method calls. That said, the glDrawArrays() call is the one that blocks (on the CPU) for the most, and for the most variable, amount of time.

Any ideas how to debug this?

PS. Since it was asked, here are my shaders:

Fragment shader:

precision mediump float;
uniform sampler2D textureMap;
varying vec2 fragmentTextureCoord;
void main() {
  gl_FragColor = texture2D(textureMap, fragmentTextureCoord);
}

Vertex shader:

uniform mat4 modelMatrix;
uniform mat4 viewProjectionMatrix;
attribute vec4 position;
attribute vec2 vertexTextureCoord;
varying vec2 fragmentTextureCoord;
void main() {
  gl_Position = viewProjectionMatrix
               * modelMatrix
               * position;
 fragmentTextureCoord = vertexTextureCoord;
}


texts: Unity2D 100x100 tile map, best practice?

texts:
I'm trying to create a top-down map in Unity2D, this map will act as an ocean that a 1 tile sized boat will drive across. I want to be able to generate this map programmatically by going through the grid to create shallow areas, spawn things, etc.

I've been reading it's not good practice to create game objects for each tile as there's so many. You can use object pooling but that sounds harder to manage. I've read that using a mesh map is the best way but no one follows up with the best way to implement it. Any clues to push me in the right direction?


texts: How can I log key presses in Game Maker?

texts:
I'm trying to create a log of a players actions as they play a game of Spelunky. The easiest I've found to do this is to log what keys are pressed at each frame. What I don't know how to do is how to integrate this with the Game Maker source code of Spelunky.

Is there a specific way to create a script that is checked every frame/tick (don't know the right term) and a command to find what buttons are pressed?


texts: Creating the Vertices and Triangle Indices for Voxel Generated Mesh

texts:
I am running into a problem with a compute shader I am writing to generate the vertices and triangle indices for a voxel generated mesh.
Currently, I am creating an AppendStructuredBuffer of triangle structs which just have the three vertices of a triangle and reading from the AppendStructuredBuffer to the CPU. When read to the CPU, I then read from the buffer and set it in a RWStructuredBuffer in the GPU. Following that, I run a compute shader kernel to parse the triangle buffer.
Obviously if I can do this all on the GPU I should since reading and writing between the CPU and GPU is expensive.
When trying to put it all in one kernel I run into problems however. Each voxel has a range of possible triangles (0-5) that can form in it. Because of that, I can't simply use the dispatch ID to put it in a RWStructuredBuffer (at least I don't think so). That's why using an AppendStructuredBuffer seems natural; it allows for the variable amount of triangles.
After getting the array of triangle vertices and array of triangle vertex indices, I bring them back to the CPU and set them to a mesh and render it. In the future I want to use a geometry shader to render the mesh since that is most likely more efficient, but I'm trying to take this one step at a time, and geometry shaders are a whole 'nother beast I know nothing about.


texts: How do I detect multiple sprite collisions when there are >10 sprites?

texts:
I making a small program to animate the astar algorithm. If you look at the image, there are lots of yellow cars moving around. Those can collide at any moment, could be just one or all of them could just stupidly crash into each other.

How do I detect all of those collisions? How do I find out which specific car has crash into which other car?

I understand that pygame has collision function, but it only detects one collision at a time and I'd have to specify which sprites.

Right now I am just trying to iterate through each sprite to see if there is collision:

for car1 in carlist:
    for car2 in carlist:
        collide(car1, car2);

This can't be the proper way to do it, if the car list goes to a huge number, a double loop will be too slow.


texts:
How to make textures fill all area as it is specified? I'm getting small gaps if the texture is smaller than area example: gl_quads setup like these:

-1f, 1f, 0,
-0.98f, 1f, 0,
-0.98f, -1f, 0,
-1f, -1f, 0

  I get this: http://i.stack.imgur.com/kWJnh.png

Red one's a texture, black is background, ignore it. Texture is imported by slick loader.

  Texture itself: http://i.stack.imgur.com/8x7ZH.png (in case someone
  will think it has gaps)

Do I need to use a glTexParameter somehow on it?
Added a rendering code down below:

//VertexArray initialization, vertexSize is 3, amountOfVertices is 8
private void initVertexArrays() {
    borderVertex = BufferUtils.createFloatBuffer(vertexSize
            * amountOfVertices);
    borderVertex.put(new float[] { -1f, 1f, 0, -0.98f, 1f, 0, -0.98f, -1f,
            0, -1f, -1f, 0 });
    borderVertex.flip();

    borderTextureVertex = BufferUtils.createFloatBuffer(vertexSize
            * amountOfVertices);
    borderTextureVertex.put(new float[] { -1f, 1f, 0, -0.98f, 1f, 0,
            -0.98f, -1f, 0, -1f, -1f, 0 });
    borderTextureVertex.flip();

    amountOfArrays = 2;
}
//VertexBufferObject initialization
private void initVBO() {
    borderVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, borderVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, borderVertex, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    borderTextureHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, borderTextureHandle);
    glBufferData(GL_ARRAY_BUFFER, borderTextureVertex, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}
//Texture loading with slick
private void setupTextures(){
    borderTexture = TextureDecoder.getTextureAt(borderTextureLocation,
            "PNG");
}
//Rendering part
public void draw() {
    borderTexture.bind();
    glBindBuffer(GL_ARRAY_BUFFER, borderVertexHandle);
    glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);

    glBindBuffer(GL_ARRAY_BUFFER, borderTextureHandle);
    glTexCoordPointer(vertexSize, GL_FLOAT, 0, 0);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glDrawArrays(GL_QUADS, 0, amountOfVertices * amountOfArrays);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}


texts:
I am trying to create an interpolate function for an animation library to achieve a tweening effect between frames.

I want this to work with Bezier curves. I have created a jsFiddle (here) of my progress so far.

I am trying to create a linear tween using this bezier definition:

{
    p0: new Vector(0,0), //Start point
    p1: new Vector(0,0), //Control point 1
    p2: new Vector(1,1), //Control point 2
    p3: new Vector(1,1)  //End point
}

I have implemented the interpolation function from this tutorial.

var u = 1 - t;
var tt = t*t;
var uu = u*u;
var uuu = uu * u;
var ttt = tt * t;

var p = p0.multiply(uuu);
p = p.add(p1.multiply(3 * uu * t));
p = p.add(p2.multiply(3 * u * tt));
p = p.add(p3.multiply(ttt));

The problem I am having is that when I run the function, the animation does not appear to be linear, but rather like 'ease-in-out'.

Ideally I would like the linear animation to work the same as this CSS transition.

Can anybody see why it is not animating in a linear fashion?


texts: What steps should I take to learn level design/programming?

texts:
I'm still in high school, and I've been playing games for 12 years, and I've always wanted to eventually learn level development and design, and programming. However I'm no good at art and as of now have absolutely no education what-so-ever about either of these things.

I was wondering which fields of study should I branch into in order to learn these things? Is it even reasonable to attempt to learn level creation if I'm no good at art anyway?


texts:
I wrote this script quickly just for moving across my map for testing purposes.  I created a prefab with this script on it and gave it the Destination GameObject which works fine, it teleports me as it should.  However when I attach this script to another object with an new destination, it still takes me to the one on the prefab.  What am I doing wrong?

public class TeleportationDevice : MonoBehaviour {
    public Transform destination;
    public GameObject interaction;
    public GameObject model;

    private GameObject player;
    private bool isInRange = false;

    void Update()
    {
        if (isInRange)
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                Teleport();
            }
        }
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            // Show the interaction canvas
            interaction.transform.position = model.transform.position;
            interaction.SetActive(true);

            // Set player GameObject
            player = other.gameObject;

            // Make sure the player is within range
            if (other.transform.position.x <= this.transform.position.x + 20f)
            {
                isInRange = true;
            }
            else
            {
                isInRange = false;
            }
        }
    }

    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
           interaction.SetActive(false);
        }
    }

    void Teleport()
    {
        player.transform.position = destination.position;
    }
  }


texts: Unity 2D switch direction in an auto runner

texts:
I'm new to Unity and I'm trying to make a 2d endless runner (something like Super Meat Boy Forever), and one idea was that when the player touches a wall he would change direction.
I tried to implement the mechanic, but in game is very strange and buggy. My idea was to change the speed value from positive to negative and vice versa when the character collides to a wall (I used a layer mask for that). If someone could help me I would be very grateful.
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour {

public float speed;
public float jumpForce;
private Rigidbody2D rb;
public bool grounded;
public bool walled;
public LayerMask whatIsGround;
public LayerMask whatIsWall;
private Collider2D myCollider;

// Start is called before the first frame update
void Start() {
    rb=GetComponent<Rigidbody2D>();
    myCollider=GetComponent<Collider2D>();
}

// Update is called once per frame
void Update() {
    grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);
    walled = Physics2D.IsTouchingLayers(myCollider, whatIsWall);
    rb.velocity = new Vector2(speed, rb.velocity.y);
    if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) {
        if (grounded) {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
        }
    }

    if (walled) {
       speed = -speed;
    }
}

}


texts: Good resources for learning about graphics hardware

texts:
I'm looking for some good learning resources for graphics hardware (and associated low level software). Basically I want to learn more about what goes on underneath the opengl/direcx API layers in terms of how things are implemented.

I familiar with what happens in principle during the various stages of the rendering pipeline (viewing, projection, clipping, rasterization etc).

My goal is to be able to make better and more informed decisions about tradeoffs and potential optimisations when graphics/shader programming with respect to the following kinds of issues;

batching
view culling
occlusions
draw order
avoiding state changes
triangles vs pointsprites
texture sampling
etc

Basically whatever the graphics programmer needs to know about modern graphics hardware in order to become more effective.

I'm not really looking for specific optimisation techniques, rather I need  more general knowledge so that I will naturally write more efficient code.


texts: What makes movement feel smooth, and what are some standard methods to achieve this?

texts:
I'm either not searching correctly or there is really not a lot of material on character movement in 3D games. I'm mostly interested in how people usually implement character movement in games like FPS and action games, where usually the WASD keys are used to move backward and forward and for strafing, with the mouse used for turning. I'd like to learn what methods are generally used, and what makes the movement handling feel right.

For example, I tried to implement movement handling using some 'walking' force to move my character, by integrating the equations of motion. Needless to say, this felt more like handling a spaceship, rather than a human. Others probably use just some velocity to steer the characters, maybe coupled with a deceleration when no buttons are pressed. I tried something similar in following code, but it still feels kinda clunky.

if(move_comps_[*entity]-&gtmv_direction != glm::ivec3(0))
{
    glm::vec3 mv_dir(0.0);
    mv_dir += (float)move_comps_[*entity]- &gt mv_direction.z
        * transform_comps_[*entity]-&gtforwardVec();
    mv_dir += (float)move_comps_[*entity]-&gtmv_direction.x
        * transform_comps_[*entity]-&gtrightVec();
    mv_dir = glm::normalize(mv_dir);

    glm::vec3& velocity = move_comps_[*entity]-&gtvelocity_;
    velocity += dt * move_comps_[*entity]-&gtacceleration_ * mv_dir;

    if(glm::dot(velocity, velocity) &gt sqr(move_comps_[*entity]-&gtmax_velocity_))
    {
        velocity = move_comps_[*entity]-&gtmax_velocity_ * mv_dir;
    }

    transform_comps_[*entity]-&gtpos_ += dt * velocity + 0.5f
        * move_comps_[*entity]-&gtacceleration_ * sqr(dt) * mv_dir;
}
else if(glm::length(move_comps_[*entity]-&gtvelocity_) &gt 0.0)
{
    glm::vec3& velocity = move_comps_[*entity]-&gtvelocity_;
    glm::vec3 mv_dir = glm::normalize(velocity);
    velocity -= dt * move_comps_[*entity]-&gtacceleration_ * mv_dir;

    if(glm::dot(velocity, velocity) &lt 0.01f)
    {
        velocity = glm::vec3(0.0);
    }
    else
    {
        transform_comps_[*entity]-&gtpos_ += dt * velocity + 0.5f
            * move_comps_[*entity]-&gtacceleration_ * sqr(dt) * mv_dir;
    }
}

Here in essence, I use an integer vector which can hold (-1, 0, 1) in each dimension. When a walk_forward_start event is fired, for example, this z component is increased by 1 and decreased when the player releases the button. This vector is used to find out in which direction to move the player. I also added a simple deceleration mechanism. As I said, this still doesn't feel right, and is certainly not really smooth. What could I do to improve it?

Others have gone as far as implementing advanced techniques such as inverse kinematics, too. I wouldn't go that far, but how far do you have to go to make a movement system feel good?

Essentially, beyond the sauce, I want to know what makes pushing forward, strafing, turning and stopping feel smooth and what are some standard methods to achieve this. Do you use some impulse/force based method? Do you use a linear velocity method?

Note: This may seem like a subjective question and it might be up to some point, but I think there must be some general consensus or else there would be a big variations on how these controls are handled by games.


texts: How to manipulate 2d image as different objects

texts:
Hello Im very new to this so I don't even know what this process is called exactly.
Im posting image of flappy bird here in which it consist all the objects day, night, birds, font etc Here :

So how to use them in 2D game? this is just example i have used. How to manipulate different objects at different coordinates ? Thanks.


texts:
This is a Java related question.

I've got this question and I searched on the internet but didn't really get any clear answer.

I want to develop a little multyplayer game which needs real time synchronization for a few clients. I don't really want to have a lot of clients, but I want to have the chance to create it for a greater scale later.

Seeing through some Links (also given here from stackexchange) I got the answer that UDP would be better, then others say TCP. I know it's sometimes more an opinion thing what you prefer most for yourself.

But I've developed some network games in the past (not proffessional ;) ) and used TCP. And I didn't really get a lagfree game, even for three clients (players)

I then used the new nio (asynch) network framework of java, but the lag just reduced a little bit.

So how can I develop a reliable Server-Client model? Using TCP or UDP? Or did I just end up developing a bad example and thats why my server-client communication lagged?

If someone has a good tutorial for developing a reliable java game server that would be nice.

Thank you


texts: For 2D games, is there any reason NOT to use a 3D API like Direct3D or OpenGL?

texts:
I've been out of hobby Game Development for quite a while now.  Back when I did it, most people used Direct Draw to create 2D games.  By the time I stopped people were saying OpenGL or Direct3D with an orthogonal projection is just the way to go.

I'm thinking about getting back into creating 2D games, in particular on mobile phone but maybe on the XNA platform as well.  To make something using OpenGL I'd have a (hopefullly) small learning curve to acclimate myself to 3D development.

Is there any reason to skip that and instead work with a 2D framework where I just have a Width x Height frame buffer I need to fill with pixels?


texts: FreeType Library - Text on multiple lines

texts:
I am rendering text using the FreeType library allong with OpenGL, but say I want to render a long line of text, as seen in the following image:

The text continues on the same line until it goes off screen. In the above image, you can see that the window can fit the word "Test" 11 times, but the 12th goes of screen, so in a perfect world I would just be able to put \n (new line command in most systems) after the 11th word and the 12th would be rendered on a new line under the original. However, the command \n does not work the same in FreeType as it does for std::cout and printf.

Therefore my question is this - How could I render the text of one TextRenderer object on multiple lines, the same way the \n command works for single std::cout and printf calls? (I don't want to create a new object for each line of text, I can already do it this way but it seems wasteful) Maybe there is a way for FreeType to know it is at the edge of a window and if so render the next characters appropriately?


texts: Top down off-screen indicator, Unity3D C#

texts:
I'm working on a top-down 3D game where things spawn off camera. Movement only occurs on 2 axis (x and z). Rotation is about y axis.

The player is in the center of the camera and needs to have indicators at the edge of the screen to show where the item is relative to the players location.

I've managed to figure out the distance from my player to the target just using the distance between 2 Vector3 points.

However, I can't figure out how to translate this into a direction/angle for an indicator arrow that I have instantiated as a child of the canvas UI and make it point to the edge of the screen.