texts:
I have a 2D grid (x,y coordinates) where each cell corresponds to each pixel of the interface that I am working with and I have a point A(x1,y1). Now I need to travel around in the grid, and I wont just move this single point, but would like to move a bunch of points together. Now what do you think is the best figure that I shall move, i.e. a circle with a predefined radius, or a square with a fixed side.

Also, once I decide upon the figure, I need to know, what all points are there in the figure, given a specific central point, and work with those points too.

I was thinking that a square would be a better idea, since I'll just have to check the if the difference of the coordinates of the point to be checked from the central point is less than side/2.

But I've heard that calculations with circle are not bad either.

Kindly suggest,


texts:
I'm making a top-down action / horror game, and I'm in the process of adding a "save game" feature. However, I'm torn between having automatic checkpoints throughout the level and letting the user save the game whenever they please.

What are the pros / cons of each approach?


texts: Is there a tool to make a Spritesheet out of 1000 PNG's?

texts:
My graphics designer has made graphics in separate PNG files. Is there a clever tool/script that mashes them into a spritesheet?

I could probably code something myself, but why re-invent the wheel :)


texts:
I'm trying to put my game view and scene view next to each other, but the game window seems to have a border around the actual game view that I can't remove:

In the screenshot above, the game view should be touching the sides. I've tried changing the aspect ratio setting at the top to no avail, increasing the scale works to remove the border but that also zooms in so isn't a correct representation of the game. Does anyone know how I can remove this border?


texts: Generating background tiles for a side-scroller with variable player speed

texts:
I'm currently working on a side-scroller which lets the player alter their speed and I wondered how should I properly generate and control background tiles for such a kind o game. I'm using Flixel but I believe it's a strictly mathematical problem. Here's how I see and do it right now:

actually the player is static but he has a pseudo-velocity, that can be increased and decreased (but there is some minimal pseudo-velocity)
tiles are random so they are not kept in any tilemap - they are generated by an emitter instead
background tiles observe player's pseudo-velocity and alter their own velocity (base velocity is static for a given tile but different tiles can have different base velocities) based on it (so they use their velocity to move in the opposite direction to the player but they also increase/decrease this velocity according to the player to create the illusion of acceleration/deceleration)
the starting velocity of each background tile is maintained no matter what the pseudo-velocity of player is (so when the player accelerates, two given tiles with different velocities approach faster to the player but there is no change in the delta of their velocities, so you can say  that one tile aproaches the player fast and the other even faster :-))
background tiles are generated based on same frequency which is also dependend on the player's pseudo-velocity (so when for example the velocity of all tiles is constant, the distance between consecutive tiles is also constant but when the player accelerates, the frequency of tile generation should increase to retain the same distance between generated tiles)
and the last one trick: when the player is moving at minimal speed their sprite is located exactly on the center of the screen but when they accelerate the sprite floats to the left edge of the screen (proportionally to the current speed but with some lag) so the player can see more and has more time to react

Ok, now it's finally time for the problems! :D

I cannot come up with the proper formula for the tile generation frequency according to the player's pseudo-velocity (when the player accelerates the frequency increases too slowly and the distance between tiles increases, and when the player decelerates the frequency decreases also too slowly and the distance between tiles gets much too small, they begin to clutter)
the problem is also intensified by the last point of the above list - when the pseudo-velocity increases the player's sprite is moved to the left so the tile generation frequency should be additionally increased (and respectively delayed during player's deceleration)

Phew! I think that's a whole description of the problem. Has any of you ever fiddled with such a game mechanic and if yes, have you encountered similar problems and what were your solutions?

If the description is not clear enough, please let my know and I'll provide working example showing above concerns.


texts: Easiest way to smoothen coarse mesh with HLSL?

texts:
I've browsed through a couple of presentations and papers about DX11 tessellation and they all say that one of the most common usages of tessellation is to take a coarse (low poly) mesh, smoothen it and then apply displacement mapping. They mention mainly two smoothening algorithms (although I might be wrong, I'm new to the topic): Catmull-Clark and PN Triangles. The former's algorithm is pretty simple to understand but honestly I don't know how to implement that with HLSL. PN Triangle's algorithm seems pretty straightforward.

But maybe there are other important algorithms. Which one is the easiest to implement? Or maybe one is significantly faster that the others?

Or maybe I'm doing it all wrong? :P


texts: How do I open/edit a *.xnb file in XNA Game Studio 4.0?

texts:
I've downloaded a *.xnb font sprite, but I don't know how to open/edit it. I installed XNA Frameword 4.0 in VS 2010.
Thanks for your help!


texts:
I have a Quad Tree implementation that is very useful for what I am trying to do.  My problem is that when my viewport has a lot of objects, the Update for the Quad Tree takes a very long time.

It is a known fact that Quad Trees are slow for non-static objects.  I tried a few methods to try to speed things up, but the fact is, I need to update a large number of objects very often.

Is there a better algorithm I should be looking at instead?  Are there some derived Quad Tree implementations you know about that might be useful to me?


texts: How do you compute the tangent space vectors with normals given in the mesh?

texts:
Suppose you are given a mesh with normals for each vertex. These normals might not correspond to the face normals, as the artist could have tweaked them. In this case, how would you go about computing the tangent and binormal vectors for the vertex?

The best algorithm I can think of, and the one that looks to be used by assimp, is to take all the faces in a given smoothing group and compute the tangent and binormal per face. Once that is done, project them into the plane determined by the normal and average over all the faces in the smoothing group.

I am uncertain as to whether this algorithm works exactly as needed. For example, does the projection operator preserve the angle between the tangent and binormal?

Another issue I have is that the assimp implementation of the algorithm does not seem to use the smoothing groups specified in the mesh. They instead seem to calculate the smoothing groups manually using nearby vertices. What is the advantage of doing this?

Finally, is this the ideal algorithm? Some other things I have found (such as this) seem to suggest that it is not, but they do not go into any more details.

EDIT:

So I checked out the MikkTSpace algorithm that was suggested in the comments, and while it answers my question of what the industry standard method for generating tangent spaces is, I do not fully understand why the algorithm works.

As described in the paper, the algorithm works by collecting triangles into groups and then averaging the tangent spaces for each individual triangle in the group. I ran into two problems understanding this: first and once again, why discard the smoothing groups specified in the mesh? It seems wasteful to discard information that is already given to you about how the mesh is supposed to appear.

Secondly, how do the groups even work? The paper specifies that two triangles are considered to be in a group if the share two vertices, two texture coordinates, and two normals. The first two requirements make sense to me, but the third does not. Suppose you are approximating a sphere by something like an icosahedron. In this case there will be no vertex normals shared by any two vertices, so each individual triangle is going to have its own tangent space. This seems counterintuitive.


texts: What are some gameplay cases where knowing the Z as a result of the raycasting is useful in a 2D setting?

texts:
The context is an 3D engine with a 2.5D level format. Like a roller coaster tycoon level, with some other level features added, and layers removed. For example the tile functions have the following interface.

markTile([3, 5]);

This statement places a mark on the tile located at 3x5. This tile can be on top of a mountain or a cave, but different tiles on the same height can't exist, so the Z axis isn't needed. Internally everything is in 3D, but it isn't exposed to the interfaces since there can't be more than one tile at the same X, Y position.

Because the tile functions are 2D, units also store their positions in 2D.

markTile(unit.position); // place a mark where the unit is

There are also cases where knowing the Z of an unit is useful, but it is almost never about the tile or the placement position. For example it is useful to create a sprite or an exclamation mark on top of an unit, but that is done by using the Z from the tile and the height of the unit. That interface also uses an unit as the parameter, not a position, because multiple units can be on the same position unlike a tile.

placeExclamationMarkOnUnit(unitId);

Now, I am wondering, is there a need for the raycaster to even return the Z data in this setting? I can't think of a gameplay case. I can think of cases where the unit height is important, but none that would need to know the Z from the ray. I can also think of cases where I could want to place an effect on an exact position on the unit, but that can be done by just X and Y(floats, not ints) as well.

Thanks.


texts: How do I distribute MonoGame games in Windows?

texts:
I'm using VS2013 and MonoGame to create a simple game. The things is I can't make it run on others PCs.

I've tried to copy Content to the Release folder using the "always copy" option in VS2013;
I've tried to add the OpenAL and wrap_oal DLLs to the Release folder too but it is not working;
I've tried to Publish the game using this functionality of VS2013 but no success neither.

Am I forgetting something?

Edit: I'm using the OpenGL template (I've tried the DirectX but had the same problem).


texts: Grab depth buffer with unlockable D3DFORMAT

texts:
I'm currently piggy backing on a mod framework (Multitheft Auto) and trying to read the depth buffer in D3DFMT_D24S8 (DirectX9). I can read it if I change the format to D3DFMT_D32F_LOCKABLE and then lock the rectange but this causes the render to be blurred like so:

I'm currently open to hacky methods like finding the pointer to the buffer and reading the depths without properly locking and/or using CUDA. Any advice would be greatly greatly appreciated. Thanks!


texts: In pygame, is there no graphicsContext.translate() method?

texts: I am new to pygame. I was searching on the internet and the pygame documentation for the functions which can translate, rotate, scale the entire graphics Context, but I couldn't find them. I know that I can apply transformations on individual surfaces using functions that are present in pygame.transform module, but I couldn't find the functions that will apply transformations to the graphics context itself. Are these functions in a different module or they don't exist?


texts: How do I create a view matrix that does not contain the camera translation?

texts:
I'm looking at this tutorial
https://capnramses.github.io/opengl/cubemaps.html
about half way down the webpage, there is a description of a vertex shader

#version 400

in vec3 vp;
uniform mat4 P, V;
out vec3 texcoords;

void main() {
  texcoords = vp;
  gl_Position = P * V * vec4(vp, 1.0);
}

  The P and V matrices are my camera's projection, and view matrices,
  respectively. The view matrix here is a special version of the
  camera's view matrix that does not contain the camera translation.
  Inside my main loop I check if the camera has moved. If so I build a
  very simple view matrix and update its uniform for the cube map
  shader. This camera only can only rotate on the Y-Axis, but you might
  use a quaternion to generate a matrix for a free-look camera. Remember
  that view matrices use negated orientations so that the scene is
  rotated around the camera. Of course if you are using a different
  maths library then you will have different matrix functions here.

I'm having difficulty figuring out how to construct this matrix in my program. How would I construct it from a projection matrix, view matrix, or camera matrix? (These are the matrices already within my program)


texts: A guide on multi-direction and multi-animation sprites?

texts:
In YoYo Game Maker Studio: Is there a way (or an already-created library) I can specify all the possible sprite frames and directions in a way I am allowed to do it in Clickteam Fusion?

As far as I read in the docs, I create Sprite resources which are linear: An image resource can be loaded and read in columns and rows, but a single sprite is generated. However, what I want to achieve is the following:

Import a single image with layout like this:

llll
rrrr
uuuu
dddd

Meaning four frames per direction (left, right, up, down).
Allow my sprite to have four directions. In such case, the animation will involve just the row corresponding to the direction.
Allow the user to stay / not move. In such cases, I would use another image like this (most of the times it would be a subset of the former):

l
r
u
d

Question: Before doing it in the hard way (which for larger games I did in ActionScript already; I'm not net at all at coding) I would like to ask:

Is there an already supported way in the environment to do it? Like managing the related sprites as a set.
Alternatively: Any good 3rd party plugin which already does that?

I have no problem at all with coding the solution on my own, but honestly I would not like to reinvent the wheel.


texts: What functions should be called in C++ gameloop from Lua Script

texts:
I am using sol2 lua wrapper for my 2D game-engine to implement some lua scripting,but I have some questions about what should functions should i call from Lua scripts in c++, and i cannot find any good resources about this topic.

For example. lets say that i am trying to render a sprite on the screen, which sprite is created inside a lua script. As usually the sprite should call render() function every frame, my question is that, should i call every frame functions from Lua in my game-engine loop ? or its bad habit? i mean can i have a structure in lua like below :

function init()
   --called only once
end

function render()
  --called every frame in C++ gameloop
end

or should I implemented in other way?
Can someone suggest me any books about this matter or any good resources ?


texts: Problems using easing equations in C# XNA

texts:
I'm having some trouble using the easing equations suggested by Robert Penner for ActionScript (http://www.robertpenner.com/easing/, and a Flash demo here) in my C# XNA game. Firstly, what is the definition of the following variables passed in as arguments to each equation?

float t, float b, float c, float d

I'm currently calculating the new X position of a sprite in the Update() loop, however even for the linear tween equation I'm getting some odd results. I'm using the following values:

float t = gameTime.TotalGameTime.TotalMilliseconds;
float d = 8000f;
float b = x.Position.X;
float c = (ScreenManager.Game.GraphicsDevice.Viewport.Width >> 1) - (x.Position.X + x.frameSize.X / 2);

And this equation for linear easing:

 float val = c*t/d + b;


texts: Android development in Unreal with an existing project

texts:
I am currently using an Unreal 3 project that has been targeted for multiple devices.  Originally, it was targeted for iOS and now I want to try and build it for Android. The project is capable of doing it and I am in the process of testing it.

I think I have everything I need in order to build it and launch it for an android device that I have set up and connected to my PC and is recognized by the Android SDK ABD. I am currently trying to build and launch the game through the Unreal Frontend but when I try, I am getting stuck at getting the Unreal Frontend to find my Android device as a platform to debug, like it would with a PC, Xbox360, or PS3.

Right now, I am just trying to launch the game to see if I can get it to simply run on an Android device, I'm going to worry about the packaging later.

So I have two questions:

Am I on the right track in looking at the Unreal Frontend to cook and launch the project on Android or should I look somewhere else?

How do I get Unreal to recognize my Android device as a platform to launch on?  I would even settle for recognizing an emulator, but that seems even harder.


texts: Component instance reference in Unreal Engine 4

texts:
I'm creating a C++ script and I want to get a reference to a component instance.
For example, imagine that I want to get the player camera, which is a UCameraComponent. I would create a UPROPERTY like this:
 UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
 class UCameraComponent* PlayerCamera;

However, I can't assign it in the editor details panel like I would in Unity. I would expect to be able to drag and drop a Component from an Actor on the World Outline to this property but it seems that's not possible. Moreover, when clicking on the dropdown in the details panel, I don't have any available to choose from.

From what I learned, it just isn't possible to do it this way and the Unreal way is to create a UPROPERTY to store a reference to the Actor and then get the component in runtime. Although this might work for most cases, it's still a bit memory inefficient since you might not need the Actor reference after getting the Component (yes, I know it's just a pointer, but still...). Plus, how would you handle multiple components of the same class in the same actor? I assume you have to loop over them and try to find the one you want, based on a priori knowledge of their order in the hierarchy or based on some of their known properties (maybe with tags)...

All of this seems kind of messy, so I ask you to please shed some light on what's the (best) Unreal workflow for setting component references.


texts: How to add the concept of entities and components into an isometric tile map?

texts:
To get some practice with SpriteKit, entities and components I built a little demo.

I created a SKNode subclass (IsometricMapNode) which renders an isometric map. It does so by adding SKSpriteNode (TileSpriteNode) subclasses to itself.

The data of the map is stored in a platform agnostic class IsometricMap which manages IsometricLayers and Tile objects. The map can do things like loading a TMX file and generate tiles which carry information (type of tile, texture name, ...).

The map is then passed to aforementioned IsometricMapNode and displayed.

All is working fine but then I read about GKEntity and I wonder if I can introduce the concept of entities into my code. I was wondering if every tile in my map should be an entity which would then get a render component and maybe a physics component or a particle component.

What I don't understand though: Would my model class Tile become a GKEntity, or its visual cousin TileSpriteNode? Or is it just philosophical?

If Tile is the entity, users of my map would add new entities to it, hopefully with a render component attached to them.

If I keep my Tile model class, the map would internally create entities from this class, add some standard components (mainly rendering) and allow the user to change those components later.

Is this making sense at all? :-)


texts: Character doesn't move. I think I've tried everything, so I'm asking [Unity3D]

texts:
The animations are playing fine, however I can't manage to move my character.
My script:

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public float turnSmoothing = 20f;
    public float speedDampTime = 0.1f;
    public float jumpHeight = 8.0f;

    private Animator anim;
    private Rigidbody rb;
    // Use this for initialization
    void Start () {
        anim = GetComponent<Animator>();
        rb = GetComponent<Rigidbody>();

    }

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

    }

    void FixedUpdate()
    {
        float h =- Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        MovementManagement(h,v);

    }

    void MovementManagement (float horizontal, float vertical)
    {
        if (horizontal != 0.0f || vertical != 0.0f)
        {
            anim.SetBool("Move", true);
            anim.SetFloat("Speed", 6.0f, speedDampTime, Time.deltaTime);
            Rotating(horizontal, vertical);

        }
        else
        {
            anim.SetFloat("Speed", 0.0f);
            anim.SetBool("Move", false);
        }

    }

    void Rotating (float horizontal, float vertical)
    {
        Vector3 targetDirection = new Vector3(horizontal, 0.0f, 0,0f); //2.5D I just want to move on the x-axis atm
        Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);
        Quaternion newRotation = Quaternion.Lerp(rb.rotation, targetRotation, turnSmoothing * Time.deltaTime);
        rb.MoveRotation(newRotation);
    }

}

My character's inspector:


texts: Playing an animation relative to current Transform in unity?

texts:
I have an animation created with the built-in dope sheet. It plays correctly but I would like it to be played relative to current object transformation. For example I have a palm tree that moves its leaves. If I rotate the palmtree and then start the animation leaves does not play animation relative to its new position/orientation. I know it is playing this way because of the animation being absolute. Is there any way to make it realtive to current transformation?.

Thanks in advance.


texts: 3DS Max 2015 - Viewport issues when using sub-object selection box

texts:
I'm fairly new to using 3DS Max (2015), and have encountered an issue that I can't figure out.

Whenever I'm using the selection tools (Vertices, Edges, Polys, etc) and drag out a marquee/selection box, it has a regular tendency of either forcing a strange wireframe view, or actually sending the whole viewport grey.

This is immediately fixed once I release the marquee, however it does interfere with my ability to select and manipulate objects, as I'm forced to select by memory. It tends to happen in 'spurts', and then doesn't happen for a few more minutes, so it would seem that it's not a setting issue or the like, as it doesn't happen consistently.

I have discussed the issue with someone who is familiar with the software, and he believes that it is a memory/performance thing, and isn't necessarily a bug. If this is the case, is there any way of disabling the feature?

I have attached images demonstrating the issue below:

Working image. This is the view for both the images below it; pan or zoom doesn't change at all.
Greyed out viewport. This is the most common change that happens, and restricts any sort of view of the object (or any other object).
WireframeThis happens reasonably regularly, though not as much as the completely greyed out view. I can handle this view if necessary, though wold still appreciate the ability to disable the 'feature' altogether.

I can confirm that none of the objects are in isolation mode, although it does happen under that mode too (for what it's worth). It also happens in all

My system specs are:

Processor: Intel(R) Core(TM) i7-4910MQ CPU @ 2.90GHz
Graphics: NVIDIA GeForce GTX 880M - 8GBVRAM
RAM: 32GB
OS: Windows 8.1 x64

I hope that I have provided enough information, and please let me know if you need more.

I tried asking this over on the Graphic Design SE, but was shot down when finding out that the community seems to have agreed NOT to answer any questions relating to 3D modelling, so I really hope this is a place I can ask! If not, please give me somewhere to go, because I'm running out of options. :/

Thanks in advance.


texts: Model in Maya looks strange, what went wrong?

texts:
I am modeling a tank and I don't know what key I've pressed, but now the object in Maya is looking very weird.

Does anybody know how to solve this problem?


texts: How to make Rigidbody.AddForce less delayed in Unity3D?

texts:
I'm trying to make it so that when the player in my game moves left or right, he lightly jumps from his current position to his new position. The way I have it set up now, the jump occurs once he has arrived at his new position. What can I do to make it so that the jump happens sooner so that it appears that he jumps to his new position? Here is the code I have that controls that part of his movement:
if (Input.GetKeyDown(KeyCode.LeftArrow) && transform.position.x > minXPos)
    {
        targetPos = new Vector3(transform.position.x - xIncrement, transform.position.y, transform.position.z);
        rb.AddForce(Vector3.up * jumpForceTwo, ForceMode.Impulse);
        transform.position = Vector3.MoveTowards(targetPos, transform.position, speed);
        isHorizontalingLeft = true;
    }
else if (Input.GetKeyDown(KeyCode.RightArrow) && transform.position.x < maxXPos)
    {
        targetPos = new Vector3(transform.position.x + xIncrement, transform.position.y, transform.position.z);
        rb.AddForce(Vector3.up * jumpForceTwo, ForceMode.Impulse);
        transform.position = Vector3.MoveTowards(targetPos, transform.position, speed);
        isHorizontalingRight = true;
    }

Here is a video showing what is happening (sorry it's blurry):
https://youtu.be/rPewtb8QywE


texts: Changing alignment within a vertical layout group

texts:
I have a vertical layout group that has text bubbles instantiated into it.
Instantiating them always aligns them to "lower middle".
However, I'd like to have them on opposite sides for a message app effect.

Right now, I'm changing the anchoredPositions of each instantiated UI object in Update. Is there any better way of doing this?


texts: 2D circle / rectangle collision detection issue - brief overlap

texts:
I'm currently trying to build a Breakout clone as a first step into game development. I'm using the following collision detection code (adapted from https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection). I have a rectangle and a circle, and the following C# code:

       Point circleDistance = new Point(Math.Abs(ball.collisionRect.Center.X - block.collisionRect.Center.X), Math.Abs(ball.collisionRect.Center.Y - block.collisionRect.Center.Y));

        if (circleDistance.X > (block.collisionRect.Width / 2 + ball.collisionRect.Width / 2)) { return false; }
        if (circleDistance.Y > (block.collisionRect.Height / 2 + ball.collisionRect.Height / 2)) { return false; }

        if (circleDistance.X <= (block.collisionRect.Width / 2)) { return true; }
        if (circleDistance.Y <= (block.collisionRect.Height / 2)) { return true; }

        float cornerDistance_sq = (circleDistance.X - block.collisionRect.Width / 2) ^ 2 + (circleDistance.Y - block.collisionRect.Height / 2) ^ 2;
        Console.WriteLine("Corner dist = " + cornerDistance_sq);
        return (cornerDistance_sq <= ((ball.collisionRect.Height / 2) ^ 2));

The ball moves automatically, and the rectangle is controlled using the keyboard.

When a collision occurs, I'm simply inverting the X and Y components of the ball's speed vector.

Occasionally, however, when the rectangle is moving and collides with the ball on its left or right edge, it gets 'caught', and overlaps by more than a few pixels. This results in several collisions in quick succession, and the ball 'jitters' until the rectangle is moved out of the way.

You can see the overlap at http://imgur.com/m8g5W

I'm not sure why this occurs - if I add a boolean variable 'previousCollide' that is set on collide, then stop inverting the vector if this is set, then unset it once collisions have stopped occurring, then whilst there is still visible overlap the 'jitters' go away.

How can I prevent this?


texts: What would be a good game making engine supporting Vector images?

texts:
I want to create a simple platforming game, in which you are a square in a wonderful world. I would like this game to be able to be played in browsers. Basically I am searching for something similar to "Flixel", but with the following features:

Support Vector Graphics
Allow zooming/rotating objects without producing huge amounts of lag as soon as you are using more objects. (Because I want to rotate the map around the player) So in other words, preferably zoom the viewport/camera instead of the objects themselves.

Does an engine like that exist?


texts: How to create a Decisecond(0.1second) function that can use in the code?

texts:
I create a circular object and pivot the minute and second pointer on the middle of the object as below.

Below is the code I use.
using System;
using UnityEngine;

public class Pivot_minute : MonoBehaviour
{
    long x;

    void Update()
    { //1complete revolution for minute pointer=3600000millisecond
        x = DateTime.Now.Minute*60*1000+DateTime.Now.Second*1000+DateTime.Now.Millisecond;
        transform.eulerAngles = new Vector3(0, 0, -(x*0.0001f));

    }
}

using System;
using UnityEngine;

public class Pivot_second : MonoBehaviour
{
    long x;

    void Update()
    {// 1 complete revolution for second pointer=60000millisecond,then x millisecond=x/60000*360degree
        x = (DateTime.Now.Second*1000+DateTime.Now.Millisecond);
        transform.eulerAngles = new Vector3(0, 0, -x*0.006f);
    }
}

As tested, taking the millisecond precision is definitely showing a smoother pointer movement(not discrete movement) compare to the code below using "second" accuracy as calculation.
using System;
using UnityEngine;

public class Pivot_second : MonoBehaviour
{
    int x;

    void Update()
    {// 1 complete revolution for second pointer=60 second, then x second= x/60*360 degree
        x = (DateTime.Now.Second);
        transform.eulerAngles = new Vector3(0, 0, -x*6);

    }
}

Now I want to test the Decisecond(0.1second) accuracy to find out at this precision, can I still distinguish between the discrete movement and continuous movement of the pointer? Search through internet and so far do not have any luck.


texts:
I am studying the gameloop used in Replica Island to understand a bit about Android game development. The main loop has the below logic...

GameThread.java (note the variable names in sample code dont match exact source code)

 while (!finished) {

        if (objectManager != null) {

            renderer.waitDrawingComplete();
            //Do more gameloop stuff after drawing is complete...
      }
 }

I was curious to see what waitDrawingComplete actually does, but found its just an empty syncrhonized method! I guess it does nothing, am I missing something here?

GameRenderer.java line 328

 public synchronized void waitDrawingComplete() {
 }

Source code can be checked out here with SVN if you feel like having a look: https://code.google.com/p/replicaisland/source/checkout


texts: How do I tell if an object is currently colliding with another object?

texts:
I can't figure out how to tell if a GameObject is currently colliding with another in Unity. I've looked online and can't find any tutorials or answers that work.

Also, what's the difference between a Collision and a Collider w.r.t. Unity?

My dilemma:

I have a third person controller set up and want it to wall jump. I already have an isGrounded function, I just need to test if I'm hitting anything other than the floor. Otherwise I want it to wall jump backwards.

I've already tried:

if (this.OnCollisionEnter){
     ...
}

if (Collider.OnCollisionEnter){
     ...
}

But it did not work. I now tried:

function OnCollisionStay(){
   Debug.Log("Collision");
}

I checked my logs, console and still can't find anything.


texts:
I currently have an object made up of only one mesh. And this object contains three bones. One for stretching the mesh left, one for stretching the mesh up, and a center bone, which moves the object around. This is how my model and the bones/mesh hierarchy looks like:

Now, the problem is I don't know how to draw this mesh in XNA, I mean I don't know which transform to use.

I am using this code to draw:

Matrix[] transforms = new Matrix[model.Model.Bones.Count];
model.Model.CopyAbsoluteBoneTransformsTo(transforms);

foreach (ModelMesh mesh in model.Model.Meshes)
{
    foreach (BasicEffect effect in mm.Effects)
    {
        effect.View = camera.view;
        effect.Projection = camera.projection;
        effect.World =; //I dont know which to use
        effect.EnableDefaultLighting();
    }
    mesh.Draw();
}

If I debug it, and then look at the code, it comes up with 7 bones in this order (as seen in the picture):

Obj,
CenterArmature,
Center(CenterArmatures bone),
GorArmature,
Zgoraj(GorArmatures bone),
LevoArmature,
Levo(LevoArmatures bone).


texts:
I am making a small game that has four players. It can be played with 1 or 2 players locally, with the remaining players controlled by AI.

I am considering online play, but it is an area I know very little about, so it will take a lot of study and work to put it in. I am using my own engine, so I would have to implement it myself, or at least search around for a free library, learn its API, and probably rearrange several of my data structures and methods to make it work. Then I would have to implement lobby screens and possibly backend stuff (I have a little php experience but not a lot).

My question is, is it really worth it? Of course it would be nice to have, but do players expect it these days? I imagine people expect it for big budget games, but how about small indie games?


texts: Why do I get errors cs1502 and cs1503 in my Destroy object script?

texts:
I have a script that lets the player place blocks (like in Minecraft), but I also want to be able to destroy those blocks. I keep getting error messages cs1502 and cs1503.

Could anyone take a look at the script and tell me what is wrong?

using UnityEngine;
using System.Collections;

public class TestForCube : MonoBehaviour {

  Ray ray;
  RaycastHit hit;

  // Use this for initialization
  void Start () {
  }

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

    ray = Camera.main.ScreenPointToRay (Input.mousePosition);

    if (Physics.Raycast (ray, out hit)) {

      if (Input.GetKeyDown (KeyCode.Mouse0)) {

        Vector3 position = hit.transform.position + hit.normal ;
        Quaternion rotation =  Quaternion.FromToRotation( Vector3.up , hit.normal );
        GameObject Placement = GameObject.CreatePrimitive( PrimitiveType.Cube );
        Placement.transform.position = position;
        Placement.transform.rotation = rotation;
      }

      {
        if (Physics.Raycast (ray, out hit)) {
          if (Input.GetKeyDown (KeyCode.Mouse1)) {
            DestroyObject( PrimitiveType.Cube);
          }
        }
      }
    }
  }
}


texts: Need help to find error in collision dection in XNA

texts:
I really need some help to find the reason why not any of my Asteroids sprites are visible on the screen after I added som code to dedect collision. My suspect is that it has to do in the collision method and that the sprites are removed from the list from the beginning!? The Spaceship is visible.

In my manager class I have this method for checking the collision:

public void CollisionControl(Spaceship spaceShip)
    {
        for (int i = 0; i < asteroidList.Count(); i++)
        {
            if (asteroidList.ElementAt(i).Bounds().Intersects(spaceShip.Bounds()))
            {
                asteroidList.RemoveAt(i);
                i--;
            }
        }
    }

And then from the Game1 class I call this manager from the Update Method like this:

 asteroidManager.CollisionControl(spaceship);

And finally in the SpaceShip class and the Asteroids Class I have this code:

// Bounds
    public Rectangle Bounds()
    {
        //return new Rectangle((int)(position.X - orgin.X), (int)(position.Y - orgin.Y), texture.Width, texture.Height);
        return new Rectangle(0,0,60,60);
    }

// Draw method
    public void Draw(SpriteBatch spriteBatch)
    {
        //spriteBatch.Draw(texture, position, new Rectangle(0,0, (int)texture.Width, (int)texture.Height) , Color.White, rotation, orgin, 1, SpriteEffects.None, 0);
        spriteBatch.Draw(texture, position, null, Color.White, rotation, orgin, 1, SpriteEffects.None, 0);
    }

Help is really preciated! I'm doing a hand in task that I need to complete soon! Thanks!


texts: Split a region into arrays based on point region

texts:
I have an array of points forming a grid. I want to split this array into multiple arrays that each contain a region of point. Let's say each point as a value like on this image

The points having the same value and being connected would go into the same array. If it was only an array of all the 8 or all the 7, it wou;d be easy, but in thsi case I need the arrays to contain connected equal values. For example, the purple region of 1 would make an array, the 8 region on the left would make an array and the one on the right too, but a different one.
I just don't know how to use a loop to navigate in the grid and affect each point to an array based on they relation with other points of the same value. As this is the objective, think of the values as biome that I want to assign to an array.


texts:
Imagine joining a room with 100 (moving) players and a lot of items and being assigned a random position in the room (read: agar.io).

At the moment I'm eager loading the other players and items and sending it to the player when he joined the room (and notifying other players about the new player) but I'm not sure if this is the best way to do this.

I was thinking about implementing lazy loading and only show players and items near the spawned player.

How is such problem most commonly solved?

I was thinking about using a quadtree in order to find surrounding objects (or would a simple distance formula work)?


texts:
How do you create a good metal shader?

For different metals and say more or less eroded / rusty and so on.

I know that one difference from ordinary materials is that metal should 'colour' the specular light but when I do that with gold for example it just looks "yellow", not metallic at all.

Any help appreciated!


texts: Passive skill for balanced race / faction

texts:
I'm currently working on an RPG game project. I’m out of ideas on how to properly set race skills in the RPG. In the game, three different races exist:

Human – Balanced starting stats, active skills are focused on crowd control, debuffs, and average damage
Dwarf – starting stats has huge amount of HP but at the cost of damage and speed. Active skills are focused on defense.
Elf – starting stats has boost to damage and speed, but at the cost of low HP/MP. Active skills are focused on Damage

Currently I’m in the phase when I want to implement race skills. Race skills should be a passive skill which your character automatically earns after creation. This skill is another way of diversification, so if you compare a dwarf warrior with an elf warrior, there will be a difference in active skills, in starting stats, and also with a race skill.

I'm thinking about race skill for Dwarfs and Elves, but I'm out of ideas for a race skill for humans, which are characterized as a balanced race.

Dwarfs – 10% damage reduction on each hit by the enemy
Elfs –  +5% critical hit chance
Humans – ???

Any suggestions are welcome.


texts: Going fullscreen without stretching in an XNA game

texts:
I've got a 2D game that I'm working on that is in a single aspect ratio. When I switch it to fullscreen mode on my widescreen monitor it stretches. I tried using two viewports to give a black background to where the game shouldn't stretch to, but that left the game in the same size as before. I couldn't get it to fill the viewport that was supposed to hold the whole game.

How can I get it to go fullscreen without stretching and without me needing to modify every position and draw statement in the game?


texts:
I can draw some curves using this:

GraphicsDevice.DrawUserPrimitives<VertexPositionColor>
           (PrimitiveType.LineStrip, Points, 0, count);

Now I try to set the PointSize to make the line thicker but I can only find a solution for XNA 3.0 using:

GraphicsDevice.RenderState.PointSize

How can I make my lines thicker in XNA 4.0?


texts: Why doesn't my android application rotate when I rotate my screen

texts: I am building a game in LibGDX and the game screen orientation is in landscape. I want it to stay in landscape but I still want the user to be able to flip the device onto the other side and the screen will rotate with it. My application refuses to do that and I don't know what to do to fix that. I tried turning on my accelerometer and compass (wasn't expecting anything from compass) but nothing changed. Any ideas?


texts: Limit/Clamp camera movement using quaternions

texts:
I'm making a camera object for rendering with OpenGL. However, instead of using the typical "LookAt" method I'm trying to use just a Quaternion for orientation and a Vector3 for position. Instead of messing with euler angles to rotate the Camera I use quaternions directly, like this:

glm::vec3 up = glm::normalize(glm::inverse(cam.Orientation) * glm::vec3(0, 1, 0));
glm::vec3 right = glm::vec3(-1, 0, 0);
cam.Orientation = glm::rotate(cam.Orientation, glm::radians(-xoffset), up);
cam.Orientation = glm::rotate(cam.Orientation, glm::radians(-yoffset), right);

xoffset and yoffset are just the amount the mouse has moved since the last frame.

I create my view matrix from the inverse of the two variables. I've already got FPS style camera movement and rotation working. The problem I have now is that I want to prevent the camera from being able to flip over. I.E. moving the mouse up or down enough that the view becomes upside down. Is there a way to clamp the rotation using purely quaternions to prevent this?


texts: Unity5 - Create navmesh for a random generated environment

texts:
I am following this tutorial to create a game with random generated mazes:

http://catlikecoding.com/unity/tutorials/maze/

I want to add some monsters to roam around the newly created maze. How can I create navmesh for this kind of random generated environment?


texts: Error on MonoGame Content Pipeline: Texture Importer Error

texts:
I just encountered this kind of error when using the MonoGame Content Pipeline and it's my first time to use it to convert png to xnb files (I use a stand alone app for converting files to xnb in the past). I've done building spritefonts to xnb files and stuff like that in my previous MonoGame projects and I thought it would be similar but it turned out to be not the case.

So this is the error I have:

error: Importer 'TextureImporter' had unexpected failure!
System.NullReferenceException: Object reference not set to an instance of an object
  at Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.Import (System.String filename, Microsoft.Xna.Framework.Content.Pipeline.ContentImporterContext context) [0x00000] in <filename unknown>:0
  at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1[Microsoft.Xna.Framework.Content.Pipeline.Graphics.TextureContent].Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import (System.String filename, Microsoft.Xna.Framework.Content.Pipeline.ContentImporterContext context) [0x00000] in <filename unknown>:0
  at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent (MonoGame.Framework.Content.Pipeline.Builder.PipelineBuildEvent pipelineEvent) [0x00000] in <filename unknown>:0

Is there a way to resolve this? Is there a tutorial of some kind I can follow to use the TextureImporter and the things I haven't yet understood on MonoGame's Content Pipeline with in-depth explanation about it?


texts: UE4 C++ Variables in my custom class change for no reason after a while

texts:
I've made a class extending UObject to store player stats, and provide some static utility functions and variables.
It gets instantiated in my PlayerController:

APuzzleProjectPlayerController::APuzzleProjectPlayerController() {
    playerStats = NewObject<UPlayerStats>();
    playerStats->setStrenght(4);
    playerStats->setSpeed(1);
    playerStats->setStamina(1);
}

Everything compiles fine and the game logic works perfectly except for the fact that after a while (1 or 2 minutes of gaming) the non-static private variables change their value.

In the following code I've added some Dummy variables just to make sure that nothing was accessing/changing them during execution. They are only accessed by GEngine->AddOnScreenDebugMessage to show their value.

UCLASS()
class PUZZLEPROJECT_API UPlayerStats : public UObject
{
    GENERATED_BODY()

    // Stats Const
    static const uint8 MIN_STAT_VALUE = 1;
    static const uint8 MAX_STAT_VALUE = 7;

    // Stamina Pool Const
    static const uint8 BASE_STAMINA_POOL = 199;
    static const uint8 STAMINA_POOL_STEP = 8;
    static const uint8 STAMINA_RECOVERY_VALUE = 3;

    // Stats
    uint8 strenght = 1; // Becomes 221
    uint8 speed = 1; // Becomes 221
    uint8 stamina = 1; // Becomes 221
    uint8 staminaPool = BASE_STAMINA_POOL; // Updated by a function, still unconsistent after a while since stamina dependent

    // These are never modified by my code, but get modified after a while like the Stats variables
    uint8 dummyA = 3; // Becomes 221
    const uint8 dummyB = 4; // Becomes 221
    int dummyC = 5; // Becomes -572662307
    const int dummyD = 6; // Becomes -572662307

    public:
    enum SpeedSteps {WALK, RUN, SPRINT};
    static const float TIMER_PRECISION;
    static const uint8 MIN_STAMINA_POOL = 0;
    static const uint8 MAX_STAMINA_POOL = 255;
    static const float DELTATIME_STAMINA_RECOVERY;
    static const float DELTATIME_STAMINA_LOSS;
    static const uint8 STAMINA_RUN_LOSS = 2;
    static const uint8 STAMINA_SPRINT_LOSS = 32;

    UPlayerStats();
    uint8 getStrenght();
    uint8 getSpeed();
    uint8 getStamina();
    uint8 getStaminaPool();
    static uint8 getStaminaDelta(SpeedSteps speedStep, bool isIdle);
    void setStrenght(uint8 value);
    void setSpeed(uint8 value);
    void setStamina(uint8 value);
};

Now, I'm a bit rusty with C++ (I work as Java & PL/SQL programmer), but I really don't know what's wrong here. The variables in the other three classes I have (default third person game mode, character and custom player controller) don't seem to be affected by the same issue.

Thanks for any suggestion you might have.


texts: How do I convert degrees to radians and vice versa in Godot?

texts:
In a game I'm toying with in Godot engine I have angles given in degrees in some places and angles given in radians in other places. Sometimes I need to mix both angles (ie. add them).

What built-in function allows me to convert degrees to radians (and the other way around)?
Or is there none?

P.S. I realize that converting those is not rocket science and I could code something on my own, but Godot is already doing such conversions internally, so I would venture a guess that such function already exists.


texts:
I've been working on a top down 2d game and the character moves freely around the map, like zelda link to the past.

How would you model the data structure for such a game in order to implement pathfinding, astar, etc.

As far I understood one could go with this approach:

Tile {
 sprite,
 walkable,
 position,
}

Board {
  width
  height
  tiles: Tile[]
}

In a board of 5x5 there will be a sprite rendered for each tile. But here comes the problem:

The player is at position (+1,+1). Now it moves to the right side (+2,+1). This will mean that the player is moved immediately from one tile to another. So, we could make the player move pixel by pixel. How would you translate this back to the grid position?

If player moves pixel by pixel (using floating point instead of integers) and is at position (1.5,1),doest it means we need a separated data to store player position and later on round its current position (1.5, 1) to find its current cell in the grid?

I'm kind lost in this subject, i would love if you could share some thoughts on it, articles, videos, books, etc.

Thanks!


texts: How to get a list of parameters from a material in UE4?

texts:
TLDR: how to access the parameters of a given material/material instance in BP and/or C++.
I would like to expose material parameters to the UI so the player can edit material instances at runtime(i.e. color, roughness of objects, etc).
I have a base class, that is the parent of everything in game; that has a variable of type Material Instance Dynamic called WMaterialInstance. It also has an Interface function to return that var.
Please see the construction script.
I'd like read parameters of this instance and expose it to the UI somehow.
But I can't get those parameters...
I am using a Get Scalar Values node to get my params...
I tried feeding it a Material Instance Dynamic reference, but my Print String nodes return zero, although there are parameters on the material, 100%.
Please see the BP nodes here.
I found a post describing a similar issue.
One of the answers says:

That node is a bit silly, it doesn't work with dynamic material instances, only constant. What you can do is get the parent of the material instance you're creating, cast it as a MaterialInstance (not dynamic), then get the scalar parameters of that one. If you need the values too you can use a for loop with the scalar parameter array as the input, break the array element and hook the Name into a GetScalarParameterValue (from your dynamic material instance) in the loop.

So I got the parent of my Material Instance Dynamic and tried casting it to just a normal MaterialInstance, but the cast seems to fail, if I feed the parent to it...
Here is how I did it.
Note: the Get Material node is my interface call to the Dynamic Instance from construction script, not the built in one.
Further down in the post there is an answer saying:

Well you need to have an actual constant material instance first,
create that by right clicking your material and creating a material
instance in the content browser. Then create your dynamic version from
that.

I created a material instance from my original material and assigned it to one of the child classes of the baseclass, so I use that one in the base construction script.
Still, doesn't want to work...  I get the same zeros and cast failures...
I noticed, that if I Print String the Display name of the Parent I get from the accessed base material it prints WorldGridMaterial, which means, it did not find what it supposed to...
Did anyone experience something similar?
Is there a better way to access these parameters?


texts:
I'm making a simple program with C++, SDL and GLEW. So far it is going great but I ran into a weird problem. One of my four textures would not show up on screen even though it used the same code as the other three. EXAMPLE: https://www.dropbox.com/s/4038p0yv041mhdy/Sk%C3%A4rmdump%202014-09-10%2021.37.48.png?dl=0
HOW IT SHOULD BE:
https://www.dropbox.com/s/huhln17zjip1pjb/Sk%C3%A4rmdump%202014-09-10%2021.39.04.png?dl=0

But the weird thing is how I fixed it.
NOT WORKING:

  _sprite[0].init(0.0f, 0.0f, 1.0f, 1.0f, "kitten.png");
  _sprite[1].init(-1.0f, -1.0f, 1.0f, 1.0f, "kitten1.png");
  _sprite[2].init(0.0f, -1.0f, 1.0f, 1.0f, "kitten1.png");
  _sprite[3].init(-1.0f, 0.0f, 1.0f, 1.0f, "kitten.png");

WORKING:

  _sprite[1].init(0.0f, 0.0f, 1.0f, 1.0f, "kitten.png");//Switched around the 0 and the 1
  _sprite[0].init(-1.0f, -1.0f, 1.0f, 1.0f, "kitten1.png");
  _sprite[2].init(0.0f, -1.0f, 1.0f, 1.0f, "kitten1.png");
  _sprite[3].init(-1.0f, 0.0f, 1.0f, 1.0f, "kitten.png");

I only changed the index when the init function was called and all of a sudden it started to work again. So my question is: Why does the texture not display when I'm using index 1 but working when I'm using index 0.

Nothing happened when I only changed the draw function.

INIT FUNCTION:

void Sprite::init(float x, float y, float w, float h, std::string image) {
//Loads image, initilaze the varibles and generate the Vertex Buffer Object(VBO)
_texture = ResourceManager::getTexture(image);

_x = x;
_y = y;
_w = w;
_h = h;

if(_vboid == 0) {
   glGenBuffers(1, &_vboid);
}
if(_eboid == 0) {
   glGenBuffers(1, &_eboid);
}
//The vertex data
Vertex vertexData[4];
//Specify which vertices to reuse
GLuint elementdata[6] = {
   0, 1, 2,
   2, 3, 0
};

//Top right corner position
vertexData[0].setPosition(_x + _w, _y + _h);
vertexData[0].setTexCoord(1, 0);

//Top left corner position
vertexData[1].setPosition(_x, _y + _h);
vertexData[1].setTexCoord(0, 0);

//Bottom left corner position
vertexData[2].setPosition(_x, _y);
vertexData[2].setTexCoord(0, 1);

//Bottom right corner position
vertexData[3].setPosition(_x + _w, _y);
vertexData[3].setTexCoord(1, 1);

for(int i = 0; i < 4; i++) {
   vertexData[i].setColor(255, 255, 255, 255);
}

//Let's set some special color

//Binds the buffer, then upload data to the GPU and the last thing it does is unbind the     buffer
glBindBuffer(GL_ARRAY_BUFFER, _vboid);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _eboid);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elementdata), elementdata, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}


texts: XNA - Prevent Holding of Mouse Button as Part of an Input Handler Game Component

texts:
I'm using C# XNA 4.0 Refresh.

I'm working to create an InputHandler Game Component for my XNA game to handle all of the keyboard and mouse input.

I used SixOfElevens RPG Game Tutorial (Here - http://xnagpa.net/xna4/rpgtutorials/xna4rpgtutorial1.pdf) to create the InputHandler.

Currently, as shown in the guide it can handle keyboard input and has methods for performing an action when a key is down, pressed, or released.

I added mouse input into this InputHandler so that it gets the current and previous state of the mouse.

My problem though is that I can't figure out how to make working methods to perform actions when a mouse button is down, released, or pressed.

For example:  With the keyboard input here is the section that handles performing and action when a key is released after being pushed.

public static bool KeyReleased(Keys key)
    {
        return keyboardState.IsKeyUp(key) &&
            lastKeyboardState.IsKeyDown(key);
    }

I've tried every way I could think of or find to get a similar thing working with the mouse.

I've seen this posting ( http://www.techpowerup.com/forums/threads/sample-code-c-xna-mouse-control-tip.57633/ ) and while it checking the button presses its doing it right at the moment when the action is to be performed.  I need a way to pass it through the InputHandler and return it like the keyboard example shown above.  Otherwise I'll be stuck having my keyboard input handled neatly and my mouse inputs handled messily all over the place.

Anyone out there know of a way to implement this like I need?


texts: What does the term "channel" mean when used in regards to computer graphics?

texts:
I was studying terminology for computer graphics, and this statement came up that confused me.

  The image can have alpha channels for transparency.

I tried searching for the meaning of the term "alpha channel," but I got really confused by the definition which used another concept called a "channel." I'm not really sure what this means, so could someone be kind enough to please explain this term to me?


texts: I cannot find LWJGL collision detection with a camera and walls. Like making it to where you can not walk through walls and other different shaped rectangular prisms and cubes. How do I set up LWJGL collision?


texts:
My TiledMap tears when the window is specific sizes, resized, or the camera moves.

The tileset is padded by 2px and have tried as high as 10px. Each tile is 70x70.

Here are the pack.json settings,

{
    paddingX: 2,
    paddingY: 2,
    bleed: true,
    edgePadding: true,
    duplicatePadding: true,
    maxWidth: 4096,
    maxHeight: 4096,
    filterMin: Nearest,
    filterMag: Nearest,
    ignoreBlankImages: true,
    wrapX: ClampToEdge,
    wrapY: ClampToEdge,
    grid: true,
    fast: false
}

Here is the code.

Parameters params = new Parameters();
params.textureMinFilter = TextureFilter.Nearest;
params.textureMagFilter = TextureFilter.Nearest;
TileMap map = new TmxMapLoader().load(file.getAbsolutePath(),params);

So what am I doing wrong? If nothing, does that mean libgdx absolutely cannot handle TileMaps of any sort?


texts: iPhone/OpenGL-ES partially texture mapping an object

texts:
I only have a basic understanding of OpenGL, so I'm probably showing my ignorance here.

I'm looking for a great iPhone/OpenGL-ES example of applying a texture (preferably from a texture atlas, but not really a requirement) to specific parts of some arbitrary object/model.

I have a game where 3D tiles "flip" to reveal some other texture on the backside of the tile.  I created the model in Blender and exported it to an Objective-C header.  The tile isn't a simple "cube", but it is relatively cube-shaped.  Everything works great when I use a single texture that simply wraps the entire model.  But I'm struggling to figure out how I can restrict that texture to just specific parts of the model.

To complicate things even more, I ultimately want to texture it with three different images.  The top will have "image x", the sides of the tile will have "image y", and the back will have "image z".

Thanks!


texts: Should recoil be an animation or script?

texts:
Should recoil for a rapid fire gun be be done through an animation or a script? I want the recoil to increase as I continuously fire, like a lot of FPS games do.
I was initially considering achieving this through a script in unity that rotates the gun slightly each time I fire, but I realized that since I plan to have most rapid fire guns be 2 handed weapons, at some point, the left hand won't be on the weapon.
However, since I also want the recoil to increase as I fire, I'm not sure how I can achieve this in an animation.
How is recoil typically done? Input on this would be very much appreciated.


texts: Apple Game Center - Sharing Data between 2 SKUs possible or not?

texts:
Question: Is it possible to access the same leaderboards and achievements via GC from 2 versions of a game (i.e. 2 different SKUs, one for iPhone/iPod and another for iPad. Where both are actually the same game in terms of game modes and features. For instance to be able to have different pricing)

Or: is this impossible and there is no other way than having 2 separate Leaderboards, Achievements -or- one universal binary.

Thanks in advance

*edit: typo and added remark about universal binary


texts: How can I use touch input for 3rd-person controls?

texts: I have a 3rd-person controller in my Unity scene, which I can only control with the WASD buttons. But since I plan to make a smartphone game, I wonder how I can change these controls t swipe up/down/right/left and (if possible) keep WASD for debugging.


texts:
I am working on an RPG type game in Java and I would like to know a few things relating to threading,

What is the best way to implement a "wait for this then do this" without hanging the whole thread? Like waiting for a player to move to a location then pick up an item? or to wait one second then attack?

Currently I am spawning new threads every time I need to wait for something, but that doesn't feel like the best solution.

Any help is appreciated.

EDIT:
Clarification and an example of how I currently do things.

User clicks on an item
The function walkToAndPickUp(item) is called which is basically this:

Make a new thread so we don't freeze the thread handling input while the player moves.
Tell player to move to the item
While the player is not at the item(The player moves through an update() function called in a different thread, I don't know how else to do it without freezing threads)
Repeat until the player is at the item
If the player is at the item then call delete item from map and add to inventory.


texts: LibGDX: Its there any way to calculate the speed of a repeated scrolling background?

texts:
I'm trying to calculate the scrolling speed of an background, I'm doing something like this on the background class:

private Texture texture = new Texture(Gdx.files.internal("backgound.png"));
private Sprite sprite;

private float scrollTimer = 0.0f;
private static float scrollFactor = 0.2f;

public Background() {
    texture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
    int width = texture.getWidth();
    int height = texture.getHeight();
    sprite = new Sprite(texture, 0, 0, width, height);
    sprite.setSize(1280, 320);

}

@Override
public void act(float delta) {
    updateScrollFactor();
    scrollTimer += delta * scrollFactor;

    if (scrollTimer > 1.0f) {
        scrollTimer = 0.0f;
    }

    sprite.setU(scrollTimer);
    sprite.setU2(scrollTimer + 2);
}

@Override
public void draw(Batch batch, float alpha) {
    sprite.draw(batch, alpha);
}

private void updateScrollFactor() {
    //Increase scroll factor when the game score being higher.
}

public static float getScrollFactor() {
    return scrollFactor;
}

And in another class I'm trying to calculate the speed of this background above because I need the same speed to apply in the entity of mentioned class, that is described below:

private Texture texture;
private Sprite sprite;

public Item(String textureName) {
    texture = new Texture(Gdx.files.internal(textureName));
    int width = texture.getWidth();
    int height = texture.getHeight();
    sprite = new Sprite(texture, 0, 0, width, height);
    sprite.setSize(30f, 50f);
    //Sets initial position, the entity will be scrolled from the screen width to zero
    sprite.setPosition(Gdx.app.getWidth() - 10, 10);
}

@Override
public void act(float delta) {
    scrollTimer = delta * Background.getScrollFactor();

    if (scrollTimer > 1.0f) {
        scrollTimer = 0.0f;
    }

    float x = sprite.getX();
    if (x + sprite.getWidth() > 0) {
        sprite.setX(x - Gdx.graphics.getWidth() * scrollTimer);
    } else {
        //sets to initial position when the entity vanish thru the window left side.
        sprite.setX(Gdx.graphics.getWidth() - 10);
    }
}

@Override
public void draw(Batch batch, float alpha) {
    sprite.draw(batch, alpha);
}

}

The case is the entity don't run sync with background but i need this separated from the background because it is a clickable entity.

Thoughts?


texts:
I am wondering what is the best / most common practice in 3D games (mostly shooters) like Quake or Doom. How are the levels built?

With larger, open spaces the answer is probably some kind of terrain editor, that is what I understand. But what about things like houses or closed areas?

I see two main solutions. One is to make a whole house, factory, dungeon (or generally a level) in other tool, like Blender, and then put it in the game. Other is to make the most simple elements like walls, floor, doorways and make the level from them (like Lego blocks).

Is one of the ways more common? More "industry standard"? Are there some obvious advantages or disadvantages?


texts:
I have this tilemap and a player in my game, and I got the player to move by adding the velocity to the position. However, it is very hard to control the player exact this way of the tilemap. So, I began trying to do something like the old final fantasy games did (and a heap of other games too): moving tile by tile, but making it look smooth.

However, I failed. So, if anyone have any idea of what the best way to make the player move tile by tile is, then shout out. If you have played final fantasy V for example, then that's the kind of movement I want to try to implement in my game.

To explain it a bit further; each tile in  my game is 16x16, so is the player. I don't want the player to "jump" between the tiles, but I want it so that say, if you press "A", then move the player to the tile to the left in a smooth way.

I tried something like this:

    private Vector posA;
private Vector posB;
private double time = 0.6 / 60;
private void move(Direction dir) {
    if (!moving) {
        //Initialize Movement
        posA = new Vector(position);
        posB = new Vector(position);

        switch (dir) {
        case UP:
            posB.subtract(0, 16);
            break;
        case DOWN:
            posB.add(0, 16);
            break;
        case LEFT:
            posB.subtract(16, 0);
            break;
        case RIGHT:
            posB.add(16, 0);
            break;
        }

        moving = true;
    }

    //Update Position
    if (moving) {
        Vector v = new Vector();
        v.set((posA.x + (posB.x - posA.x) * time), (posA.y + (posB.y - posA.y) * time));

        //Set  Position
        position.add(v);

        if (position.x >= posB.x && position.y >= posB.y) {
            position.set(posB);
            moving = false;
            System.out.println("DONE MOVING!!!");
            posB = null;
            posA = null;
        }
    }

}


texts: How can I convert screen coordinates to world coordinates on the floor (when the y component = 0)?

texts:
I am using the Irrlicht Engine and would like to convert the coordinates of the mouse on the screen to the floor of my world. I am currently trying to use

getRayFromScreenCoordinates()

which returns a "Ray starting from the position of the camera and ending at a length of the far value of the camera at a position which would be behind the 2d screen coodinates." Then I do this to get the position:

    core::line3df line = getRayFromScreenCoordinates(receiver.mousePos, device);
    irr::core::vector3df lineVector = line.getVector().normalize();
    irr::core::vector3df pos = line.start + lineVector*x;

x would be the magnitude from camera to the coordinate. However I do not know how to calculate x (as I don't know the coordinate yet).

The page I got the code from, written in 2003


texts: Write to one channel of R16G16 texture on Xbox

texts:
I was going to draw my shadow map into one channel of a 16 bit texture and then draw a different shadow map into another channel of the same texture.

I realized that this might not be possible to do efficiently since my targetted hardware (Xbox) does not support blending R16G16 formats. (Although the HDRBlendable might make it possible if I need a blendable format to do this.)

Is it possible to mask one channel of a R16G16 texture on the Xbox? How do I do that?


texts: Triggering State Changes with Health Counter

texts:
I'm developing a game where the player changes states as their health decreases. Below 50, it should trigger animation1. Below 30, it should trigger animation2.

The problem is, I only want to trigger animation1 once. But my game timer is checking every "frame", so it's triggering animation1 every cycle below 50. I only want it to trigger once, then not again until it's gone over 50 and then naturally decreased back to below 50.

Are there any tried and true strategies for triggering state changes as a timer counts down (without the over-triggering problem)?

I thought I could say:

if (health == 50)
 animation1.play();

but sometimes, health never equals exactly 50, so it will skip right past that statement.


texts: If statement works fine until I add a tag check requirement. Why is this?

texts:
I'm trying to add a tag check to an if statement but for some reason when I add said tag check it stops working.

void Update ()
    {
        Vector3 fwd = transform.forward; // Equivalent to the code you had.

        Ray ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Input.GetMouseButton(0) && Physics.Raycast(ray, out hit, 10f) && isPlayerHolding == false && gameObject.CompareTag("Pickable"))
        {
                isPlayerHolding = true;
                hit.transform.SetParent(Player.transform);
                Debug.Log("We hit: " + hit.transform.name);
                hit.rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
                hit.rigidbody.constraints = RigidbodyConstraints.FreezePosition;

        }
        if (Input.GetMouseButton(1) && Physics.Raycast(ray, out hit, 10f) && isPlayerHolding == true)
        {
            hit.transform.parent = null;
            isPlayerHolding = false;
            hit.rigidbody.constraints = RigidbodyConstraints.None;
        }

More specifically this is the bit of code that is holding things up "&& gameObject.CompareTag("Pickable")".

Things I've tried:

Debugged variables in C# to be sure nothing is missing/null.
Making sure the tag is setup properly within Unity.

I really can't think of what the problem is. Anyone have any ideas?


texts: Ground for 2D AndEngine game with physics

texts:
I am using AndEngine to create a 2D Game for Android platform using Java and AndEngine.

I have learned how to use Tiled editor to create tiled maps. The only problem I am having is that I don't know how to place an object such as a character on the ground, and have it count as the ground.

How do I go about doing this or what is the best way to do this?


texts: How would I go about implementing a globe-like "ballish" map?

texts:
I am new to 3D development and I have this idea of having the game world like our globe is - a ball. So, there would be no corners in the map and the game is top-down RTS game. I would like the camera to go on and on and never stop even though you are moving the camera to the same direction all the time.

I am not sure if this is even possible, but I would really like to build a globe-like map without borders. Can this be done, and how exactly? I am using XNA, C#, and DirectX. Any tutorials or links or help is greatly appreciated!


texts: Which style/technique is more time efficient for an inexperienced artists?

texts:
For a top-view 2D mobile game where you have to create and animate humanoids (human, golems) and "objects" like fire, boulders, levers, etc.

Considering the artist has no prior experience with drawing, nor with any related software.


texts: Shmup Unity, create an enemy spread shot to the player

texts:
Following this lecture: http://www.shmup-dev.com/forum/viewtopic.php?f=6&t=347 , i created a bullet that shoot from the enemy directly to the player, in a straight line.

Now i want to create 3 bullets that are shot from the enemy to the player creating a spread effect, one shot goes directly to the player, and the other two opens a little from the one of the middle,

This line of code is the one that create the line motion from the enemy to the player:

    // calculate the direction to the player
    shootVector = SharedInfo.getInstance().player.transform.position - myTransform.position;

How can i create the other two motions for the bullets?

http://postimg.org/image/ialuek24r/

Here is the code i have for one shoot (this code is applied to the enemy):

void Shoot() // waits for 'delay' seconds, then shoots directly at the player
{
    // get a bullet from the stack
    //var newBullet = gameManager.GetComponent(GameManager).enemyBulletStack.Pop();
    Bullet newBullet = (Bullet)SharedInfo.getInstance().enemyBulletStack.Pop();

    // position and enable it
    newBullet.gameObject.transform.position = new Vector3 (myTransform.position.x,
                                                           myTransform.position.y,
                                                           myTransform.position.z);
    newBullet.gameObject.SetActive(true);

    if (changeShootVector) {
        // calculate the direction to the player
        shootVector = SharedInfo.getInstance().player.transform.position - myTransform.position;
    }

    // normalize this vector (make it length 1)
    shootVector.Normalize();
    shootVector = new Vector3 (0, shootVector.y, shootVector.z);

    // scale it up to the correct speed
    shootVector *= enemyBulletSpeed;
    newBullet.motion = shootVector;
}


texts: Restore object right vector to horizontal position using quaternions

texts:
I'm fairly new in gamedev mathematics and i have a problem i cannot solve on my own.

I'm working on L-System tree generation engine and i'm having serious difficulities while trying to work out certain quaternion manipulation.
Every generated tree is a group of segments, growing from its parent starting from root. Every segments rotation is represented by quaternion. When child segment grows from its parent, i just multiply quaternion representing child rotation relative to parent by parent rotation quaternion.
It works fine, however i need to implement another type of rotation to the child branch: bringing back segments right vector back to horizontal position.
Is there any way i can solve this problem using quaternions?

I've tried manipulating quaternion converted to rotation matrix (extract quaternions front vector, recalculate right and up, modify rotation matrix and convert it to new quaternion) but i see that extracted informations about segment rotation are somehow corrupted, as it can be seen on screenshots ('tree' is at position (0,0,0), camera facing direction (0,-1,0)). Second one presents segment rotated 90 degrees about z axis (yaw). Expected vectors should be:
Right: 0 1 0Front: 1 0 0Up: 0 0 1

Is there something i do/understand wrong?

Edit:
I've checked again my vectors-to-matrix code part and turns out i've messed up vector rows with columns, that's why i was getting those strange results while trying different approaches!

I'm posting my working $ operation:

...
mat4 rotationMatrix = mat4_cast(transform.rotation);
vec3 front(rotationMatrix[0][1], rotationMatrix[1][1], rotationMatrix[2][1]);
vec3 worldDown = vec3(0, -1, 0);

vec3 right = normalize(cross(front, worldDown));
vec3 up = normalize(cross(front, right));

float matrix[16] = {
    right.x, front.x, up.x, 0,
    right.y, front.y, up.y, 0,
    right.z, front.z, up.z, 0,
    0,      0,       0,    0
};

mat4 newMatrix = make_mat4(matrix);
transform.rotation = quat(newMatrix);
...


texts: Reward volatility of League of Legends matchmaking system

texts:
According to this article in league of legends matchmaking there's an average of 50/50 chances of winning or loosing a game based on how system ranks a specific account (player skill). However this implies that a player is expected to loose at least half of his games (provided that he's not a student of the game) or at most he'll win 75% of the games (that's ranked top rated guys and the highest win rate I've seen in my region, so should be a feasible boundary).

However, the latter is rather rare since not so many people actually achieve that skill level (that can also be observed by going through ranked statistics) and the former is also not a constant since a) it's also in the algorithm and a queue of 1 min is most likely not a 50/50 and b) there are situations where it is extremely obvious that a player was placed against a way stronger team or vice verse.

An example from my practice is that I had a win rate of 88% which severely dropped after about one ore two weeks (to around 71%) and it rose again in a week or so with me learning nothing (I literally didn't). So, during such drops a player reward expectation is not met which results in negative attitude (taken to extreme in some cases, as was also observed). Some people were literally saying: "I hate the game" and they kept playing.

So the question is: why? why is it that with such reward volatility people still keep playing? (please, give a rigorous proof, if any, supplied with references presumably from behavioral psychology)

P.S.: I do not have any empirical data, so I realize this might be only a feeling as well as the fact that mostly I observed it through my account (not even lvl 30) and in my region. I also understand that most likely they are using statistical learning algorithms which obviously require data and will put a player to his actual rating as number of games grows (theory of big numbers).


texts: most efficient way to create a grid system in unity

texts:
I'm creating a little tower defence game to get myself acquainted with unity.

At first I was going to emulate a grid system by capturing touches / mouse clicks and rounding the coordinates to the nearest whole numbers. This is very low cost and works well for placing things, however I'm a bit of an AI geek and I've decided to make a more tangible grid so that the agents can run searches on it for pathfinding.

For this I'll need a grid of nodes and for those nodes to have a bit of information attached. Would it be a much better idea to do this entirely in code? Or could I get away with placing actual cubes in a big grid on the map?

This would certainly be easy as then I could ray cast against them - but I've tried this and rendering that many cubes slows down the game a lot!

I suppose my question is - is it unnecessarily expensive to have a load of cubes set up like this, but not rendered? Or should the cost of having a load of cube shaped collision volumes be only marginally more expensive than emulating this in code? (if at all...)

Also as a side question - should I be able to render say, 200 cubes and have a smooth game? Am I missing some instancing options? I presumed things would be automatically instanced.


texts: How to load a spherical planet and its regions?

texts:
I'm designing a game partially composed of planets exploration. I want to use pseudo-random generation for them, regenerating from a defined seed when I have to load them rather than store every detail, which would be too heavy. So I will just store in a file the random seed and modifications done by the player if any.
The player must be able to see the planet from orbit (with very low level of details, then go down to the ground, increasing slowly the level of details of the region where he/she is landing, and unloading the ones on the other sides of the planet, which go outside the player's field of view.
If I had to do it on a plane ground, I would do it easily with a square chunk system. But the problem here is that planets are - almost - spheres.
So what would be the best way to load ground details (relief and grounded objects) around a precise point ?
I already though on two solutions, but both have a weak point:
1. Cutting the sphere in square chunks.

Once the player is close enough of the ground, I just have to improve details of closest squares from his/her position.
If it is not enough, I still can cut each square in sub-squares to load when the players is on or really close of the ground.
But as you can see on the picture, there is a problem if the player try to land on a pole: squares become very slim rectangles, or even triangles for the last line, and additionally to the fact that they would be many to load, generation would appear distorted.
2. Starting from an icosahedron.

Here, I could just increase triangle tessellation around player's position when he/she is getting close.
But I don't know how to locate triangles close than player's position. I heard Cartesian coordinates could be usefull in that case, but I don't know how to use them.

I'm using C++/OpenGL for it, so the main thing to generate and load here are vertices representing the surface relief and color/texture.


texts:
edit: clarified my question. I also realized that I didn't pick a very conclusive question title, which unfortunately I cannot change anymore, sorry.

Hey everyone,

to improve my programming skills a little and getting familiar with good design patterns, I'm trying to program a litte turn based strategy game, and I am at the point to choose a good data structure for the configuration of different terraintypes and unittypes etc. which do exist.

What I have implemented so far is a big "Game Object" with knowledge about everything in the game, and many of its properties are big associative arrays (I'm using PHP, but my question doesn't really have to do much with the language), for example an arrays of units, a map array.... What my array structure is comparable to is the type object pattern mentioned here.

Example: A single unit is of a certain type, say 'Infantry', and shares many data with all the other infantry untis on the field. Instead of copying all these values, I give every unit a "type" so it can look up the details there. Similar with terraintypes. Example:

terraintypes = array()
terraintypes[0] = array()
terraintypes[0]['name'] = 'Forest'
terraintypes[0]['capturable'] = false

unittypes = array()
unittypes[0] = array()
unittypes[0]['name'] = 'Infantry'
unittypes[0]['movecost'] = array()
unittypes[0]['movecost'][0] = 5 //Movementpoints needed for forest
unittypes[0]['movecost'][1] = 7 //Movementpoints needed for terraintype 1

A specific unit or tile on the map wouldn't know its movement costs or name, but would be able to look that up in the unittypes array. Example:

sometile = array();
sometile['owner'] = whatever
sometile['type'] = 0; //this tile is a forest

someunit = array()
someunit['type'] = 0 //This is an "Infantry".

The problem is that getting any kind of information will produce very verbose code, for example finding out how much it costs for a unit to move onto a tile will be

unittypes[unit['type']]['movecost'][tile['type']]

I am trying right now to move to using more objects and classes, so if I give a unit a reference to its unittype, it can lookup information itself, for example

terraintypes[0] = new Terraintype('Forest')
unittypes[0] = new Unittype('Infantry')
someunit = new Unit(unittypes[0])

Now, if I ask a unit something only its unittype would now, the unit can look it up itself, e.g. someunit.getName() will be implemented in the unit like this.unittype.getName().

So far so good. However, how could a unittype store its movecost on the different terrains? Basically I would need an array indexed with terraintypes, but as that is not possible, I will have to swhich back to translate everything to numeric keys, and have a movecost value for every pair (terraintype, unittype).

Who assigns these numeric keys and where? Will every single unittype need to store some kind of identifier which is unique among all the unittypes?
Should I use some constants like const FOREST = 0; const ROAD = 1; const INFANTRY = 0; const VEHICLES = 1 etc?

Another of my problems for finding a good data structure is that if I don't give the game all the data directly, but break everything down to smaller parts, then many parts will need to know about the same objects.

For example, if the Map object knows about all tiles of the map and the units on it, then the game doesn't really know anything about the units, it only knows about the map, and every command in the game which affects a unit needs to be passed to the map, even though its not actually a "map task", like healing units.

This seems like breaking the single responsibility pattern. However, storing references to all the units in several places (so both the Map and something else store references to units) seems to be troublesome with bookkeeping.

To sum it up a little, can you hint me to data structure which are suitable to represent what I am describing? Thanks in advance!


texts: How to mirror a vector through some other vector?

texts:
I have a player's direction (playerDirection).
I want to fire two bullets, one rotated by -30f, and one by 30f, so it looks like this:

Blue line is the playerDirection. I'm looking for the green and the red.
I have calculated the red vector with:
bullet1Direction = Quaternion.Euler(0, 30f, 0) * playerDirection;

But this method doesn't seem to work for all cases because it produces negative angles etc.
So I've tried taking that red vector I've calculated and reflecting it with Vector3.Reflect but I think it's for different purposes.
How do I do that?
edit just for reference
Turns out it works out of the box as DMGregory says. I had some issues in the algorithm.
Here's how the final version looks like, supporting shooting multiple bullets.
I know that the algorithm probably could be simplified somehow.
for (int i = 0; i < bullets; i++)
{
    // we will calculate the angle for each bullet
    float angle = 0f;
    if (evenCount) // if the bullet count is even or not
    {
        if (i % 2 == 0) // bullet 0, 2, 4
        {
            angle = playerDirection.y + ((i + 2) * 15f); // 30f, 60f, 90f...
        }
        else // bullet 1, 3, 5
        {
            angle = playerDirection.y - ((i + 1) * 15f); // -30f, -60f, -90f...
        }
    }
    else
    {
        if (i == 0) angle = playerDirection.y; // bullet count is odd. we spawn one bullet at the player's direction
        else
        {
            if (i % 2 == 1) // bullet 1, 3, 5
            {
                angle = playerDirection.y + ((i + 1) * 15f); // 30f, 60f, 90f...
            }
            else // bullet 2, 4, 6
            {
                angle = playerDirection.y - ((i) * 15f); // -30f, -60f, -90f...
            }
        }
    }

    newDirection = Quaternion.Euler(0, angle, 0) * playerDirection;
}

And here's a visual result! (6 bullets and 3 bullets)


texts: How to help players find friends in a cross-platform mobile game?

texts:
Users on different platforms (iOS and Android) that play the game should be able to find each other and become friends in the game. They must have the possibility to invite other friends as well.
The game is PvP so they will also be able to fight one another.

Is Facebook the best way to go about it? (invitation sent by email)


texts: What are the common methods for achieving dynamic asset destruction?

texts:
I am trying to determine the most appropriate destruction solution for an online desktop game. There are two main factors here that I am considering; 1) the performance of the approach taken and how much resources it requires, 2) the turn around time for making an asset "destructible".

There are three main destruction approaches which I am aware of:

1) Creating a destruction animation for each asset, which plays based on specific conditions

2) Create a second version of each asset consisting of rigidbodies. Under specific conditions, replace the static asset with the rigidibodies and gravity/ other physics forces will cause it to collapse

3) Use a mesh splitting system to dynamically split static assets into rigidbodies at runtime

Option 1 appears to have the best performance, however it also requires the most preparation time to do realistically. Option 3 on the other hand requires no preparation time for assets, however it is the heaviest on performance since it is completely physics based.

My question than is, which of the above approaches is most common in the industry today? Or if there is another better approach which I have missed, what is it. Ideally I would like to go with option 3, but I fear that the performance hit would be too severe.


texts:
I'm creating a game in Flash AS3 in which the player needs to modify land in order to direct the water in the right direction.

However, water simulation is a new topic for me and I'm kinda stuck. It doesn't have to be like realistic water, with ripples and stuff, but it has to flow, and if there's enough water, it needs to rise.

I've thought up two different types of water:

A Spring: Infinite source of water. Used for simulating seas and stuff.
Water block: Just one unit of water.

My current implementation shows how I'd like the water to spread, but it doesn't rise, and doesn't allow for finite water. Also, the spreading isn't accounting for any amount of water, it just duplicates instead of actually moving units of water.

I'm curious to how you guys would solve this problem. Any examples/pseudo-code is always appreciated.

Current version: http://dl.dropbox.com/u/319897/ProjectWater.swf
You can manipulate the land by pressing left mouse. And can simulate one step of water at a time by pressing A.

Source of the water part: http://pastebin.com/Js2kYt4y


texts: Callback a function when a label is touched in cocos2d-x?

texts: How do I callback a function when label is touched in cocos2d-x?


texts: Transformation movement by using Accelerometer data

texts:
Is It possible to make transformation movement by using Accelerometer data or Accel + Gyro ?
as we know, we can make rotation by using Accel or Gyro data.
However, how can we make transformation movement?
I know this is still problematic and experimental. but there must be some ways to reach.

Is there any algorithm or math formula solving this problem?


texts: Proper way to handle destruction of game entities

texts:
Imagine a game world where loads and loads of entities are dynamicly loaded all the time, I would represent that as a list of entities perhaps, but what about removing them?

While when adding i could be pushing back the new entity, i could have the need to remove anywhere in the container. To avoid searching the element to find its position for removal, what choices do i have?

I tought that i could store the entity id as being its position in the container, creating a path for direct removal, but wouldnt that generate some kind of mutual dependency 'disorder' ?

I know the right way would be something like List.RemoveAt(whereToRemove); but what if only the entity knows when it should die?

Or am I just missing something and a list container would know when an object is destructed and reduce its own size?


texts: Implementing a modal dialog from scratch with C++

texts:
Right now I'm implementing my modal dialogs in windows with a separate message loop after popping up the dialog.

This straightforward an approach won't work with other systems that don't have message loops.

Obviously if I'd designed from scratch assuming one message loop I wouldn't have this problem.

In Unity3D (C#) I believe I could use a coroutine for this.

Aside from manually unrolling the code after the message loop so I can put it into a separate state or lambda to be called on close of the dialog, does anyone have any brilliant ideas on ways to make the code work with only one message loop?

I've tried googling but nothing obvious comes up.

EDIT:
I know how to write modal dialogs from scratch, the question is whether there's a simpler way to update older code to remove the message loops.

Let me see if I can write a better example of the pseudcode. This is the best I've come up with.

//DoAlert has a while doAlert is up processmessage loop in it
int i = doAlert("title", "Choice1", Choice2", "Choice3")
switch (i) {
  Case 1 : do something;
}

do something else and return to the routine that called you which does something else before returning, etc.

would become

auto alert = doAlert("title", "Choice1", Choice2", "Choice3");
alert.addChoice(1, [](){ do something; });
alert.addChoice(2, [](){ do something; });
alert.addPostProcess([](){});
... return from routine
alert.addPostProcess([](){});
... when finally at message pump...
alert.process();

...

Clumsy but at least it's simple to read and understand.

If I were writing from scratch, I would not have written it this way for new code.

I'd rather not decipher all these in order to get rid of the multiple message loops. The only way seems to be to trace what happens when the message loop exits, and put that into a lambda or possibly put the whole mess into a state machine. The lambda seems to be the simplest but it still means tracing through all of them and creating a stack of onexit routines from doAlert.

Thanks,
Ralph


texts:
I have a double array of tiles that show the ground.
They are randomly populated with a variety of items.

one item that only spawns one is a creature spawner.

this spawner spawns up to 5 creatures (for testing it does all 5 immediately).

these creatures move around randomly every update.

i know for a fact they are moving independent of each other.

but the weird part is, sometimes i only see 1 or 2 of the 5. the others arent there. console output tells me there is in fact 5.

and, additionally, when there is all 5, some of them get cut off if they move too far in one direction. but only SOME of them. ive seen two different creatures move in the same direction and only one of them got cut off.

to further complicate things, i believe some of the items on the ground are disappearing shortly after the world is created, including the spawner. sometimes i never even see the spawner, but the creatures are still created 'properly'.

i have in the initialization section to randomly generate the world, including all the items and where the spawner is.

after that is done, in the Update section, it checks if a tile contains an updateable object (currently, spawner is the only one). if it does, that objects calls its update method.

after that is done, the creatures are updated, if any.

then it is drawn. background tiles then ground objects then creatures.

if anyone has any idea what i might need to change to fix it or require any further information, just let me know, and thanks in advance!


texts:
I am trying to create a textured hexagonal tile map in opengl. I have the VBO and respective index buffer. Additionally I have a texture atlas for texturing individual tiles. I'm attempting to create a distinct texture for each hex without mixing the textures.

I understood that one should use a pair of (U,V) texture coordinates for each vertex. Now if the tile map would not be indexed and have the overlapping vertices, I could just set the texture coordinates for each vertex and get each hex rendering the correct texture. However, with indexing the overlapping vertices are gone and I can only set single pair of texture coordinates for each vertex which results in the textures mixing inside the hexes. Is there a way to texture tiles with indexing or another alternative approach to creating hex maps with different textures?


texts: View individual UI Rect boxes when multiple UI elements are selected?

texts:
I have 2D UI layout with multiple text boxes over the canvas, I need to easily be able to see where the Rect boxes for each are positioned, so that I can see where the safe areas are for placing buttons etc.

Selecting each individual item shows its own individual Rect box, but selecting multiple items just shows one big box around all of them.

Is there a way of selecting multiple items and see each individual Rect box?
It's extremely time consuming having to go and check each one individually.


texts:
I've been searching for a solution for my problem for a while on the web, but i didn't find anything that work properly

What i want to do

I have a bouncing ball and I want to let the user flick it with his finger (using a swipe gesture or whatever).
The ball shouldn't start moving unless the player flick touch the ball. I don't want the ball to move if the player flicks anywhere on the screen, only if the flick touch the ball

What i've done so far :

I've tried to write a script which would detect the touch starting position and the touch end position, and check if the end position is the same as the ball position to make sure that the flick touch the ball. Then the script calculate the direction vector by substrating the start position from the end position.
After that i use the AddForce methode and give it the direction vector as a parameter.

Here's my code, (it's better than 1000 words ) :

using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour
{
    public Vector2 start;
    public Vector2 end;
    public Vector2 direction;
    public Vector2 ballPos;
    public float Flicktime;
    void Start(){
        }
    void Update(){
        ballPos = new Vector2(transform.position.x,transform.position.y);
        if (Input.touchCount > 0)
        {
            Touch t = Input.touches[0];
            if (t.phase == TouchPhase.Began)
            {
                start = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x,t.position.y,0));
            }

            if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled)
            {
                end = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x,t.position.y,0));
                direction = end-start ;
                if(t.position == ballPos){

                    rigidbody2D.velocity = direction * 2 ;
                }
            }
        }
    }

}

What's the problem ?

The problem is that the code doesn't work.

When i launch the game in the Unity Remote 4 app in my android device and try to flick the ball it doesn't move, the inspector shows that the the scripte is calculating the start & end positions and the direction vector, but the ball doesn't move, it stays in the same position even when the flick touch the ball.

So what's the problem ? is there a better way to do it ?

Since the ball have a circle collider how to make it detect collision with the player swipe ?

Thank's and have a nice weekend !


texts: Procedural generation of physics-enabled structures (in a 2D world)

texts: Is it possible to procedurally generate stable structures out of rigidbody objects at a reasonable runtime speed? Imagine Angry Birds's levels kind of structures but generated procedurally.