texts: How to get access to Nintendo Switch development environment?

texts:
I would like to make game for Nintendo Switch.

I have been searching for an SDK of the same, but I couldn't find any. The only thing I found was that I can use Unreal Engine or Unity to make games for Nintendo Switch.

However I don't want to use any of these game engines and instead want to code from scratch, making my own game engine in the process.

Isn't there a C/C++ (or any language) sdk which will allow me to make games for Nintendo Switch without using Unreal/Unity or any other game engine ?


texts: HTML 5 multiplayer game with java server logic code duplication?

texts:
I want to make a browser multiplayer game with java server.
I'm still in the design stage and i'm deciding what technologies to use.
But i stumble upon the problem when the client need the same logic as the server to predict movement and events before the response from server is received.
And i don't want a code duplication javascript and java.

So what are my options ?


texts: Creating a vehicle using a physics engine

texts:
What is the theory behind creating a generic 3D vehicle in a physics engine?

What I would like to know is what parts should I stick together to make the vehicle, how they parts should stick together, and how to make the vehicle have the feel and movement of what you expect of a vehicle.

I'm not looking for any code, or how to do it with a specific engine. Just the theory behind how it is done.


texts:
I am using Goblin XNA 3.6.
When I export a 3D model in FBX format from Maya, the model often looks transparent. For some 3D models it works fine though. What could be causing this?


texts:
I am designing a small mobile game. Eventually i am going to release it on Play store and App store. But is there any platform such as Steam Greenlight where I can put my concept or demo and get some good helpful feedbacks before I put it in market.

I found that GOG accepts mobile games but don't know about their process. So can GOG be helpful for me?

(I am sorry if the question is duplicate. Couldn't find any proper answer on google.)


texts:
I'm making a GUI API (in C++) for games which uses Allegro 5 as a backend. I looked at how GuiChan works and noticed that they intend for the user to override the paint event and do all the drawing yourself.

Since I felt that in general, there's a decent standard to how widgets behave, I have a static theme class in each widget class (static ButtonTheme buttonTheme; etc) and the parameters set in that theme are used to construct that widget (from there, the parameters can be changed individually for specific widgets). These sorts of things are: padding, font color, border color, is drawing border, back color, size, min / max size etc).

Where I also differ from GuiChan is in the fact that instead of default drawing being rectangles, the widgets have bitmap pointers and if they are NULL, it draws rectangles like GuiChan, if not, they are drawn with bitmaps: ex: button has default, hover, clicked. And if hover is not provided, the switch case will just use default for hover. Each theme has corresponding bitmaps. I also have bitmaps for focused and disabled.

The user can always choose to override the paint event and do it from scratch.

Is this a good idea or a terrible one to use themes and theming? Should I stay generic like GuiChan?

As game developers , which would you prefer, (no themes, partial themes, partial themes + bitmaps)?

Thanks


texts: How to detect collision direction in Phaser 3

texts:
Please consider this scene. Developed using PhaserJS 3.

I want to make the slider move left when the player touches the right hand side of it, and move right when the player touches the left hand side of it.

This is the code I'm currently using in the collision callback to decide what to do:

  hitSlider: function (player, slider) {
    // ...
      if (player.body.touching.left) {
        slider_actions.moveSliderLeft(slider)
      } else if (player.body.touching.right) {
        slider_actions.moveSliderRight(slider);
      }
  // ...
  }

This works in most cases, EXCEPT that it doesn't check if the player is touching the slider on the left, just that they're touching something on the left.

My screenshot contains an example. If the player stands on top of the slider, and walks left, they are both colliding with the sider and touching something on the left. So the slider moves left.

How can I detect the direction of the collision event itself instead?


texts: Character blocking when walking on cube edges

texts:
I have my character walking on a ground made of cube. (scale 1,1,1). There is no space between them.  Also, I have a RigidBody with 15 drag and I'm moving with AddForce.

When I walk, my character sometimes block when trying to pass over the place where the 2 box meet. Like if my player collider was hitting the collider under him. Any fix for that?


texts: Tools/methods for creating demo videos of iPhone/iPod Touch games?

texts: I'd like to create a simple demo video of a game for iPhone and iPod Touch.  What tools do people use for this?  Ideally I can capture the device's screen... as opposed to the simulator.  Also the game uses tilt controls... hence capturing the device's screen helps put actual game play into the demo video.


texts: Are TestFlight apps the same as the finished product?

texts:
This may be an obvious question, but to me it is a little unclear. I built an app using PhoneGap. While testing with PhoneGap Desktop and the associated app it was pretty obvious that this was just a testing environment. For example, any check to see if it was an iOS device would return false even though the app was up and running  on my iPhone. Also there were some strange positioning issues between what I saw in the browser vs. what I saw on the app.

So, I finished building the app and packed it and uploaded it as a beta app sent via TestFlight to my phone. I was pleased to see I was now passing the iOS checks and some positioning errors were gone. I am curious if I can conclude for sure if I fix any issues to where it looks good in the testflight app it will look good with the real published app or if testflight too uses some sort of test-web-wrapper?

tl:dr; I'm going to guess and check my positioning via the TestFlight App, if it looks good there will it look good in the wild?


texts: Why Minecraft has such a terrible backward compatibility?

texts:
For every release of Minecraft, even a minor release, is almost guaranteed to break some plugins or mod.

Why is this so? I am asking this so that we could avoid the same architecture problem as Minecraft.

I mean, why can't the upgrades also support previous version of minecraft? Minecraft requires an EXACT version number match in order to connect. I am pretty sure the protocol can be designed so that clients should ignore unsupported commands.

For example, if there is new block introduced and the client doesn't understand it, they can just fall back to default/dummy block so that players can still play but start seeing dummy wireframe block or so.

Once they start seeing too much of wireframe blocks they know they should upgrade.


texts: How do I order sprites by depth in Java, when their objects are of different classes?

texts:
I'm developing a game to learn more about Java, and I've run into a problem: My character (the guy) moves, but I can not figure out how to automatically change the order of how the sprites are drawn. Each sprite has a depth, which is just the y value of the bottom of the sprite. If a sprite has a higher depth, then it is displayed in front of a sprite with a lower depth. Here are a few pictures of the problem:

As you can see the first picture, the guy should be in front of the girl.

I was thinking about putting them into an array list, and ordering them based upon their depth, but they are different object types. The guy is an object of class character, and the girl is an object of class NPC. Is there a way to put both of these object types into one array list, or is there a better solution?


texts: Calculate min number of moves (no path involved)

texts:
I'm looking to implement an algorithm that will calculate the minimum number of moves based on the rules below.
Let's say that we have a grid (NxM), as exampled in the image below.

Each cell will be the sum based on the row and column and I can subtract 1 unit from one cell and add it to a neighbour. For example, on the image above, the minimum number of moves on Initial will be 2 and on Initial - 2 will be 4.


texts: A simple map, four biomes, and how to distribute them

texts:
Here's the basic idea: I've got a Rogue-ish, perhaps Dwarf Fortress-ish game, with a randomly generated overworld and several dungeon entrances scattered around it. I already have the dungeons basically covered, but I'm stuck on an aspect of the overworld.

Said overworld, considered as a 2D map of screens, should have a perhaps blob-like distribution of four different themes or biomes -- grasslands, desert, snow and swamp, each with their own total amount of screens. Let's say the map is 8x8, which gives 64 unique screens. Half of those could be grasslands, a quarter desert, and swamp and snow get a quarter each:

It seems palette reduction has made snow the same color as swamp. Originally, there were eight snow screens in the bottom corner, and a slightly staggered eight-screen swamp area in the middle. Sorry 'bout that, and please ignore the location markers.

The best I could get was some snaking shapes, and often enough with nonsensical combinations like desert snaking through snow (or vice versa). I can't for the life of me figure out how to get it nice and blobby, let alone having it make climatical (?) sense. So how do I generate a biome map like in the mockup?

Okay, by request: the world really isn't much bigger than that example, and what I need is just a way to spread some blobs that determine thematic appearances, with the extra limitation that snow can't touch desert. Screens don't scroll, and if a screen is set to "desert", there'll be no grass anywhere on it.


texts: How do I add a random number of points to my score stored in Player Preferences?

texts:
My problem is the value I get from Random.Range is not stored, but I get another value instead.

In level 1 I press the "claim" button to store a randomly-chosen score
In level 2 I retrieve the level 1 score using player preferences.
When I press the "claim" button again in level 2 I want to add the new random score to the score from level 1.

How can I do this?

Here is the code I'm using currently:

playermanager.cs

 internal static int pointsAdd;

 void Start()
 {
       PlayerManager.pointsAdd = PlayerPrefs.GetInt("score");
 }

 void FixedUpdate()
 {
        creditsText.text = PlayerPrefs.GetInt("score").ToString();
 }

 public void GetClaim()
 {
        PlayerManager.pointsAdd = PlayerPrefs.GetInt("score");
        Debug.Log("pointadd" + PlayerManager.pointsAdd);

        PlayerManager.pointsAdd =  Random.Range(20, 40);
        Debug.Log("Your Point is:" + PlayerManager.pointsAdd);
        Debug.Log("random.range" + Random.Range(20, 40));

        PlayerPrefs.SetInt("score", PlayerManager.pointsAdd);

        creditsText.text = ("" + PlayerManager.pointsAdd);
 }

Output:


texts:
Hey, im a newbie at this programming lark and its really frustrating me. I'm trying to move a snake in all directions while using classes. Ive created a vector2 for speed and ive attempted creating a method which moves the snake within the snake class.

Now I'm confused and not sure what to do next.

Appreciate any help. Thanks :D

This is what i've done in terms of the method...

  public Vector2 direction()
        {
                Vector2 inputDirection = Vector2.Zero;

                if (Keyboard.GetState().IsKeyDown(Keys.Left)) inputDirection.X -= -1;
                if (Keyboard.GetState().IsKeyDown(Keys.Right)) inputDirection.X += 1;
                if (Keyboard.GetState().IsKeyDown(Keys.Up)) inputDirection.Y -= -1;
                if (Keyboard.GetState().IsKeyDown(Keys.Down)) inputDirection.Y += 1;

                return inputDirection * snakeSpeed;

        }

Appreciate any help. Thanks :D

EDIT:
Well let me make everything clear. Im making a small basic game for an assignment. The game is similar to the old snake game on the old Nokia phones. I've created a snake class (even though I'm not sure whether this is needed because im only going to be having one moving sprite within the game). After I written the code above (in the snake class), the game ran with no errors but I couldn't actually move the image :(

EDIT2:
Thanks so much for everyones responses!!


texts: Project organization for a multiplayer client-server game

texts:
I'm programming a game 100% in Java but I'm having some issues concerning the final games architecture.

I plan on having two separate projects: one that will hold the client side of communication and another, the server side. As for all the rest, the Player Class, the Main Game class, etc. I'm not sure whether they should be in the server project or the client project... any suggestions?


texts:
When a spell is on cooldown I display a "unfilling" black bar over the spell GUI until the cooldown is reached. Problem is when i have more than one second of cooldown the scale of the "unfilling" black bar getting strange outcome. I have found the calculation from this website https://gamedevelopment.tutsplus.com/tutorials/how-to-code-hud-cooldown-bars--cms-20983 at the article Skill Buttons Cooldown
float cooldownTime = 1000.0f; //milliseconds.
long elapsedTime = System.currentTimeMillis(); //This is called every second in the main loop
float cooldownEndTime = elapsedTime + cooldownTime;
guiTexture.scale.y = 0.06f; //The "unfilling" black bar over the sprite. 0.06 = cover the whole spell GUI
//When i try to change the scale of the "unfilling" black bar i use this code.
scale.y = (0.06f*(elapsedTime/1000)) - (((0.06f*(elapsedTime/1000))/cooldownEndTime) * elapsedTime);

I have tried to modify the calculation but I havent succeed. If anyone have tackle this problem before or can help me reache a soultion i would be grateful.
Thanks


texts: I'm creating a game where you are inside a boiler room, the problem is I want to create the fog (smoke) to make this more realistic.


texts: Can't figure out what's making the player teleport back to spawn

texts:
I've been working on a multiplayer game that uses pathfinding and I'm really confused over this one weird bug.  On your screen, the other player glitches between the spawn point and his current location.  It seems like there's a problem with the interpolation as it doesn't do this when I comment out:

transform.position = Vector3.Lerp(transform.position, bestGuessPosition, Time.deltaTime * latencySmoothingFactor);

Does this have anything to do with the way I'm moving the player?

using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;

public class MinionController : NetworkBehaviour {

    public Camera cam;

    public NavMeshAgent agent;

    Vector3 velocity;
    Vector3 bestGuessPosition;

    float ourLatency;
    float latencySmoothingFactor = 10;

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

        if (hasAuthority == false)
        {
            bestGuessPosition = bestGuessPosition + (velocity * Time.deltaTime);
            transform.position = Vector3.Lerp(transform.position, bestGuessPosition, Time.deltaTime * latencySmoothingFactor);
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                agent.SetDestination(hit.point);
            }
        }
    }

    [Command]
    void CmdUpdateVelocity(Vector3 v, Vector3 p)
    {
        transform.position = p;
        velocity = v;

        RpcUpdateVelocity(velocity, transform.position);
    }

    [ClientRpc]
    void RpcUpdateVelocity(Vector3 v, Vector3 p)
    {

        if (hasAuthority)
        {
            return;
        }

        velocity = v;
        bestGuessPosition = p + (velocity * (ourLatency));
    }
}


texts: Pokémon character turning / facing: How is it achieved? Movement is already done though

texts:
You know that when the player playing Pokémon games want to change the facing of the main character, one would simply tap on the directional pad (D-pad) on the Game Boy (Color/Advanced/Advanced SP) or Nintendo DS systems, and the character would just turn towards the general direction the player wants to turn to.

As far as I know, the turning mechanics from Pokémon Gold/Silver/Crystal is also combined with the movement mechanics from Pokémon Red/Blue/Yellow, which the latter (movement mechanics) is successfully implemented in Java, shown below.

Movement mechanic:

package entity;

import level.BaseWorld;
import main.Keys;
import resources.Art;
import screen.BaseScreen;

public class TestEntity extends Entity {

    public Keys keys;
    int facing = 0;
    int turning = 0;
    int xPosition;
    int yPosition;

    int xAccel;
    int yAccel;

    boolean lockWalking;
    boolean lockTurning;
    int turningTick = 4;

    public TestEntity(Keys keys) {
        this.keys = keys;
    }

    @Override
    public void initialize(BaseWorld world) {
    }

    @Override
    public void tick() {
        if (!lockTurning) {
            if (keys.up.isDown) {
                turning = 2;
                lockTurning = true;
            }
            else if (keys.down.isDown) {
                turning = 0;
                lockTurning = true;
            }
            else if (keys.left.isDown) {
                turning = 1;
                lockTurning = true;
            }
            else if (keys.right.isDown) {
                turning = 3;
                lockTurning = true;
            }
        }
        if (!lockWalking && turningTick < 0) {
            if (keys.up.isDown) {
                facing = 2;
                yAccel--;
                lockWalking = true;
            }
            else if (keys.down.isDown) {
                facing = 0;
                yAccel++;
                lockWalking = true;
            }
            else if (keys.left.isDown) {
                facing = 1;
                xAccel--;
                lockWalking = true;
            }
            else if (keys.right.isDown) {
                facing = 3;
                xAccel++;
                lockWalking = true;
            }
            if (turningTick < -5)
                lockTurning = false;
        }
        handleMovement();
        turningTick--;
    }

    @Override
    public void render(BaseScreen screen) {
        screen.blit(Art.player[facing][0], xPosition, yPosition, 16, 16);
    }

    //-----------------------------------
    //Private methods

    private void handleMovement() {
        if (lockTurning) {
            facing = turning;
        }
        if (lockWalking) {
            xPosition += xAccel;
            yPosition += yAccel;
        }
        if (xPosition % 16 == 0 && yPosition % 16 == 0) {
            lockWalking = false;
            xAccel = 0;
            yAccel = 0;
        }
    }
}

The movement mechanics I have implemented as of now DOES NOT contain codes that rely on System.currentTimeMillis() or System.nanoTime(), which means it's not elapsed-time-based. Rather, it relies on current-states via fixed game ticks, which is prominent during the Game Boy era.

Unfortunately, it contains a side effect where if the player were to press multiple keys on the D-pad, it will cause the character to turn while it's moving. I can remove only the turning mechanics from the mixed mechanism above, and would obtain the movement mechanics that were used only in Pokémon Red / Blue, Generation 1 games.

However, I would like to use the movement + turning mechanics used from Pokémon Gold/Silver/Crystal, Generation 2 and above.

Could someone suggest an idea / tip / hint / solution for this problem?

You may also use the codes given above to your likings, just make sure to change stuffs a bit while you're at it.


texts: Why is the drag force multiplied by the inverse normalised velocity vector?

texts:
In pure physics texbooks, I'm seeing this formula to calculate fluid drag force:

It is clearly stated that it should be opposite to the velocity. Now to me that means, in pseudocode:

fd = get_drag(v) // using the above formula
if v < 0: fd = -fd

That is, if the velocity is negative the drag should be positive, so we invert the returned value.

However, in game code, game physics books and tutorials, I see people doing:

drag = -v
drag.normalise()
fd = get_drag(v)
fd *= drag

That is, we multiply the drag force by the (inverted) velocity unit vector.

This to me is logic in regard to the sign, but also it scales down the drag force by a factor between 0 and 1.

Which one is correct, and why?

PS: to be noted, normalisation involves square root, multiplications and divisions, so it's more expensive than a conditional check and subtraction.


texts: How to determine the amount of experience needed for leveling up

texts:
Related questions under this topic might include:

How should I base how much experience points it takes to get to the next level?
What factors are involved in this?
How do I keep the player not entertained long enough till he levels up?
How can I vary the way the player gets experience points?


texts: How to move the camera to center an object in screen?

texts:
For example, an object is located at (x,y,z) in world space. Now how to calculate the offset translation, I mean no rotation, that will be applied to the camera so as to place the object at the center of the screen?

BTW, I'm using three.js r91. But pseudo code/C++/C# is also OK.


texts: Can I mix the use of VAO and direct usage of glVertexAttribPointer?

texts:
Let's say I am not using VAOs. I have an array of vertex positions in memory that I want to send to the shader. I do the following (assume I have enabled the corresponding vertex attrib arrays):

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vertexDataAsFloats);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureData);
glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 0, someOtherData);
glDrawArrays(...);

This works well and I see the mesh with proper textures. someOtherData is sent to the shader correctly as well. Now I decide to put the vertexDataAsFloats and textureData in VBOs:

BindVAO(1); // binds the VAO with a handle generated from glGenVertexArrays()
glBindBuffer(GL_ARRAY_BUFFER, vertexDataBufferObject);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, textureData);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
UnBindVAO();

Later, before drawing:

glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 0, someOtherData);
BindVAO(1);
glDrawArrays(...);
UnBindVAO();

Can I mix the calls to glVertexAttribPointer and VAO before the draw call, where someOtherData is not in a VBO? Currently, this approach is not working as I am not receiving valid data for someOtherData in the shader.

I realize that someOtherData should go in a VBO as well and bound with the VAO. There is some legacy code that I have to work with which does not use VBOs. In any case, I would like to know if the above is legal in OpenGL.


texts: How can i send from server to client a large amount of tile data? Having chunks of almost 2MB of data seems prohibitive to send this information just like that. Minecraft compress each chunk and Terraria uses RLE, but im not sure if they send so much information.


texts:
How do I show range of grid movement in AS3? When player controls a character and chooses "move" options, the grid of movement will be displayed as 3 grid of X, 4 grid of Y (Both sides, + and -). So, it will be like this:

In the image above, movement grid displayed in blue color. But, how do i display a range grid movement like that?


texts: WebGL Primitive Batching unexpected performance

texts:
I'm kinda new to WebGL in general, I've started to make some batching experiences on primitives (just drying a bunch of rectangles by using a combination of two triangles repeatedly).

I've started by implementing Direct Drawing that draws a rectangle (TRIANGLE_STRIP like) as soon it is requested:

  var colorArr = new Float32Array(<color values here>);

    var vertices = [
        rectangle.x, rectangle.y, 0.0,                                              // TOP LEFT
        rectangle.x, rectangle.y + rectangle.height, 0.0,                           // BOTTOM LEFT
        rectangle.x + rectangle.width, rectangle.y, 0.0,                        // TOP RIGHT
        rectangle.x + rectangle.width, rectangle.y + rectangle.height, 0.0        // BOTTOM RIGHT
    ];

    _this.game.getShaderManager().useShader(_this.primitiveShader);

    // position buffer
    gl.bindBuffer(gl.ARRAY_BUFFER, _this.vertexBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);

    gl.enableVertexAttribArray(_this.primitiveShader.attributes.aVertexPosition);
    gl.vertexAttribPointer(_this.primitiveShader.attributes.aVertexPosition, 3, _this.gl.FLOAT, false, 0, 0);

    // color buffer
    gl.bindBuffer(gl.ARRAY_BUFFER, _this.colorBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, colorArr, gl.STATIC_DRAW);

    gl.enableVertexAttribArray(_this.primitiveShader.attributes.aColor);
    gl.vertexAttribPointer(_this.primitiveShader.attributes.aColor, 4, _this.gl.FLOAT, false, 0, 0);

    // set uniforms
    gl.uniformMatrix4fv(_this.primitiveShader.uniforms.uMatrix._location, false, _this.game.getActiveCamera().getMatrix());

    gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);

But then I wanted to go one step further and I've implemented a simple batcher (mostly by common sense, which is probably where I started wrong).

Basically the batcher does the same thing has the code above, the difference is that I concat all the vertex and color data into a big array of data and then draw everything:

    // position buffer
        gl.bindBuffer(gl.ARRAY_BUFFER, _this.vertexBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(_this.rectangleVertexData), gl.STATIC_DRAW);

        gl.enableVertexAttribArray(_this.primitiveShader.attributes.aVertexPosition);
        gl.vertexAttribPointer(_this.primitiveShader.attributes.aVertexPosition, 3, _this.gl.FLOAT, false, 0, 0);

        // color buffer
        gl.bindBuffer(gl.ARRAY_BUFFER, _this.colorBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(_this.rectangleColorData), gl.STATIC_DRAW);

        gl.enableVertexAttribArray(_this.primitiveShader.attributes.aColor);
        gl.vertexAttribPointer(_this.primitiveShader.attributes.aColor, 4, _this.gl.FLOAT, false, 0, 0);

        // set uniforms
        gl.uniformMatrix4fv(_this.primitiveShader.uniforms.uMatrix._location, false, cameraMatrix);

        gl.drawArrays(gl.TRIANGLES, 0, 6 * _this.rectangleCount);

For my surprise, the second attempt is getting worst results. Using the first approach I get a solid 60 fps on a 320 rectangles drawing and on the second only 40 fps.

So, my questions specifically are:

Why is the batcher having worst results?
What can be optimized to have an optimal drawing performance?

Best Regards.


texts: Input management techniques in large games

texts:
Is there a standard technique for managing input in large games. Currently, in my project, all input handling is done in the game loop, like so:

while(SDL_PollEvent(&event)){
            switch(event.type){
                case SDL_QUIT:
                    exit = 1;
                    break;
                case SDL_KEYDOWN:
                    switch(event.key.keysym.sym){
                        case SDLK_c:
                            //do stuff
                            break;
                    }
                    break;
                case SDL_MOUSEBUTTONDOWN:
                    switch(event.button.button){
                        case SDL_BUTTON_MIDDLE:
                                //do stuff
                                break;
                            }
                    }
                    break;
            }

(I am using SDL, but I expect the main practice applies libraries and frameworks as well). For a large project this doesn't seem the best solution. I may have several objects all  wanting to know what the user has pressed, so it would make more sense for those objects to handle input. However, they can't all be handling input, as after one gets an event, it will be pushed off the event buffer, so another object won't receive that input. What method is most commonly used to counteract this?


texts: move sprite relative to position on another sprite (sword and player)

texts:
I'm sure this is a common problem people face but I can't find much on this topic after some googling.

I have a sword, and a player, both which are sprites. I want the sword to be attached to the player -- Normally you would be able to just child the sword sprite to the player sprite and change the relative position of the sword sprite -- but my player's hands move during the walking animation.

So is there an easy way of moving the position of the sword sprite during each frame of the player walking animation? Or some way of attaching the handle of the sword sprite to the player's hand?


texts:
I'm working in a toy BSP (quake3 version) renderer. I started creating the context and handling the input with GLFW but then I switched over SDL. The performance change was amazing with SDL leading with 100+ fps.

But when rendering some surfaces from far now I'm getting some strange and ugly artifacts in the borders or junctions. The only thing that I changed from GLFW to SDL was the initialization (code bellow) and the input handling but the OpenGL Draw calls are the same.

Why am I getting these artifacts when rendering polygons with OpenGL and SDL from far distance?

This only happens with some surfaces (mostly the ones without textures, only vertex colors) but there are some tiny surfaces (pendants or flags) that also have the same problem. Also, not all the borders of the same faces have the problem.

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
    cout << "Failed to init SDL Video" << endl;
};

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,   SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

_window = SDL_CreateWindow("BSP Test", 0, 0, width, height,
                            SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);

if (_window == nullptr) {
    SDL_Quit();
    return false;
}

SDL_GLContext ctx = SDL_GL_CreateContext(_window);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glGetIntegerv(GL_MAX_PATCH_VERTICES, &ee);
cout << "Max patch vertices : " << ee << endl;

glPatchParameteri(GL_PATCH_VERTICES, 9);

cout << "GL ERROR LOAD  :" << glGetError() << endl;

glClearColor(0.0f, 0.0f, 0.01f, 1.0f);

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_LINE_SMOOTH);

SDL_GL_SetSwapInterval(0);

matrices.proj = glm::perspective(glm::radians(100.0f), (float) width / (float) height, 1.0f, 4000.0f);

camera.position = glm::vec3{-41.415211f, 320.293121f, -537.225281f};

return true;


texts: Unity - job system compatibility for end user?

texts:
I'm thinking about using Job system. But it requires .Net 4.x (also look like .Net 4.x will be default for Unity in 2019). It is a little hassle for me cause I'm using Visual Studio 2015, I have to download & install .Net target pack 4.7

My question is: If my game is developed with .Net 4.7.2 (so that I can use Job system), does it require the end user installing .Net 4.7.2 to play the game?

My target user is low-end PC (they may using windows 7, I see that .NET Framework 3.5.1 is included in Windows 7)


texts:
My game uses DLLs as mods. Players can write DLLs which can render, play audio, print to console, etc. This works fine, however when I try to access GLFW functions, they don't seem to work properly.
CustomMod.cpp (compiled to DLL)
void runDLLCode()
{
    std::cout << glfwGetKey(Game::getWindow(), GLFW_KEY_A);
}

Game.cpp (compiled to EXE)
void run()
{
    //Load DLL....

    std::cout << glfwGetKey(Game::getWindow(), GLFW_KEY_A); // Prints 1
    runDLLCode();                                           // Prints 0 (should print 1 since key is still down)
    std::cout << glfwGetKey(Game::getWindow(), GLFW_KEY_A); // Prints 1
}

Running std::this_thread::get_id() provides the same thread ID across both the DLL and exe.
The address of both Game::getWindow() is the same as well.
Is it possible to have all print 1 when the application is run? Or is it not possible to use GLFW functions across the DLL "wall"?


texts: How can I make a black shadow/glow around my drawn rectangle made of primitives? Drop-shadowing is easy, but it's not exactly what I am looking for.


texts: Most Efficient Way To Get Objects In A Rectagular Area - Unity2D

texts:
First of all, if you know a better way to do what I want to achieve please don't hesitate to suggest your own method.

What I want to do is the classic area selection in RTS games, which player drags his mouse to draw a rectangle and units inside rectangle become selected.

At this point, I have two ideas:

A dedicated gameObject with a trigger BoxCollider2D.
Detecting overlaps with Physics2D.OverlapArea method.

In the first method, the gameObject will get resized on the fly while the user drags and by using collision control the objects get selected.

In the second method starting point and end point of the area is being recorded and script draws an OverlapArea using these two coordinates.

Which one would be more effective in terms of performance?

Thanks in advance.


texts: Console spam when opening editor: Assertion failed on expression: 'txn.Exists(guid)'

texts:
I have just opened up a new project in Unity 2019.3.04b - and in the console I got an error message repeating a lot of times:

In addition, when unfocus and focus Unity, it spits out one more pair of errors (the same errors like in this image).
Anyone knows what it is and how to fix it?


texts: Ogre3D : seeking advices about game files management

texts:
I'm working on a new game, and its related level editor, based on Ogre3D.
I was thinking about how i could manage the game files, knowing that Ogre use .mesh files for models, .material for materials/texture information etc... .
At first i thought about a common .zip folder decompressed at runtime (the same way Torchlight and Ogre samples do). But this way the game assets become a monolithic archive, loading takes time, and could be difficult to eventually patch them.
So, let's say i have a game object named "Cube" i want to load in my program.
Going for modularity, what if i create a compressed file (using zlib compression routines) named Cube.extname, containing its sub-files Cube.mesh, Cube.material and so on ?
Are there any alternatives or should i stick with compressed objects?

PS: Just to clear things, the answer is unrelated to my program code, at the moment i'm using "resources.cfg" pointing to the OgreSDK media directory.


texts:
I am currently programming a 2d platformer and this is the first time I am coding a video game. Now I've downloaded the 'platformer art deluxe' package. In the tiles folder there are single tiles and a spritesheet with every tile on it.
Should I use the spritesheet or the single tile sprites?


texts:
I have used
void OnCollisionEnter(Collision collision) {
    collision.gameObject.transform.parent = gameObject.transform;
}

To stick two players together when they connect.
Basically after they have collided the second game object is still stuck to the original object and i need that not to be the case.
How do i make the game object not stuck when they come apart ?


texts: Unity build report for Android is missing information

texts:
This is my build report for Android:

Build Report
Uncompressed usage by category:
Textures      3.4 mb     3.7%
Meshes        0.0 kb     0.0%
Animations    0.0 kb     0.0%
Sounds        0.0 kb     0.0%
Shaders       0.0 kb     0.0%
Other Assets  13.5 kb    0.0%
Levels        21.9 kb    0.0%
Scripts       687.9 kb   0.7%
Included DLLs 3.9 mb     4.3%
File headers  13.2 kb    0.0%
Complete size 92.5 mb    100.0%

The space used by all the categories does not add up to the complete size of 92.5 mb. The build report in the Unity manual shows full utilisation by the listed categories. Where does the other 91% of the utilisation go?


texts: Sorting cube depth correctly with an isometric engine

texts:
Possible Duplicate:
  How should I sort images in an isometric game so that they appear in the correct order?

I'm starting work on a simple isometric engine. Everything thing is going great at the moment, but I think I've hit an issue everyone hits. I'm having difficulty getting sorting the depth of a cube.

This image shows the default view (character not near a cube)

This image shows the character behind a cube

The issue is here, when the character goes in front of the cube.

Is there a common solution to this? How would i go about it? Would i need to give a depth to EVERY cube, then somehow work out the current tile the character is on then apply the depth to him? I'm using game maker on a mac and I'm happy to upload the project somewhere if you need to check it out.

Thanks for any input.


texts: Are there any implemented game controls like a screen (thumb) joystick? - iOS

texts:
I'm looking for some open source game controls.
Especially I'm looking for a thumb screen joystick to move a character on the screen, something like a touch circle.

Are there any open source implementation of what I'm looking for?


texts: What is the order of execution, when calling an instantiation method, in Unity?

texts:
In my GameManager script, I instantiate a player game object, and call another method like this:

void Start()
{
   Debug.Log("GameManager Start() called...");
   Instantiate(player, Vector3.zero, Quaternion.identity);
   InitNewLevel();
}

void InitNewLevel()
{
    Debug.Log("GameManager InitNewLevel() called...");
}

In my Player script, I have this:

void Start()
{
    Debug.Log("Player Start() called...");
}

I was expecting Player.Start() to be called after the Instantiate(player, Vector3.zero, Quaternion.identity); line, and before the InitNewLevel(). However, if I look at my debug log output, I see this:

  GameManager Start() called...
  GameManager InitNewLevel() called...
  Player Start() called...

Why do my methods execute in this order? Why does Player.Start() get called after GameManager.InitNewLevel?


texts:
I made my first 2d platformer game using java + swing.

Now I want to achieve the same gameplay adding 1 dimension. I think this will require opengl knowledge.

I know the basics but i don't consider myself an expert.

This is an idea of how the game should look like.

So the question is, what will i need in order to do this(libraries,programs etc)?

Please do not start writing answers and comments on how hard this will be. I know that it will take me some time but i am willing to finish the project.


texts:
I'm working on a top-down shooter in XNA, and I need to implement line-of-sight checking.  I've come up with a solution that seems to work, but I get the nagging feeling that it won't be efficient enough to do every frame for multiple calls (the game already hiccups slightly at about 10 calls per frame).

The code is below, but my general plan was to create a series of rectangles with a width and height of zero to act as points along the sight line, and then check to see if any of these rectangles intersects a ClutterObject (an interface I defined for things like walls or other obstacles) after first screening for any that can't possibly be in the line of sight (i.e. behind the viewer) or are too far away (a concession I made for efficiency).

public static bool LOSCheck(Vector2 pos1, Vector2 pos2)
    {
        Vector2 currentPos = pos1;
        Vector2 perMove = (pos2 - pos1);
        perMove.Normalize();

        HashSet<ClutterObject> clutter = new HashSet<ClutterObject>();
        foreach (Room r in map.GetRooms())
        {
            if (r != null)
            {
                foreach (ClutterObject c in r.GetClutter())
                {
                    if (c != null
                        &&!(c.GetRectangle().X * perMove.X < 0)
                        && !(c.GetRectangle().Y * perMove.Y < 0))
                    {
                        Vector2 cVector = new Vector2(c.GetRectangle().X, c.GetRectangle().Y);
                        if ((cVector - pos1).Length() < 1500)
                            clutter.Add(c);
                    }
                }
            }
        }

        while (currentPos != pos2 && ((currentPos - pos1).Length() < 1500))
        {
            Rectangle position = new Rectangle((int)currentPos.X, (int)currentPos.Y, 0, 0);
            foreach (ClutterObject c in clutter)
            {
                if (position.Intersects(c.GetRectangle()))
                    return false;
            }
            currentPos += perMove;
        }
        return true;
    }

I'm sure that there's a better way to do this (or at least a way to make this method more efficient), but I'm not too used to XNA yet, so I figured it couldn't hurt to bring it here.  At the very least, is there an efficient to determine which objects may be in front of the viewer with greater precision than the rather broad 90 degree window I've given myself?


texts: Passing strings padded with white space into a byte[]

texts:
I am using Google Play services for a real time multiplayer game in Unity 3d. When sending the data in a byte[] in the multiplayer update I have to pad certain entries going into the byte[] with white space so all entries are a certain length. I am having a problem where they don't have the white spaces anymore when I get the strings back from the byte[].

For example I have a string called username that is set to "test name " with 6 white spaces on the end in order to take up 15 bytes.

I add the string to the byte[] like so:

updateMessage.AddRange(System.Text.Encoding.ASCII.GetBytes(username));

Then to get the part back out I use this code:

string username = System.Text.Encoding.ASCII.GetString(data, 38, 15);

38 is the index where the username string should start and it should be 15 bytes long. It actually ends up going into the next string I have stored because it doesn't have the white spaces anymore.

Is there a way to make sure the white spaces stay in the string so that I keep the padding after pulling it from the byte[]?


texts: How can i make fade in/out of the alpha color of a material from black to none black?

texts:
This is script is attached to a black plane.
I have a plane and i added to it a material and the plane is in black.
When running the game the alpha color of the plane material is changing slowly.

The script is working it's getting slowly from dark black to none black.
But i want to make some changes:

It's not my script i took it from the youtube and did some changes the first one converted from js to c# second added the fade bool variable.

First of all i don't see any meaning setting the variable timer to 10 at the top. Any ideas what is the point ?
Second is how can i check when the alpha color value is high enough to do some stuff:

Enabled true the fpc again. Once it's not black again the fpc is still enabled false.
If i want when the alpha color value reached it's max to make automatic fade back to black Now i'm using manual fade bool variable but i wonder how to do it automatic fade in/out.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;

public class FadeScript : MonoBehaviour
{
    public float timer = 10.0f;
    public FirstPersonController fpc;
    public bool fade = true;

// Use this for initialization
void Start()
{
    Color tempcolor = GetComponent<Renderer>().material.color;
    tempcolor.a = 1f;
    GetComponent<Renderer>().material.color = tempcolor;

    fpc.enabled = false;
}

// Update is called once per frame
void Update()
{
    timer = Time.deltaTime;

    if (timer >= 0)
    {
        Color tempcolor = GetComponent<Renderer>().material.color;
        if (fade == true)
        {
            tempcolor.a -= 0.1f * Time.deltaTime;
        }
        else
        {
            tempcolor.a += 0.1f * Time.deltaTime;
        }
        GetComponent<Renderer>().material.color = tempcolor;
    }
}

}


texts: Why real time lightning fails to show shadows on terrain in Unity?

texts:
I'm using the TerrainTools unity package to create a simple 500x500 terrain, and placing a simple character that moves around, however, by default, the lightning is at real time mode, and the shadows over the terrain flicker like this:
https://youtu.be/_eFFDCRjObY
I know I can set the terrain as static and bake the lighting, however, doing that I lose my character shadow.
So my questions are, why this happens over real time lighting?, and, why I cannot see my shadow on a dynamic mesh over baked lightning?
Here you can see my lighting and directional light configs:
Lighting config:

Directional light config:


texts: How to transform Capsule Component in UE4?

texts:
The collision of the character with the environment only works correctly (in the eyes) when I use the original skeletal mesh.

I tested it in the most varied sizes and it worked perfectly.

It turns out that when I import any 3D object (FBX of Blender), it does not work properly (though the UE4 says that in the import it makes several adjustments).

I realized that the problem is because of the capsule component, which is responsible for detecting the character's collision with the environment. So at first I would like to know how to increase its size and make modifications.

Links that I researched and that helped me in some way:

https://answers.unrealengine.com/questions/853084/is-it-possible-to-transform-the-capsule-component.html

https://answers.unrealengine.com/questions/200546/change-the-capsule-component.html

https://answers.unrealengine.com/questions/465122/how-to-change-character-capsule-component-location.html


texts: Why is my gameloop slightly faster than 60 per second?

texts:
Here is my gameloop (taken from http://www.koonsolo.com/news/dewitters-gameloop/) which is supposed to limit the game (logic) updates to 60 per seconds and render as fast as the device allows:

long nextGameTick = System.currentTimeMillis();
int loops;
final int maxFrameskip =5;
final int ticksPerSecond = 60;
final int skipTicks = 1000 / ticksPerSecond;
float dt = 1f/ticksPerSecond;
int ticks;
long secondCount;

onDrawFrame{

    //This loop will limit the logic update to defined value and render flat out
    loops = 0;

    while( System.currentTimeMillis() > nextGameTick && loops < maxFrameskip){
        updateLogic();
        //Update nextGameTic by adding skipTicks value to it, ready for next comparison
        nextGameTick += skipTicks;
        //Update loops value ready for next comparison in while loop
        loops++;
        ticks++;
        }
        //Once thses conditions are no longer true, exit while loop and render
    render();

    if (System.currentTimeMillis()>secondCount+1000){
        Log.v("Blocks","Ticks this second:"+ticks);
        secondCount = 0;
        ticks=0;
        }
}

However, when I run this, I'm getting anywhere between 62 and 65 as you can see from my logcat output:

So, the loop doesn't do what it's supposed to.


texts: Is there a name for this kind of mini-game? (cursor moves on a bar, press key in part of the bar to win)

texts:
Today I played a game which has a mini-game in it, basically it looks like this:
here's a bar:
----------=====----------

and a cursor moves back and forth on it:
-|--------=====----------  ( cursor "|" moves in this direction -> )

-----|----=====----------

----------===|=----------

----------=====---------|  ( when the cursor reaches the end, it goes back <-)

If I hit a key when the cursor is on the specific part of the bar (which I used the "=" sign to represent), I win. Otherwise I lose.
This kind of mini-game is pretty common as I've seen many variant of it in a lot of games, yet I don't know the name of it. Does it have a name? What's the origin of it?

EDIT: There's an answer mentions QTE. Well... I'm aware of that and I don't think this mini-game belongs in that category thus I avoided using that term. Here's the reason for that:
QTEs have time limits, after all it's Quick time event, this kind of mini-game I'm asking about usually doesn't. Well, I've seen variations of it that does count as lose if you didn't hit the key in some amount of time, it's not the main focus of it.
Unlike how QTEs are all about testing player's reflex, this kind of mini-game is all about precision, as seen in many rhythm games. However, it doesn't necessary have any audible cue like rhythm games do, it's all about learning the pattern/speed of the moving cursor then press the key at the right time.
It's not about how quick you can press a key, but when to press the key. Hence I don't think this counts as a QTE.


texts: Automating the process of creating a steam lobby (for dota) and inviting users to it

texts:
I'm working on a Ruby on Rails web-application and I want to create lobbies and send invitations to users to join these lobbies. Simply, I want to achieve ISteamMatchmaking Interface functionality of Steam SDK but the problem is that sdk in written in C/C++ and I would have to write wrapper to integrate sdk in my application.

My question is that is there some easy and less time consuming approach to achieve ISteamMatchmaking Interface functionality in web-application?

I'm using RoR but I'm open to use other technologies too.


texts: How can I rig an object to animate from two different orientations?

texts:
As an example: Say you're animating a skateboard. The board has a nose and a tail. Normally, the nose points forward and the tail points backward. Now say you have two animations: idle and trick. The idle is animated with the nose pointing forward. The trick, however involves the board rotating 180°, ending with the nose pointing backward, functionally swapping the nose and tail. Now, if you were to blend the trick animation back into idle, the blend would rotate the board back around so the nose points forward, which would not be the intended behavior. The intended behavior would be for the animator to somehow know that the tail is now the forward facing orientation and animate as if the tail were the nose.

I'm competent but no expert with rigging/animation and I've been racking my brain trying to come up with either a way to cleverly rig the object to somehow work as intended or to be able to modify the animations procedurally in code or something, but I haven't been able to figure it out.

This seems like a problem that must come up somewhat frequently with game animation, but I haven't been able to find any specific resources.

I'm using Blender and Unity.

Edit: To be clear, I'm not talking about root motion or the animating object's position/rotation in the world, just the orientation of the bones being animated.


texts: Show the edges between the clipping plane and clipped objects

texts:
I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection.

My fragment shader currently does something along the lines of:

float dot = dot(world_coordinate, normalize(clipping_normal.xyz)) - clipping_normal.w;
if (dot > 0.0f)
    discard;

this works but without the desired contour. I tried comparing the dot product against values close to 0.0 but this results in a contour with varying width depending on view etc...

This is what I am trying to achieve. Notice that the white contour/edge of where the plane intersects the sphere is of consistent width:

So below is what the result I currently see:

With the fragment shader:

in vec4 color;
in vec3 world_position;

out vec4 frag_color;

void main()
{
    float dist = (dot(clipping_plane.xyz, world_position) - clipping_plane.w) /
              dot(clipping_plane.xyz, clipping_plane.xyz);

    if(dist >= 0.0f && dist < 0.05f)
        frag_color = vec4(0.0f, 0.0f, 0.0f, 1.0f);
    else if(dist < 0.0f)
        discard;
    else
        frag_color = ComputePhong(color);
}


texts: Getting It Done vs Solid Software Design?

texts:
With barely enough time at our hands to complete the games we craft, how can you strike a good balance between solid software architecture and making good progress to get it all done?

My personal challenge:
How about being effective today and long-term thinking at the same time? Plus, while you're doing it you may just as well want to learn new things on the way instead of resorting to the same repetitive patterns you've been using those past 5 years?


texts:
this is a graphics/math problem.
Consider this 2 sprite / surface

As you can see they are a tank and his gun turret.
Now, i manage the turret rotation, and it works, and, also, the rotation of the tank on the screen.

What it'snt work is the correct "blitting" of the turret on my tank.

The problem is that the turret is never blitted correctly on the tank.
This is a math problem, and i'm not so good in math !
How can i correct blit the turret centered on the "right" hole of my tank sprite ?

I'm using c# and sdl.net and actually i blit the turret with this code ( 13,13 are the X and Y position of the 'black' hole of the tank, but, i know, this is not the right method to blit it!):

            Surface tmpsurf = new Surface("graphics/tank_turret_long.png");

            Surface turretSurf = tmpsurf.CreateRotatedSurface(cannonangle);

            turretSurf.Transparent = true;

            turretSurf.TransparentColor = Color.Black;

            Point posTurret = new Point(13+this.X,13+this.Y);
            Video.Screen.Blit(torrettaSurf,posTorretta);

Thank in advance


texts: Should I use the pathfinding client side or server side?

texts: I'm developping a game where the user can walk in a room (with the others players). There are some obstacles that blocks the user. I'm using a Javascript pathfinding library to find where the user can walk. But the question is: Should I use the pathfinding library Client side or server side? Why?


texts: How to create card layout in a trading card game Libgdx

texts:
I am trying to create a card layout for my trading card game. Right now I use this code:

public class ClientCard extends Table {

    ClientCard(int cost, int attack, int health, String title, String description) {
        Texture texture = new Texture(Gdx.files.internal("data/"+title+".jpg"));
        Image image = new Image(texture);
        this.add(image).width(Gdx.graphics.getWidth() / 10).height(Gdx.graphics.getHeight() / 7).colspan(3);
        this.row();
        Skin skin = new Skin(Gdx.files.internal("skin/glassy-ui.json"));
        Label cardName = new Label(title, skin);
        Label cardDescription = new Label(description, skin);
        Label cardCost = new Label(cost + "", skin);
        Label cardAttack = new Label("", skin);
        Label cardLife = new Label(health + "", skin);
        this.add(cardName).colspan(3).padBottom(5);
        this.row();
        this.add(cardDescription).colspan(3).padBottom(5);
        this.row();
        this.add(cardCost);
        this.add(cardLife);
        this.add(cardAttack);
    }
}

It works, it shows the card data, but it looks pretty bad and it's not very compact, also I can't set the outer border for the Table (table.debug is not good). What I want is something like this:

I want to use scene2d so it's easier to fill the card with the data I want (life, attack etc). Any idea how I could realize this?
Thanks!


texts:
I'm getting an error that says "control may reach end of function" and I have gone through my code several times now and am not spotting the error. It may be something simple too.

// loop continually until the user gives a valid guess
FText GetValidGuess()
{
    EGuessStatus Status = EGuessStatus::Invalid_Status;
    do {
        // get a guess from the player
        int32 CurrentTry = BCGame.GetCurrentTry();
        std::cout << "Try " << CurrentTry << ". Enter your guess: ";
        FText Guess = "";
        std::getline(std::cin, Guess);

        // check status and give feedback
        Status = BCGame.CheckGuessValidity(Guess);
        switch (Status) {
            case EGuessStatus::Wrong_Length:
                std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
                break;
            case EGuessStatus::Not_an_isogram:
                std::cout << "Please enter a word witout repeating letters.\n";
                break;
            case EGuessStatus::Not_Lowercase:
                std::cout << "Please enter all lowercase letters.\n";
                break;
            default:
                return Guess;
        }
        std::cout << std::endl;
    } while (Status != EGuessStatus::OK); // keep looping until we get no error
}


texts:
I've a list of buttons that I create using XML stored data. To achieve it, I've created a Prefab. These buttons are created correctly, and now I want them to be sorted for the user.

public List<GameObject> myButtons;

As I said, now I want to sort them. I've found out that sorting the List itself, buttons are sorted in the UI.

myButtons.Sort((x, y) => ...);

The problem is, that I don't have the necessary data to sort them within them. This leaves the .Sort() method unavailable for use.

I've tried to sort them adding an script to each one, which contains the data that I need to use to sort them. However, it doesn't work correctly and I seem unable to find out why, so I'm wondering about other more direct methods to sort them.

Notice that I'm referring to simple buttons in a 2D game, and that they're all inside the same parent/gameobject.

Technical Details

Let's start by the basics: I want to order the buttons taking into account if the user has reached a point in which the item it represents should be available.

This is stored in an instance of a class that represents the items related to the buttons of the question.

public class myItemClass
    {
        # Here there are other properties
        public bool available;
    }

Therefore, we've a correspondence between two lists:

public List<myItemClass> myItems;
public List<GameObject> myButtons;

Where:

  myItems[0] is related/represented by myButtons[0]

  ...

NOTICE that this relation exist at the initialization of the game, so i need to keep it at any moment (meaning, having to sort both lists).

What I tried

To be able to order my buttons depending on if the items are available or not, what I've done is:

Creating an script myItemScript, which has a reference to my original items from the other list.
Sorted the items using Sort function over them.

public class myItemScript: MonoBehaviour {
    public OtherClass.myItemClass dataObject;
}

And then sorting them like:

myButtons.Sort((x, y) => y.GetComponent<myItemScript>().dataObject.available.CompareTo(x.GetComponent<myItemScript>().dataObject.available));

As I said before, both list need to be following the same order, so just after it, I order the item list as well:

myItems.Sort((x, y) => y.available.CompareTo(x.available));

Checking/Debug

As result, I found that items were in fact sorting different. However:

Items inside myItems List were sorted as expected.
Buttons in UI (and hence, myButtons List were not sorted as expected. Mixed items (available = true/false) were mixed and not ordered in two blocks, one first and then the other one.

This was checked using breakpoints within VS2017 and pausing the game in Unity interface.


texts: Throwing a ball and estimating its path using a Physics engine

texts:
The problem:
A player entity wishes to throw a ball from a known position with a known initial velocity. The surrounding environment contains physical objects that can alter the trajectory of the ball. How can this trajectory be as accurately as possible be rendered?

One solution: perform small steps and simulate throwing the ball. During each small step, a raycast is performed against the world to find potential colliding bodies. In case a collision is reported, it must be handled accordingly. The intermediate positions of the ball will then be saved in an array and the trajectory should be described by the succession of these points.

While this solution works (it is tested and doesn't fail almost never :) ), are there any workarounds or possible optimizations that can be done to avoid performing the raycast queries too often? It would be nice if there were such a thing as a parabolic caster instead of a linear ray caster. Do you know of any existing solution that is better of the one I just described (that either avoids those many raycasts or performs a more clever kind of query to reduce the number of intermediate steps and replace the actual line segments with parabola segments)?


texts: Billboards offset for character names + rotation

texts:
I am successfully using Matrix.CreateBillboard in my XNA game to print the characters name above the models. The problem I have is with the offset (to appear above the models). Currently, I am creating the location of the text using;

Vector3 objTextPosition = objPlayerShip.objShipVector + new Vector3(0, 3, 0);

This works fine if I stay within the same general lateral location. If I rotate above or below the model the text either appears on top of, or is covered by (or even below) the model. To compensate for this, I would need to create a rotation around the model (should I use a quaternion?) with the top always pointing up (with a Vector3(0, 3, 0) offset).

Am I over thinking this? Is there a simple way to achieve this?

Thanks in advance!

Here is the correct way (above the model)

Here is looking from top, down


texts: Conceptual - What is the optimal way to combine steering behaviors with rigid body physics?

texts:
I am working on a simple 3D space simulator that makes use of the Bullet physics engine. The spaceships are rigid bodies that have a mass and hitbox so that they can be considered for collisions. At the same time, I am trying to implement simple steering A.I. as detailed in numerous tutorials across the web. However, all of these tutorials assume zero-size points in 2D space with no orientation.

For the most part, I have succeeded in implementing the behaviors by applying a force to the rigid body in the direction of desired steering. The spaceship moves, turns, and accelerates smoothly and correctly navigates to the desired position in 3D space:

currentVelocity = body.getLinearVelocity();
tempVector = body.getWorldTransform().getTranslation();
desiredVelocity = targetPosition.sub(tempVector).normalize().scale(maxVelocity);
steeringForce = desiredVelocity.sub(currentVelocity);

body.setGravity(steeringForce); *[see footnote]

However, the spaceship does not change its orientation at all. The problem I am trying to solve is simple - to make the spaceship face in the direction that it is currently travelling.

From my research, it seems that simply setting the orientation of the object to face the direction of its velocity is really bad when using a physics engine because it may cause a rigid body to become stuck inside another one. On the other hand, using a more realistic navigation system based on thrusters is prohibitively (and needlessly) complex because the number of spaceships will be very high.

What is the best way of overcoming this problem?

Edit: Also of note is that the Bullet physics library does not allow setting the orientation of a body.

**Note: I used the function setGravity() instead of applyForce() as suggested by an admin at the Bullet physics forums because applying a force is dependent upon frame-rate. On the other hand, gravity is applied evenly according to Bullet's simulation steps, not to mention that gravity otherwise unused in a space simulator.*


texts: Pixel Buffer Object (PBO) does not work correctly

texts:
I've written a very simple OpenGL application. Its goal is to load a texture and draw it on a plane using a PBO. If I use the function 'glTexSubImage2D' the plane is not textured and the function 'glGetError' returns the error '1281' (invalid value). However if I use the function 'glTexImage2D' my plane plane is textured correctly (and I have no error).

Here's the code for the texture loading :

#define OFFSET_BUFFER(offset) ((char*)NULL + offset)

void core::RootDevice::LoadTexture(char const *pFileName)
{
    SDL_Surface *pSurface = IMG_Load(pFileName);
    char *pPixels = reinterpret_cast<char*>(pSurface->pixels);
    uint32_t bytePerPixel = pSurface->format->BitsPerPixel;

    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    {
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        glGenBuffers(1, &pboID);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboID);
        {
            unsigned int bufferSize = pSurface->w * pSurface->h * 3 * sizeof(unsigned char);

            glBufferData(GL_PIXEL_UNPACK_BUFFER, bufferSize, 0, GL_STATIC_DRAW);
            glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, bufferSize, pPixels);

            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pSurface->w,                //NOT OK : ERROR 1281
                pSurface->h, GL_RGB, GL_UNSIGNED_BYTE, OFFSET_BUFFER(0));

            /*glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, pSurface->w,               //OK : NO ERROR
                pSurface->h, 0, GL_RGB, GL_UNSIGNED_BYTE, OFFSET_BUFFER(0));*/
        }
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
    }
    glBindTexture(GL_TEXTURE_2D, 0);
}

And the rendering code :

void core::RootDevice::Render(void)
{
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, textureId);
    {
        glBegin(GL_QUADS);
            glTexCoord2f(0.0f, 0.0f);
            glVertex3f(-1.0f, -1.0f, 0.0f);
            glTexCoord2f(1.0f, 0.0f);
            glVertex3f(1.0f, -1.0f, 0.0f);
            glTexCoord2f(1.0f, 1.0f);
            glVertex3f(1.0f, 1.0f, 0.0f);
            glTexCoord2f(0.0f, 1.0f);
            glVertex3f(-1.0f, 1.0f, 0.0f);
        glEnd();
    }
    glBindTexture(GL_TEXTURE_2D, 0);
}

And the result is the followings:

I'm really lost. Does anyone can help me, please ?

Thanks a lot in advance for your help.


texts: How can I change the dimensions of collision volumes showed in UE4's physics asset tool?

texts:
How can I change the dimensions of the capsule for one bone in the physics assets tool?

The problem is that bones not connected by joints have overlapping collision volumes in the mannequin that comes with the starter content, which causes those body parts to apear dislocated or out of place when the simulation is running.

For instance in this image the pelvis and the middle bone in the spine (Spine 2) are overlapping.

So, when the simulation runs Pelvis and Spine 2 get pushed apart reducing the overlapping to a contact point.


texts: How to implement Lua thread for Sleep function

texts:
I am running into a problem in my game engine right now.
I want to be able to call Sleep(number_of_seconds) from .lua file (1 only) and halt the execution of the lua file, WHILE the game is running and rendering / updating.
When the sleep is done, the .lua file will return execution.
Is this possible?
All the best,
Aldo

p.s.
I guess this can be implemented with C++ <thread>but I couldn't find a solution for now:/


texts: Hardcore or casual? Help me understand please

texts:
I am working on an easy casual physics puzzle on iOS for kids and thought of this question.

In my honest opinion casual kids games must have simple gameplay - one tap or command for a step, several steps/decisions for a stage. But how thin is the line between casual and hardcore games for iOS?

For example, Angry Birds - on first stages it's easy and fun, but then it gets challenging - you need to calculate and determine how to strike with each birdy. For the player that means some heavier calculations, so does it become not so casual eevn though financial statistics say that it is?

Please, help me to understand, how can I make my game more complicated or involved but let it be still as simple as it can be. Feel free to say about some global things, without detailising.
TY!!!

upd.
Game is kind of physics puzzle in space. There are stars on gamefield, that behave like balls attached to rubber strings - you can move them in any direction on short distance, and after release they fly away in choosed direction. There's no gravity, so stars don't fall to the bottom of screen and stay on their place after momentum is over.
Also there's teleporters (black holes), that deliver stars from A point to B point (other end of black hole), star wind, that transfer captured stars to some destination, etc.
There's a authority thought, that this mechanics can be too hard for little kids too understand, also that no-gravity feature is hard to understand for kids.
Still, everything is cute, music is calm, and main character, who operate with stars, is ultracute.
The main goal is to put stars in direct order in the "goal line" in the middle of screen. Player got score bonus for doing minimum of star moves (hitting goal line with one move for each star), and there's no game over, so kids can have as much attempt to put each star in direct place as many times, as they need.


texts:
I am having a shadow shimmering in my scene when using a shadow mapping technique. I know that there is a lot of posts over the internet dealing with this subject but my issue is slightly different.

I know that the problem comes from sub-texel issue when moving the camera BUT my scene is using a different technique as the camera and the light sources are stable and the objects inside the scene is moving Relative To Eye concept (RTE). The issue is when implementing cascaded shadow mapping and variance shadow mapping as stated in DirectX examples, everything goes well except that the shadows are shimmering (flickering). The shimmering is coming from the objects that are moving, not the camera. So when I try to solve the problem with adjusting the sub-texel problem with the camera movement it didn't solve the problem as the camera is stable but the objects are not.


texts: 2D sprite 360 degrees rotation according to the mouse

texts:
I am trying to make my top down character rotate according to degrees between its position and the mouse. I'm using this code:

float xDiff = mouseState.X - (graphics.PreferredBackBufferWidth / 2);
            float yDiff = mouseState.Y - (graphics.PreferredBackBufferHeight / 2);

float angle = (float)(Math.Atan2(yDiff, xDiff)) * 180 / Math.PI);

But it's not working. At the place where I should get somewhere about 0 degrees - I get about -75.


texts: How do I determine the slope of a curve?

texts:
I am making a 2D game where the character rides on the curve of a graph. I need to find out whether the player is going uphill or downhill and calculate speed accordingly.

The problem is that I am not sure how to determine the slope of the curve on the point that the character is at.

Here is an example of what some of the curves look like:


texts:
Anyone knows the formula inside the Bartle Test of players taxonomy?

I need to do the test, but I need the weight of each question to make something more accurate and trustworthy to the real test...

Some links to the online test:

http://matthewbarr.co.uk/bartle/
http://4you2learn.com/bartle/


texts:
I'm quite new to java.

I'm trying to come up with my own game after watching a few video tutorials. However, I encountered a problem where I cannot draw an external image file that I loaded using the BufferedImage object.

The problem seems to be on the method that I'm using to draw the image on the screen, where I'm using Graphics2D.drawImage() method to draw.

Here is part of my code (I modified and skipped parts that seemed irrelevant to the topic):

Window Class

public class Window extends JPanel{
    public Window(int width, int height) {
        JFrame frame = new JFrame("Zerro's Game");

        frame.setPreferredSize(new Dimension(width, height));

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setResizable(false);
        frame.setVisible(true);
        frame.pack();
    }
}

Game Class

public class Game extends JFrame implements Runnable {
    // Dimension for Main Frame
    private static final int WIDTH = 640;
    private static final int HEIGHT = 480;

    // Image
    private BufferedImage image;
    private Graphics2D g;

    public void run() {
        this.requestFocus();

        // For rendering purposes
        image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
        g = (Graphics2D) image.getGraphics();

        //Game Loop
        long now;
        long updateTime;
        long wait;

        final int TARGET_FPS = 60;
        final long OPTIMAL_TIME = 1000000000 / TARGET_FPS;

        while (isRunning) {
            now = System.nanoTime();

            update();
            render();

            updateTime = now - System.nanoTime();
            wait = (OPTIMAL_TIME - updateTime) / 1000000;

            try {
                Thread.sleep(wait);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private void render() {
        if(gameState == STATE.GAME) {
            handler.render(g);
        } else if(gameState == STATE.MENU) {
            menu.render(g);
        }
    }

Menu Class

public class Menu extends KeyAdapter{
    private BufferedImage image;

    public void render(Graphics2D g) {
        try {
            image = ImageIO.read(getClass().getResource("/Pixel_Background.png"));
            g.drawImage(image, 0, 0, null);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

This code results in making empty frame without any content inside. I confirmed that it properly loads an image by using System.out.println(image.getHeight()) which prints out the exact height of an image that I'm using.

I've seen some comments in the internet that I need to use paintComponent() method. However, I'm just wondering if it's not a good idea to use paintComponent() in game development as the video tutorials (3 of them) that I watched didn't use such method to draw images.

Also, I'm wondering about the reason why we pass in the Graphics2D object as parameter in all the render() methods.


texts: Game state and input handling in component-based entity systems

texts:
My question is:

How can I handle game states in my entity system, without resorting to keeping a stack of game state objects around?

So the design of my entity system means that when an entity needs to register for input events for instance, the input component calls the input system and says "register this entity for this input". This is all fine and well, however if you add into this the concept of game states (say a pause screen), it becomes a problem to work out if an entity is in the current state and should receive the input.

I could augment the input component/system so that it says, "register this entity for this input while in these game states", but this requires that every entity know which states it's going to be used in, and that may not be obvious. Also, keeping a list of game states around per registered input (and other systems that use callbacks) doesn't sound too efficient.

Another idea I had is since there will be an entity that represents the game state, mark that as being disabled, then when generating the input event check that the entity is not a descendant of a disabled game state entity. Seems expensive to work out the parent for every callback.

Another idea is to have all the systems store their data keyed against the current state, that way when generating the input, the target entity won't even be a candidate. However this really hurts the ability to allow communication between entities in different states (not so much a problem for pause screens, but think lock picking in Oblivion/Skyrim).

The only other idea I've had is to have all components handle a state change events and communicate with their relevant system to disable anything they have registered, and re-enable it when switching back to this state.

The second (mark an object as disabled) and forth (have each component deal with state changes) seem like the best of my ideas, but none of them jump out at me as being particularly great.

Does anyone else have any other ideas on how to do this?

edit While I talk about input specifically in this question, it can mean any system capable of sending messages/events to entities, such as collisions, timer events, etc...


texts: Maintain proper symbol order when applying an armature in flash

texts:
I am trying to animate a character's leg in flash CS 5.5 for a game I am working on. I decided to use the bone tool because it's awesome. The problem I am having, however, is that for my character to be animated properly, the symbols that make up his leg (upper leg, lower leg, and shoe) need to be on top of each other in a specific way (otherwise the shoe looks like its next to the leg, etc). Applying the bones results in the following problem: the first symbol I apply it to is placed in the rear on the armature layer, the next on top of it, and so on, until the final symbol is already on top. I need them to be in the opposite order, but arrange > send to back does nothing on the armature layer. How can I fix this?

tl;dr: The bone tool is not maintaining the stacking order of my objects, please help.

Thanks for helping :).


texts: How can I develop and publish a game when I don't have the money to buy a brand new computer?

texts:
I'd like to complete and publish a game made with Unity, but given the fact that the cost of a brand new computer represents a significant part of my yearly income, I don't have enough money to buy one.

My ultimate goal is to publish the game on iOS.

Aside from generating more revenue upfront, what are my options?

Notes from the moderators: We've made this question canonical, so we're looking for non-specific options (e.g. please avoid targeting specific regions, or suggesting to buy specific models, etc.); we'd like to help future visitors coming from all over the world, for the years to come.


texts: player movement variable is not being set to false

texts:
i have a player with a basic movement. when i press W he just keep on going
this my code
private void fixedupdate
{
    rigid.AddForce(new Vector3(0, 0, 10) * speed, ForceMode.Impulse);

    moveup = false;
}


texts: Efficient way to store entities in javascript

texts:
I am trying to design a game from strach with Javascript.

It's a 2D game (a kind of Zelda on old devices).

I am trying to find an efficient way to store my data because I know I will have to face some major challenges among which :

Pathfinding
collision

I may have more than 1 000 entities on screen and maybe even more background objects (let's shoot for the stars !)

Do you have some advices / hints / articles about an efficient way to store objects so that I can (for e.g.) retrieve only a reduced set of entities in my collision algorithm

maybe there are some design patterns to deal with those challenges ?


texts: Given N objects in my 3d world, how to set camera zoom to have all framed?

texts:
I have N objects and I've done a routine to get the overall objects :

min_x, max_x
min_y, max_y
min_z, max_z

and, i have an

 Vector3 avarage_position

that is the avarage Vector3 position of all my objects in my 3d world.

Then I have a camera.

I set my camera to

LookAt(avarage_position)

So the camera look that point.

Next step, that is my question is:  how to set Zoom (Y position of my camera) to frame all my objects having the min_x, max_x, min_y, max_y, min_z,max_z  positions ?

Thanks


texts: Would studying psychology give an advantage to a game designer?

texts:
I've recently read The Art of Game Design and am currently reading Why Reality is Broken and am wanting to learn more about the psychology behind game design. I'm a computer science student but I'm intrigued by the subject and have thought about minoring in psychology.

For the veteran game design people out there, would academically studying psychology give a huge advantage to a game designer? There is one class in particular called Sensation and Perception that gets into what goes on in the nervous system when we are stimulated through our five senses and how these stimulations creates certain perceptions.

So, basically is this over doing it for someone who wants to create games/become a game designer?

What originally caught my interest in this subject was reading about how zynga hired a psychologist to help design the mechanics for farmville.


texts: How can I rotate pixel art sprites without the aesthetics getting ruined?

texts:
I'm right now in front of a huge "Game Design" question.
I'm making a pixel-art-ish game and using bilinear interpolation could solve lots of animation-issues. On the other hand, its not a "pixel-game" anymore.

If I use Bilinear Interpolation the animation works but it looks "hybrid-ish" and the artstyle gets lost. Either I mess up my animations or I mess up the artstyle. I cant have both it seems.

Is there any other way to solve this?


texts: I'm looking for pseudo-code examples of the A* pathfinding algorithm that actually works. I tried plenty of different ones where it's not really clear how to implement them at all times. Keep in mind that I'm a newbie, so if everything could be detailed, that'd be great.


texts: How to make parabolic jump from a to b to c and so on?

texts:
I want to make a game similar to "Dancing HOP: Tiles Ball EDM Rush"

I am trying to make an object jump from point a(z=0) to b(z=10) to c(z=20) and so on, keeping the z axis distance constant for each hop.

I also want to change the x axis value when the player swipes on the screen. While swiping it should move from eg. (x=0) to (x=2 or x=-2). This translation on the x axis should be in a curve, while the object keeps moving in the z axis undisturbed.

Here is the code I have so far:

IEnumerator FollowArc(Transform mover, Vector3 start, Vector3 end, float radius, float duration) {

    //print(start);
    //print(end);
    Vector3 difference = end - start;
    float span = difference.magnitude;

    // Override the radius if it's too small to bridge the points.
    float absRadius = Mathf.Abs(radius);
    if (span > 2f * absRadius) radius = absRadius = span / 2f;

    Vector3 perpendicular = new Vector3(difference.y, -transform.position.x, difference.z) / span;
    perpendicular *= Mathf.Sign(radius) * Mathf.Sqrt(radius * radius - span * span / 4f);

    Vector3 center = start + difference / 2f + perpendicular; Vector3 toStart = start - center;

    float startAngle = Mathf.Atan2(toStart.y, toStart.x); Vector3 toEnd = end - center;

    float endAngle = Mathf.Atan2(toEnd.y, toEnd.x);

    // Choose the smaller of two angles separating the start & end
    float travel = (endAngle - startAngle + 5f * Mathf.PI) % (2f * Mathf.PI) - Mathf.PI;

    float progress = 0f;
    if (movingSignCheck == 0) {
        travel = -travel;
    } else if (movingSignCheck == 1) {
        travel = -(-travel);
    }

    do {
        float angle = startAngle + progress * travel;
        mover.position = center + new Vector3(Mathf.Cos(angle), Mathf.Sin(angle)) * absRadius;
        progress += Time.deltaTime / duration;

        yield return null;
    } while (progress < 1f);

    mover.position = end;
}


texts: How can I set decimal values to a Pygame rect position?

texts:
I'm trying to make the gravity a bit slower, like

Dog.rect.y += 0.5
print (Dog.rect.y)
screen.blit(background, (0, 0))
screen.blit(spikeUp0.image, (0, 0))
screen.blit(spikeDown0.image, (0, 436))
screen.blit(Dog.image, (Dog.rect.topleft))
pygame.display.update()

But the dog floats. The minimum I get set to y 1 with rect methods. How can I make it slower?

Here is the complete code in GitHub Gist


texts: How to access Maya Bonus Tools 2012 in Maya 2014

texts: I have been trying to use the paint geometry tool for Maya 2014 but it isnt showing up. I downloaded Bonus Tools 2012 and installed it. Where can I find this tool in Maya 2014?


texts:
I do not understand how the rotation of the image i have works. Is it something to do with the ThumbSticks on the Xbox Pad? or properties of a float? if someone could explain to me what is actually happening here i would be very greatful.

The image is of a Gun. I would like to add in shooting guided by the thumbsticks for enemies above the player, so understanding this is crucial.

The image and coding has its own class. So in Game1.cs only initialised, WMpos set to the character and update and draw methods referenced, so does not affect rotation.

This is all the relevant code for it here:

public Texture2D WMtxr;
public Vector2 WMorigin;
public float WMrotation;

public void UpdateMe(GameTime gameTime)
    {
        WMorigin = new Vector2(WMtxr.Width - 100, WMtxr.Height - 36);
        if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Right.Y < -0.1)
        {
            WMrotation += 0.03f;
        }
        if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Right.Y > 0.1)
        {
            WMrotation -= 0.03f;
        }
    }

public void DrawMe(SpriteBatch sb)
    {
        sb.Draw(WMtxr, WMpos, null, Color.White, WMrotation, WMorigin, 1f, SpriteEffects.None, 0);
    }


texts: How do I get hardware accelerated graphics and shaders in PyGame?

texts:
I have created several simple games with PyGame, but until now, I have focused on mechanics rather than graphics. The graphics in my games have been extremely rudimentary, consisting of basic shapes on black backgrounds.

I've recently decided to change that and create a 2D graphics engine supporting proper texturing, some animation, and most importantly: lighting. While researching these, especially the last, I've started doubting whether PyGame is the right tool for this. Many tutorials concering implementation of lighting, shadows, et cetera recommend using techniques such as GPU shaders and pixel-level manipulation.

Looking at the documentation of PyGame, I don't see anything that would let me implement such things with any degree of efficiency. I can access bitmaps directly with PixelArray, but doing any significant processing this way seems like it would be a performance nightmare.

How can I get hardware accelerated graphics, vertex and pixel shaders when making a game with PyGame?


texts: Finding cells within range on hexagonal grid

texts:
First up - I know I'm being super-dense here.

With that out of the way, I'm trying to write a C# implementation of this algorithm:

var results = []
for each -N ≤ dx ≤ N:
  for each max(-N, -dx-N) ≤ dy ≤ min(N, -dx+N):
    var dz = -dx-dy
    results.append(cube_add(center, Cube(dx, dy, dz)))

I've taken this from this tremendous resource.

My problem is that every implementation of this I've tried so far has had crazy results. For example, the code shown below currently results in this:

and this:

My code currently sits like this:

for (int x = this.CellPositionX - distance; x <= this.CellPositionX + distance; x++)
    {
        for (int y = this.CellPositionY - Math.Max(-distance, -x - distance); y <= this.CellPositionY + Math.Min(distance, -x + distance); y++)
        {
            HexPosition rangePosition = new HexPosition(x, y);
            range.Add(rangePosition);
        }
    }

Can anyone spot something awry here? All suggestions welcome. I've been banging my head on this one a while now.

Thanks!

Updated note: I am using Axial coordinates in the grid.
Update #2: as pointed out below, I had my for..each loop wrong and wasn't using deltas for the working out. Thanks for the help!

I currently have an issue as shown below with the implementation from the answers:

I'm going to keep investigating - if I figure it out I'll post the full results back here. Thanks all!


texts:
I've started working in a quest system for my game, but I stumble in a zone where I have to many, if/else conditions to handle a quest, whether you have X and Y item in your inventory, whether you have already talk with a NPC, or whether some other quest stage is a given value and so on.

This end ups making the code very unclean, hard to fix and extend.

I'm wondering what's a good way to handle this.

I've read that keeping your quest as XML file is a good practice, but I've never worked with XML before(I know what they are, but I'm unfamiliar with how to properly make one)

I made a template quest to handle fetch/talk quests in a CSV file. Which looks something like this:

But I'm not that I'll end-up shooting my own foot with this custom system.

The branches of a quest can depend on items, previous quests, npc status, player status... So, what's a good way to deal with this?

EDIT:

This is not a duplicate of this question since the answers for this question are either using XML (which I said I don't have the know-how) or use multiple if/else conditions, which is my start problem.


texts: How to transform a matrix's local space position into another's local space

texts:
When looking at an example to learn how to do per pixel collision, I came across this:

// Calculate a matrix which transforms from A's local space into
// world space and then into B's local space
Matrix transformAToB = transformA * Matrix.Invert(transformB);

I have a (very) basic understanding of matrices, so I'm not too sure how this works, how can you convert the local space of one matrix to another by multiplying by the others inverted?


texts: How do I avoid StackOverflow due to circular dependencies in a FSM?

texts:
I have a FSM defined as the following which essentially iterates though the actions in the current state and transitions to another state depending on the result of calling the Act function on the current action.
public interface IAction
{
    public abstract IState Act();
}

public interface IState
{
    public IAction[] Actions { get; }
}

public class StateController
{
    public IState CurrentState;

    public void Update()
    {
        foreach (var action in CurrentState.Actions)
        {
            var state = action.Act();
            TransitionToState(state);
        }
    }

    private void TransitionToState(IState nextState)
    {
        if (nextState == null || nextState == CurrentState)
        {
            return;
        }

        CurrentState = nextState;
    }
}

If I have start implementing my states and setting their actions then things get ugly pretty quickly as I set one of the return states of the LookAction to a new instance of SleepState which itself sets a return state to a new instance of WakeState.
public class WakeState : IState
{
    public IAction[] Actions { get; }

    public WakeState()
    {
        Actions = new IAction[]
        {
            new LookAction()
            {
                TargetNotVisibleState = new SleepState() // StackOverflow as this calls SleepState instantiates WakeState in its constructor
            },
            new WaitForTimeElapsedAction(2f)
            {
                TimeElapsedState = new AttackState()
            }
        };
    }
}

public class SleepState : IState
{
    public IAction[] Actions { get; }

    public SleepState()
    {
        Actions = new IAction[]
        {
            new LookAction(true)
            {
                TargetVisibleState = new WakeState()
            },
            new WaitForTimeElapsedAction(2f)
            {
                TimeElapsedState = new ScanState()
            }
        };
    }
}

public class LookAction : IAction
{
    public IState TargetVisibleState;
    public IState TargetNotVisibleState;
    public IState TargetOutOfRangeState;

    public IState Act()
    {
        if (TargetOutOfRange())
        {
            return TargetOutOfRangeState;
        }

        return CanSee() ? TargetVisibleState : TargetNotVisibleState;
    }

    ...

How would it be best to avoid this without losing the ability to set any State for the return state in an Action?


texts:
I've been dwelling with a question lately,

I can generate screenshots with my library, but i found that i would like to be able to record video from a game.

Since video is just(well-simply enough, yeah) a collection of images, i guess i could easily write "screenshots" into a single file.

I know that makes sense, but the end result won't be understood by any video application around.
That's where the question pumps in,

What is the simplest file format that i can write to, that a video editing application will be able to understand and convert to a format of choice later?

As a bonus: What if i want to add the sound too? What do you think?

Thanks for the help.


texts: Why is my character jumping at different heights randomly?

texts:
I have a character controller on my character's gameobject and I'm trying to make the character jump. This is working but sometimes he jumps way higher than other times. Does anyone know why this is happening? Here's the code:

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

public class Movement : MonoBehaviour
{
CharacterController cc;
public float Speed;
float Forward;
float Sideways;
float vertical;
public float gravity;
public float Jump;

// Start is called before the first frame update
void Start()
{
    cc = GetComponent<CharacterController>();
}

// Update is called once per frame
void Update()
{
    Forward = Input.GetAxis("Vertical") * Speed;
    Sideways = Input.GetAxis("Horizontal") * Speed;

    if (!cc.isGrounded)
    {
        vertical -= gravity * Time.deltaTime;
    }
    else
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            vertical = Jump * Time.deltaTime;
        }

        vertical = -8 * Time.deltaTime;
    }

   Vector3 Delta = transform.TransformDirection(Sideways, vertical, Forward);

    cc.Move(Delta * Time.deltaTime);
}
}


texts: Efficient unwrapping on multi hard edge object

texts:
I'm having trouble unwrapping this without creating hundreds of seams which massively increases the vertex count in the game engine (Unity).

I've tried the various projection methods without much success. Three planar maps (45 deg looking down, 45 up and one side) yielded the leat amount but still dozens.

I've tried all sorts of manual seam drawings but can't figure out what would be optimal so I'm looking for suggestions.

Regarding the texture having contiguous seams doesn't really matter.

Cross posted on Blender Stack Exchange


texts: Make a flying object rotate so the camera sees the rotation

texts:
When I attach a camera to my flying object (plane), when I rotate the object, the camera is perfectly following it so you can't really "feel" the plane rotating. I want to create the effect that you see in flying games where you see the plane rotating along the x axis (so you see the nose go up and tail down) while also semi-following the plane, creating a better effect.

How do I achieve this?


texts: How do I make my character jump in every direction?

texts:
My character can only jump when he is grounded, but he can only grounded in one direction
I want him to jump in every direction, can anyone help?

CAN JUMP :

CAN'T JUMP :

Code:

 using UnityEngine;
using System.Collections;

public class Player: MonoBehaviour {

public float maxspeed = 10f;
bool facingRight = true;

Animator anim;

bool grounded = false;
public Transform groundCheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
public Vector2 jumpDirection = new Vector2(0f, 0f);
public float jumpFocre = 500f;

bool doubleJump = false;

void Start ()
{
    anim = GetComponent<Animator> ();
}

void FixedUpdate () {
    grounded = Physics2D.OverlapCircle(groundCheck.position, groundRadius, whatIsGround);
    anim.SetBool ("Ground", grounded);

    if (grounded)
        doubleJump = false;

    float move = Input.GetAxis ("Horizontal");
    anim.SetFloat ("Speed", Mathf.Abs (move));

    GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
}
void Update()
{
    if((!doubleJump) && Input.GetKeyDown ("up"))
    {
        anim.SetBool("Ground", false);
        float move = Input.GetAxis ("Horizontal");
        jumpDirection.x = move;
        GetComponent<Rigidbody2D>().AddForce(jumpDirection.normalized * jumpFocre);

        if(!doubleJump && !grounded)
            doubleJump = true;
    }

}

void Flip()
{
    facingRight = !facingRight;
    Vector3 theScale = transform.localScale;
    theScale.x *= -1;
    transform.localScale = theScale;
}
}


texts: How can i scale up a bounding box in Xna?

texts:
In Xna a spritebatch can be passed a value for scale. I have A bounding
box Rectangle that i have a border drawn around my sprite using the bounding box rect.

Now my question Scale can make the sprite go up just fine,but how
can i get the bounding box rect to scale up with the scale propertie?