texts: What do potential employers look for in a good portfolio?

texts:
A buddy from work and myself are wanting to get into the indie scene for game development. I've done a few tech demos demonstrating different ideas and approaches for various problems. Now, I feel it's time for us to commit to a project in order to develop a portfolio for later down the road.

I've been struggling greatly with how to begin an actual project, more specifically to create an engine or use an OTS package, or use one then create one, or create one then use one.. etc.

Which looks better to potential employers? A smaller portfolio of games that includes your engine or a (possibly) larger one that was built using something OTS?

I am a programmer. I'm not an artist. I will be performing most of the programming for this project. My buddy is also a developer, but he is also proficient with graphical tools (thus, he becomes the art guy).

At work, we are both .NET developers (C#). I know, I know "Well then use XNA" some will yell at me. The demos I've completed thus far have been in XNA. But I have some concerns with building an XNA portfolio. While it is nice to abstract DirectX, I worry that I may not build the necessary knowledge base to extend beyond XNA easily. The counter to that argument is probably "you can more easily move on to DirectX after XNA", but since I will   move careers from Business Development to Game Development, is it even worth while to focus on XNA currently? Or will potential employers giggle when I say XNA?

Should I embrace the experience of XNA knowing the concepts and lessons learned will mostly transfer? Or spend my most valuable resource (time) else where?

Looking for some advice from any industry vets out there.


texts: Texture the quad with different parts of texture

texts:
I have a 2D quad. Let say it's position is (5,10) and size is (7,11).

I want to texture it with one texture, but using three different parts of it.
I want to texture the part of quad from x = 5 to x = 7 with part of texture from U = 0 to U = 0.5 (replaying it after achieving 0.5, so I will have 4 same 0.5-lenght fragments).
The second one with some other part of texture (also repeating it) and third in the same style.

But, how to achieve it?

I know that:

float2 tc = fmod(input.TexCoord, textureCoordinates.zw - textureCoordinates.xy) + textureCoordinates.xy; //textureCoordinates.xy = fragments' offset

Will give me the texture part replaying.


texts: How to incorporate (agile) user stories with specs into game development?

texts:
It seems some features/changes lend themselves to user stories: "as a user, I want to be prompted to exit or retry the battle after the hero dies, since these are the only two common navigations". But other features wouldn't be a good fit for stories, like a detailed description of which game elements appear during an event.

How are these detailed specs incorporated into the agile task system? Certainly the umbrella task could be written as an epic, but the specs seem not to fit as stories. (They are not about direct user motivation or benefit, because these specs often make the game harder, like "boss health should refill at 100% per 90 seconds".)

Note: we're using Jira to track bugs and tasks.


texts: How AI is balanced across different type of races in RTS games?

texts:
There are some real-time strategy games (like StarCraft 1 or 2) where AI needs to be balanced across different type of races (in SC it's Protoss, Terran, Zerg), so despite they've different type of troops to play, no specific type of opponent have any advantage. Not to mention that they need to consider different type of maps, so in overall each AI playing different race have the same changes of win.

How in general this balance can be achieved by gaming companies? Is it just by playing massive amount of games headlessly with different setups?

This study and this one plus this dataset may help answering it, but it could be not related.


texts: How to create fun and interactive menus with cocos2d?

texts:
Possible Duplicate:
  How to make animated buttons in a menu with Cocos2d?

How do I make fun and interactive menus with cocos2d, all the tutorials are just for simple clickable menus. Can any one help me learn this?

It would be see the menu flip or slide away, I know you can do this with scenes but how do I make this with just the menu?

Let's say the menu is a bunch of cards and I want them to flip over like the sub-menu is on the backside of the card, how would I do this?

Or, make the Main menu slide in from the left, right, top or bottom side and then when a button is selected it slides away the same way and switch to a sub-menu (settings, Score etc)?

Anyone?

David


texts: How can I implement slow motion for one player in multiplayer?

texts:
Special attacks in Mortal Kombat Mobile require slow motion i.e. delay in game play.

On multiplayer mode, when the opponent uses special attacks, I don't observe any lag/delay.

When I use special attack, the game goes in slow motion mode for me, however I guess my opponent doesn't experience any delay.

How is this possible? How can I implement something like this? Can my multiplayer mode still be real-time when using a feature like this?


texts: D3DX11SaveTextureToFile with shared resources

texts:
I'm using shared resources to send textures from one D3D11 device to another, so that I can copy the back buffer over the second device and use the second device context to save that texture to a file. This seems to be working, but when I save the texture, it saves an empty PNG.
I tried saving the texture with the primary device context and it works, except if I use the D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX MiscFlag, which I need in order to share the resources.
Is there any reason D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX prevents a texture from being saved ? Or am I maybe missing something out in order for it to work ?

Here is the code I'm using:

D3D11_TEXTURE2D_DESC td;
backBuffer->GetDesc(&td);
td.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
this->_device->CreateTexture2D(&td, 0, &g_tex);
this->_context->CopyResource(g_tex, backBuffer);

// saves a blank image if using D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX
D3DX11SaveTextureToFile(this->_context, g_tex, D3DX11_IFF_JPG, "test.jpg");

g_tex->QueryInterface(__uuidof(IDXGIResource), reinterpret_cast<void **>(&g_dxgiResource));
g_dxgiResource->GetSharedHandle(&g_shaderHandle);
g_dxgiResource->Release();
g_tex->QueryInterface(__uuidof(IDXGIKeyedMutex), reinterpret_cast<void **>(&g_dxgiMutex));

And this is the code used to save the shared textue in the second device

ID3D11Texture2D *texture = 0;
IDXGIKeyedMutex *keyedMutex = 0;
device2->OpenSharedResource(g_shaderHandle, __uuidof(ID3D11Texture2D), reinterpret_cast<void **>(&texture));
texture->QueryInterface(__uuidof(IDXGIKeyedMutex), reinterpret_cast<void **>(&keyedMutex));
UINT acqKey = 0;
UINT relKey = 1;
DWORD timeout = 16;
DWORD res = keyedMutex->AcquireSync(acqKey, timeout);
if (res == WAIT_OBJECT_0 && texture)
{
    // saves a blank image too
    D3DX10SaveTextureToFile(texture, D3DX10_IFF_JPG, "test2.jpg");
}
keyedMutex->ReleaseSync(relKey);

Edit:
Also, the code that is supposed to save the shared texture to the filesystem is running in it's own thread.


texts: How is the environment moved in endless runner games like Tiny Wings

texts:
I've always wondered how the background scene is scrolled endlessly as the main player is moving (usually to the right). With Tiny Wings I suspect that it's somehow drawn dynamically because when investigated a little deeper, one can see that the hills can easily be drawn. All in all it's just some parabola shaped curves, some texture and mini sprites on them. In Cocos2D the hills themselves could be drawn by a very convenient class called CCRenderTexture. Of course this will involve some maths too, but that shouldn't be a problem. But how about a scene that I want to be composed of images but not easily drawable shapes?

Is this even done in practice?
Is it possible to dynamically customize the same images so that they look a bit different the next time they appear on the screen again?
How is smooth transition achieved between different images?
And finally how are the images swapped one after another?

For this game I'm going to be using Cocos2D V3.


texts:
I want to trigger behavior based on certain conditions. I currently just have a sequence that runs different behavior, it triggers on condition but always in sequence. When the first condition is met it runs that.
Let's say I have 2 behaviors. Flee from threat and find food if hungry. Usually the flee from stronger threat prevails and thus is placed early in the sequence. But what if the entity running the behavior is starving, it can take more risk. Since the flee from threat comes first in sequence and triggers on a threat it will never pick to gather food if there is a threat present. I guess I need something like a scoring system and let the tree pick the best option. Is this common in behavior trees? How is it called or best implemented?
I'm using gdx.ai in particular and perhaps there is something out of the box I can use. I can make a task in the behavior tree that weighs all the possible actions but this ties everything together and bt's are widely used for the opposite.


texts:
I decided to write my first Quake source port, but I'm a bit confused.

There are 2 rasterization code files: d_draw.s and d_draw16.s.

The first is, as John Carmack said, horizontal 8-bpp span-drawing code. The second is the same, but with 16-pixel subdivision.

Which is more preferable for full-color 320x200 source port?

Do they both feature non-power-of-2 texture distortion?

GL code is not an option, because the target system doesn't feature 3D API.


texts:
I have a sliding animation on this penguin model which moves the penguin from a standing position to a belly position. During this animation, I've noticed that the object transform origin stays locked relative to the animation, using the encoded origin from blender.  In my case this is an undesired pivot point and is often buried beneath other game objects I may want to raycast against.

Ideally, I am hoping to have the origin centered in the model with respect to the XZ plane throughout the animation. Toggling the handle position tool to "Center" in the editor gives me an origin that is closer to what I would like, however I understand this is just a feature of the editor and does not reflect the true object transform.
My question for everyone is:
What are some ways I can achieve a transform that follows the body of my animation?
I have parenting an empty game object, but this transform still would not follow the body animation.
For raycasting below the body specifically, I am considering following the transform of my armature's spine which does follow the animation. Would this be a valid approach?
Any help is much appreciated!


texts: How can I make a shader that will make a cube or any object invisible?

texts:
I'm trying to create a shader that will make the object invisible and then with a script a fade in/out effect between invisible and visible.

What I tried:

Shader "InsideVisible" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Color ("Color (RGBA)", Color) = (1, 1, 1, 1) // add _Color property
    }

    SubShader {
        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha
        Cull front    // ADDED BY BERNIE, TO FLIP THE SURFACES
        LOD 100

        Pass {
            CGPROGRAM

                #pragma vertex vert alpha
                #pragma fragment frag alpha

                #include "UnityCG.cginc"

                struct appdata_t {
                    float4 vertex : POSITION;
                    float2 texcoord : TEXCOORD0;
                };

                struct v2f {
                    float4 vertex : SV_POSITION;
                    half2 texcoord : TEXCOORD0;
                };

                sampler2D _MainTex;
                float4 _MainTex_ST;
                float4 _Color;

                v2f vert (appdata_t v)
                {
                    v2f o;
                    o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                    // ADDED BY BERNIE:
                    v.texcoord.x = 1 - v.texcoord.x;
                    o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                    return o;
                }

                fixed4 frag (v2f i) : SV_Target
                {
                    fixed4 col = tex2D(_MainTex, i.texcoord) * _Color; // multiply by _Color
                    return col;
                }
            ENDCG
        }
    }
}

I added this shader to my cube's material But it's not invisible at all not even close.

Sorry for the confusion.

The shader that I need is not to be based on distance from the camera but to be based on fade in/out effect so it will change between visible/invisible slowly depending on speed value.

Update:

This script seems to be working on Standard shader but for some reason it's not fading smooth it's fading  a bit each time but not smooth flow. Why is that ?

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

public class InsideVisible : MonoBehaviour
{
    private void Start()
    {
        Coroutine _currentFade = StartCoroutine(FadeTo(0f, 10.0f));
    }

    IEnumerator FadeTo(float aValue, float aTime)
    {
        float alpha = transform.GetComponent<Renderer>().material.color.a;
        for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
        {
            Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, aValue, t));
            transform.GetComponent<Renderer>().material.color = newColor;
            yield return null;
        }
    }
}


texts: How would a server handle sending entity updates to clients?

texts:
Lately I've been looking into networking and sockets and made small test programs to get the basics down. So far I've made a TCP turn-based game from where I learnt a lot and helped me getting some fundamentals down.

Recently I also got a basic game working where multiple clients can connect and see each other move, but I feel like the architecture is not the best though.
This made me want to expand the game a little and build a more solid foundation but I've been struggling to find the answers on a few questions I have.

The approach I've had for 2D action games(which is my goal to make) is to have a dedicated server, a separate project written purely in java(I use LibGDX for clients) and in the server project I have a Client class which has a x, y, and an id. Then when a client connects to the server it creates a new Client object, gives it an ID based on the amount of clients connected and puts it in an ArrayList called players.

Then for movement I have the Game client send a message when it moves, structured like id,x,y;. The servers Client object receives the message and tells the server to broadcast() it to all the other clients which in turn receives a position message. The Game clients get a message, structured as above, and the Game client updates his own playerList.

This feels really clumsy and not well structured at all and this leads to my next question, what data should the server have?

Let's say we have a 2-player game where the players cooperate to kill mobs and receive items and exp. How would the server keep track of the mob entities? Would i create an identical Entity class from the Game Client and put in the Server project with everything but the render / graphical stuff? And collision with projectiles and stuff, do I collision check in the Game Client and then validate in the server?

All this feels very overwhelming and I would love if someone could give me some advice or point me to any forum posts they've read. I've searched around the forum but haven't managed to find anything that really answers this structuring part.

Thanks in advance, feel free to ask me anything!


texts:
Problem

I have a crosshair in the middle of the screen.

I need to create a lineTrace that passes straight through this crosshair.

As this is a third person game, I need the line trace to cast through the crosshair

Question

How do I do this

Code sample

    #include "GameFramework/PlayerController.h"
    #include "Engine/World.h"
    #include "DrawDebugHelpers.h"
    #include "Camera/PlayerCameraManager.h"
    #include "GrabObjects.h"
    #include "CollisionQueryParams.h"

    #define OUT

    //...

    // Called every frame
    void UGrabObjects::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
    {
        //...

        FVector PlayerViewPointLocation;
        FRotator PlayerViewPointRotation;

        // Get player viewport
        GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
            OUT PlayerViewPointLocation,
            OUT PlayerViewPointRotation
            );

        // Draw a line from player showing reach
        // PlayerViewPointRotation.Vector() is the unit vector
        FVector LineTraceEnd = PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;

        DrawDebugLine(
            GetWorld(),
            PlayerViewPointLocation,
            LineTraceEnd,
            FColor(0, 255, 0),
            0.f,
            0,
            5.f
        );

        //...
    }

```


texts: In FPS's what is the primary reason for unused ammo in a removed magazine returning to the ammo pool?

texts:
All FPS's I know of return unused ammo in a removed magazine back to the users overall ammo count.

For example, I have 3 magazines with 30 rounds in each, I fire off 25 rounds and do a magazine change. I do this another 2 times so i technically have 3 magazines with 5 rounds in each, but when i reload I have a magazine with 15 rounds, somehow they have all jumped into the one magazine.

Yes, I am overthinking it and it probably wouldn't be fun. I'm just trying to narrow down the reasoning, especially games like modern warfare 2 which in terms of weapons are pretty much accurate in every other regard.


texts:
Noob here,

I am trying to display a list of a vector with ascending numbers. To display the list I iterate through the following code.

cout << "\nYour games list is: \n";
        for (iter = gameTitle.begin(); iter != gameTitle.end(); ++iter)
        {
            cout << listNum << ".- " << *iter << endl;
        }

So listNum is an integer that I initialized as "0" but this particular setup will give me a list with three elements as follows.
3.- userInput
3.- userInput
3.- userInput

"userInput" is a vector of string type that is declared yet not initialized.

¿How do I get a list like follows?
1.- userInput
2.- userInput
3.- userInput
etc.

Thanks


texts: how to access player prefab in endless runner game?

texts:
I am working on an endless runner.

The player is a prefab.
After player died, when user press watch ad, the game should continue and player should respawn where he died previously.

public void showAd()
{

    game_ = GameObject.FindObjectOfType<Game_manager>();
    game_.gameOn = true;
  Instantiate(playerPrefab, new Vector3(0, -0.337f,game_.spawnPos+10), Quaternion.identity);
    Debug.Log("ad is here");

}


texts: Count number of CCSprite added to a CCLayer

texts:
Does cocos2d has a method that returns the amount of CCSprites added to a CCLayer?

A have SceneControlLayer object, and I added some CCSprites to it.

@interface SceneControlLayer : CCLayer {
}

@implementation SceneControlLayer

-(id)init {

CCSprite *spr1 = [CCSprite spriteWithFile:@"spr1.png];
[self addChild:spr1 z:1 tag:1];

CCSprite *spr2 = [CCSprite spriteWithFile:@"spr2.png];
[self addChild:spr2 z:2 tag:2];

...

}
@end

How do I retrieve an array of sprites added to the layer? Could I retrieve all the objects added through addChild and test its type?

Since I'm starting with cocos2d/objectivec, please, give some examples how to do it...

I also thought that I could create an array, and, besides adding it to the layer, add it to the array also. But I'm not so sure if it's a good option.

TIA,

Bob


texts: How to change AddForce code to MovePosition or SetVelocity?

texts:
Vector2 vec = new Vector2(horizontal, vertical);
    vec = Vector2.ClampMagnitude(vec, 1f);

    Vector3 camF = cam.transform.forward;
    Vector3 camR = cam.transform.right;

    camF.y = 0;
    camR.y = 0;
    camF = camF.normalized;
    camR = camR.normalized;

    targetPosition = (camF * vec.y + camR * vec.x) * MoveSpeed;

    Vector2 targetVelocity = (targetPosition - transform.position)/Time.deltaTime;

    rb.AddForce(targetPosition - rb.velocity, ForceMode.VelocityChange);

My problem is my character doesn't affects by the gravity when i changed my code from transform.position to rb.AddForce. I searched online and even asked here how to calculate gravity and add it to my character, nobody knew, so i think if i can change this code to rb.MovePosition or rb.SetVelocity maybe it does affects by the gravity?


texts: Ways I can identify fraudulent customers / users for an upcoming game?

texts:
I'm trying to figure out ways I can identify potential fraudulent customers and users for an upcoming project. Similar to how major game publishes track and detect users who "hack" or "bot".

The only thing I could find regarding ways to track someone is by:
Cookies
IP
Mac Address

Any information is greatly appreciated.


texts: How to check the device type using Adobe AIR for iOS

texts:
How do I check what kind of device the user is running my Adobe AIR app on?

Example: if(device == ipad3) { stagestuff.width = 300; }


texts: Pygame - RPG Battle-Style Animation and movement when not controlled by player

texts:
Examples: https://www.youtube.com/watch?v=C2cOiFntLY4 https://www.youtube.com/watch?v=iHl1YFkeR78
I am making a small little RPG based on a text-adventure game that I made. This RPG involves a battle system similar to the SNES Final Fantasy games. I am currently limited to the player character and a single enemy, since those are the only actors that were ever present in the text-adventure game.
My battle system involves selecting your choice (attack or run away) and, upon attacking, the damage is calculated, battle text is displayed showing the damage, and then there is a short delay before the enemy attacks in return. This is all fine and good, but I don't want static images of my player and the enemy.
In the first example above, you can see the enemies jump onto the player for their attacks and you can see that the player runs to the enemy and then swings his sword. In the second example, you can see that the players will run forward a short distance and then either cast a spell or swing their weapon. What I'm looking for is something somewhere in the middle -- I want my player sprite to run/jump over to a position directly in front of the enemy, perform an attack animation in that position, and then run/jump back to their starting position.
I don't have my code in front of me, but I do know that I am currently drawing the sprites in specific locations, basically using standard pygame.draw functionality.
So: Any chance someone could walk me through this? I know how to move my player around when outside of the battle system, but I don't know how to properly do the same thing when the player is not in control... and adding the Y-axis to the equation (for the jump) just stumps me in this situation. I have (extremely basic) knowledge of tweening/easing functions, which I suspect will be relevant here, but I've only ever used them along one axis to make an item bounce up and down in place, so I'm not sure how to apply them to a sprite moving in two different axes.
Any help would be appreciated, especially code examples. Thanks!


texts: Computing Field-of-View from window dimensions

texts:
I'm looking into computing the vertical Field-of-View (FOVy) based on the projection parameters of my camera. From this source, I've found an equation that seems to work.

float FOVyForProjection(const float height, const float nearClip, const float farClip)
{
    // From http://paulbourke.net/miscellaneous/lens/
    //
    // vertical_field_of_view = 2 atan(0.5 height / focal_length)
    //
    const float focalLength = (farClip - nearClip);
    const float fovy = 2.0f * std::atan((height * 0.5f) / focalLength);
    return (fovy);
}

However, the author of the last link is talking about actual cameras and lenses, measured in millimeters, so I'm not sure if my interpretation is valid. Is the above function correctly computing the y-FOV based on the window height and near/far planes?

For a 768 height and far plane = 1000 it is giving a ~42 degrees FOV, which seems a bit low.

std::cout << "FOV = " << RadToDeg( FOVyForProjection( 768, 0.1f, 1000.f ) ) << std::endl;
// prints: FOV = 42.0174


texts: SDL text or additional images not loading

texts:
I've got a basic side scroller that allows the user to run and jump around. I've used various tutorials to get this far, but I can't seem to get any text to render, no matter what method. I also can't get any images to render outside of my draw() function which is rendered at run time, which I think is my problem. (Is it possible to recall the function again to load another image?)

I can't just give a line of code to show the issue since the whole program is interwoven together:

http://pastebin.com/d1CNiVf5

I'm not asking for someone to go through the code and fix everything, just if you could point me in the right direction, or at least know what is causing the problem that would be great!

(Sorry about having all the code in one file, I'm bad a modularising it and kept on getting errors early on in the project because of it. So for learning purposes it's going to be in one file for now).

Edit: At the moment the priority is to get projectiles working. I've tried SDL_UpdateRect and similar but nothing has helped so far.

Edit #2:
SO I've created a new function and have called it on top of the map, like it should do. But now I get a strange output:
http://youtu.be/8piWyjfDgbI


texts: How to achieve this sprite/mesh tile splitting like in Peggle?

texts:
Everyone knows Peggle. Here's a simple screenshot from one of their 'shapes':

On the first look, it looks so simple.
It's a circle made of identical tiles:

It's easy to make a circle like this, even programatically.

But then I realised that I can't make bigger/smaller circles with this single tile. For instance, the shape above has 17 tiles. If I want to make a circle with 9 tiles, I need to make a tile more curved, so it can close the entire shape with 9 elements.

Here's a sample of a shape which cannot be constructed using the above tile:

As you can see, it's probably made dynamically. Each tile has different size and it's warped differently and I don't think so that they've used 30000 types of tiles with multiple angles. They did actually, in the first version of the game coded in Lua, but there were 3-5 types of tiles. In their latest game, they've created more exotic shapes, and that would be so inefficient, especially for mobiles.

Are there any algorithms for filling an oval or circle with irregular tiles like this?

I assume I'd need to split some meshes dynamically for that, or at least sprites.

I'll be thankful for pointing me a right direction!


texts: Why are there weird texture artifacts in baked light which don't appear with realtime light?

texts:
This is the comparison of the same scene, realtime light vs baked light.

What's am I wrong ?

EDIT: In particular, also texture are low quality (see image 2). Why ?


texts: I'm not hearing any sound even though its picked up by audioSource?

texts:
I have two sound clips that I am feeding to an audioSource via script, it seems to be working as I can see the audio clips populating the audioSource component. But the problem is that I dont hear anything.

How ever if I remove the script and manually select the audioclip in source then I can hear both clips clearly. Why is this not working when done through script:

Here is my small script, its choosing two sounds based on the navMeshAgent status.

public class KnightAudio : MonoBehaviour {

    //private Animator anim;
    private NavMeshAgent agent;

    private AudioSource knightAudio;
    public AudioClip crying; //set this in ispector with audiofile
    public AudioClip scream; //set this in ispector with audiofile

    // Use this for initialization
    void Start () {
        knightAudio = GetComponent<AudioSource>();
        agent = GetComponent<NavMeshAgent>();
        //anim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update () {
        if (!agent.isStopped)
        {
            knightAudio.clip = scream;
            knightAudio.Play();
        }
        else
        {
            knightAudio.clip = crying;
            knightAudio.Play();
        }

    }
}

Here is the audio source, as can be seen it is populating the crying clip in there as expected when the agent is stopped and it will change this to scream when agent starts moving. But in game I cannot hear any of these.


texts: How can I reproduce the physics that we can see in Dawn of Titans?

texts:
I'm working on a hobby RTS project and I want to implement collision physics between soldiers like in the mobile game Dawn of Titans.

Here is a video reference https://youtu.be/Fnpot2NeJl8?t=341

How can I achieve this?


texts: How to persist Unity camera values changed while running/paused

texts:
I have a Unity program where all the GameObjects are created programmatically in C#, so there's nothing to see in the Scene window unless I hit play. I can hit pause and change the settings for a camera, but those changes are all discarded when I exit playmode.

What do I have to do to make the MODIFIED values the new, PERMANENT ones?


texts:
I am trying to figure out how to not break the SOLID principles with a collection of classes I am writing.

Currently, I have two stacks of classes that cater for editing and rendering Terrain and Paths.

Terrain -> TerrainChunk -> TerrainTile

Path -> PathChunk -> PathTile

The top level Terrain object exposes methods to add and remove Tiles which are then partitioned into Chunk objects forming part of a partitioned scene graph.

The Chunk objects themselves contain an array of Tiles and if something causes the tile or chunk to become dirty (terrain height is altered or a tile is added/removed) then the chunk “re-draws” itself which is as simple as looping through the tiles and calling Render().

The implementation of both the Terrain and Path stack of classes are largely the same (adding, removing, partitioning into chunks etc) with only the Render() method really doing anything different, i.e.: rendering a simple path or a single terrain tile.

I am quite happy with this setup so far which has proven to be extensible enough for my needs to date. This is working as expected and (surprisingly) I haven't butchered my code enough to worry about breaking any of the SOLID principles. Yet.

However, the need has arisen for the TerrainTile to know about the PathTile and also the PathTile needs  to know about the TerrainTile.

The reason I believe this is true is that I would like to be able to “cut away” the terrain where the path is and also add “tunnels” to the path though the terrain. In order to do this, both terrain and path need to know about each other to determine where the terrain should be drawn or cut away and which paths should have "tunnels" added to them.

Ideally, I would like to implement something similar to this capture from Theme Parkitect although the principle is most likely the same in any other simulation game with terraforming.

I’m not sure how to create the relationships between the two classes however without breaking at least 3 of the SOLID principles.

I could certainly go right at it and brute force this into my current implementation but that’s not very nice and would go against the lean and sane implementation I have strived for thus far.

Can anyone offer up any suggestions as to how I might inform one stack about the changes in another without introducing dependencies or hacking my code to pieces?

Perhaps I am barking up the wrong tree and the approach I have in mind isn't entirely suited for the job, in which case, are there any alternative options I could explore?

Note that I am not asking here about how to create either the terrain or the path tiles themselves but simply, how can I inform each of the appropriate parties of changes to each other without creating cyclical dependencies on each class.

If it matters, I am using Unity and C# but really this problem is both platform and language agnostic.


texts:
I come from Unreal, still using it. There, how it works is like this:
Let's say you as a player have a laser gun or something, and when shooting, you use raycast to see if you've shot anything, and if yes, you send an interface message (let's say Damage() function of IDamagable interface) to the hit result, if any.

Now, if the hit result implements that interface and has a Damage() function, it gets damaged. (And of course, if it doesn't implement the interface, nothing happens.)

But in Unity, I don't know how to send that interface message to the hit result (saying "if you have IDamagable implemented, call your Damage() function), but if it doesn't have it, that's fine either.

I've watched many videos on interfaces in Unity, but I still don't know how to achieve the same as in Unreal.


texts: Why don't game companies buy 3D models of cars from the respective car manufacturers?

texts:
My friend is working in a game company in India. They are developing 3D car models for racing games for other companies. They create their own car models right from the beginning.

I asked my friend "why are game companies not buying 3D models of cars from the respective car manufacturers? Why they are outsourcing it to other 3D modeling companies or creating on their own?"

He doesn't know the answer... So I am asking here.


texts: How can i rotate both NPCS facing the door moving to the door and then...?

texts:
I need to make some steps.

To rotate both npcs but each time running the game they will rotate randomly from another direction. For example the first one will rotate from the right side or left side same the other one.
They will facing the door and start moving to the door. Near the door she will open automatic they will wait then they will move through the door.
one of the npcs will keep moving and will start random patrolling.
The second npc will rotate facing the door from the outside and will do something like locking the door ( I will animate it later he will rotate facing the door wait 2-3 seconds will rotate and will join the first npc and start patrolling too.

This is a screenshot of both npcs each one have a box collider. The door they should rotate smooth randomly and facing and moving to the door the one behind them.

This is the behind the door outside the hall. This is where one of the npcs should start patrolling and the other one wait some seconds facing the door like he is locking the door and then after some seconds to join and start patrolling too.

And this is the hall out side the door and then the hall right and left. They should be patrolling the hall right and left and also the hall with the door.
But not getting too close to the door/s so they will not open all the time.

The last screenshot show where they should be patrolling. The left image is the hall outside the door the right image is a door on the front hall on the right and the bottom image the door on the left.

It's like a T

I need some guide how to start it by logic how to do it.
I have the scenario in my mind what they should do the 4 steps. But not surw hot start doing it.

The scenario in general is: Two guards(npcs) lock the door from the outside and start patrolling outside.


texts: Cross-platform builds with OGRE3D via CMake. Any tips?

texts:
I've been trying to compile a simple project for both OSX and Windows platforms, using OGRE3D, but I've got some problems on the way.

I'm using CMake to create my platform specific project files (VS solution & Xcode project). Some problems I found are:

OGRE3D source is distributed in 2 flavors, Windows sources and UNIX/OSX sources.
In OSX, compiling dependencies (freetype, FreeImage and specially OIS) is such a pain.
I don't know how to handle precompiled dependencies (they exist for both Win & Mac).

May sound like a noob question, but I would appreciate some tips on this. Resources, forum posts, anything. There exists any "cross-platform base project for OGRE3D" on the net?
Would be really helpful if someone who already managed to do this can bring some light.

Btw, I'm not basing the project on OGRE3D, it's just that is the biggest library I'm probably using, so I depend a lot on it.


texts: Have there been precedents where a closed-source game maker adopted user-made code (major overhaul)?

texts:
I'm interested to learn if there have been notable cases of a game maker accepting code or game engine portions developed by fans to replace their own buggy/flawed/slow parts, or even complete game remakes that turned official. For open-source games it should not be uncommon, but I'd like to know if there were any closed-source games which did that and the details of such occurrence.

For example, if Dark Souls was remade on Dark Souls 3's engine to improve world mesh clipping, graphics and framerate.

The goal is to find out how realistic it would be to remake or improve some (possibly old) games and figure out all the legal intricacies so it would be allowed for public distribution.


texts: Creating a 2d look sprite sheet and textures out of 3d models

texts:
I'm trying to make a 2d game (rpg top down), and I've got no 2d artists help me out making 2d characters and textures, but I have one who can make 3d stuff (using Blender and 3d Max), I was wondering if there's a way to make these 3d models look 2d so I can capture some poses to make a sprite sheet.

Is it possible to make 3d models look 2d?

Edit: Here are examples

Sly Crooper (Playstation 2 Game)
http://static.gamesradar.com/images/mb/GamesRadar/us/Features/2009/02/Sneaky%20History%20of%20Stealth%20Games/Screens/slycooper3--article_image.jpg

Legend Of Zelda Wind Waker:
http://www.zeldadungeon.net/images/News/Folder/10-05-06/Screen1-Large.jpg

I wish for sucha similar art.


texts: What is the best rate at which to send updates to clients for a first person shooter NodeJS WebSocket server?

texts:
I developed a multiplayer FPS using WebGL, Nodejs and WebSockets.
So far it is running great.
I am currently using setInterval(sendPlayerPositions, 16); to send updates to WebGL clients.
Ideally I would use 16.66667 but this is not possible to my understanding.
So I wonder if I should change to setInterval(sendPlayerPositions, 10); to make up for the drift.
And in general it might be a good idea to send stuff faster than the client frame rate (60 in most cases).
I also recently learned about process.nextTick and setImmediate and I wonder if I should use those
instead...
Any advice ?
PS: I am currently using Nodejs 10 on my Linux server and Nodejs 14 on my dev machine.


texts: Direct3D: should I use MIXED_VERTEXPROCESSING?

texts:
Yesterday on Youtube I watched a video tutorial about creating Direct3D stuff. On that tutorial there was a part about VERTEXPROCESSING compatibility with older video cards. The guy said that the compatibility can be checked by this code:

D3DDISPLAYMODE         d3ddm;
D3DPRESENT_PARAMETERS  d3dp;
D3DCAPS9               d3dc;
int VP;

d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dc);
if (d3dc.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
    VP = D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
    VP = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

//and then:
d3d->CreateDevice(D3DADAPTER_DEFAULT,
                  D3DDEVTYPE_HAL,
                  dxhwnd,
                  VP,
                  &d3dp,
                  &d3ddev);

But hey OpenGL does this stuff automatically so there must be a way to achieve that easier. So today I found that this can be done by D3DCREATE_MIXED_VERTEXPROCESSING. But on some forums I have read that some (most older) video cards can have problems with this mode. So is there any reason why should I or shouldn't use Mixed Vertex Processing instead of using them both but with D3DDEVCAPS?


texts: What is the best way to manage 'state' in Phaser?

texts:
I have heard that this is not the best way to manage state in phaser

var game = new Phaser.Game(800, 600, Phaser.CANVAS,'YourGameName');
game.state.add("Boot", Boot);
game.state.add("Preload", Preload);
game.state.add("MainMenu", mainMenu);
game.state.add("Play", Play);
game.state.add("GameOver", GameOver);
game.state.start("Boot");

so what is the best way to do it. I am newbie in Phaser game development.


texts: How do you display non-cutout transparent 2D textures with a depth buffer? (OpenGL)

texts:
I've been able to get my 2D renderer to display transparent cutout textures by testing the alpha of a fragment and discarding if it is less than 1 (or any fraction really). The problem is I want to support using translucent textures.

The current way I sort my sprites is by what texture they use, so that I can minimize texture changes. The only way I can think of getting this to work properly is by scrapping that and only sorting by z-order. But I don't want to throw away the optimization I already did. Is there any way to do both?

Does only rendering in 2D simplify the problem at all?

I was hoping to support translucent sprites, but my font renderer makes translucent font textures, so I can't just only use cutouts.

EDIT: After doing some research, it seems there really is no easy way to do this. (depth peeling for a 2D renderer seems a little overkill) I'm going to compromise by having my renderer hold 2 different sets of sprites, cutouts and translucent. I can draw the cutouts first in whatever order I want, making full use of texture atlases. The translucent textures, however, will need to be in z-order, ignoring atlases.

If anyone can tell me a better way, I'm all ears.


texts: Where can I advertise my engine, library or framework to attract users?

texts:
I have just finished my hypothetical game engine, library or framework.
Now, I want to share it with people who may find it useful in their projects. Where can I advertise it to gain users?

By advertise, I mean to spread the word of its existence - not advertise it for money.


texts: Is Global location using OpenGL bound by the shader?

texts: I have recently started writing a game engine in C++ with OpenGL and using some tutorials online. So far from what I have seen, shaders are the way to manipulate an object's position in worldspace. Is this true or is there a way to write a physics engine which can work without shaders in order to "move" and object in worldspace?


texts:
I'm currently writing a small game that is based on earning experience when killing enemies. As usual, each level requires more experience gain than the level before, and on higher levels, killing enemies awards more experience.

But I have a problem balancing this system. Are there any prebuilt algorithms that help to calculate how the experience curve required for each level should look like? And how much experience an average enemy on a specific level should provide?


texts: How do I implement a Bullet Physics CollisionObject that represents my cube like terrain?

texts:
I've successfully integrated the Bullet Physics library into my entity/component system. Entities can collide with each other. Now I need to enable them to collide with the terrain, which is finite and cube-like (think InfiniMiner or it's clone Minecraft). I only started using the Bullet Physics library yesterday, so perhaps I'm missing something obvious.

So far I've extended the RigidBody class to override the checkCollisionWith(CollisionObject co) function. At the moment it's just a simple check of the origin, not using the other shape. I'll iterate on that later. For now it looks like this:

@Override
public boolean checkCollideWith(CollisionObject co) {
    Transform t = new Transform();
    co.getWorldTransform(t);
    if(COLONY.SolidAtPoint(t.origin.x, t.origin.y,t.origin.z)){
        return true;
    }
    return false;
}

This works great, as far as detecting when collisions happen. However, this doesn't handle the collision response. It seems that the default collision response is to move the colliding objects outside of each others shapes, possibly their AABBs.

At the moment the shape of the terrain is just a box the size of the world. This means the entities that collide with the terrain just shoot away to outside that world size box. So it's clear that I either need to modify the collision response or I need to create a shape that conforms directly to the shape of the terrain. So which option is best and how do I go about implementing it? Perhaps there's an option I'm not thinking of?

It should be noted that the terrain is dynamic and frequently modified by the player.


texts: handle mousedrag() for two different game objects individually in 2D environment

texts:
I am developing a pong game for android mobiles having 2 slider and want to assign movement of  individual slider corresponding to its current position

I tried some code for the movement of these sliders using OnMouseDrag();

void OnMouseDrag()
    {
        Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        transform.position = new Vector2(transform.position.x, mousePos.y);

    }

I got the movement for the sliders but problem is that, I can only slide one slider at a time
But I need to move both the sliders at the same time using both hands because this game is getting developed for android mobiles environment.

please Help....


texts:
these are the pics of the inspect panel on the parts of the 3D pacman that you asked for.

(I just added these photos because I couldn’t while i was away and because even though the advice given so far was amazing, it didn’t resolve my problem, so please help if you can)

I’ve been trying to make a teleport for a while and it works only part of the time. the collisions work because i put a debug.log in it but the teleporting part doesn’t work. there are no errors in the collision, it just doesn’t teleport the pieces of pacman. here is the script (it's not the most improved but i was trying to make it work)

public GameObject pacman;
public GameObject Camera;
public GameObject pointLight;
public GameObject body;
public Vector3 pacmantele;
public Vector3 cameratele;
public Vector3 pointlighttele;
public Vector3 bodytele;

void OnTriggerEnter(Collider other)
{
    Debug.Log("works");
    pacman.transform.position = pacmantele;
    Camera.transform.position = cameratele;
    pointLight.transform.position = pointlighttele;
    body.transform.position = bodytele;
}

here is a photo of the inspection panel on the non-working teleporter


texts:
I'm starting/started a 2D tilemap RPG game in Java and I want to implement random map generation. I have a list of different tiles, (dirt/sand/stone/grass/gravel etc) along with water tiles and path tiles, the problem I have is that I have no idea where to start on generating a map randomly.

It would need to have terrain sections (Like a part of it will be sand, part dirt, etc.) Similar to how Minecraft is where you have different biomes and they seamlessly transform into each other. Lastly I would also need to add random paths into this as well going in different directions all over the map.

I'm not asking anyone to write me all the code or anything, just piont me into the right direction please.

tl;dr - Generate a tile map with biomes, paths and make sure the biomes seamlessly go into each other.


texts:
I am playing around with drawing an SVG sprite (imported in through [Embed]). Depending on the coordinates of the image, sometimes it appears more crisp than others.

The following image shows how at different locations is it rendered differently:

(Image link - You may have to download and zoom in with an image editor to see it)

You'll notice that the middle sprite is more blurry than the ones on the sides. Does anyone know why this is? Any help would be appreciated.


texts: Is texture 1D array a valid way to handle object coloring?

texts:
I would like to render game UI, and for that I need rectangles. However, since a button could be textured just as well as solid color or (multistop)gradient a problem arises. I would also like all types of rectangles(buttons) somehow at least partially uniform at handling.
I have been puzzled by this issue for quite a time and idea came across my mind - what if I stored colors to a 1D texture array and treat all rectangles as textured. Could you give me some example how to do this? Or event better a reason not-to solve it this way and point to better solution?


texts: Generate ETC2 compressed texture from Android Bitmap in OpenGL ES 2

texts:
My app currently uses a lot of textures most of which probably could be compressed quite a lot by using ETC2 (my app runs on 4.4 so i have a lot of devices supporting GLES30), i cannot use ETC1 since i need alpha too.

Problem is that i map my textures from a Bitmap i create dynamically (and quite often every 60 seconds), i currently map them this way (textures are not power of 2 sized):

GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, mode);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, mode);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

So i was wondering if:

Is it possible to load a Bitmap using ETC2 to use less memory on the graphic card? A code example would be great
How much overhead does the compression have? Mapping a 1024x1024 ARGB_8888 Bitmap every 60 seconds is feasible?


texts: Python 3: How can I make my Text-based game windowed?

texts:
I've been making a text-based RPG in Python, and I'm a bit lost in transitioning from a console to a window.

I'm not trying to do anything fancy (I think). I'd like my text to display normally, as it would in the console.

This is a good example: http://inventwithpython.com/blogstatic/esotera.png?27f655

However, I'd like to load images so that my different locations have corresponding backgrounds (I.e. When the character enters a tavern, the background is a tavern).

I have Pygame installed, but I really have no idea where to go from here, and I can't find any tutorials for text-based games like this.

My game code is here if you'd like to take a look:

https://gist.github.com/NervousTumbleweed/f42f325982f2sf2549b528ce0156j34a


texts:
I relaunched my prev unity project and the editor is not behaving as intented...
All the data that was manually set in the scripts in inspector in not there...
All the public variables and references are just empty....
I am using Unity 2019.4.2 lts


texts: Applying friction force not working correctly

texts:
I have a simple physics simulation I'm creating whilst following the Nature of Code tutorials on YouTube by Daniel Shiffman, at the moment I've just started learning about friction and have had a go at implementing in it my project.

But for some reason, applying friction doesn't work when placed directly in the update method. To elaborate, when I apply friction by holding down the space bar rather than just doing it every frame, the friction works as instead.

Another thing to note is that when I apply friction directly in the update method, the objects don't appear on the screen.

Below is the loop I have that iterates through all the rigid bodies in the scene:

        foreach (var body in this.bodies)
        {
            Vector2 wind = new Vector2(0.01f, 0.0f);;
            Vector2 gravity = new Vector2(0.0f, 0.1f * body.Mass);

            // Setup friction
            float c = 0.05f;
            var friction = body.Velocity;
            friction *= -1;
            friction.Normalize();
            friction *= c;

            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                // If I move this call to where I'm applying
                // all the other forces, the objects dissappear.

                // But if I apply force by pressing the space bar
                // the force is applied correctly.

                // Apply friction
                body.ApplyForce(friction);
            }

            // If I apply friction out here, it doesn't work
            // also, friction when printed to the screen is
            // NaN.

            // Apply wind and gravity
            body.ApplyForce(wind);
            body.ApplyForce(gravity);

            body.Update();
        }

and also, here is the source code that I'm following along with (essentially copying) in the video tutorials here

I feel as though I've supplied enough information, but if you need to know anything else please don't hesitate to do ask.


texts: Why would Assets.getBytes returns null in a test environment?

texts:
I'm using the latest Haxe (2.10), NME (3.4.3), and MUnit.

I've written some unit tests that need to fetch bitmap data from SWF symbols. The first step is to actually load the SWF data. To do this, I use NME's getByteArray along with the swf library, like so:

var blah:SWF = new SWF(Assets.getBytes("assets/swf/test.swf"));

The call to Assets.getBytes returns null when I'm running this under MUnit. When running my actual game code, I'm able to get the byte array (and consequentially, instantiate the SWF class).

Am I doing something wrong? What am I missing?

Edit: My directory structure is:

. (root
.\assets
.\assets\*.png (other images)
.\assets\swf\*.swf (SWFs)
.\Source\*.hx (source code)
.\Test\*.hx (tests)


texts: AndEngine: Painting on a canvas rather than composing image from objects

texts: I'm trying to implement drawing a line with a finger, similar to a Pencil tool in image editors. From what I've found on AndEngine, it seems like the recommended approach would be to create a line entity on every finger move, from the previous position to the new one. To me it seems rather inefficient to mimic this raster tool by vector graphics: apart from creating tens on objects per simple swipe, I guess that all these objects are repainted on each frame which is bad for speed. So I'm looking for a way to do all the painting on a bitmap canvas and draw it as a single entity. Am I missing something conceptually or did I just overlook some method?


texts: How to change particle graphics emitted by FlxEmitter?

texts:
I'm working with Flixel and attempting to emit "custom" FlxParticles from a FlxEmitter.  However, my main issue is that I typically get the default Flixel image emitted instead of my custom graphic.

If I modify the FlxParticle constructor in the Flixel source code like so:

public function FlxParticle()
{
    super();
    lifespan = 0;
    friction = 500;
    makeGraphic(4, 4, 0xFFFFFFFF);
}

I can get a custom particle (a 4 x 4 white square) to emit from my FlxEmitter.

However, if I write my own class that extends FlxParticle like so:

public class EffectParticle extends FlxParticle
{
    public function EffectParticle()
    {
        super();
        makeGraphic(4, 4, 0xFFFFFFFF);
    }
}

That class won't work - I will get the default Flixel image instead of my tiny white square.  I similar thing happens if I just call "makeGraphic()" on a FlxParticle variable.

Why does this happen, and other than modifying Flixel's source code or loading in custom graphic (from an embedded image), how can I create my custom particles?


texts:
i have been looking for 3d Bone Animation for plain C# (to be used with Sharpdx or Slimdx) but i did not find anything !!!
I just find some for XNA.

Any Suggestions!
Accept c++ suggestions also


texts: Drawing very large slowly rotating planets

texts:
I'd like to draw very large (~500 px) graphics of planets slowly rotating. These graphics are meant to impress. What's the best way of doing this? I don't have experience with any particular 3D engine, and I'm not even sure what platform this game would run on,  so:

I could pre-render each frame, but at 500px and a rotation period of 10 seconds, that's a ludicrous amount of data per planet.
I could use a 3D engine and map the planet's texture onto a mesh approaching a sphere, but at 500px, I fear the polygon count would have to be huge to make it look good.
I could write a kind of custom 3D engine that does nothing but efficiently render a textured sphere, by converting the x/y coordinate of each view pixel into the coordinate space of the sphere's texture - but this is involved, and couldn't benefit from graphics acceleration.
Something else I haven't thought of?

Here's an example animated GIF of what I mean. (At 100x100 px and 60 frames, it's already pretty huge, sorry.) Imagine this much, much bigger, rotating much slower, and animated more smoothly:

But if this were 500x500 px and 10 x 25 = 250 frames, we'd be talking about hundreds of MB of data, so this straightforward approach doesn't work.


texts: Better way to implement iPhone Games targeting iPhone 4, 4S & 5

texts:
iPhone 5:

4″ at 1146 x 640 resolution retina display

iPhone 4, 4S:

3.5″ at 960 x 640 resolution retina display

We are developing games targeting iPhone 4, 4S & 5.

What graphics resource ratio would be better with less time and
investment?
Which ratio would be easy to integrate with targeting device with
less coding?


texts: I have a 2D game and my goal is to make a car follow a path (the road in the picture) and rotate in the same time. I tried a plugin in the assets store but it didn't work well for me and i had difficulties making work as intended. If you have any suggestions, i ready to listen. Thanks for help in advance.


texts: What do you need to know in C++ before starting to program with DirectX

texts:
I was wondering what do you need to know in C++ before starting to program with DirectX?

I have only been programming in C++ (more for 2D games using SDL and learning the basics) for just over a year, I was wondering what kind of concepts and methods should someone be knowledgeable with or at least have seen before, before attempting to learn how to use Direct X?


texts: How to emulate Mode 13h in a modern 3D renderer?

texts:
I was indulging in nostalgia and remembered the first game I created, which used Mode 13h.

This mode was really simple to work with, since it was essentially just an array of bytes with an element for each pixel on the screen (using an indexed color scheme).

So I thought it might be fun to create something nowadays under these restrictions, but on modern hardware. The API could be as simple as:

public class Mode13h
{
    public byte[] VideoMemory = new byte[320 * 200];
    public Color[] Palette = new Color[256];
}

Now I'm wondering what would be the best way to get this data on the screen, using something like XNA / DirectX / OpenGL.

The only solution I could think of was to create a texture with the same size as the VideoMemory array, write the contents of VideoMemory to it every frame, then render that texture in a full screen quad with the correct aspect ratio and using point texture filtering for that retro look.

Is there a better way?


texts: How to park vehicles of random size on a 2d board?

texts:
Problem: I've a 2d board (HTML canvas or div) and some vehicles (png images) of different size. I've to place /park vehicle on the board randomly. They should not intersect.

Every vehicle can be rotated by any angle.
Every vehicle can be resized by X% of it's original size.

What I can think for it's algorithm is

Check if all n vehicles can be parked in available area
if yes, mark random area for vehicle 1

Check if all n-1 vehicles can be parked in available area
if yes then reserve marked area. and go to step 1 with n -1 vehicle.
if no then go to step 2

if no, resize a random vehicle and go to step 1

challenge: how to know optimally if all given vehicles can fit in given space.

I can know the boundary of vehicle image with the help of HTML canvas.
I need help to write an algorithm of parking vehicles on the board.


texts:
How would you go about determining a players position server side based off player input?

The Setup:
Player sends packet to server containing the command and view angles. Server takes the direction and multiplies it by speed.

Say a player is going up a hill. How would the server make the players position reflect that the player is going up a hill.

The way i see doing is taking the ground height under the player and calculating if the height change in direction x is too high. However calculating that info for n players say 1000 would be very intense. So what is the proper way of determining a players position based on input with a client/server setup with the server being authorative. There is 10 updates per second.


texts: Why do most FPS games have a machine gun, shotgun, and sniper rifle?

texts:
Most folks who've played FPS games would have noticed that the same weapons tend to reappear again and again, such as machine guns and shotguns. There was once a lot of innovation in the types of weapons in the genre's early days (see Duke Nukem 3D or Unreal Tournament for example), but in recent years the weapons tend to be cosmetic variations on a few standard types (warning: tvtropes link).

Why has this happened? I believe a large reason is that these standard guns serve distinct gameplay roles or purposes, so that even if they are replaced with a gun that is named differently or looks different, they act almost the same. If so, what are these roles, and could they be replaced with a gun that acted differently? For example, is it possible to replace the shotgun with something that was not semi-automatic, or fired a burst of pellets, without affecting the role?


texts: LibGDX viewport touch coordinates transformation

texts:
I've been trying to get LibGDX's viewport and camera unproject() to work and so far none of the tutorials/answers I've found have worked for me.
I have a game window of 840x480 units with FitViewport. If the screen resolution matches the aspect ratio of the viewport, the coordinates are unprojected correctly. If it doesn't and the viewport inserts black bars, the transformation is incorrect (see below):

I'd like for the shape to be drawn where the cursor is, since the current behavior makes touch input on Android absolutely useless...

Furthermore, on Android the viewport doesn't fill the entire screen and just produces a rectangle on the bottom left quarter of my 1920x1080 px display.

Here's the code that produces this:

public class MainScreen extends ApplicationAdapter implements InputProcessor {
OrthographicCamera camera;
Viewport viewport;
Vector3 worldCoordinates = new Vector3();
Shape shape, background;
public ShapeRenderer sr;

@Override
public void create() {
    worldCoordinates = new Vector3();
    camera = new OrthographicCamera(800,480);
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
    viewport = new FitViewport(800, 480, camera);
    viewport.apply();
    sr = new ShapeRenderer();
    shape = new Shape(this, 20, 20, 0, 0);
    background = new Shape(this, 800, 480, 0, 0, Color.WHITE);
    Gdx.input.setInputProcessor(this);
}

@Override
public void resize(int width, int height) {
    viewport.update(width, height);
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
}

@Override
public void dispose() {

}

@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void render() {
    camera.update();

    Gdx.gl.glClearColor(0, 0.1f, 0.1f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    background.render();
    sr.setProjectionMatrix(camera.combined);

    shape.posX[0] = (int) worldCoordinates.x - shape.sizeX[0] / 2;
    shape.posY[0] = (int) worldCoordinates.y - shape.sizeY[0] / 2;

    shape.render();
}

@Override
public boolean mouseMoved(int screenX, int screenY) {
    worldCoordinates = camera.unproject(new Vector3(screenX, screenY, 0));
    return true;
}

@Override
public boolean keyDown(int keycode) {
    throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean keyUp(int keycode) {
    throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean keyTyped(char character) {
    throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    return true;
}

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    return true;
}

@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
    return false;
}

@Override
public boolean scrolled(int amount) {
    throw new UnsupportedOperationException("Not supported yet.");
}
}

And the Shape class:

public class Shape extends Element {
public Color background;
ShapeRenderer sr;
public Shape( MainScreen ms, int sizeX, int sizeY, int posX, int posY){
    super(sizeX, sizeY, posX, posY);
    sr=ms.sr;
    sr.setAutoShapeType(true);
    background = new Color();
    background.set(1, 0.533f, 0, 1);
}
public Shape(MainScreen ms, int sizeX, int sizeY, int posX, int posY, Color background){
    super(sizeX, sizeY, posX, posY);
    sr=ms.sr;
    sr.setAutoShapeType(true);
    this.background = background;
}

@Override
public void render(){
    sr.begin(ShapeRenderer.ShapeType.Filled);
    sr.setColor(background);
    sr.rect(posX[0],posY[0],sizeX[0],sizeY[0]);
    sr.end();
}
}

I have tried literally every option I could find without any result. Thank you for any help.


texts: DirectX11 - CreateInputLayout() Vertex shader linkage problem

texts:
I keep getting the same error every time, I really have tried everything to fix the problem but it's still not working.
Basically I'd like to draw a simple cube.

The error(s):

D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (SV_Position,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]

The vertex shader, pos.hlsl:

float4 main(float3 pos : POSITION) : SV_POSITION
{
    float4 finalPos = { pos.x, pos.y, pos.z, 1.0f };

    return finalPos;
}

The vertex layout:

const D3D11_INPUT_ELEMENT_DESC d[] =
    {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
    };

struct Vertex
    {
        XMFLOAT3 poz;
    };

The actual code:

Vertex vertex_list[] =
{
    { XMFLOAT3{-1.0f, -1.0f, -1.0f} },
    { XMFLOAT3{-1.0f, +1.0f, -1.0f} },
    { XMFLOAT3{+1.0f, +1.0f, -1.0f} },
    { XMFLOAT3{+1.0f, -1.0f, -1.0f} },
    { XMFLOAT3{-1.0f, -1.0f, +1.0f} },
    { XMFLOAT3{-1.0f, +1.0f, +1.0f} },
    { XMFLOAT3{+1.0f, +1.0f, +1.0f} },
    { XMFLOAT3{+1.0f, -1.0f, +1.0f} }
};

/* First, setup the vertex buffer */
D3D11_BUFFER_DESC o;
o.ByteWidth = sizeof(Vertex) * ARRAYSIZE(vertex_list);
o.Usage = D3D11_USAGE_IMMUTABLE;
o.BindFlags = D3D11_BIND_VERTEX_BUFFER;
o.CPUAccessFlags = 0;
o.MiscFlags = NULL;
o.StructureByteStride = 0;

D3D11_SUBRESOURCE_DATA d;
d.pSysMem = vertex_list;

if FAILED(pRenderer->GetDevice()->CreateBuffer(
    &o,
    &d,
    &m_pBuffer
))
    return R_BUFFER_ERROR;

/* Now, setup the vertex layout */
long size = pFileManager->ReadShaderFile("pos.cso", m_bytes);

if FAILED(m_pD3DDevice->CreateInputLayout(
    d,
    ARRAYSIZE(d),
    m_bytes,
    size,
    &m_pInputLayout
))
    return R_SETUP_VERTEX_LAYOUT;

m_pD3DKontekst->IASetInputLayout(m_pInputLayout);

Then I'm using m_pD3DContext->Draw() to draw the scene.
Nothing shows up, just the usual gray background color using ClearRenderTargetView()

Thanks a lot for any help.


texts: Input prediction and server re-simultaion

texts:
I have read plenty of articles about multiplayer principles and I have basic client-server system set up. There is however one thing I am not clear on.

When player enters input, it is sent to the server and steps back in time to check if what should have happened at the time of that input and it resimulates the world again. So far everything's clear.

All articles took shooting as an example, because it is easy to explain and it is pretty straightforward, but I believe movement is more complicated. Imagine following situation:
2 players move towards each other.

A------><------B

Player A stops halfway towards the collision point, but there is lag spike so the command does not arrive on the server for a second or so. Current state of the world on the server (and on the other clients as well) at the time when input arrives is this:

[1]:

-------AB-------

The command arrives and we go back in time and re-simulate the world, the result is this:

[2]:

---AB-----------

Player A sees situation [2] which is correct, but the player is suddenly teleported from the position in [1] (center) to the position in [2].

Is this how this is supposed to work? Point of the client prediction is to give lagged player feeling that everything is smooth, not to ruin experience for other players.

Alternative is to discard timestamp on the player's input and handle it when it arrives on the server without going back in time. This, however, creates even more severe problems for lagged player (even if he is lagging just a bit)

EDIT:

To give you more info about my situation, I am making a game where exact position is quite important and the action is quite fast-paced. Imagine air-hockey with some perks on top.
Another thing worth considering is that this is flash game and I have to use TCP. From my previous experience, ping times of 200ms are the norm (unlike 50ms on pc games) in situations I will be facing.


texts: Building a simple bomberman game with Node.js and Socket.io

texts:
I'm building this game mostly because I want to experiment with Node.js and Socket.io, and the game is more like a proof of concept.

To start with, I have a 2D grid system as the game map.

_________________________________________.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|
.
|____|____|____|____|____|____|____|____|____|.

Each position with values:

0: empty
1: wall - can not be destroyed by explosion
2: obstacles - can be destroyed by explosion
3: bomb
4-9: some powerups
10>=: the id of player

CLIENT-SIDE

I'm not planning to have any game logic happen on the client side, so the client simply send left, right, up, down and plant a bomb command to my server. There is however, some simple check that happen on the client side - 1. check that there's no wall at the direction the client is moving to; 2. the client didn't plant a bomb in the last 3 seconds.

The client also receives the state of the map as a 2d array and knows how to draw everything using that info.

SERVER-SIDE

Main game logic happen on the server side, which includes updating the position of player, calculating the damage of bomb explosion - destroy stuff in the range, except walls and space behind walls

Questions:

When the player is moving, he won't see himself moved until he gets the data back from server that updates his position. So I worry this delay may affect user experience, is it better that I move his position on his browser right away, and only update other players' position using info received from server, that means his own movement is rendered away, while his position info is sent to server.
When rendering everything, it's simple to implement that whenever anything on the map move or change, redraw everything with the new data. Is that a waste? Can I only update things that change, for example, a player move right 1 position, nothing else changed on the game map, do I still have to redraw everything? I think I'm going to use Canvas to render.
Please feel free to comment or answer if you think there are places I can improve or I simply thought wrong, thanks!


texts:
I need some help on a simulation of an Artillery like this one

https://www.youtube.com/watch?v=YktWSKo_UbA.

I cant figure out how to make the "tomato" to get to the selected spot.

Where can I get solutions for this kind of questions in the future? Physics programming books? I am using LibGDX (Java).


texts: Movement on objects in 2D tile/grid based game

texts:
This question is an addition to both of these questions:

Boat passing under a bridge in a 2D tile based RTS
How to handle slopes/bridges in a 2d grid turn based strategy game

While I get the idea that you can just have multiple independant "layers" of your grid for each unit type. I'm curios as to how this works out in an action game where a player controls a character that can jump (or even crouch). So let's say I want to have the following kind of things:

Bridges or other places that a player can walk over or under.
Slopes that allow a player to move up or down without jumping
Crates, walls or even little differences in hight that a player should be able to jump onto or down.
Tall walles or cliffs that a player should not be able to jump down or up but walk on top of them if he finds another way to get up/down.
Pseudo-free-movement. A player can walk freely on the tiles while movement is still limited by the tile grid.

So slopes and crates are identical in a way that they allow a player to traverse from one layer to another one.

I'm not sure if this can even be achieved with a simple 2D approach, so maybe I'm better off with a full 3D engine? I liked the idea of a simple 2D engine but I don't want to make it more complicated if a a 3D engine is the right call here.

I'm also having a hard time finding any descriptions or papers that deal with these things.


texts:
I have implemented a "look at" method for my screen elements and it almost works how I want it to work.

The ScreenElement class uses a R3 Vector and a Quaternion to determine the position and orientation. As a convenience function I implemented a "look at" method. I am not the biggest expert on linear algebra, so my solution was an adaption of stuff I found on forums; but it was the only solution I understood.

The current approach is as follows:

void SceneElement::look_at(const mx::Vector3f& target, const mx::Vector3f& up)
{
    mx::Vector3f forward_l = mx::normalize(target - position);
    mx::Vector3f forward_w(1, 0, 0);
    mx::Vector3f axis  = forward_l % forward_w;
    float        angle = mx::rad_to_deg(acos(forward_l * forward_w));

    mx::Vector3f third = axis % forward_w;
    if (third * forward_l < 0)
    {
        angle = - angle;
    }
    orientation = mx::axis_angle_to_quaternion(angle, axis);
}

As you can see the up vector is not used and as a result the orientation is so far correct, that it looks as the target, but the up orientation is all over the place.

I have tried different approached to integrate the up vector. The "best" (i.e. it still mostly looked at the target) was to make the same approach with a orthonormalized up vector.

Just as a note, the up vector is expected to work like gluLookAt, that is used as a baseline but it needs to be projected into the local coordinate system, this I did as:

mx::Vector3f right = mx::normalise(forward % up);
mx::Vector3f up_n  = mx::normalise(right % forward);

Just to complete the info, the math lib I use is my own mathex and the basterised modulo (%) operator is the R3 cross product.


texts: How can I create online leaderboards for iOS and Android?

texts:
I'm developing a racing game for iOS and Android phones/tablets and I want to implement online leaderboards. My game has a singleplayer mode(no multiplayer features) but I want to implement online leaderboards to encourage people to beat other player's score and time.

I want to save the score and time(the time that you need to finish the race) in an online leaderboard. In addition, the name of the player and if possible his country are also saved in the leaderboard. The leaderboards don't need to be cross platform, I can create two leaderboards, one for iOS and one for Android.

Is it possible to create online leaderboards without MySQL and PHP knowledge? In addition, I don't have a server to save the data.

I use MonoGame to develop my game. Do you know a step by step tutorial for implementing online leaderboards because I don't know where to start.


texts:
I have a project where I flip a card after 5 seconds, then I want to start a countdown timer of x seconds. After x seconds the card flips again.

I found a good example for the timer here, but that works inside a Update() method. My problem comes from the fact that the rotation of the card is made also inside the Update() method.

If I put the timer inside the Update() method, as soon as the Update() method is called the timer starts, and I don't want it to start it as soon as I call the Update() method, but when I want to start ip, wich is 60 seconds after I flip the card.

If I put the timer inside a method other than Update() then the timer start but never decrease.

 using UnityEngine;
 using System.Collections;
 public class Juego1Carta2 : MonoBehaviour
 {
     public float velocidadDeRotacion = 100.0f;
     public Sprite cartaBase;
     public Sprite cartaDelantera;
     private bool carta2Activada = false;
     private bool cartaDeLado = false;
     float tiempoDeJuego = 2;
     IEnumerator Esperar()
     {
         yield return new WaitForSeconds(5);
         transform.position = new Vector3(Screen.width / 2, Screen.height / 2 +GetComponent<SpriteRenderer>().bounds.size.y, 0);
         carta2Activada = true;
         Regresa();
     }
void Regresa()
{
    Update();
}
// Use this for initialization
void Start ()
{
    StartCoroutine (Esperar());
}
// Update is called once per frame
void Update ()
{
    if (carta2Activada)
    {
        transform.Rotate(Vector3.up * Time.deltaTime * velocidadDeRotacion);
        if (transform.eulerAngles.y >= 90)
        {
            SpriteRenderer Carta = GetComponent<SpriteRenderer>();
            if (Carta.sprite == cartaBase)
            {
                Carta.sprite = cartaDelantera;
                cartaDeLado = true;
                carta2Activada = false;
            }
            else
            {
                Carta.sprite = cartaBase;
                cartaDeLado = true;
                carta2Activada = false;
            }
            tiempoDeJuego = 60;
        }
    }
    tiempoDeJuego -= Time.deltaTime;
    if (tiempoDeJuego <= 0)
    {
        print("Fin del tiempo");
    }
    if (cartaDeLado)
    {
        transform.Rotate(Vector3.up * Time.deltaTime * velocidadDeRotacion);
        if (transform.eulerAngles.y >= 180)
        {
            transform.eulerAngles = new Vector3(0, 0, 0);
            cartaDeLado = false;
            carta2Activada = false;
            return;
        }
     }
   }
}

Is there a way to rotate the card and make a countdown timer at the same time?

I'm sorry, maybe this is a very obvious question but after 3 consecutive days working on this, I'm more than burnout...


texts: Why is H (blinn) used instead of R (phong) in specular shading?

texts:
I can't find a good reason for this anywhere. The reflection vector used in phong has a simple basis in physics. But the half vector used in blinn seemingly has no rational basis, and does not constitute a proper reflection. And yet it is used in every so-called "physically based" shading function. If there is a good physical basis for it, I'd like to know.

What I've been able to find are a few reasons:

It's faster - there's mixed information on this, but even so it would have been a great reason... in the year 1998.

It handles angles higher than 90 degrees better - as far as I can tell the only reason for this is because the phong term has been used improperly. The dot product of the reflection and the view gives an angle between -1 and +1. Usually this angle is clamped to 0 to 1, this is the direct cause of the 90 degree problem. Re-normalize the angle instead of clamping it and you get the full 180 degree coverage. I refuse to believe a simple x * 0.5 + 0.5 operation has eluded the graphics world for 40 years.

it handles edges better - The edge "problem" also exists in the blinn solution, just to a lesser degree. The main cause is improper simulation of area lighting at the terminator, which should be essential for any "physically based" shader. But even in simpler situations a sigmoid function can approximate a soft terminator line correctly. Multiplying into a lambert term is incorrect as it attenuates the specular term improperly, this could cancel out a fresnel term and lead to further errors.

It has long reflections at the edge - It seems to me that while anisotropic reflections may be realistic, blinn is not the correct way to implement them, as they only appear at the edge. It is merely a happy coincidence that an error in the H term happens to look realistic.

None of these reasons are satisfactory, I want to sort out this madness.

I want to clarify that I am not talking about blinn and phong specifically, but instead about the vector components H and R, which are used as the basis for these shaders as well as others.


texts: How do I accept only one directional input per update?

texts:
I'm coding "Snake" as my first game and I'm facing the logical fail when pressing multiple keys simultaneously eg. { up, right}; {up, left}; {down, right}, etc. Snake is able to go back and forth and eat his own body (that's not supposed to be).

My question is how can I write the keypress condition for only one press per one update is allowed?

Thank in advance.

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
    if (dir == DOWN ) {
        head = new Point(head.getX(), head.getY() + SPEED * delta);
    }
    if (dir == UP) {
        head = new Point(head.getX(), head.getY() - SPEED * delta);
    }
    if (dir == RIGHT) {
        head = new Point(head.getX() + SPEED * delta, head.getY());
    }
    if (dir == LEFT) {
        head = new Point(head.getX() - SPEED * delta, head.getY());
    }

}
public void keyPressed (int key, char c) {
    if ((key == Input.KEY_LEFT) && dir != RIGHT) {
        dir = LEFT;
    }
    if ((key == Input.KEY_RIGHT) && dir != LEFT) {
        dir = RIGHT;
    }
    if ((key == Input.KEY_UP) && dir != DOWN) {
        dir = UP;
    }
    if ((key == Input.KEY_DOWN) && dir != UP) {
        dir = DOWN;
    }

}


texts: How to implement trading card game's "special effects cards"?

texts:
I am trying to write a kind of a trading card game here, in some way, it is similar to Magic The Gathering, or the Yu-Gi-Oh! card game.

For those of you who are not familiar with it, basically, in the game, there is a special kind of card (Spell cards/ Trap cards/ etc.), which have special effects that can bend the rules of the game. What I totally have no idea is, how to implement the logic of these cards. I have some idea of storing the card's data with some flags that can signal what kind of ability it has, but that would be very limited in what it can do (only some simple stats modification, maybe).

To give you an idea of what kind of effects these cards can have, here is some example of the spell card effects that are present in the Yu-Gi-Oh! card game:

Revive a creature that has been destroyed
Take control of the opponent's creature
Modify stats of the creature based on some conditions (e.g. Number of creature with certain names that have been
destroyed)
Special summon a certain creatures if the some conditions are fulfilled.
Fuse two or more creatures into a stronger creature.
Immunity to some of the special cards' effect.

Konami has made several video games of the game, complete with the AI and thousands of cards variety. I don't think it is actually possible to hard-code the entire database, is it?

Now, of course what I am trying to do is in no where as complex as those games, but I am curious, how do they implement these?


texts: Is it possible to run simulation of two scenes simultaneously in Unity3D?

texts:
I have got 2 scenes in a unity project and want to play simulation of both the scenes in parallel. Has anyone tried this?
Thanks!


texts: Is there a way to write a camera class without matrix-transformation?

texts:
I have a problem with a camera class I got from the internet. It does a transformation like this:

public Matrix get_transformation(GraphicsDevice graphicsDevice)
    {
        _transform =
          Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
                                     Matrix.CreateRotationZ(Rotation) *
                                     Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
                                     Matrix.CreateTranslation(new Vector3(ViewportWidth * 0.5f, ViewportHeight * 0.5f, 0));
        return _transform;
    }

Later the spritebatch is called like this:

spriteBatch.Begin(SpriteSortMode.BackToFront,
                    BlendState.AlphaBlend,
                    null,
                    null,
                    null,
                    null,
                    cam.get_transformation(device));

The problem is that at this point the mouse coordinates are not relative anymore to the other sprites I draw. This is a problem because I try detect which sprite has been clicked. I understand that this issue can be solved by considering the following picture:

This was posted in a very good awnser before, here. But somehow this does not really help me. So my question is:

Is there a way to create a Camera class which does not use transformation, can be moved with keys and keeps the viewport coordinates relative?

Thanks in advance!


texts: How would I access my list from Update function?

texts:
The DFT function below works fine but I want to use the list, generated from that function, in the Update function.

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

public class FFT : MonoBehaviour
{
    public ArrayList amp = new ArrayList();
    public ArrayList freq = new ArrayList();

    void DFT()
    {
        float[]  X = {1, 2, 3};
        float[]  Y = {2, 3, 5};
        float  N = X.Length;

        for(int k = 0; k < N; k++)
        {
            float re = 0;
            float im = 0;

            for(int n = 0; n < N; n++)
            {
                float phi = (2 * Mathf.PI * k * n) / N;
                re += X[n] * Mathf.Cos(phi) + Y[n] * Mathf.Sin(phi);
                im += Y[n] * Mathf.Cos(phi) - X[n] * Mathf.Sin(phi);
            }

            var  freqq = k;
            var  ampp = Mathf.Sqrt(re*re + im*im);
            var  phasse = Mathf.Atan2(re, im);
            phase.Add(phasse);

            amp.Add(ampp);
            freq.Add(freqq);

        }
    }
}

I want to use the lists elements in another function (for example in Update)

void Update()
{
    for(var i = 0; i < 2; ++i)
    {
        var x = amp[i] * Mathf.Cos(freq[i]);
        var y = amp[i] * Mathf.Sin(freq[i]);

        var pos = new Vector3(x, y, 0);

        //Debug.Log(pos);
    }
}

The problem is that amp[i] and freq[i] doesn't work in another function.


texts:
I'm working on a RPG game, however, I am not the amazing person at math that I wish I was, although someone suggested a logarithmic equation would work well. My current idea is for this:

You start off getting levels relatively quickly (lower xp amounts), then once you get higher up like 20-30 maybe it starts to take longer and longer to level, ending somewhere around 10-15 million experience for level 100. Can anyone offer me an equation or suggestions on how to do this? Thanks :)


texts: How to move points of a multi-segmented bezier curve to one side

texts:
I am trying to move points from a multi-segmented bezier curve to one end of the curve using the following code which modified for my use from here. Only the last segment seems to give the desired behaviour. All other segments, basically just disappear or skip through briskly.

public Vector2[] MultiSegmentCubicCurveReduction(Path curve, float start, float end)
{
    List<Vector2> pointsForSubpath = new List<Vector2>();

    float oneMinusStart = 1f - start;
    float oneMinusEnd = 1f - end;

    float scale = (end - start) / (curve.NumPoints - 1);

    for (int i = 0; i < curve.NumSegments; i++)
    {

        var a =
            oneMinusStart * oneMinusStart * oneMinusStart * curve[3*i] +
           3f * oneMinusStart * oneMinusStart * start * curve[3 * i + 1] +
           3f * oneMinusStart * start * start * curve[3 * i + 2] +
                                     start * start * start * curve[3 * i + 3];

        var b = a + (3f * oneMinusStart * oneMinusStart * (curve[3 * i + 1] - curve[3 * i]) +
                     6 * start * oneMinusStart * (curve[3 * i + 2] - curve[3 * i + 1]) +
          3 * start * start * (curve[3 * i + 3] - curve[3 * i + 2])) * scale;

        ;

        var d = oneMinusEnd * oneMinusEnd * oneMinusEnd * curve[3 * i] +
            3f * oneMinusEnd * oneMinusEnd * end * curve[3 * i + 1] +
            3f * oneMinusEnd * end * end * curve[3 * i + 2] +
                                            end * end * end * curve[3 * i + 3];

        var c = d - (3f * oneMinusEnd * oneMinusEnd * (curve[3 * i + 1] - curve[3 * i]) +
                     6 * end * oneMinusEnd * (curve[3 * i + 2] - curve[3 * i + 1]) +
                                                        3 * end * end * (curve[3 * i + 3] - curve[3 * i + 2])) * scale;

        pointsForSubpath.AddRange(new List<Vector2>() { a, b, c, d });
    }

    return pointsForSubpath.Distinct().ToArray();

}

UPDATE

The brisk movement I was having earlier was actually a reduction of control points to four regardless of the number of segments.
Now I am getting the following behaviour. All the points for the first segment converge to one end point whiles all the points of the remaining segments converge to the other end point, resulting in a straight line.


texts:
Currently I'm doing an android game. My problem is the score. The game speeds up in every round and currently I'm counting the score like this:

private static final const int MAX_SCORE = 150;
private int countdown = 0;

public void scoreUpdate(){

   if(countdown <= 0){
      score = 0;
   }

   score += countdown;

   countdown = MAX_SCORE;
}

countdown gets constantly decreased in my game loop so the less time you take to react the more score you get. Every Tap you do correctly will start the next round and call scoreUpdate().

Problem now is, that the game is speeding up, so you only get good scores the further you play the game. Does anyone has a better method to count the score more evenly?


texts:
I'm playing around in LWJGL3 and I'm experiencing an issue regarding glDrawArrays.

At glDrawArrays the JVM crashes.

I'm using modern OpenGL and therefore I have my own shaders and matrix calculations.
The pipeline I've programmed is quite complex so pasting all the code here isn't of any use.

Vertex shader:

#version 330 core

uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;

layout (location = 0) in vec3 in_position;

void main() {
    gl_Position = (projectionMatrix * viewMatrix * modelMatrix) * vec4(in_position, 1.0f);
}

Fragment shader:

#version 330 core

void main() {
    gl_FragColor = vec4(1.0f, 0.0, 1.0f, 1.0f);
}

I'm trying to draw 1 point to the screen using a VBO. Creation of the VBO:

float[] vboData = new float[]{0.0f, 0.0f, 0.0f};
FloatBuffer buffer = BufferUtils.createFloatBuffer(vboData);

vbo_id = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

And the rendering of the point using glDrawArrays:

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    testShader.bind();
        pipeline.applyMatrices(testShader);

        glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
            glVertexAttribPointer(0, 3, GL_FLOAT, false, 12, 0);
            glDrawArrays(GL_POINTS, 0, 1);
        glBindBuffer(GL_ARRAY_BUFFER, 0);

        pipeline.setCameraPosition(new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.0f, 0.0f, 0.0f));
    testShader.unbind();

    GLFWUtils.swapBuffers();

Using GLIntercept I managed to get a log of every OpenGL call made:

glClearColor(1.000000,0.000000,1.000000,1.000000)
glPointSize(10.000000)
glGenBuffers(1,000000001E0F6FC0)
glBindBuffer(GL_ARRAY_BUFFER,1)
glBufferData(GL_ARRAY_BUFFER,12,0000000025EB8D90,GL_STATIC_DRAW)
glBindBuffer(GL_ARRAY_BUFFER,0)
glCreateProgram()=1
glCreateShader(GL_VERTEX_SHADER)=2
glCreateShader(GL_FRAGMENT_SHADER)=3
glShaderSource(2,1,000000001E0F6FC0,000000001E0F6FC8)
glShaderSource(3,1,000000001E0F6FC0,000000001E0F6FC8)
glCompileShader(2)
glCompileShader(3)
glGetShaderiv(2,GL_COMPILE_STATUS,000000001E0F6FC0)
glGetShaderiv(3,GL_COMPILE_STATUS,000000001E0F6FC0)
glAttachShader(1,2)
glAttachShader(1,3)
glLinkProgram(1)
glEnableVertexAttribArray(0)
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
glUseProgram(1)
glGetUniformLocation(1,"projectionMatrix")=1
glUniformMatrix4fv(1,1,false,[-0.671312,-0.000000,-0.000000,-0.000000,-0.000000,-0.895083,-0.000000,-0.000000,-0.000000,-0.000000,-1.000020,-1.000000,-0.000000,-0.000000,-0.020000,-0.000000])
glGetUniformLocation(1,"viewMatrix")=2
glUniformMatrix4fv(2,1,false,[1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000])
glGetUniformLocation(1,"modelMatrix")=0
glUniformMatrix4fv(0,1,false,[1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000])
glBindBuffer(GL_ARRAY_BUFFER,0)
glVertexAttribPointer(0,3,GL_FLOAT,false,12,0000000000000000)
glDrawArrays(GL_POINTS,0,1)

I've carefully tested a few things:

The shaders compile and link fine
The matrices calculated look correct (you can double check inside the GLIntercept log)
The VBO is correctly created and filled with the correct data
The attribute pointer ( = layout 1) is enabled
The matrices are correctly sent to the shader (this happens at pipeline.applyMatrices)

What am I missing?

Interesting debug finding: I'm running this on nVidia. On a Intel graphics CPU it runs, but nothing shows on the screen!


texts: How can I use a lookup table for brightness and contrast?

texts:
Currently, I implemented a rudimentary brightness and contrast algorithm that changes brightness and contrast pixel by pixel. This was super inefficient performance wise and the algorithm looked a bit strange.

I heard that I can use a lookup table to get values brightness and contrast for a texture 2D image. How can I do something like this in Unity?

Currently in Unity, I have a prefab in which I load a texture 2D image on top of it. That's the image i want to apply brightness and contrast changes to.


texts: How do I efficiently display image tiles in Unity 4.3 free

texts:
I previously wrote a TileEngine with SFML that I would like to port to Unity3D 4.3, but have not found a way to draw a tile on the screen programmatically in Unity.

All I am looking for something akin to SFML's RenderTexture(), and not a plugin or something from the asset store.

I am using Unity 4.3's new 2D tools/workflow, and as such need a method that will work with the 2d viewport.


texts: Box2d joints still attached after Explosion simulation

texts:
I ported simple Box2d Explosion simulation the function is called once when there is some event with the "Truck Car"
the problem is that the Explosion working fine but it looks like when the explosion done the "parts" of the car Returning to
the initial car position instead of bean scatter on the floor.
what am i doing wrong here ?

here is the code for the Explosion

class MyQueryCallback : public b2QueryCallback {
public:
    std::vector<b2Body*> foundBodies;

    bool ReportFixture(b2Fixture* fixture) {
        foundBodies.push_back(fixture->GetBody());
        return true;//keep going to find all fixtures in the query area
    }
};
void BackgroundSprite::explode()
{
        float m_blastRadius = 40.0f;
        float m_blastPower = 50.5f;
        MyQueryCallback queryCallback;
        b2Vec2 locationPnt = _truck->truckBody->GetPosition();
        b2AABB aabb;
        aabb.lowerBound.Set((locationPnt.x - m_blastRadius), (locationPnt.y - m_blastRadius));
        aabb.upperBound.Set((locationPnt.x + m_blastRadius), (locationPnt.y + m_blastRadius));
        m_world->QueryAABB(&queryCallback, aabb);

        for (int i = 0; i < queryCallback.foundBodies.size(); i++) {
            b2Body* pBody = queryCallback.foundBodies.at(i);
            b2Vec2 pBodyPos = pBody->GetWorldCenter();
            b2Vec2 pHitVector(pBodyPos.x - locationPnt.x, pBodyPos.y - locationPnt.y);
            float radDist = pHitVector.Normalize();
            radDist = (radDist * PTM_RATIO);
            if ((pBody->GetType() == b2_dynamicBody) == (radDist <= m_blastRadius)){

                float nHitForce = ((m_blastRadius - radDist) / m_blastRadius) * m_blastPower;
                b2Vec2 appForce(pHitVector.x*nHitForce, pHitVector.y*nHitForce);
                pBody->ApplyLinearImpulse(appForce, pBody->GetWorldCenter(),true);
            }
        }
 }

see what i mean in the video at 3:30
https://www.youtube.com/watch?v=3JmimxLiTpo