texts: Power, achievement and affiliation games for psychology research project

texts:
For a psychology research project we're looking for short (ca. 5 minute) single-player games to observe people's basic motivation. We would like to ask people to list games that provide the closest possible (even if not perfect) fit to each description. We need 2-3 promising candidates for each of the following 3 categories.

We would be happy with anything we can use, build on, mod, change slightly etc. to fit our purposes.

A) Game that taps into affiliation

Affiliation involves being emotionally close to others and establishing new relationships. The game should revolve around meeting other characters. I.e. through simple means (clicking certain actions) one can explore possibilities to meet friends. Requests to establish relationships should be accepted in most cases, because the player is well-liked. This liking not related to status or performance, but to the warm fuzzy feeling of friendliness. When getting to know each other, many commonalities between player and character emerge and are happily acknowledged.

B) Game that taps into achievement

Achievement involves mastering difficult goals. In achievement games you would solve several quests by using some ability (speed, spatial thinking, strategy use). It should adapt to the player's ability, so that it is always possible to solve 60-70% of the quests. Player's should be able to improve their abilities and results with some training. Results should always be related to the individual performance, so there is no high score ranking with others or some such.The goal of this game should simply be to remain focused on a task of moderate difficulty, trying to become better at it.

C) Game that taps into power

Power involves obtaining social status and influencing other people. A power game would involve influencing characters and yielding reactions. It should have a low difficulty and work without points (kind of like a cheat mode maybe). In other words: Influencing other people should be easy, not dependent on achievement or liking. For example, the ability to change the lives of others could be due to insurmountable and unquestionable status differences between the person playing (e.g., a deity, a biologist) and the characters of the game (sticking to the example: mortals, ants).

Now, we hope to find resources we can re-use for our games. We don't have the ambition to create new games and many games already suit our needs. We only need the game to have at least 10 events relevant to the motive and to log these events (so we can align it with the reactions of our participants). If we can change it to do that, that'd be cool too.

Probably many quite simple games have been lost in the drawers of computer science students who made them as finger exercises and homework. We would only use these games in our research setting, so there is no commercial interest involved.

Many thanks in advance and best wishes from the whole lab!

we edited this in response to some comments


texts: Finding a way to display objects efficiently

texts: I am making a 2D simple Breakout game, and I would like to know of an efficient way to display all the blocks on the screen. I was thinking of dividing the whole screen into little squares that can be occupied by a block or a wall (or most objects). Is this the best way of doing it? Sorry if my question is kinda noob-ish, I just started learning to develop games.


texts:
Assume a tree of objects that need to be rendered, each with their own x/y coordinates.

Now let's say I could crawl through the tree and give each element a "z" coordinate, before rendering.

Is there a technique to allow the tree to be rendered out-of-order, yet still have the appropriate layering?

In other words, it makes no difference whether parent is drawn before child, or child before parent, the parent will always be drawn before the child (or the other way around, but it will be consistent).

I'm just getting started with WebGL, but I'm thinking that with some sort of orthographic projection, this would work?


texts: How to calculate normal vector of a Bézier curve?

texts:
How I can calculate the normal vector for two dimensional Bézier curve?

(I have the control points of the curve in the x y plane)


texts: Using GPU on Silverlight 5 for a Fast Fourier Transform

texts:
I've got an audio library for Silverlight that is in need of some acceleration on slower machines. Specifically, this library makes extensive and repeated use of the FFT transform as a part of its acoustic echo cancellation and noise reduction algorithms, and I'm wondering if it would make any sense to use the GPU for this (as described, for instance, here: http://www.inf.fu-berlin.de/lehre/SS10/SP-Par/download/fft1.pdf).

I know that Silverlight 5 provides a fairly simple port of Microsoft's XNA framework, but unfortunately, I'm a complete novice to 3D coding in general, and XNA in particular. It seems to me like it should be theoretically possible to use some combination of vertex and/or pixel shaders to work this magic, but before I go too far down this road, I wanted to get some expert opinions on a few questions:

(1) SL5's XNA implementation throws the output of its pipeline onto a single "DrawingSurface". I had been thinking that this is where I might be able to read the results of the calculations (kind of how you could use a WriteableBitmap to read the results of pixel shader calculations in SL4). But I can't figure out how I would do that: there's no "GetPixels()" method, or anything like that. In regular XNA 4.0, the VertexBuffer has a GetData() method, as do the Texture2D and Texture3D classes, but those methods are missing in the SL5 version. Does anyone know of any way to actually read the results of shader outputs? Or is the GPU a write-only device in SL5?

(2) It seems like the real problem with GPU calculations is reading the results quickly. Assuming I can solve problem #1, does anyone know whether an FFT would be amenable to this sort of solution?

(3) Silverlight 5 is limited to HLSL Level 2, which has a number of serious limitations, so far as instructions, registers, available functions, and so forth. Is it at all reasonable to expect to be able to port an FFT or some portion thereof over to this?

Thanks in advance.


texts: Creating practically solvable 15 puzzle inputs

texts:
I am now developing a 15 puzzle game. I know the method to detect unsolvable puzzles. But unlike 8-puzzle, solution for 15-puzzle takes quite long time for some input states and can be solved within 5 seconds some other set of input states.

Now the problem is that I cannot give the user(the player), a problem for which the solution takes more than 10 seconds(if he/she chooses to see the solution). So what I want is that when I initially shuffle the puzzle, I want to only present those puzzles which can be solved within 10 seconds. There must be some way to determine the hardness of the puzzle. I tried searching the net but could not find it.

Does anyone know a way of determining the hardness of a puzzle?
NOTE : I am using A* algorithm to find out the solution on a computer with 3GB RAM and 2.27GHZ processor.
EDIT : I have an additional requirement also. I am including a Puzzle Solver also. So based on the user's input, the cpu will solve the problem. Present A* algorithm with manhattan distance as heuristic takes a lot of time. First of all I would like to know which algorithm to choose - A* or IDA or some other. And I would like to know about other heuristics also.


texts: How can I fill the interior of a closed loop on a tile map?

texts:
In my game the player can dynamically modify terrain.  The map is stored within a 2D array of prefabricated 3D objects.  This is working well for now.  The player modifies terrain by selecting what sort of tile they'd like to create (like cliff going up or down), and then clicking individual tiles, or "painting" over multiple by holding down mouse button and scrolling.

I don't want the player to have to manually click every tile they want to rise or fall in elevation.  The most elegant solution I can conceive, is for the player to "paint" a loop of cliff tiles, which is then filled in automatically when the loop closes.  Imagine, perhaps, someone drawing a line using MS Paint or Photoshop, until that line closes into a shape which then autofills.

Let's say the player wants a plateau, and so they select cliff going up, and then click and drag the desired shape.  Upon closing the loop, when the last cliff tile is created beside the first cliff tile, witchcraft is invoked which fills the inside.

I have no idea how this can be done, never mind elegantly or optimally.  There are obvious possible solutions (find the average vector of all tiles in the loop, and then dijkstra algorithm from the average until the space is filled with the correct elevation), but these assume the shape generated is blobby or boxy.  An irregular shape where the mid point falls outside of the shape is possible and would probably ruin that solution!

How can I fill the inside of a closed loop? I'd like a theoretical solution I can go away and implement in C#.  At this point it seems like there is probably conceptual overlap between raster graphics and procedural maps!


texts: How do I avoid using the wrong texture2D function in GLSL?

texts:
I was developing a small engine running on a combination of SDL and OpenGL, and I want to use that engine for a school project, so I needed to test it on a school PC to see the performance. This resulted in a shader compile error:

  Shader compile ERROR
  DEBUG INFO: ERROR: 0:12: 'texture' : no matching overloaded function found (using implicit conversion)
  ERROR 0:12: '=' : cannot convert from 'const float' to '4-component vector of float'
  Failed to load uniform

This is my fragment shader, where the error occured:

    #version 130

in vec4 fragmentColor;
in vec2 fragmentUV;

out vec4 color;

uniform float time;
uniform sampler2D mySampler;

void main(){
    vec4 textureColor =  texture(mySampler, fragmentUV);

    color = textureColor * fragmentColor;
}

I solved it by using the texture2D function, instead of texture. However, the older function is not recommended in newer code. This leaves me with two questions:

Why did this happen? Could it had been because of older drivers being installed on these PCs?
What should I do when I want to follow the new guidelines, and also to make it runnable on older machines? I thought about using two different shader,s and letting the program decide on the version, but I´m not sure.


texts: Simple Automation of Car Path Finding Between 2 Points

texts:
I would think that it would be simple to have a car drive from A to B, but apparently I haven't been able to figure it out. My goal is to have a car begin at a certain position and angle, calculate the best path to another position with another angle, and then travel there.

Please keep in mind that this car has a minimum turning radius, so it can't simply change angles by spinning. Also, I would like to see what I can do with the car only traveling in a single direction, ie. no reversing.

I have read over many grid-based algorithms, but I don't see how I can translate those to what I need, which is most likely a series of arcs and straight lines.

The closest thing I have have found is Dubins Interval, which seems closest to what I need, though I believe it is old and has probably long since been replaced. I have sketched out paths using this method, but have had trouble translating it to programmatic form (C++). I believe the rough idea is to line up the minimum steering circles of the start and goal, start turning from the start until you are on the line, head towards the goal, and then either simply go onto the goal circle and curve it, or project an additional circle on the same line and use it to end up on the goal circle in the opposite direction.

If anyone knows of any examples, code preferred, of simple car driving path examples, I would appreciate it.


texts: Box collider pushes me out of it's area slowly, I can pass through it if moving quickly

texts:
I am new to Unity. I Setup a character in unity2D with a rigidbody. I had the scale off my sprites set to 100 pixels per unit. At this scale, my rigidbody character stood on top of platforms and could not pass through walls containing box colliders. I decided, that to make things easier, I would change all sprites to 1 pixel per unit. After doing so, I scaled everything (variables, sizes, etc.) by 100. I confirmed that the box colliders on both the caharcters, floor, and walls, are all in the same places, relatively. The box colliders on the floors still work, but the wall box colliders behave differently. When I walk into a wall, the wall slowly pushes me in a direction (depending on whether or not my character has walked through half the wall or not). The wall should be stopping my motion completely.

The code is very simple, but this is what I use to move:

if (Input.GetKey (KeyCode.D)) {
        transform.Translate (Vector2.right*moveOffset*Time.deltaTime);
        transform.localScale = new Vector3(1,1,1);
        anim.SetBool("moving",true);
    }

Do note that the moveOffset variable, was scaled by 100 after the change. Thanks in advanced!


texts: Update Camera manually after Camera's target updates, bypassing the game loop. Is this a good or bad practice?

texts:
This question may be suited better for codereview.stackexchange.com?

I've been experimenting with a camera implementation / matrix SpriteBatch transformations and have run in to a bit of a snag.

The camera's .Update() method updates the transformation matrix and the camera's positioning.

My Player class depends upon the camera in order to work out where the mouse is in relation to the game world for a rotation calculation. This leads to the camera's information being one frame out of date when I need to be. This isn't noticeable when the player isn't moving as the camera's information is correct; even at low speeds I didn't personally notice the problem. However the speed was in excess of ~1000 pixels/sec (a few pixels per frame), it started to introduce a jittery-ness to the player's transformed position. Above and beyond these speeds resulted in very ugly drawing.

My thought process was "So I should update my camera immediately after the player's position has changed instead. Won't that introduce an unnecessary dependency? What happens if my camera isn't following the player or a player doesn't exist?"

My solution:

// in Camera2D.cs

public void ManualUpdate(GameTime gt)
{
    Update(gt);
    _hasAlreadyUpdated = true;
}

public void Update(GameTime gt)
{
    if (!_hasAlreadyUpdated)
    {
        DoUpdate(gt);
    }
    else
    {
        _hasAlreadyUpdated = false;
    }
}

private void DoUpdate(GameTime gt)
{
    ...
}

I can now manually call the camera's .Update() method early if I want to and it won't lead to multiple calls per frame. The jitter has been completely eliminated.

Would you consider this an adequate solution? Can you think of something more elegant?


texts: I'm looking at implementing an existing XNA Animation library into my engine.  I would ideally like to be able to use BVH animations, but I'm not sure on which is a good library to work with.  Any ideas?


texts: isometric coordinates issue: (0,0) and (5,5) are flipped?

texts:
I am having an issue with the isometric coordinates.

When I enter the coordinates (5,5), the character should be at the bottom corner of the tile, but it is at the top corner, (5,5) and (0,0) look like they have been switched :

With (5,5), my character goes at the top instead of being at the bottom corner :

(The convertToScreen method is from :
Isometric rendering and picking? )

//create isometric tiles
public Vector2 convertToScreen(float x, float y, int offsetX, int offsetY)
    {
            Vector2 screen;
            float TILE_WIDTH = 1;
            float TILE_DEPTH = 0.5f;
            //calculate the screen coordinates
            float _x =  offsetX - (y * TILE_WIDTH/2) + (x * TILE_WIDTH/2) - (TILE_WIDTH/2);
            float _y = offsetY + (y * TILE_DEPTH/2) + (x * TILE_DEPTH/2);

            screen = new Vector2(_x, _y);
            return screen;
     }

//in the "create" method
float valueCam = 10;
    camera = new OrthographicCamera(valueCam, valueCam * (Gdx.graphics.getHeight() / (float)Gdx.graphics.getWidth()));
    camera.translate(new Vector2(0,0));

    Vector2 conv = convertToScreen(5,5, 0,0);
    myCharacter.setPosition(conv.x, conv.y);

    public void renderMap(){
        float tileWidth = 1;
        float tileHeight = 0.5f;
        for (int x = 0; x < 5; x++){
            for(int y = 5-1; y >= 0; y--){

                Vector2 v = convertToScreen(x,y, 0,0);
                float x_pos = v.x;
                float y_pos = v.y;

                //float x_pos = (x * tileWidth*0.5f ) + (y * tileWidth*0.5f);
                //float y_pos = - (x * tileHeight*0.5f) + (y * tileHeight*0.5f);

(edit: the previous issue was the offset of x-1, fixed by changing the x_pos and y_pos as shown above)


texts: Getting ray using gluUnProject or inverted MVP matrix

texts:
I've read a lot of topics here, on SO, opengl.org etc.
Example how gluUnProject should work (from NeHe tutorial):

winX = (float)x;
winY = (float)viewport[3] - (float)y;
glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);

The problem is that gluUnProject returns mostly zeros, if not zeros then it returns Camera position in World Coords. Value winZ I'm getting from glReadPixels is always correct, if I scale it like below:

float z_distance = ProjectionMatrix[14] / (winZ * -2.0 + 1.0 - ProjectionMatrix[10]);

I get distance between near plane and parallel plane that contains mouse click point. Look at the sample below:

gluUnProject( winX, winY, -1, modelview, projection, viewport, &posX1, &posY1, &posZ1);
gluUnProject( winX, winY, 0, modelview, projection, viewport, &posX2, &posY2, &posZ2);
gluUnProject( winX, winY, 1, modelview, projection, viewport, &posX3, &posY3, &posZ3);
gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX4, &posY4, &posZ4);

The result is always the same (posX1,posY1,posZ1)=(posX2,posY2,posZ2)=(posX3,posY3,posZ3)=(posX4,posY4,posZ4) and is either (0,0,0) or (Camera-Position.x,Camera-Position.y,Camera-Position.z)

After gluUnProject I tried to do it manually:

float NDC_x = 2.0f * winX / Width - 1.0f;
float NDC_y = 1.0f - 2.0f * winY / Height;
float winZ = 0;
glReadPixels(winX, (Height - winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
vec4 point1 = inverse(ViewProjectionMatrix) * vec4(NDC_x, NDC_y, winZ, 1.0f);
vec4 point2 = inverse(ViewProjectionMatrix) * vec4(NDC_x, NDC_y, -1.0f, 1.0f);
vec4 point3 = inverse(ViewProjectionMatrix) * vec4(NDC_x, NDC_y, 0.0f, 1.0f);
vec4 point4 = inverse(ViewProjectionMatrix) * vec4(NDC_x, NDC_y, 1.0f, 1.0f);

Now all points coordinates are different and never zeros but some values, seems like real ones but I don't know how to handle it or I missed something.

BTW I used different approach to get ray (using angles) and it works perfectly. Check here.

Q1: Any suggestions what's wrong with gluUnProject ?

Q2: What is my mistake in manual implementation?

I thought that I messed with row\column-major format, but transposition of matrices had no effect. I read\write matrices as column-major format so last column is (ViewMatrix[12], ViewMatrix[13], ViewMatrix[14], ViewMatrix[15])


texts: Adding gravity to arrival steering behavior

texts:
I trying to write an autopilot for the classic Lunar Lander or its clones.

According to this paper, the arrival behavior is exactly what I need for a soft landing. In this example, it accelerates at max_speed until it's near the target and decreases near the target to zero. Adding gravity and a engine to decelerate makes this a lot more complicated, at least for me since I couldn't wrap my head around the concept for the past few hours.

Currently my spaceship moves in the right direction but doesn't counter gravity and just throttles the engine, crashing near the target. I know my current position, velocity and the gravity is constant. I need to output thrust-levels (0-4) with a -90° to 90° angle.

Can you give me some pointers as to how I could incorporate gravity into this steering behavior?


texts: Are there such things as online development projects?

texts: I would like to practice a bit as a programmer in the gaming field but know of no one making games in my proximity. I was wondering if there is an online community or something where people look for other developers for their projects? I mean as in simple independent stuff, not paid of course, it would be just to get practice and maybe be able to complete something. Any pointer appreciated.


texts:
In the editor's hierarchy, if I drag and drop one object onto another, the second becomes the parent of the first, and moving the parent will cause the child to move. I see I can set this relationship in code by setting the transform.parent property. So I wrote a component to help with doing that from code:

public class ParentTo: MonoBehaviour
{
    public GameObject _parent;

    public GameObject Parent {
        get { return _parent; }
        set {
            this.transform.parent = value.transform;
            this._parent = value;
            Debug.Log("Set parent");
        }
    }
}

So to test it, I have 2 cubes in the scene. On cube 2 I put the ParentTo script, leaving it with no parent set, then start the game and use the editor to drop Cube 1 on that field in the inspector. According to the inspector, it seems to have been set right, but the debug statement doesn't appear in the console and moving Cube 1 doesn't move Cube 2. What am I doing wrong?


texts:
I try to understand what's the best way to handle error conditions in Unity. In a lot of places I've read that throwing exceptions is a bad thing. Unfortunately, I have not found any guidance on Unity website on this matter as well finding clear guidance on the wide Internet is also difficult.

What I use quite often is Debug.Assert statements to check that certain conditions for proper operation are met.

But what to do, if something unexpected happens? Some examples could be:

Network connection lost
File write operation failed (for some reason)

What is a good practice to handle these situations? Just do a Debug.LogError to log important info and then let the game crash?

Happy to hear your thoughts on this.

Thanks!

Update 12.08.2019 22:06

Based on the comments received, I have added the code example below with some comments / thoughts from my side.

Example: Load Level Data From JSON File

In this example, I load level data from a JSON file (SceneData.json). It could theoretically happen, that the level file is not available. I do not check the result of Resources.Load() yet, but if the file cannot be found, a NullReferenceException is thrown. I have not tested this yet, but I think a NullReferenceException will terminate the whole Unity game at runtime. So how to improve this situation in a way, that informs the player about this problem? What can be done to support the developer in fixing the issue?

Some thoughts from my side for improving code:

I should check the return value of Resources.Load(). If it is null, I also issue a Debug.Error log. That way, the problem gets logged to the console during testing/development but also to the Player.log on the target system (e.g: Windows).
If I want to inform the player about the problem, I could return null in the GetDragAndDropLevel method to inform the caller about the fact, that no level was loaded. I could the further propagate this information up the call stack to display an error message in the GUI at the end.

Does this sound reasonable in the Unity context? Or do you guys do this stuff completely different?

public static DragAndDropLevel GetDragAndDropLevel(GameLanguage language, GameScene scene, int level)
{
    Debug.Assert(level >= 1);

    // Generate filename
    var sceneDataFilename = "SceneData/" + scene + "/SceneData";

    // Read JSON structure into SceneDataDragAndDropLevel object
    var textAsset = Resources.Load<TextAsset>(sceneDataFilename);
    var jsonData = textAsset.text;
    Logger.LogDebug(jsonData);
    var sceneData = JsonConvert.DeserializeObject<SceneData>(jsonData);

    var numLevels = GetNumberOfLevels(sceneData, GameType.DragAndDrop, scene);
    Debug.Assert(level <= numLevels);

    // Generate level object
    var dragAndDropLevel = GetDragAndDropLevelFromSceneData(sceneData, level);
    return dragAndDropLevel;
}


texts: libgdx - Image artifacts when downscaling image

texts:
Why does this border appear around the edges when I downscale a bitmap and how do I avoid it? I tried every filter I know, the results go from bad to worse.

Here's the original bitmap:


texts: How can I reposition Cinemachine Virtual Camera?

texts:
The main goal is when I will move the soldier around either by keys or by animation the virtual camera should follow and tracked him.

In the screenshot this is the original camera position and rotation on the soldier. The original camera name in the Hierarchy is SoldierNaviFightCamera just under SoldierNaviFight in the Cutscenes.

The soldier is the Space_soldier_A under NPCS

Now to the Cutscenes I'm adding a new empty GameObject name it CM Cameras.
Then I'm adding from the editor top menu of the Cinemachine a Virutal Camera:
Now I have a new virutal camera name CM vcam1
In Follow and in the LookAt I'm dragging the Space_Soldier_A

To the original camera I'm adding the component: Cinemachine Brain
Once added it it's automatic assigning in the CM vcam1 but it also change the whole camera/s position and rotation.

This is a screenshot once I added the Cinemachine Brain:
You can see the whole position and rotation is different from the top first screenshot.

And this screenshot is of the virtual camera: Inspector

What I want to do and can't figure out yet is:

How to keep the original camera position and rotation so the virtual camera that take over the original camera will position and rotation will be like the original camera.
Have I missed anything for making the camera to follow the soldier ? Will it follow the soldier also if I move the soldier on my own with keys ?
Should I put the virtual camera CM vcam1 as child of CM Cameras ?


texts:
I'm in the process of trying to get familiar with making games in Java, using the Swing library.

Coding my Snake game however, I've got to a point where the game is flickering/ghosting and I haven't a clue why.

An example of the flickering can be seen on this short youtube video:
http://www.youtube.com/watch?v=QP1IcZ5TRoY

I dread to post too much code here as it won't help anyone, but for glancers, I'll post some facts.

Painting on a JComponent
I do call super.paintComponent(g) at the start of my overrriden
paintComponent method
I've set setDoubleBuffered(boolean) to true.
Although unsure of its necessity, I've invoked
createBufferStrategy(2) on my JFrame
My "game loop" is based on a swing.Timer calling repaint every 17ms, but tried, 30fps
Snake piece moves at 25 pixel paces (or relative to world size).

This is how I draw each tile:

    for (int i = 0; i < gamePieces.length; i++) {
        int x = i % ROW_COL_SIZE;
        int y = i / ROW_COL_SIZE;

        if (gamePieces[i].equals(Tile.EMPTY)) {
            continue;

        } else {
            final SnakeGraphics gfx = gamePieces[i].getGraphic();
            gfx.draw(g2d, x, y, direction);
        }
    }

This is what is called on repaint:

public void render(Graphics2D g2d) {
    Direction dir = keyboard.getDirection();
    snake.setDirection(dir);
    snake.move();
    gameWorld.draw(g2d, dir);

}

and finally, how the snake moves:

public boolean move() {
    Point snakeHead = snake.getFirst();
    int x = snakeHead.x;
    int y = snakeHead.y;

    boolean success = validateStep(snakeHead); //boundary control + move

    if (success) {
        gameWorld.setTile(x, y, Tile.EMPTY);
        gameWorld.setTile(snakeHead.x, snakeHead.y, Tile.SNAKE_HEAD);
    }
    return success;

}

where gameWorld has all the tile information, i.e. what tiles get drawn and where, and Snake is just current position of the head thus far.

Apologies for the code-drop, but its all that I can determine to be relevant.


texts:
I'm trying to make an enemy for my game, and everything works, except for the bit of code where the enemy is supposed to die.

My player attacks but nothing happens.

I filled in the prefabs, I have the right tags, I tried remaking it and I can't find anything that is wrong.

What am I doing wrong?

#pragma strict
var EnemyItself : GameObject;
var EnemyCorpse : GameObject;

function OnTriggerEnter(other : Collider) {
    if (other.gameObject.tag == "Hero Punch") {
        EnemyItself.SetActive(false);
        EnemyCorpse.SetActive(true);
    }
}


texts: How big should my tiles be for tilemaps?

texts:
I'm creating my first tilemaps.

Tutorials usually do 32x32px (example), but this tutorial did 128x128px, which made it easier for me to see without zooming in so much.

In tiled, I did a 40 x 40 tile map at 128 x 128 px, and the map was 5120 x 5120 px big, versus the same 40 x 40 tile map at 32 x 32 px giving me 1280 x 1280 px in resolution. I'm making a web game from the typical HTML 5 (with canvas), JS, CSS3, and melonJS engine.

Does it matter if I make 32 x 32 px tiles vs 128 x 128 px? Will it affect performance?


texts:
I'm making a 2d multiplayer html5 game that needs client-side movement, collision etc.

Client sends active cursors to the server (w,a,s,d), server updates cursors on all clients and clients handles movement for each other. Every client sends server it's x,y every 100ms and server updates sender's x,y on all clients.

It works perfectly if player's latency is <1ms but even if player has 40ms latency everything seems like teleporting.

How can i make everything smooth without handling movement on the server? (like transformice.com do)

Sorry for my grammar.


texts: Why does Mathf.Log(x) return infinity in this case?

texts:
I'm facing an unexpected behavior due to computational limits, I guess.

I have a function Log(x) which, for some high value in the Fibonacci series n 187 = 5.38·10^38 returns Infinity.

Is there a way I could follow to avoid this and always have computed numbers?


texts: Has there been any research into how to maximize in-game tutorials effectiveness? Any blogs, articles or research papers would be appreciated.


texts: "ArgumentNullException: Value cannot be null" for AudioSource.PlayOneShot

texts:
I am working on a game and I am trying to add a sound effect.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private Rigidbody playerbody;
    private Animator playerAnim;
    private bool grounded;
    public bool gameover;
    public float jumpforce;
    public float gravmod;
    public ParticleSystem explosion;
    public ParticleSystem dirt;
    public AudioClip jumpSound;
    public AudioClip crashSound;
    private AudioSource playerAudio;

    // Start is called before the first frame update
    void Start()
    {
        playerbody = GetComponent<Rigidbody>();
        playerAnim = GetComponent<Animator>();
        playerAudio = GetComponent<AudioSource>();
        Physics.gravity *= gravmod;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && grounded && gameover == false)
        {
            playerAudio.PlayOneShot(jumpSound, 1.0f);
            playerbody.AddForce(Vector3.up * jumpforce, ForceMode.Impulse);
            playerAnim.SetTrigger("Jump_trig");
            grounded = false;
            dirt.Stop();
        }
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Ground"))
        {
            grounded = true;
            dirt.Play();
        }
        if (collision.gameObject.CompareTag("Obstacle"))
        {
            playerAudio.PlayOneShot(crashSound, 1.0f);
            gameover = true;
            playerAnim.SetBool("Death_b", true);
            playerAnim.SetInteger("DeathType_int", 1);
            explosion.Play();
            dirt.Stop();
        }
    }
}

At playerAudio.PlayOneShot, it just won't play and the rest of that part of the code stops working. It returns ArgumentNullException: Value cannot be null even though jumpSound and crashSound are both clearly defined. What is wrong?


texts: How to rotate camera counterclockwise around player?

texts:
Holder contains camera and rotates around player

Camera looks like in diablo, titan quest, grim dawn, etc

I cant rotate camera to negative angle values

My code:

public void ChangeRotation(float val){
    if(isTurning)
        return;
    isTurning = true;
    needAngleY += val;
}

void Turning(){
    Quaternion quatertion = transform.rotation;
    Vector3 eulerAngle = new Vector3(0, quatertion.eulerAngles.y, 0);

    if(needAngleY - eulerAngle.y < 0.2f){
        if(needAngleY == 360 || needAngleY == -360){
            needAngleY = 0;
        }
        eulerAngle.y = needAngleY;
        isTurning = false;
    } else {
        eulerAngle.y = Mathf.Lerp(eulerAngle.y, needAngleY, timeRotation * Time.deltaTime);
    }
    m_Compas.rotation = eulerAngle.y;
    quatertion.eulerAngles = eulerAngle;
    parentTran.rotation = quatertion;
}


texts: How to determine which cells in a grid intersect with a given triangle?

texts:
I'm currently writing a 2D AI simulation, but I'm not completely certain how to check whether the position of an agent is within the field of view of another.

Currently, my world partitioning is simple cell-space partitioning (a grid). I want to use a triangle to represent the field of view, but how can I calculate the cells that intersect with the triangle?

Similar to this picture:

The red areas are the cells I want to calculate, by checking whether the triangle intersects those cells.

Thanks in advance.

EDIT:

Just to add to the confusion (or perhaps even make it easier). Each cell has a min and max vector where the min is the bottom left corner and the max is the top right corner.


texts:
I created a model and then tried to add armature. But when I'm moving the rig, some of it stays in the place (the mouth), and I don't know why. Anyone know why it could happen and how to fix it?

This is what I did : http://www.mediafire.com/download/fg86hdb82wjit6q/Alien2.blend

These pictures illustrate the problem:
idle pose:

when rotating a bone:

Thank you!!


texts: How can I determine which tiles in a tilemap an oriented bounding box (OBB) overlaps?

texts:
I need to detect collisions between an oriented bounding box and a static tile map. My tile map class looks something like this:

function Tilemap(width, height, tiles) {
    this.width = width;        // Width of the map in tiles
    this.height = height;      // Height of the map in tiles
    this.tiles = tiles;        // 1D array containing tiles, grouped by row
}

Tilemap.prototype.getTile = function (x, y) {
    return this.tiles[y * this.width + x];
};

Tilemap.prototype.setTile = function (x, y, value) {
    this.tiles[y * this.width + x] = value;
};

My question is this: How can I determine which tiles an OBB, represented as an array of vertices, overlaps?

(I am writing in JavaScript but answers for any language would be appreciated.)


texts: PYGAME: When I release two directional keys together the player keep moving

texts:
I did the code this way to avoid the player to stop if a press two directional keys together making the movement more smooth. It works well but when I release two keys or more together the player keep moving in one of the directions of the key. I can't figure out how to solve this issue.

Here is my code:

def input(self, event, pygame):
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_LEFT:
            self.left_is_down = True
            self.speed_x = -self.velocity
        if event.key == pygame.K_RIGHT:
            self.right_is_down = True
            self.speed_x = self.velocity
        if event.key == pygame.K_UP:
            self.up_is_down = True
            self.speed_y = -self.velocity
        if event.key == pygame.K_DOWN:
            self.down_is_down = True
            self.speed_y = self.velocity

    if event.type == pygame.KEYUP:
        if event.key == pygame.K_LEFT:
            self.left_is_down = False
            if self.right_is_down:
                self.speed_x = self.velocity
            else:
                self.speed_x = 0
        if event.key == pygame.K_RIGHT:
            self.right_is_down = False
            if self.left_is_down:
                self.speed_x = -self.velocity
            else:
                self.speed_x = 0
        if event.key == pygame.K_UP:
            self.up_is_down = False
            if self.down_is_down:
                self.speed_y = self.velocity
            else:
                self.speed_y = 0
        if event.key == pygame.K_DOWN:
            self.down_is_down = False
            if self.up_is_down:
                self.speed_y = -self.velocity
            else:
                self.speed_y = 0

def update(self):

    self.x += self.speed_x
    self.y += self.speed_y


texts: Efficient datastructure to store a galaxy map

texts:
I'm working on a project for an intro level Ai class, and the project I've closen is to create a simulated universe in which Ai actors play against each other economically and militarily. I have the actual Ai fundamentals planned out, but I've hit a bit of a snag in trying to properly store the randomly generated game world.

The solar system objects are generated and populated randomly and the aim I'm going for is to place them in a 3d world, with x,y,z positions relative to a galactic center.

Each system should be reachable from any other system, limited only by the jump range of a given ship. Which I assume would mean that id need a 3d bounding algorithm to determine what other systems are in range.

For storing them, would a weighted edge graph be best, although the number of edges would be huge as in theory each system is reachable from any other. Or would an octree be better. And if so how would I calculate a list of reachable systems from the current system with an octree.


texts:
Sfxr (and also Bfxr) is a great tool for generating sound-effects for games. Is there something like this for speech synthesis?

Not every game development tool and platform has a speech synthesis engine, and it would be great to at least get some decent-sounding placeholders in place to see how the usability/experience plays out. Even better if the results are tweakable, like sfxr.

I'm looking for something I can at least run on windows, though preferably (like Bfxr) I would like a web application that I can just run out of my browser.


texts: How do I calculate where which pixel it's reflecting based on a height map?

texts:
I saw this How can I Compute steepness for heightmap while looking for a way to reflect pixels.
But now that I have the steepness/slope I don't know how to calculate which angle it's pointing at.
Imagine if I had an image parallel (directly above my heightmap) with my heightmap and 100(units/pixels) away/above from it, if the steepness is 0, then i just grab a pixel at that same [x,y].  Imagine that i am trying reflect what the heightmap would show if i was to be able to see through my image.
But let's say I have a steepness of 1 which i am guessing is 45 degrees since 1/1 is 45 degrees but which pixel should i be grabbing from my image how do I calculate what angle the pixel is coming from [x,y].
How would i calculate which pixel(location) is reflected onto the heightmap (imagining that the heightmap is a chrome surface).
I know if the angle is too steep it'll be way outside of the image but I'll just use min/max hack to grab border pixels (unless you can think of another method to handle that) but for angles that are inside my image still...how do I calculate which pixels to reflect.
Basically trying to render an image reflected by height-map when image is placed directly above heightmap with variable input of distance between image and heightmap (use like 100 units as example, but i want to allow user the ability to change this distand)
Please explain in easy terms as sometimes I don't understand rare mathematics notation/symbols.
Thanks in advance.
EDIT: This got me searching for calculating normal for heightmap I think I found what I was looking for.


texts: Creating shattering effects without having to use actual physics?

texts:
For certain effects like glass shattering and falling objects cracking to reveal their inner contents, are there any tricks or ways to implement these fracture physics without having to use actual physics simulation? Also, what are the trade-offs if I don't use real physics simulations?

Since the effects don't really require exact simulation, an actual physics simulation may be too expensive and wasteful.


texts: (unity3d) Raycast Tags: Object reference not set to an instance of an object not working!

texts:
Here is the code I have written for an AI:

public Transform player;
public NavMeshAgent Enemy;
public CharacterPowers CharPow;
public GameObject me;

// Update is called once per frame
void Update () {
    Vector3 targetDir = player.position - transform.position;
    float angleToPlayer = (Vector3.Angle(targetDir, transform.forward));

    if (angleToPlayer >= -90 && angleToPlayer <= 90)
    {
        RaycastHit hit;
        Physics.Raycast(me.transform.position, player.position, out hit);

        if(hit.transform.tag == "MainChar")
        {

            if(CharPow.IsCloaked == false)
            {
                Debug.Log("Player in sight!");
                Enemy.destination = player.position;
            }

        }

    }

}

However, according to the error message, the line

if(hit.transform.tag == "MainChar")

is missing a reference to an object. I have checked, and yes, the player character does have the tag. Everything else used to work, such as the cloaking mechanic. However, now nothing about the AI works at all.


texts: Animating compression wave shader which uses image for displacement map

texts:
I've been testing a variety of shockwave or ripple effect shaders, and spent time on this cleaned up and improved version on shadertoy.

I'm not entirely satisfied with that because it produces an ugly "bubbling" effect in the center. I'm trying to add a stronger "compression" effect to the shockwave itself but everything I do results in a stronger bubbling effect in the center.

I've found an example of what I want which uses an image for the displacement map: example

The author of that example only provided a sample of the shader code which I've been able to port. However, I don't understand how to animate this (to expand outward) over time.

Here's my current port into hlsl for Unity:

Shader "Hidden/Shockwave2"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _GradientTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _MainTex;
            sampler2D _GradientTex;

            fixed4 frag (v2f i) : SV_Target
            {
                fixed2 center = fixed2(.5, .5);

                fixed2 dir = normalize(i.uv - center);

                // Get the pixels off of the maps.
                fixed4 gradC = tex2D(_GradientTex, i.uv);

                // Read the pixel from the displaced position.
                fixed2 pos = i.uv;
                pos.x += (gradC.r * 2.0 - 1.0) * 0.025;
                pos.y -= (gradC.g * 2.0 - 1.0) * 0.025;

                return tex2D(_MainTex, pos * dir);
            }
            ENDCG
        }
    }
}

This produces the correct visual, but I need to animate its expansion outward.


texts: Setting oblique projection to data visualization

texts:
I'm developing a small application using Directx intended to plot frequency spectra data in a waterfall plot. It should look like this:

So far, I managed to created most of the chart components(axes, title and the data can be plotted as lines or slices as the picture above). The problem now is that I could not managed to create a projection similar to that in the image. I know the projection shown in the image is an "Oblique projection" and I've tried several ways to get it:

https://www.cs.unm.edu/~angel/CS433/LECTURES/CS433_17.pdf

Here, the author proposes the projection matrix as

P = M_orth * H(θ,φ)

where M_orth is an orthogonal projection matrix and H(θ,φ) is a shear matrix defined as

H(θ,φ) =
    | 1  0  -cot(θ)  0 |
    | 0  1  -cot(φ)  0 |
    | 0  0    1      0 |
    | 0  0    0      1 |

Practical C# - Chart and Graphics, Chapter 5, Pg 247

Here, the projection matrix is defined as

P(α,θ) =
    | 1  0  cos(θ) / tan(α)  0 |
    | 0  1  sin(θ) / tan(α)  0 |
    | 0  0         0         0 |
    | 0  0         0         1 |

and the author gives two special cases:

Cavalier projection: alpha = 45°, 30 <= theta <= 45
Cabinet projection: alpha = 63.4°, 30 <= theta <= 45

But none of them have gave me good results:

And I don't understand why I'm getting this strange results? Any of you guys knows how to set the oblique projection properly?

Thanks in advance


texts: Applying different materials to an object

texts:
I'm currently implementing an Object Loader for the Wavefront File Format (*.obj). When exporting a model (with associated materials) from blender, a material for a group of faces is specified like this:

usemtl MyMaterial
s off
f 2/1/1 4/2/1 3/3/1
f 1/4/1 2/1/1 3/3/1

Since each material consists of (at least) 3 components for each of ambient, diffuse specular color and also shininess (which totals up to 10 floats) I would consider it to be a tremendous waste of memory to store all of these values for each vertex.

Does OpenGL provide us with a more elegant/viable way to achieve the same result with a more reasonable memory consumption or do I have to swallow the bitter pill?


texts: Unity - PoolingSystem failing to instantiate

texts:
I am wanting to spawn monsters into my scene in Unity. I was told to use a Pooling System, so I got the free one Unity offers in the Asset store. I have followed the little documentation that there is, and am encountering an error. I do not know if I am just missing something but I am getting an object reference not set error.

NullReferenceException: Object reference not set to an instance of an object
PoolingSystem.InstantiateAPS (System.String itemType) (at Assets/Advanced Pooling     System/PoolingSystem.cs:104)
MobSpawner.Start () (at Assets/_Scripts/MobSpawner.cs:16)

It throws this on the following code:

private PoolingSystem poolingSystem;

// Use this for initialization
void Start () {
    poolingSystem = PoolingSystem.Instance;

    poolingSystem.InstantiateAPS("Resources/EnemyPrefabs/Skeleton");
}

Could someone please guide me in the right direction or tell me what is wrong here?


texts: Store voxel type data in XML or Java classes?

texts:
So, I want it to be very easy to create all the entities of my game and for other people to come in and do the same. I was thinking I could just let the users/myself create an XML sheet the stores all the properties of each block (Like a Terraria or Minecraft voxel) and add Lua scripts that are referenced in the XML for additional functionality of any of the blocks.

I'm starting to think It would just be easier to let the user create a JAR file full of classes for each block. And then that JAR file could easily be used to get all the blocks. It'd just be interesting to reference all the blocks by a block id without storing all the classes by ID. Or I could give each class a static id. But that's not important.

Okay, so my short question is what are the pros and cons of storing all the the different types of blocks as classes versus in an XML sheet with Lua for additional functionality?

UPDATE: I will probably go for the only use Lua approach. I found about it just recently and it appears like it could be the best method as of right now for me!


texts:
I have been told to research up on interchange formats, only comes up with certain interchange formats without actually explaining what they are.

What are interchange formats, specifically in the context of game development?


texts: Adobe Air Mobile AS3 app: challenges and how to overcome them?

texts:
I made a PC flash game for LD 26 - minimalism and I am working on porting it to Android.

Some questions I'd like to ask:

Is it bad to heavily use vector graphics (ie. this.graphics.lineTo()) in Mobile Air?
Does Stencyl completely alleviate this issue?
Are there any inherit disadvantages to using Air Mobile that I'm missing?
Where is the documentation for Air mobile (I googled and found no recent books or documentation pdf so far)


texts:
I have got simple 1x1x1 cube model. I draw 3 of them. They are located at:

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

I draw them in the same order every time. When I move the camera and look at them from one end everything is fine. If I look at them from the opposite end I can see parts of the cubes that should be occluded by the cubes.

How can I have them draw properly?


texts: How to make compound data in Game Maker?

texts:
In other languages, such as Lisp, there is such a thing as "compound data", where several variables are grouped together.

For example, if I want to represent an orbital that rotate around the player without creating a new object, I may use something like this:

(define (Orbital rx ry colour))
;; creating a new data type called "Orbital", with 3 var.s

(define ORB1 (make-Orbital 30 -20 "red"))
;; creating a particular orbital at (30, -20) with red as colour,
;; stored under the name "ORB1"

Is there a similar mechanism in Game Maker (made in Delphi) that permits such grouping of information under a structure which itself can be considered a single item, and thus such things to be stored in lists?


texts: GetCurrentAnimatorStateInfo(0) returns animation hash which is not found in list of animations

texts:
I trigger the animation "hg reload g2f" from "Any State" using a trigger.
Here is a screenshot of my animator:

I would now like to detect if the  animation is still being played.
To do that, I have tried the following approaches. None of them returned True while the animation is being played:
void LateUpdate()
{
    Debug.Log(_animator.GetCurrentAnimatorStateInfo(0).IsName("hg reload g2f") + "\n");
    Debug.Log(_animator.GetCurrentAnimatorStateInfo(0).IsName("6 Reload Pistol") + "\n");
    Debug.Log(_animator.GetCurrentAnimatorStateInfo(0).IsName("Base.hg reload g2f") + "\n");
    Debug.Log(_animator.GetCurrentAnimatorStateInfo(0).IsName("Base.6 Reload Pistol") + "\n");

I have then tried a different approach which gives me deeper insights of what is currently being played:
At void Start(), I build a dictionary of the animations in the animator like that:
private void pBuildAnimationNameTable()
{
    _NamesTable = new Dictionary<int, string>();

    foreach (AnimationClip nClip in _animator.runtimeAnimatorController.animationClips)
    {
        _NamesTable[Animator.StringToHash(nClip.name)] = nClip.name;
    }
}

And then at LateUpdate, I call the following:
public string GetCurrentAnimatorStateName()
{
    if (_animator == null)
    {
        Debug.Break();
        return "nothing assigned yet";
    }

    AnimatorStateInfo stateInfo = _animator.GetCurrentAnimatorStateInfo(0);

    string sStateName;
    if (_NamesTable.TryGetValue(stateInfo.shortNameHash, out sStateName))
    {
        return sStateName;
    }
    else
    {
        return "Unknown animator state name.";
    }
}

However, it doesn't find the current animation's hash in the list:

What might be the reason why it's not found in the list of animations?


texts: Gaps in custom body parts export for Daz Genesis 8 character

texts:
I am trying to attach a custom mesh to a Daz Genesis 8 character, and export it into Unreal Engine.
I use a custom script (namely: goldenpalace - NSFW); it exports both mesh and morphs... but it creates a small gap between the body parts. I tried different body parts, but it creates the same problem.
As far as I got, I found out if I am setting the "tools" option from "Geometry editor" to "node selection" the gap goes away, but then at the export it creates a duplicated mesh from the extra body part, and the morphs won't export at all.
How can I solve this issue?
Here are some images of the problem (not safe for work):

duplicated mesh

gap between body parts


texts:
I'm planning to write a fairly basic scrolling shoot 'em up, however, I have run into a query with regards to checking for collision.  I plan to have a fixed top down view, where the player and enemies are all 3d objects on a fixed plane, and when the enemy or player fires at the other, their shots will also be along this fixed plane.

In order to handle the collision, I have read up a bit on collision detection in 3d, as it is not something I have looked into previously, but I'm not sure what would be ideal for this situation.  My options appear to be:

Sphere collision, however, this lacks the pixel precision I would like
Detection using all vertexes and planes of each object, but this seems overly convoluted for a fixed plane of play
Rendering the play screen in black and white (where white is an object, black is empty space), once for enemies and once for the player, and checking for collisions that way (if a pixel is white on both, there is a collision)

Which of these would be the best approach, or is there another option that I am missing?

I have done this previously using 2d sprites, however I can't use the same thinking here as I don't have the image to refer to.

Edit:
For clarity, I just wanted to add some additional information.

One of the things that I would like to account for is if the player or enemy is rotated in some way, which would mean intersecting along 1 Z plane would not be completely accurate.  For example, if there is banking on the player's ship when they move from side to side, the tips of their ship would be above and below the central plane, but I would still like these parts to be possible to hit.

Secondly, I plan to have different sizes and shapes for the player's craft, where the size and shape affects the hit box and is one of the properties the player can use to choose which ship they would like to use.


texts: Can I run a script and generate warning when Unity project is saved?

texts:
Context:

I'm working with Unity using Git and we have .gitignore setup so that we could create "_local" folder anywhere in Assets and it won't be commited. It makes for kind of a Debug/Backup folder, where I can put any of textures I want to check or any script I want to test in Unity, but keep it locally.

Problem:

That unfortunately causes problems. After referencing many local files I decide to commit the project, so I make all the references pointing files that will be commited. Sometimes though I don't notice one wrong reference and I commit the project which causes errors on collaborators' devices.

Idea:

I came up with an idea that I could write a script which goes through every reference and if any of them points to a local file it should generate a warning or error. All that would happen after saving the project.

But can it be done?

Is there a way to find all the references and call the script once the project is saved?


texts: Efficient Algorithm for the boundary of a set of tiles

texts:
I have a grid of tiles of a known finite size that forms a map. Some of the tiles inside the map are put into a set known as a territory. This territory is connected, but nothing is known about its shape. Most of the time it would be a fairly regular blob, but it could be very elongated in one direction, and it could potentially even have holes. I am interested in finding the (outer) border of the territory.

That is, I want a list of all the tiles that touch one of the tiles in the territory without itself being in the territory. What is an efficient way of finding this?

For extra difficulty, it happens that my tiles are hexes, but I suspect this doesn't make too much difference, each tile is still labelled with an integer x and y coordinate and, given a tile, I can easily find its neighbors. Below are a few examples: The black is the territory, and the blue the border I want to find.

This in itself, is not a difficult problem, One simple algorithm for this, in pseudo-python, is:

def find_border_of_territory(territory):
    border = []
    for tile in territory:
        for neighbor in tile.neighbors():
            if neighbor not in territory and neighbor not in border:
                border.add(neighbor)

However this is slow and I would like something better. I have an O(n) loop over the territory, another loop (a short one, but still) over all the neighbors, and then I have to check membership over two lists, one of which is of size n. That gives an awful scaling of O(n^2). I can reduce that to O(n) by using sets instead of lists for border and territory so that membership is fast to check, but it still isn't great. I expect there to be many cases where the territory is large but the border is small due to a simple area vs line scaling. For example if the territory is a hex of radius 5, it is of size 91 but the border is only of size 36.

Can anyone propose something better?

Edit:

To answer some of the questions below. The territory can range in size, from about 20 to 100 or so. The set of tiles forming the territory is an attribute of an object, and it's this object that needs a set of all the border tiles.

Initially the territory is created as a block, and then mostly gains tiles one by one. In this case, it is true that the fastest way is just to keep a set of the border and only update it on the tile that is gained. Occasionally a big change to the territory might happen - so it will need to be recalculated fully then.

I'm now of the opinion that doing a simple border-finding algorithm is the best solution. The only additional complexity this raises is to ensure that the border is recalculated every single time it might need to be, but not more than that. I'm pretty confident that this can be done reliably in my current framework.

As for timing, in my current code I have some routines that need to check every tile of the territory . Not every turn, but on creation and occasionally afterwards. That takes over 50% of the running time of my suit of test code even though it is a very small part of the complete program. I was therefore keen to minimise any repeats. HOWEVER, the test code involves a lot more object creation than a normal running of the program (naturally), so I realise this might not be very relevant.


texts: How can I draw Polyline and detect its collision with other objects?

texts:
The idea is to draw trace of moving Actor and if some other Actor intersect it, some function would be called.

I've been searching for solution to this problem in Intersector class, but it seems to me that the only way to do what I want is to implement my polyline as a Polygon and find intersections, but its totally inelegant. I'm sure there should be some smart way to do this.


texts: Unity run-time creating material has performance impact?

texts:
Just found creating a material in a script for the first time would have performance impact.
(Using Unity 5.6.5f)

A very simple script for testing is to create a game object with MeshRenderer in Start(), assign a new material each time in Update(),

gameObj.GetComponent<MeshRenderer>().material = new Material(Shader.Find("Standard"));

From Unity Profiler the first function call took much longer than following calls, the first one took 100ms and others less then 1ms.

Can someone give it an explanation? Thanks.


texts: Stacking Drawing Matrix for SpriteBatch in XNA

texts:
I'm trying to make a 2D engine for XNA with SpriteBatch. My object unit is Entity, which can include other Entities as its children. However, when drawing them, the rotation and scaling stacking do not work well.

Here is my Entity code:

    protected virtual void PreDraw(Engine pEngine)
    {
        pEngine.PushMatrix();

        { // Transform Matrix
            // Translate
            pEngine.DrawingMatrix *= Matrix.CreateTranslation(this.X, this.Y, 0);

            { // Scale
                float translateX = this.ScaleCenterY + this.X;
                float translateY = this.ScaleCenterX + this.Y;

                pEngine.DrawingMatrix *= Matrix.CreateTranslation(-translateX, -translateY, 0);
                pEngine.DrawingMatrix *= Matrix.CreateScale(this.ScaleX, this.ScaleY, 0);
                pEngine.DrawingMatrix *= Matrix.CreateTranslation(translateX, translateY, 0);
            }

            { // Rotation
                float translateX = this.RotationCenterX + this.X;
                float translateY = this.RotationCenterY + this.Y;

                pEngine.DrawingMatrix *= Matrix.CreateTranslation(-translateX, -translateY, 0);
                pEngine.DrawingMatrix *= Matrix.CreateRotationZ(MathHelper.ToRadians(this.Rotation));
                pEngine.DrawingMatrix *= Matrix.CreateTranslation(translateX, translateY, 0);
            }
        }

    }

    protected virtual void Draw(Engine pEngine) { }

    protected virtual void PostDraw(Engine pEngine)
    {
        pEngine.PopMatrix();
    }

I will implement some primitive entities by overridding Draw method. Here is my Drawing call, and the Draw implementation for Rectangle, and the StartDrawing in the Engine:

Managed Draw call every drawing:

    public void ManagedDraw(Engine pEngine)
    {
        if (!this.Visible) return;

        { // Perform Drawing
            this.PreDraw(pEngine);

            int childIndex = 0;

            // Underlay Children
            while (childIndex < this.Children.Count && this.Children[childIndex].Z < 0)
            {
                this.Children[childIndex].ManagedDraw(pEngine);
                childIndex++;
            }

            // Draw Self
            this.Draw(pEngine);

            // Overlay Children
            for (; childIndex < this.Children.Count; childIndex++)
            {
                this.Children[childIndex].ManagedDraw(pEngine);
            }

            this.PostDraw(pEngine);
        }

    }

** Draw implementation of Rectable**:

    protected override void Draw(Engine pEngine)
    {
        pEngine.StartDrawing();
        pEngine.SpriteBatch.Draw(pEngine.RectangleTexture, new Rectangle(0, 0, (int)this.Width, (int)this.Height), new Rectangle(0, 0, 1, 1), this.Color);
        pEngine.StopDrawing();
    }

Start Drawing of Engine:

    public void StartDrawing()
    {
        this.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, null, null, this.DrawingMatrix);
    }

Here is one example of my failure, where the parent has Rotation of 30, while the children has none, but it should be in the center of the parent (red) rectangle:

Please give me the problem with above Drawing Matrix. What should I do to achieve the stacking?


texts:
I'm currently using a geometry shader to generate grass blades out of single root points that are layed out in a grid. For each root point, I generate a grass blade with, right now, a constant number of vertices.

However, for level of detail, I would like to generate a number of vertices depending on the distance to the camera. Now, since there are no dynamic arrays, I tried to declare multiple techniques which call the geometry shader with the number of vertices.

I would then be able to divide my grass into patches/smaller grids, calculate the distance to the camera for this patch and then call the technique with the appropriate number of vertices.

The HLSL part looks something like this:

[maxvertexcount(24)]
void GS_LOD1(point GEO_IN points[1], inout TriangleStream<GEO_OUT> output)
{
    GS_Shader(points, 8, output);
}

[maxvertexcount(24)]
void GS_LOD2(point GEO_IN points[1], inout TriangleStream<GEO_OUT> output)
{
    GS_Shader(points, 16, output);
}

technique LevelOfDetail1
{
    pass Pass1
    {
        VertexShader = compile vs_4_0 VS_Shader();
        GeometryShader = compile gs_4_0 GS_LOD1();
        PixelShader = compile ps_4_0 PS_Shader();
    }
}

technique LevelOfDetail2
{
    pass Pass1
    {
        VertexShader = compile vs_4_0 VS_Shader();
        GeometryShader = compile gs_4_0 GS_LOD2();
        PixelShader = compile ps_4_0 PS_Shader();
    }
}

And the definition of the GS function:

void GS_Shader(point GEO_IN points[1], in const int realVertexCount, inout TriangleStream<GEO_OUT> output)
{
  [...]
  GEO_OUT v[realVertexCount];

However, even this way the compiler complains:

  array dimensions must be literal scalar expressions

Is this possible in any way? I guess what would is just writing several geometry shaders that basically do the same thing but with a already defined number of vertices - this sounds a bit messy though.

Thanks!


texts: Where to update Player health text graphics? (C++)

texts:
I am trying to update the text rendered on the screen after the health of a player changes. The problem I am having is deciding where to update this.
The player and health graphics are separate objects.

Currently,my code is organized like this:
The main c++ has vectors:

vector< Players>
vector< Renderables>

"Renderables" is anything that can be rendered. It has a member function render() which is called for every object in the vector.  A "Text" class inherits from it. It contains the string that is displayed on screen. "Text" has its own render function, and calls its member function getString() inside its render function.

The question is where do I update this string once the player's health has changed?

My current solution is actually to have a "PlayerHealth" subclass of "Text", which holds a pointer to the player.  That way "PlayerHealth"can just redefine getString() as player->health converted to a string, and using "Text"'s render function. But I've been told this wasn't a very good method and was wondering what other approaches there were to this problem.

Thank you for your time


texts: Updating a multithreaded Entity-Component-System

texts: I am currently trying to implement an (sort-of) Entity-Component-System. I've got the gist of it, that is, how an ECS is supposed to work. So far i have 4 classes in my design (not yet fully implemented): EntityWorld is a global container for systems, entities and their respective components. It is responsible for updating systems/stepping. EntitySystem represents the base class for a system, with a virtual update-function. Entity is a container, basically with a list of components and an id, nothing more. EntityComponent represents a component. Now, i thought about making it possible to multithread my systems, but i think i've ran into a problem here. Suppose my EntityWorld stores its entities in the simplest way possible, in a std::vector<Entity*> for example. Now, that list would either be fully passed to a system when it is updated, or the EntityWorld loops through this list and sends the entities to the systems one-by-one. In my understanding though, when using multiple threads, this would require me to lock the whole list every time a system is being updated. That would practically equal zero increase in performance, since the other threads are always waiting for the list to get free. Is there a better way to implement this? So multiple threads can be updated (and r/w to entites at the same time)? Thanks in advance!


texts:
I'm using Libgdx to do some simple home projects. I'm trying to make a simple 2D game with Box2d using R.U.B.E as editor. I create a 2d terrain in R.U.B.E now I want to create the terrain texture.
I see this tool for Unity:

https://www.assetstore.unity3d.com/en/#!/content/15761

This type of tool is exactly what I need for terrains. What I want to know is not related with this specific tool, but I wan't to know if I can import Unity 2d objects generated by tools related to Unity in my Libgdx 2d games?


texts: Collision detection between triangle and polygon

texts:
I have some difficulties to understand how to be sure if there is a collision between a space ship (black) and an asteroid (in blue). A space ship is placed on a case and an asteroid comes from the right, like on the image.

Also Y1 != Y2, there are not exactly on the same line. What is the best way, in that case, to detect if there is a collision ? Is AABB collision the correct algorith I need ?


texts:
My game is fully working but now I want to make a shop so that the player can buy boosts or other useful stuff for the money the player has collected.

What is the best way of doing this kind of shops:

*The collected coins you have saved goes up/down in value when you buy something

*The item activates if bought.

Is this possible in libGDX and how can I start?


texts: Saving Very Little Data But for Lots of Objects

texts: Imagine 50 instances of one type of object and 25 instances of another. Both types of object needs to remember a simple Boolean  or int for their own purposes that can be saved to file and reloaded. For the life of me, I cannot find any help on the interwebs regarding the best way to do this. I already know and understand how to use serialization and deserialization, but I cannot figure out how to organize this. I obviously don't want 75 save files but I can't think of a good way to combine their data to one save file--especially since not everything is serializable. Any help??


texts: Setting up a low res viewport to stretch in Unity

texts:
I am working on porting a low-res game over to Unity. In my previous engine, I had the option to set a native resolution (say, 160 x 144), and it would automatically stretch when the player entered fullscreen (with options for whether you wanted to keep the same aspect ratio, or stretch).

I am having trouble figuring out how to set up something similar in Unity. I see that you can play around with resolution settings from Edit > Project Settings > Player. I tried various combinations of Default Is Fullscreen, Default Is Native Resolution, and Default Screen Width and Default Screen Height, but I haven't been able to get it to work.

When I play the scene in the editor, the viewport is still much larger than my desired resolution. And when I Maximize On Play, the FOV is even larger.

I Googled around, but couldn't find an answer that helped.

Any advice?


texts: NLua - How to implement Roblox like function security?

texts: Roblox uses Normal Identities, basicly they assign a lua block/object to a certain number. They use 2 for Scripts and LocalScripts, which can only use non-secured functions, while the command bar can access everything that is LocalUserSecurity and RobloxPlaceSecurity. How can I implement this type of Lua Security into NLua?


texts:
I've recently encountered a problem where I needed to blur an object that is inside another object. I've tried several methods to fix this but none of them works properly. In the screenshot below, renders have to happen in order so that the shape is preserved but the middle portion is blurred.

My current setup is this: 3 Cameras each rendering different objects (one object per camera), the white one below is actually a depth mask and only the camera that renders it is clearing the depth mask. The others aren't clearing anything.

When I apply a blur mask on the camera that has the middle portion (Object in the blurmask layer), everything else gets blurred too (there's a background off screen which shouldn't get blurred, that's the reason for Vuforia tag). How do I solve this? Frankly, I'm absolutely stumped at this point and willing to try anything (comments are welcome too).

This is what I have right now (The longer cylinder had a depth-shader in its material which clears any 3D object parts behind it):


texts: How do I convert between two different 2D coordinate systems?

texts:
I'm trying to convert a coordinate from one coordinate system to another, so that I can draw it on an image.

Basically the destination coordinate system is as follows:

X range: 0 to 1066
Y range: 0 to 1600

(just a standard image I'm drawing onto with the size of 1066 x 1600)

The position I'm trying to draw onto the image actually has the exact same size, but the coordinate system is different.  The span all of the coordinates is 1066x1600.

But a coordinate example would be:

(111.33f, 1408.41f)
(-212.87f, 1225.16f)

The range of this coordinate system is:

X range: -533.333 to 533.333
Y range: 533.333 to 2133.333

I feel like this is VERY simple math, but for some reason I'm not getting it.

How can I convert the coordinates provided into the first coordinate system?


texts: How do I create a blob shadow under a character?

texts:
I have a webgl based 2.5D platformer game, and I would like to add a simple blob shadow under the character to help the player with the platforming.

How is this normally done?
As you can see below, I do not need to worry about sloped terrain if that matters.


texts:
I'm trying to implement a free-look third person camera (using glm). I know that the general transformation is

newCameraPosition = translate(lookatPoint) * rotation(angle,axis) * translate(-lookatPoint);

So I need to find the axis to rotate around, with the constraint that I give the algorithm an axis in camera space to rotate around. Sounds confusing.

For example, let's take a camera that points up (0,1,0), is positioned in the XY plane at (-1,0,0) and is looking at the origin (0,0,0). So it is looking "along the x-axis".

Now I want to rotate the camera around the "camera-space-x-axis" (1,0,0). In words: The axis that "points to the right" when looking through the camera. Simply rotating around (1,0,0) doesn't work, since it will rotate the camera around the world-space x-axis. From the point of the camera however, the x-axis is in fact the z-axis in world space (0,0,1);

How do I go from the given camera-space axis to the world-space axis? I've tried just applying the inverse transform of the current camera transform to the given camera-space axis using

glm::vec3 rotateAxis = swizzle<X,Y,Z>(glm::inverse(GetCameraTransform()) * cameraSpaceAxis);

where cameraSpaceAxis.w = 0;

but that produces wrong results, e.g. if I give the algorithm the axis (1,0,0) to rotate around, continuously rotation around it in 1 degree steps just creates a wobbly circular motion around y and x axis;


texts: Picking a specific point of a map in Direct 3D

texts:
I'm trying to pick a specific point on a randomly generated terrain with bunch of tiny triangles. Right now, I'm just iterating through every triangle and picking a intersected triangle using D3DXIntersect function. It serves its function but the performance is just not tolerable.

Is there a way to pick a triangle without millions of iteration?


texts:
In my game, I have an inventory system with slots and images in those slots. The images are by default disabled, but when an item is added to the slot, the image component becomes enabled. I have implemented a very simple drag and drop system for moving objects around in the inventory using IBeginDragHandler, IDragHandler, and IEndDragHandler. As I am dragging an item from one slot to another, I want the item image to be rendered in front of the slots and the rest of the inventory. Currently, when dragging an item image, it renders behind the empty slots.

I don't want to use hierarchy order to organize the layers of these slots because moving items around is very dynamic and the hierarchy order of the slots changes seemingly randomly when I press play. Is there another way to ensure that the item image being dragged is "closer to the camera" or in front of the rest of the inventory? Thanks.


texts: Interpolation on Rigidbody2D not working

texts:
I'm trying to achieve smooth movement for a ball. I seem to be failing to achieve this and now I've created a sample scene, which shows my setup from the game and the problem exists in that sample scene, as well.
I've uploaded the sample project to github: https://github.com/iQew/PhysicsTesting (open Assets/Scenes/SampleScene)
Here's a recording of the problem. It's a bit more extreme here than it is in the editor, but it shows the problem even better because of it: https://imgur.com/a/ByzwKlg
Scenario:
I have a 2D mobile game (android) using Unity 2019.4.14f1 with URP. The camera does not move and will always have the same settings. The playfield consists of a certain area, which is blocked in by walls, which have a BoxCollider2D on them. The ball is a simple sprite with a CircleCollider2D, RigidBody2D and a Trail Renderer.
I have deleted all quality settings except the "Low" one, which has VSync Count set to "Don't Sync". In the Awake block of a controller script I set the Application.targetFrameRate to 60. In the Start block I use BallRigidBody2D.AddForce(new Vector2(1f, 10f), ForceMode2D.Impulse) to make the ball move.
The RigidBody2D of the Ball has the following settings:

Body Type: Dynamic
Material: DefaultBall (a Physics2D material with friction: 0 | bounciness: 1)
Simulated: true
Use Auto Mass: false
Mass: 0.025f
Linear Drag: 0
Angular Drag: 0
Gravity Scale: 0
Collision Detection: Continous
Sleeping Mode: Start Awake
Interpolate: Interpolate

All other project settings are at default.
When I launch the game, the ball starts moving as expected. Most of the time the movement is smooth, but there is stuttering every now and then. I am wondering, if there is a way to make this stuttering go away. The tutorials I found on the internet, which solve this exact problem set the Interpolation mode of the RigidBody2D to "Interpolate", but I did that and there's no change.
There are no other scripts interfering with the physics calculation at all. So, I assume this has to do with some kind of project settings? Using a smaller Fixed Timestep does not help, in fact it gets a lot worse, if I use 1/120 for example.
Any help would be greatly appreciated!


texts: Platforms for sharing content and expertise

texts:
Are there any platforms / sites where people can share expertise in game development and where you can share (either payed or free) digital content (like images, sounds, animations but also frameworks or libraries) to be used in games?
I'd also like the possibility to contact users and request specific pieces of content.

I'd like to start out as an indie developer and have programming skills but I lack the experience and time to create ingame artwork and sound.
Is there any site where I could locate other people (artists mostly) who would want to work on a game for free?

I know I can get most technical questions answered on this site and I have some contacts but I'm affraid this won't be enough.


texts: How can I track how "well-lit" a player is so that I can determine if my AI can see him or her?

texts:
I want to see how well-lit the player character is in an environment so that my AI can react (or not) to the player when he or she is visible.

Currently I am doing this by reading back the color data of the final render target and computing the brightness of the player's region. It seems expensive and taxing, so I was wondering if there is a better way to approach this?


texts: How do I permanently set the interpolation for every image, sprite, and texture in pyglet to GL_NEAREST in pyglet?

texts:
There are plenty of examples of posts that describe how to set the default interpolation of specific images to GL_NEAREST, for example here, but they all have to be run after the image texture is defined.

My question is simply this: is there any way to set the default interpolation of every image, including ones that have not been created yet, to GL_NEAREST in a single statement? I will never use any other scaling method as I am making a pixel-based game, and I do not want to have to set the interpolation every time on_draw() is run. If there is no answer, then please say so.


texts: How do I determine which card is underneath the currently-dragged card in a card game?

texts:
I'm developing a card game. My custom control works great, but I need help to solve this:

When I move a card (my custom control) over another card I need to know which card is underneath. Once I know that, I'll be able to put in logic for game rules.

EDIT

I'd like to have some event in cardcontrol like: OnOtherCardControlOver() but I have some difficulty to figure it out.


texts: Do I have to re-assign localized text every time the game loads?

texts:
I am trying to build a localization system for games. And I have stumbled upon a problem where in Unity you basically have to change all the text in Text components / any other references like audio - when loading a game every time.

To better explain it - if the default language is English and user decided to change language to any other. Even if you localize all the files used in the game via code, later on you will have to do it again, when user loads the game after quiting it. Because components don't persist data changed via code in run-time.

How do I make it so that user would be able to change the language once, and all of those references and text... would persist and didn't require re-set up every time the game is loaded? Is that even possible in Unity?

Or should I just localize after the game has been made. And just allow people to download different language versions. But then again, it makes it difficult for people who want to change their language.


texts: Building Irregular terrain in tile-based approach

texts:
I'm starting to build a 2D game, metroidvania-like, tile-based and all. I've had some prior experience in it, and one of the major letdowns of those prior games was that worlds seemed too "blockish", kinda inorganic, when they shouldn't (underground caverns aren't squarish at all). So, for this time, I'm trying to come up with a way to build a world just like Cave Story's:

It has some nice angles and feels way better than a purely tiled world.

As far as I know, SP built this world using AS2 back in 2002, when computers hadn't all the processing power they have today, so I think he haven't used any kind of heavy mask to do it. Talking with one of my teachers, he suggested the guy used raycasts to search for non-transparent pixels in rectangular tiles. Dunno if it's true, but I decided to get further help through here. I'd like some suggestions for a nice and soft approach to this kind of work, if possible.


texts: Make the components of an ECS polymorphic

texts:
I have implemented an entity component sytsem (ECS) in my game engine (SFML and C++ 17). An entity has an array of components. You can get a components by its type e.g.: myEntity.GetComponent<RenderComponent>(). So far so good.

The problem

Best to illustrate this point by an (admittedly oversimplified) example:

Some systems or possibly other components might want to be able to call myEntity.GetComponent<RenderComponent>() without knowing the type of that render component (e.g. whether it is a house render component with a sprite and a paritcle system for smoke or a character) but knowing that every render component has e.g. a GetPixelMask() method.

A more concrete case of this is the collision component that might be implemented as a collision box or a pixel mask that may come from any type of render component. However, every collision component would have a method bool Contains(Position). I would like to be able to loop through all entities with a collition component and check whether e.g. the mouse click lies within them.

I want a clean solution. It must not use polymorphism, it should solve the problem in a neat way.

Possible Solutions

This is bad code smell to me but still its a solution. Screw polymorphic behaivour and just add an if cause to the systems. Something like If(myEntity.HasComponent<HouseRenderComponent>()) { /*Call method a*/ } and If(myEntity.HasComponent<CharacterRenderComponent>()) { /*Also call method a*/ }
Another solution would be to make it so that the component are 'configured'. This is my current solution which kinda works but isn't all to clean (I find). This would mean making some RenderObject base class and letting the RenderComponent manage a dictionary of RenderObject pointers. RenderObjects would have to be added through a method like AddRenderObject() and accessed through an id which isn't all too efficient (Not my biggest concirn here). However, every RenderComponent would have the same methods and the specific type of the RenderComponent would be defined through the RenderObjects added.

Question

I'm pretty sure that adding some kind of real polymorphism to the components would be possible and I could figure out how to do it. The question is: is that good design? - as for me it kind of defeats the point of the ECS. I'd be grateful if you could share your experiences and how you have dealt with this. I can't be the first one to have come across this problem!

Thanks for your help!


texts: How do I read the an environment map CPU side? (Similar to texCube function on GPU)

texts:
I need to extract the one pixel from a environment mapping (I already have the 6 textures) using the normal vector. How can I achieve this ?

I want something very similar to what texCUBE(link) does in GPU but in CPU.

I am using XNA and C#, but an example in any language may help.


texts:
I want to change the size X of my 'Horizontal Box' widget's through blueprints but cannot figure out how to do that... the properties that I want to be able to control from blueprints are marked red below:

To give you some context, I need this to instantiate my widget dynamically. I first add a bunch of child widgets which works just great, but I also need to kinda resize the quad in the background to fit in size the child widgets that I am 'spawning'. Isn't there really any way to do this? Because this seems a super-basic thing to do as from my point of view but can't find it anywhere...


texts: What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?

texts:
I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library.

To project a single vector (X,Y,Z) on the screen, the code first applies the View matrix of the camera and then for the actual projection does the following:

ScreenX=X/Z;
ScreenY=Y/Z;

ScreenX and ScreenY are then used as the screen coordinates (after additional scaling and translation).

What kind of projection is this?

Since it uses the Z coordinate to adjust the X and Y coordinates, I would think it is a perspective projection, but I'm not sure. If it's indeed a perspectice projection, then what would be the FOV for this?

I'm just trying to understand how the existing code works so that I can rebuild it using standard libraries and using a standard projection matrix if possible.

Any idea?

Edit - Some more information:

After this division, the coordinates are multiplied (scaled) by the "lens resolution" (pixels per unit) and translated by the lens center (X,Y coordinates in pixels):

ScreenX = ScreenX * Res + CenterX;
ScreenY = ScreenY * Res + CenterY;

Res is a large number and I'm guessing it defines the projection plane, letting the coordinates scale from 0 to the size of the actual image in pixels.


texts: Is there any advantage in using  DX10/11 for a 2D game?

texts:
I'm not entirely familiar with the feature set introduced by DX10/11 class hardware. I'm vaguely familiar with the new stages added to the programmable graphics pipeline, such as the geometry shader, the compute shader, and the new tessellation stages. I don't see how any of these make much of a difference for a 2D game though.

Is there any compelling reason to make the switch to DX10/11 (or the OpenGL equivalents) for a 2D game, or would it be wiser to stick with DX9 considering that that a significant share of the market still runs on older technologies (e.g. the February 2012 Steam surveys lists around 17% of users as still using Windows XP)?


texts: How can I make an infinite cave using stage3d?

texts:
I want to make an infinite cave in my 3d game using flash stage3d. But I got no idea about how to build that cave. Can anyone can give me some solution or hint?
update:
I've tried agal fragment shader like squeae tunnel in shadertoy

code:

var fragmentProgramCode:String =
                AGALUtils.build()
                .mov("ft0","v0")
                .div("ft1","ft0.xy","fc3.xy")
                .mul("ft2","fc6.x","ft1")
                .sub("ft3","ft2","fc5.x")//vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
                .mul("ft1","ft3.x","ft3.x")
                .mul("ft2","ft3.y","ft3.y")
                .pow("ft4","ft1","fc6.z")//float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 );
                .pow("ft5","ft2","fc6.z")
                .add("ft1","ft4","ft5")
                .pow("ft4","ft1","fc6.w")
                .mov("ft5","fc5")//uv
                .sub("ft1","fc7.x","ft4")
                .add("ft5.x","fc7.x","ft1")//uv.x = .5*time + 0.5/r;
                .mov("ft6","fc0")//for atan
                .atan2("ft5.y","ft3.y","ft3.x",new <String>["fc7.y","fc5.x","fc7.z","fc7.w","fc8.x","fc8.y","fc8.z","fc8.w","fc9.x","fc9.y"],"ft6")
                .tex("ft0","ft5","fs0","repeat","linear","nomip")//tex
                .mul("ft1","ft4","ft4")
                .mul("ft2","ft1","ft4")//r*r*r
                .mul("ft1","ft0.xyz","ft2")
                .mov("ft0.w","fc5.x")
                .mov("oc","ft1").toString()

it can only apply one material,but my project requires different types of material (like floor,ceilling).
so ,I create a 3d model
Is there anyway to make that 3d model render like "infinity cave"? use agal to make each side of cave's texture move?
thanks for your help

update again:

I tried glsl to make a cube,when using color It looks good,but when I don't know how to apply texture's transform. It's really hard for me to accomplish this,haven't 3d experience before,thanks for your time !

#ifdef GL_ES
precision highp float;
#endif

uniform vec2 resolution;
uniform float time;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;

vec4 p1 = vec4(0.0, 1.0, 0.0, 1.3);//down
vec4 p2 = vec4(0.0, - 1.0, 0.0, 1.3);//up
vec4 p3 = vec4(1.0, 0.0, 0.0, 1.3);//left
vec4 p4 = vec4(-1.0, 0.0, 0.0, 1.3);//right
vec4 p5 = vec4(0.0, 0.0, 1.0, 1.3);//center

void main(){
 vec2 uv = -1.0 + 2.0*gl_FragCoord.xy/resolution.xy;
 uv.x *= resolution.x/resolution.y;
 vec3 o = vec3(0.0, 0.0, 2.3);
 vec3 rd = normalize(vec3(uv, -1.0));
 vec3 lp = vec3(sin(time), sin(time), cos(time));
 float li = 2.0;
 vec3 co;

 float tm = 10000.0;
 float t=- (dot(p1.xyz, o)+p1.w)/dot(p1.xyz,rd);
 if(t>0.0&&t<tm){
   co =vec3(.2);//down
   tm=t;
 }
 t=- (dot(p2.xyz, o)+p2.w)/dot(p2.xyz,rd);
 if (t>0.0&&t<tm){
   co =vec3(.3);//top
   tm = t;
 }
 t=- (dot(p3.xyz, o)+p3.w)/dot(p3.xyz,rd);
 if (t>0.0&&t<tm){
    co =vec3(.4);//left
    tm = t;
 }
 t=- (dot(p4.xyz, o)+p4.w)/dot(p4.xyz,rd);
 if (t>0.0&&t<tm){
    co =vec3(.5);//right

    tm = t;
 }
 t=- (dot(p5.xyz, o)+p5.w)/dot(p5.xyz,rd);
 if (t>0.0&&t<tm){
     co =vec3(.6); //center
     tm=t;
 }
 gl_FragColor = vec4(co, 1.0);
}


texts:
I'm trying to load a date in the form of a string. As there is always 4 possible date formats (x.x.xxxx, x.xx.xxxx, xx.x.xxxx, xx.xx.xxxx (day month year)) I had to take this into account and it is especially hard with the strings length of 8 as it is either xx.x or x.xx.

So I came up with this:

public void setDate(String CompleteDate, boolean loadOrNew){
  Date = CompleteDate;
  if(loadOrNew){
    int totalLength = Date.length();
    String sday = null;
    String smonth = null;
    String syear = null;
    if(totalLength == 9){
      sday = String.valueOf(Date.toCharArray(), 0, 2);
      smonth = String.valueOf(Date.toCharArray(), 3, 2);
      syear = String.valueOf(Date.toCharArray(), 6, 4);
    }else if(totalLength == 8){
      sday = String.valueOf(Date.toCharArray(), 0, 2);
      if(sday.contains(".")){
        smonth = String.valueOf(Date.toCharArray(), 2, 2);
      }else{
        smonth = String.valueOf(Date.toCharArray(),3, 1);
      }
      syear = String.valueOf(Date.toCharArray(), 5, 3);
    }else if(totalLength == 7){
      sday = String.valueOf(Date.toCharArray(), 0, 1);
      smonth = String.valueOf(Date.toCharArray(), 2, 1);
      syear = String.valueOf(Date.toCharArray(), 4, 4);
    }else{
      Toast.makeText(c, "Critical date format error occurred. Error G205", Toast.LENGTH_LONG).show();
    }
    sday.replace(".", "");
    smonth.replace(".", "");
    syear.replace(".", "");
    this.day = Integer.parseInt(sday);
    this.year = Integer.parseInt(syear);
    this.month = Integer.parseInt(smonth);
  }
  date.setText("Date: " + CompleteDate);
}

However it isn't correct as I get NumberFormatException with "1."

This means I somewhere messed up and the removing of the "." doesn't work. So I need help improving this so it works.

NOTE:

Some of this is android-specific, e.g. the Toast class and TextView class, but everything else is in standard Java.

date and Date isn't the same. Date is the String, date is the TextView(android).


texts: How can I achieve UnrealEd's per-face texturing in Blender 2.6?

texts:
Using UnrealEd I can create geometry and assign a material to each face of that geometry. Each face can have its own UV settings. How can I achieve the same functionality using Blender?

I've seen the "Texture Face" option mentioned but that seems to be gone in Blender 2.59+?


texts: How to render sprites without using SpriteRenderers

texts:
I'm creating a component that lets you write text, like the UI Text component, but using sprites as letters.

I already have the mapping for characters->sprites, and now was going to draw the text using the sprites.

My first idea, was to just create one children for each letter, each child having a sprite renderer.

But it feels like a pretty poor approach, since a transform and a sprite renderer component have to created or destroyed, when the text changes size.

Then I thought about using a Mesh renderer and mesh filter, and define the mesh when the text changes, creating a quad for each letter. But what I don't like about this idea is having 2 extra components in my gameObject, as I would like to keep it as clean as possible.

Is there a way to achieve this keeping all the necessary components inside my own class? Defining my own quads, UVs and such is just fine, but I just don't know how to render them through script. Is it even possible without adding more components to the gameObject?

Don't know if its relevant, but I want to use World Coordinates, not screen coordinates.


texts: What I need to do to integrate in game micro payments for virtual goods in desktop games?

texts:
Does anyone here have experience in implementing in game payments , does such thing is possible ?
Where should I look in to?


texts: How can I make the overlapping object's outlines merge and not display on top of other objects that have the outline shader?

texts:
This is what I am trying to achieve. I was following https://www.youtube.com/watch?v=SlTkBe4YNbo but the outlines show on top of other if the objects overlap. I tried looking through various outline shaders but couldn't find much. I found that it has something to do with Z-Depth but I am not sure how.
My reason for doing this was to replicate the Unity Editor's object selection in the project. I somehow got the gizmo partially working(using a 2nd camera) and am now stuck on object highlighting on selection.


texts:
In my game I am trying to see all touching actors of a particular DynamicSMActor and it does return only two Actors as touching Actors - Water Volume and Player Pawn. It is ignoring all the other DynamicSMActors that are touching. I actually tried different values for collision type, Blocking type, etc,. No success.

Any help is really appreciated.


texts:
I was listening to some of Neo Geo game music on Youtube the other day and it made me think about creating new music in this style.

If I wanted to make a retro-style game today, how would I compose/sequence new music to make it sound like a Neo Geo game?


texts:
I am trying put a seek feature in my code.

Just frame code, not actual code.

 Seek(TargetPos)
{
  Vector2D DesiredVelocity = Normalize(TargetPos - currentPos)*MaxSpeed();

  return (DesiredVelocity - currentVelocity}

Simply when I press 2, it will change the target, 3 will change the target and so on...

Do I need to make the currentVelocity the old Desired velocity?


texts: player goes off screen as the camera smooth follow interpolation

texts:
Sometimes player goes off screen as the camera lags behind it, especially when the player is falling. Also when the player is climbing walls by jumping left and right, the camera moves left and right, as I want it to stay still.
I am assuming this is a problem with the camera speed not matching the physics speed of the player, I don't know how to match those two.
This is my code:
let camera = Camera()
let player = Player()

let followFrame = Rectangle(0, 0, viewWidth, viewHeight);

let followTarget = Point(player.x, player.y);

function update = () => {

  if (!followFrame.containsPoint(player.x, player.y)) {

     followFrame.position = [player.x - followFrame.width * 0.5,
         player.y - followFrame.height * 0.5];

     followTarget.position = [followFrame.x, followFrame.y];
  }

  camera.position = interpolate(camera.position, followTarget)

};

I have to account for player to take long distance jumps and falls.