texts: Why does compiling Unreal Engine fail in Xcode on OS X?

texts:
I'm following Ben Tristem's latest course on using Unreal Engine and coding in C++. I have issues getting into Unreal however: when I create a project, it does its stuff, i.e. generates code, compiles it etc. but then I get this message:

I tried to open it with Xcode but I don't know what to do next… could someone help me out?


texts: sdl: unlock mouse in fullscreen mode and make it useable on another monitor

texts:
Is it possible to unlock the mouse in fullscreen mode so that you can use it on a another monitor?
I read trough the SDL documentation, but I couldn't find anything related to my problem.


texts: Messaging/Event System in Generic Game Engine? Yay or nay?

texts:
Should I develop a basic messaging/event system for a generic game engine or should I leave it up to the individual case-by-case basis of the end-users to create systems specific to the game being developed?

This question raises some valid points: (I am currently using the per-frame function call system mentioned)

Per-frame-function-calls-versus-event-driven-messaging-in-game-design


texts:
How do I declare the keycodes as strings instead of selecting the keys from a list? Such that the user can input a key in inspector window and it will be read?
public string StringKey = "a";

void Update () {

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

   }


texts:
I'm trying to achieve the results in this tutorial: Link

So far, I was be able to do that;

with these;

    public PixelMap GetNormalMap(double strength)
    {
        var newMap = new PixelMap(Width, Height);

        for (int i = 1; i < Width - 1; i++)
        {
            for (int j = 1; j < Height - 1; j++)
            {
                /*
                    [ a b c ]
                    [ d x e ]
                    [ f g h ]
                */
                var a = this[i - 1, j - 1].Intensity;
                var b = this[i, j - 1].Intensity;
                var c = this[i + 1, j - 1].Intensity;
                var d = this[i - 1, j].Intensity;
                var e = this[i + 1, j].Intensity;
                var f = this[i - 1, j + 1].Intensity;
                var g = this[i, j + 1].Intensity;
                var h = this[i + 1, j + 1].Intensity;

                // sobel filter
                double dX = (c + 2.0 * e + h) - (a + 2.0 * d + f);
                double dY = (a + 2.0 * b + c) - (f + 2.0 * g + h);
                double dZ = 1.0 / strength;

                var v = new Vector3D(dX, dY, dZ);
                v.Normalize();

                newMap[i, j] = new Pixel(Pixel.Map(v.X), Pixel.Map(v.Y), Pixel.Map(v.Z), this[i, j].A);
            }
        }

        return newMap;
    }

    public double Intensity
    {
        get { return (R + G + B) / (3.0 * 255); }
    }

    public static byte Map(double value)
    {
        return (byte)((value + 1.0) * (255 / 2.0));
    }

The first issue is that the normal map colors are different on my image. Also, I was not be able to understand how the get the image in D (can be found in the middle of the linked article). I can upload all the code if the functions above are not enough.

Normal map after alpha map;


texts:
I'm developing a simple game by andengine. I have 10 balls which are moving randomly on screen.i'm importing the balls as picture in sprites.if they move at the same coordinate , they pass though their own insides.but i want: if they move at the same coodirnates ,they should change their directions.so they cannot pass through their insides.how can i do that?

 private Runnable mStartCircle = new Runnable() {
  public void run() {
    int i = circleNumber++;
    Scene scene = Level1Activity.this.mEngine.getScene();
    float startY = -64.0f;
    float startX = randomNumber.nextFloat()*(CAMERA_WIDTH-70.0f);
    float a= randomNumber.nextFloat()*(CAMERA_WIDTH-70.0f);
    circles[i] = new Sprite(startX, startY, textRegCircle[i]);
    circles[i].registerEntityModifier(
            (IEntityModifier) new SequenceEntityModifier (
                        new MoveModifier(10.0f, circles[i].getX(),  a,
                                circles[i].getY(),CAMERA_HEIGHT+64.0f)));
    }
    scene.getLastChild().attachChild(circles[i]);
    if (circleNumber < 10){
        mHandler.postDelayed(mStartCircle,1000);
    }
}

};


texts: Regarding Profile Pictures of Facebook Friends

texts:
Background: I am creating a Leaderboard of Facebook friends in unity.
Question: Can we download and save the images of Facebook Friends on the device of the user for the purpose of reuse? I would like to store the images of the FBFriends on the user's device so that there is no need to download the same pictures everytime the game is restarted. Is it legal to do so?
I asked the same question in Facebook Developers forums but I did not get any response. Kindly guide me. How do devs build a leaderboard of Facebook friends normally?
Thankyou.


texts: Unity Input.GetMouseButtonDown(0) is not working

texts:
My code to detect left mouse click is not working Input.GetMouseButtonDown(0) and Input.GetMouseButtonUp(0).
But same code for Input.GetMouseButton(0) is working.

Code:

void FixedUpdate()
{
  #if UNITY_ANDROID
    mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 4f));
    mouseCameraOffset = bowlingBall.position - mouseWorldPos;

    if (Input.GetMouseButtonDown(0))
    {
        Debug.Log("last");
        lastMousePos = Input.mousePosition;
    }


texts:
According to OGLES specification, we have the following definition:

EGLSurface eglCreateWindowSurface(EGLDisplay display,
                                  EGLConfig config,
                                  NativeWindowType native_window,
                                  EGLint const * attrib_list)

More details, here: http://www.khronos.org/opengles/documentation/opengles1_0/html/eglCreateWindowSurface.html

And also by definition:

int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width,
                                         int32_t height, int32_t format);

More details, here: http://mobilepearls.com/labs/native-android-api

I am running Android Native App on OGLES 2 and debugging it in a Samsung Nexus device. For setting up the 3D scene graph environment, the following variables are defined:

struct android_app {
    ...
    ANativeWindow* window;
};
android_app* mApplication;
...
mApplication=&pApplication;

And to initialize the App, we run the commands in the code:

ANativeWindow_setBuffersGeometry(mApplication->window, 0, 0, lFormat);
mSurface = eglCreateWindowSurface(mDisplay, lConfig,
                                  mApplication->window, NULL);

Funny to say is that, the command ANativeWindow_setBuffersGeometry behaves as expected and works fine according to its definition, accepting all the parameters sent to it. But the eglCreateWindowSurface does no accept the parameter mApplication->window, as it should accept according to its definition. Instead, it looks for the following input:

EGLNativeWindowType hWnd;
mSurface = eglCreateWindowSurface(mDisplay,lConfig,hWnd,NULL);

As an alternative, I considered to use instead:

NativeWindowType hWnd=android_createDisplaySurface();

But debugger says:

Function 'android_createDisplaySurface' could not be resolved

Is 'android_createDisplaySurface' compatible only for OGLES 1 and not for OGLES 2?

Can someone tell if there is a way to convert mApplication->window? In a way that the data from the android_app get accepted to the window surface?


texts:
I am currently using XML to create my dialog trees in my rpg, but doing this by hand for hundreds of different discussions can get very tedious very fast. I was wondering if there is any way I can implement a flow chart/udk kismet like system of visually coding these diolog trees. I still want the end result to be the XML because I already wrote the parsing and other logic around the XML.

EDIT: to give an idea of what I am looking for, here is an example. This was shown to me when I asked this on reddit and it is basically what I am looking for but it is limiting . Really what I am looking for is any dialog software that is already in use for games or software that is graph/flowchart like and can be modified to suit my needs.


texts: Does collision detection data structures require a manifold mesh

texts:
Is it possible to apply spatial split techniques (oct-trees bsp-trees, etc) when meshes are not necessary manifolds?

The mesh in question represents the "map". This means that it is static so spatial splits should be a good approach. Not requiring a manifold saves a lot of time when modeling, and also it may reduce the number of extra faces that has to be drawn, as forcing the mesh to be a manifold may require additional cuts.


texts: How do I go from world coordinates (X/Y) to tile coordinates?

texts:
So, I've got this game rendered in fake isometric view with the following code for generating the mesh:

_x = x + ( y & 1 > 0 ? 0 : 0.5 );
_y = y * 0.25;

ADD_VERTICES( [
        _x-0.5,  _y,      0,  _uv[0], _uv[3], //B
        _x,      _y+0.25, 0,  _uv[0], _uv[1], //A
        _x+0.5,  _y,      0,  _uv[2], _uv[1], //C

        _x+0.5,  _y,      0,  _uv[2], _uv[1], //C
        _x,      _y-0.25, 0,  _uv[0], _uv[1], //D
        _x-0.5,  _y,      0,  _uv[0], _uv[3], //B
] );

Which creates quads (2 triangles really) with the following corners:

0 0 [0.5, -0.5  -   0, 0,       -   0.5, 0.5    - 1, 0]
1 0 [1.5, -0.5  -   1, 0,       -   1.5, 0.5    - 2, 0]
0 1 [0, 0       -   -0.5, 0.5   -   0, 1        - 0.5, 0.5]
1 1 [1, 0       -   0.5, 0.5    -   1, 1        - 1.5, 0.5]

I can get the world coordinates from the mouse position, how ever, I can't for the life of me figure out how to get from world coordinates back to tile coordinates. What is the algorithm for that? (Or, how can I change the vertices around so that that is easier)


texts: Change entity's size based on health [ECS]

texts:
I'm making a kind of entity component system framework and I have a doubt:

I have two components 'health_damage', 'physic' (which contains position, weight,...) and 'sprite' (position, dimensions...).

When this entity takes damage I want to reduce its dimensions based on health percentage (50% life -> 50% original size) and I thought that I need to create a new system 'change_dimensions_on_hit', register the entity and on hit send a message to it which will update the dimensions (and weight) based on health. And that's, in my opinion, it's fine.

The problem is: imagine I create an item which increases the dimensions of the entity when it's picked up. It would increase the size of a fixed amount without knowing it's original or not (maybe it's at 10%) and when the entity regains health it will become huge
Ex.
Health = 10; MaxHealth = 100
ActiveDimensions = 10 (original is 100);
I take a +20 size object and then a full heal item:
ActiveDimensions would be (10 + 20)/0.1*1.0f = 300 (and not 120)

These are the solutions I found (but I don't really like anyone of them):

storing for each 'mutable variable' its current and max value like for health, so I can always calculate the current percentage and change correctly the original size. I think that's not a good idea because really few entities would have this behaviour and so I would waste a lot of memory.
make the physic component aware of the existence of the health component and (if a flag is set) look for che percentage when it is modified. I think it similar to the first and it also forces a tied relationship which I think it's even worse.
(the one that I think it's the best) I'm using a message system to handle things such as damage on collision, creation of entities... I still need to figure if it's the best way but I'm pretty sure of this. I can use it to handle everything possible and so also the changing of sizes: the item picked up sends a message to the entity 'grow up/shrink'; the entity spreads it to all the systems which is registered to and they can modify the message data before it's handled by the 'base components' (physic, dimensions,...). So it will be received at first by the change_dimensions_on_hit which would adjust the amount of growing based on current health. At the moment I handle messages in a very specific way:
1) it's handled by the systems which will modify them directly (ex.'double_growing_items')
2) by the ones which need to read other components to perform the change (ex. 'Change_dimensions_on_hit')
3) by the base components such as dimensions.
This solution seems the best to me, even if has its own limitation (I have a specific path for each message and I'll face problems such as 'I need that this message, in this case, is handled first by this system and then from that, and not the opposite') and relies entirely on a message system which isn't the best solution performance wise (but I don't think that's a real problem).

Any advice and suggestion is welcomed. Do you think message system is the right way? Or maybe the firsts methods with slightly changes? Something totally new? (I can't change too much because I need to finish this project in one two month for the high school's final exam)


texts: How can I use CCClippingNode to trim the top and bottom from a CCTableView?

texts:
I'm fairly new to Cocos2d and struggling with sizing a CCTableView. How can its height be controlled so that I have space at the top and the bottom?

I'm trying to visually wrap the top and bottom of my table view with a sprite, to provide the look and feel of a frame. But when I touch the table view, to scroll it up or down, it occupies most of the screen vertically. I thought the contentSize would alter where each cell appears and disappears from the top and bottom, but changing it had no effect.

Having had a Google about, I'm reading that I have to use a Clipping Node with a Stencil? Coming from UIkit, this seems like a bit of a faff. Would anyone like to hazard at a tutorial, bit of code with a simple CCTableView representation, sat in the middle of the scene where each cell appears and disappears under a content frame?


texts:
Imagine yourself a vertex array in OpenGL representing blocks in a platform game.

But some vertices may be not used.

The environment is dynamic, so there always some vertex may suddenly become invisible.

What is the best way to make them not draw? Graphic cards are complicated and it's hard to predict what is best approach.

Few best ways I can think of:

delete and move all vertices after deleted one to fill freed space (sounds extremely inefficient)
set positions to 0
set transparency to maximum

I could of course benchmark, but what on my computer works faster doesn't have to on other.


texts: How to keep an object in a certain part of the camera view?

texts:
I have a 3d camera that is viewing a character that is moving. As the character is moving i want the camera to adjust itself so as to keep the character in the left third of the camera view.

I understand how to move the character in world space but how do i check in what part of the camera view it is in? And then know how to adjust the camera to compensate?

EDIT:  I am looking for the maths behind this. I understand that if i have the character world space postiton, i can convert that to screen coordinates by applying the view and projection matrices. I then get the camera view in screen coordinates. I am able then to create some 2d bounding box that will move the camera if the character enters it.


texts:
I'm developing a Minecraft plugin (bukkit) in which a server admin can create 'portals' - a small region that will teleport any  players who enter it. I have the teleportation sorted and I know how I could define areas that the player's position could be tested against.

This would involve an ArrayList containing the zones and then hooking the PlayerMoveEvent so that the ArrayList is searched each time for a matching portal region.

Although this method would work, I doubt that it would be very efficient when 100+ players are all moving around at the same time. Is there a better way of checking a player position against a set of 'zones' / regions?


texts:
How do you have rigged clothing animate with a base model?
Or how can you coalesce multiple skinned mesh renderers or have them all be controlled by just one?
Or, do you just have multiple animators for each SkinnedMeshRenderer (and there would be quite a number, for a character with a complex outfit that is modular)?

Have not been able to get it to work from the only thing I can find online (surprised there aren't more tutorials on this) https://forum.unity.com/threads/tutorial-how-to-make-clothes-animate-along-with-character.475253/
I've applied the method by looping through the SkinnedMeshRenderers present in the clothing assigned when a character root is loaded in ApplyClothing(clothing,root). Clothing and character have the same bone structure, as the clothing is custom modeled to the character model and rig.
I get a few unable to map L/R_Knee Ankle Foot errors, but I have removed the break. I've tried rotating several other joints in the root character but the clothing is still not deforming with the joints.
    void ApplyClothing(GameObject clothing,Transform root)
    {
        GameObject g = Instantiate(clothing);
        g.transform.parent = root;
        g.transform.localPosition = Vector3.zero;

        BoneSyncer(clothing, root);
    }

    void BoneSyncer(GameObject clothing,Transform root)
    {
        SkinnedMeshRenderer[] smrclothing = clothing.GetComponentsInChildren<SkinnedMeshRenderer>();

        for(int i = 0; i < smrclothing.Length; i++)
        {
            SkinnedMeshRenderer[] rootsmrs = root.GetComponentsInChildren<SkinnedMeshRenderer>();
            SkinnedMeshRenderer rootsmr = null;
            for(int j = 0; j < rootsmrs.Length; j++)
            {
                if (!rootsmrs[i].name.ToLower().Contains("haircut"))
                {
                    rootsmr = rootsmrs[i];
                }
            }

           if(rootsmr!=null) BoneSyncer(smrclothing[i], rootsmr);
        }
    }

    void BoneSyncer(SkinnedMeshRenderer clothingmeshrenderer, SkinnedMeshRenderer targetmeshrenderer)
    {
        Dictionary<string, Transform> boneMap = new Dictionary<string, Transform>();
        foreach (Transform bone in targetmeshrenderer.bones)
            boneMap[bone.gameObject.name] = bone;

        Transform[] newBones = new Transform[clothingmeshrenderer.bones.Length];
        for (int i = 0; i < clothingmeshrenderer.bones.Length; ++i)
        {
            GameObject bone = clothingmeshrenderer.bones[i].gameObject;
            if (!boneMap.TryGetValue(bone.name, out newBones[i]))
            {
                Debug.Log("Unable to map bone \"" + bone.name + "\" to target skeleton.");
                //break;
            }
        }
        clothingmeshrenderer.bones = newBones;
    }

```


texts: How can I manually construct a right-handed orthographic projection matrix?

texts:
I need the formula to create a orthographic projection matrix. I am using GLM math libary and DirectX11. The reason I cannot use GLM to create it is because the NDC spaces are different between DX11 and OpenGL, thus I need to manually create one.

I am however using right-handed coordinate system and column-major matrices, just like GLM.

This is my attempt, but I get wrongly images when rendering with it, so it is probably wrong. I am using it for cascading shadow maps, and from the graphics debugger, I probably need to mirror it, but it is just a guess. Any ideas?

Mat4 OrthographicMatrix(const float left, const float right, const float top, const float bottom, const float zNear, const float zFar)
{
    Mat4 ret(1.0f);

    ret[0][0] = 2.0f / (right - left);
    ret[1][1] = 2.0f / (top - bottom);
    ret[2][2] = 1.0f / (zNear - zFar);
    ret[3][0] = (left + right) / (left - right);
    ret[3][1] = (top + bottom) / (bottom - top);
    ret[3][2] = (zNear) / (zNear - zFar);

    return ret;
}


texts: How does having the Debugger change the game execution on an XBOX 360?

texts:
So I thought my issue was relating to the difference between a Debug and a Release build as per this question: What's the difference between a "Release" Xbox 360 build and a "Debug" one? but I've since found that if I go ahead and build a Creators Club version of the game using a Debug build and deploy to the XBOX, I get the same experience I had with the Release version of my game.

However if I run the game from Visual Studio using F5 and having set the XBOX as the default platform, then the game runs as expected. If I change from Debug to Release and run with CTRL+F5 then the game also works as expected.

How would running the game with the debugger attached change the results I am getting in game? Is there any way that I can use the same approach or change the default compilation of the game so that I can use this approach to release my game?


texts: Make Dropdown adhere size of its contents

texts: When Dropdown is placed inside a panel with ContentSizeFitter/LayoutGroup with preferred size set, it appears to take just 10x10 units, no matter what the contents are. How can I make Dropdown's preferred size adhere size of its contents, i.e. size of its biggest option?


texts: DirectX is the camera a point or a plane?

texts:
I've built an application in SlimDX using an orbit camera. Currently I treat the position of the camera as a singular point in space.  I've noticed my projections from 3D space to 2d space are off by a small amount. The further something is from the center of the view, the more the projection to 2D space is off.

Should I be thinking of the camera position as a point in space, or as a plane?  Treating the camera as a plane would be conceptually similar to saying the lens of the camera has the same height & width as the view it observes.


texts: Where can I get DirectX headers for Mingw?

texts:
I have downloaded the latest Mingw toolchain from mingw.org, but it seems DirectX headers are missing. Where can I get those?

I assume there are open source compatibility headers out there, in particular for ddraw.h, which is deprecated by Microsoft.


texts:
I'm trying to figure out where to start with getting code together to check if a shape tessellates.

An example:

Consider that the shapes cannot be rotated, just as-is. A 'compound' shape (as seen in the pic - second and third shapes) will have a series of co-ordinates that make them up.

Where could I begin to getting the computer to figure out if they can tessellate?

I'm using c# & unity. Thanks in advance.


texts: How can I implement large moving "colossus" characters that also act as environmental objects?

texts:
I'm curious how enormous characters that act both as entities and environments are implemented.  I'm thinking of characters like in Shadow of the Colossus which move, but which the player can also move on.

It seems these objects would be created as characters, rigged like any character would be with their various animations, but they would also need to be usual physical surfaces that we can walk on. Considering the way characters are handled compared to how static environment is handled physically in most game engines, this could prove problematic, and added to that is the problem of size.

So, generalising over engine details (but assuming you have a generic physics/character engine, e.g. Unity/Unreal) what approach should be taken?

Also, screenshot:

As you can see in this screenshot, the colossus is really big, and the player can walk on it and climb on some parts of it (hairs mostly)

And a video of a boss fight here which really shows what this gameplay is all about


texts: How to avoid Singleton/Statics/Injection in my puzzle game

texts:
I am developing a puzzle game in java with swing.
Purpose of the game to find the  all the correct pairs on the board without ur lifes reaching 0 , preety simple etc.

I have a class My_Button which extends JButton.
My game consists of 6 type of Tiles (square , circle etc)
All these type of tiles extend My_Button class and implements my_Actions interf.
my_actions interface has some methods, not crucial for the question.
I have my_board class which holds arraylist with buttons , initializes buttons, fills the array , checks for validity between pairs , delete pairs etc.
It contains all the game functions in a way.

Now my main problem is the actionListener implementation and logic.
In my ActionListener in simple words i add the button that got clicked to a temp array and when 2 buttons got added to this array i do certain actions.
for example: (pseudo)

ActionListener{
my_board.posible_pair.add(this);
my_board.click_counter++;
my_board.check_game_state();
}

!check_game_state() runs if's and updates all the info of the game like: tries,score,check_valid_pair,delete etc.!

Now my thinking and my  question laid out:

First case:
If i make every Tile class implement actionListener like the example above ill have to make my_board singleton to be able to have acess to all this variables outside of the my_board class.

Second case:
even if i implement actionListener inside the my_board class and add the actionlistener through anonymous classes to my button after i add them to the board it gives error ofc because the scope gets weird.

Third case:
full static class and variables, its really bad programming so id like to avoid.

QUESTION:

--How i can reconstruct my project to manage these problem without singletons/static ?

--How i can avoid putting the check_game_state() inside the ActionListener which also is a bad practice?

I checked infinite number of qestions on this forum , google , stackoverflow but nothing really helps on the specifics.
I have developed simmilar games before but i always follow the singleton tecqniques and id like to change that.


texts: Is my skeletal animation algorith/representation correct?

texts:
I'm representing a rig (skeleton) as:

A root pivot point, with a position (Vector3) and a direction (Vector 3).
A tree of bones, where each bone is a struct with a rotation (Quaternion) and a length (Float).

I'm projecting the positions of the joints by:

Start with the root pivot point and the root bone, rotate it by bone.rotation and project it by bone.length across its new direction. The new pivot is a pair of position, direction.
Repeat for each child bone.

Is that correct?


texts: How to generate AABB, OBB & Sphere from polygon soup

texts:
How can I generate AABB, OOBB and Sphere from a polygon soup, where the bounding volumes are defined as follows:

AABB should be specified by min(x,y,z) max(x,y,z)
OOBB should be specified by min(x,y,z) max(x,y,z) and a quaternion for rotation
Sphere is specified as position(x,y,z) and radius


texts: Move Player on Mouse click in update loop

texts:
I'm trying to move my player when clicking the right button on the mouse. The problem is that my player is just standing and "shaking" in the top left corner.

Any idea?

package game;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;

import javax.swing.JLabel;

public class Player {
    private Rectangle playerRec;
    float x, y;
    PlayerJLabel playerJLabel;
    int worldX = 800;
    int worldY = 600;
    int targetX, targetY;

    public Player(int posX, int posY, int size){
        playerRec = new Rectangle(posX, posY, size, size);
        x = posX;
        y = posY;

        playerJLabel = new PlayerJLabel();
        playerJLabel.setBounds(0, 0, 800, 600);

        Game.screen.add(playerJLabel);
    }

    public void update(float timeSinceLastFrame){

        if (Mouse.isMouse(MouseEvent.BUTTON3)) {
            targetX = Mouse.getX();
            targetY = Mouse.getY();
        }

        if ((targetX != 0 && targetX != x) && (targetY != 0 && targetY != y)) {
            float dx = (float) (targetX-x);
            float dy = (float) (targetY-y);

            // normalize
            float length = (float) Math.sqrt(dx*dx+dy*dy);
            dx/=length;
            dy/=length;

            // add speed
            x = dx * timeSinceLastFrame * 300;
            y = dy * timeSinceLastFrame * 300;

            // Move the player
            playerRec.x = (int) x;
            playerRec.y = (int) y;

        }

    }

    private Rectangle getRec(){
        return playerRec;
    }

    public class PlayerJLabel extends JLabel{
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.RED);
            g.fillRect(getRec().x, getRec().y, getRec().width, getRec().height);
        }
    }

}

Edit: I have a GameState method which calls the player update() method and a repaint() method which repains the whole scene.

GameState update method:

@Override
public void update(float lastFrame) {
    player.update(lastFrame);
}

Game repaint method:

public void repaint() {
            // screen is a JFrame Object
    screen.repaint();
}

Main class

package game;

public class Main {

    public static void main(String[] args) {
        Game game = new Game("Mein erstes Spiel", 800, 600);

        long lastFrame = System.nanoTime();

        while(game.isRunning()) {
            long thisFrame = System.nanoTime();
            float timeSinceLastFrame = ((float)(thisFrame-lastFrame))/100000f;
            lastFrame=thisFrame;

            game.nextState();
            game.update(timeSinceLastFrame);
            game.repaint();
        }

    }

}

Update 2:

I updated my code to:

        // Move the player
        x = playerRec.x += (int) (dx * timeSinceLastFrame * 500);
        y = playerRec.y += (int) (dy * timeSinceLastFrame * 500);

My player is moving, but not at the same speed and not very smooth: http://screencast.com/t/pv5M9Un4QhFR


texts: How to reference nameof private serialized field in unity custom inspector

texts:
I'm running into a problem that I think will seriously affect maintainability down the road, so I'd like to figure it out now before it becomes a problem.

I've been starting to use private [SerializeField] rather than public fields to avoid other scripts manipulating internal data.Then, for scripts referencing the component's fields through properties in an interface.

So in a MonoBehaviour I have something like:

[SerializeField]
private float speed;

public float Speed => speed; //implements interface

However, In my custom inspectors, I now can't use

serializedObject.FindProperty(nameof(MonoBehaviourScript.speed));

This is because it doesn't have access to the private member speed. I now have to reference it by string name:

serializedObject.FindProperty("speed");

This worries me since now I can't easily rename the speed field. Also, Making both speed and Speed public is scary since then speed can be manipulated from outside.

Is there a good way to protect myself from external modification, while keeping refactoring easy?


texts: How to calculate the enemy to arrive in the middle of cell?

texts:
The game is 2d, and the genre of this game is tower defense.

I managed to get it moving to the cell and arrived in the cell. But it never arrives at the middle of a cell.

Here's what I did...

public Enemy plotPath(Cell start, Enemy enemy, float deltaTime) {

    //Direction
    int directionx = 0;
    int directiony = 0;
    if(enemy.position.x < start.position.x) {
        directionx = GraphConstants.X_DIRECTION_RIGHT;
    }
    else if(enemy.position.x > position.x){
        directionx = GraphConstants.X_DIRECTION_LEFT;
    }
    else {
        directionx = GraphConstants.X_DIRECTION_NA;
    }

    if(enemy.position.y < start.position.y) {
        directiony = GraphConstants.Y_DIRECTION_DOWN;
    }
    else if(enemy.position.y > start.position.y){
        directiony = GraphConstants.Y_DIRECTION_UP;
    }
    else {
        directiony = GraphConstants.Y_DIRECTION_NA;
    }
    enemy.position.add(velocity.x * deltaTime * directionx, velocity.y * deltaTime * directiony);

    return enemy;
}

Then, the game would calculate the distance between the enemy and a point. If it is zero, then remove the cell from the enemy's list of cells (A*star algorithm). The enemy position would be calculated by vector addition.  It looks like the enemy's position wouldn't never arrive at the point.

Vector addition

public Vector2 add(float x, float y) {
        this.x += x;
        this.y += y;
        return this;
    }

I have the enemy positioned in (-0.1f, 3.5f). The velocity of the enemy is 2f. The cell is based 1f x 1f. The middle of a cell is (0.5f, 3.5f);

I logged the calculations, here's the calculations -

-0.1    3.5
0.03482666  3.5
0.04385986  3.5
0.054541014 3.5
0.072546385 3.5
0.106665045 3.5
0.14072266  3.5
0.17520753  3.5
0.21030274  3.5
0.24313965  3.5
0.27927247  3.5
0.31210938  3.5
0.3467163   3.5
0.3805298   3.5
0.41867676  3.5
0.44882813  3.5
0.486792    3.5
0.5188354   3.5

I used distance between the enemy and the middle of a cell -

if(position.dist(start.position) == 0) {
                path.remove(0);
 }

I'm thinking the velocity * deltaTime * direction isn't correct.  I tried to google around but couldn't find the solution.  Any ideas?


texts: Restrict the rotation of the camera using button

texts:
I've been trying to limit the Y-axis of the camera rotation but I'm out of depth until now. I'd looked up many tutorials and I found the clamping method, but I seem can't get it to work on my code, and all the tutorials I found is using them in Update(), while I'm using a button to rotate the camera. Here's the code:

public void RotateLeft()
{
    cameraY = Mathf.Clamp(cameraY, minAngle, maxAngle);
    if(cameraY >= minAngle)
    {
        Camera.main.transform.Rotate(0,-cameraY,0);
    }
}
public void RotateRight()
{
    cameraY = Mathf.Clamp(cameraY, minAngle, maxAngle);
    if(cameraY <= maxAngle)
    {
        Camera.main.transform.Rotate(0,cameraY,0);
    }
}

Does clamping works outside an Update()? What am I missing?

Thank you in advance.


texts: App icon on phone looks squished in Unity

texts:
I am working on a 2D platformer. And I am alomost finished!! I am trying to work on adding the app icon. The icon that you would see on your phone. I imported the picture and added it to player settings. But when I put my game on my phone the icon looks squished. These are the settings that I imported it on

Texture Type (sprite 2D and UI)

sprite mode Single

Filter mode Blinear (not pixel art)

Here is a link to a screen shot on my phone of the icon

https://www.dropbox.com/s/jbgciscda7nykjd/app%20on%20phone.png?dl=0

Ok I am getting closer to an solution now. My first problem was that the image was not square as staed below. But now the image is smaller compared to the rest of the app icons. the resolution of teh image now is 2000X2000

Here is a screenshot of what it looks like now

https://www.dropbox.com/s/t45vylzpi3chnsf/App_Icon_2.png?dl=0


texts: Unity C# 2D Platformer Main Camera should stop on sides of level

texts:
I've been working on a 2D Platformer and i succeeded in setting up a script for my Main Camera to follow my Player gameobject using transform positions.

Now when my character is near the sides (or ends) of my level, it's showing dead space, blue space if you will. I want my camera to stop when it reaches the edges of my background sprite(end of level).

Here's my script that is attached to the Main Camera so far:

using UnityEngine;
using System.Collections;

public class CameraSmoothFollow : MonoBehaviour
{

public GameObject cameraTarget; // object to look at or follow
public GameObject player; // player object for moving

public float smoothTime = 0.1f;    // time for dampen
public bool cameraFollowX = true; // camera follows on horizontal
public bool cameraFollowY = true; // camera follows on vertical
public bool cameraFollowHeight = true; // camera follow CameraTarget object height
public float cameraHeight = 2.5f; // height of camera adjustable
public Vector2 velocity; // speed of camera movement

private Transform thisTransform; // camera Transform

// Use this for initialization
void Start()
{
    thisTransform = transform;

}

// Update is called once per frame
void Update()
{
    if (cameraFollowX)
    {
        thisTransform.position = new Vector3(Mathf.SmoothDamp(thisTransform.position.x, cameraTarget.transform.position.x, ref velocity.x, smoothTime), thisTransform.position.y, thisTransform.position.z);
    }
    if (cameraFollowY)
    {
        // to do
    }
    if (!cameraFollowX & cameraFollowHeight)
    {
        // to do
    }

}

}


texts: Is it normal in skeletal animation to NOT consider the translation component in bone transform matrices?

texts:
I'm using assimp to load a model, and DirectX11 and DirectX ToolKit to render it.

In the document of DirectXTK's IEffectSkinning, it says:

  As an optimization, SkinnedEffect and DGSLEffect assume that all the
  matrices are affine transformations, and that the final column is (0 0
  0 1). This means that the value of the last column is effectively
  ignored when set into the constant buffer containing the bone
  transformations (i.e. the shaders use float4x3)

Is this the convention when implementing skeletal animation ?

Does it have negative repercussions ? If it does, what are they ?
Do some animated models require the translation components to be considered?


texts: Destroying instantiated objects stored in a list not working in Unity

texts:
I have a GameObject with associated a javascript. I have defined a private variable like this:

    private var objects = new Array();

now in the Update method I instantiate new objects and push each obtained reference into the private array like this

    objects.push(newObjectInstance);

when a certain event occurs (i.e. the user press a button in the GUI) I'd like all the objects to be destroyed. I am doing that like this

    for (var i =0 ;i<objects.length; i++){
        Destory(objects[i]);
    }
    objects.clear();

The problem is that although the objects are removed from the array they remain displayed in the Game. What am I doing wrong?


texts: How can I express Logarithmic and Arithmetic spirals as segmented cubic bezier curves?

texts: I am creating cubic bezier curves using this code from another question I asked. I would like to know how I can express Logarithmic and Arithmetic spirals as segmented cubic bezier curves.


texts: How to Convert DirectX Texture2D to a DXGI Surface for WPF Rendering?

texts:
I have an image in my WPF application that uses a D3DImage to render DirectX content. On the DirectX side I render everything to a Texture2D using SharpDX (a C# DirectX wrapper), but I'm not sure how to convert the rendered texture to a D3DImage.

I found the D3DImage.SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer) method, but that requires the texture to be a DXGI Surface. Here's the code I'm working with:

// renderTexture is a Texture2D that serves as the renderTarget for the DirectX content
// d3dimg is the D3DImage that WPF uses

d3dimg.Lock()
d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9,
                     renderTexture.QueryInterface<Surface>().NativePointer);
d3dimg.Unlock();

But for some reason, the SetBackBuffer function call throws an exception saying that the "specified cast is not valid," even though I'm not doing any casts here (as far as I can see). What am I doing wrong?


texts:
I'm developing simple Android game in OpenGL ES 2.0 and the development stage is getting closer to publishing game on play store, but I'm still unsure about EGL context behaviour on different devices.

GLSurfaceView Android documentation says:

  A GLSurfaceView must be notified when the activity is paused and resumed. GLSurfaceView > clients are required to call onPause() when the activity pauses and onResume() when the > activity resumes. These calls allow GLSurfaceView to pause and resume the rendering
  thread, and also allow GLSurfaceView to release and recreate the OpenGL display.

Problem is that I don't want my game to recreate and reload all textures after every activity change or home button press, it really breaks user experience, so I don't invoke onPause and onResume methods on my GLSurfaceView in order to not loose my OpenGL assets. This approach works perfectly on some devices I've tested - Nexus 7 and Lenovo Yoga Tab 2, but I'm afraid it may cause some unexpected results on some specific devices. What are the drawbacks of this approach? Can I workaround EGL context lost in some other way?

I've read many resources about this subject but most of them are related to Android in version 2.x and were written 3-4 years ago. I'm targeting minimum API 16 which is Android 4.1.x, so maybe there are some new ways to work this out?

I did use some custom GLSurfaceView implementations as the one from Chris Pruett's game Replica Island but as I've said those workarounds were targetting older Android versions and still they didn't let me solve my problem. I was also trying using setPreserveEglContextOnPause method on GLSurfaceView but it doesn't seem to work.


texts: Why has my object detached itself from the parent?

texts:
I made an two objects in blender, animated them, and saved them.

Firstly, when I reloaded them, half of the animations I created had disappeared, which is annoying itself but the real annoyance is that the item, a sword, detached itself from the parent, the character. I exported as fbx but for some reason it is completely seperated.

Also, my mesh has holes everywhere. Is this normal for untextured objects?

  How it should look

  Whats actually happening


texts: Different iPhone screen resolutions and game graphics

texts:
We are developing a 2D game for iPhone using cocos2d-x. The artists are drawing the raster graphic for a resoluion of 640x960. For older iPhone devices, those that have a resolution of 320x480, should we provide a completely new set of graphics, to be adapted to the smaller resolution?
I was thinking of simply scaling the whole scene of a factor of 2. That would save us the time to write a specific set of graphic elements for the smaller resolution.
What is the best practices? How do you guys handle the different screen resolution w.r.t. the graphic part of the game?


texts: Sound not playing on Windows XP - SoundEffect or Song: Monogame

texts:
*Solution:* I have a RealTek ALC888. I solved this (OpenAL) by disabling hardware acceleration on my sound (Control Panel > Sound > Advanced, disable acceleration).

I'm trying to integrate sound into my Monogame game. I don't have the content pipeline hack -- just straight Monogame (Beta 3) at this point.

(I tried adding the content pipeline, but ran into some issues.)

I added a .wav file to my /Content directory, and I can create and instantiate both SoundEffect and Song classes. However, both show durations of 00:00:00 (on a ten-second long file), and neither plays.

I can call LoadContent without any issue. But when I call Play, nothing plays.

I've tried a couple of different sounds, and different formats (MP3 and WAV) to rule that out. Only WAV seems to even load without crashing out, but it doesn't play.

This issue only occurs on Windows XP. I tested it on a Windows 7 laptop, and the sound plays fine.

Edit: I opened a MonoGame issue to track this, and it includes several more details.


texts: How can I draw image and label on another image

texts:
The idea is to make a shop structure like in Arrow game from KetchApp.

As I think I need to create ShopCell class, add objects of this class to Table, then add this Table to ScrollPane(so I can scroll my shop). But not really sure how to implement this.

The main problem for me is to create ShopCell class. It seems reasonable to start this way:

public class ShopCell extends ImageButton {

But how can I draw a Texture (item image) and Label (price) on another Texture (background)?


texts:
I have successfully set up a billboard shader that works, it can take in a quad and rotate it so it always points toward the screen. I am using this vertex-shader:

void main(){
vec4 tmpPos = (MVP * bufferMatrix * vec4(0.0, 0.0, 0.0, 1.0)) + (MV * vec4(
    vertexPosition.x * 1.0 * bufferMatrix[0][0],
    vertexPosition.y * 1.0 * bufferMatrix[1][1],
    vertexPosition.z * 1.0 * bufferMatrix[2][2],
    0.0)
);

UV = UVOffset + vertexUV * UVScale;
gl_Position = tmpPos;

BufferMatrix is the model-matrix, it is an attribute to support Instance-drawing.

The problem is best explained through pictures:

This is the start position of the camera:

And this is the position, looking in from 45 degree to the right:

Obviously, as each character is it's own quad, the shader rotates each one around their own center towards the camera. What I in fact want is for them to rotate around a shared center, how would I do this?

What I have been trying to do this far is:

 mat4 translation = mat4(1.0);
    translation = glm::translate(translation, vec3(pos)*1.f * 2.f);
    translation = glm::scale(translation, vec3(scale, 1.f));
    translation = glm::translate(translation, vec3(anchorPoint - pos) / vec3(scale, 1.f));

Where the translation is the bufferMatrix sent to the shader. What I am trying to do is offset the center, but this might not be possible with a single matrix..?

I am interested in a solution that doesn't require CPU calculations each frame, but rather set it up once and then let the shader do the billboard rotation. I realize there's many different solutions, like merging all the quads together, but I would first like to know if the approach with offsetting the center is possible.

If it all seems a bit confusing, it's because I'm a little confused myself.


texts: Universal Tween Engine: are accessor hierarchies possible?

texts:
Background: I'm using Universal Tween Engine, which allows generic accessors to be implemented to permit tweening of arbitrary atttributes.

I have a hierarchy of game entity classes that share a common base class (say, Entity). I've implemented a TweenAccessor on Entity for basic attribute tweening (position, color, rotation, etc). I'd also like subclasses of Entity to be able to implement their own, more specialized tweens, in addition to having access to Entity's base set of tweens. However, it seems that when I register a class and a subclass accessor, the base class' accessor is never called during tweening.

For example, assume base class Entity and subclass Bullet:

Tween.registerAccessor(Entity.class, new EntityAccessor());
Tween.registerAccessor(Bullet.class, new BulletAccessor());

Attempting to do any of the tweens defined in EntityAccessor will not be called -- BulletAccessor will always be used instead. Is there any way to configure Universal Tween Engine to work in such a hierarchical fashion?


texts: is there a way to check if an animatorcontroller has a parameter?

texts: With mecanim, if you try to set a parameter that doesn't exist, it logs a warning. It doesn't throw an exception or return null or anything useful like that.  So if I set a parameter very often that doesn't exist, a lot of CPU time is spent logging warnings. How can I tell if a parameter exists in an animatorcontroller?  It would be great if there was a method like ProceduralMaterial.HasProceduralProperty (which allows you to check if the ProceduralMaterial has the property in question).


texts:
I'm trying to implement 5.1 surround sound in my game. I've set Unity's AudioManager to a default of 5.1 surround and loaded in a 6 channel audio clip that should play a sound in each of the different audio spots.

However, when I go to run my game, all I get is flat sound coming out of my front two speakers. Even then, these don't play the sound they should (front speaker should play "front speaker" right should play "right speaker" and so). Both speakers just end up playing the entire sound file.

I've tried looking to see if there is a parameter that I have missed, but information on how to set up 5.1 sound in Unity is lacking (or my google skills aren't that good) and I can't get it to work as intended. Could someone please either tell me what I'm missing, or point me in the right direction?

My audio source is situated at point (0, 0, 0) with my camera also being in the same point. I've moved about the scene but the same thing happens as I've already described.


texts:
I am developing 3D game , the main camera is child of player.

When player jumps camera too gets move up with player as its child of player.Is there anyway to stop this behavior?

The only thing I can guess is to make camera separate gameobject and let it follow player

EDIT
After applying @Everless Drop 41's script, here is what main problem arises


texts:
does anyone know how to export an explosion modifier in blender and use it in panda3d?
I have tried a lot of settings but not sure how to do it, all I want to do is see a mesh explosion in panda3d that iv already created in blender but don't seem to export to panda3d or I am doing it wrong.
any help would be great.
thank you


texts:
How do people making 2D games maintain a consistent scale for everything in their game?

Say I'm coding an RPG. A house needs to be proportionally bigger than a person; an item, smaller. Everything from enemies to locations to people.

Is there a technique to doing this -- like picking a single item like the player sprite and scaling everything relative to that?


texts: Determine the stride of a DirectX Texture2D line?

texts:
Is there a way to determine, or preferably calculate/predict, the the stride of a line of a DirectX 11 Texture2D resource when using SharpDX?

(E.g. Can we say the stride of a line is always a power of 2?)


texts:
I have created a simple player control. I have used "Vertical" and "Horizontal" axes as input to move. There is a character controller and I used this to move my player. But I don't know how to add a force as jump with space input. I am new to game development. Please help me to learn this. This is my script,

public class PlayerControll : MonoBehaviour
{
    public Animator anim;
    public CharacterController characterController;
    public Rigidbody rb;
    public float Speed;
    public float Direction;

    Vector3 moveDir = Vector3.zero;
    float speedwalking = 8;
    float gravity = 8;

    void Start()
    {
        anim = GetComponent<Animator>();
        characterController = GetComponent<CharacterController>();
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
        if (characterController.isGrounded)
        {
            anim.SetBool("Grounded", true);
            if (Input.GetButton("Vertical") || Input.GetButton("Horizontal"))
            {
                Speed = Input.GetAxis("Vertical");
                Direction = Input.GetAxis("Horizontal");
                anim.SetFloat("Speed", Speed);
                anim.SetFloat("Direction", Direction);
                moveDir = new Vector3(Direction, 0, Speed);
                moveDir *= speedwalking;
                moveDir = transform.TransformDirection(moveDir);
                characterController.Move(moveDir * Time.deltaTime);
                moveDir.y -= gravity * Time.deltaTime;
            }
            else
            {
                anim.SetFloat("Speed", 0);
                anim.SetFloat("Direction", 0);
            }
        }
        else
        {
            anim.SetBool("Grounded", false);
        }
    }
}


texts: Free camera navigation and pre-defined locations

texts:
I have an interactive scenery app written in Unity, where users can freely navigate the camera through the scene. What I want to do now, is to let user automatically fly to some "hotspots" with a single key stroke, while still allowing the users to navigate manually.
I tried Animation, but with it, auto-fly and manual navigation are mutually exclusive - I have to disable one in order for the other to work.
Right now, I'm attempting the fall-back solution, where I create some empty game objects with special scripts attached, so that when public script functions are invoked, the game object animates the camera to a pre-defined transformation.
My question being: is there a better solution than my fall-back?


texts: How to optimize this branching instruction?

texts:
I have an outline shader, which samples my texture 8 times to compute the outline.

The problem is, that there's transitional alpha values between picture and background. To cut them off I'm using the following function instead of just sampling my texture by calling texture2D().

vec4 texSample(sampler2D sampler, vec2 pos)
{
    vec4 color = texture2D(sampler, pos);

    if (color.a < 0.5)
    {
        color.a = 0.0;
    }

    return color;
}

The question is: are there any ways to optimize this check or even avoid it at all?


texts:
I have two classes Circle and Square which derive from an abstract base class Shape.

A Shape*array stores pointers to the Circle and Square objects (which include their random position in a 2D grid).

The objective is to determine which shapes in the array overlap and the objects themselves should contain the methods to calculate this. For example, the Square class would have methods: bool overlapsWithSquare(Shape s) and bool overlapsWithCircle(Shape s).

My idea is to construct two for loops which compare each and every shape in the array, however, how would my program know which method to call upon as we don't know what sub-type each Shape object is?

If the actual type was known, I could have two virtual methods in each object, bool overlaps(...) with different parameters Square s and Circle c.


texts: GLSL - Overlap shapes generated by the same function with custom size/color

texts:
I'm trying to make a ui button shader by overlaping a rounded rectangle on another rounded rectangle but with different size and gradient color. This way I'll have a small outline of a color (e.g. grey) and the body with a grey-ish gradient.

This is how my fragment code looks so far:

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;

const float PI = 3.14159265;

// from http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
float rect( vec2 p, vec2 size, float r ) {
    return length(max(abs(p)-size+r,0.0))-r;
}

void main() {
    vec2 halfRes = 0.5 * u_resolution.xy;
    float aspect = u_resolution.y/u_resolution.x;
    // compute box
    float b = rect(gl_FragCoord.xy - halfRes, halfRes, 30.0);
    b *= rect(gl_FragCoord.xy - halfRes, halfRes * vec2(0.99, 0.96), 30.0);

    // colorize (red / black )
    vec4 c = mix( vec4(0.326,0.603,1.000,1.000), vec4(0.0), smoothstep(0.0, 13.264,b) );

    gl_FragColor = c;
}

You can modify it directly here by cp http://editor.thebookofshaders.com/

EDIT: I've managed to get the border, now I'll only need to fill the hollow..


texts: How best to structure/manage hundreds of 'in-game' characters

texts:
I've been making a simple RTS game, which contains hundreds of characters like Crusader Kings 2, in Unity. For storing them the easiest option would be to use scriptable objects, but that isn't a good solution as you cannot create new ones at runtime.

So I created a C# class called "Character" which contains all data. Everything is working fine, but as the game simulates it constantly creates new characters and kill some characters (as in-game events happen). As the game continuously simulates it creates 1000s of characters. I added a simple check to make sure a character is "Alive" while processing its function. So it helps performance, but I can't remove "Character" if he/she is dead, because I need his/her information while creating the family tree.

Is a list is the best way to save data for my game? Or it will give problems once there are 10000s of a character created? One possible solution is to make another list once the list reaches a certain amount and move all dead characters in them.


texts: Creating Compute Shaders throws E_INVALIDARG exception in SharpDX

texts:
I've recently been working on a small helper for creating and using compute shaders in C# along with Monogame/XNA. My end goal is simply to have compute shaders working in C#.
My main issue is as such:
   var result = SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile(filepath, "CSMain", "cs_5_0", ShaderFlags.Debug);
   if (result.ResultCode.Failure)
      throw new Exception($"HLSL Compilation failed with the code: [{result.ResultCode.Code}] and message: [{result.Message}]");
   shader = new SharpDX.Direct3D11.ComputeShader(device, result.Bytecode);

Calling the constructor on the ComputeShader class throws the error: "HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect." (Of type SharpDXException). The device is obtained via Microsoft.Xna.Framework.Graphics.GraphicsDevice.Handle casted to a D3D11 Device.
Call Stack:

Anyone know how to fix this? Or is this just something I'll have to find some new way of doing?
NOTE:
The fact that I went down the Monogame-DirectX + SharpDX route is largely incidental, but I don't seem to have many options - something like Vortice.Windows, which aims to replace the now abandoned SharpDX, doesn't appear to have compute shader support. While I wouldn't mind using OpenGL, and would be happy with being recommended working .Net Core OpenGL binding libraries (Vulkan would probably be way over my head), that type of question isn't accepted here, but I'm aware it may be the better option.


texts: How should I show shared resources during a Shared Resource game in the Galaxy Editor?

texts:
One of my favorite ways to play the original StarCraft was in a "Team" game.  In this game type, multiple players on the same "team" would share control, resources, supply, and even the same starting location.  It was like playing as 1 player, only 2 humans were controlling it.  It was a lot of fun.

I want to do something very similar in StarCraft 2, but I need to create a custom map in the Galaxy Editor to do it.

I found the editor can quite easily emulate this behavior.  There is a Trigger action "Set Alliance for Player Group" to "...treat each other as Ally With Shared Vision, Control, And Spending."  To use this, I create units for only 1 of the players, and then set all players to be allied with each other in this way.  All the other players get no units and no resources.  This makes it so 1 player is the actual owner of all the units and everyone else is tagging along with full control.

This nearly works! The problem is that if I am not the actual owning player, I can't actually see how many minerals/gas/supply the team has.  This makes it pretty difficult to build stuff.

What would be the best way to display to the other players how many Minerals/Gas/Supply the team has?


texts: XNA - Efficient way to get pixel color from rendertarget2D

texts:
I'm stuck with a framerate perf down with getData from a rendertarget, what's your idea, what are the other options I can use ?

I explain my problem :
I'm making a board game, the objects or monsters are overflow the board rooms,
I use kryton framework to manage light sources, krypton is an efficient 2D pixel shader raycasting engine, I've made Hulls (#blocking light blocks) all around the rooms of my board, but the objects and monsters Texture2D were cutted by the hull shadows of the board sides... So I can't use Krypton to light my monsters

krypton give me a rendertarget of the screen which is a screen light color map
If I pick color from center board square, It give me the perfect color to draw my monsters, but with getData it's reaaaallllyy slow.

I'm using this code :

  public Color GetLightColorOnPoint(Vector2 position)
          {
              Vector2 v = WorldToScreen(position);
              return lightManager.GetLightColorAtPoint((int)v.X, (int)v.Y);
          }

  public Color LightManagerClass.GetLightColorAtPoint(int x, int y)
          {
              Color[] lightPixel = new Color[ 1 ];
              Rectangle sourceRectangle = new Rectangle(x, y, 1, 1);
              //rendertarget2D
              this.krypton_SolShadow.mMap.GetData(0, sourceRectangle, lightPixel, 0, 1);
              return lightPixel[0];
          }

(I don't understand well pixel shaders and I don't think you can pick a board square center color and apply it to an entire monster texture2D with the correct  offset/zoom of a camera 2D of course and variable texture2D size (a giant vs a rat texture2D size))

with 40 GetData (40 monsters on screen) per draw, the FrameRate slow down to 7 FPS :(, please help


texts: Scaling sprite velocity / co-ordinates in Android

texts:
I'm trying to find the answer to a question that I've had for a long time, but am having trouble finding it! I hope someone can help :-)

I'm trying to find information on how to scale sprite velocity / movement / co-ordinates.

What I mean by this is how do I get a sprite to move at the same speed relative to the screen size / DPI so that it takes the same amount of real-time to get from one side of the screen to the other?

All of the posts pertaining to sprite scaling that I can find on the various forums relate to the size of the sprite, but this part of it I'm OK with so far, it's just that when I move a sprite, it kind of gets there at different speed depending on the dpi / resolution of the device. I hope I'm making sense.

This is the code I have so far, instead of using explicit amounts, like 1, I'm using something like the following:

platSpeedFloat= (1 * (dpi/160)); //Use '1' so on an MDPI screen, the sprite will move by 1 physical pixel

Then basically what I'm doing is something like this: (all varialble previously declared)

platSpeedSave+=platSpeedFloat; //Add the platSpeedFloat value to the current platSpeedSave value

platSpeed=(int) platSpeedSave; //Cast to int so it can be checked in the following statement

if (platSpeed==platSpeedSave) //Check the casted int value to float value stored previoiusly

{floorY=floorY-platSpeed; //If they match then change the Y value

platSpeedSave=0;} //Reset

Would be grateful if someone could assists - hope I'm making sense. The above doesn't seems to work the sprite moves 'faster' on lower DPI screens.

Thanks


texts: lightmap equivalent with realtime shadow

texts:
i'm using in Unity free edition.

I try to bake a lightmap which equivalent feeling with Unity's real time light map and shadowing, like left figure.

But the result is the right figure.

How can i set a paremters of lighting window to get result like left figure?

--added--

here's all of screenshots.


texts: Playing part of a sfx audio file in HTML5 using WebAudio

texts:
I have compiled all of my sound effects into one sequenced .ogg file. I have the start and stop times for each sound effect. How do I play the individual effects? That is, how do I play part of an audio file.

More specificially, I've created a dictionary

{
    'sword_hit':
    {
        src: 'sfx.ogg',
        start: 265, // ms
        length: 212 // ms
    }
}

that my play_sound() function can use to look up 'sword_hit' and play the correct audio file at the correct start time for the correct duration. I simply need to know how to tell the WebAudio API to start playing at start ms and only play for length ms.


texts: Build a Cube/Prism from other varied Cubes/Prisms

texts:
I'm wondering, are there any algorithms or theories in existence (that aren't patented/proprietary/protected) that would take a series of 3d rectangular prisms (or cubes but a cube is a prism) and stacks them in such a way as they form another cube or fit together in the best possible format?

I'm working on logistics software at work and this might be an interesting feature.

I'd also accept good articles that discuss the theory of this, if an algorithm isn't already available for me to look at and study.


texts: For a typical windows phone game where storage files could contain high scores or in-game currency data, how does one go about protecting these files from user tampering?


texts: How to do you separate or do you separate a Player/Non Player movement, action, behavior states in one or more component?

texts:
Assume we are using Finite State Machine, what is the best way to organize states?

Given I have current StateComponent, all states are here.

MOVEMENT (Parallel) - Can be for player and non player
        [stand, walk, run]
        [forward, backward]
        [left, right]
        [jump, attack]
BEHAVIOR - For non player only
       [patrol, follow, chase, evade]


texts: How do I program a custom FPS overlay in Ogre3D?

texts:
I want to make a frames per second and debugging info overlay, similar to the one in the bottom of the following image, but without using SDKTrays or OIS.

I also want to be able customize its look, by changing its font and background color. How do I program something like this, in C++?


texts: can no longer drag post processing profile into CenterEyeAnchor in OVRCameraRig -> TrackingSpace, is there an alternative step?

texts:
The video https://youtu.be/gh4k0Q1Pl7E?t=120 shows a step where I need to drag a newly created post-processing profile into the CenterEyeAnchor section. I am aware this video is the demo using an older version of the Post Processing Stack package, so one can not longer add it as a component into anywhere. But I do not know an alternative to achieve the same step?
Is it not even necessary?
By not going with step, I got all darken objects (but have some light on some part of the objects if I add some sort of light) But still its very different than the complete light achieved in that video.

What I have

What the video show

I follow pretty much 100% in the video until that step adding post-processing profile setup.

I am very noobie in Unity.

I am using

Unity 2019.3.14
Post Processing 2.3.0


texts: Call Unity3D coroutines from a scripting language

texts:
I created a simple scripting language to use on a Unity3D game. My parser generates an AST with nodes for every type of operation, and to run the script all I need to do is call Execute() on the root of the tree, which propagates recursively to every node in it.

To run functions from my script, I first create a dictionary linking function names to delegates, and the function node simply needs to look it up run it.

But I have ran into a problem now... Some of the functions I need to call from the script are coroutines that take time to execute, such as WalkTo or WaitNSeconds, and for those coroutines I need to halt the script execution until they are done.

I'm stuck on figuring a way to halt the script execution, as once I call Execute() on the root node, the script gets executed recursively all the way.

Just to provide some more context, here are some examples of a few possible types of nodes and how they operate (not the actual nodes from my language, but close enough). Some nodes simply call Execute() on their children and return nothing. Some nodes simply return values directly. Other nodes get values from their children and modify it in some way.

abstract class Node
{
    object Execute();
}

class RootNode: Node {
    List<Node> Children;
    object Execute() {
        foreach(Node node in Children)
            node.Execute();
        return null;
    }
}

class NumberNode : Node {
    int Value;
    object Execute() { return Value; }
}

class SumNode : Node {
    Node Left;
    Node right;
    object Execute() {
        return (int)Left.Execute() + (int)Right.Execute();
    }
}

class PrintNode : Node {
    Node Expression;
    object Execute() {
        Console.WriteLine(Expression.Execute().ToString();
        return null;
    }
}

class FunctionNode: Node {
    string Name;
    object Execute() {
        return SymbolTable.FindFunction(Name)();
    }
}


texts: Unable to detect continuous keypress event in SDL

texts:
I am developing a game using SDL, and am unable to do continuous motion for my object when a key is held down.

I'm calling SDL_PollEvent() to retrieve all events during a frame, and passing each resulting SDL_Event structure into this function:

void Avatar::handle_input(SDL_Event keyInput){
if( keyInput.type == SDL_KEYDOWN )
{
    //Adjust the velocity
    switch( keyInput.key.keysym.sym )
    {
    case SDLK_LEFT: Move(1); break;
    case SDLK_RIGHT: Move(2); break;
    }
}

The problem is that when I hold down the right or left arrow keys, the avatar only moves once instead of moving continuously for as long as I hold down the key.  How can I make the motion continue for as long as the key is held down?


texts: How can I defer the initialization of my level's entities until I need them?

texts:
I intend to use a level-entity-components hierarchy in my C++ game engine where a "level" is just a container for entities. However, since I'd like to setup all the levels at once (and thus all entities and components) I've stumbled upon a memory management dilemma: since only one level can be run at a time I need somehow to delay an initialization of other level's entities. How can I accomplish that?

I've considered a solution where all the levels derive from some Level base class and are initialized in the constructor when needed, but that would require creating a class with just the constructor in it for each level.


texts:
Some games have the option to let you play offline and sync with a server once you have internet again. To prevent cheating and validate if it was an authentic play, usually some sort of log of all input actions is sent and validated afterwards on the server.
In my case I would be interested in a single MonoBehaviour and having all its method calls logged with the its parameters values. Giving this input, the game result output should be the same. (There is no random involved and no physics interaction)

One way would be just a writer at the start of each method that logs the timestamp, method name and paramter
Another would be maybe something like a multi delegate inbetween that calls both my method and a writer class

Is there something build-in in Unity that does this already like an annotation for the methods I want to track or something like an audit interface?


texts:
I'm programming collision systems for a 2D game engine. The idea is that different systems can interact with each other. So one of the cases would be check collisions between axis aligned bounding box against a radius based circle collision. They both are implemented to react with its same type of collision returning me a minimum translation vector. So my approach is to combine them was to interpret the box with its bounding circle if the circle was in one of the corner outer regions of the box, and check collisions between both circles but if the circle is located in a side outer region of the box I interpret the circle with its bounding box and apply AABB collision.

The question: Is that approach, a good one?


texts: What mathematics would I need to know in order to build a 2.5D raycasting engine

texts:
I realize this is a fairly common-type question, but I've been studying Maths in my spare time, fairly slowly at that, and I really want to develop a raycasting engine like the original DOOM.

I know more-or-less the subjects / categories of Maths needed for modern 3D games, such as Linear Algebra, but I don't they all would be applicable for a raycasting engine.

Assume I am starting from the ground-up in Maths, what would I need to know? I assume Algebra, Trigonometry and Geometry would be the most important. I'm wondering if I could pull it off just with that?


texts:
I am currently working on a simple obstacle avoidance system in unity. I have a player and a school of Ai fish that are traveling in a fixed direction (Down-Right). While swimming, I want the Ai fish to keep away from the player, and also keep away from incoming obstacles. I first thought I should use a boid flocking algorithm, but it may be overkill for what I need as I am trying to limit computation to as low as possible since it will need to run on a mobile device. the fish do not need to avoid each other and they simply need to head toward the fixed direction. Other notes: I can't use unity's NavMesh system since I am using 2d physics and obstacles will be random at runtime.

My issue is that I do not know how to efficiently steer the AI when there are multiple obstacles and players in the proximity. I have something working(Below), but I am manually steering it when it gets too close but this won't work when I have multiple obstacles to avoid within their proximity. Could someone steer (ha) me in the right direction on how to approach this?

Thank You

Below is the class I made for the Ai fish:

public class FishMoveTest : MonoBehaviour {
public float Speed;
Rigidbody2D rb;
public float MinSpeed;
public float MaxSpeed;
public float DisableDistance;
private float DistanceFromPlayer;
public GameObject Player;
 Material NormalMat;
public Material CollideMat;
 MeshRenderer MeshRend;
public UnderwaterObstacle _UnderwaterObstacle;
public float AvoidDistance;
public float SteerSpeed;
float DistanceFromObstacle;
// Use this for initialization
void Awake () {
    MeshRend =  GetComponent<MeshRenderer> ();
    NormalMat = MeshRend.material;
    rb = GetComponent<Rigidbody2D> ();
    Speed = Random.Range (MinSpeed, MaxSpeed);
}

// Update is called once per frame
void FixedUpdate () {
    DistanceFromObstacle = Vector3.Distance(transform.position, _UnderwaterObstacle.Obstacle.position);
    if (DistanceFromObstacle < AvoidDistance) {
        CastObstacleRay ();
        if (MeshRend.material != CollideMat) {
            MeshRend.material = CollideMat;
        }
        if (transform.position.y > _UnderwaterObstacle.Obstacle.position.y) {
            //Move Up-Right;
            rb.velocity = Vector3.Lerp(rb.velocity,new Vector3 (0.5f, 0.5f, 0) * Speed,SteerSpeed);

        } else {
            //Move Down
            rb.velocity = Vector3.Lerp(rb.velocity,new Vector3 (0, -1, 0) * Speed,SteerSpeed);
        }
    } else {

        rb.velocity = Vector3.Lerp(rb.velocity,new Vector3 (0.5f, -0.5f, 0) * Speed,SteerSpeed);
        if (MeshRend.material != NormalMat) {
            MeshRend.material = NormalMat;
        }
    }
}


texts: Why does the following code print logs even after the game object is detroyed?

texts:
I have the following in a script attached to a game object in a unity scene. When I run this scene and press 'E', I get the following logs. (The game object is destroyed too)

In destroy
After destroy

void Update () {
    if(Input.GetKey(KeyCode.E)){
        Debug.Log ("In destroy");
        Destroy (gameObject);
        Debug.Log ("After destroy");
    }
}

My question is that if the game object is destroyed, then why does the execution continue to the code which logs "After destroy"?


texts: How can i remove the margins in Window_Base?

texts:
So i am remaking Window_Status for my game where i have the character battler displayed in the background. bellow is the portion of the script which adds the battler image taken from def refresh (the first part, i omitted the at-the-time experimental code for Status Icons and Stats)

bitmap = RPG::Cache.battler(@actor.battler_name+"_menu", @actor.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw,ch)
self.contents.blt(0,0, bitmap, src_rect, 75)
draw_actor_name(@actor, 0, 0)
draw_actor_level(@actor, 80,0)
draw_actor_class(@actor, 0, 32)

and this is the result

now the battler image used is about 5x larger than the regular one (because stretching it using code made it look pixely, this way it's a bit more smoother) and also i've chopped off the left side because some of the battlers i use don't have their head perfectly centered (this way they can all can get set at 0,0)

however as you can see the bottom, which isn't cropped in the original image, is still being chopped off at the bottom. also despite the bitmap being at 0,0 it's not flesh against the sides.

i'd like to know how i can remove these margins? ideally at the Window_Base level since i can see myself running into the same problem with Window_Command

NOTE: this is in RPG Maker XP so i'm using RGSS


texts: Generating interesting water using perlin noise

texts:
I use Mathf.PerlinNoise to generate grass/water in a 2d square. It works as intended, however I am not really getting very interesting water, and at times it can look very bare or unrealistic, here is a sample of a bad generation:

Unfortunately it took me about 20 tries to find an interesting one, what I want is something along these lines:

Or something like this, but I don't want any tiny areas of water:

You can copy/paste the components below and try urself with 1x1 cubes (if you don't have Odin just delete that part):

using UnityEngine;
using Sirenix.OdinInspector;

public class GenerateMap : MonoBehaviour
{
    [Range(0, 40)]
    public int mapWidth = 20;
    [Range(0, 40)]
    public int mapHeight = 20;
    [Range(0, 20)]
    public float noiseScale;

    [Space]
    public GameObject parent;
    public GameObject grassTile, waterTile;

    [Button("Generate map")]
    public void GenerateMap()
    {
        for (int i = 0; i < parent.transform.childCount; i++)
        {
            Destroy(parent.transform.GetChild(i).gameObject);
        }

        float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, noiseScale);

        for (int x = 0; x < mapWidth; x++)
        {
            for (int y = 0; y < mapHeight; y++)
            {
                Debug.Log(noiseMap[x, y]);

                if (noiseMap[x, y] >= .3)
                    Instantiate(grassTile, new Vector3(x, 0, y), Quaternion.identity, parent.transform);
                else
                    Instantiate(waterTile, new Vector3(x, 0, y), Quaternion.identity, parent.transform);
            }
        }
    }
}

Noise:

using UnityEngine;

public static class Noise
{

    public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale)
    {
        float[,] noiseMap = new float[mapWidth, mapHeight];

        Vector2 offset = new Vector2(Random.Range(0, 100), Random.Range(0, 100));

        if (scale <= 0)
            scale = .0001f;

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                float sampleX = x / scale + offset.x;
                float sampleY = y / scale + offset.y;

                float perlinValue = Mathf.PerlinNoise(sampleX, sampleY);
                noiseMap[x, y] = perlinValue;
            }
        }

        return noiseMap;
    }
}


texts: Time to render each frame is proportional to the amount of models in the scene

texts:
This question is deliberately written in a "High-Level" manor to avoid screeds and screeds of code snippets, hopefully I can get my point across, I am using C++ and OpenGL.

I have a game engine, and in the engine I have my "game loop" that is called every frame, one of the things in this game loop is my call to Render(), before a call to SwapBuffers(), nothing new there.

Essentially my engine draws the scene using a scene graph, that is I have GameObject's and each object has a GameComponent. So when the Render() is called in the "game loop" I get the root GameObject and render its GameComponent and then move onto the next GameObject and render its GameComponent, etc. until all GameObject's and each of their GameComponent's are drawn using glDrawElements(...).

One of the GameComponent's a GameObject can have is a MeshRenderer, that is a Mesh paired with a Texture. In my scene I want to add loads of tree models, therefore I create for example 50 GameObject's that each have a MeshRenderer component (a tree) that will eventually in the game loop described above be drawn.

The issue with this is that the time it takes to render a frame is directly proportional to the number of tree models I have (O(N) I think is how you word it). For example with 100 trees the render time is 23ms, with 200 trees it is 46ms, with 400 trees it is 90ms so on and so forth.

This is terrible, I need at least 1000 trees in my "game world" and even at around 400 my game is "laggy". Because the time to draw a frame is proportional to the number of tees I know that each frame it is re-drawing each mesh essentially (every frame drawing 100 trees, and then 200 and so on, and the time to draw scales with it)

My question is this - How can I store the mesh data so that I don't need to draw them from scratch every frame, I can just draw them once, and then re-use that data for the next frame, but don't re-draw it all? is there a way to firstly use glDrawElements(...), then store that mesh data(all the vertices etc.) and then every frame after call something like for example glDrawExcistingElements() instead of  glDrawElements(...). Ultimately meaning that for consecutive frame draws the time is the exact same wether I have 1 tree or 1000 trees because the system is simply saying "here is the scene I already drew", instead of "lets draw it all again from scratch".


texts: What design pattern would be most suitable for RPG skills?

texts:
I'm developing a small Java digital card game project. In my game, players can perform skills when using cards. Each skill does different things, like deal damage, heal etc.. I'm looking for a way to program those skills into the game.

I saw an answer to a similar question online mentioning "Strategy Design", and thus I found out about the world of Design Patterns.

Because of the sheer amount of different design patters out there, I was hoping someone could recommend me an appropriate design pattern for achieving the above. Would Strategy Design suit my needs, or is there a better choice?

Thank you.


texts: Opengl the light position always on the origin point therefore the diffuse and specular does not work

texts:
I am newbie of opengl, so I did the tutorial by learnopengl. I have a strange problem when I was trying to do the light effect (ambient, diffuse and specular).
For the diffuse, the effect appears on incorrect surface,and it seems like the light position always local on the origin point even I have change the position of it(the right cube position and the light position as the image shows):

I was also tried to add the specular in fragment shader but it also only appear on the left surface of that cube(the green arrow, that surface should not be lighten because now the vector is parallel the surface, so theoretically that surface should be black).
I have passed the light position and camera position to fragment shader of the cube (also the light fragment shader):

    glm::vec3 lightPos(0.0f, 2.5f, 3.0f);
    cubeShader->use();
    cubeShader->setVec3("lightPos", lightPos);
    cubeShader->setVec3("cameraPos", secondCamera->Position);

and the fragment shader is, as simply as the tutorial's example:

out vec4 FragColor;
in vec3 Normal;
in vec3 FragPos;
in vec3 lightPos;
uniform vec3 cameraPos;
uniform vec3 lightColor;
uniform vec3 objectColor;
void main()
{

    //ambient CONDITION
    float ambientStrength = 0.1;
    vec3 ambient = ambientStrength * lightColor;
    //diffuse CONDITION
    vec3 norm = normalize(Normal);
    vec3 lightDirection = normalize(lightPos - FragPos);
    float diff = max(dot(norm, lightDirection), 0.0);
    vec3 diffuse =  diff* lightColor;
    //specular CONDITON
    float specularStrength = 0.5;
    vec3 viewDirection = normalize(cameraPos- FragPos);
    vec3 reflectDirection = reflect(-1.0 * lightDirection, norm);
    float spec = pow(max(dot(viewDirection, reflectDirection), 0.0), 32);
    vec3 specular = specularStrength * spec * lightColor;
    //Result
    vec3 Result = (ambient + diffuse + specular) * objectColor;
    FragColor = vec4(Result, 1.0f);

}

Even I add the specular, the specular appears on the incorrect surface.
I was also refer this answer, thought it might be the transformation of model from camera to world by using inverse and transpose:

glsl directional light specular seems to be relative to origin not camera

However I did this in my vertex shader:

layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
out vec3 Normal;
out vec3 FragPos;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform vec3 cPosition[10];

void main()
{
vec3 newPosition = cPosition[gl_InstanceID];
gl_Position =  projection * view  * model * vec4(aPos + newPosition,1.0);
FragPos = vec3(model * vec4(aPos +newPosition,1.0));
Normal = mat3(transpose(inverse(model))) * aNormal;
}

So in totally, the problem is, when the light position changed, the effect will not change because it only control by the "ghost" light which locals on the origin point.
Could you guys please tell me, why there is a light on the origin? Thanks!


texts: How would I implement an endless road the player runs down?

texts:
I want to create the illusion that a man is running down a long road i.e. this pic

http://camlinecambridgelimited.web.officelive.com/images/road%20graphic1.jpg

If you have played Temple Run on the iPhone, it's the same principle, but instead of a temple it's a normal road.

I want to know how this is implemented. For example, do I just repeat this road image in a loop?


texts: How do I deal with this tilemap wraparound edge case?

texts:
I'm building a 2D game engine that uses tilesets to build levels.  I recently added functionality to handle wraparounds (ie. where the right edge of the map connects to the left edge.)  The engine scrolls the map to follow the character around, remaining centered on the player whenever possible.

I implemented wraparound as follows:

The map engine has a Viewport object, which has a bounding rect and can test each tile to see if the tile is contained within the viewport.  When the screen coordinates are such that wraparound is needed, the viewport can set up sub-viewport objects that display different parts of the coordinate space, and place them side by side.

Each frame, I test the tiles on the map against the viewport to see if they can render.  Each tile object has a viewport property designating which viewport it's rendering into.  In the case of a composite viewport, this will delegate the test to each sub-view in turn, and on the first match, set the tile's viewport object and break the loop.

This works just fine in practice, until I hit one specific edge case: When the map is the minimum size, which is exactly the size of the screen, while trying to scroll, the tiles along the edge will be in the area of both viewports at once until the scroll completes the full width of that tile, which causes it to render on one edge and the other edge to show blank space for a moment.

I could resolve this by giving each tile a list of viewports instead of a single one, but that would significantly increase the complexity of my rendering, which I want to keep as fast and simple as possible, just to deal with a minor edge case.

Does anyone know of an elegant way to resolve this issue?


texts: How can I extrude a regular, grid-based 2D shape to 3D?

texts:
I have a list of vertex coordinates which encircle several 2D areas. Orthogonal lines only, but not necessarily convex areas... similar to PCB traces of conductive copper areas. I want to draw them like solid objects in 3D using OpenGL, but I'm still very new to 3D and struggling.

Please point me how to do this. I've managed to draw the outline only using GL_LINE_STRIP, but when I try GL_QUAD_STRIP or GL_TRIANGLE_STRIP, the list of coordinates is not properly ordered for triangle strip and the fact the areas are not convex prevent me from doing a simple triangular tessellation.

These are the 2D shapes:

I'd like to render them like this:


texts: Extending control remapping script to work with mouse buttons

texts:
I have created a default key map for my game, however I have also included an option in the settings where the player can change the key bindings.

My issue is if the player clicks on the button for shooting, which is defaults to mouse0, or aim on mouse1, then click on another key, they can never go back to mouse0 or mouse1.

I am unsure of how to include all the mouse buttons/scroll wheel into the viable buttons the player can choose from.

Here is the part of my code that deals with the changing of the keys:

private void OnGUI()
{
    if(curKey != null)
    {
        Event e = Event.current;
        if (e.isKey)
        {
            keyBinds[curKey.name] = e.keyCode;
            curKey.transform.GetChild(0).GetComponent<Text>().text = e.keyCode.ToString();
            curKey.GetComponent<Image>().color = normal;
            curKey = null;
        }
    }
}


texts: Questions about dynamic loading and unloading of assets and game state

texts:
I've wondered about this for a while as I worked on my project, but couldn't quite come up with the best way to expose my problem. I'll start with some context.
Context
I have a game that is divided into rooms. So from an asset point of view, it makes sense to load and unload them on a room by room basis. In my case this boils down to all the textures and audio files required by that room.
However, player triggered events can change the state of any dynamic object in the world, even those that are not on the current room. Furthermore, since the game is multiplayer, even if I'm not seeing the changes immediatly, other players might. So, even if the assets aren't loaded, I still need some way to register that change in state.
The way I'm currently handling this is to keep the entire game world state in memory since the start of the game, and only bother about dynamically loading and unloading its assets.
Which leads to the following questions related to resource management.
Questions

Loading and storing the entire game state at once seems reasonable for the scope of my games, but I get the feeling it wouldn't scale very well to larger projects. So how is this usually implemented in massive games such as MMOs that need to update a large amount of entities that are far away from the player?

Assets that are guaranteed to be needed for a particular room (such as the room's scenario and static objects) can be loaded when the player enters the room - possibly with a transition or a loading screen in between. But what about assets for unpredictable game entities that might suddenly come into your current room at any time, such as other players?
Would it be reasonable to treat those separately, load them all at once when the game starts, and keep them in memory the entire time, or would it be better to load them and unloaded dynamically in a separate thread? And in that case, does XNA handle loading assets from another thread well?


texts: Camera.unproject(Vector3) method is not working in libGdx

texts:
I know the touch postioning in libGdx uses OpenGL, making 0,0 the bottom left corner while the camera uses the top left corner as 0,0. I did some searching and found this SO question that specifies that I need to use the Camera.unoroject(Vector3) method. This is the relevant code:

package com.mycompany.mygame;

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.math.*;

public class MyGdxGame implements ApplicationListener
{
    public float x;
    public float y;
    public float w = 50;
    public float h = 50;

    Texture texture;
    SpriteBatch batch;
    OrthographicCamera cam;

    @Override
    public void create()
    {
        texture = new Texture(Gdx.files.internal("android.jpg"));
        batch = new SpriteBatch();
        cam = new OrthographicCamera();

        //x = 50;
        //y = 50;
    }

    @Override
    public void render()
    {
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.begin();

        if(Gdx.input.isTouched()){
            Vector3 touchPos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
            cam.unproject(touchPos);
            batch.draw(texture, touchPos.x, touchPos.y, w, h);
        }
        batch.end();
    }

    @Override
    public void dispose()
    {
    }

    @Override
    public void resize(int width, int height)
    {
    }

    @Override
    public void pause()
    {
    }

    @Override
    public void resume()
    {
    }
}

The problem is the game is not drawing correctly. It should draw the character at the touchPos.x and touchPos.y coordinates, but it is not. It is drawing in the bottom left corner. See the pictures below:


texts: Non-Perfect maze generation with objectives

texts:
I need an algorithm that can generate mazes with these requirements:

Allows for random structures to be made (Ex: a center spawn area, objective points and 'Caverns (corridors with 2 or more entrances and a width > 1)' )

Generates paths from structures to required connections

Can be implemented in Python with relatively little difficulty

No extra modules (unless supports Python 3.5.5)

As an example, the objectives would look like this in game (I use integers to store the walls in the ray caster):

2 2 2 2
2 0 0 2
2 0 0 2
2 2 2 2

I also tried looking on wikipedia
and I found this semi-helpful link
but none have helped me achieve this so far.


texts:
I'm making a game where I have circles filed with words or pictures drop from the top of the screen to the bottom. they should spawn right above and then drop.
I just started using unity a couple days ago and I managed to do this with a simple sprite, but I couldn't fill it with the info I wanted and from searching online it seems like it can't be done.
So I decided to try with buttons instead, since those can be given text and images(I think) but i'm not sure how to do so.
with the circles I passed an object of them to the script and then used
newCircle = Instantiate(Circle, temp, Quaternion.identity);
but with buttons everything seems to work weird because there's also the need for the canvas and the units are different so I'm not sure how to do it


texts: Is it safe to run multiple XNA ContentManager instances on multiple threads?

texts:
My XNA project currently uses one ContentManager instance, and one dedicated background thread for loading all content.

I wonder, would it be safe to have multiple ContentManager instances, each in it's own dedicated thread, loading different content at the same time?

I'm prompted to ask this question because this article makes the following statement:

  If there are two textures created at the same time on different
  threads, they will clobber the other and you will end up with some
  garbage in the textures.

I think that what the author is saying here, is that if I access one ContentManager simultaneously on two threads, I'll get garbage. But what if I have separate ContentManager instances for each thread?

If no-one knows the answer already from experience, I'll go ahead and try it and see what happens.


texts: Player shooting himself when moving - Unity UNET

texts:
Setting : Creating my first multiplayer game and running into an odd issue. it's a tank game where players can shoot bullets and kill each other

Problem : When the client shoots while moving, the bullet seems to spawn with a little delay which causes the the player to collide with the bullet.

  The issue seems to be that the player itself is local and the bullet
  is being spawned on the network ( which is causing the delay)

Note: The host player does not have this problem, therefore it's somehow related to networking.

How can I sync the bullet with the client player?

private void Fire(){
    // Set the fired flag so only Fire is only called once.
    m_Fired = true;
    CmdCreateBullets ();
    // Change the clip to the firing clip and play it.
    m_ShootingAudio.clip = m_FireClip;
    m_ShootingAudio.Play ();
    // Reset the launch force.  This is a precaution in case of missing button events.
    m_CurrentLaunchForce = m_MinLaunchForce;
}

[Command]
private void CmdCreateBullets()
{

    GameObject shellInstance = (GameObject)
        Instantiate (m_Shell, m_FireTransform.position, m_FireTransform.rotation) ;
    // Set the shell's velocity to the launch force in the fire position's forward direction.
    shellInstance.GetComponent<Rigidbody>().velocity = m_CurrentLaunchForce * m_FireTransform.forward;

    NetworkServer.Spawn (shellInstance);

}


texts: Unity: finding force vector to separate colliders in OnTriggerStay events

texts:
In Unity, I have Trigger Colliders, and catch the OnTriggerStay(Collider other) events.

Once two Colliders are touching, how do I get the Force vector to make them want to separate again?

In the example below, I have a Sphere and a Box Collider touching. The OnTriggerStay is being called for the Sphere.

I cannot use the center positions of the transforms to get a direction, as that would not give me a very good force vector:

And I do not think I can use the Collider.ClosestPointOnBounds to figure out the Box touch position, because the point I look from (center of Sphere), could be inside the Box Collider itself, which I understand will just return me back the center of the Sphere again. I would not be able to resolve any force vector from that.


texts: Cannot detect input in void OnCollisionEnter()

texts:
Code:

void OnCollisionEnter()
{
    if (Input.GetMouseButton(0))
       {
            // do something
       }
}

Of course, this code does not work. What I intend to do: "After collision, if the user is pressing down, do something". How can we write this another way? I can't figure it out.


texts:
My question if about resource management.
Is it a good idea to store resources like Sounds in an array and then make a second array(lets call this SoundCollections) as a sort of reference table(name + index of sounds array).

The SoundCollection structure looks like this:

struct SoundCollection{
    unsigned char name[64];
    unsigned int offset;
    unsigned int count;
};

GameObjects can aqcuire a SoundCollectionHandle and use the SoundCollection[SoundCollectionHandle].offset in the Sounds array.
GameObjects then can call

Audio.playsound(Sounds[SoundCollection[SoundCollectionHandle].offset + PlayerSounds::Jump])

for playing a jump sound.

The SoundCollection::count is used as offset for next SoundCollection and bound checking. The same thing I want to use for Sprites and Textures.

Are there any other methods you usually use in your games?


texts: Is the corporate video game development industry habitable?

texts:
After a bit of research, I realized that almost every article about video game development portrays the industry in a terrible light. In these articles, companies abuse workers with unpaid overtime. Developers are left out to dry when studios fall. Developers have a terrible quality of life, and few stay on board for very long (10 or more years).

What are the real working conditions actually like (regular 40-50 hour work weeks, stability, treated well, ect.)? Are there any statistics about job satisfaction in the in game development industry?