texts:
My directory for my Pygame program looks something like this:

[Parent directory]
    lib
        engine
            Various .py files
        graphics
            spritesheet.py
            spritesheet.png
    skeleton.py (starter script)
    font.ttf
    spritesheet.png
    pygame2exe.py (Pygame2Exe script)

When I run pygame2exe.py (found here, everything seems fine: the dist directory is created with an executable file and all the necessary dlls. However, when I try to run the program, it says I cannot find the file "lib\graphics\spritesheet.png"

I've tried to manually insert the image file by using 7zip to "open" the .exe; however 7zip doesn't support it. That seemed to be the best solution, but now I am stumped. Does anyone have an answer?


texts:
In my game I have some box2d bodies where I add sprites using the following code in my render() method.

for (Body body : worldBodies) {
        if (body.getUserData() instanceof Sprite) {
            Sprite sprite = (Sprite) body.getUserData();

            Vector2 position = body.getPosition();
            sprite.setPosition(position.x - sprite.getWidth() / 2 , position.y - sprite.getHeight() / 2);
            sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
            sprite.draw(batch);
        }
    }

One of the bodies has to be animated.

birdAnimation = new Animation(1, birdAtlas.getRegions());
birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

This is the animation and now I tried to set the body's sprite obstacle6 to the current textureRegion from the Animation unsing this code:

obstacle6.setRegion(birdAnimation.getKeyFrame(delta));

Somehow it just shows the first texture of the atlas. How can I get it to change? Or is there an other way to animate a box2d body?
If you need any other information just comment.


texts: In Slick2D, how can I generate a 2D platformer map from an image?

texts:
I'm fairly new to game development. I've been messing around with Slick2D. My map consists of rectangular objects. I want to use an image to represent my map, similar to this:

How could I generate a level from that image? As I said, I'm new to game development and am not familiar with terminology or procedures.

Bonus question: How could I also generate non-rectangular game objects from it?


texts: Libgdx - IsometricTiledMapRenderer and light shading

texts:
I am wondering if there is any way to simulate light shading in Libgdx using an IsometricTiledMapRenderer.

Here is my code to draw an isometric map, it's able to be moved around with the mouse and you can zoom in and out with the mouse scroll wheel.

package com.iso.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.IsometricTiledMapRenderer;
import com.iso.game.Main;

public class GameScreen extends AbstractScreen
{
    private TiledMap map;
    private IsometricTiledMapRenderer renderer;
    private OrthographicCamera camera;

    public GameScreen(Main game)
    {
        super(game);
    }

    public void load()
    {
        map = new TmxMapLoader().load("map.tmx");
        renderer = new IsometricTiledMapRenderer(map);

        renderer.getSpriteBatch().setShader(null);

        camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
    }

    public void render(float delta)
    {
        Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        camera.update();

        renderer.setView(camera);
        renderer.render();
    }

    public boolean scrolled(int amount)
    {
        camera.zoom += 0.1 * amount;
        // Don't go below the map
        if (camera.zoom < 0.01)
            camera.zoom = (float) 0.01;
        return false;
    }

    public boolean pan(float x, float y, float deltaX, float deltaY)
    {
        camera.position.add(camera.zoom * -deltaX, camera.zoom * deltaY, 0);
        return false;
    }

    public boolean touchDown(int screenX, int screenY, int pointer, int button)
    {
        if (button == Buttons.MIDDLE)
            camera.zoom = 1;
        return false;
    }

    public void resize(int width, int height)
    {
        camera.viewportWidth = width;
        camera.viewportHeight = height;
    }

    public void dispose()
    {
        map.dispose();
        renderer.dispose();
    }
}

And here is an image of what this code looks like (Note, this class is not the entirety of my code. If you need to rest for some reason please let me know).

Can anyone give me an example on how to simulate lighting with this map? Such as a point light that spreads out and looks isometric, perhaps choosing some tiles as objects that block or distort light. I have no idea how to get started and I couldn't really find anything useful online.

Thank you for your help in advance.


texts: Handling parametric and reusable sprite animations

texts:
I'd like to create a simple logic that handles sprite animations in a way that they can be easily reproduced and parametrized.
As example, I want to perform some basics animation like transitions and rotations and I like to have these animations receiving parameters as x, y and angle so that I can just attach the animation to gameObjects and set the parameters to obtain the needed animation.
I'm really new to Unity and I wonder if Controller Animators can handle this behaviour or if I have to go through animations off the Transform component properties. Is there any other way I'm not aware of to parametrize animations?


texts: How can I go about learning to write a shader

texts:
So here's the background:

I'm writing a game, just for my own amusement and education really. I've already come to the conclusion that XNA was the way to go for graphics, I've bought a couple of books, I've gotten basic game graphics going, and that's great.

Now I'm starting to get a little in-depth and I'm starting to need to do stuff not covered in my (beginner) books. In particular, I need to display a sprite using a mask. Actually, what I need to do is display a generic sprite with a different color for each player. After banging around on the web, it seems the way to go is to have a color texture (one for each player) which I display using the mask, then display the generic part of the sprite. This has to be done dynamically, i.e. at runtime because there are too many sprites to keep in memory if I try to generate all the permutations at startup.

So, I need to use a shader. Fine. I've downloaded a sample shader program, and managed to hit it with a hammer until it does something close enough to what I want so that I know I'm on the right track. And here, we come to my problem... I have no friggin' clue what I'm doing. While there are a lot of samples and such about shaders, no one ever actually explains what's going on. For instance, I can't find any real docs on Tex2D. I feel like the guys in Zoolander poking at the computer. So, my question (yes, I have a question) -- where is a good URL or what is a good book to take me from dumskie to reasonably competent to write a basic shader?


texts: HLSL texture sampler always returns white

texts:
I'm facing in problem in HLSL with Monogame that I can't figure out. The gist is that sampling from a texture seems to always return white rather than the texture's actual color. My pixel shader code is below, and then I'll say more.

texture2D fillTexture;

sampler fillSampler = sampler_state
{
    Texture = <fillTexture>;
};

sampler s0;

struct VertexShaderOutput
{
    float4 Color : COLOR0;
    float4 Position : SV_POSITION0;
    float2 TexCoords : TEXCOORD0;
};

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    return tex2D(fillSampler, input.TexCoords);
}

technique Technique0
{
    pass Pass0
    {
        PixelShader = compile ps_4_0 PixelShaderFunction();
    }
}

First, in my C# code, I'm using the SpriteBatch to draw a large rectangle. That part works fine. Second, I have a smaller texture that I'm passing as a parameter into my pixel shader (fillTexture). No matter what I try, the resulting large rectangle is pure white.

I've already verified that my shader is being applied, as the following code results in a red block.

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    return float4(1, 0, 0, 1);
}

I've also verified that my texture coordinates within the pixel shader function are correct. The following code produces the image below.

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    float2 texCoords = input.TexCoords;

    return float4(texCoords.x, texCoords.y, 0, 1);
}

I've also verified that the fill texture itself has valid colors (i.e. it isn't pure white itself).

Apart from that, I've tried every combination I've seen. I've tried using sampler2D rather than sampler, fillTexture.Sample rather than tex2D, even compiling with ps_4_0_level_9_1 and level_9_3. I've tried using SamplerState rather than sampler_state, binding registers, everything I can think of.

Any help would be greatly appreciated. Thank you :)


texts:
I have a Level Prefabs that contain enemies Prefabs inside them. Those Enemy Prefabs contain behavior script components that contain certain values controlling the behavior of this specific enemy. The problem is that those values are almost always unique for every single enemy.

Should I use ScriptableObjects in my situation and if yes, then how exactly?

The reason for my question is that I am totally new to ScriptableObjects so I wanted to ask the experts is there a way to utilize them in this situation, because I want to use the best ways / tools / features for my project right away.


texts:
My rendering engine currently takes "xMin, yMin, xMax, yMax" to render a rectangular region of tiles, and will automatically scale based on the size of the panel it is rendering to.

However, I am having an issue rendering based on line of sight. Currently (I know this is inefficient but it is simply the best option as of right now) I use Bresenham's line algorithm. However, that results in

As you can see, the walls invisible. How should I go about updating the algorithm to have it make the walls visible as well?

If I render tiles that end where the raytrace ended, I get

This implies that a floating point solution would be preferred.

Of note, I will accept suggestions on how to improve the rendering engine if it would make this more possible.


texts: Alternative to Google Play when publishing Android game app (.apk)?

texts: In order to register as a game developer and publisher of the Android app for Google Play Developer account, you must pay around $100. But what if there's a tight budget, especially for indie game developers from the start? I want to know where can I find alternatives to publish and promote Android game apps with no registration cost. It is something like a stepping stone.


texts: Setting a Boolean as a field of an object from another script

texts:
I saw this question asked some times but no one correlates to mine. I see people using the GetComponent() function but this one should work too.

First I receive a Bool value from a toggle button and assign it as a field of the object 'hydro':

hydroControl.cs

using UnityEngine;
using System.Collections;
using Assets.Code.PowerPlants;

public class hydroProwerControlPanel : MonoBehaviour {
private HydroElectric hydro;
public bool t1;

void Start ()
{
    t1 = true;
}

public hydroProwerControlPanel (){
    hydro = new HydroElectric();
}
public void turbine1State (bool t1) {
     hydro.t1Bool = t1;
}

Then I have the object where this bool change should be recognized and sent as an output, but it doesn't:

using System;
using UnityEngine;
namespace Assets.Code.PowerPlants
{
    public class HydroElectric
    {
        public bool t1Bool;
        float turbina1;

        public float prod;

        public HydroElectric ()
        {
          t1Bool = true;
          prod = 0f;
        }

        public float ControlPanel ()
        {
            turbina1 = t1Bool ? 1.5F : 0;

            prod = turbina1 ;
            Debug.Log (prod);
            return prod;
        }
    }
}

As requested, this is where the function ControlPanel() is called:

using System;
using UnityEngine;
using UnityEngine.UI;
using Assets.Code.PowerPlants;
namespace Assets.Code.Interfaces
{

public class PlayLevel1 : MonoBehaviour
{
private HydroElectric hydro;
public Text producao;

public PlayLevel1 ()
{
    hydro = new HydroElectric();
}

public void OnGUI()
{
 producao.text = hydro.ControlPanel().ToString();
}
}
}

Do you have any idea why does this Bool does not get updated? Any help appreciated.


texts: Unity UI InputField does not consume the keyboard input

texts: Unity UI:  I have an input field in which I can type.  Unfortunately, when I hit any of the movement keys, such as the space bar, I move while I'm typing which is not the effect I want.  Is there a way to force the input field to consume the keyboard input so it doesn't also get picked up by the game?  Or do I have to write the code in my game to do that for me.  (Seems like it should be configurable at least).


texts: How do I use the keyboard to activate buttons?

texts:
I have two buttons on my canvas: Play and Option. I use arrows to highlight the selected button. If I select any button and press space from the keyboard, it should active the button without needing to click on it with mouse.

I have already tried doing so with if(button_option== EventSystem.current.currentSelectedGameObject) { Debug.Log(" option selected " ); }, but it simply did not work.

How do I activate buttons using the keyboard?


texts:
What I want is that when ever my player left click(mouse click) in the menuState,
My init() method in my Game Class must reload. How can i do that???

My game class witn the init() method

public class Game implements Runnable {

private Display display;
private int width,
            height;
public String title;

private boolean running = false;
private Thread thread;

private BufferStrategy bs;
private Graphics g;

//States
public State gameState;
public MenuState menuState;
public SplashScreen splashscreen;

//Input
private KeyManager keyManager;
private MouseManager mouseManager;

//Camera
private GameCamera gameCamera;

//Handler
private Handler handler;

public Game(String title, int width, int height){
    this.width = width;
    this.height = height;
    this.title = title;
    keyManager = new KeyManager();
    mouseManager = new MouseManager();
}

// MY INIT METHOD!!

private void init(){
    display = new Display(title, width, height);
    display.getFrame().addKeyListener(keyManager);
    display.getFrame().addMouseListener(mouseManager);
    display.getFrame().addMouseMotionListener(mouseManager);
    display.getCanvas().addMouseListener(mouseManager);
    display.getCanvas().addMouseMotionListener(mouseManager);
    Assets.init();

    handler = new Handler(this);
    gameCamera = new GameCamera(handler, 0, 0);

    gameState = new GameState(handler);
    menuState = new MenuState(handler);
    splashscreen = new SplashScreen(handler);
    State.setState(splashscreen);
}

private void tick(){
    keyManager.tick();

    if(State.getState() != null);
        State.getState().tick();
}

private void render(){
    bs = display.getCanvas().getBufferStrategy();
    if(bs == null){
        display.getCanvas().createBufferStrategy(3);
        return;
    }
    g = bs.getDrawGraphics();
    //Clear Screen
    g.clearRect(0, 0, width, height);
    //Draw Here!

    if(State.getState() != null);
        State.getState().render(g);

    //End Drawing!
    bs.show();
    g.dispose();
}
//WHEN THE GAME RUNS, it also runs the intit() method and shows fps and tick

public void run(){

    init();

    int fps = 1000;
    double timePerTick = 1000000000 / fps;
    double delta = 0;
    long now;
    long lastTime = System.nanoTime();
    long timer = 0;
    int ticks = 0;

    while(running){
        now = System.nanoTime();
        delta += (now - lastTime) / timePerTick;
        timer += now - lastTime;
        lastTime = now;

        if(delta >= 1){
            tick();
            render();
            ticks++;
            delta--;
        }

        if(timer >= 1000000000){
            System.out.println("Ticks and Frames: " + ticks);
            ticks = 0;
            timer = 0;
        }

    }

    stop();

}

public KeyManager getKeyManager(){
    return keyManager;
}

public MouseManager getMouseManager(){
    return mouseManager;
}

public GameCamera getGameCamera(){
    return gameCamera;
}

public int getWidth(){
    return width;
}

public int getHeight(){
    return height;
}

public synchronized void start(){
    if(running)
        return;
    running = true;
    thread = new Thread(this);
    thread.start();
}

public synchronized void stop(){
    if(!running)
        return;
    running = false;
    try {
        thread.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
}


texts: How do you get the player's last car in GTA IV?

texts:
I am developing a car control plugin for GTA IV and everything is working except the lock/unlock doors feature.

Despite using the Player.LastVehicle handle, the code only works while the player is in the car. How can I get the code to work when the player is inside or outside the car?

Here's what I have so far:

'Lock/Unlock
        If e.Key = Keys.OemPipe AndAlso e.Control Then
            'Lock Codes: 1 - Unlocked; 2 - Locked (Player & NPCs); 3 - Locked (Player); 4 - Locked (Player, Inside); 7 - Locked (Can Break Into)
            If DoorLock = False Then
                Player.LastVehicle.HazardLightsOn = True
                Wait(1000)
                Player.LastVehicle.HazardLightsOn = False
                Native.Function.Call("LOCK_CAR_DOORS", Player.LastVehicle, 2)
                DoorLock = True
                Game.DisplayText("Vehicle Locked")
            Else
                Player.LastVehicle.HazardLightsOn = True
                Wait(2000)
                Player.LastVehicle.HazardLightsOn = False
                Native.Function.Call("LOCK_CAR_DOORS", Player.LastVehicle, 1)
                DoorLock = False
                Game.DisplayText("Vehicle Unlocked")
            End If
        End If


texts: Animation is delayed after few play attemps even though all transition times' are zero

texts:
I am trying to play animation forward and backward when player press the same button again and again. I have a straight line and I want to convert it to 8 while moving it. I want to play animation backward or forward from the exact frame where I pressed the button again.

When I pressed the button, animation starts playing and moving and If I pressed the button again in the middle of animation it is played backward from the exact frame. However, after a few try my animation starts playing with a delay or it stops playing completely.

I am sending speedMultiplier parameter to make the speed -1 to play backward my animation.

This is the video of the problem

private Animator eightAnimator;
private bool isLine;
private bool isMoving;
private bool becomingEight;
private bool becomingLine;

private Vector3 nextPosition;
private Vector3 startPosition;

// Start is called before the first frame update
void Start()
{
    isMoving = false;
    isLine = false;
    becomingEight = false;
    becomingLine = false;
    eightAnimator = GetComponent<Animator>();

    startPosition = this.transform.position;
}

// Update is called once per frame
void Update()
{
    if(Input.GetKeyDown(KeyCode.M))
    {
        eightAnimator.SetBool("isMoving", true);

        if (isLine)
        {
            isMoving = true;
            isLine = false;
            becomingEight = true;
            becomingLine = false;
            nextPosition = new Vector3(this.transform.position.x + 6, this.transform.position.y, this.transform.position.z);
            eightAnimator.SetFloat("speedMultiplier", 1f);

        } else
        {
            isMoving = true;
            isLine = true;
            becomingLine = true;
            becomingEight = false;
            eightAnimator.SetFloat("speedMultiplier", -1f);
        }

    }

    if(becomingEight)
    {
        this.transform.position = Vector3.MoveTowards(this.transform.position, nextPosition, Time.deltaTime * 10);

        if (Vector3.Distance(nextPosition, this.transform.position) < 0.01f)
        {
            isMoving = false;
            becomingEight = false;
            eightAnimator.SetBool("isMoving", false);
        }
    }

    if(becomingLine)
    {
        this.transform.position = Vector3.MoveTowards(this.transform.position, startPosition, Time.deltaTime * 10);

        if (Vector3.Distance(this.transform.position, startPosition) < 0.01f)
        {
            isMoving = false;
            isLine = true;
            becomingLine = false;
            eightAnimator.SetBool("isMoving", false);
        }
    }

}

I am adding here unity package, video, screen shot and my simple code.

So how can I play my animation when I pressed the button with the exact frame and exact time without delay

This is the project unitypackage file


texts:
What the title says.Is it possible to update a texture via a glsl shader  ? Something like :

//Read
vec4 Pixel = texture2D(TextureID,gl_TexCoord[TextureIndex].st);

//Write to texture memory ?
vec4 NewPixel = Pixel + vec4(0.0,0.0,0.0,AlphaPatch);

// ?? How to write back to texture memory ??
texture2D(TextureID,gl_TexCoord[TextureIndex].st) = NewPixel;

??


texts: Which of these two particle generator lifetime management techniques is better?

texts:
What would be better:

An explosion class which gets created when needed, does it's stuff, then is deleted. (one instance per explosion)
An explosion class which persists through the whole game, and creates a new explosion in the appropriate place when needed. (one instance per game)


texts: Why isn't my image's transparency honoured in the Unity sprite?

texts:
I'm following through Jesse Freeman's Lynda course Unity 5 2D Essential Training. The exercise files contain sprites with transparency. Here's a screenshot of one such sprite on the trainers screen (sorry it's so small):

But here's how it looks in my scene in Unity 5.5.0F3:

I think that the sprite's alpha properties are set correctly, I have Alpha Source set to "Input Texture Alpha" and Alpha Is Transparency is checked:

When I open the PNG in PhotoShop the transparency is correctly set:

Why is the transparent area rendered as opaque in my sprite?


texts: Can Xcode be used to create very simple games?

texts:
I am brand new to Xcode, and I am also brand new Objective-C programmer.

I was wondering if it is possible to create simple Mac games with Xcode. If it's not possible, could you recommend me some good, cheap game engines?


texts: Unintended twisting of geometry while generating a mesh?

texts:
I am creating a real time animation of tori (toruses), and I've run into a problem where at certain angles of my tori, the geometry is twisting up where it should remain straight.

Here is an animated gif of the animation. (sorry I can't embed this)

If you look closely you can see small twists appearing and disappearing in the geometry. Every frame, I am updating the 3D spline which is the guide for the torus, and at certain angles, the mesh gets distorted/twisted.

I've used two different approaches to generate the meshes seen here, one uses the algorithm found here, in an earlier question of mine, and the other, I used a third party quaternion library.  Both approaches produced different, but similar twisting effects.

I'm hoping there is a conceptual idea about 3D rotations I'm missing, as opposed to a small bug in my code, which would take too much of your time to lay out here.


texts: Do OpenGL buffers overflow to CPU memory?

texts:
This is a question about OpenGL buffers and memory. My game world is mid-sized, one contiguous space, unchanging, and only partially visible from any position.

Will modern OpenGL overflow buffers into CPU memory?

And if so, can I just allocate buffers (vertex and texture) for all of it, and adjust my draw calls to skip non-visible areas, and let OpenGL pull buffers into GPU as needed, hopefully minimizing thrashing? (Or does OpenGL just fail on the allocate after a while?)

EDIT: The above was ambiguous. But maybe both variations are interesting.

Could I just allocate one huge vertex buffer and a few giant textures, and hope that OpenGL moves parts of it in and out of the GPU as needed, and maybe enough early depth-testing lets it skip some of the texture drawing...
Could I have a handful, or maybe a lot, of "sensibly-sized" vertex and texture buffers, but only glDrawXxx() some of them on each frame? In that case, would OpenGL move them up and down from the GPU, maybe in a least-recently-used sort of way?


texts:
In my game, I'd like my character to be able to grab and hold onto ledges, and to be able to pull themselves up if there's room to do so.

How do I detect if there's a ledge, and if the character has enough space to climb up?


texts:
I'm making a game where in needs to randomly generate objects on a plane, so I setup a code to spawn Food, but whenever I run the code Unity uses up all my computers memory and 40% cpu.  I have a fairly good computer and have no issue with anything else in the project.  The code has worked when I called it in FixedUpdate but as soon as I try and call it in an invoke it just breaks everything.  I have only started working with unity for less than 24 hours so I don't really know what could be wrong, since I didn't get any errors or warnings.

using System.Collections;
using UnityEngine;

public class SpawnFood : MonoBehaviour
{
public Rigidbody Food;
public float x;
public float y;
public float z;
public Vector3 pos;
public float spawnTime;

void FixedUpdate()
{
    Start:
    Invoke("FoodSpawn", spawnTime);
    goto Start;
}

void FoodSpawn()
{
    x = (UnityEngine.Random.Range(-110f, 110f));
    z = (UnityEngine.Random.Range(0.50f, 0.51f));
    y = (UnityEngine.Random.Range(-50f, 51f));
    Vector3 pos = new Vector3(x, z, y);
    Instantiate(Food, pos, Quaternion.identity);
}

}


texts: Shaders: packing 4 textures into a single RGBA - slower?

texts:
I'm experiencing something really strange on an iOS mobile device. I have 4 textures, and after some profiling it seems, that doing four separate grayscale texture reads is faster, than reading the same textures from a single packed texture:

#ifdef COMBINED_METALLIC_ROUGHNESS_AO_EMISSION_TEXTURE
    fixed4 mraeTex = tex2D(_MetallicRoughnesAOEmissionTex, IN.uv_MainTex);

    fixed metallic = mraeTex.r;
    fixed roughness = mraeTex.g;
    fixed ambientOcclusion = mraeTex.b;
    fixed3 emission = mraeTex.a * albedo;
#else
    fixed metallic = tex2D(_MetallicTex, IN.uv_MainTex).r * _Metallic;
    fixed roughness = tex2D(_RoughnessTex, IN.uv_MainTex).r * _Roughness;
    fixed ambientOcclusion = tex2D(_AmbientOcclusionTex, IN.uv_MainTex).r;
    fixed3 emission = tex2D(_EmissionTex, IN.uv_MainTex).rgb;
#endif

It seems, that the second option is faster for some reason. Isn't a single texture read supposed to be faster, than doing 4 separate texture reads? Am I missing something?

Thanks!


texts: Need help with algorithm for generating connected bricks in Pick A Brick clone

texts:
I want to make a clone of an Amiga 500 game, Pick A Brick, a 2D game where the goal is to clear a table of bricks by matching them up, following certain rules. I am getting nowhere when it comes to the algorithm for generating the layout of the bricks. I have added the rules of the game (as I remember them) below.

The player wins the game by clearing all tiles before the time runs out.
Tiles are cleared by clicking on a pair of them and if the following is true:

The tiles must be of the same type (there is only one pair of each type).
There is a clear path between them (more on path in the points below).
The path from a tile must always start towards an (clear) edge of the screen.
The path between the tiles must be u-shaped.

(edit) NOTE: In the video the path is not always the u-shaped. I do not recall if the path shown is just a shortcut or not, but regardless, in my version I do not want to allow removing tiles "from inside out".

I have done some manual testing/prototyping using both outside in and inside out approaches, with variations on both. So far, nothing I have come up with has really come close. I kind of dislike asking a question like this since it is so specific, probably not of general interest and may take up more than a little time for anyone interested in helping out. That being said, some people enjoy coming up with algorithms and "solving stuff", and the community may learn something from the answer, so, a post it is.

(edit) Clarification. The algorithm must provide a solvable solution.


texts: How to Make Organic Fade to Black in Unity

texts:
I'm working a retro/old-style video game, and I was wondering whether or not there is a way to create an organic fade-to-black, similar to what is found in the original NES console. I am aware of how to create a traditional fade-to-black screen, but it doesn't really fit the theme of my game. I'm using Unity 2019.4 LTS.
Here’s a example of a character about to exit the area and cause a fade to black:

Here’s what the organic fade looks like at 75% completion:

And here’s what a traditional fade looks like at 75% completion:


texts:
I am drawing a game in 2D (isometric)
My objects have their own arrays. (i.e. Tiles[], Objects[], Particles[], etc)
I want to have a draw[] array to hold anything that will be drawn.
Because it is 2D, I assume I must prioritise depth over any other sorting or things will look weird.
My game is turn based so Tiles and Objects won't be changing position every frame. However, Particles probably will.

So I am thinking I can populate the draw[] array (probably a vector?) with what is on-screen and have it add/remove object, tile & particle references when I pan the screen or when a tile or object is specifically moved. No idea how often I'm going to have to update for particles right now. I want to do this because my game may have many thousands of objects and I want to iterate through as few as possible when drawing.

I plan to give each element a depth value to sort by.

So, my questions:

Does the above method sound like a good way to deal with the actual drawing?
What is the most efficient way to sort a vector? Most of the time it wont require efficiency. But for panning the screen it will. And I imagine if I have many particles on screen moving across multiple tiles, it may happen quite often.

For reference, my screen will be drawing about 2,800 objects at any one time. When panning, it will be adding/removing about ~200 elements every second, and each new element will need adding in the correct location based on depth.


texts: Random generation of realistic human faces

texts: What would be a practicable way of generating huge numbers of realistically looking human faces? Randomizing 3D-models and rendering them would require a lot of computing power, especially as I'm needing them on an ad-hoc basis. Layering individual 2D-drawn parts requires some artistic talent, which I'm definitely lacking. Also, I'd like to parameterize as many aspects of the generational process as possible. Do you have any suggestions how to go about this?


texts: How to slow down my Variable Timestep Loop in Java

texts:
I am currently developing a game in Java and I ran into a problem

At first, I thought my game loop was working well as it was giving a similar amount of FPS as the tutorial I was following

Then I reach to the phase where I started implementing input from the user. When the user entered in the W key the sprite would move very rapidly to the bottom of the screen and then back up to the top for no explained reason

I think it is something to do with my game loop. As I did my research I deduced that my game loop is running way to fast. The only problem is that I haven't been able to slow down the loop. Or maybe it is a totally different problem

Can anyone please help

Run method of my game:

public void run() {
    long lastTime = System.nanoTime();
    double amountOfTicks = 60.0;
    double ns = 1000000000 / amountOfTicks;
    double delta = 0;
    long timer = System.currentTimeMillis();
    int frames = 0 ;

    /*  Game loop use:
     *      From timer calls to while loops to recursive function calls to keep the game alive
     *      Until a certain condition is meet (The loop)
     *
     *      A way to delay the length of each loop iteration so you get a stable frame rate (The timing mechanism)
     *
     *      A way to make the game speed remain independent of the speed of the loop (The interpolation)*/

    //This is a variable timestep loop
    while (running) {
        long now = System.nanoTime();
        delta += (now - lastTime) / ns;
        lastTime = now;
        while (delta >= 1) {
            tick();
            delta--;
        }
        if(running)
            render();
        frames++;

        if(System.currentTimeMillis() - timer > 1000) {
            timer += 1000;
            System.out.println("FPS: " + frames);
            frames = 0;
            //While times updated per second is greater than one (allowing updates to be seen) call tick method of Handler class

            /* Fixed timestep loops vs Variable timestep loops:
             *
             *      Variable timestep loops: Great because the game will seem consistent regardless of how fast the players's computer is
             *          Allowing it to work on a variety of machines and update the game logic with very high attention to details happening in the game
             *          Graphics latency is not a problem as things are drawn as they change
             *
             *
             *
             *      Fixed timestep loops: You know that every single timestep
             *          will take up the exact same length of time. Allows for consistent gameplay
             *          regardless of how fast a machine is as you know the tick rate of your machine
             *          Works wonderfully for math-heavy games with physics operations. Also good for networked games as packets are going and coming at a generally constant speed.
             *          Keeps game logic running at a very low rate while the frame rate can still and frame rate really high
             *                                                            */
        }
        stop();
    }
}

'''

Thanks!!!


texts:
I 'understand' that the concept of how a game runs i.e

while (game_loop = true)
 {
  //handle events
  // input/output/sound etc
 }

But it has come to my attention while programming in another HLL is do some games use threads for certain operations? For example take any Pokemon game ; during interaction a textbox appears to display information. Now I've been trying to simulate that sort of textbox and the only way I could have got it to be exactly the same is by using a loop and yes once a loop is started there is no way to handle window events unless they are handled again inside the loop itself.

I couldn't have used this loop inside a different thread other than the main one (due to a DirectX limitation) so the only option was to use it inside the main program thread. I was wondering if some games work like this ; do they only use the main program thread and handle events again if they're inside a loop?

Edit: I forgot to mention this is about console games not PC games!

Thanks
Nubcake


texts: Moving large group of units 1 by 1 takes too long, how can I improve this?

texts:
I use use Unity's own NavMesh/AI system and I think it works pretty well. The only problem I have is that when I move large groups of units, they will find a path one by one, but it takes a really long time as you can see in the video:

https://gfycat.com/blankhalfdartfrog

To set destinations I use this:

    public bool SetDestination(Vector3 point)
    {
        if (SamplePosition(point))
        {
            agent.SetDestination(point);
            return true;
        }

        return false;
    }

I know I could wait until they all have pathPending == false, but that would mean the entire group moves with a huge delay. Is there some way I can improve or fix this issue?

Edit: It is quite simple to recreate (if you have some basic knowledge on Unity NavMesh): simply create a "click to move"-script that moves a List of units to where you clicked using the code above (just fill the list in Start on each unit). Put down a few obstacles and you're done.


texts: Camera rotation - First Person Camera using GLM

texts:
I've just switched from deprecated opengl functions to using shaders and GLM math library and i'm having a few problems setting up my camera rotations (first person camera). I'll show what i've got setup so far.

I'm setting up my ViewMatrix using the glm::lookAt function which takes an eye position, target and up vector

// arbitrary pos and target values
pos = glm::vec3(0.0f, 0.0f, 10.0f);
target = glm::vec3(0.0f, 0.0f, 0.0f);
up = glm::vec3(0.0f, 1.0f, 0.0f);

m_view = glm::lookAt(pos, target, up);

i'm using glm::perspective for my projection and the model matrix is just identity

m_projection = glm::perspective(m_fov, m_aspectRatio, m_near, m_far);

model = glm::mat4(1.0);

I send the MVP matrix to my shader to multiply the vertex position

glm::mat4 MVP = camera->getProjection() * camera->getView() * model;
// in shader
gl_Position = MVP * vec4(vertexPos, 1.0);

My camera class has standard rotate and translate functions which call glm::rotate and glm::translate respectively

void camera::rotate(float amount, glm::vec3 axis)
{
    m_view = glm::rotate(m_view, amount, axis);
}
void camera::translate(glm::vec3 dir)
{
    m_view = glm::translate(m_view, dir);
}

and i usually just use the mouse delta position as the amount for rotation

Now normally in my previous opengl applications i'd just setup the yaw and pitch angles and have a sin and cos to change the direction vector using (gluLookAt) but i'd like to be able to do this using GLM and matrices.

So at the moment i have my camera set 10 units away from the origin facing that direction. I can see my geometry fine, it renders perfectly. When i use my rotation function...

camera->rotate(mouseDeltaX, glm::vec3(0, 1, 0));

What i want is for me to look to the right and left (like i would with manipulating the lookAt vector with gluLookAt) but what's happening is
It just rotates the model i'm looking at around the origin, like im just doing a full circle around it. Because i've translated my view matrix, shouldn't i need to translate it to the centre, do the rotation then translate back away for it to be rotating around the origin? Also, i've tried using the rotate function around the x axis to get pitch working, but as soon as i rotate the model about 90 degrees, it starts to roll instead of pitch (gimbal lock?).

Thanks for your help guys,

and if i've not explained it well, basically i'm trying to get a first person camera working with matrix multiplication and rotating my view matrix is just rotating the model around the origin.


texts: Godot radial TextureProgress does not fully fill in after value of 61?

texts:
So i've been trying to create a radial TextureProgress node in Godot engine. I created two simple png textures of two different colored circles. Both textures are the same size and contain alpha background.

I apply one texture to the "under" and the other one as "progress". Everything seems to work fine and the progress gets filled in while the value rises until value is 61 (max 100 range). The progress then just disappears. However; once i hit 100 (exactly, not 99) the progress comes back and is fully filled in.

Why am i getting this gap of nothing between 61 and 99.9?


texts: Will using one class per inventory item create issue on the long term?

texts:
I finally managed to plug my menu to my inventory system, display current items, use them etc. But the way I did it... makes me feel dirty.

To cut short, my items are described this way:

using System;

public abstract class Item {
    public abstract string Name { get; }
    public abstract string Description { get; }
    public virtual bool IsUsable { get { return false; } }
    public virtual bool IsEquippable { get { return false; } }
    public virtual bool NeedTarget { get { return false; } }
    public virtual void OnUse() { }
}

public class Potion : Item {
    public override string Name { get { return "Potion"; } }
    public override string Description { get { return "Restores 100HP to one character"; } }
    public override bool IsUsable { get { return true; } }
    public override bool NeedTarget { get { return true; } }

    public void OnUse(PlayerCharacter target) {
        Effects.HealTarget(target, 100);
    }

    public override void OnUse() {
        OnUse(GameData.getFirstPc());
    }
}

public class Poison : Item {
    public override string Name { get { return "Poison"; } }
    public override string Description { get { return "Deals 100HP damage to one character"; } }
    public override bool IsUsable { get { return true; } }
    public override bool NeedTarget { get { return true; } }

    public void OnUse(PlayerCharacter target) {
        Effects.DamageTarget(target, 50);
    }

    public override void OnUse() {
        OnUse(GameData.getFirstPc());
    }
}

My Inventory is declared like this:

public class Inventory {
    private static Dictionary<string, Item> ItemDB = new Dictionary<string, Item>() {
        { "00001", new Potion()},
        { "00002", new Poison()},
        { "00003", new HiPotion()},
        { "00004", new FangOfDestroyer()},
        { "00005", new Elixir()}
    };

    public static Dictionary<string, int> CarriedInventory = new Dictionary<string, int>();
}

When I want to add items to CarriedInventory I basically call CarriedInventory[itemID] = newAmount

Everything only uses the ID, and when I want to get an item's name I call ItemDB[itemID].Name, when I want to use an item I call ItemDB[itemID].OnUse() , etc

My reasons for doing this were:

I can be as specific as I want on item uses as I want, I can have unique item effects without having to worry about extending it to all other items
I can use the effects in the Effects class for general effects (heal, damage, etc)
if later on I realize I need a new property for an item, I can just add a virtual property as default to the Item class (e.g. I realize I want an item to not be droppable, I add a public virtual bool IsDroppable with a value of true, and non-droppable items can override this
I avoid inheritance hell

And... it works, it works, but it feels wrong.

Is it wrong? How wrong?

Is there a better way to do it?


texts: Moving and shrinking circle to a circle inside of it (PUBG like zone)

texts:
I am trying to create a battle royale circle gamemode within Arma3 that would work like in PUBG.
For anyone who doesn't know how it looks like:

Red circle should smoothly shrink into the blue one (that means sides that close to each other should move very slowly by adjusting speed of the red circle center)
Global variables:
Center = (getMarkerPos "marker_start"); // eg. [1000, 1000]
ClosingSpeed = 0.5;
CurrentRadius = 1000;
EndingRadius = 250;
Offset = 1;

Code for generating new circle:
// Determines maximum radius of a new circle
private _maxRadius = CurrentRadius * 0.7;
// Generates radius of the new circle
private _randomRadius = [_maxRadius * 0.6, _maxRadius] call BIS_fnc_randomNum;
// Generates new circle center
private _randomCenter = [CurrentRadius * 0.1, (CurrentRadius - _randomRadius)] call BIS_fnc_randomNum;
// Randomizes position of the new circle within the old one
FinalCenter = Center getPos [_randomCenter, random 360];
EndingRadius = _randomRadius;
ClosingSpeed = ClosingSpeed / 2;
// This number should be somehow calculated to make the closing circle animation work properly
Offset = 0.75;

Shrinking code, executed every 100 ms:
// Decreases radius
CurrentRadius = CurrentRadius - ClosingSpeed;
// Gets the angle between two center points - in degrees
private _angle = ((FinalCenter select 1) - (Center select 1)) atan2 ((FinalCenter select 0) - (Center select 0));
if (CurrentRadius > EndingRadius) then {
    // This sets new position of the circle
    Center set [0, (Center select 0) + ((Offset * ClosingSpeed) * cos (_angle))];
    Center set [1, (Center select 1) + ((Offset * ClosingSpeed) * sin (_angle))];
};

Without the correct Offset it shrinks like this - center points (red circle center was moving at a wrong velocity):


texts:
I would like to dynamically "build" a song in my game by adding/removing instrument layers. This is normally possible exporting each instrument layer as a separate track, but this method is not so efficient for memory (it's like having multiple songs). I've started to use FMOD recently, so I would like to know if there is a method to save a song with multiple instrument tracks, for example, in an internal format, so that I can manipulate which instrument is going to play by code.

EDIT:
An example from my game: I have a character that can transform to different forms. Imagine that the player has an aggressive melee form: I want that the main theme changes accordingly with the current player form. In my example, when the player is in the melee form, I want to add an electric guitar. If I change to a "bird" form, it would be nice to have a marimba instead of the guitar. Note that the rest of the main theme remain exactly the same. I know that I can export different songs, each one tailored for each player form, but I was wondering if it is possible to do something "better".
When you save a song as a project file, you have more information than the actual music. Take FMOD Designer, for example:

Here we have all the information about layers, instruments etc. so that is possible to mute an instrument, for example. What I want to achieve is to make one song, containing all the instruments(guitar,marimba in the example), so that I can mute/un-mute them by code. Is there a way to have such a format loaded by FMOD c++ API?


texts: Spine: export both skeleton and spritesheet

texts:
I am follow this tutorial for animation using spine. In this tutorial, they are import components separately (i.e: head, body, hands, legs ...). After I finish animation part, I want to export to json. After export to json, I check content, I see this:

{
"skeleton": {
    "hash": "3EPAHc7vcP4zQ93w+eSLhR5M6YQ",
    "spine": "3.6.53",
    "width": 205.5,
    "height": 506.79,
    "images": "../../Downloads/SpineElf_START/"
},

I see that images path is absolutely. Moreover, they are using images separately based on file name.

"lArm": {
            "lArm": { "x": 59.26, "y": 8.91, "rotation": 76.18, "width": 69, "height": 142 }
        },

I want to use spritesheet. I don't have much experience in this field. So my question is: We will import spritesheet from very first time start project or there is an option in spine that allow export json file + spritesheet.

Thanks


texts: I'm wanting to render multiple objects on a screen and in some cases several of each object. I'm not sure what the best method of doing this is and was wanting some advice. The only way I can think of doing this is having X Command Buffers for each model I want to render and store all draw requests for that model inside, then submit them when I require the draws.... Would this work or is there a better solution?


texts: Anti-Aliasing + Atlas Texture + VBO = nasty looking artifact

texts:
With my research I have found that using a VBO to render graphics is much faster than using depreciated OpenGL. I've found with this that you can't switch textures mid VBO render, so if I have multiple objects in a single VBO, they all have to use the same texture. I solved this problem by using a texture atlas to combine multiple textures together into one texture used throughout the whole VBO.

Now all this works perfectly. It's fast, it's efficient, and it looks good until you turn on SFML's anti-aliasing. If you look at the pictures, it appears that it's merging textures in the texture atlas at a distance. These pictures should help clear up what that means.

Without Anti-Aliasing:

With Anti-Aliasing:

The Atlas Map as it looks in memory:

Also if it helps, I experimented with adding blank space between these individual textures to see if that would hide the problem. The problem persists, only it makes objects far away appear translucent because of the alpha between the textures.


texts: Getting an object to shoot directly towards click libgdx java

texts:
I am trying to get my player to shoot a spell and it travels to where ever the player clicked. I can easily accomplish this by doing the following.

    if(position.x >= destination.x - 1 && position.x <= destination.x + 1)
        reachedX = true;
    if(position.y >= destination.y - 1 && position.y <= destination.y + 1)
        reachedY = true;

However if the players origin is at, for example, 0,0 and I click at 10,300 then it travels right and up but when the spell reaches an x of 10 it travels directly upwards. I want the spell to travel at an angle that it will reach the x coordinate at the same time as the y coordinate. Here is an image showing what happens and what I want to happen.


texts: Legal issues concerning using superheroes in games

texts:
Before proceeding on with the idea of developing a mobile game that involves superhero characters from both Marvel/DC Comics, I am taking a serious dip into looking into things from a legal point of view. As what I have observed so far that all the games of this genre are under the banner of warner bros. or some other concerning production company.

I need to know whether it is legal to use the names/images/weapons/sounds/themes or any other specific association of a given character in a game?

If not, then what is the right way of going about to make one? Should I need some sort of permission/license to make one?

What if the game developed is kept free? Will that give us a safe passage to walk on?


texts: How to Effectively Create Bullet Patterns

texts:
I'm currently creating a top-down shooter like Touhou. The most important factor of the game is that there are many diverse patterns and ways at which bullets are generated and shot at the player, see this video: http://www.youtube.com/watch?v=4Nb5Ohbt1Sg#start=0:60;end=9:53;

At the moment, I'm using a class "Pattern" which has a series of steps on moving and shooting. However, I feel this method is quite laborous as I have to create a new Pattern for each attack and perhaps new Bullet classes that will implement a certain behavior.

This question received a comment suggesting I should look into BulletML for easy creation and storage of bullets with a specific pattern. It looks decent, but it led me to wonder, what other solutions do you have that I should take into consideration?

Update

My current design is as follows:

An example of an implemented pattern:

My GigasPattern first executes a teleport which moves Alice to a certain point (X, Y) on the screen. After this is completed, the pattern starts using the Mover to move the sprite around (whereas teleporting has separate effects and animation). These are of no concern, really, as they are quite simple.

The Shooter also creates various Attacks, which are classes again that the Shooter can use to create various patterns of bullets, much like the one in the question I posted. Once the Mover has reached it's destination, both it and the shooter stop and return to an inactive state. The pattern completes, is removed by the AI and a new one gets chosen.


texts: How to check whether a ray cast hits a specific side of an object?

texts:
I am using Ogre3d to develop a 3d simulation/game. One task is to determine whether the user has focused the camera on a specific object. So I cast a ray from the camera to what is currently in the center of the screen. This check works fine, I can determine which object is currently in the focus (i.e. centered on the screen).

However, I also need to determine which side of this object is in focus (i.e. centered on the screen). So, for example, when I have a model/object of a human standing on the ground, I need to determine whether the user looks at this model from the front or from the back.

How can I determine which side of an object is currently in the focus of the camera?


texts: Unity: Stop Rigidbody from moving in one direction

texts:
I move a rigidbody by moving the mouse.

I want my rigidbody to stop moving in the x direction when it exceeds a certain range. To do that I set the x velocity to 0. If I log the velocity, the x-value is 0 when I exceed the range, but somehow it is still moving slightly.
The following answer SOLVED it for me: Limit position rigidbody

You need to put the code that controlls the range inside Update or LateUpdate and in General, it is better to use Math.Clamp instead of the if-statements

    //React on user input
    float xForce = Input.GetAxis("Mouse X");
    float yForce = Input.GetAxis("Mouse Y");

    xForce *= Time.fixedDeltaTime * speed;
    yForce *= Time.fixedDeltaTime * speed;

    handRb.AddForce(new Vector3( xForce,  yForce, 0));

    //Check, if hand is movable in current Direction
    Vector2 currentPos = hand.localPosition;
    float xVelocity = handRb.velocity.x;
    float yVelocity = handRb.velocity.y;

    if ((currentPos.x <= (-movementPlaneScale.x / 2) && (xVelocity < 0)) || (currentPos.x >= (movementPlaneScale.x / 2) && (xVelocity > 0)))
    {
        xVelocity = 0;
    }

    if ((currentPos.y <= (movementPlaneOriginY - (movementPlaneScale.y / 2)) && (yVelocity < 0)) || (currentPos.y >= (movementPlaneOriginY + (movementPlaneScale.y / 2)) && (yVelocity > 0)))
    {
        yVelocity = 0;
    }

    Debug.Log(xVelocity);
    handRb.velocity = new Vector3(xVelocity, yVelocity, 0);

How can I stop the rigidbody from moving along one axis?


texts: How to color individual parts of curve in unity, real time?

texts:
So I have a mesh curve that I've imported from Blender. What I want to do is to place individual points on the curve (at fixed distance) and then based on a specific number, color them.

Let's say for instance number 1000 is color red and number 10 is color blue (based on color gradient). These numbers get updated real time, so I want my color to get updated real time.

I have no idea how to approach this problem. I've looked up some ideas but couldn't find anything useful.

Please help!

Thank you


texts: Is there a game oriented graphics or image editor?

texts:
I remember looking a few times over the years for an alternative to Photoshop for editing images. I've tried using Gimp too, and that's also not quite sufficient. There are some problems that have only been solvable by breaking out into an asset compiling stage. For example, none of the graphics packages come with premultiplied alpha options, and none come boxed with previews of what the image will look like once it's been compressed for hardware. I've never come across a package that lets you modify the diffuse, specular, ambient and normal maps all at the same time with the same tools.

Is there an image manipulation package out there that can satisfy things like this, allow for textures that have more than just 4 channels, export with preview to final format, maybe even rendering them in some coherent way?

items on the wishlist include:

batch conversion
scriptable pixel shader/transform
view diffuse+alpha over a background / allow alpha2coverage preview
render depth mapping via height or normal map
show mip-maps and allow editing them


texts: How does atan2 work when getting angle of a vector?

texts:
I know that atan2 gives me the absolute angle of any vector. But it doesn't give a value from 0 to 360 degrees. Instead, it gives a value (if I'm not mistaken), between 0 and 180, or between 0 and -180. For example, instead of giving angle 270, it will say -90.

This is a little confusing for me. Let me try to describe how I think this works, and please tell me if I'm correct. Actually, I'll draw it.

Is this correct? I'm having a little trouble understanding this. Thanks


texts: How to represent ray and line segment in parametric form?(Visibility)

texts:
I am trying to implement this algorithm but am not sure how I am supposed to represent my ray and my line segments(walls).
For the r_px/r_py do I just use the position of the light? For the r_dx/r_dy do I just use the normalized vector pointing from the light position to the direction of the ray?
For the s_px/s_py do I just use the location of one of the two points of the line segment. Finally for the s_dx/s_dy do I just use the normalized vector pointing from the first point, to the second point?
Thanks!


texts: How do I create 4 rows of SDL_Rects with each row being a different color?

texts:
So using a class i've created a vector and managed to make one row of SDL_rects(with collision detection and destroy on collision). But when I make a second row(and obviously 2 or more rows):
1) it doesn't make the row
2) it makes the row on top of the first row and overrides the color.

BTW this is a breakout game and i've looked through a bunch of source code but I can't find an answer.

I thought if I pass a variable called(barType) using a switch statement I can do this, but it doesn't work.

Here is part of the Bar class:

Bar(int xPos, int yPos,  int barType){
    x = xPos; y = yPos;
    type = barType; shown = true;
    gBar.x = x;
    gBar.y = y;
    gBar.w = 130;
    gBar.h = 20;
}
int x,y;
int type;

void show() {
    //if(shown) {
        switch(type) {
            case 0:
                SDL_SetRenderDrawColor(gRenderer, 255, 0, 0, 255);
                break;
            case 1:
                SDL_SetRenderDrawColor(gRenderer, 0, 205, 0, 255);
                break;

        }
  //  }
}

I managed to do it by using images but when I use color it doesn't work.I get a "Bad access" error from Xcode.

Here is the for loop that creates the Bars:

for (int j = 0; j < 2; ++j) {
    for (int i =0; i < 5; ++i) {
        //if (bars.size() <=4) {
            bars.push_back(Bar(xOffset, yOffset, j));
        //}

        xOffset = xOffset + 154;
       // SDL_SetRenderDrawColor(Renderer, 204, 204, 0, 255);
        SDL_RenderDrawRect(Renderer, &bars.at(i).barsRectGet());
        SDL_RenderFillRect(Renderer, &bars.at(i).barsRectGet());

    }
    xOffset = 0;
    yOffset += 20;
}

TLDR: I want to created 4 rows of SDL_Rect. Each row containing 4 or 5 Rects(doesn't really matter right now).And each row being a different color.

I hope I formatted this question so you guys can understand easily.


texts:
I have been making a Texas Hold'Em game as a part of an assessment, and I have been mulling over how to examine the 7 available cards and determine if hands exist.

The only possible method I can think of is to sort the cards numerically, then examine each possible group of 5 cards and check if they match a list of every single possible hand. That would take a long time snd would only be feasible for determining pairs, as the suit is irrelevant.

The cards are each strings, made up of a number/a/j/q/k, and a suit (char)3 (that makes a little spades symbol).

Does anyone have any suggestions, formulas, or links I could use to help create a hand-analysing system?

Don't worry about ranking hands against each other yet, that's a different kettle of fish.


texts:
I would like to scale a D3D11Texture2D to make it smaller.

I'm using AcquireNextFrame to get an output of my desktop but it's on FullHD resolution. I just want to scale the texture because I need then to send the buffer over network.

Here is my code :

if (mRealTexture == nullptr) {
        D3D11_TEXTURE2D_DESC description;
        texture2D->GetDesc(&description);
        description.BindFlags = 0;
        description.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
        description.Usage = D3D11_USAGE_STAGING;
        description.MiscFlags = 0;
        hr = mDevice->CreateTexture2D(&description, NULL, &mRealTexture);
        if (FAILED(hr)) {
            if (mRealTexture) {
                mRealTexture->Release();
                mRealTexture = nullptr;
            }
            return NULL;
        }
    }
    mImmediateContext->CopyResource(mRealTexture, texture2D);

    if (mScaledTexture == nullptr) {
        D3D11_TEXTURE2D_DESC description;
        texture2D->GetDesc(&description);
        description.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
        description.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
        description.Width = 1440;
        description.Height = 585;
        description.MipLevels = 4;
        description.ArraySize = 1;
        description.SampleDesc.Count = 1;
        description.SampleDesc.Quality = 0;
        description.Usage = D3D11_USAGE_DEFAULT;
        hr = mDevice->CreateTexture2D(&description, NULL, &mScaledTexture);
        if (FAILED(hr)) {
            if (mScaledTexture) {
                mScaledTexture->Release();
                mScaledTexture = nullptr;
            }
            return NULL;
        }
    } //How to copy the mRealTexture to the mScaledTexture and get the new buffer ?

    D3D11_MAPPED_SUBRESOURCE mapped;
    hr = mImmediateContext->Map(mRealTexture, 0, D3D11_MAP_READ_WRITE, 0, &mapped);
    if (FAILED(hr)) {
        mRealTexture->Release();
        mRealTexture = NULL;
        return NULL;
    }
    unsigned char *source = static_cast<unsigned char *>(mapped.pData);

Thank you very much for your help.


texts: How simulate the return effect of the wheel of fortune needle

texts:
I am trying to create a spinning wheel which slows down after a specific time.
I managed to simulate the slowdown of the wheel but I need also to put a needle which go up and down with an angle of 45°.

Here my wheel with the needle :

My wheel turn in clockwise and the needle (object in red in the above scheme) rotate in counter clockwise.

Once done the needle back to his original position slower than the previous movement.

The code i wrote :

// Once 3 seconds are passed, the speed rotation start to decrease
If RealMillisecs() -_fRotateTime > 3000 Then
    If _fSpeedRotation > 0 Then
        _fSpeedRotation = _fSpeedRotation - 0.001
    Else
        _fSpeedRotation = 0
    EndIf
EndIf

_fWheelRotation -= _fSpeedRotation * dt.frametime

// If the needle is not going back to its orginal position then is going up
If not _bAnimBackNeedle Then
    _fNeedleRotation = _fWheelRotation Mod 45 * -1

   /* If its previous rotation greater than actual position
    it's mean that the needle has reach its max angle (45)*/
    If _fNeedleRotation < _fPreviousNeedleRotation Then
        _bAnimBackNeedle = True // The going back animation to true
    EndIf

    _fPreviousNeedleRotation = _fNeedleRotation
EndIf

// If the going back animation is set to true or the wheel has stopped to turn
// get the needle back to its position at constant speed
If _bAnimBackNeedle Or _fSpeedRotation = 0 Then
    _fNeedleRotation -= 0.5 * dt.frametime
    If _fNeedleRotation <= 0 Then
        _bAnimBackNeedle = False
    EndIf
EndIf

My code doesn't make what i hope.

The needle doesn't come back to its original position when the wheel is stopped.

How can I managed the code to have the wheel and the needle with a good behaviour?


texts: Cannot Draw a triangle without VAO on MacOS

texts:
So I was watching Cherno's Video on Vertex attributes and he was successful in drawing a triangle without a VAO, but in tutorials from learnopengl.com they specifically say they we need a VAO to draw VBO and I tested it and it works fine.
Here is my snippet :
//==============================================================================
// glGenVertexArrays(1, &VAO);
// glBindVertexArray(VAO);

glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(triangleVertices), triangleVertices, GL_STATIC_DRAW);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);

//-----------------------------------------------------------------------------
// Game Loop
//-----------------------------------------------------------------------------
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
    /* Poll for and process events */
    glfwPollEvents();

    /* Render here */
    glClearColor(0.2f, 0.3f, 0.3f, 1.0f);   // RGBA
    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgram(shaderProgram);
    // glBindVertexArray(VAO);// we did not unbind it so it's still binded to the assigned      VAO
    glDrawArrays(GL_TRIANGLES, 0, 3);

    /* Swap front and back buffers */
    glfwSwapBuffers(window);
}
//-----------------------------------------------------------------------------

This only works if I uncomment the VAO which is understandable, what I can't get my head around is how did Cherno got it working without a VAO and just using a VBO? Is it a MacOS specific thing?


texts: Representing feelings such as temperature, pain, smell, taste, hunger, and thirst immersively

texts:
In a totally immersive, simulation-type role-playing game, the player should not look at bars or numbers to keep track of his or her stats, so another method of showing these stats is needed.  For example, the player needs to know when to eat, because games (currently) cannot incite a real feeling of hunger.  The player also needs to know if they are hurt, so they can take appropriate measures.

Somehow, these feelings must be represented visually or audibly.  I'm not a fan of coloring and blurring the screen to show feelings like how most first-person shooters show that you have been shot.  What are some ways to represent these feelings immersively?


texts: Unity RaycastHit2D sprites error C#. Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?

texts:
Figured out that this code only works on 3D colliders so how do I change it so that I can use it on 2D colliders?

Below is the c# code.

using UnityEngine;

// This script allows you to drag this GameObject using any finger, as long it has a collider
public class SimpleDrag : MonoBehaviour
{
    // This stores the layers we want the raycast to hit (make sure this GameObject's layer is included!)
    public LayerMask LayerMask = UnityEngine.Physics.DefaultRaycastLayers;

// This stores the finger that's currently dragging this GameObject
private Lean.LeanFinger draggingFinger;

protected virtual void OnEnable()
{
    // Hook into the OnFingerDown event
    Lean.LeanTouch.OnFingerDown += OnFingerDown;

    // Hook into the OnFingerUp event
    Lean.LeanTouch.OnFingerUp += OnFingerUp;
}

protected virtual void OnDisable()
{
    // Unhook the OnFingerDown event
    Lean.LeanTouch.OnFingerDown -= OnFingerDown;

    // Unhook the OnFingerUp event
    Lean.LeanTouch.OnFingerUp -= OnFingerUp;
}

protected virtual void LateUpdate()
{
    // If there is an active finger, move this GameObject based on it
    if (draggingFinger != null)
    {
        Lean.LeanTouch.MoveObject(transform, draggingFinger.DeltaScreenPosition);
    }
}

public void OnFingerDown(Lean.LeanFinger finger)
{
    // Raycast information
    var ray = finger.GetRay();
    var hit = default(RaycastHit);

    // Was this finger pressed down on a collider?
    if (Physics.Raycast(ray, out hit, float.PositiveInfinity, LayerMask) == true)
    {
        // Was that collider this one?
        if (hit.collider.gameObject == gameObject)
        {
            // Set the current finger to this one
            draggingFinger = finger;
        }
    }
}

public void OnFingerUp(Lean.LeanFinger finger)
{
    // Was the current finger lifted from the screen?
    if (finger == draggingFinger)
    {
        // Unset the current finger
        draggingFinger = null;
    }
}

}


texts: Creating structure to a game (Missions, Dialogue, Triggering events upon items collected, etc) & monitoring the progress of a player in our code?

texts:
Hello all I have been working with Unity and other game engines/libraries for many years in my spare time. It's been a long twisty road full of joy and pain :D In the last few months or so I have been jumping back in and noticing I really have a good grasp of the basics for almost all aspects of game development (in other words I can happily make little characters move on input in several ways with rigidbody, without rigidbody; Animations I have an ok understanding with; shaders and skyboxes and post processing I kind a barebones knowledge of, etc).

My main issue I always come unstuck with (and end up defeated until I start building a new project which just involves doing the above stuff I listed that I already kinda understand), is managing actual Quests or Special Events throughout the game.

For example, today I'm trying to make a puzzle game (similar to Monkey Island but much much more basic puzzles for now). So you start out in the game stuck inside a room, there are many items in the room , and a door and fireplace.
The door is locked. To solve the puzzle you just need to use the Jug of Water on the fire, then you will be able to click the fireplace to climb out of the room.

I've actually made this exact puzzle before and it all worked (I used mainly Strings and had complicated if statements to work out if the player was holding that item). But once I applied this method across a whole game (lets say you keep the empty water jug there and need it in a puzzle way later in game along with some other items etc.) then it gets majorly complicated and seems like not a good way to do it.

I've read lots about text-data types. Apparently its possible to create my own custom commands in text files so that I can annotate the text and use that to trigger methods in my code , but whilst I have read a bit about this on a few forum posts I cannot find much help with coding this (on a very simple beginner level).

I'm hoping I can build a text file that holds items along with dialogue and mission data : Item names; Item description dialogue; Whether they are quest items; Can they be combined (and if so with what and into what);

Ideally, the same system could be used for dialogue (Initial "Hello" with NPC; follow-up conversations; does NPC give quests? if so start one; final (after all quests from this NPC complete) "See ya around!" type dialogue) The text file should be able to help me from what I've read but I dont know how?!?!?

I'm fairly well versed in Polymorphism so like an Item is the parent and then child class might be Food: Item ; Weapon: Item; Tool: Item ,etc.
and I also have parsed data from text to make simple pong-breakout style levels (using Json and XML). I feel like that is the way to do it, but Im missing much about adding attributes or custom markup or something like this to my text data.

I know the query here is extremely broad but any broad helpful suggestions of where I can start would be greatly appreciated. Many thanks


texts: Box2D - World step on Android game using LibGDX

texts:
I'm running a simple Libgdx game using Box2D physic and i get different speed on different Android devices.

I believe that this is because timestep.

If I use 1 and 2 example i get different speed on different devices and the 3 example it works nice but on old devices (on my old smartphone Galaxy Wonder) lose fps and is unplayable

1)

world.step(1f/60f, 6, 2);

2)

static final float STEP_TIME = 1f/60f;
float accumulator = 0;

private void stepWorld() {
    float delta = Gdx.graphics.getDeltaTime();

    accumulator += Math.min(delta, 0.25f);

    if (accumulator >= STEP_TIME) {
        accumulator -= STEP_TIME;

        world.step(STEP_TIME, 6, 2);
    }
}

3)

world.step(Gdx.graphics.getDeltaTime(), 6, 2);

There is an other way how to get the same speed?


texts: How to subscribe to an event fired from any Instance/Object of type X?

texts:
I'm currently working on a small game engine and I'm kinda stuck on finding the right pattern to subscribe to an event fired from any instance of type X. To understand what I'm trying to achieve, here are some code snippets:

 public class FireEffect : BaseEffect
 {
   public FireEffect(BaseAbility effectOwner)
   {
    this.Owner = effectOwner; // each effect belong to an ability
    this.Name = "Fire";
   }
   //apply effect on target
   public override void CalculateEffect(Unit target)
   {
    // set the event here (to get the target as argument for the event)
    this.Event = new EventDispatcher(this.Owner, new EffectEventArgs(target));
    this.Event.DispatchMyEvent(); // rise/dispatch this effect event
    base.CalculateEffect(target); // do stuffs like burn ..damage etc
  }
}

and let,s say we have two Units: a "dragon" with FireBall ability (contain FireEffect) and a "Shaolin" with a passiveAbility (contain WindEffect)

 public class PassiveAbility : BaseAbility
 {
   public PassiveAbility(Unit caster)
   {
    this.Name = "WindFury";
    this.Caster = caster; // ability caster (owner)
    this.EffectList = new List<BaseEffect>(); // effects that an ability possess
    this.EffectList.Add(new WindEffect(this));
    this.initListeners(); // subscribe to events (aka add listeners)
   }

   // apply all effects that this ability has on the selected target
   public override void DoAbility(Unit target)
   {
     foreach (BaseEffect eff in this.EffectList)
    {
        eff.CalculateEffect(target);
    }
   }
   // THE MAIN PROBLEM :
   public override void initListeners(){}

  //call this method if FireEffect.Event was rised
  public void CallBack(object sender, EffectEventArgs e)
  {
   BaseAbility ab = (BaseAbility)sender;
   this.DoEffect(ab.UnitCaster); // hit the unit caster back (revenge)
  }
}

How to subscribe via PassiveAbility.initListeners() to an event fired from any instance of type FireEffect (an ability that use fireEffect)?

In other words: when our dragon throws an ability with a FireEffect (like fireBall) on our friend "Shaolin", he should react to it using WindEffect via PassiveAbility.

Notice please that we can have so many dragons and Shaolins in this game or simulation and any passive holder (unit) should only react to the attacker (unit) etc.

Many thanks in advance for your support and contribution.


texts: Libgdx: How to replace texture with shaperenderer?

texts:
I have a method that creates rectangles, it takes a texture

 for (Rectangle rect : rect) {
            game.batch.draw(rectImage, rect.x, rect.y);
        }

The texture is simple, I could just draw it instead. I created for example

shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
shapeRenderer.rect(
        rect.x,
        rect.y,
        rect.width,
        rect.height,
        Color.DARK_GRAY,
);

Now what? game.batch.draw doesn't accept shapeRenderer instead of rectImage and doesn't accept only rect.x, rect.y

I'm just wondering how to call it?


texts: How would I handle input with a Game Component?

texts:
I am currently having problems from finding my way into the component-oriented XNA design.

I read an overview over the general design pattern and googled a lot of XNA examples. However, they seem to be right on the opposite site. In the general design pattern, an object (my current player) is passed to InputComponent::update(Player). This means the class will know what to do and how this will affect the game (e.g. move person vs. scroll text in a menu).

Yet, in XNA GameComponent::update(GameTime) is called automatically without a reference to the current player.

The only XNA examples I found built some sort of higher-level Keyboard engine into the game component like this:

class InputComponent: GameComponent
{
    public void keyReleased(Keys);
    public void keyPressed(Keys);
    public bool keyDown(Keys);

    public void override update(GameTime gameTime)
    {
        // compare previous state with current state and
        // determine if released, pressed, down or nothing
    }
 }

Some others went a bit further making it possible to use a Service Locator by a design like this:

interface IInputComponent
{
    public void downwardsMovement(Keys);
    public void upwardsMovement(Keys);
    public bool pausedGame(Keys);

    // determine which keys pressed and what that means
    // can be done for different inputs in different implementations
    public void override update(GameTime);
 }

Yet, then I am wondering if it is possible to design an input class to resolve all possible situations. Like in a menu a mouse click can mean "click that button", but in game play it can mean "shoot that weapon".

So if I am using such a modular design with game components for input, how much logic is to be put into the InputComponent / KeyboardComponent / GamepadComponent and where is the rest handled?

What I had in mind, when I heard about Game Components and Service Locator in XNA was something like this:

use Game Components to run the InputHandler automatically in the loop
use Service Locator to be able to switch input at runtime (i.e. let player choose if he wants to use a gamepad or a keyboard; or which shall be player 1 and which player 2).

However, now I cannot see how this can be done.

First code example does not seem flexible enough, as on a game pad you could require some combination of buttons for something that is possible on keyboard with only one button or with the mouse)
The second code example seems really hard to implement, because the InputComponent has to know in which context we are currently. Moreover, you could imagine your application to be multi-layered and let the key-stroke go through all layers to the bottom-layer which requires a different behaviour than the InputComponent would have guessed from the top-layer.
The general design pattern with passing the Player to update() does not have a representation in XNA and I also cannot see how and where to decide which class should be passed to update(). At most time of course the player, but sometimes there could be menu items you have to or can click

I see that the question in general is already dealt with here, but probably from a more elobate point-of-view. At least, I am not smart enough in game development to understand it. I am searching for a rather code-based example directly for XNA.

And the answer there leaves (a noob like) me still alone in how the object that should receive the detected event is chosen. Like if I have a key-up event, should it go to the text box or to the player?


texts: Finding the contact point of two spheres

texts:
Is there a way to get the normal and depth of two spheres that have collided.

I know that it is something to do with the center and radius of two spheres but I am not sure what


texts: Circled plus math symbol - Direct sum of triangles?

texts:
I'm reading a paper on terrain rendering LOD and there's some math notation there I'm not clear on.

When talking about how triangles are split into pairs of smaller triangles where more detail is needed on the mesh they have an equation along the lines of

large triangle = left triangle ⊕ right triangle

From the context of the rest of the paragraph, I get that they're saying that the bigger triangle contains/is made up of the two smaller triangle.  But what specifically does that symbol mean in terms of triangles & trigonometry?

Should that be interpreted as the direct sum of two triangles?  If so, what does that operation actually entail?  Performing a direct sum of the matrices of the triangle vertices?

Paper in question is here btw, page 4, section 4.1 has the notation I'm talking about.


texts: I'm trying to make another object move, besides from the character

texts:
I want to create a small build of a TRPG, simaler to the Fire Emblem games. What I want to do is that I want to have the cursor be able to move a 'character' to a certain location. Any help?
(I'm doing this in Game Maker)


texts: I'm just curious when and what games are legal to mod and what are the processes I must follow to keep the mod project from becoming illegal. To be specific i'm trying to do a side project while in college. The idea is to make a completely modded version of Pokemon red/blue. The main idea of the project is to see how faithfully we can recreate the game in a modern language (like java, C++, or C#) since the games were originally written in Assembly(I think). It would have the same battle system but updated graphics and potential bugs worked out.


texts: Turn-based multiplayer animate moves from last turn

texts:
I'm trying to make a 2-player turn-based strategy game, using the Google Play Games APIs

According to the documentation,

  As a match progresses, the current player can modify and store the game data on Google's servers. The other participants can then retrieve and update this data on their turn.

What this seems to be saying (sorry if I'm completely misinterpreting this; I've never played with the Play Games APIs before) is that, since each turn is just updating the game state data on the server, a round could look something like this:

Unit A is on Square 1, Unit B is on Square 3
[P1's turn] Player 1 moves Unit A to Square 2
[P1's turn] Player 1 kills Unit B with Unit A
[P2's turn] When Player 2 looks at the game, it shows Unit A on Square 2, and no Unit B

What I want is for both players to see the animation when Unit A moves, rather than Player 2 just seeing the new state and not the transition:

Unit A is on Square 1, Unit B is on Square 3
[P1's turn] Player 1 moves Unit A to Square 2
[P1's turn] Player 1 kills Unit B with Unit A
[P2's turn] When Player 2 looks at the game, it shows Unit A on Square 1 and Unit B on Square 3, then animates Unit A moving to Square 2 and killing Unit B

So basically each player gets a replay of the action from their opponent's turn before taking their turn.

I know it could be possible to do something like this by looking at the differences in position of a unit between turns, then animating the change; this, however, breaks down when you have something like an attack, where all you know is a unit was destroyed and wouldn't necessarily be able to infer which unit attacked and should be animated.

How would I go about implementing something like this?


texts: How should I do 3D games through Java on a mac?

texts:
I have been self-teaching myself Java on the mac mostly because the language is cross-platform. Recently, I have been only able to develop 2D games using the Graphics2D class.
Now, I want to learn how to make 3D games in Java. I used to model and animate stuff in 3D, so my knowledge of 3-Dimensional stuff is okay.

I have spent the last 3 hours using google to look up ways of making 3D games in java. Apparently the best one to use is OpenGL, so i looked up a tutorial on it and i cannot find a tutorial that shows how to (if there is a way) install JOGL on the Mac platform.

Should i continue to use Java?

How can i make 3D games using Java?

What is the best way to make 3D games on a mac?


texts: Best practices for communication between game designer and artist

texts:
I'm having big troubles to sharing ideas and communicating my ideas to artists. They're friends who don't get a dime helping me so I don't want to waste their time trying to figure out what I have in mind. And my crappy sketches don't seem to be enough.

How do you communicate with the artist to create the assets? What kind of templates are commonly used? I'm looking for best practices and templates to define characters, assets, backgrounds.


texts:
Ok guys I have had some pretty good success on this site but I feel that this is a pretty complex question.

I am trying to do tile based deferred lighting using DirectX 11 and the compute shader.  Basically I am splitting up the screen into tiles and figuring out which lights hit the pixels in that tile.  Then once I get to the pixel shader I only calculate the lighting for the current pixel based on what lights hit that pixel.  (I'm pretty sure that I can find the lights that hit the pixel and the lighting calculations for that pixel solely in the compute shader but for now I am not doing that).  So currently I think there is two ways that I can get the information to the compute shader. The tile data needs to come in a RWStructuredBuffer so that I can write to it and then use it during other parts of the GPU pipeline in a ShaderResourceView.  The thing that I am not sure how to do is what is the best way to get all of the light data to the compute shader?  I think I could do it in a constant buffer or a groupshared buffer.  I believe the latter of the two is faster but I am not sure how it works and I cannot find much information on it.  And if I was to use a constant buffer I would need to house an array of lights in that buffer and I am not sure how I would do that either because I do not want to hard code an array size in the shader.

Here is some code samples to show you what I am doing.

struct ComputeIn
{
    uint3 DTid  : SV_DispatchThreadID;
    int index   : SV_GroupIndex;
};

struct TileData
{
    float4 position;
    float3 normal;
    float2 texCoord;
    vector<float, 8> something;
};

struct PointLightData
{
    float4 color;
    float3 pos;
    float radius;
};

//If I use a cbuffer for the light data
cbuffer LightData
{
    //How do I make an array of lights in a cbuffer
    Array of lights here!
};

RWStructuredBuffer<TileData> tileData : register(u0);

//If I use a groupshared
groupshared PointLightData pointLights : register(u1);

[numthreads(1, 1, 1)]
void CS( ComputeIn input )
{
    //How do I iterate through the groupshared buffer?
    //groupshared[?];
    //

}

One more thing.  I may be incorrect in assuming this but I assume that memory on the GPU is similar to memory outside of the GPU.  If I have a buffer that is passes to the GPU and I know how my data is lined up inside of this buffer, I should be able to traverse through this memory to get to what data I need.  My question is how do you traverse memory on the GPU.  If I have a this.

struct PointLightData
{
    float4 color;
    float3 pos;
    float radius;
};

StructuredBuffer<PointLightData> pointLights : register(u0);

[numthreads(1, 1, 1)]
void CS( ComputeIn input )
{
    //FIGURE OUT WHAT LIGHTS HIT THIS TILE!

}

I assume that pointLights is a "pointer" to the beginning of this memory.  How would I go about traversing all of the memory inside of this buffer?  Suppose I know the total size of the memory and will not go out of bounds?

If anyone can shed some light on any of these topics I would greatly appreciate it!

Thanks!


texts:
So I have coded simple tetris games on the past but I have never done one where the pieces drop smoothly, like for instance Super Tetris 3 on the SNES.I am planning to learn SDL and for such I want to code a Tetris on it.

My questions are two, as follow :

Can you give me some hints as to how to code this?
How hard is to code this compared to make the pieces fall in the easy way?


texts: Unable to remove class information in serialized json file using libgdx

texts:
I am encountering a problem in serializing an array of objects to json file. Please let me know where I'm making the mistake.

Object to be serialized :

package components;

public class UserGameInfo {
private int level;
private boolean isLocked;

public UserGameInfo() {

}

public UserGameInfo(final int level, final boolean isLocked) {
    this.level = level;
    this.isLocked = isLocked;
}
public int getLevel() {
    return level;
}
public void setLevel(int level) {
    this.level = level;
}
public boolean isLocked() {
    return isLocked;
}
public void setLocked(boolean isLocked) {
    this.isLocked = isLocked;
}
}

Object definitions:

  public class LevelsInfoFileReader {
  private Json fileJson;
  private Logger logger;
  private Array<LevelObjects> levelObjectsList;
  private Array<UserGameInfo> userGameObjectsList;
  ....
  }

Code for serializing the object :

    //write to the file
    try {
        FileHandle newFile = Gdx.files.local(userInfoFilePath);
        fileJson.toJson(userGameObjectsList, Array.class, UserGameInfo.class, newFile);
        System.out.println(fileJson.prettyPrint(userGameObjectsList));
    } catch (final Exception e) {
        logger.error("Could not save user data to the filepath", e);
    }

1st approach :

File contents after serialization :
[{level:1},{level:2},{level:3,isLocked:true},{level:4,isLocked:true},{level:5,isLocked:true},{level:6,isLocked:true},{level:7,isLocked:true},{level:8,isLocked:true},{level:9,isLocked:true},{level:10,isLocked:true}]

The problem here is that, though no class information is displayed, the boolean variable is not shown for level1 and level2 in the serialized json file. However, I put a debug point and checked the array object before serialization. It does contain the list properly as shown int the attached snapshot
2nd approach
The second approach I tried was with pretty print. However, the class information of the array elements is also displayed in the .json file :

Following is the .json file content :

[
{
class: components.UserGameInfo
level: 1
}
{
class: components.UserGameInfo
level: 2
}
{
class: components.UserGameInfo
level: 3
isLocked: true
}
]

My final expected output is :

[
{
"level": 1,
isLocked : false
}
{
"level": 2.
isLocked : false
}
{
"level": 3,
isLocked: true
}
]


texts:
I am trying to port a demo I found on PositionBasedDynamics . It has a generic function which does the rendering and on their example works but they don't generate/bind any Vertex Array Object or Vertex Buffer Object even though they use Core OpenGL and shaders.

The function is this:

template<class PositionData>
void Visualization::drawTexturedMesh(const PositionData &pd, const IndexedFaceMesh &mesh, const unsigned int offset, const float * const color, GLuint text)
{
    // draw mesh
    const unsigned int *faces = mesh.getFaces().data();
    const unsigned int nFaces = mesh.numFaces();
    const Vector3r *vertexNormals = mesh.getVertexNormals().data();
    const Vector2r *uvs = mesh.getUVs().data();

    std::cout << nFaces << std::endl;

    glBindTexture(GL_TEXTURE_2D, text);

    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 3, GL_REAL, GL_FALSE, 0, &pd.getPosition(offset)[0]);
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, 2, GL_REAL, GL_FALSE, 0, &uvs[0][0]);
    glEnableVertexAttribArray(2);
    glVertexAttribPointer(2, 3, GL_REAL, GL_FALSE, 0, &vertexNormals[0][0]);

    glDrawElements(GL_TRIANGLES, (GLsizei)3 * mesh.numFaces(), GL_UNSIGNED_INT, mesh.getFaces().data());

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(2);

    glBindTexture(GL_TEXTURE_2D, 0);
}

I did the same thing and it render's a white screen . I used RenderDoc to check what's going on and it show's these: https://puu.sh/rM1wB/80620ade8d.png .

How can they get it to work while i can't?


texts: Is it better to connect signals in source code or with the IDE feature?

texts:
In Godot IDE, what are the advantages and the caveats of using the visual IDE to connect signals to listerners instead of doing this:
var state: bool

onready var countdown: Timer = $Countdown

func _ready() -> void:
    state = true
    countdown.connect("end", self, "_toggle")

func _toggle() -> void:
    state = not state


texts: Can you suggest ways to store and track lots of objects in a turn based strategy game?

texts:
I know just enough about programming to be dangerous, so please be gentle.  I've created and released few simple apps for android and do some powershell scripting at work, but that's about the extent of my programming experience.  I'll be using c# and XNA if that makes a difference.

If I need to keep track of ten thousand to several hundred thousand of the same object with a handful of variables each, what's a good way to handle that in a turn based strategy game?  The game will need to loop through each object on each turn to check a few things.


texts:
I have a around 100k points on the screen (that might update). 2D points.

The goal is to cluster them into groups, by a constant distance. Meaning, finding groups of points that the distance between them is less than this distance. Instead of drawing those points, a big point will be drawn there with a number on it.

The problem is the calculation time.
Tried many algorithms on CPU, but didn't get the performances i wished for.

I'm trying to find an algorithm to solve this problem in the GPU using WebGL-GLSL, when texture contains all my locations.

Can be single draw phase or multiple.. as long as i achieve better calculation time than i get with the CPU.


texts: What is the story of game programmers beside gaming history?

texts:
Nowadays, game programming is like a big business-ish, technological, academical, programming havoc. There are dozen of engines, free or not, don't-reinvent-the-wheel dos and don't, plenty of different platform, plenty of game genres, and a lot of languages.

The video game economy boomed around the 90's (I guess, with the NES etc), and just before that, I wonder how game programmers were doing their job, what languages they used, what was the equivalent of the current "dev kit", anyways what were those few guys technics and tools to achieve a working game on such tiny computer power ?

I read that the playstation had only 3MB memory total: besides CD-swapping, how could they achieve to build an executable to hold on 2mb or ram, for complex games like Metal Gear Solid or Vagrant Story ?

Since I'm young and I missed all that, I have some questions...

Were game makers only or most programmers ? Why do I think a game programmer who has played a lot, has a more important role that game designers, 3D artists, because they know how a game is really made ?
Since C was invented in the 70, did all programmers use it, or were they forced to use ASM to get the best optimisation ?
Is being a game programmer a safe job (I mean in the job market) ?
Since computers are so freaking fast today, how has the optimisation task changed ? Do we use computer/console power to their maximum, or do we waste it because we can't come up with complex enough gameplay ?


texts: How to change Gravity towards certain object in Unity?

texts: I have two spheres in Unity. One is 1000x in size other is 1x in size. So I want the smaller sphere to be attracted to bigger sphere. So how do I do it. I know that it can be down through gravity using rigid body. But how do I change gravity angle towards the big sphere?


texts: Let player upload text file in-game Unity

texts:
How would I create a button for the user to click and be able to upload a text file from his desktop let's say?

I'd like to know about both, computer and mobiles.


texts: Why is my model exported from Blender vanishing when using it in UE4 mobile?

texts:
My 3D models and animation vanishes when I preview it using the mobile view port. However they work just fine for the desktop viewport.

I usually model the characters using MakeHuman and import them into Blender. In Blender I animate them and then I import the model/animation into UE4. The problem is that my model/animation works when I preview it using the shader meant for desktop & consoles. When I preview my animation using the openGLES2 shader, my model vanishes. Anything I import form belnder vanishes when I view it in a mobile viewport. I cant figure out why this is so? Have any of you experienced this before ? Can you guys let me know how I can correct this issue?

Also, if I upload the models from MakeHuman into UE directly, I can upload the files properly in UE. But, when I try the workflow MakeHuman -> Blender -> UE with not much modifications to the models in Blender, the models are not visible in the openGLES2 shader. I am not sure why this is happening in Blender and why the models coming out if it is affected.

Any help would be appreciated.


texts:
I have a 2D map, for each element I apply this isometric projection to place my Sprite

 //Element e;
 float[] f= projection(e.getX(), e.getY() ,z);
         // x and y represent Sprite Coordonate (tile_width and height depend of my
         // camera size and the number of elements in x and in y
 float x =  f[0]*tile_width;
 float y =  f[1]*tile_height;

   public float[] projection(float x, float y, float z)
   {
     return new float[]{  (( x )-(y) ) , ((x/2) + (y/2) - z  )};
   }

the sprite for one element :

The result of my projection :

The problem is I need to add an offset of tile_height/2 to the y and tile_width/2 to the x to have something like this (in the red rectangle I drawed with paint what I want) :

Where did I make wrong?

(I found the projection method in How should I sort images in an isometric game so that they appear in the correct order? )

edit :  How I calculate my tile_height and tile_width :

    tile_height = (float) ((CAMERA_HEIGHT/(game.map.getHeight()/2)));
    tile_width =  (float) ((CAMERA_HEIGHT/(game.map.getWidth()/2)));


texts: Can I programmatically generate textures in java?

texts: Is it possible to programmatically generate textures in Java, textures that could then be used to cover in game objects?