texts:
I have a question about isometric projection: Why did in all tutorials and examples start point for isometric is in left top corner ?
For example in cocos2d 3.1 my start screen point in left bottom, so left top isometric position will nearly 1500,1500. So is it normal to make start isometric point in left bottom corner ? i mean :

x,y
0,3 1,3 2,3
0,2 1,2 2,2
0,1 1,1 2,1
0,0 1,0 2,0

or better

0,0 1,0 2,0
0,1 1,1 2,1
0,2 1,2 2,2
0,3 1,3 2,3

sorry for stupid question


texts: How to create 3d picking ray with the cursor position

texts:
I'm new here and I'm not sure how to go about doing this. I am creating an application that is supposed to use the cursor's position in the window to perform 3d picking. The tutorials I have found only explain casting a ray out of the center of the camera (like from a cross-hair), but this isn't helpful because the mouse isn't always in the center. I'm looking to understand how I could go about extruding the picking ray based on the mouse's x and y position over the window.

Also, it's not as much about the picking as it is casting the ray in the right direction. Picking will be handled by getting points in the ray and checking to see if the unit at that point is full or not.

Any help is greatly appreciated, please be respectful, and thanks in advance!


texts: Optimizing large number of ModelRenderable cubes with ARCore?

texts:
I am creating an ARCore Android app that involves rendering up to thousands of cubes, of course using a Node and ModelRenderable object for each. Understandably, I'm unable to do that without running into memory issues, so I'm looking for ways to optimize. Ideas I've had so far are:

Removing all of the cubes that had no empty space around them since they would be invisible.
Investigating into some sort of culling (which I don't know much about) to not render the sides of the cubes that are invisible. I don't know if ARCore will already do this.
Hiding all of the cubes that are hidden behind other cubes. I don't yet understand the math behind this.
Grouping cubes of the same type into larger cubes. In one example, there might be 16x16x16 rendered on the screen. Each cube is an individual unit with its own type. So in relation to my grouping idea, I would take all the cubes that have the same type would be replaced with one larger cube or cuboid.

I've tried removing all of the cubes that have no empty space around them, as those will not be visible. Long term, however, this will be insufficient.

I don't have a lot of code to show that's related as this question is more looking for ideas to write code, but basically I'll be having a very large number of:

// Where position is a Vector3 and material is a Material object.
ModelRenderable cube = ShapeFactory.makeCube(new Vector3(CUBE_WIDTH, CUBE_WIDTH, CUBE_WIDTH), position, material);
Node node = new Node();
node.setRenderable(cube);

I'm not creating a new material every time, I generate those at startup.

I understand there are lots of questions already answered about this kind of optimization, but I haven't been able to find much about the implementation of things such as culling and hiding blocked cubes in the context of ARCore. Would I be better off using Unity?

If anyone has advice or ideas, I'd love to hear them.


texts: How to make the Angry Birds "shot arch" dotted line?

texts: I am making a game that includes 2D projectile flight paths like that of Angry Birds. Angry Birds employs the notion that a previous shot is shown with a dotted line "arch" showing the player where that last shot went. I think recording that data is simple enough once a shot is fired, but in my game, I want to show it preemptively, ie: before the shot. How would I go about calculating this dotted line? The other caveat is I have wind in my game. How can you determine a projectile preemptively when wind will affect it too? This seems like a pretty tough problem. My wind right now just applies a constant force every step of animation in the direction of the wind flow. I'm using Box2D and AndEngine if it matters.


texts: Bullet Physics too many rigid bodies framerate drops

texts:
I have a question regarding rigid bodies in bullet physics.

At the moment I have low-poly asteroids, which I create a convex Hull shape.
Then I add a motion state and give them a linear velocity.

Collision and everything is working fine, if its a low amount of asteroids (less than 5).

But as soon as the amound of objects in the world get higher, my framerate starts to drop under 1 FPS.

I have a Intel i56600k and a AMD Fury. Could it be related to my hardware?
Or is bullet limited in this regard? Or did I do something wrong in my program?

I'm writing the game in C++.


texts: Problems with Obstacle Avoidance steering behavior

texts:
I learned how to implement the Obstacle Avoidance steering behavior from this tutorial. The approach depicted in this tutorial (simplified) is this (note that I'm using rectangular OBBs for obstacles, not circles):

The entity that avoids obstacles will have a 'ahead' vector, representing the entity's 'sight'. It will be equal to the velocity vector, but scaled to some length (the "sight distance").

For each entity in the "sight distance" radius from the entity, we check if it contains the the 'edge' of the ahead vector, marked with a red dot (actually the vector itself treated as a point):

For an entity that contains the red dot, we calculate the vector from the center of the entity to the red dot:

This vector (scaled by a scalar MAX_AVOIDANCE_FORCE) is the avoidance force. We apply it on our entity, and it should avoid the obstacle.

However, what happens in practice after applying the force is this:

As you can see, the entity is about to get stuck on the obstacle. That's because it doesn't sense it's about to collide, because the obstacle doesn't contain the edge of the 'ahead' vector.

So: what would be a good solution to this problem? How should I implement the algorithm?


texts: How do I figure out if a point is infront or behind my vehicle?

texts:
I need to figure out whether a point is infront or behind my vehicle.

I have the vector of it's position, forward direction.

So far I have tried finding the vector perpendicular to its forward direction and then calculating what side of the line it is positioned on.

This works fine at first. But then I realised it is only calculating around the origin.

bool Car::isInfront(ngl::Vec2 _pos)
{
//http://stackoverflow.com/questions/1243614/how-do-i-calculate-the-normal-vector-of-a-line-segment

//if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx).

//create vector per to the direction of travel.
ngl::Vec2 fwdVec = m_carPhysics->getForwardVec2();
ngl::Vec2 pos = m_carPhysics->getPosVec2();

ngl::Vec2 dir = pos + fwdVec;

float dx = dir.m_x - pos.m_x;
float dy = dir.m_y - pos.m_y;

ngl::Vec2 v1(-dy, dx);
ngl::Vec2 v2(dy, -dx);

ngl::Vec2 perp = (v1) - (v2);

int turn = getLeftOrRight(_pos, perp);

if(turn == LEFT)
{
    return true;
}
else
{
    return false;
}

int Car::getLeftOrRight(ngl::Vec2 _dir, ngl::Vec2 _fwd)
{
//http://gamedev.stackexchange.com/questions/34536/calculating-angle-between-two-vectors-to-steer-towards-a-target
//cross product;
float val = (_dir.m_x * _fwd.m_y) - (_dir.m_y * _fwd.m_x);

if(val > 0)
{
    return LEFT;
}
else
{
    return RIGHT;
}

}


texts:
So I have a simple script to move a character. The problem is that no matter where i'm looking at (my y rotation) it always makes me go the direction if I try to go forward, but I want it to go toward where i'm looking when I go forward or relative to where i'm looking for any direction. HOw can I do this ? (also I do not want to use a already existing fps controller) transform.forward works but only if I go forward or backward, not for left right or diagonal.
(placed on player)

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

public class player : MonoBehaviour
{
public float speed;
Rigidbody rb;

void Start()
{
    rb = gameObject.GetComponent<Rigidbody>();
}

void Update()
{
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");
    rb.velocity = new Vector3(x*speed.rb.velocity.y,z*speed);
}
}

for my camera, I am using a script I found online:
(placed on player)

using System;
using UnityEngine;

public class mouseLook : MonoBehaviour
{
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
Rigidbody rigidbody;
float rotationY = 0F;

void Update ()
{
    if (axes == RotationAxes.MouseXAndY)
    {
        float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse
X") * sensitivityX;
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
        rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
        transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
    }
    else if (axes == RotationAxes.MouseX)
    {
        transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
    }
    else
    {
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
        rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
        transform.localEulerAngles = new Vector3(-rotationY,
transform.localEulerAngles.y, 0);
    }
}

void Start ()
{
    Cursor.lockState = CursorLockMode.Locked;
    rigidbody = gameObject.GetComponent<Rigidbody>();
    if(GetComponent<Rigidbody>())
    {
        GetComponent<Rigidbody>().freezeRotation = true;
    }
}
}


texts: Is it legal to use the name of an existing game?

texts: I'm planning on creating an iPhone game titled "Guess Who!". I know there is already a board game with the same title (linked here) so I'm wondering it is legal for me to use this title for my game. Will the game get pulled off of the App Store if I use it? Thanks in advance.


texts: Need instructions for my AI racing car game

texts:
I'm having a school project to create an 2D AI racing car game, but nobody know where is the destination, and the map is randomly generated. But to avoid the dead end, we must teach the car not to move to that path again. I wonder if there were any algorithms or methods to store the dead end which was passed. I have searched the A* algorithm but I think that algorithm doesn't help me in this case.

The map should look like this:

And this is the road:


texts: Touchscript: multiple overlapping colliders

texts:
Im building a tower defense game on unity and would like to allow the player to pan the camera on a large map. I am using touchscript to handle the touches.

I made a testing project with the following hierarchy
Main Camera
Panning object
Sprite

I am using the pan gesture to move the panning object which then sets the main camera's position to negative of the panning object's corrds.

So far, the things that should work worked properly. There is however the issue that the sprite object is higher up the layer and thus take priority. This means that if the viewport is filled with the sprite object, you are no longer able to pan as you cant touch the panning object behind the sprite object.

So the question is,
1. How does touchscript handle layering?
2. How can one achieve a passthrough effect where the sprite would handle tap gestures and the panning object handles pan gestures?
3. Can anyone suggest a better touch system for what im trying to do other than touchscript?

Thanks


texts: Which communication should I use between server and client

texts:
For a school project I am creating a multiplayer game for the smartphone.
I want the "GUI" to be a flutter application to cover IOS and Android.
As backend I use Golang.

Now I wanted to ask, what is the best way that the backend and frontend can communicate together.
The communication should be fast and without a lot of calculations, because a lot of calculations are done by the backend, because I cannot allow cheating. And to have some performance it should be fast.


texts:
I'm trying to get a basic OBB/OBB Collision System working. For this I use ODE.

My problem is: Whenever I use the dSpaceCollide and pass in my Space and my Callback, my Callback shows me, that a collision happened. But the contact-point is far away (or even in X/Y/Z-(Near-)Infinite) from my OBB's.

Here a pic:

I did this:

In the Constructor: Box with dCreateBox
Every frame: Position with dGeomSetPosition and
Rotation with dGeomSetRotation
Also every frame: Check per dSpaceCollide

What could I've missed? Thanks in advance!

PS: I'm using DirectX9!

EDIT:

My Collision-Code:

In my Game-Loop:

dSpaceCollide(space, 0, &nearCallback); // space is my dSpaceID

My NearCallback:

static void nearCallback(void *data, dGeomID o1, dGeomID o2)

{

dContact contact;

contact.surface.mode = dContactBounce | dContactSoftCFM;
contact.surface.mu = dInfinity;
contact.surface.mu2 = 0;
contact.surface.bounce = 0.01;
contact.surface.bounce_vel = 0.1;
contact.surface.soft_cfm = 0.01;

if (int numc = dCollide(o1, o2, 1, &contact.geom, sizeof(dContact)))
{
    // DrawTextOnScreen is a function to Draw things on my Screen (obviously)
    DrawTextOnScreen("Collision", D3DCOLOR_XRGB(0, 255, 0), 2, 200, 270, 20);
    DrawTextOnScreen(std::to_string(numc).c_str(), D3DCOLOR_XRGB(0, 0, 0), 2, 220, 270, 20);
    // etc...
}

else
    DrawTextOnScreen("No Collision", D3DCOLOR_XRGB(255, 0, 0), 2, 200, 270, 20);
}

EDIT-2:

After some trying I got to a point where the Collision not not works. :-P

I changed it this way:

The Rotation is made by Quaternions instead of Matrices. And I update the Box-Length every Frame.

Now it showes me, that there is no collision when there is no collision. (Fine) The problem is, that when there is a collision, it doesn't show it to me:

But (!) when I Spawn myself at the exact same position of the "Enemy", it detects a collision. I can rotate around the X-Axis and the Point where the collision occurs changes. The collision-point is in a weird Position.

The Box in ODE is declared with the same dimensions as I declared for the Box, which is rendered!

EDIT-3

I just want to show you how I define my Space!

// Initialization
dSpaceID space;
space = dSimpleSpaceCreate(space);

// In the Loop
dSpaceCollide(space, 0, &nearCallback);

I really hope, that you can help! And apologise my english, it's kind of shitty! :-)

EDIT-4
After a week of so doing other stuff, I looked back on the problem and found the issue:
In the beginning you have to declare

dDouble

instead of

dSingle

...

Makes me a little bit sad :-( Somthing boring as an error... :-)


texts: How should I model exact 90-degree rotations in 3D?

texts:
I'm familiar with quaternions... have used them in the past to model arbitrary rotations in 3D, as for a plane flying around with full pitch/yaw/roll freedom. Works great.

Now I'm working on a 3D puzzle where the rotation is "quantized": all rotations are whole multiples of 90 degrees. I could use quaternions, but it seems like complexity overkill for this situation. And more importantly, I need to be able to test different orientations according to their quantized values, aligned to the three main axes. Quaternions (usually) use floating point values rather than integers, so if we compose several rotations and then compare the resulting orientation to a known orientation, it may not be straightforward to test whether a certain face is pointing a given direction, due to rounding.

Anyway, there may be an easier way to model this.

The puzzle is like "netwalk", but in 3D. So the requirements are:

Be able to rotate a given piece +/-90 degrees, around a specified axis, updating its orientation state (which is modeled how?)
Be able to query whether a particular piece, in its current orientation, is connected in a particular direction (e.g. has a tube touching the face that is in the positive X direction)
For the latter we probably have an array of booleans that say whether the piece is connected in each direction in its "initial" orientation. But in order to make use of this, we need a way to rotate this initial state to the current orientation.
Oh, we also need to be able to display each piece graphically in its updated orientation. But that could use a separate orientation state if necessary... it's a pretty standard feature of scene graph libraries.

Maybe I just need to implement an integer version of quaternions?

Thanks for any thoughts...


texts: Use JS to grab values from a dynamic Lua Table

texts:
((BACKGROUND: I'm modding a game that runs using Lua and the Source2 Engine (Dota). Gameplay logic uses Lua and HUD uses JS))
I used Lua to create a global table. For instance:
global itemRollsManager[itemID] = {
  id = 19,
  buff1 = "modifier_bonus_range",
  ability = "tusk_ice_shards"
}

Now I need to grab that info and display it in the HUD using JS. I've successfully grabbed the itemID inside JS, but now I need to grab that table and those values while the game is running.
How do I do this? Is it even possible with just JS and Lua?


texts: How can I create a VBO of a type determined at runtime?

texts:
I've written a Vbo template class to work with OpenGL.

I'd like to set the type from a config file at runtime. For example:

<vbo type="bump_vt" ... />

Vbo* pVbo = new Vbo(bump_vt, ...);

Is there some way I can do this without a large if-else block such as:

if( sType.compareTo("bump_vt") == 0 )
    Vbo* pVbo = new Vbo(bump_vt, ...);
else if
    ...

I'm writing for multiple platforms in C++.


texts:
Given the equations found in the answer here:

Determine arc-length of a Catmull-Rom spline to move at a constant speed

How would one A) Apply this to a 3D Catmull-Rom Spline, and B) write A out programmatically (for the math illiterate)?


texts:
I'm trying to figure out how to calculate the following angle:

I know center (p1) and radius (r) of a circle. Given a point p3 I want to calculate the angle a such as the tangent (tan) of the circle at point p4, points in p3 direction.

Here's a figure:

Doesn anyone know how to do that?


texts:
I have a class called Tile, the constructor takes an integer that represents the tile's
type. You can load a tileset ( via loadTileset() ) which initalizes the fields -

tileset
numOfTiles
tileWidth
tileHeight

My question is, in the constructor, depending on the type variable. How do I figure out the proper x and y cooridates to uses in the getSubimage() method.

So for example, if type is set to the value 2, I'd want to get the x and y position of the upper-left corner of number two.

import java.awt.image.*;
import java.awt.*;
import java.io.*;
import javax.imageio.ImageIO;

public class Tile {

private int type;
private BufferedImage tile;

// tileset attributes
public static BufferedImage tileset;
public static int numOfTiles;

public static int tileWidth;
public static int tileHeight;

// constructor
public Tile(int type) {

    // contruct tile
    this.type = type;
    // ...
    tile = tileset.getSubimage(0, 0, tileWidth, tileHeight);
}

public static void loadTileset(String filename, Dimension tileSize) {

    // load tileset
    try {
        tileset = ImageIO.read(new File(filename));
    }
    catch(Exception e) {
        e.printStackTrace();
    }

    // initalize attributes
    tileWidth  = (int) tileSize.getWidth ();
    tileHeight = (int) tileSize.getHeight();

    numOfTiles = (tileset.getWidth() / tileWidth) * (tileset.getHeight() / tileHeight);
}
}


texts:
I have a planet rotating around its own axis (like regular planets, and Pluto) and a spaceship that can fly around in space.
The idea is to lock the player (ship) in a deadzone "above" the planet and when he moves to an edge, the planet begin to rotate in the direction that the ship is traveling. I.E. not rotate the player or camera, but instead rotate the planet.

The problem is I need to rotate the planet (in THOSE cases) around the ship's axis and not its own. So I need some way to create the rotation matrix for the planet using the ship's right and Up vector.

I don't want to use the CreateAxisFromAngle method because I don't want to automate the rotation (assuming that is how the function works, correct me if I'm wrong). I want to rotate the planet while the player is moving in a direction and stop rotating when they stop moving.

I also am not very comfortable with Quaternions. So if that is the solution (which I fear it is), please lay it out to me like you would a child, cause I am quaternions retarded. General math is fine though.


texts: What can make a peaceful game successful?

texts:
Today, the most successful games are action games like FPS, RPG, MMORPG...

I'd like to make a peaceful game, but I don't know how to attract people. I can make good graphics, but that's not the main thing that makes people like a game for more than a couple of minutes. The content is important. In the game styles mentioned earlier, their main content is fighting, killing others, and generally making yourself the most powerful player in the game.

But what content can attract people in a peaceful game?


texts: How many testers should I get for my game?

texts:
I made a game for my bachelor final project. How many testers should I get to play-test my game? Is there any theory about that?

Would be really helpful if you can give any citation or source, since most likely my examiner will ask about that.

Thanks!


texts: Suggestion for C++ reinforcement learning library to control flocking algorithm

texts:
I am looking to use reinforcement learning to adaptively modify the weights involved in a flocking algorithm (i.e. 'boids').

Searching google revealed several libraries, but I don't know anything about any of them.

I am far from being an expert in reinforcement learning, though I have perused Sutton and Barto's classic book on the subject, so I understand some of the concepts.

A little background, in case it helps.  I have a few steering behaviours (seperation, alignment, cohesion, forward, and wall avoidance), which each generate a 'force' vector and compete to tell the agent(s) where to move.  Each force vector is combined in, basically, a weighted sum.  I would like to 'learn' these weights adaptively so as to cause e.g. more/less clustering, reduce/increase the flock's speed, etc.

Can anyone recommend a good library to use?

I would also need some kind of linear classifier, or something, to interface the learning with the (float valued) weights for each of the flocking steering behaviours.  So a library that provides a one-stop solution for this problem would be good?


texts: Is index drawing faster than non-index drawing

texts:
I need to draw a lot of polygons consisting of 6 vertices's (two triangles).

Without any texture coordinates, normals etc., both approaches result in 72 bytes. In the future I would definitely also need texture coordinates and normals, which would make index drawing consume less memory. Not a lot though.

So my question is: For VAOs with few vertex overlaps, which approach is faster? I don't care about the extra memory consumed by non-index drawing, only speed.

Edit: To make it clear.

Non-index approach:

float[18] vertices = {
//Triangle 1
1,1,0,
1,0,0,
0,0,0,

//Triangle 2
1,0,0,
0,1,0,
0,0,0,
};

Index approach:

float[12] vertices = {
1,1,0,
1,0,0,
0,0,0,
0,1,0,
};

int[6] indices = {
//Triangle 1
0,1,2,

//Triangle 2
0,3,2
};


texts: Move Background in AndEngine for a Racing Game

texts:
I am new to game development and AndEngine. I have small query about racing game. I am going to develop a bike racing game. For bike racing game we will move the background or the player. I am tried with andengine autoparallax background. But I didn't got the correct answer.

I need to do a background  like these screenshots in SpeedMoto.

Can anyone help me to set the background.


texts:
I have the following simple raycast from a capsule on a cube:

bool hit = Physics.Raycast
(transform.position, Vector3.down,
jumpSettings.groundJumpDistanceCheck,
jumpSettings.layerMask);

print(hit);

When my layerMask is 8 (terrain), I have set my layer on my cube and my groundJumpDistanceCheck is 2. Then my hit is false.

When my groundJumpDistanceCheck is set to Infinity. Then my hit is still false.

However when I remove the distance parameter:

bool hit = Physics.Raycast
(transform.position, Vector3.down,
/* jumpSettings.groundJumpDistanceCheck, */
jumpSettings.layerMask);

print(hit);

Then hit returns true. This is odd for me, as far as I know when you exclude the distance parameter it's supposed to be Infinity by default. But when I explicitly give Infinity as the distance, it returns false.

I have also used the following code in an attempt to debug my issue, using the desired distance 2f

Debug.DrawRay(transform.position,
Vector3.down * jumpSettings.groundJumpDistanceCheck, Color.red, 60f);

As you can see, the ray does intercept the cube.

I need the reycast to return true with a distance of 2f.


texts: How can I create a 2D camera with zoom and parallax scrolling that works on every Windows Phone resolution?

texts:
Mario game that uses parallax scrolling: http://www.youtube.com/watch?v=de5f3mvRyIY

I want to create a Windows Phone jump-and-run game with parallax scrolling. The parallax scrolling should be like in this Mario game. The character should be centered in the viewport.
I use the code of this tutorial to create the camera and parallax scrolling:
http://www.david-gouveia.com/portfolio/2d-camera-with-parallax-scrolling-in-xna/

I can zoom in and zoom out with the camera and the player(basketball) is in the center of the viewport, but parallax scrolling isn’t working correctly on every Windows Phone resolution. I get different results on every resolution. The backgrounds look different on every resolution.

For example:

WVGA emulator(resolution: 800x480pixel): http://s1.directupload.net/images/140730/ljbsolu2.png

720p emulator(resolution: 1280x720pixel): http://s1.directupload.net/images/140730/36ic4rfo.png

If you compare both pictures, you see that the backgrounds are not on the same place on both resolutions when the basketball touches the orange rectangle.

Why are the background layers not on the same place in both pictures?

I use the same sprites and same coordinates for the sprites on every Windows Phone resolution. In the WVGA picture, I just zoomed out with the camera so that you can see the entire background.
How can I create a Windows Phone game that uses parallax scrolling and looks on every resolution the same? The background layers should be on the same place on every resolution.


texts: How should I store grid-based character inventories in the database?

texts:
I used to encode the whole inventory data into binary but I'm thinking of doing something different now.

The inventory has a 64 slots in an 8×8 grid. Large items like weapons fill up 6 to 8 slots in a vertical rectangle, while potions take 1 slot.

How would you store this data in a database?


texts:
Im making a game and i want to organise my weapons, and im having a few doubts on not only the best architecture but also on how to use it properly:

The First approach is to make a single Weapon class with a Type variable, and create every weapon, melee or ranged, in there. That way, even handeling collision would be "easy" (i have a collisionManager class where i handle all the collision (with pointers to collideable game elements), but thats also a problem, since weapons might have different ways to collide, lets say if im using a projectile weapon, like a pistol, i only need to check collision with its bullets, while a knife's is all about its range, so the Type variable would be very useful for that). The downside, i believe, is that:

1 - In the future, the class might get very big and maybe complex (i intend to add lasers, flamethrowers and rocket launchers so...)

2 - Every mob that posesses a "Weapon" object initialized would have data to use every weapon, when some enemies might just use one of them (lets say i have an enemy that just melee hits, which i might say its the knife), and althought i might be overreacting about the memory it wastes, it bothers me.

The second approach is the classic, yet quite attractive, hierarchical one, where i would create a class Weapon similar to this:

public abstract class zWeapon {

//weapon attack info
protected boolean attacking = false;
protected int damage;
protected long startTime;
protected long delay;
protected long elapsed;

public void attack(double X, double Y, double angleShoot)
{
    if(attacking) return;

    startTime = System.nanoTime();
    attacking = true;

    useWeapon();
}

protected abstract void useWeapon();

public void update()
{
    if(attacking)
    {
        elapsed = (System.nanoTime()-startTime) / 1000000;
        if(elapsed >= delay)
            attacking = false;
    }
}

protected abstract void draw();}

(forget about the "z" behind Weapon)

and then create extensions like MeleeWeapon, ProjectileWeapon, Laser etc

What confuses me, is how to properly use this. My only idea to use this. if a mob has a Weapon, and a certain mob only uses Knife, it makes sense that i say weapon = new Knife(); and the mob uses the knife as it should. But lets say, for example, the player. The Player can use every weapon, eventually. And i would probabily create an array of weapons with every weapon object initialized, and id change the weapon variable everytime i had to change weapon. The problems that come up to my mind are the following:

1 - If i use it like this, if i change weapon variable from, lets say, pistol to knife, the vector of bullets in pistol would stop being updated since im now updating a different weapon.

2 - The collision would be a harder work, i dont want to use instanceof to check which type of collision i should do with the weapon against my game elements...

So as you see i have alot of confusion going on in this Weapon Class architecture, would you ease my mind with a few solutions/hints/tips?


texts:
I've been making a visual novel game where the Player Character can get hungry, thirsty, has energy and also needs to go to the toilet, has sanity,
has cleanliness, has life, has money, has a reputation in the school he visits, has a "Love-Meter" with his relationship partner (for now), strength, intelligence and the list goes on and on.....

But now I think too much of those things would rather "bother" the player than add fun.

But then I also think a lot of survival games have those things and it's a lot of fun to keep those numbers up and survive or get punished.

Now I'm struggling with the balance between making "too much" and "too few".

So maybe one experienced Game Designer here has a good answer for this problem. How much "real life" immersion is good?


texts: Load previous (last) scene used in unity3d

texts:
Im making a 2D game for android and I made over 200 levels/scenes.I also made a game over scene that opens when the players collides with an obscale.In the GameOver scene I added a retry button which I wanna make it so it opens the last level played.Im new in Unity and scripting.I've read other similar questions but none of them fixed my issue.Anyone has any idea that could help ? Im doing this because I don't wanna create over 200 game over scenes and edit each obscale in game.

Thank you.

Edit : Im using javascript.


texts: How to make sure that at least one element in a collection has a certain value?

texts:
In my game, I assign each agent a random direction. However, at least one of these agents has to have a direction of Vector2.up. How can I ensure that?

private void AssignRandomDirection()
{
    var directions = new List<Vector2>
    {
        Vector2.up,
        Vector2.down,
        Vector2.left,
        Vector2.right
    };

    foreach (var agent in FindObjectsOfType<Agent>())
    {
        var random = Random.Range(0, directions.Count);
        agent.direction = directions[random];
    }
}


texts:
I've implemented a dynamic sky model (Preetham). I've got Rayleigh and Mie scattering working fine, but I'm not sure how to get the foggy effects in this Unity article

Here is what I have so far:

How do I get the fog/haze in my scene ? Is it a matter of adding the same scattering shader to each mesh in my scene ?
I tried adding a fog shader to my meshes but the fog colour will obviously not match the sky colour.
I've also tried adding volumetric light scattering as a post-process from this GPU gems but I can't come close to getting the result I'm looking for.

In both cases I end up having my meshes be a distinct colour along the horizon, they do not fade out into the horizon nor do they have all the nice haze above them.


texts: Recently I acquired a myriad of free time and have decided that I want to learn how to program. My question is what language should a newbie start off in? I understand that each language has its own pros and cons, but were could someone who is interested in making games start off?


texts: In lockstep networking game, how to handle sudden lags and disconnection?

texts:
I am trying to implement a game similar to "Street Fighter" by using lockstep networking model so that two players can play remotely via Internet.

I have read a lot of articles about lockstep networking method and I can basically implement the turn/frame handling for each step.

My understanding is that if it's now turn 101 and if player A has not received turn 101 action (packet) from player B, player A has to wait.

When this situation happens, player B has to wait too because player A will not send out further actions to player B because he is waiting.

Should the game do anything for this situation? For example, I saw games like Starcraft, sometimes there is a dialog showing up to wait for other players and if the count down goes to 0, players can disconnect this hanging player.

In order to do so, I don't understand how to decide who is lagging and what the proper handling is. Both player A or player B would think the other party is lagging because he does not receive the packet for his current turn. What am I going to show to the user? And if the lagging continues, how to end the game earlier by giving a correct game result (the player who lags should be given a loss and the other player should be given a win)? Just similar to the countdown dialog in Starcraft.

And on the other hand, what if the situation is not lagging but is a disconnection from player B?


texts: I have been trying a little bit the new TileMap system in Unity and I was looking for a way to access the tiles as a List or 2D array but I can't find anything other than GetTile(Vector3Int vector) which returns only one tile ... Is there any way to do this ?


texts:
I'm trying to use if statement in my fragment shader.

I want to compare my in int finalLightType[4];

Here is my vertex shader code and fragment shader code:

Vertex:

#version 400 core

in vec3 position;
in vec2 textureVector;
in vec3 normalVector;

out vec3 color;
out vec3 surfaceNormal;
out vec2 textureCoords;
out float visibility;
out vec3 toLightVector[4];
out int finalLightType[4];

uniform vec3 mainColor;

uniform mat4 transformationMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;

uniform float tilingX;
uniform float tilingY;

uniform float density = 0.01;
uniform float gradient = 1.5;

uniform int lightType[4];
uniform float lightRange[4];
uniform vec3 lightPosition[4];

void main(void)
{
    finalLightType[0] = 1;
    color = mainColor;

    textureCoords = textureVector;
    textureCoords.x = textureCoords.x * tilingX;
    textureCoords.y = textureCoords.y * tilingY;

    vec4 worldPosition = transformationMatrix * vec4(position,1.0);

    vec4 positionRelativeToCam = viewMatrix * worldPosition;

    float distance1 = length(positionRelativeToCam.xyz);

    visibility = exp(-pow((distance1 * density), gradient));
    visibility = clamp(visibility,0.0,1.0);

    surfaceNormal = (transformationMatrix * vec4(normalVector,0.0)).xyz;

    gl_Position = projectionMatrix * positionRelativeToCam;
}

You can see out int finalLightType[4]; and finalLightType[0] = 1;

Fragment:

#version 400 core

in vec3 color;
in vec3 surfaceNormal;
in vec2 textureCoords;
in float visibility;
in vec3 toLightVector[4];
in int finalLightType[4];

out vec4 out_Color;

uniform bool textured;

uniform sampler2D sampler;

uniform vec3 bgColor;
uniform vec3 ambientColor;

uniform vec3 lightColor[4];
uniform float lightIntensity[4];
uniform vec3 lightDir[4];
uniform float lightSpotAngle[4];

void main(void)
{
    vec3 unitSurfaceNormal = normalize(surfaceNormal);

    if(finalLightType[0] == 0)
    {
    }

    if(textured == true)
    {
        out_Color = texture2D(sampler,textureCoords);
    }
    else
    {
        out_Color = vec4(color,1.0);
    }

    out_Color = mix(vec4(bgColor,1.0),out_Color,visibility);

    vec3 convAmbientColor = vec3(1.0,1.0,1.0) - ambientColor;

    out_Color = out_Color - vec4(convAmbientColor,1.0);

    out_Color.w = 1.0;
}

Everything looks good, but if I start my game I receive really strange effect (Uncolored, untextured, transformed on the front of the camera object):

But.. If I try to compare another int same way, but not in variable, but local variable (Or even uniform variable, they works fine too):

#version 400 core

in vec3 color;
in vec3 surfaceNormal;
in vec2 textureCoords;
in float visibility;
in vec3 toLightVector[4];
in int finalLightType[4];

out vec4 out_Color;

uniform bool textured;

uniform sampler2D sampler;

uniform vec3 bgColor;
uniform vec3 ambientColor;

uniform vec3 lightColor[4];
uniform float lightIntensity[4];
uniform vec3 lightDir[4];
uniform float lightSpotAngle[4];

void main(void)
{
    vec3 unitSurfaceNormal = normalize(surfaceNormal);

    int lightTyp = 0;

    if(lightTyp == 0)
    {
    }

    if(textured == true)
    {
        out_Color = texture2D(sampler,textureCoords);
    }
    else
    {
        out_Color = vec4(color,1.0);
    }

    out_Color = mix(vec4(bgColor,1.0),out_Color,visibility);

    vec3 convAmbientColor = vec3(1.0,1.0,1.0) - ambientColor;

    out_Color = out_Color - vec4(convAmbientColor,1.0);

    out_Color.w = 1.0;
}

It only happens if I compare in variables, everything is works fine with uniform variables, local variables, etc.. (Also tried with varying variable).

Edit:

This object after I run my game is always on the front of the camera and never rotates or whatever. I can't also see other object like a cube that should appear something (probably my camera is inside this cube and I can't see it because of culling faces).


texts: Xna c# picking model with Ray mouse cursor select the wrong model

texts:
i made a small 3D game and i just try to apply a basic sample from here : http://rbwhitaker.wikidot.com/picking
for picking model by the mouse cursor.
For that i use the Ray object and check if some model intersect my Ray.
But i don't know why, the model object target by my cursor is always offset to the left.there is a shift difference.

Here is the code i use.

// Update Ray cursor each frame in the Update loop function

public void UpdateRayCursor()
        {
            Vector3 nearPoint = new Vector3(Globals.mouseState.Position.ToVector2(), 0);
            Vector3 farPoint = new Vector3(Globals.mouseState.Position.ToVector2(), 1);

            nearPoint = graphic.GraphicsDevice.Viewport.Unproject(nearPoint, CameraNode.Camera.Projection, (Matrix)CameraNode.View, Matrix.Identity);
            farPoint = graphic.GraphicsDevice.Viewport.Unproject(farPoint, CameraNode.Camera.Projection, (Matrix)CameraNode.View, Matrix.Identity);

            Vector3 direction = farPoint - nearPoint;
            direction.Normalize();

            Ray = new Microsoft.Xna.Framework.Ray(
                nearPoint
                ,
                direction
                );
        }

// check if a model is target by the Ray

public void UpdateIntersectSceneRay()
    {
        float? nearestDistance = 0f;
        bool findModelTarget = false;
        foreach (var bdgToCheck in ListBlocksSelectable)
        {
            //Check if the boundingBox intersect with the ray
            var checkIntersectDistance = _mainPlayer.Ray.Intersects(bdgToCheck);
            if (checkIntersectDistance != null)
            {
                if ((float)checkIntersectDistance < (float)nearestDistance || nearestDistance == 0)
                {
                    nearestDistance = checkIntersectDistance;
                    _mainPlayer.ItemFocusByReticle = item;
                    findModelTarget = true;
                }
            }
        }
        if(!findModelTarget)
        {
            _mainPlayer.ItemFocusByReticle = null;
        }

    }

Some people have some idea why ? i use monogame library with XNA.
Thank you in advance


texts: Calculate whether you can jump from one platform to another

texts:
I need some kind of formula that will help me connect two platforms that are reachable to each other by jump. I am working on a pathfinding implementation for a 2D platformer and preprocessing the map has been the bane of my existence. Here are some of the physics involved in this platformer:

fallSpeed = 670 px/s (Maximum speed falling in the downwards direction)

gravityAcc = 2000 px/s^2

jumpSpeed = 555 px/s (velocity component along the y-axis)

walkSpeed = 125 px/s (Base speed of a character)


texts: HLSL What you get when you subtract world position from InvertViewProjection.Translation?

texts:
In one of NVIDIA's Vertex shaders (the metal one) I found the following code:

// transform object normals, tangents, & binormals to world-space:
float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >;

// provide tranform from "view" or "eye" coords back to world-space:
float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >;
...
float4 Po = float4(IN.Position.xyz,1); // homogeneous location coordinates
float4 Pw = mul(Po,WorldXf);    // convert to "world" space
OUT.WorldView = normalize(ViewIXf[3].xyz - Pw.xyz);

The term OUT.WorldView is subsequently used in a Pixel Shader to compute lighting:

float3 Ln = normalize(IN.LightVec.xyz);
float3 Nn = normalize(IN.WorldNormal);
float3 Vn = normalize(IN.WorldView);
float3 Hn = normalize(Vn + Ln);
float4 litV = lit(dot(Ln,Nn),dot(Hn,Nn),SpecExpon);
DiffuseContrib = litV.y * Kd * LightColor + AmbiColor;
SpecularContrib = litV.z * LightColor;

Can anyone tell me what exactly is WorldView here? And why do they add it to the normal?

PS. Error in the last sentence - they add it to the light vector.


texts:
Problem:

I'm trying to set up some tests with mock collision objects, but i cannot construct collisions with custom objects. What I'm trying to do:

Collision2D col = new Collision2D();
col.gameObject = this.gameObject;

There seems to be no way to do this as col.gameObject has no visible setter. Is there a way to do this? I would like to script the passing of a collision to a mono-behavior via an event that gets handled by the OnCollisionEnter2D(Collision2D collision) inherited from mono-behaviors. Thanks for your time.


texts: How does this circle collision detection math work?

texts:
I'm going through the wildbunny blog to learn about collision detection. I'm confused about how the vectors he's talking about come into play.

Here's the part that confuses me:

  p = ||A-B|| – (r1+r2)

  The two spheres are penetrating by
  distance p. We would also like the
  penetration vector so that we can
  correct the penetration once we
  discover it. This is the vector that
  moves both circles to the point where
  they just touch, correcting the
  penetration. Importantly it is not
  only just a vector that does this, it
  is the only vector which corrects the
  penetration by moving the minimum
  amount. This is important because we
  only want to correct the error, not
  introduce more by moving too much when
  we correct, or too little.

  N = (A-B) / ||A-B||

  P = N*p

  Here we have calculated the normalised
  vector N between the two centres and
  the penetration vector P by
  multiplying our unit direction by the
  penetration distance.

I understand that p is the distance by which the circles penetrate, but I don't get what exactly N and P are. It seems to me N is just the coordinates of the 3rd point of the right trianlge formed by point A and B (A-B) then being divided by the hypotenuse of that triangle or distance between A and B (||A-B||). What's the significance of this?

Also, what is the penetration vector used for? It seems to me like a movement that one of the circles would perform to get un-penetrated.


texts: How to deal with animated doors in isometric tiles

texts:
I've got a tricky issue I'm not sure how to tackle best:
I have an animated tile of a door. When it's closed it should be sorted one way, but when it's openend it will need to be sorted a different way, as it belonging to a different(neighbouring tile).

Here's the door closed:

and the door opened:

I imagine it would be possible to override the sorting system for such tiles and adjust the sorting based on the frame, but it feels a bit hacky.

Has anyone encountered a similar scenario ? Any elegant solutions ?


texts: Significant 2D SmallTalk/Squeak Game? Smalltalk/Squeak vs. C#

texts:
Prompted by this question about becoming a faster programmer, I'm curious to know if anyone has made a significant-sized 2D game in SmallTalk or Squeak.

And if so, how does it compare to C#? I'm using C# with FlatRedBall for my graphics/physics stuff, and I find it pretty easy to make whatever I want to make. Also, how is Squeak/SmallTalk as far as automated testing?

It's not clear from the Squeak site how the games work; are they download-and-play? I prefer in-browser (via a plugin, like Flash/Silverlight).


texts:
Suppose there are 4 areas namely A1,A2,A3,A4 and each object is given a number(1,2,3,4). When I drag and drop the object(1) on A1, it should print a message "where the object is being dropped".  (no need of mouse over... any mouse collision concept)

first set i=1  -----> o1

ie;logic

if(mousecollision == "L1" && i=1)
{
  mouseup
  score++;
}
else
{
  score--;
}


texts: How to cut polygon shape sprite in Multiple Sprite Editor Unity

texts:
Here is a sprite I have taken from internet and trying to slice it out in many smaller pieces.

But the problem is I have polygon shape sprite, how to cut it out, selected in picture ?

Rest are just fine.


texts:
I want to place my items and enemies randomly (or as randomly as possible).  At the moment I use XNA's Random class to generate a number between 800 for X and 600 for Y.  It feels like enemies spawn more towards the top of the map than in the middle or bottom.  I do not seed the generator, maybe that is something to consider.

Are there other techniques described that can improve random enemy placement on a 2d grid?


texts:
I am trying to set my character up to strafe left and right and have 2 different animations, on for left and one for right, so far what i have written allows me to strafe left or right but it only ever plays the right strafe animation. What am i doing wrong?

private void Strafe() {
    if (Mathf.Abs (Input.GetAxis ("Strafe")) > 0) {
        animation.CrossFade ("strafeRight");
        _controller.SimpleMove(_myTransform.TransformDirection(Vector3.right) * Input.GetAxis ("Strafe") * strafeSpeed);
    } else if (Mathf.Abs (Input.GetAxis ("Strafe")) < 0) {
        animation.CrossFade ("strafeLeft");
        _controller.SimpleMove(_myTransform.TransformDirection(Vector3.right) * Input.GetAxis ("Strafe") * strafeSpeed);
    }
}


texts: Java Slick2D how to draw text with a centered alingment

texts:
I've made a button class that can be drawn and clicked on. How can I write the text of that button (using the slick drawing API, g.drawString()) with a Centered alingment (so that the text is exactly centered in a rect with defined x,y,widht and height).
Thanks


texts: How to make a 3d beam effect with XNA 4.0?

texts:
Do you know any demo or tutorial to learn to make a 3D Beam effect?

I have learn to make a 2D laser by simply using a texture and moving it thru screen.
But I am a little bit lost while trying to do it in 3D.

After googling I've found several examples, but they are old, not working or made for an older version of XNA.

As a visual hint, what I want to achieve is some 3d beam effect similar to this photo:


texts: SDL - BlitSurfaced Background Slowing Time Based Movement

texts:
Whenever I use BlitSurface to apply a background image, the movement of my characters is slowed drastically even though I have movement based on time:

SDL_BlitSurface( background, camera, screen, offset );

Though, if I simply fill the screen with white:

SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

The movement is exactly as I have it set.

Any idea why this could be happening?


texts:
I am attempting to make a game in C# in windows forms, and need for the character to react to key input. I have implemented a very basic code which changes the position of a picture box on key pressed, and then displays the picture box in a new position:

    public Form1()
    {
        InitializeComponent();

        KeyDown += new KeyEventHandler(keyDown);
    }
    void keyDown(object sender, KeyEventArgs e)
    {
        int x = SpriteCharacter.Location.X;
        int y = SpriteCharacter.Location.Y;

        if (e.KeyCode == Keys.Right) x += 1;
        else if (e.KeyCode == Keys.Left) x -= 1;
        else if (e.KeyCode == Keys.Up) y -= 1;
        else if (e.KeyCode == Keys.Down) y += 1;
        else if (e.KeyCode == Keys.Escape) Close();

        SpriteCharacter.Location = new Point(x, y);
    }

The problem you can probably immediately spot is that this script cannot handle user input if two keys are pressed at the same time. E.g. if you press right and down, the character will not move diagonally, but will either go right or down, depending on which key was pressed last.

What would be a more advanced way to handle key input, to make something like this possible? Is these anything I could read up on?


texts:
I want to get the current state from Animator. The reason I do this is because I want my sprite can approach multiple Idle state. For example, when sprite move left, when it go to idle state, it should go for leftidle instead of front idle. And

However when I type

theanim.GetCurrentAnimatorStateInfo(0).IsName("charactersbackwalk"))

"GetCurrentAnimatorStateInfo" the code is in red line which Visual Studios indicate that

  'Game object' does not contain a definition GetCurrentAnimatorStateInfo and no extension method accpeting a first argument of type 'Game object' could be found (are you missing using a directive or an assembly reference)

Below I attach my code:

if (!Input.GetKey("up") && !Input.GetKey("down") && !Input.GetKey("left") && !(Input.GetKey("right") && (theanim.GetComponent<Animator>().GetBool("BackIdle") == true)))
        {
            theanim.GetComponent<Animator>().SetBool(charactersfrontwalk, false);
            theanim.GetComponent<Animator>().SetBool(charactersbackwalk, false);
            theanim.GetComponent<Animator>().SetBool(charactersleftwalk, false);
            theanim.GetComponent<Animator>().SetBool(charactersrightwalk, false);
            theanim.GetComponent<Animator>().SetBool(charactersidlewalk, false);
            theanim.GetComponent<Animator>().SetBool(charactersbackidle, true);
            theanim.GetComponent<Animator>().SetBool(charactersrightidle, false);
            theanim.GetComponent<Animator>().SetBool(charactersleftidle, false);
        }

Below I attach my Unity Animator:


texts:
I'm trying to allow the player to press any button to continue from the main page. I was able to do this by making a List of Buttons and looping through these and checking for one of them being down; however, I feel like this code is kind of ugly and wonder if there's a simpler way to do it that I'm just not thinking of?

Here's my what my code looks like now:

            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                var buttonList = new List<Buttons>()
                {
                    {Buttons.A},
                    {Buttons.B},
                    {Buttons.Y},
                    {Buttons.X},
                    {Buttons.Start},
                    {Buttons.Back},
                    {Buttons.RightShoulder},
                    {Buttons.LeftShoulder},
                    {Buttons.RightTrigger},
                    {Buttons.LeftTrigger}
                };

                foreach (var button in buttonList)
                {
                    if (GamePad.GetState(PlayerIndex.One).IsButtonDown(button))
                        ExitMainMenu= true;
                }
            }


texts: How can I avoid false positives with "blow" input?

texts:
I’m working on a game which uses blow functionality to move an object in the game screen.
This screen also has background music in it.

The problem is that the microphone is detecting the BGM as blow input and the object is being moved without any actual user input.

How can I avoid this kind of false positive?


texts:
I'm a bit confused as to what's going on, but I've just noticed that my imported character model never blinks during his animations. I currently have 3 animations - an idle, walk and jump. Every aspect of the animations work correctly, but for some reason the blinking doesn't. o_o Looking at the keyframes in the Animation tab, they're there, but they don't work. Any ideas what could be wrong?

Thanks


texts: Unity method/framework for handling different input modes

texts:
I'm a very new Unity developer who's looking for a best practice or framework for handling different input modes.  I'm working in C#.  Here's a contrived example:
Sample Map Application
Control Scheme 1:

W/A/S/D keys move map up/right/down/left.
Escape key closes application

Spacebar opens menu and switches to Control Scheme 2
Control Scheme 2:

W/A/S/D moves menu selection up/down/into submenu/back to parent menu.
Escape key closes menu and switches to Control Scheme 1

I realize this is a silly contrived example, but it demonstrates the point.  When we are in a menu we don't want the W/A/S/D keys to also move the map while we are trying to navigate the menu.  This could be done with a bunch of if statements such as
if(moveMode)
   // read keypresses and move map
else if(menuMode)
   // read keypresses and menu navigation

But you can see how this would get messy very quickly if we had lots of modes.  We could also end up with a lot of nested if statements if we have sub-modes for controls.
Surely there's a cleaner way to do this?  Any best practices for this?  Any frameworks?


texts:
I am making a game where objects are represented by colored cubes. I have files that mark the location and rotation of the cubes. I've been using Processing's 3D library and the cubes disappear within a certain distance, like this:

Why is this happening?


texts:
I have a surface (OffScreenPlain or RenderTarget with D3DFMT_A8R8G8B8) which I copy pixels (ARGB) to, from a third party function. Before pixel copying, Bits are accessed by LockRect.

This surface is then StretchRect to the Backbuffer which is (D3DFMT_A8R8G8B8). Surface and Backbuffer are different dimensions. Filtering is set to D3DTEXF_NONE.

Just after creating the d3d device I've set following RenderState settings

D3DRS_ALPHABLENDENABLE -> TRUE
D3DRS_BLENDOP          -> D3DBLENDOP_ADD
D3DRS_SRCBLEND         -> D3DBLEND_SRCALPHA
D3DRS_DESTBLEND        -> D3DBLEND_INVSRCALPHA

But I see no alpha blending happening. I've verified that alpha is specified in pixels.

I've done a simple test by creating a vertex buffer and drawing a triangle (DrawPrimitive) which displays with alpha blending.

In this test surface was StretchRect first and then DrawPrimitive, and the surface content displays without alpha blending and the triangle displays with alpha blending.

What am I missing here? Thanks

EDIT: I must add this is on x64 Win7


texts: Box2D Issues determining the side of collision

texts:
I'm trying to determine which side of my object a collision is happening. In all of my searching, I have found 2 different proposed solutions, but each one has a major issue. I'm hoping that someone here can explain what steps I am missing.

Attempt 1 : Sensors

The first solution I tried was using Sensors on the sides of a Dynamic body. Like this :

The issue with this solution is that multiple sensors can easily collide with a single obstacle, like this :

Attempt 2 : Determine side of contact using the World Normal

My second solution was to get the Normal from the b2WorldManifold that is provided by the contact in BeginContact(). This works perfectly, but only for detecting the side when a collision begins, not when it ends. EndContact() doesn't have the ability to provide a World Normal. You can get the manifold, but the components of the Normal are undefined. The issue with this is that I have no way of knowing which collision just ended.

Hopefully someone knows enough about Box2D to see something simple that I am obviously missing. Thanks in advance for any input.


texts: How is XML being used for a game engine, here?

texts:
In this question, the first answer explains a way of defining components of a gaming engine in XML, like this:

<?xml version="1.0" encoding="UTF-8"?>
<mobs>
  <mob>
    <personality>Aggressive</personality>
    <intelligence>20</intelligence>
  </mob>
</mobs>

Then, states in Java that your mob class would look like this:

public class Mob {
  private IPersonality personality;
  private Integer intelligence

  //**  Getters & Setters **//
}

What exactly is the XML doing, here? I'm not really familiar with XML, at all.


texts:
I'm trying to decide how to implement player movement in an MMORPG.  Player positions must be synchronized in a way that meets the following requirements:

Low lag
Difficult to hack or cheat
Authoritative server with constant accurate knowledge of player positions
Fairly simple to implement

I already know of two approaches:

The client sends position: Every so often, the client sends the player's current position to the server.  This is simplest.
The client sends input: Basically the player's machine sends keypresses to the server, and the server handles all simulation and state, sending back the player's position every so often.

Both systems have their advantages and disadvantages.  Is either one superior to the other, or is there a better alternative?


texts: How to perform alpha blending on saved raw argb videos(a image and a video will also work) using direct3d9 , direct3d10 or direct3d11?

texts:
I'm trying to perform alpha blending on videos using direct3d11. I've wrote the code snippet below to achieve this. I've tried to read the video file out2.argb frame by frame and store it in the rawData. Later, I passed that rawData to CreateTexture2D but pTexture remained null after the execution of the API. So I tried passing NULL to the CreateTexture2D and passing rawData to the UpdateSubresource but again the pTexture remained NULL.

HRESULT result;
    FILE * fp = NULL;
    int size = 1280 * 720 * 4 ;
    void * rawData = NULL;
    D3D11_TEXTURE2D_DESC desc;
    desc.Width = 1280;
    desc.Height = 720;
    desc.MipLevels = 0;
    desc.ArraySize = 1;
    desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    desc.SampleDesc.Count = 1;
    desc.Usage = D3D11_USAGE_DYNAMIC;
    desc.BindFlags = D3D11_BIND_SHADER_RESOURCE| D3D11_BIND_RENDER_TARGET;
    desc.CPUAccessFlags = 0;
    desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;

    D3D11_SHADER_RESOURCE_VIEW_DESC shader;
    shader.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    shader.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    shader.Texture2D.MipLevels = -1 ;
    shader.Texture2D.MostDetailedMip = 0;

    fp = fopen("../Engine/Data/out2.argb", "rb");
    rawData = malloc(size);

    D3D11_SUBRESOURCE_DATA data;
    data.SysMemPitch = 1280 * 4;
    data.SysMemSlicePitch = 1280 * 720 * 4;

    if (NULL == rawData)
        return -1;
    int row_pitch = (1280 * 4) * sizeof(unsigned char);
    if (fp)
    {
        /*while (!feof(fp))
        {*/
            fread(rawData, size,1, fp);
            //D3D11_SUBRESOURCE_DATA *sSubData = new D3D11_SUBRESOURCE_DATA[1];
            //for (int i = 0; i < 1; i++) {
            //  sSubData[i].pSysMem = rawData;
            //  sSubData[i].SysMemPitch = (UINT)(1280 * 4);
            //  sSubData[i].SysMemSlicePitch = /*(UINT)(1280 * 720 * 4)*/0;
            //}

            //data.pSysMem = rawData;
            // GOT FRAME
            device->CreateTexture2D(&desc, NULL, &pTexture);
            deviceContext->UpdateSubresource(pTexture, 0, NULL, rawData, row_pitch , 0);
            result = device->CreateShaderResourceView(pTexture, &shader, &m_texture);
            if (FAILED(result))
            {
                return false;
            }

    /*  }*/

        fclose(fp);
        fp = NULL;
        free(rawData);
        return true;
```


texts: Directx 11 How to set Texture2D in constant buffer

texts: I have a texture2D packed within my constant buffer. how do i set the texture using ID3D11DeviceContext::UpdateSubresource or another method?


texts: Error binding indices to device context [ STATE_SETTING ERROR #241: IASETINDEXBUFFER_INVALIDBUFFER]

texts:
This is how i initialized the D3D11_BUFFER_DESC for my indices. When i go to bound it to the deviceContext i get this error.

D3D11 ERROR: ID3D11DeviceContext::IASetIndexBuffer: The Buffer trying to be bound as an IndexBuffer did not have the appropriate bind flag set at creation time to allow the Buffer to be bound as an IndexBuffer. [ STATE_SETTING ERROR #241: IASETINDEXBUFFER_INVALIDBUFFER]

And is kinda of strange becouse i setted the bindFlags to "D3D11_BIND_INDEX_BUFFER"

   D3D11_BUFFER_DESC buffDescIndices;

    ZeroMemory(&buffDescIndices, sizeof(D3D11_BUFFER_DESC));
    buffDescIndices.MiscFlags = 0;
    bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    buffDescIndices.Usage = D3D11_USAGE_DEFAULT;
    buffDescIndices.ByteWidth = sizeof(UINT) * ARRAYSIZE(indices);
    buffDescIndices.StructureByteStride = 0;
    buffDescIndices.CPUAccessFlags = 0;

    D3D11_SUBRESOURCE_DATA subResData2;
    subResData2.pSysMem = indices;
    HRESULT hr=device->CreateBuffer(&buffDescIndices, &subResData2, &mBoxIB);

And this is the deviceContext call

    deviceContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);


texts:
I'm working on a tower defense game as a class project and i got it to a kinda working level(creep spawns, towers can shoot etc), but i have a problem with my classes.

Currently the towers shoot but there's no bullets, i'm using an ArrayList to store bullets.

Where should the ArrayList be, on the Game class(manages all the logic) or on the tower class?


texts:
I have been working on a client-server architecture for my multiplayer game.

The server is used for communication between Clients. There is no cheat control because I trusting all clients :) I don't want to control any Physics, Cheats in the server.

My game/connection structure is like:

Client 1 (Admin/Host) <---> Server <---> Client 2

Moving Client 1: sending positon every frame - broadcast to Client 2
Moving Client 2: sending positon every frame - broadcast to Client 1

The movements is interpolated and Client 1 can move smooth in Client 2 screen, Client 2 can move smooth in Client 1 screen.

There is 200-300 ms delay in clients but movements working perfectly.

There is no any problem so far. But... How to SYNC World/Level objects?

I should SYNC World / Level objects because world objects (pushing box) is out-of-sync after few movements. But how I can SYNC it?

I tried, send world object positions from Client 1 to Client 2 every frame. Update world objects in Client 2. But not working, objects is unstable and jumping because 200-300 ms delay in Clients.

I searched solution from http://www.gabrielgambetta.com/fpm3.html but I can't figure out it.


texts: Unity: onEditEnd and onSubmit only firing from Return key

texts:
I have an InputField in my UI, but currently I can only submit its contents via the Return key. I tried mapping other buttons to the Submit action (e.g. the tab key on keyboard and the X button on my joystick), but neither worked. I tested both onEndEdit and onSubmit (via the Event Trigger component).

That said, onClick is being called correctly when I remap my Submit button. I can navigate the menu with my joystick and alternate keyboard controls, but I can't submit the InputField without pressing Return. Why is this?


texts:
I'm back with another question.

I'm trying to get a collision between an actor and a sprite.

With the actor, which only moves upwards and downwards, I've got no problem since it's shape is a rectangle.

But with the other sprite I've got this:

This sprite moves from the very right part of the screen to the left and resets its position when it reaches the left edge of the screen So the actor moves upwards or downwards to avoid it.

The problem is, I can't use a rectangle as a collision detector for this sprite and I haven't found a proper way to do its collision.

The way I call this triangle and the actor's sprite is this:

texture = new Texture(Gdx.files.internal("texturepack_nuevo.png"));

then, out of that single Texture I get a texture region for both the actor and the triangle sprite.


texts: Why is OpenGL point (0,0) not in top-left corner of the screen?

texts: Most of computer graphics systems use screen's top-left corner as staring point, but OpenGL uses bottom-to-top direction, why?


texts: Rotating a cube using jBullet collisions

texts:
How would one go about rotating/flipping a cube with the physics of jBullet?

Here is my Draw method for my cube object:

    public void  Draw() {
    // center point posX, posY, posZ
    float radius = .25f;//size / 2;

    glPushMatrix();
    glBegin(GL_QUADS);
        //top
        {
            glColor3f(5.0f,1.0f,5.0f); // white
            glVertex3f(posX + radius, posY + radius, posZ - radius);
            glVertex3f(posX - radius, posY + radius, posZ - radius);
            glVertex3f(posX - radius, posY + radius, posZ + radius);
            glVertex3f(posX + radius, posY + radius, posZ + radius);
        }

        //bottom
        {
            glColor3f(1.0f,1.0f,0.0f); // ?? color
            glVertex3f(posX + radius, posY - radius, posZ + radius);
            glVertex3f(posX - radius, posY - radius, posZ + radius);
            glVertex3f(posX - radius, posY - radius, posZ - radius);
            glVertex3f(posX + radius, posY - radius, posZ - radius);
        }

        //right side
        {
            glColor3f(1.0f,0.0f,1.0f); // ?? color
            glVertex3f(posX + radius, posY + radius, posZ + radius);
            glVertex3f(posX + radius, posY - radius, posZ + radius);
            glVertex3f(posX + radius, posY - radius, posZ - radius);
            glVertex3f(posX + radius, posY + radius, posZ - radius);
        }

        //left side
        {
            glColor3f(0.0f,1.0f,1.0f); // ?? color
            glVertex3f(posX - radius, posY + radius, posZ - radius);
            glVertex3f(posX - radius, posY - radius, posZ - radius);
            glVertex3f(posX - radius, posY - radius, posZ + radius);
            glVertex3f(posX - radius, posY + radius, posZ + radius);
        }

        //front side
        {
            glColor3f(0.0f,0.0f,1.0f); // blue
            glVertex3f(posX + radius, posY + radius, posZ + radius);
            glVertex3f(posX - radius, posY + radius, posZ + radius);
            glVertex3f(posX - radius, posY - radius, posZ + radius);
            glVertex3f(posX + radius, posY - radius, posZ + radius);
        }

        //back side
        {
            glColor3f(0.0f,1.0f,0.0f); // green
            glVertex3f(posX + radius, posY - radius, posZ - radius);
            glVertex3f(posX - radius, posY - radius, posZ - radius);
            glVertex3f(posX - radius, posY + radius, posZ - radius);
            glVertex3f(posX + radius, posY + radius, posZ - radius);
        }
    glEnd();
    glPopMatrix();

}

This is my update method for the cube position:

    public void Update() {
    Transform trans = new Transform();
    cubeRigidBody.getMotionState().getWorldTransform(trans);

    posX = trans.origin.x;
    posY = trans.origin.y;
    posZ = trans.origin.z;

    Quat4f outRot = new Quat4f();
    trans.getRotation(outRot);
    rotX = outRot.x;
    rotY = outRot.y;
    rotZ = outRot.z;
    rotW = outRot.w;
}

I am assuming I need to use glrotatef, but it does not seem to work at all when I try that..

this is how I have tried to rotate the cubes:

    GL11.glRotatef(rotW, rotX, 0.0f, 0.0f);
    GL11.glRotatef(rotW, 0.0f, rotY, 0.0f);
    GL11.glRotatef(rotW, 0.0f, 0.0f, rotZ);

Here is how I am getting the XYZ for the cubes from jBullet:

    public void Update() {
    //cubeTransform = new Transform();
    cubeRigidBody.getMotionState().getWorldTransform(cubeTransform);

    posX = cubeTransform.origin.x;
    posY = cubeTransform.origin.y;
    posZ = cubeTransform.origin.z;

    processTransformMatrix(cubeTransform);
}


texts: How to open prerequisite retrieval application

texts:
I have an application that cannot use OneClick publishing.

I still want to access those nice prerequisite (applications?) that install .NET and XNA for you when you create a OneClick publisher.

I can check if the frameworks are needed via the registry, but is there anyway to get something similar to what the setup.exe consists of in a publish?


texts: How are scripted camera usually managed?

texts:
I noticed that many open games (think platformers, adventure, action...) have very complex cameras that appear to mix both automatic placement most of the time, and sort of pre-placed camera locations.

How are these usually implemented? Is it just some sort of zone trigger that then launches an interpolation between the last camera state and the scripted camera for the zone, or are there more special details?


texts:
I'm trying to implement parallax scrolling and have a partially working equation (from a book I've read) but it doesn't fully align to the screen.  I also want to stick purely to integer maths.  I've played around with it a lot and tried alternate approaches but can't get it right.

Unfortunately the book doesn't go into detail of how the maths is supposed to work it just glosses over it.

The calculation is:

x * (screenWidth - layerWidth) / (screenWidth - playfieldWidth)

Variables I'm inputting are the following values:

x = Player x Position within playfield width
the others should be self explanatory

The book also calculates x as (screenWidth / 2 - playerX - tilewidth) which I've tried.

The only difference I can think of is that to the book the player X co-ordinate is left of the player where for my engine it's the centre, but I changed - tileWidth to account for that to no avail.

The way it should work is when the player is at 0 the left-most pixel of the layer should be at the left edge of the screen and when the player is at (playfieldWidth - 1) then the right most pixel of the layer should be touching the right of the screen.

I finally figured it out, after tracking down the fact that I had a small rendering bug that shifted things a few pixels (oversight from adding overscan)

The final algorithm is as follows and works as long as layer is equal to or lower than screen width which i derived from scroll bar maths

public static final int calculateScroll(final int scroll, final int minScroll, final int maxScroll, final int contentSize) {
    return (scroll - minScroll) * contentSize / (maxScroll - minScroll);
}

scrollX = calculateScroll(playerX, 0, playfieldWidth, screenWidth - layerWidth + 1);

I'm sure it will work for layers that are larger than the screen width just need to figure out the right input values

After further playing I realised the variable I was using for testing the larger than viewport layers was incorrect and throwing everything off, that's now been fixed and i've refined the final function

  public static final int calculateScroll(final int scroll, final int minScroll, final int maxScroll, final int contentSize, final int viewportSize) {
    return (minScroll / 2 - scroll) * (contentSize - viewportSize) / (maxScroll - minScroll);
  }


texts: Efficiently checking input and firing events

texts:
I'm writing an InputHandler class in XNA, and there are several different keys considered valid input (all of type Microsoft.XNA.Framework.Input.Keys). For each key, I have three events:

internal event InputEvent XYZPressed;
internal event InputEvent XYZHeld;
internal event InputEvent XYZReleased;

where XYZ is the name of the Keys object representing that key. To fire these events, I have the following for each key:

if (Keyboard.GetState().IsKeyDown(XYZ))
{
  if (PreviousKeyState.IsKeyDown(XYZ))
  {
    if (XYZHeld != null)
      XYZHeld();
  }
  else
  {
    if (XYZPressed != null)
      XYZPressed();
  }
}
else if (PreviousKeyState.IsKeyDown(XYZ))
{
  if (XYZReleased != null)
    XYZReleased();
}

However, this is a lot of repeated code (the above needs to be repeated for each input key). Aside from being a hassle to write, if any keys are added to/removed from the keys (if functionality is added/removed), a new section needs to be added (or an existing one removed).

Is there a cleaner way to do this? Perhaps something along the lines of

foreach key
  check which state it's in
  fire this key's event for that state

where the code does the foreach (automatically checking exactly those keys that "exist") rather than the coder?


texts:
I am trying to create a physics engine for my game, and need to cancel out any lateral velocity for when entities turn. I have tried to mimic this page's example, but it is not working. I have objects sliding sideways, as if they continued to have no friction.

Could you please check my friction equation below and make sure I have the proper variables plugged into the right places? If everything checks out I can do some more intensive debugging.

Vector2d lateralnormalized = new Vector2d(1, new Angle(heading));
lateralnormalized.invert();
double dot = Vector2d.dotProduct(lateralnormalized, velocityvector);
Vector2d lateralvelocity = new Vector2d(lateralnormalized);
lateralvelocity.multiplyInline(dot);

// Multiply by mass to get impulse
lateralvelocity.multiplyInline(-1 * getMass());
applyImpulse(new Vector3d(lateralvelocity));

Vector2d(int, Angle) creates a new vector of magnitude int at angle Angle.

Vector2d.invert() rotates the vector pi/2 radians (90 degrees).


texts:
After following some of the Unreal tutorials, I was able to create an AI that tracks the player. Now I want it to target specific buildings. I have tried various methods of modifying what was demonstrated in the Unreal videos but all I can get my AI controller to do is either stand in place or walk to the center of the nav mesh. Here is an example of what I have done:

If anyone can help, how can I get my AI to attack the Armory? Thanks.


texts: Implement Bubble Shooter arrow rotation using LibGDX?

texts:
I'm trying to implement an arrow at the bottom of the screen on an Android device. This arrow is placed in the center of the screen and is supposed to rotate by a given angle. The problem is that when using the SpriteBatch's draw function for a TextureRegion it rotates the whole image, so the y coordinate also moves up a bit.

I want the arrow to always be in the center of the screen with the x, y coordinates and not move up the y coordinate. I want the y coordinate to stick to the bottom of the screen, but I still need to rotate the arrow. So I don't know if this is possible in my approach to do this.

If you have an approach in LibGDX that is very different from mine. I still want to see it because I don't care how I get this to work, I just want to get it to work somehow.

This far I've found this
Rotation - libGDX that helped me get the rotation a little better, but I need an arrow like in the game called Bubble Shooter.
Image of Bubble Shooter Arrow

The arrow should be the radius inside of an invisible circle, I guess, is one way to see it. See images below.

Example:


texts:
I googled like crazy and checked the OpenGL documentations but I couldn't find out how the precision of a depth buffer created using GL_DEPTH_COMPONENT is chosen.

As far as I know the precision is implementation dependent. But how will the precision be chosen? Will it always use the highest precision possible or rather the fastest one? Or is no general answer possible?

Shoud I always go with GL_DEPTH_COMPONENT32 instead?


texts: Rotating an object when the center in not the origin - opengl

texts:
I'm beginning with GLSL and I learning the basic, I  am using glm to do the matrix calculations at this point everthing ok,the problem is how I can move the origin to the center of my object, not the other way round,
for example if I have a quad whose coordinates are
bottom left  0,0.
bottom right 2,0.
top left     0,2.
top right    2,2.
how can I move the origin to the center of the quat without re-writing my coordinates?


texts:
Just a heads up, I'm sure there are much more efficient ways to do what I'm trying to do. I've even thought of some myself. However, at the moment, I'm mostly interested in getting this code to work. I think I understand exactly why it doesn't work, but I'm not sure how to fix it.

Firstly, there is an ItemPickupTrigger script attached to the drop prefab. The purpose of this script is simply to modify a variable's truth value depending on whether or not the player is in range. This script must be attached to the drop prefab because it uses OnTriggerEnter/OnTriggerExit. No problem here.

Secondly, there is a pretty standard EnemyDrops script.

public class EnemyDrops : MonoBehaviour {

    private EnemyHealth enemyHealth;

    public GameObject dropPrefab;

    private float randomNumber;

    public bool objectDropped;
    private bool numberGenerated;

    public GameObject drop;

    // This is the correct offset for enemies' current y-position of 1.083333
    private Vector3 dropPositionOffset = new Vector3(0f, -0.958333f, 0f);

    void Start()
    {
        enemyHealth = GetComponent<EnemyHealth>();
    }

    void Update()
    {
        if (enemyHealth.isDead && !objectDropped && !numberGenerated) {

            randomNumber = Random.value;
            numberGenerated = true;

            if (randomNumber <= 1.0)
            {
                DropObject();
            }
        }
    }

    private void DropObject()
    {
        objectDropped = true;

        drop = GameObject.Instantiate(dropPrefab, transform.position + dropPositionOffset, Quaternion.identity);
    }
}

It drops the object where the enemy has been killed. This script is attached to each enemy. As it's currently set up for testing purposes, an item will always drop. I'm sure there are better ways to do this, but it works, so no problem here.

Finally, there is an ItemPickup script attached to an ItemController object which is otherwise pretty empty. I'm not even really sure why I decided to do it this way, I just thought that it might be better for things I wanted to do in the foreseeable future to not have this script attached to each enemy. Now get ready because the code below is problematic.

public class ItemPickup : MonoBehaviour {

    private GameObject pickupWindow;

    private bool windowOpen;

    private GameObject drop;
    private ItemPickupTrigger itemPickupTrigger;

    void Start()
    {
        pickupWindow = GameObject.Find("Pickup Window");
        pickupWindow.SetActive(false);

        drop = GameObject.Find("Drop");
        itemPickupTrigger = drop.GetComponent<ItemPickupTrigger>();
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R) && itemPickupTrigger.playerInRange && !windowOpen) {
            pickupWindow.SetActive(true);

            windowOpen = true;
        }
        else if (Input.GetKeyDown(KeyCode.R) && windowOpen)
        {
            pickupWindow.SetActive(false);

            windowOpen = false;
        }
    }
}

For starters, it only works if there is a drop object already present when the script begins, but there shouldn't be a drop object then. Second, if I don't set the reference there, I'm not sure how to set itemPickupTrigger's reference, since I'm using it in update and need the reference set before then. Make a function called SetReferences() and call it early in Update()? Yeah, I'm pretty lost. Basically, I want to be able to open the "loot window" near any instantiated drop object in the game. Currently, that functionality only in a limited capacity (either only on a "preexisting" drop object in the scene or on one random instantiated drop object(?) depending on how I have been modifying the code). Help!


texts: Legal considerations when starting a game development team

texts:
I am about to start a project with two other developers and an artist, who I still haven't found. I'm not sure how exactly should we handle that from a legal perspective, though.

Are we supposed to sign a contract? What should be stated in such a document?

The game will most likely be free.


texts: What are some ways to store level data in a game like Gunpoint?

texts:
Gunpoint is a 2D stealth game available here. I was wondering how you might go about storing level data for a game like this. I'm mostly concerned about how the collision detection is saved. There are several types of things which need to be stored; solid objects (walls, floors/roofs), breakable objects (glass), and editable objects (doors, light switches). A tile based approach may work, but I think that getting small details like light switches in there would get hairy quick.

(source: steamstatic.com)


texts: creating a simple cartoon like light effect

texts:
I could like to create a really simple light engine that does not eat to much CPU and will produce this effect:

I am using libgdx for my game with box 2D light (which is too heavy for my needs). I have no idea of what is the best solution to create this effect (shapeRenderer? pure shader?). For the moment I don't need any shadow casting, but I would like to be able to maintain multiple light sources and to add color to the light.


texts:
I have a game - virtual soccer manager. It is browser based game. It is split into 'seasons' each of them takes around a half of a real year. The central game element is a soccer match, each team plays around 40-50 matches per season, there are roughly a thousand of teams.

Each match has a lot of match related data: game moments description, amount of experience earned by each team player during each match, etc...

Web site has around 200-600 users in different times and exists almost 8 years. For this time game get a ton of data. All data are saved in MySQL DB (5.1).

My problem is that tables size is growing constantly. It is not the problem on its own, but when I do some data maintenance (add new fields into existing tables, change field type, etc.) it takes a ton of time to execute those queries.

From one side, I don't really want to delete aged data (that is more than 5 years old) as potentially users could be interested in looking into them. from another side, 5 years old and older data are not really concerning and COULD be deleted.

Question: what is good practices for keeping/archiving data in general and for online games in particular?

P.S. Probably I should ask on another site?


texts:
Hey all , I want to make something more interesting in my game some thing like a charts Analysis for a flash game. When THE PLAYER FINISH THE GAME  . The score appears in charts . I want to integrate it with actionscript3 .

NOTE

The game is 60 seconds only I want to draw the score of the user in Y-axis And the Time in X-axis .

I read before about highcharts, but i didn't get much information if there are something easier I'll be grateful .
something like that


texts: Unity only rendering certian parts of 3d building model from certian angles

texts:
So I made a couple modular building sections in blender, modular in the sense that I can insert build a floor at a time. I transferred them into Unity and then I got a rendering error that  I have gotten many times before. I will put the object in the game world and then certain chunks of the building will only be visible from on direction and the other it will be completely invisible. I have been having trouble with this bug for a long time and I really would like if someone could point out what's causing this problem. I will include pictures below to help show my problem.

Thanks, Nova


texts: Calculating required force for pushing a body to a desired position at once in Unity

texts:
In a 3D world I simulate that a coin is being pushed over a plane (applying a force in his rigidbody where y-axis = 0) using a top-down view.

Some time ago but using Box2D, I was able to calculate the amount of force required to stop the coin in a desired position with just one push.

Box2d-js

var fps=60;
var groundFriction = 0.01;
var force= new Box2D.Common.Math.b2Vec2(distance.x * coin.box2dBody.GetMass() * fps * (groundFriction * fps),
      distance.y * coin.box2dBody.GetMass()* fps *(groundFriction * fps));
coin.box2dBody.ApplyForce( force, coin.box2dBody.GetWorldCenter(), true );

In order to simulate the friction, during the update, I substracted the groundFriction(0.01) to the linearvelocity of the objects in movement in every frame.

Now using Unity with a more complex physics engine I cant replicate the same.

Unity3d

Vector3 posFinal = transform.position + direction * distFinal;
Vector3 distanceVecFinal = posFinal - transform.position;
float fps= 1/Time.fixedDeltaTime //50 fps
Vector3 force = new Vector3(distanceVecFinal.x  * myBody.mass * fps, 0,
     distanceVecFinal.z  *    myBody.mass * fps);
myBody.AddForce(force);

I think that in the final formula I should add the friction of the objects, but I am not sure how to do it. Maybe this is not the only thing that I should change.

I need help pls!

tl&dr Calculate the required force for making move an object to a desired position in a plane with just one push.


texts: How to generate caves that resemble those of Minecraft?

texts:
I've been working on a 3D procedural world for a while now and am wanting to start adding cave systems. I'm currently using 2D/3D Perlin Noise for the terrain generation in combination with Marching Cubes for smoother terrain. I'm just getting stumped when it comes to long interconnecting caves.

I'm hoping to get something more like Minecraft's cave systems. They seem to be very connected, branch off randomly in nearly any direction, and nearly any point in the cave would have a fairly circular look with a fairly equal radius throughout (not the best wording, but not quite sure how else to put it).

The biggest challenge for generating caves like I'm wanting is that I want to generate the world on the fly. The world is generated chunk by chunk currently, starting where the player is and it generates outwards from there. I would NOT want to generate any of the world and then dig the caves out using a wandering pattern, cellular automata, etc.

Are there any well known algorithms that can be used for this? If so, does anyone want to share how they do something similar? I'd greatly appreciate any help.

A good example:


texts: Is an extra collision-mesh for level-data worth the hassle?

texts:
What is the optimal approach for collision-detection with the environment in an 3D engine (with triangle mesh based geometry, no bsp)?

A) Use the render mesh

[+] no need for additional work for artists to fiddle with collision detection
[-] high detail is harder for physics calculation
[+/-] maybe use collidable flags for materials
[+/-] compute the collision-mesh from the render-mesh

B) Use an additional collision mesh

[+] faster/more optimal collision-detection
[-] additional work (either by the artist or by the programmer who has to develop an algorithm to compute it from the render-mesh)
[-] more memory useage

How do AAA title handle this?
And what are the indie dev's approaches?


texts: How to save slider button positon on saved value.?

texts:
I am new to game dev.
I have below code and it`s work good. I can change volume using this code and with AudioSource slider script. I also saving this volume state using playerprefs from 0-1.  My problem is I can not keep slider button to its saved value when reload / replay the game.

If slide has value like .72 or anywhere between 0-1. then audio play with perfect saved volume but button not set to .72. Any one can help.

How can i save button position on saved value when start play again.

My code is...

using UnityEngine;
using System.Collections;

public class vfxslider : MonoBehaviour {

void Awake(){
    GetComponent<AudioSource> ().volume = PlayerPrefs.GetFloat ("CurVol");
}
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
//  AudioListener.volume = PlayerPrefs.GetFloat ("CurVol");
}

public void slidervolumecontrol(float volumecontrol){
    GetComponent<AudioSource> ().volume = volumecontrol;
    //audio = GetComponent<AudioSource> ().volume;
    // audio.volume = volumecontrol;
    PlayerPrefs.SetFloat("CurVol",GetComponent<AudioSource> ().volume);
    PlayerPrefs.Save ();
    }
}

In first picture I have sated volume value of first VFX slider to 0.60800. On this I can listen music.

but in second When i stop playing and play again then slide button remain in zero position but still i can hear music.and also I can not see saved value of volume in right side. check that volume is zero but still I can hear music with 0.60800 value.


texts:
I've made a character, attached a camera to it and setted input. But now i want only character's head to rotate with mouse, but not a whole character (player capsule rotates with Q and E keys). I tried to attach camera to head socket, but it doesn't work (i think it's a wrong way). How can i do it on C++? Thank you!

P.S.
I know, that it's a stange idea (control like this will be uncomfortable probably), but it's my work-task and i find it very intersting.


texts: Cant set up to get input from second analog stick

texts: So I know for a fact that the stick on my gamepad is working. The problem is I cant set it up in the Input Manager. I tried all possible Axis configurations and still getting a input values of 0. Here is a screenshot of the configuration.


texts: Fixed distance between character and ground whatever slope value

texts:
I am working on character moving on any ground meaning whatever slope degree ,the result i got is the character does not moving on just shake in his place
the following the code i wrote

public float speed = 1;
bool isMoving;
Transform childPosition;
Rigidbody rb;

private void Start ( )
{
    rb = GetComponent<Rigidbody>();
}

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

    if (Input.GetAxis("Horizontal") > 0)
    {
        rb.velocity = new Vector3(1f, rb.velocity.y, rb.velocity.z);
    }
    else
    if (Input.GetAxis("Horizontal") < 0)
    {
        rb.velocity = new Vector3(-1f, rb.velocity.y, rb.velocity.z);
    }
    else
    transform.position += transform.forward * Time.deltaTime * speed;

    detectRoad();
}
private void detectRoad()
{
    Ray ray = new Ray(transform.position, -transform.up);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit))
    {
        transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
    }
    if (hit.distance < 0.6f)
    {
        transform.position += transform.up * Time.deltaTime;
    }
    else
    if (hit.distance > 2f)
    {
        transform.position += -transform.up * Time.deltaTime;
    }
}
   `

This animated gif is about what I want:


texts:
Hey everyone just some css and styling tips needed! i want to use a game as a 404 page. so i would need on top to be either text or a contact form then some spacing and then the actual game window. iframes dont work that good on mobile devices and by doing a simple div in unity index although on mobile it works rather crude but nice, on desktop the text is going behind the unity game window. any tips please? Note that im adding the style in the index.html and not using the separate css file in the template folder.
So to sum up how can i make another div centered in the page and well responsive for mobile above the game container and add a margin on the bottom of that div!
Thank you!!


texts: How can I store spell & items using a std::vector implementation?

texts:
I'm following along with a book from GameInstitute right now, and it's asking me to:

  Allow the player to buy and carry healing potions and potions of
  fireball. You can add an Item array (after you define the item class)
  to the Player class for storing them, or use a std::vector to store
  them.

I think I would like to use the std::vector implementation, because that seems to confuse me less than making an item class, but I am unsure how to do so. I've heard from many people that vectors are great ways to store dynamic values (such as items, weapons, etc), but I've not seen it used.


texts:
When I hit an object, my Fighter is supposed to fall to the Ground but because of the Accelerometer, I can still move it up and down even though it died. The Scroller on the x-Axis though stops.
Question: (FIXED) How can I make the Accelerometer stop, after I've been hit, and make the Fighter accelerate to the ground (in absence of the accelerometer, all by itself)?
When I move the Fighter up and down, the transition from "moving up" to "moving down" isn't smooth. It seems like it lags.
Question: How can I Increase the Sensitivity of my Accelerometer?
Also, when I tilt the phone further, the velocity stays the same.
Question: How can I increase the velocity, in relation to the tilt degree?

The code is below:

Accelerometer Code:

float accelY = Gdx.input.getAccelerometerY();

if (Gdx.input.getAccelerometerY() < 5){
   velocity.y = -40;
}

if (Gdx.input.getAccelerometerY() > 5){
   velocity.y = 40;
}

When Fighter hits an Object and dies:

public void die() {
    isAlive = false;
    velocity.y = 0;
    acceleration.y = 460;
}


texts: I've been developing casual iPhone/iPod Touch games touch for about two years.  I'd like to port some games to the Android platform.  Since I'm stuck w/ a two year iPhone contract I don't want to get an Android phone that requires a service plan.  What is the best phone to get for development in this situation?


texts: Should all primitives be GL_TRIANGLES in order to create large, unified batches?

texts:
Optimizing modern OpenGL relies on aggressive batching, which is done by calls like glMultiDrawElementsIndirect. Although glMultiDrawElementsIndirect can render a large number of different meshes, it makes the assumption that all these meshes are made of the same primitives (eg. GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_POINTS).

In order to most efficiently batch rendering, is it wise to force everything to be GL_TRIANGLES (while ignoring possible optimizations with GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN) in order to make it possible to group more meshes together?

This though comes from reading the Approaching Zero Driver Overhead slides, which suggests to draw everything (or, presumably, as much as possible) in a single glMultiDrawElementsIndirect call.


texts:
I'm trying to wrap my brain around the concept of creating a server/client multiplayer experience.

My problem is mainly related to timestep.  Consider the following scenario:

A client connects to a server.  The client sends his inputs to the server to indicate he wants to move.  Server simulates the input and determines the position of that client in the game world.

Since the client and the server are both running on different timesteps, how do you accurately simulate so that all clients are in sync with the server?   My server is currently set at at 30ms timestep.  When I process client movements, there are potentially hundreds of requests waiting to be processed, yet no way to indicate how long it took between each one of the requests.

I'm really not grasping how to properly simulate on the server based on time, in order to have everything sync up.


texts: How to use friction to bring object to a stop in a simple 2D platformer?

texts:
I'm coding the physics for a little platformer I'm making but I'm not sure how to design a friction calculation that does what I expect. When running along a platform I want the player's character to pick up speed but be prevented from going too fast due to friction counteracting their movement. Then, if they stop running I want them to continue to run for a little bit proportional to their speed (if they're going slow they should stop almost instantly).

void Update(V2!float forces, Elapsed time){
    position += (velocity * time.deltaS);
    forces -= 0.5 * velocity^3; //friction???
    velocity += (forces * time.deltaS);
}

The forces variable contains anything accelerating the object such as gravity, or acceleration from the player hitting a directional key, etc. What keeps happening is that whatever I try to plug in as friction doesn't bring the object its moving to a nice clean stop. It will look like it's stopped but then move a pixel or two after that because its velocity, while very small, doesn't hit zero for several seconds.

I can fix this with a bunch of conditional statements, but if there's a simple solution I'd much rather do that!


texts: How should I handle different aspect ratios in a fullscreen game?

texts:
I am creating a game using C#, GDI+ and Raster images (2D images).  For performance sake, I believe that I should have the game change the user's resolution to 800 x 600 and run the game in that setting.  However, the graphics look distorted in a wide screen since the aspect ratio for 800 x 600 is different than from a wide screen.  I cannot figure out how to determine the aspect ratio.

How is game programming normally handled on different resolutions?  Should I even change the user's resolution?  If I dont change the resolution, the game slows down a lot.

Also, some wide screens will "maintain the aspect ratio" when changing the resolution to 800 x 600 (thus creating black bars on the right and left) and some wide screens will fill up the entire screen.  How do people handle that situation??