texts: Why are radians preferred over degrees in game development?

texts:
I've been looking up the definition of radians and found out that mathematicians prefer them because they are derived from pi instead of being completely arbitrary like degrees.

However, I have not found a compelling reason to use them in game development, possibly due to my complete lack of related mathematical understanding. I know that most sin/cos/tan functions in languages what radians, but someone could just as well create library functions in degrees (and avoid the inherent rounding errors when using pi).

I don't want this to be an opinionated poll, I would just like to hear from people that have done game development (and the associated math research) where radians offer a superior experience over degrees, as opposed to "We're using radians because we always used them", just for the sake of helping me (and possibly others) to understand what they are good for.


texts: I feel like Im missing something really simple, but Ive read about all the events NGUI can generate from an object and just dont get where to recive (or handle) the event. Do I just attach it to a script on the object?


texts:
I found this article here: https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx
But it's from September 2017, and since then Android and Android Studio have been updated. How can I add AdMob to my LibGdx game currently in 2018?


texts: Should a Game include Multi-Monitor Support?

texts:
I'm coding a 2D platformer in SDL2 and c++ and was wondering if there's an expectation for videogame's to support Multi-Monitor setups and if so, if it applies to 2D platformers.

As a bonus question too: Does the expectation of being able to change a game's resolution apply to 2D platformers? Thanks.


texts: Creating graphics at different angles for sprites

texts:
I am developing a Java game that uses sprites for the graphics. It's just a top down shooter and our ship sprites look like the following:

These work fine, but they're hard to create and the artist who created them is no longer working on the game. I could easily create a top down view of a ship in Photoshop myself, but I'm not sure how to get all the angles.

What do you think would be the best program or approach would be for me to create more?


texts: Unity Ambient Occlusion not working with Orthographic camera

texts:
It seems like the Ambient Occlusion setting from the Unity Post Processing stack (obtained from the asset store) only works with a Perspective camera, yet I haven't come across any documentation stating that this is the case or that it lacks support for Orthographic.

All the other settings in the stack seem to be working in both Perspective and Orthographic.

Is this a bug, or something I'm not doing right or understanding?


texts:
I'm just getting started with the UDK, with experience in Unity, and would like a good tutorial series about getting to know my way around the basics of level design and a touch on programming. I have found some basic tutorials on level creation, but they are pretty old, and would like to know more.

Thank you!


texts:
I'm trying to convert a list of Vector3 on Vector2 because I need to put them in a graph like this:

The graph is easy to do having the Vector2 list, but I have a non-trivial problem obtaining the Vector3 Points:

As you can see, I get them using a Plane which can be in any orientation and rotation.
 What formula can I use to convert them so I get X,Y points no matter the rotation of the plane.

PD: I use this code to do the job but it doesn't work on different positions and rotations of the plane...
projectedPosition.X = Vector3.Dot(ballPosition - planeOrigin, planeX);
projectedPosition.Y = Vector3.Dot(ballPosition - planeOrigin, planeY);

PlaneY = Vector3.up & PlaneX = plane.transform.forward


texts: How can I scale a color component by Time.deltaTime and still fit it into a byte?

texts:
I am confused about this issue, and I can't find why I get this and how to fix it properly from  the Google searches I've tried.

This is a short version of my code:

     byte redtarget = 70;
     byte greentarget = 222;
     byte bluetarget = 255;
     byte opacitytarget = 1;
     byte redcurrent = 0;
     byte greencurrent = 0;
     byte bluecurrent = 0;
     void OnMouseOver() {
        redcurrent = redcurrent + redtarget * Time.deltaTime;
        greencurrent = greencurrent + greentarget * Time.deltaTime;
        bluecurrent = bluecurrent + bluetarget * Time.deltaTime;
    if(redcurrent >= redtarget) {
        redcurrent = redtarget;
    }
    if(greencurrent >= greentarget) {
        greencurrent = greentarget;
    }
    if(bluecurrent >= bluetarget) {
        bluecurrent = bluetarget;
    }
    theobject.GetComponent<Renderer>().material.SetColor("_EmissionColor",new Color32(redcurrent,greencurrent,bluecurrent,opacitytarget)) ;
     }

Please ignore the other errors that could have been introduced when I copy + pasted it to here.

And this is the error I get:

As you see the error, "cannot implicit convert type float to byte", the problem is caused by Time.deltaTime that returns a float value, and I need a byte due to Color32.

Is there any way to turn Time.deltaTime to byte? Or should I use another type of color that use floating point numbers?

I'm a beginner with Unity so I'm sorry if this has already been asked somewhere; as I said, I can't find it on the Internet.


texts: OpenGL picking performance: ray casting vs. color picking

texts:
I am curious of how the performance of color picking compares to ray casting. I am looking at the scenario when the mouse is clicked which means only then the scene is rendered in a backbuffer for color picking or ray-cating has to be applied.

Note: I have found this question which unfortunatly does not give any indication.


texts: Choosing the correct isometric character facing direction

texts:
I am currently building a 3D game presented from a 2D isometric viewpoint.

The 3D coordinates start at the top left corner of the screen with x and y increasing towards the right and bottom edges respectively. An angle about the z axis starts with 0 facing right and increases CW.

The isometric coordinates use the diamond method seen in this reference:

My problem is related to choosing the correct frame for my characters. The characters each have a sprite sheet containing an image for one of the 8 compass directions. The start with the image facing right and rotate CW as in the 3D coordinates.

How can I choose the correct sub-image based on their rotation in 3D space? Is the problem is equivalent to converting the rotation into the isometric coordinate space?


texts: Can't figure out why my mouse picking code doesn't work

texts:
I am trying to create code to check for intersections between bounding spheres and the mouse. I get a mouse ray but it doesnt seem to point in the direction you think it should Attached is a screenshot and code. If anyone can help I would appreciate it as this is driving me crazy.

    auto state = m_mouse->GetState();

    float mouseX = state.x;
    float mouseY = state.y;
    float m_screenWidth = m_deviceResources->GetScreenViewport().Width;
    float m_screenHeight = m_deviceResources->GetScreenViewport().Height;

    // Normalized device coordinates
    float x = (2.0f * mouseX) / m_screenWidth - 1.0f;
    float y = 1.0f - (2.0f * mouseY) / m_screenHeight;

    DirectX::XMMATRIX viewMatrix = DirectX::XMMatrixTranspose(DirectX::XMLoadFloat4x4(&cameraComponentHandle->view));
    DirectX::XMMATRIX projectionMatrix = DirectX::XMMatrixTranspose(DirectX::XMLoadFloat4x4(&cameraComponentHandle->projection));
    DirectX::XMMATRIX inverseviewproj = DirectX::XMMatrixInverse(nullptr, viewMatrix * projectionMatrix);

    DirectX::SimpleMath::Vector3 origin = DirectX::SimpleMath::Vector3(x, y, 0);
    DirectX::SimpleMath::Vector3 farPoint = DirectX::SimpleMath::Vector3(x, y, 1);

    DirectX::SimpleMath::Vector3 rayorigin = DirectX::XMVector3TransformCoord(origin, inverseviewproj);
    DirectX::SimpleMath::Vector3 rayend = DirectX::XMVector3TransformCoord(farPoint, inverseviewproj);
    DirectX::SimpleMath::Vector3 raydirection = (rayend - rayorigin);
    raydirection.Normalize();

    rayComponentHandle->position = rayorigin;
    rayComponentHandle->direction = raydirection;


texts:
I have a square model that has been fractured using blender's cell fracture.
I also have a material that I want to apply onto the broken pieces.
The only problem is that the material needs to be organized in a certain way so it looks right when I replace it with the broken model.
Scripting-wise i'm using Brackey's tutorial for destruction
How can I make the material look the same on both the fractured and the unfractured model?
I also left a picture if it helps.
The one on the left, is the unbroken model with the material. The one on the right is the broken model with all the cells having the same material.


texts: Why does occlusion culling have a negative performance impact on Gear VR in Unity 5.4.03f?

texts:
I am making a GearVR game using Unity 5.4.03f and Oculus Utilities for Unity 5.

I have problem with Occlusion Culling. I've set appropriate objects as static and baked the data. The culling works correctly when I visualize it in the editor - I set a complex scene and hid it behind a big cube. The scene is not rendered when visualizing in the editor when the camera is behind the cube.

When I deploy this scene to the device, Samsung Galaxy S6. The culling does work - when looking at the complex scene through the occluding cube, I have good a framerate, the scene is culled. Without the cube and occlusion culling, the FPS would be around 40, with the cube and OC, it is around 60.

The problem starts when I get past the cube with OC on - the FPS drop to 30, while without OC in the same spot they were around 55.

I tried looking online for solutions, but this is supposed to be an old bug that was fixed back in Unity 5.1.X.

Any ideas?


texts: Should I cull off-screen objects in SDL2

texts:
My game will have a large number of objects moving offscreen at any given time, can i just render them all with SDL_RenderCopy even though they are off screen or should I only render them if they are on-screen? I will probably have many hundreds or throusands of objects loaded at a time. My dev machine is quite overpowered for what I'm trying to do but I am conserned that I just won't notice a preformance drop that may affect players with less powerful computers.

So, will checking if each object is on screen before drawing increase performance/lower CPU load, or can I safely let SDL handle this with clipping?


texts: How to Animate a Mechanical Model to work with Unity's Mechanim?

texts:
I made a relatively simple model in 3D Studio Max to be used in a game. It's a simple stationary laser turret with an openable maintenance hatch. I want to use Mechanim to handle the animation states. The parts of the model are parented in a way that it's easy to just make it move from code but I rather have it use Mechanim and animation files to make it easier to add details like idle animations. I tried animating it with Unity's build in animation editor which looked nice enough but I couldn't get the animation created with that in Mechanim for some reason. If I have to use an external editor to add animations, I can't seem to find any. Google only gives results on how to animate character models or how to make an animation just to be exported to video.
How would I animate this model to work with mechanim, what programs should I use and what should I pay attention to?


texts: How to Destroy an Instance of a Prefab Without Removing the Prefab?

texts:
I'm making a simple runner game where obstacles spawn off in the distance and move towards the player. I want to remove them after they're invisible to the player.

I made an Obstacle prefab and a SpawnObstacles.cs script, which I added to an empty game object. In it, I call

Instantiate(obstaclePrefab, xLocation, yLocation, zLocation, Quaternion.identity);

a set number of times per second.

In the Update() method of the obstacle prefab, I have

if (transform.position.z < -20){
    GameObject.Destroy(gameObject);
}

so each obstacle will destroy itself automatically.

When I run the game, I get a:

MissingReferenceException: The object of type 'GameObject'
has been destroyed but you are still trying to access it.

error on the Instantiate call in SpawnObstacles.cs

Before the game starts:

As the game is running:

How can I have a single instance of a prefab destroy itself without destroying the entire prefab? I think I need the obstacles to be inside the Obstacle Prefab. Perhaps I could loop through all obstacles and delete the ones invisible to the player?


texts: What game systems exist which uses camera input?

texts:
The group and I is in the middle of a semester project where we are currently researching on which game systems are using camera as input or as an interactive medium?
We would like some help listing some of the game systems which uses camera input, as it seems hard to find other examples.
Currently we know that webcam browser games uses camera input (Newgrounds webcam games), as well as the xbox kinect.
I know this questions seems rather vague, though I still hope some people is capable of helping.


texts: How can I create an orthographic display that handles different screen dimensions?

texts:
I'm trying to create an iPad/iPhone game using GLES2.0 that contains a 3D scene with a heads-up-display/GUI overlaid on the top. However, this problem would also apply if I were to port my game to a computer and run the game in a resizable window, or allow the user to change screen resolutions...

When trying to make the 2D GUI/HUD work I've made the assumption that all I'm really doing is drawing a load of 2D textured 'quads' on the screen and am trying to treat the orthographic projection as an old-style 2D display with 0,0 in the upper left and screenWidth,ScreenHeight in the lower right.

This causes me all sorts of confusion when I rotate my ipad into Landscape mode since I can't work out what to put into my projection and modelview matrices to turn everything around the right way. It also gets messy if I want to support the iPad's large screen, an iPhone or a Retina display since I have to then draw three sets of textures for everything and work out which ones to use.

Should I be trying to map the 2D OpenGL co-ords 1:1 with the screen? While typing out this question it occurs to me that I could keep my origin in the centre, still running -1/+1 along the axes. This would let me scale my 2D content appropriately on the different screen sizes, but wouldn't I end up with the textures being scaled and possibly losing quality?

I'm using OpenGLES 2.0 and have a matrix library that has equivalents to the GLES1.1 glOrthof() and glFrustrum() calls.


texts: How to make Unreal save assets in 3-file style?

texts:
I'm trying to play around with some code to explore UE4 maps, but it assumes that every file is actually multiple files, with the asset accompanied by a .uexp file and optionally a .ubulk file.  When I save a map in Unreal Engine, though, it's all there together as one big .umap.
A bit of googling suggests that this can be changed by changing two config options in the project's engine.ini file, but when I change that, the map still saves as a single file, both for saving the file in-place and saving a copy of it elsewhere, even after completely closing and re-launching the editor.
What's the proper way to force the editor to save my map as 3 files rather than just the one?  (Using Unreal Editor 4.25.4, in case it matters.)


texts:
I want to generate some game textures into coloured vertex arrays.

Is there a known algorithm  to transform texture/bitmap data into an optimised vertex array. Much like how the Homeworld skyboxes were made.

EDIT:
Don't need the dome part, would like todo these flat.


texts: How should I deal with different enemy types?

texts:
I'm making simple space shooter game for Android in Unity. I want to have different types of enemies (different weapon, stats, movement schemes) and I'm not sure how to do it. I'm quite new to objective programming and I don't really know what classes should I create. I guess I could just make a prefab for every enemy since there won't be many types, but that is not what I'm looking for. I have some ideas:

First of all I'd write an BaseEnemy class and enemy type subclasses that inherit from it.

My first idea is to create those without MonoBehaviour. Then I'd have to make an EnemyScript with MonoBehaviour that I'd add to enemy game object. It'd have a specific subclass object inside, which will set every variable. BaseEnemy would just have undeclared variables and in subclass I'd set particular values. But I'm not sure how to deal with different movement schemes then. I wouldn't be able to put move() function in subclass since it wouldn't have MonoBehaviour, so I'd have to find another way. I might put in EnemyScript every possible scheme and then use correct one depending on some type value, but it doesn't seem like a proper way, does it?

The second idea is to just make a MonoBehaviour BaseEnemy class. Then while creating enemy game object I'd just add correct subclass script (aaand... I'm not sure how to do it :/ )

Could you tell me which one is a better way? Maybe neither of those?


texts: How to make the character dash forward in Roblox?

texts:
In my game I want to make a skill in a tool to dash forward for a specific range
and if the character came in contact with a humanoid during the dash,
it stops right on contact and stops the other humanoid from moving temporarly too and deal damage

I don't know what functions should i do and where to look for them...
i figured how to use onActivate and getting the mouse through Equipped
Appritiate any help and guidance


texts: how can you use playerprefs to save an array in javascript on unity

texts: As I stated I can't find a working answer anywhere else. I have a game where you are to draw out your own weapon and I'm storing that information in an array. How?


texts: How can you make filled-in circles in cocos2d? I understand you have to create a new method, but I don't really understand how it works/how to do it. Could someone please provide maybe an example or tell me how to go about achieving this? Also, I need to create about 24 filled-in circles, would this cause lags of some sort? Thanks!


texts: Play a sound on button click before loading the load scene in Unity3D

texts:
I am trying to play the sound of the button click before loading the scene in unity. However, the sound is never played. Below is my code, help would be appreciated.

public void RestartGame()
{
    audioManager.PlaySound(forwardSound);
    StartCoroutine(DelaySceneLoad("Gameplay"));
}

IEnumerator DelaySceneLoad(string scene)
{
    yield return new WaitForSeconds(forwardSound.length);
    GameTracker.SetGameOver(false);
    SceneManager.LoadScene(scene);
}


texts: (Gamemaker Studio) How to draw a vector?

texts:
Let's say I want to start from the center pixel of a screen of indeterminate size, and I want to be able to draw an arrow from this center pixel to any other pixel.

The only way I know how to do that is to assign entirely new sprites for each and every possible direction and magnitude of the vector...which might work (even if it's tedious) for around 10 or even 20 possible combinations, but much more and it would really chug a system with the switch statement alone to find which sprite to use.

So, the obvious, much better, way of doing this is just to dynamically draw from one point to another...I don't know how to though.


texts: Arbitrary number of VBO to Vertex Shader

texts:
I am currently using standard modern OpenGL way to render a mesh via VBO and attributes

    glEnableVertexAttribArray(aVertexPosition);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glVertexAttribPointer(aVertexPosition, 3, GL_FLOAT, GL_FALSE, 0,0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

and in the GLSL code also the standard way to received into as in vec3 aVertexPosition.

However, I wonder if there is anyway to make this for a dynamic amount of VBOs. Let's say my software creates a number of VBOs that depend on the inputs, and I successfully create and allocate memory for all of them, how do I pass all of them to the shader? Does the number need to be constant? If so, what is the best way to do it?


texts:
What is the difference between Serializable, and System.Serializable?
I'm guessing SerializeField is only for attributes of a class. What is the difference between the above two, then?


texts: LibGDX: Colllisions between bullets and enemies in arrays

texts:
I am writing a "Gauntlet" style game. So far I have managed to successfully detect collisions between my player object and my ghost enemy objects, and when they collide they drain the player's energy.

The Ghosts are stored in an ArrayList. I now have bullets which the player can fire, these are instantiated from the Player class and added to another ArrayList called bullets.

I typically have around 50 ghosts on the screen dotted around the map.

ArrayList<Ghost> ghosts = new ArrayList<Ghost>();
ArrayList<Bullet> bullets = new ArrayList<Bullet>();

The ghosts and bullets are added to these lists when spawned/fired

I have tried to implement a method as per below, to try and determine whether a ghost's bounding rect and a bullet's bounding rect overlap, as follows:

/**
 * Check if a ghost has been hit by a bullet
 */
public void checkGhostsHit() {

    Iterator<Ghost> iterEn = ghosts.iterator();

    while ( iterEn.hasNext() ){
        Ghost g = iterEn.next();

        //initialise the bullet iterator each time here
        Iterator<Bullet> iterBul = Player.bullets.iterator();

        while ( iterBul.hasNext() ) {
            Bullet b = iterBul.next();

            if ( b.getBoundingRect().overlaps( g.getBoundingRect() ) ) {
                Gdx.app.log("Enemy", " Hit");
                iterBul.remove();
                iterEn.remove();
            }
        }
    }
}

This method is being called from my main render loop but I cannot get it working for love or money. I have tried various forms of the above method, including 'For' loops etc.

Am I performing the check in the correct place? Should the Bullet class instance iteself be checking for a collision, or is the above approach the correct idea.

As you can tell I'm a noob to this and I am still struggling with working out which activities should be undertaken by particular game Classes.


texts: Translating Viewmatrix is inverted, why?

texts:
So I've defined a Projectionmatrix, Viewmatrix and a Modelmatrix using OpenGL (LWJGL).

But when I translate my Viewmatrix to +X it moves my object to the right (hence my camera is moving to the left), and when I move it to -X the object moves to the left (camera moving to the right). Same goes for Y movement, Z works as it should though.

My matrices are as follows:

Projectionmatrix

perspectiveMatrix = new Matrix4f();
perspectiveMatrix.setIdentity();

float aspectRatio = WIDTH / HEIGHT;
float zRange = zNear - zFar;

//COLUMN / ROW
perspectiveMatrix.m00 = (float) (1.0f / (aspectRatio * Math.tan(degreesToRadians(fieldOfView / 2.0f))));
perspectiveMatrix.m11 =  (float) (1.0f / (Math.tan(degreesToRadians(fieldOfView / 2.0f))));
perspectiveMatrix.m22 = (-zNear - zFar) / zRange;
perspectiveMatrix.m23 = 1;
perspectiveMatrix.m32 = (2 * zFar * zNear) / zRange;

Viewmatrix

Matrices.viewMatrix = new Matrix4f();
    Matrix4f.setIdentity(Matrices.viewMatrix);

    //Initialize all vectors
    this.xAxis = new Vector3f();
    this.yAxis = new Vector3f();
    this.zAxis = new Vector3f();
    this.newPos = new Vector3f();
    this.currPos = new Vector3f();

    /*
     * position.xyz = 0, 2, 7
     * target.xyz = 0, 0, -1
     * up.xyz = 0, 1, 0
     */
    //Set all values to the Camera-class values
    position.negate(this.currPos);
    target.normalise(this.zAxis);
    up.normalise(this.yAxis);

    Vector3f.cross(target, up, xAxis);
    Vector3f.cross(xAxis, target, yAxis); //Recalulate yAxis to make it valid coordinate system.

    /*
     * This defines the View Matrix. This is calculated and explained here:
     * http://ogldev.atspace.co.uk/www/tutorial13/tutorial13.html
     *
     * m(Column)(Row)
     */
    Matrices.viewMatrix.m00 = xAxis.x; Matrices.viewMatrix.m10 = xAxis.y; Matrices.viewMatrix.m20 = xAxis.z;
    Matrices.viewMatrix.m01 = yAxis.x; Matrices.viewMatrix.m11 = yAxis.y; Matrices.viewMatrix.m21 = yAxis.z;
    Matrices.viewMatrix.m02 = zAxis.x; Matrices.viewMatrix.m12 = zAxis.y; Matrices.viewMatrix.m22 = zAxis.z;
    Matrices.viewMatrix.m33 = 1;

    Matrices.viewMatrix.translate(this.currPos);

Modelmatrix

Identity


texts: How can I create a "rain drops on camera lense" effect with the HDRP?

texts:
I did follow this tutorial https://www.youtube.com/watch?v=OG7zyogrUTs&t=115s but I did not made it cause I am using HDRP and they are not using HDRP so the problem is I can't use the normal materials being in HDRP mode help me if there is any way to do so or if there is another good video please.

In picture 1 I want these white particles on camera lens looks like the second picture I want water texture on these white particles.


texts: Performing simple network call to retreive JSON in Unity?

texts:
I have looked at the network documentation for Unity and most examples seem to be related to networking your game for multiplayer. I am just looking to grab a JSON response from an API for dynamically generating a menu.

Are there some good examples for doing just simple network calls to get a response from a web server?


texts:
I want to create a state machine for menu in my SDL game. So this is my code without the SDL I just want to ask if this is a good way to create it.
here is a code:
#include <stdio.h>
#include <windows.h>
enum states
{
Menu,
Game,
Game_over,
Exit
};

int main()
{
 int game_is_running = 1;
 enum states state = Menu;
 while(game_is_running == 1)
{
  switch(state)
 {
  case Menu:
    state = Game;
    printf("menu screen with play and exit button.\n"); //need to add if
                                                //exit or play is pressed
                     // if exit then exit program if play than you know...
     break;
    case Game:
     state = Game_over;
    printf("after play button is pressed game screen will show up.\n"); //after this i will come back to menu.
    break;
  case Game_over:
    state = Exit;
    printf("screen after game.\n");
    break;
  case Exit:
    printf("turn game off.\n"); //this will be in the if function with a game.
    game_is_running = 0;
    break;
}
 Sleep(1000); // sleep for a second just for test
}
   return 0;
}


texts:
In Unity 5 on Windows 10, I try to change the text color from the Inspector and in scripts, but the color won't change. Here are some screenshots of my Text objects open in the inspector, with there colors set to red and white, but staying the default black in the Scene and Game windows:

Here are the lines of code I am using to change the color

var textColor = beatBestTime ? "#FF0" : "FFF";

scoreText.text = "Time " + FormatTime (timeElapsed) + "\n<color="+textColor+">Best " + FormatTime (bestTime)+"</color>";

which I can verify are being run, but the color remains the same!


texts:
I am totally stuck on with pixel perfectness of the game. I have tried a few pixel perfect camera -assets, but they have lots of issues considering scalability. is it normal that these cameras zoom in and out, instead of scaling the camera screen when using different resolutions for the game. Because this is a huge problem for me, cause i need to make a game for aspect ratio of 16:10, and every resolution that has the same aspect ratio is needed to scale it correctly keeping the pixel perfectness. The ortographic camera size is dependent of screen width (width / PPU / 2) So it always zooms in or out with different resolutions.
Question is: Is there a way to make it scale the game sprites instead of zooming the view?


texts: How can I spawn items based on probabilities?

texts:
I'm working on a game where I want to choose which object to spawn based on probabilities. Assuming the decision to spawn the object has been done by some other process, I'd like the object with the highest probability to have a higher chance of being spawned. An object with 50% spawn probability should spawn more often than an object with 15% spawn probability. I also need to account for instance where a game object has the same spawn probability

GameObject 1 .50
GameObject 2 .25
GameObject 3 .25

How can I implement this logic?


texts:
In my top-down game character moves to target (pathfinding) also avoiding obstacles with Raycasting(Central ray with whiskers), but situation like on picture causes shiver and unneeded turning (problem similar to corner trap). Even if the whiskers angle is small (0.2 rad). How to deal with it?

EDIT:

Added more exact picture. I'm using Priority steering and if Raycast steering is not zero, it wins.


texts: Debugging/Logging Techniques for End Users

texts:
I searched a bit, but didn't find anything particularly pertinent to my problem - so please do excuse me if I missed something!

A few months back I inherited the source to a fairly-popular indie game project and have been working, along with another developer, on the code-base.  We recently made our first release since taking over the development but we're a little stuck.

A few users are experiencing slowdowns/lagging in the current version, as compared to the previous version, and we are not able to reproduce these issues in any of our various development environments (debug, release, different OSes, different machines, etc.).  What I'd like to know is how can we go about implementing some form of logging/debugging mechanism into the game, that users can enable and send the reports to us for  examination?  We're not able to distribute debug binaries using the MSVS 2010 runtimes, due to the licensing - and wouldn't want to, for a variety of reasons.

We'd really like to get to the bottom of this issue, even if just to find out it's nothing to do with our code base but everything to do with their system configuration.  At the moment, we just have no leads - and the community isn't a very technically-savvy one, so we're unable to rely on 'expert' bug reports or investigations.

I've seen the debug logging mechanism used in other applications and games for everything from logging simple errors to crash dumps.  We're really at a loss at this stage as to how to address these issues, having been over every commit to the repository from the previous to the current version and not finding any real issues.


texts: Quaternion based rotation and pivot position

texts:
I can't figure out how to perform matrix rotation using Quaternion while taking into account pivot position in OpenGL.What I am currently getting is rotation of the object around some point in the space and not a local pivot which is what I want.
Here is the code [Using Java]

Quaternion rotation method:

  public void rotateTo3(float xr, float yr, float zr) {

    _rotation.x = xr;
    _rotation.y = yr;
    _rotation.z = zr;

    Quaternion xrotQ = Glm.angleAxis((xr), Vec3.X_AXIS);
    Quaternion yrotQ = Glm.angleAxis((yr), Vec3.Y_AXIS);
    Quaternion zrotQ = Glm.angleAxis((zr), Vec3.Z_AXIS);
    xrotQ = Glm.normalize(xrotQ);
    yrotQ = Glm.normalize(yrotQ);
    zrotQ = Glm.normalize(zrotQ);

    Quaternion acumQuat;
    acumQuat = Quaternion.mul(xrotQ, yrotQ);
    acumQuat = Quaternion.mul(acumQuat, zrotQ);

    Mat4 rotMat = Glm.matCast(acumQuat);

    _model = new Mat4(1);

   scaleTo(_scaleX, _scaleY, _scaleZ);

    _model = Glm.translate(_model, new Vec3(_pivot.x, _pivot.y, 0));

    _model =rotMat.mul(_model);//_model.mul(rotMat); //rotMat.mul(_model);

    _model = Glm.translate(_model, new Vec3(-_pivot.x, -_pivot.y, 0));

   translateTo(_x, _y, _z);

    notifyTranformChange();
   }

Model matrix scale method:
      public void scaleTo(float x, float y, float z) {

    _model.set(0, x);
    _model.set(5, y);
    _model.set(10, z);

    _scaleX = x;
    _scaleY = y;
    _scaleZ = z;

    notifyTranformChange();
  }

Translate method:
      public void translateTo(float x, float y, float z) {

    _x = x - _pivot.x;
    _y = y - _pivot.y;
    _z = z;
    _position.x = _x;
    _position.y = _y;
    _position.z = _z;

    _model.set(12, _x);
    _model.set(13, _y);
    _model.set(14, _z);

    notifyTranformChange();
   }

But this method in which I don't use Quaternion works fine:

  public void rotate(Vec3 axis, float angleDegr) {
    _rotation.add(axis.scale(angleDegr));
    //  change to GLM:
    Mat4 backTr = new Mat4(1.0f);

    backTr = Glm.translate(backTr, new Vec3(_pivot.x, _pivot.y, 0));

    backTr = Glm.rotate(backTr, angleDegr, axis);

    backTr = Glm.translate(backTr, new Vec3(-_pivot.x, -_pivot.y, 0));

    _model =_model.mul(backTr);///backTr.mul(_model);
    notifyTranformChange();

   }


texts: Aron Granbergs Unity Pathfinding AI goes back and forth

texts:
The agent goes back and forth after calculating the path with seeker.StartPath (transform.position,target.transform.position, OnPathComplete);. The gizmo shows the correct path. Please watch this short video to get an impression on what happens.
It starts after adding about 100 obstacles during runtime. Is this a known bug or am I doing something wrong? My test case is really simple. I can provide the project if necessary.

Link to the Video:
http://screencast.com/t/2ww04975l


texts: Play and Stop Animation on Condition - Unity

texts:
I've applied a scale animation on Play button of my game. I want to stop animation when play button is not interactable. It stops playing animation, but animation is not playing again, even when play button gets interactable. Here is my snippet to Play and Stop Animation.

if (!PlayButton.GetComponent<Button> ().IsInteractable()) {
    PlayButtonAnimator.Stop ();
} else if (PlayButton.GetComponent<Button> ().IsInteractable()) {
    PlayButtonAnimator.Play ("Play_Button_Animation");
}

What should i do to play animation again. Thanks in advance :)


texts: Finding tileX and tileY based on x and y (and vice versa) in isometric 2D view

texts:
I'm working on 2d Isometric game in ruby and gosu, although my problem is probably universal. My map is saved in 2d array:

@map_tiles[layer][y][x] = tile_id

Each tile is displayed on coordinates:

isoX = (x * @tile_width/2) - (y * @tile_height)
isoY = ((x * @tile_width/2) + (y * @tile_height)) / 2

So it's displayed in "diamond" like way. But I'm having a problem with calculating two things.
- Entity's tile_x and tile_y (on which tile is the entity positioned) when given x and y, and;
- Entity's x and y when I'm sending it's tile_x and tile_y.

One method is pretty much the other one reversed. I tried various methods I found over internet, but either I'm doing something wrong, or I don't understand the instructions correctly. The closest I got is:

@x = (tile_x * 32) - (tile_y*32)
@y = ((tile_x * 32) + (tile_y * 32) / 2)

for finding @x and @y based on tiles (player "teleportation" method), and

@tile_x = ((@x / 32) + (@y / 32)) / 2
@tile_y = ((@y / 16) - (@x / 32)) / 2

But they kinda don't work correctly.
- When I send player to tile position (4, 3), he is displayed at (5, 4), and after recalculating it's tile_x/y position, printing says it is at tiles (3,5)
- When I send player to tile position (3, 4), he is displayed at (4, 5), and after recalculating it's tile_x/y position, printing says it is at tiles (2,5)
- When I send player to tile position (4, 2), he is displayed at (5, 3), and after recalculating it's tile_x/y position, printing says it is at tiles (2,5)

So you can clearly see that something's not right here.

That's pretty much it, thanks in advance. I can post the code on github if it's neccessary, but I reckon the problem lies in what I posted.


texts: Can I store D3D9 textures so that they don't consume process memory and also don't require "lost device" handling?

texts:
I have an OpenGL application that uses a lot of texture memory.  While the texture is stored in the system memory, that texture memory is not part of my application process memory.

When this application is ported to D3D and the textures are uploaded to the D3DPOOL_MANAGED pool, the process memory increases proportional to the texture memory and the application crashes due to running out of memory (while in OpenGL, even though the overall system memory utilization has greatly increased, the process memory is still low)

I don't want to have to switch to D3DPOOL_DEFAULT, since the I would have to reload all textures when the device is reset. Is there a workable solution to get my D3D9 application to put the system texture memory somewhere else beside my process, similar to OpenGL?

EDIT: So I just learned about IDirect3DDevice9Ex.  Turns out using this interface instead of IDirect3DDevice9 make DirectX work exactly like opengl in terms of texture memory (system memory goes up proportional to my texture usage, but not the process memory).  So this is an option for me.  However I would still like to know if there are any options since IDirect3DDevice9Ex doesn't work on XP.


texts: What is the best way to interpolate vertex data in OpenGL?

texts:
I am working on a game which has a board of falling down blocks, similar to Tetris. Each block is represented with for vertices and two triangles, each vertex consisting out of its location and texture coordinations. I am using glDrawElements to render the blocks.

I would like to interpolate the location data when blocks fall down. I am wondering, what is the most efficient, elegant and easy way to interpolate such vertex data in OpenGL?

I obviously need two location states (x0 y0) and (x1 y1) and a time step t (0 < t < 1), then I can lerp in my vertex shader. How do I pass this information to the shader? For the timestep, uniforms came into my mind. But what about the locations?

Pass both locations to my VBO at any time. This would work, but requires my VBO to be twice as big as it includes both location states, even if they are equal (= the block hasn't moved)! Blocks will move at times, but most of the time, they are static - wouldn't this approach be a wast of memory?
Keep (x0 y0) in the VBO, transmit (x1 y1) via uniforms if necessary (= if the block has moved). This would save memory, but completely destroy my rendering pipeline.
Anything else? Both of the approaches above seem silly to me. How do other games do this?

Thanks!


texts:
I am looking for help/links/notes/agorithms/URLs/examples on drawing/rendering spheres in pure Java (so that I can hopefully, one day, generate/render planets with various surfaces & atmospheres)

So for the moment, i'd be pretty happy to be able to start off with just drawing a wireframed sphere(s).

ps: I don't want to use external libraries like Java3D, JOGL or aftermarket engines like JMonkeyEngine, Would rather keep it as straight Java.


texts: What design pattern should I employ for validating character movement?

texts:
I'm developing a RPG in Java and have a Map class, which will contain all the MapObjects (the Player, Enemies, Walls, etc.):

Map.java

public class Map {

private int width;
private int height;

private ArrayList<MapObject> MapObjects = new ArrayList<MapObject>();

public Map(int width, int height) {
    this.width = width;
    this.height = height;
}
 }

Hero.java:

public class Hero extends MapObject implements Movable {

private Map map;

public Hero(int x, int y, int direction, Map map) {
    super(x, y, direction);
    this.map = map;
}

public boolean move(int direction) {
    //movement code
}

}

I will have a listener on an external class that will call the hero.move(direction) function.

What is the best approach to validate the movement (making sure that there's an empty space on the map)?

I could pass the Map as an argument, or even use the Command design pattern (the hero being the "remote" and the map being the implementation and executer), but I'm not sure if any of those are the right way to approach this problem.


texts:
I'm trying to get the world coordinates out of a mouse click. Currently I'm doing the following:

var invertedMatrix = mat4.create();
var viewMatrix = activeCamera.getMatrix();
mat4.invert(invertedMatrix, viewMatrix);

var worldCoord = Vector2.transformMat4(new Vector2(mouseX, mouseY), invertedMatrix);

But the values I'm getting are away off. The Y for instance, is between 0 (top of the screen) and 200.000+ on the bottom of the screen. Also, even if I move the camera, let's say 50 in the x axis, if I click in the same spot before and after, the value calculated is the same.

I'm using gl-matrix to generate and calculate the matrices. The used active camera transform was created by using the following instructions:

 mat4.ortho(this._matrix, -this.viewWidth / 2.0, this.viewWidth / 2.0, this.viewHeight / 2.0, -this.viewHeight / 2.0, 0.0, 1.0);
 mat4.translate(this._matrix, this._matrix, [-this.x, -this.y, 0]);

I've checked both the vector2 transform and matrix invert for any issues but there seems to be none which makes me believe it can be the ortho projection itself but I'm currently lacking the knowledge to understand the problem.

The transform calculation:

    return new Vector2(
       (mat[0] * vec2.x) + (mat[4] * vec2.y) + mat[12],
       (mat[1] * vec2.x) + (mat[5] * vec2.y) + mat[13]);

Any ideas? thanks!


texts:
Is there a way to hide UIs such as text, images etc. behind another transparent image? The problem is that I am using the latest Unity version and these custom shaders have no effect on hiding the UI shaders. The two custom shaders I have applied for testing are:
Shader "Custom/DepthReserve"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType" = "Opaque" "Queue"="Geometry-1" }
        LOD 100

        Blend Zero One

        Pass
        {

        }
    }
}

Shader "Custom/InvisibleMask" {
  SubShader {
    // draw after all opaque objects (queue = 2001):
    Tags { "Queue"="Geometry+1" }
    Pass {
      Blend Zero One // keep the image behind it
    }
  }
}

So is there a way to use a transparent image to hide text, images and even gameobjects?


texts: The proper name for a state, view, screen, etc

texts:
Most of my experience is in programming in HTML, JavaScript, etc.  I'm taking on a relatively large project, and while I'm the only developer, I eventually want to open source my code for other developers.

For project scaling purposes, I'd like to have decent terminology, because terminology affects all my variables, and changing it later is a pain.

What is the proper name for when you change views or screens? For example, changing between  an options screen and the playing screen.

I mostly hear it called "state", but when I refer to "gamestate", I typically mean the locations of all entities, the turn count, the score, etc.

I think it may be called "screen", but my games are not full screen, and I'm not sure if that one makes sense.

A "view" is something I don't hear very often, but when searching for "views" with "games", I find material on the point of view.

Is there a proper word for it?


texts: Perspective projection matrix with a non-orthogonal near plane

texts: I'm trying to figure out a way to provide such a perspective projection matrix to a shader that the "near" plane wouldn't necessarily be orthogonal to the camera vector. More specifically, I'm basically trying to clip all vertices above a certain y-coordinate, but I don't have access to the shader programs themselves. Is there such a matrix that would throw those vertices with a y-coordinate over some specific value outside of the clip space?


texts: Calculate turn rate between xy and target xy on a moving sprite with variable speed

texts:
My First question on here so be kind...

I am writing an aerodrome simulator in as2, I need to calculate a turn rate between 2 points so that the aircraft turns nicely. I have tried a few things but the maths forums on this type of subject use complex calculations and I struggle to understand them. I need an answer in a more variable specific format.

I have the XY of both tile and target, the speed of tile and the distance of target from the tile.

I use vector math, with frame time calculations to move the tile. I already have a good calculation for shortest turn i.e. left right.

I need to calculate the turn rate required to go from point a to point b in a nice fluid motion and turn the tile/aircraft in a nice fashion.

Any help would be much appreciated.


texts: Collision response and delta-time problems

texts:
I'm working on a 2d top-down shooter game. At the time, I am trying to get the movement and collision right, but I have a few problems with this.
First of all, I am making my game frame independent with delta time but that makes it harder for me to implement a collision system.

For example, I am checking collisions like this(java and libgdx):

public boolean collision(Rectangle collision) {
    this.setX(this.getX() + this.delta.x);
    this.AABB.x = this.getX();

    if (this.AABB.overlaps(ext))
    {
        this.setX(this.getX() - this.delta.x);

        this.AABB.x = this.getX();

        collided = true;
    }

    // The same for Y
    this.setY(this.getY() + this.delta.y);
    AABB.y = this.getY();

    if (AABB.overlaps(ext))
    {
        this.setY(this.getY() - this.delta.y);

        AABB.y = this.getY();

        collided = true;
    }

    if (collided)
        System.out.println("Collided, setting X to " + this.getX() + " and Y to " + this.getY());

    return collided;
}

Basically, I move the character on X, if there is a collision, I move it back to where it was before, and do the same for Y.The problem with this approach is that as the movement is frame independent, every frame delta.x and delta.y will be different, so when moving the player back to where it was before colliding will end up in different results.

    this.setX(this.getX() + this.delta.x); // delta.x is a little bit different every frame because of delta time.
    this.AABB.x = this.getX();

    if (this.AABB.overlaps(ext))
    {
        this.setX(this.getX() - this.delta.x); // So this will also bring me back to a different location every frame.

        this.AABB.x = this.getX();

        collided = true;

How can I deal with this(or is this acceptable, as it is almost invisible)?

Any help apreciated, thanks!


texts:
As the title. I have stuck on this:
When many agents have same destination, they will be stuck with each other. I want they find a new path as character in the picture a attached below
How can i make agent more clever like this gif bellow. Any one have experiemnt or solution on this? Thanks!


texts: Setting collider in 3D map (blender file)

texts:
New to gamedev and I also have no idea about 3D files but, I'll try to explain the best I can. We are using our own custom engine built in C++ with OpenGL (glm, gl3w, glfw, entityx)

We have a 3D map in a Blender file (.dae), We want to set the colliders for the hitboxes so the player can't step outside. My colleagues started doing it by hand, but it would take a tremendous amount of work none of us want to spend doing a trivial task.

We worked with the same map in 2D (doing the same game in 2D and 3D), and my colleagues used a program to do it visually and then importing a .tmx file (I don't really know how or what program). The question is, is there a way to do the same in 3D? They say Blender (used to create the map) does not provide the tools necessary, or they probably don't know how.

Thanks in advance and sorry if I explained something wrong, I'll gladly answer any questions.


texts:
So I looked up a tutorial on how to scale sprites in XNA and I think I have it all figured out.

The only problem is that I want to use a spriteBatch.Begin() method overload without changing anything except for the Matrix.

The only spriteBatch.Begin() method that has a Matrix as a parameter is this one:

public void Begin (
         SpriteSortMode sortMode,
         BlendState blendState,
         SamplerState samplerState,
         DepthStencilState depthStencilState,
         RasterizerState rasterizerState,
         Effect effect,
         Matrix transformMatrix
)

I don't really want to mess around with any of the parameters except to pass in my matrix. How would I do that?


texts: Techniques for managing vertex buffer memory

texts:
I'm learning OpenGL and I haven't seen any advice on managing vertex buffers in all of the tutorials I've read.

The basic problem is that I have some memory allocated as a buffer B in which I'm going to store vertex data to send to the graphics card.

Then I have the data that represents my domain D. This is the data that the game's simulation is run against. Let's say in a simple case it's just a list of 100,000 circles that will be moving around. Let's also assume that all of the data can, but might not, change every frame. Nothing is necessarily static.

I'm looking for the techniques people use to efficiently fill B with D.

I could create a new B each frame, but I imagine that would be very expensive.

I could give every object in D a pointer to a location in B and have it update that pointer directly, but that strikes me as error prone as then I have to manage all of these pointers.

I could also traverse D and fill a reused B every frame. This is what I'm currently leaning towards. The only problem here is that I'm forced to update every vertex in B every frame (because the location of the vertex data for a particular D could change within B) unless I come up with a more sophisticated scheme that guarantees that that an object in D always gets the same spot in B.

So I can think of several options, but I'm wondering what people typically do. I imagine almost everyone has to solve this problem at some point.


texts: Why does the drag fail when I move too fast?

texts:
I got this code that drags a 2d sphere when i touch the screen:

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

public class Dragstick : MonoBehaviour {

    private Vector3 offset;

    void Update()
    {
        if (Input.touchCount > 0)
        {
            Vector3 touchPosWorld = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
            Vector2 touchPosWorld2D = new Vector2(touchPosWorld.x, touchPosWorld.y);

            RaycastHit2D hitInformation = Physics2D.Raycast(touchPosWorld2D, Camera.main.transform.forward);
            if (hitInformation.collider != null)
            {
                GameObject touchedObject = hitInformation.transform.gameObject;
                switch (touchedObject.tag)
                {
                    case "Player":
                        Debug.Log("Touched Sphere " + touchedObject.transform.name);
                        touchPosWorld.z = 0f;
                        transform.position = touchPosWorld;
                        break;
                }
            }
        }
    }
}

Thing is, if I move my finger too fast, the drag stops and the sphere drops... also it runs kind of slow when i execute it...

Any help about what am I doing wrong? Maybe I'm making things too complex, drag and drop of a sphere should be really easy but functions in unity have changed a lot.

Thanks in advance!


texts:
For one of my games, I need an enemy that pursues the player in a sort of "lazy" way, where they don't exactly follow the player's movement and instead have somewhat slippery movement. Example: the player does a sharp turn to the right, the enemy will go to that direction too, but it will slightly "overshoot" the distance and go beyond the point where the player turned to the right before going to the new direction. Here is an example:

Some examples from games:

Missiles (Super Meat Boy)
Phanto (Super Mario Bros. 2, the USA one)

Is there a term for this kind of "lazy" movement for homing enemies?


texts: Creating a light that follows the player

texts: How do I create a point light that follows the player character when they walk around? The light should shine on the player and not on a fixed point.


texts:
I'm trying to make a loading screen. My idea is to have two threads working - one in the background loading the 'game' scene, one displaying 'load' scene. When building 'game' scene is finished, it's displayed instead of 'load' scene. Before threading I want to make it work the usual way: first display 'load' scene, then 'game' scene. Both GameScene and LoadScene inherit from a virtual function Scene. Here's how my main looks like:

LoadScene *load_scene;
GameScene *game_scene;
Scene *scene;

int main(int argc, char **argv)
{
// Init GLUT and create window
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL);
glutInitWindowPosition(initWindowX, initWindowY);
glutInitWindowSize(windowWidth, windowHeight);
glutCreateWindow("OpenGL");

// Register callback functions for change in size and rendering.
glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glutIdleFunc(renderScene);

// Register Input callback functions.
// 'Normal' keys processing
glutKeyboardFunc(processNormalKeys);
glutKeyboardUpFunc(processNormalKeysUp);
// Special keys processing
glutSpecialFunc(processSpecialKeys);
glutSpecialUpFunc(processSpecialKeysUp);

// Mouse callbacks
glutMotionFunc(processActiveMouseMove);
glutPassiveMotionFunc(processPassiveMouseMove);
// void glutMouseFunc(void(*func)(int button, int state, int x, int y))
glutMouseFunc(processMouseButtons);
glutMouseWheelFunc(processMouseWheel);
// Position mouse in centre of windows before main loop (window not resized
yet)
glutWarpPointer(windowWidth / 2, windowHeight / 2);
// Hide mouse cursor
glutSetCursor(GLUT_CURSOR_NONE);
// warp

// Initialise input and scene objects.
input = new Input();
//scene = new LoadingScene(input);
load_scene = new LoadScene();
game_scene = new GameScene(input);

// load scene
// Create GameScene();
// Create LoadingScene(GameScene *)
// delete LoadingScene();
// LoadingScene thread tells game to start loafing assetss

// Enter GLUT event processing cycle
glutMainLoop();

return 1;
}

The game scene reassignment must be called in changeSize function. I thought it should be in the renderScene function but it's the only way it works. Here's how it looks like:

void changeSize(int w, int h)
{
scene = load_scene;

scene->resize(w, h);
}

Any ideas how I could go on about it? So far if I assign to 'scene' pointer 'load_scene' object it's displaying 'load' scene. Same goes for 'game' scene.
Is it even possible to achieve a transition between scenes without threading?


texts: libGDX application does not support 800x480 resolution

texts:
I have an application written with libGDX that does not run with a resolution of 800x480, whereas on devices with other resolutions (e.g. 480x320) it works perfectly. It also works perfectly as a desktop application with a resolution of 800x480.

In onCreate() method I only have this code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        initialize(new BreakTheBall(), false);
}

So what do I have to do to have it work in a resolution of 800x480?
I have to ask this question because my samsung galaxy sx2 display only blank screen at the time of game execution but emulator work perfectly. I also want to said that all the given demo application by libGDX could not run on the same device resolution.

Also I like to mention the base class of my project which specify about stage, camera and viewport declaration

protected BreakTheBall game;
protected Stage stage;
protected World world;
protected OrthographicCamera camera;
protected Preferences preferences;
protected ArrayList<Obstacles> boxArrayList;
protected ArrayList<BlastBall> blastBallArrayList;

private static final int VIRTUAL_WIDTH = 480;
private static final int VIRTUAL_HEIGHT = 320;
private static final float ASPECT_RATIO = (float) VIRTUAL_WIDTH
        / (float) VIRTUAL_HEIGHT;
private Rectangle viewport;

// protected Box2DDebugRenderer renderer;

public AbstractScreen(BreakTheBall game) {
    this.game = game;

    Texture.setEnforcePotImages(false);
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
            false);

    Constant.setStageRatio(stage.width(), stage.height());

    world = new World(new Vector2(0.0f, 0.0f), false);
    // camera = new OrthographicCamera(Gdx.graphics.getWidth() / 10.0f,
    // Gdx.graphics.getHeight() / 10.0f);
    camera = new OrthographicCamera((float) VIRTUAL_WIDTH / 10.0f,
            (float) VIRTUAL_HEIGHT / 10.0f);

    // camera.position.scale(0.0f, 0.0f, 0.0f);

    // renderer = new Box2DDebugRenderer(true, false, false);
    Gdx.input.setInputProcessor(stage);

    preferences = new Preferences();
}

@Override
public void render(float deltaTime) {
    GL10 gl = Gdx.graphics.getGL10();

    camera.update();
    camera.apply(gl);

    gl.glClearColor(0f, 0f, 0f, 1f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    gl.glViewport(0, 0, (int) viewport.width, (int) viewport.height);

    world.step(1 / 60f, 3, 3);
    world.clearForces();

    stage.act(deltaTime);
    stage.setCamera(camera);
}

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

    float aspectRatio = (float) width / (float) height;
    float scale = 1f;

    Vector2 crop = new Vector2(0f, 0f);

    if (aspectRatio > ASPECT_RATIO) {
        scale = (float) height / (float) VIRTUAL_HEIGHT;
        crop.x = (width - VIRTUAL_WIDTH * scale) / 2f;
    } else if (aspectRatio < ASPECT_RATIO) {
        scale = (float) width / (float) VIRTUAL_WIDTH;
        crop.y = (height - VIRTUAL_HEIGHT * scale) / 2f;
    } else {
        scale = (float) width / (float) VIRTUAL_WIDTH;
    }

    float w = (float) VIRTUAL_WIDTH * scale;
    float h = (float) VIRTUAL_HEIGHT * scale;

    viewport = new Rectangle(crop.x, crop.y, w, h);

}

I think above specified code provide more guidance to community members so please help me to come out of this problem.


texts: How can I get complete path of a sprite?

texts:
I want to get a path of sprite using the spriteRenderer component in Unity.I want my path should  be like - "asset/PATH OF MY FILE/FILENAME.EXTENSION". Currently I am using following code but it returns only parent name/path.

string GetSpritePath(Transform goPath){
    List<string> path = new List<string> ();

    Transform current = goPath.transform;
    path.Add(current.name);

    while (current.parent != null) {
        path.Insert(0, current.parent.name);
        current = current.parent;
    }

    return string.Join("/", path.ToArray());
}

Whats wrong with my code ?


texts: Is there a plugin to integrate Face FX with Blender? I only see plugins for Maya, Max, SoftImage, and MotionBuilder on the Face FX website.


texts: Displaying pixels on a canvas at 60 hertz

texts:
I'm (new to SO and) attempting to code an "emulator" for an 8-bit CPU I am making with a friend.
I have only ever used Java to make simple GUIs with Swing, and from reading similar questions it seems to me that using repaint() and Graphics2D to display 60fps is not the way to go.

From my attempts at using a custom JComponent to draw, I couldn't agree more. Despite calling screenComponent.repaint() 60 times per second, Java was only updating the screen around 2 times per second, whereas the video memory byte array (stores pixel data) that was also updated 60 times per second (before calling repaint) did change every frame.

So my question is: what can I use to display my one-dimension pixel array (using y * width + x to get pixels at a coordinate) and update it at 60fps?

What I need to be able to do:

draw each individual pixel with a set color
-draw text with a font and size (the computer I am emulating has a toggle able text-only graphics mode)
efficiency is not a huge concern since the main purpose of this is to test assembly programs that will later run on the physical CPU, but it needs to update the screen at 60 Hertz and run CPU clock cycles at least at 1 kilohertz
scale up the canvas as the cpu only displays at 78 by 128 pixels (I did this in swing by using g2d.fillRect to display pixels and multiplying the arguments by a screen size multiplier integer)
not 3D


texts: Where can a game developer/programmer get freelance jobs?

texts:
I'm a game programmer looking for freelance jobs online. I know that there are lots of sites for freelance jobs, but I haven't been lucky with them, I was wondering, which sites are the best for looking for jobs? I know that Freelance.com and upwork.com are some of them, but they ask a lot of profile information and, although I complete it, added a portfolio and have a low hourly rate price for starting (and, by the way, what would be an ideal hourly rate for a starter?) I can't get any jobs because the vicious cycle of not having reputation in the site because I'm not hired because I don't have reputation...

So, resuming the question: What would be the best sites/way to get a freelance job as a Game Programmer through the web?

Thanks!


texts: Can you use python, c and c++ in udk without plugins?

texts: Im pretty new to game engines and i was wondering if I could use python, c and c++ in udk. I've tried getting the answer all over the internet but the answers  i do find aren't very clear. So am i able to use the aforementioned languages without the use of plugins or special downloads, and please mention any other languages already built into udk.


texts: How can I keep the drawn lines instead deleting them?

texts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DrawLines : MonoBehaviour
{
    private Transform startMarker, endMarker;
    public GameObject[] waypoints;
    private float speed = 2f;
    private float startTime = 0f;
    private float journeyLength = 1f;
    private int currentStartPoint = 0;
    private LineRenderer lineRenderer;

    public void StartInit()
    {
        currentStartPoint = 0;
        SetPoints();
        lineRenderer = GetComponent<LineRenderer>();
        lineRenderer.startWidth = 0.2f;
        lineRenderer.endWidth = 0.2f;
    }
    void SetPoints()
    {
        startMarker = waypoints[currentStartPoint].transform;
        endMarker = waypoints[currentStartPoint + 1].transform;
        startTime = Time.time;
        journeyLength = Vector3.Distance(startMarker.position, endMarker.position);
    }
    void Update()
    {
        if (waypoints.Length > 0)
        {
            float distCovered = (Time.time - startTime) * speed;
            float fracJourney = distCovered / journeyLength;
            Vector3 startPosition = startMarker.position;
            Vector3 endPosition = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
            lineRenderer.SetPosition(0, startPosition);
            lineRenderer.SetPosition(1, endPosition);
            if (fracJourney >= 1f)
            {
                if (currentStartPoint + 2 < waypoints.Length)
                {
                    currentStartPoint++;
                    SetPoints();
                }
                else
                {
                    //if finished, disable lineRenderer and this script
                    lineRenderer.enabled = false;
                    this.enabled = false;
                }
            }
        }
    }
}

Each time it's drawing a line between two waypoints but then the line is deleted and then it's drawing a new line between the next two waypoints.

Instead I want it to draw one line between all the waypoints. And to keep the line in the end not to delete it.


texts: Set / Get UserPointer - What Do They Do?

texts:
I see a lot of talk about glfwGetWindowUserPointer() and glfwSetWindowUserPointer() but I can't for the life of me understand what these functions actually do.

From http://discourse.glfw.org/t/what-is-a-possible-use-of-glfwgetwindowuserpointer/1294:

  "If you are trying to use glfw in a program that follows object-oriented design, for example, you can use this pointer to store the address of the instance that is handling a particular window, and forward the callbacks (which have to be static functions, because of the way the API works) to the appropriate member functions."

The author of that comment then posts the following example:

/* Constructor for the MyWindowHandler class */

MyWindowHandler (GLFWwindow * window)
{
....
    glfwSetWindowUserPointer(window, reinterpret_cast<void *>(this));
}

/* Key event callback wrapper function */

static void key_callback (GLFWwindow * window, int key, int scancode, int
                                                        action, int mods)
{
    MyWindowHandler * handler =
    reinterpret_cast<MyWindowHandler *>(glfwGetWindowUserPointer(window));

    if (handler)
        handler->keyEvent(key, scancode, action, mods);
}

What confuses me is that (at least as far as I can tell) I was able to achieve the exact same outcome in my program without using glfwSetWindowUserPointer() or glfwGetWindowUserPointer() at all.

/* Class constructor (just provided for reference) */

GLFW::GLFW(int right, int top)
    : m_Window(0)
{
    if (!glfwInit())
    {
        std::cout << "GLFW initialisation failed!\n";
        __debugbreak();
    }

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    m_Window = glfwCreateWindow(right, top, "OpenGL Window", NULL, NULL);

    if (!m_Window)
    {
        glfwTerminate();
        std::cout << "Could not create window!\n";
        __debugbreak();
    }

    glfwMakeContextCurrent(m_Window);
    glfwSwapInterval(2);

    if (glewInit() != GLEW_OK)
    {
        std::cout << "GLEW initialisation failed!\n";
        __debugbreak();
    }

    std::cout << glGetString(GL_VERSION) << std::endl;
}

/* My callback member function */

void GLFW::MouseMovement(int x, int y)
{
    std::cout << "Mouse moved\n";
    // do other stuff...
}

/* Main.cpp */

static void MouseMovementCallback(GLFWwindow* window, double x, double y)
{
    GLFW* glfw = nullptr;
    glfw->MouseMovement(x , y);
}

int main()
{
    GLFW glfw(1200, 600);
    glfwSetCursorPosCallback(glfw.GetWindowID(), MouseMovementCallback);

    // ......
    // ......
}

In the above code my 'MouseMovement' callback function was called... so I'm rather stumped as to what the purpose of the glfwGetWindowUserPointer() and glfwSetWindowUserPointer() functions actually is.

I'm sure there is something rather obvious that I am missing here, hopefully someone can enlighten me.

Thanks in advance.


texts: How do I disassemble a 3x3 transformation matrix into rotation and scaling matrices?

texts:
I have a transformation matrix that rotates and scales. Is there any easy way to disassemble it into the original rotation and scaling matrices?

For instance:

M = R * S;
// I need f and h such that
R = f(M); S = h(M);


texts: Intersecting Ray with Extruded 2D Shapes (e.g. Extruded Text)

texts: I'm looking for a way to find intersection between a ray and an extruded 2D shape or text (defied by a Bézier curve). Any ideas?


texts: Draw many flashlights' focused lights' "circles" on a voxel engine map (and other objects)

texts:
So, I've been searching the internet for a while and I still didn't understand how to create a flashlight's "circle" in front of the camera over other objects.

I found the following links:

using shader;

multi pass effect;

forum question about multiple passes and multiple effects;

shader example with multiple lights (which I can't open because its an old project).

And they give me examples and solutions about how to draw lights or other effects on objects.

But it's not clear to me yet. I'm newbie with HLSL (and still a little with XNA itself) and I don't get what should I do. I need help with the steps I should take to modify my HLSL effect* of the voxel engine to draw a white circle where the cursor points and shine the light around the camera position as the flashlight is on.

*I created a voxel engine that uses a effect (modified a little) I found in a project called TechCraft. It changes the light on the map depending of the time of the day and the sun position. But I'm not sure how it works neither, I just read a little but I'm not used to HLSL as I said. (Where could I find good HLSL tutorials?)

Do I need to make many passes and make a pixel shader and a vertex shader for each one? Or should I create many techniques? What's the difference?

Or is that a bad idea? Should I create another effect and draw again the voxel with its technique and pass?

And maybe it's not only one light. If I'm able to create a multiplayer someday, or NPCs, the game will have more than one light on at the same time. How to draw more than one circle?

I'm really lost with this, and I have no idea where should I start from. I appreciate any help; even showing already answered questions is helpful to me.


texts: How to structure tic tac toe game loop (or equivalent simple turn based game)?

texts:
I'm developing the simple Tic Tac Toe game in Java and got stuck on the game loop architecture.

The game must support local, remote and automatic players.
The graphical interface is based on JavaFX.

How can I best structure the game loop so that the game logic is as separate as possible from the graphic interface?

I have thought of two approaches to solve this problem

Approach 1 - wait/notify

The simplest approach I thought of is to develop classes for each type of player (remote, interactive and automatic) and implement the necessary code within the mark (Board) method. The update method iterates the players and for each one executes the mark method.
In the case of the AI, no problem, but in the case of the interactive player I would find myself having to pause the current thread while waiting for input from the graphic interface thread. A solution that does not convince me.

public synchronized void mark(Board board) {
    nextMarkLocation = null;
    try {
        if(nextMarkLocation == null) {
            wait();
        }
    } catch (InterruptedException e) {
        // handling
    }

and

public synchronized void setNextMarkLocation(Location location) {
    nextMarkLocation = location;
    notify();
}

Approach 2 - expose methods

The second approach would be to implement the methods for setting the current player's action in the game class. In this case, at each execution of the update method the routine would be the following (pseudo code):

public void update() {
    var player = getCurrentPlayer();
    var location = player.getNextMarkLocation();
    var symbol = player.getSymbol();
    board.markCell(location, symbol);
    updateCurrentPlayer();
}

The GUI will take care of updating itself according to the update of the match and setting the action for the current player. Here a check should be placed on the GUI owner. If the current player is not the same as the GUI owner, the game must ignore the action.

But the problem would be the reverse: And the automatic players?

Do you have any suggestions? Thanks


texts: Is there an specific isometric tile map handler in cocos2d-x? I can't find any.


texts: How to correctly implement 'layered lighting' with Box2D-Lights

texts:
How does one only allow Box2D-Lights to affect one and only one OrthographicCamera.

After researching, I found the following answer. This answer goes into detail about how to prevent one camera from being lit by the RayHandler by blending layers of the FBO object. I'm unsure if this answer will produce the results I require. If it indeed does create the results I require, how can I do so more simply/elegantly.

For example:

1) In this image you can see ambient light is set to:

this.rayHandler.setAmbientLight(new Color(0.1f, 0.1f, 0.1f, 0.25f));

2) There is a point light on the far right with purple colour.

4) There is a star background on a different OrthographicCamera to the other objects.

When looking at this image, you notice that the stars are brighter near the planet due to the point light casting light on the background. However, I require the inverse. The stars should be brighter when light is not drowning them out. Knowing that the star background is on a different OrthographicCamera how can I allow the texture to be completely unaffected by light so the ambient light of the RayHandler does not dim them further away from the planet.

The texture used for the stars contains transparency. The black is created using:

Gdx.gl.glClearColor(0f, 0f, 0f, 1);

Preferably, I would like to be able to simply place cameras into two lists, affected by light and not affected by light. How does I produce the results I require?

I can manage to get the lighting to ignore the star background by rendering it after the RayHandler has been updated and rendered, however this obviously causes the star background to be drawn over the top of everything like so:

After achieving this, I was reminded of the OpenGL depth buffer. I enabled it using Gdx.gl.glEnable(GL20.GL_DEPTH_TEST), I then attempted to change the z coordinate of the spritebatch used in the camera for the star background by using SpriteBatch.getTransformMatrix().idt().translate(0f, 0f, -1f) however after playing with the values of the other sprite batches I can still not get the effect I require.

It is possible that the above method did indeed work, although I am aware that using the depth buffer incorrectly can cause issues with alpha blending? Making it seem like my problem was not fixed because the planet became translucent.


texts: OpenGL: Generating a single square with a Quad Strip

texts:
I am currently trying to create a terrain generation system (for my 3D game) with OpenGL 2.1.

The way I am doing it requires the creation of a massive 2D square that consists of multiple smaller squares. After the flat square is generated, the points are randomly offset in the y axis, making it into a 3D structure.

But I can't seem to figure out how to generate this using GL_QUAD_STRIP. Can someone please help me figure this out?

Thanks!

P.s. I know my method may not be the best, but I would like to get it to work anyway as it suits my game


texts:
I want to develop basic level GameRanger link game lobby.

I am using Winform, C# Framework 4.0.
currently i am exploring below code
https://www.codeproject.com/Articles/14050/A-game-lobby-system-in-C?msg=5449482#xx5449482xx

But getting error to load gametypes/bridge.dll

desktop app GUI


texts:
Should an AABB "contain" a point when the point is:

Exclusive: Only exactly inside the aabb
Inclusive: Inside the aabb or exactly on the sides
Almost:  Inside the aabb or a little bit outside of the sides


texts: Audio Engines , do they work on CPU, GPU or DSP

texts:
I have been reading design specifications of the audio engines. What I am trying to achieve requires performance and I want to parallelize.

Only and only while reading openAL specification it was mentioned very very shortly that if hardware supports than openAL will use DSP as well.

But I am curious for other engines as well and couldn't find information for wwise for example.

In general do audio engine takes advantage of DSP or even GPU maybe ?


texts: How can I test if one point can "see" another point. (XNA)

texts:
I want to test if my enemy can see the player, however I want this to be pixel-perfect.

I already have all of the solid objects drawing into a separate render state. It should be noted that every solid object is changing and warping all over the place constantly. I cannot check individual walls because a distortion effect is applied to all of them. The walls blend together.

Essentially it would lerp between the enemy's position and the player's position and see if there are any pixels that have an alpha value of greater than 0.
The rotation of the enemy and the player do not matter.

All of my attempts at doing this on the cpu have worked, however they slowed the game down dramatically. All of my attempts at going this on the gpu just didn't work at all.

What is the most efficient way of doing this?
Is there any way to do this in the gpu?

Edit: There is no geometry at all. The walls are completely amorphous.

I did not realize that global variables were constant in hlsl until after I wrote this:

sampler s0;
texture tex;
sampler tex_sampler = sampler_state{Texture = tex;};

float2 screenSize;
float2 from;
float2 to;
float2 impact;
int impacted;

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
    from /= screenSize;
    to /= screenSize;

    impacted = 0;

    for (float i = 0; i < 1; i += 1.0f / length(to - from))
    {
        float2 test = lerp(from, to, i);

        if ( (tex2D(tex_sampler, test)).a )
        {
            impacted = 1;
            impact = test * screenSize;
            break;
        }
    }

    return tex2D(s0, coords);
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}

The solid pixels would be passed into the "tex" variable.
I would read the "impacted" and "impact" variables after one pass on a 1x1 texture.
hlsl just doesn't want to let me do this.
Apparently global variables are implicitly constant.
Is there another way of doing this?

on the variable syntax page it says "Global variables are considered const by default (suppress this behavior by supplying the /Gec flag to the compiler)."
How do I add the /Gec flag to the compiler?

I also wrote this, but it slowed the game down:

private bool CanSee(Vector2 from, Vector2 to)
{
    Color[] t = new Color[target_solid_final.Width * target_solid_final.Height];
    target_solid_final.GetData(t);

    for (float i = 0; i < 1; i += 8.0f / (to - from).Length())
    {
        Vector2 test = Vector2.Lerp(from, to, i);
        Point test_p = new Point((int)test.X, (int)test.Y);

        if (viewportRect.Contains(test_p) &&
            t[test_p.X + test_p.Y * target_solid_final.Width].A > 0)
            return false;
    }

    return true;
}


texts: Examples of good Javascript/HTML5 based games

texts: Now that Flash is largely being replaced with HTML5 elements (video, audio, canvas, etc.) are there any good examples of web-based games built on completely open standards (meaning Javascript, HTML and CSS)? I see a lot of examples of pure HTML5 implementations of what was once only in Flash (like stuff here: http://www.html5rocks.com/) but not many games, a domain which still seem dominated by Flash. I'm curious what's possible and what the limitations are.


texts: Add and remove tiles? Or better to have them all loaded off screen?

texts:
Which method do you expect would have better performance when stressed?  It's a 2D tile map where the camera has view of a small portion of the map.  As I pan up/down/left/right, should I be adding and removing tiles from the stage as needed? or have them loaded, offstage, and just change their x/y coords as needed?

I'm using AS3 to code this and I have it working fine.  And I know it's not wise to try to optimize early, but since I'm very new at this, I thought maybe someone already knows if one is usually better.


texts:
In teh tangent space vertex attributes why is the bitangent (aka binormal) provided as an attribute instead of calculated?

If the three vectors of the tangent space must be perpendicular then the bitangent can be calculated as the cross-product of the other two vectors. There are technically two perpendiculars here, but surely we could consistently calculate the one we want, even if it requires a boolean marker to negate it.

Similarly the bitangent itself doesn't need a full vector to be represented. From the normal alone we know the plane on which the tangent must reside. In theory a simple angle would be enough to calculate the tangent vector.

Given that GPU memory is at a premium why do we provide the full vectors for these values rather than calculating them (with reduced data input)?  Or am I wrong in assuming the tangent space must be a cartesian system?


texts:
I'm trying to draw a filled rectangle in Libgdx and according to the API this should work:

shapeRenderer.begin(ShapeRenderer.ShapeType.FilledRectangle);

But it gives me an error and tells me to change FilledRectangle to Filled, Pointor Line.

imports: import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

Any ideas on what is causing this?


texts: Check which Player got highest Number from Dice

texts:
I am doing a Ludo Game and currently i need to check which Player got the Highest Number from the Dice and the player which has the highest number goes on the starting position. Currently i created this method to check which player got the highest number then the player which has the highest numbers runs the method MovePlayer()

public void FirstTurn(){
    player1Steps = GameObject.Find("Player1").GetComponent<LevelManager>().randomNumberSteps;
    player2Steps = GameObject.Find("Player2").GetComponent<LevelManager>().randomNumberSteps;

    if(NetworkManager.MyGamePlayerId == "Player1" && player2Played == true)
    {
        MovePlayer();
    } else if(NetworkManager.MyGamePlayerId == "Player2" && player1Played == true)
    {
        if(player2Steps > player1Steps)
        {
            MovePlayer();
        }
    }
}

I am using the Photon Cloud Service since this is a multiplayer Game
Thanks


texts: How does the fragment shader get data from the vertex shader?

texts:
How can any interactions between these two shaders work? I mean the vertex shader sends a vertex's color to the fragment shader, but that's only one fragment, what about all the other ones between the vertices?

Does the fragment shader get called a lot more than the vertex shader?

I mean the fragment-to-vertex ratio is pretty high in most games, given that a fragment is a pixel, right?


texts: Setting the main camera's size to be equivalent to the device's width and height

texts:
Making a 2D game with Unity. I need a way to set the main camera's width and height to be equal to the mobile device's resolution. So if you're using an iPad Mini 3, then the main camera will be 2048 × 1536 pixels. Or an iPhone 4, it will be 960 × 640.

Is there a way to calculate the main camera's size this way?

Here's some data:

For Galaxy S5, which is 1920 x 1080, I found that the camera should have a size of 540, and a viewport rect width of 1.33 and height of 1.

For an iPad mini 3, which is 2048 x 1536, the camera seems to be better with a size of 770. The viewport rect can stay at 1 width and 1 height.

All of that was calculated manually. Surely there is a formula for this?


texts: Activate and Deactivate Mouse Cursor on UI

texts:
I have a player with a character controller component.

When the player is generally interacting with the UI I would like to stop the character and camera controller and show the cursor to the player in order to (e.g select a weapon) and when they're done I would like it to switch back.

How do I address this issue?


texts: Sending changes to a terrain heightmap over UDP

texts:
This is a more conceptual, thinking-out-loud question than a technical one. I have a 3D heightmapped terrain as part of a multiplayer RTS that I would like to terraform over a network. The terraforming will be done by units within the gameworld; the player will paint a "target heightmap" that they'd like the current terrain to resemble and units will deform towards that on their own (a la Perimeter).

Given my terrain is 257x257 vertices, the naive approach of sending heights when they change will flood the bandwidth very quickly - updating a quarter of the terrain every second will hit ~66kB/s. This is clearly way too much.

My next thought was to move to a brush-based system, where you send e.g. the centre of a circle, its radius, and some function defining the influence of the brush from the centre going outwards. But even with reliable UDP the "start" and "stop" messages could still be delayed. I guess I could compare timestamps and compensate for this, although it'd likely mean that clients would deform verts too much on their local simulations and then have to smooth them back to the correct heights. I could also send absolute vert heights in the "start" and "stop" messages to guarantee correct data on the clients.

Alternatively I could treat brushes in a similar way to units, and do the standard position + velocity + client-side prediction jazz on them, with the added stipulation that they deform terrain within a certain radius around them. The server could then intermittently do a pass and send (a subset of) recently updated verts to clients as and when there's bandwidth to spare.

Any other suggestions, or indications that I'm on the right (or wrong!) track with any of these ideas would be greatly appreciated.


texts: What exactly are "semaphore signal operations" in the Vulkan specification and how do they relate to a CommandBuffer?

texts:
In section 7.4.1.Semaphore Signaling of vulkan specification,

https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#synchronization-semaphores

"When a batch is submitted to a queue via a queue submission, and it includes semaphores to be signaled, it defines a memory dependency on the batch, and defines semaphore signal operations which set the semaphores to the signaled state."
What are operations in this sentence?And what is the difference between pipline stages and operations?Is this semaphore signal operation inserted into queue and wait to be executed like stages which a CommandBuffer consists of?


texts: What is the Xbox360's D3DRS_VIEWPORTENABLE equivalent on WinXP D3D9?

texts:
I posted this on StackOverlow, but of course it should be posted here.

I am maintaining a multiplatform codebase for Xbox360 and WinXP. I am seeing an issue on the XP side that appears to be related to D3DRS_VIEWPORTENABLE on the Xbox360 version not having an equivalent on WinXP D3D9. This article had an interesting idea, but the only way to construct an identity matrix is to supply negative numbers to D3DVIEWPORT9::X and D3DVIEWPORT9::Height, but they are unsigned numbers. (I tried to put in negative numbers anyway, but nothing interesting happened.)

So, how does one emulate the behavior of D3DRS_VIEWPORTENABLE under WinXP/D3D9?

(For clarity, the result I'm seeing is that a 2d screen-aligned quad works fine on Xbox360 but is offset/stretched on WinXP. In fact, the (0, 0) starts in the center of the screen on WinXP instead of in the lower-left corner like on the Xbox360 as a result of applying the viewport transform.)

Update: I didn't have an Xbox360 devkit at the time I wrote up this question, but I've since gotten one. I commented out the disabling of the D3DRS_VIEWPORTENABLE state, and the exact same behavior resulted on the Xbox360 as on the WinXP build. So, there must be some DirectX magic to bridge the gap here for emulating D3DRS_VIEWPORTENABLE being turned off on WinXP.


texts: How would you have a range of movement within a class in pygame?

texts:
I have blitted 4 zombies to the screen in pygame. First, the zombies will wander in a specific region (let us say a 10 x 10 area). And when the player enters any one of the zombie's areas, the zombie should target the player.
import pygame, random, os
from pygame.locals import *

pygame.init()

scr_width = 1020
scr_height = 510
screen = pygame.display.set_mode((scr_width, scr_height))

clock = pygame.time.Clock()

images = {}
path = 'Desktop/Files/Dungeon Minigame/'
filenames = [f for f in os.listdir(path) if f.endswith('.png')]
for name in filenames:
    imagename = os.path.splitext(name)[0]
    images[imagename] = pygame.image.load(os.path.join(path, name))

pygame.display.set_caption('Dungeon Minigame')

font = pygame.font.SysFont('Times_New_Roman', 27)

white = [240, 240, 240]

fps = 60
lives = 3
score = 0

playerX = 510
playerY = 220
playerxchange = 0
playerychange = 0

def player(x, y):
    screen.blit(images['r_knight'], (playerX, playerY))

class Enemy:
    def __init__(self):
        self.x = random.randint(8, 800)
        self.y = random.randint(8, 440)
        self.moveX = 0
        self.moveY = 0

    def move(self):
        self.speed = 3
    def draw(self):
        screen.blit(images['r_zombie'], (self.x, self.y))

def enemy(x, y):
    screen.blit(images['r_zombie'], (x, y))

enemy_list = []
for i in range(4):
    new_enemy = Enemy()
    enemy_list.append(new_enemy)

while True:

    screen.blit(images['background'], (0, 0))

    score_text = font.render('Score: ' + str(score), True, white)
    lives_text = font.render('Lives: ', True, white)

    screen.blit(score_text, (20, 20))
    screen.blit(lives_text, (840, 20))

    onpress = pygame.key.get_pressed()

    screen.blit(images['r_knight'], (playerX, playerY))

    if lives == 3:
        screen.blit(images['triple_heart'], (920, 0))

    if lives == 2:
        screen.blit(images['double_heart'], (920, 0))

    if lives == 1:
        screen.blit(images['single_heart'], (920, 0))

    if lives <= 0:
        screen.blit(images['triple_empty_heart'], (920, 0))
        if lives < 0:
            lives = 0

    if onpress[pygame.K_a]:
        playerX -= 3
        screen.blit(images['l_knight'], (playerX, playerY))

    if onpress[pygame.K_w]:
        playerY -= 3
        screen.blit(images['l_knight'], (playerX, playerY))

    if onpress[pygame.K_d]:
        playerX += 3
        screen.blit(images['r_knight'], (playerX, playerY))

    if onpress[pygame.K_s]:
        playerY += 3
        screen.blit(images['r_knight'], (playerX, playerY))

    if onpress[pygame.K_w] and onpress[pygame.K_a]:
        screen.blit(images['l_knight'], (playerX, playerY))

    if onpress[pygame.K_s] and onpress[pygame.K_a]:
        screen.blit(images['l_knight'], (playerX, playerY))

    if onpress[pygame.K_w] and onpress[pygame.K_d]:
        screen.blit(images['r_knight'], (playerX, playerY))

    if onpress[pygame.K_s] and onpress[pygame.K_d]:
        screen.blit(images['r_knight'], (playerX, playerY))

    if playerX <= -8:
        playerX = -8
    elif playerX >= 965:
        playerX = 965

    if playerY <= 5:
        playerY = 5
    elif playerY >= 440:
        playerY = 440

    for enemy in enemy_list:
        enemy.move()

    for enemy in enemy_list:
        enemy.draw()

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()

    clock.tick(fps)
    pygame.display.update()

Output


texts: How can I limit the rotation angle of the object?

texts:
At the top
float speed = 1.0f;
float rotationAngle = 45;

In Update :
private void Update()
    {
            if (Mathf.Approximately(transform.localPosition.y, 7))
            {
                float rotationY = rotationAngle * Mathf.Sin(Time.time * speedRot);
                transform.Rotate(new Vector3(0f, rotationY, 0));
            }
    }

but it's just rotating nonstop at the same direction.
I need it to rotate for example in the limited range of 45 to both sides like a ping pong from side to side. and optional to make it to rotate in limited angle/s for all axis but now for the Y how to limit it like a ping pong to rotate 45 degrees to the right then back to the left and so on nonstop but in limited angle/s.


texts: What elements of D3DPRESENT_PARAMETERS MUST be set?

texts:
DIRECTX9...
For ages, I've shipped games that only half-fill out the D3DPRESENT_PARAMETERS structure, and now I'm wondering if this is buggy. The items I'm worried about, and never set are:

hDeviceWindow
Windowed
EnableAutoDepthStencil
FullScreen_RefreshRateInHz

I zero out the whole structure initially, so they should all be zero, even if my game is running (happily) in a window. As ever, there are a tiny %tage of users who have issues, and I am looking for possible causes. Could not setting one of these cause problems? The documentation doesn't say either way, and 99% of users certainly are fine with these settings. Does anyone have a definitive answer as to what should be set?


texts: What kind of physics to choose for our arcade 3D MMO?

texts:
We're creating an action MMO using Three.js (WebGL) with an arcadish feel, and implementing physics for it has been a pain in the butt.

Our game has a terrain where the character will walk on, and in the future 3D objects (a house, a tree, etc) that will have collisions. In terms of complexity, the physics engine should be like World of Warcraft. We don't need friction, bouncing behaviour or anything more complex like joints, etc. Just gravity.

I have managed to implement terrain physics so far by casting a ray downwards, but it does not take into account possible 3D objects.
Note that these 3D objects need to have convex collisions, so our artists create a 3D house and the player can walk inside but can't walk through the walls.

How do I implement proper collision detection with 3D objects like in World of Warcraft? Do I need an advanced physics engine? I read about Physijs which looks cool, but I fear that it may be overkill to implement that for our game.

Also, how does WoW do it? Do they have a separate raycasting system for the terrain? Or do they treat the terrain like any other convex mesh?

A screenshot of our game so far:


texts:
I have a problem here with GameMaker built-in physics environment.My player is designed to be on a skateboard. I want my player to rotate its sprite, according to the kind of fixture(up or down slopes) he is moving on.I've tried everything i could and everything i could find, but it didn't help me much, because the object is rotating in a very strange way.I enabled some flags to see the mask. Also, I've been studying vector algebra and i know it the angle between vector x speed and vector y speed should be the direction. Please help. Here's what i have so far:

1 object which is the player
Information about object: obj_Player
Sprite: sprite7
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: obj_Static_Parent
Children:
Mask:
Physics
Start Awake: true
Is Kinematic: false
Is Sensor: false
Density: 0.5
Restitution: 0.1
Group: 0
Linear Damping: 0
Angular Damping: 0
Friction: 0.2
Shape: Polygon
Points:
(76, 52)
(76, 60)
(0, 56)
(0, 52)
Create Event:
execute code:

///Initialize the tires
var half = sprite_width / 2;
var halfy = sprite_height / 2;
var tire = instance_create(x-half+12,y+halfy,obj_Wheel);
physics_joint_revolute_create(id,tire,tire.x,tire.y,0,0,0,0,0,0,false);
var tire = instance_create(x+half+12,y+halfy,obj_Wheel);
physics_joint_revolute_create(id,tire,tire.x,tire.y,0,0,0,0,0,0,false);

Step Event:
execute code:

//Code
facing = -point_direction(0, 0, phy_speed_x, phy_speed_y);
phy_fixed_rotation = true;
phy_rotation = facing;

//Move him
if(keyboard_check(vk_space)) {
physics_apply_impulse(x,y,0,-100);
}
if mouse_check_button(mb_left)
{
phy_position_x = mouse_x;
phy_position_y = mouse_y;
}

Information about object: obj_Wheel
Sprite: spr_Wheel
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: obj_Static_Parent
Children:
Mask:
Physics
Start Awake: true
Is Kinematic: false
Is Sensor: false
Density: 0.05
Restitution: 0.1
Group: 0
Linear Damping: 0.1
Angular Damping: 0.1
Friction: 30
Shape: Circle
Points:
(8, 8)
(8, 8)
Create Event:
execute code:
Keyboard Event for  Key:
execute code:
            physics_apply_torque(-100);
Keyboard Event for  Key:
execute code:
            physics_apply_torque(100);

And here is the result:
  http://i.stack.imgur.com/sn1qh.gif


texts: How to make a cube mesh and texture for XNA use?

texts:
I have a very specific question which I feel should have a very short answer, but which I can't seem to find despite Googling on and off all day.

I'm trying to start with 3D graphics, and I read up a bit on the theory, etc. and I know the math.  The issue is just with software.  I'm trying to make a cube, which appears to be made of dirt (honestly solid brown would be fine), to appear on the screen.  Technically I'm using XNA but I don't think this affects the answer or question very much.

I know how to make a functioning mesh/texture combo appear on the screen properly (I've read http://msdn.microsoft.com/en-us/library/bb975644(v=xnagamestudio.31).aspx among others); the issue is producing the texture itself.

For example, with Blender, I can easily make a cube and stick a procedurally generated texture on it that looks pretty good, but when I export as, say, .fbx, I get a mesh (and I think no texture data) and it doesn't work (as in doesn't appear on the screen but doesn't give an error message, which is consistent with the "no texture data" hypothesis).

So one great answer would just be to tell me how to export texture data from Blender along with, or in addition to, the mesh.

One other great answer would be to tell me how to produce textures in a different (free) program that is perhaps better suited (Blender may not be the right choice, I don't know anything about it).

Either answer or some completely other kind of answer is fine.  But I feel like this should be a simple problem to solve, and I don't think I can stand another 30 minute youtube video that doesn't answer the question.


texts: How do you get the best rendering performance in a 2D Java Game?

texts:
I have seen a lot of tutorials, and they develop games with 2 different ways:

The first one is using a virtual image (BufferedImage) and filling it's pixels. And displaying virtual picture.

private BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
private int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
private int[] colors = new int[6 * 6 * 6];

Second one is using lots of real images. And displaying they.

SpriteSheet sheet = new SpriteSheet(ImageLoader.loadImage("/textures/sheet.png"));

    //PLAYER SPRITES PROVIDED BY: AddFact
    player = sheet.crop(width * 4, 0, width, height);

    dirt = sheet.crop(width, 0, width, height);
    grass = sheet.crop(width * 2, 0, width, height);
    stone = sheet.crop(width * 3, 0, width, height);
    tree = sheet.crop(0, 0, width, height);

First Question: Which one has the best performance ?

Second Question: How should we load maps? With images or with text files ? Which one is good to chose ?

Sorry for my english. I hope I can explain to you :) Thanks for helping, have a nice day ^^