texts: Passing a unique Uniform buffer with each model

texts:
I have been following "Vulkan Tuturial" on GitHub as a reference on how to get basic objects rendering. In their tutorial, they create the command buffers at the start of the application after they have created a objects vertex and index buffers, then define that they want to draw it. Then one per frame they submit the command. That part I'm fine with.

I have been attempting to make it so I can send draw commands during the rendering loop, rather than just define one object that should be rendered and call that command every frame, the reason is so I can send custom uniform buffers with each command, to draw them in different locations on the screen.

Unfortunately, when I try and pass a diffrent uniform buffer for each draw call, only the last uniform buffer is applied.

Render loop

while (engine.Running())
{
    engine.PreRender();

    engine.BindMesh(mesh);
    engine.UpdateUniformBuffer(0.0f);
    engine.Draw();
    engine.UpdateUniformBuffer(90.0f);
    engine.Draw();

    engine.PostRender();
}

UpdateUniformBuffer

void Engine::UpdateUniformBuffer(float rot)
{
    static auto startTime = std::chrono::high_resolution_clock::now();

    auto currentTime = std::chrono::high_resolution_clock::now();
    float time = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startTime).count() / 1000.0f;

    UniformBufferObject ubo = {};
    ubo.model = glm::rotate(glm::mat4(), rot, glm::vec3(0.0f, 0.0f, 1.0f));
    ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
    ubo.proj = glm::perspective(glm::radians(45.0f), window.swap_chain_extent.width / (float)window.swap_chain_extent.height, 0.1f, 10.0f);
    // Since GLM was made for OpenGL we need to flip the frame
    ubo.proj[1][1] *= -1;

    void* data;
    vkMapMemory(vulkan.device, vulkan.uniform_buffer.buffer_memory, 0, sizeof(ubo), 0, &data);
    memcpy(data, &ubo, sizeof(ubo));
    vkUnmapMemory(vulkan.device, vulkan.uniform_buffer.buffer_memory);
}

Draw function

vkCmdDrawIndexed(
        vulkan.command_buffers[i],
        static_cast<uint32_t>(indices.size()),
        1,
        0,
        0,
        0
    );


texts: Android : Some textures not loading after resuming twice

texts:
This is an odd one.  When I press home and then restart my game I reload all my textures (checking glIsTexture on the id's first).  If I do this once, all textures load as expected, but if I do it twice or more one of my textures doesn't load (the texture is white).

I have checked glGetError and there are no errors (assuming GLES10.glGetError() is the correct way to do this)

Do I need to do any tidying up when home is pressed?  I currently call myGlView.onPause() and myGlView.onResume() when the onPause/Resume activity events are triggered.  I was under the impression that's all that's needed.  Is there anything else (perhaps non-openGL) that needs to be cleaned up?  Perhaps I'm hitting a limit of some kind

I am also using the NDK for some physics and rendering functions if that is relevant, but all resources are loaded using java.


texts: How to figure out which tiles are within view, and where to draw them in the grid?

texts:
I know there are a few questions on here similar to mine, but none of them seem to fit my needs.

I'm using PyGame to implement a tile based game similar to Final Fantasy or Zelda from the early Nintendo and Super Nintendo generation consoles.

The issue I'm running into is that I can't figure out how make a general way to render and position the tiles within view of the player camera. Once the camera starts moving, finding how much of an image is present in the camera view is very difficult, and then positioning it correctly is more complicated.

Any suggestions on how I can figure out a general way to create the grid correctly?


texts: Not see through models without adjusting clipping panels

texts: I'm making a FPS game in Unity3d with a lot of weapons, but when I'm aiming I can see through the weapon. I know I can adjust the near clipping panel, but when I do that, my terrain starts flickering. Is there some solution?


texts: JBullet - Detecting when 2 objects collide?

texts:
How can I detect when 2 collision objects collide with JBullet? Currently, all body types are going to be of type RigidBody.
I have quite literally been trying to find the answer of this for over 2 months, and would highly appreciate it if someone could help me.

There is some random stuff about collision callback, but that never seems to work - Either there is missing classes, or the code just does not do what I want it to do (Or is something stupid like "check every singke collision object" to do this), and just other things that mean I have never got an answer to my question.

I need to know this to allow ships and a cannonballs to be able to collide and explode. The game is fully playable and has got collision detection manually implemented, however it takes up over 50% of my I7's CPU - Far too much.

Thank you if you can answer my question.

P.S. JBullet is being used on my server, not my client.


texts:
http://www.gfycat.com/FlawedLimpingGrizzlybear
http://www.gfycat.com/UnawareQuerulousHawk

Every texture and shader has the same problem. It seems like the problem has nothing to do with either.

Tried all the things my friends suggested I should, reimported everything, restarted my machine, nothing seems to work.


texts: Correct way to move player in cocos2d-x chipmunk platformer

texts:
I'm attempting to make a physics based 2d platformer in cocos2d-x using the built in chipmunk physics engine.  I've not used a physics engine before and I'm having some issues setting the correct values (mass, friction, etc...) for my physics bodies so that I can make the player move correctly.  The problem that I'm facing is that when I add any amount of friction to either the tilemap bodies or the player body, the player moves so slowly that it's almost not visible.

Right now I'm loading a TMXTileMap and creating a PhysicsBody for each tile and a PhysicsBody for the player.  Relevant code for player physics body material:

 auto physicsBody = PhysicsBody::createCircle(this->getContentSize().width, PhysicsMaterial(0.0f, 0.0f, 1.0f));

relevant code for tile map physics bodies:

auto physicsBody = PhysicsBody::createBox(tileSprite->getContentSize(), PhysicsMaterial(0.0f, 0.0f, 0.0f));
physicsBody->setDynamic(false);
physicsBody->setGravityEnable(false);

And here is how I'm trying to move the player:

void Player::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event) {
    log("Key with keycode %d pressed", keyCode);
    switch(keyCode){
        case EventKeyboard::KeyCode::KEY_LEFT_ARROW:
            _impulseX += -700.0f;
            break;
        case EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
            _impulseX += 700.0f;
            break;
    }
}

void Player::update(float dt) {
    this->getPhysicsBody()->applyImpulse(Vec2(_impulseX * dt, _impulseY * dt));
}

I currently have all of the PhysicsMaterial values set to 0.0f.  Without setting those to 0 I can't get the player to move, but when they are set at 0 the player appears as if he's moving on ice and there is no friction to slow it down.  Is there something wrong with the way I'm moving the player?  Or is there something wrong with my PhysicsMaterial?

note: I'm not currently using a fixed timestep but plan to in the future.  Could this be causing my problem?

edit:  I've read a few places that it's better to use surface velocity to move a character but I can't find any examples of doing that.  Is it possible using cocos2d-x?


texts: How to update the data in the source code to avoid cheats?

texts:
I developed a multiplayer fps game in C++ and many peoples appreciated it, and today someone has created cheats for my game and he is trying to spoil my hard work which I spend developing the game. I am not expert to create an anti cheat system but I know by updating or releasing the new patch can avoid those cheats for a little time and then after some time I will need to update it again.
I want to know the quick and easy way to update all the files. This is a headache to search manually for all classes and strings and values to update them.
Data I want to update to avoid speed hack, aimbot, wall hack and flying hack.


texts:
I'm applying sideways friction to my car from each wheel, but for some reason my car starts to accelerate forward instead of having forces acting sideways and stopping it.

This is the script:

    frictionForce = car.transform.TransformDirection(
        car.transform.right *
        sidewaysFriction *
        car.transform.InverseTransformDirection(car.velocity).z
    );

    car.AddForceAtPosition(springForce - frictionForce * sidewaysFriction, transform.position);

Thanks for any help.


texts: How can i make my soldier to patrol over the space stationin random?

texts:
I mean i want to bake all the places in the space station and make the soldier to move automatic around the spaceship to random places.

What i did so far is placing the soldier at a start point. Added a camera as child to the soldier. Added a nav mesh agent component to the soldier.

Attached a script to the soldier: It's not my script. I don't want the soldier for now to chase only to walk randomly around the space station.

I didn't change any of the setting on the Nav Mesh Agent component in the inspector and i didn't

Should i change anything in the nav mesh agent component and if so what ?

How do select or set what areas to bake so the character will know to walk to this areas or if i want to select all the areas ?

How do i tell the character when to turn right or left in case there is a wall ?
Could be also random to turn left or right. Depending if there is left and right ways or maybe there is also straight way so that's 3 possible ways to move to.

clicked the Bake button yet.

I didn't write yet the script.

using UnityEngine;
using System.Collections;

public class SoldiersPatrol : MonoBehaviour
{

}


texts: What are "view frustum", "focal length" and near plane distance?

texts:
I've been reading through "Mathematics for 3D game programming and Computer Graphics" lately. Specifically definition of the view frustum and how the APIs generally process it, author introduces the concept of a length e which he classifies as the focal length. And it makes absolutely no sense, isn't the whole notion of focal length incompatible with the pinhole camera concept (inf. small) which is at the heart of 3D APIs as Direct3D and OpenGL? I thought all I need is the aspect ratio, the distance from the near plane and the FoV which can be established from the distance from the near plane.

And then he simply drops it and speaks of near plane distance n, which I thought was the actual value of e. What gives? Isn't the distance from the near plane the same as the "focal length" since we're talking about a pinhole camera? How do they differentiate?


texts: Odd Android touch event problem (Nexus 10)

texts:
Overview

When testing my game I came across a bizarre problem with my touch controls.

Note this isn't related to multi-touch as I completely removed my ACTION_POINTER_UP and ACTION_POINTER_DOWN along with my ACTION_MOVE code.  So I'm simply working with ACTION_UP and ACTION_DOWN now and still get the problem.

The problem

I have a left and right button on the left of the screen and a jump button on the right.  Everything works as it should but if I touch a large area of my hand (the fleshy part at the base of the thumb for instance) onto the screen, then release it and then press one of my arrows, the sprite moves in that direction for a few seconds, and then ACTION_UP is mysteriously triggered.  The sprite stops and then if I release my finger and re-apply it to an arrow, the same thing happens.  This goes on and on and eventually (randomly??) stops and everything work OK again.

Test device & OS

Google Nexus 10 Tablet running Jellybean 4.2.2

Code

        //Action upon which to switch
        actionMask = event.getActionMasked();
        //Pointer Index of the currently touching pointer
        pointerIndex = event.getActionIndex();
        //Number of pointers (for multi-touch)
        pointerCount = event.getPointerCount();
        //ID of the pointer currently being processed (Multitouch)
        pointerID = event.getPointerId(pointerIndex);

        switch (actionMask){

        //Primary pointer down
        case MotionEvent.ACTION_DOWN: {

        //if pressing left button then set moving left
        if (isLeftPressed(event.getX(), event.getY())){
                    renderer.setSpriteLeft();
                }

        //if pressing right button then set moving right
        else if (isRightPressed(event.getX(), event.getY())){
                    renderer.setSpriteRight();
                }

        //if pressing jump button then set sprite jumping
        else if (isJumpPressed(event.getX(),event.getY())){
                    renderer.setSpriteState('j', true);
                }

        break;

        }//End of case

        //Primary pointer up
        case MotionEvent.ACTION_UP:{

        //When finger leaves the screen, stop sprite's horizontal movement
            renderer.setSpriteStopped();
            break;
        }


texts:
So after some google searching apparently I don't even know what this technique is specifically called:

I'm trying to figure out how to create an effect in unity that 'paints' a 2d asset on screen.

By paint, I mean animates brush strokes, eventually 'revealing' the final image. (Start with outlines, then colors)

What is the conventional name for a technique like this, and where would I get started going about creating this kind of effect?

I am not talking about a shader / filter that simply adds a 'painted' or 'hand drawn' effect to an image, but one that simulates actually 'painting' it.


texts:
I'm trying to create a simple space shooter game using typescript and i've got kind of stuck at checking the movement.The thing is that if i only press one
key it works fine but if i press 2 keys at the same time it won't check for collisions with margins.Do i have to check for every case if i press multiple buttons or there's another way to do it? Here's the code:

update(canvas) {
        if (Game.keysPressed[KeyBindings.LEFT]) {
            this.xVel = -1;
            if (this.x <= 20) {
                this.xVel = 0
            }
        } else if (Game.keysPressed[KeyBindings.RIGHT]) {
            this.xVel = 1;
            if (this.x + this.width >= canvas.width - 20) {
                this.xVel = 0;
            }
        } else if (Game.keysPressed[KeyBindings.UP]) {
            this.yVel = -1;
            if (this.y + this.height <= 500) {
                this.yVel = 0;
            }

        } else if (Game.keysPressed[KeyBindings.DOWN]) {
            this.yVel = 1;
            if (this.y + this.height >= 880) {
                this.yVel = 0;
            }
        }

        else {
            this.xVel = 0;
            this.yVel = 0;
        }

        this.x += this.xVel * this.speed;
        this.y += this.yVel * this.speed;

    }

Thanks for helping!


texts: Nullpointerexception when loading resources in openGL ES 2.0 Android project

texts:
Overview

My splash screen starts by display a 'loading' dialogue and then kicks off an asyncTask (The loading dialogue is derived from the standard Android View class)

Within the doInBackground method of the asyncTask, all of my quads / sprite objects are created and other values set etc.

When the code gets to onSurfaceCreated, it loads all of the textures and runs the game.

The texture loading happens in onSurfaceCreated because it has to be done on the GL Thread.

Now, on a nice fast tablet, it all works great and it's all very stable.  However, when I run it on an old handset, it (intermittently) crashes all over the place with nullpointerexceptions.

Reason

What's happening is on the slower device, the asyncTask is running and (due to the asynchronous nature of it), continues to run in the background while the main code moves on to the onSurfaceCreate method of the GLRenderer, there it attempts to apply textures to objects that don't yet exist because the asyncTask is still doing it's business.

How best to proceed?

What are some methods I can implement that would allow me to guarantee that the async has done it's stuff before attempting to affect any of the objects that it creates?

Is there a way to 'halt' the GLThread until the asyncTask has finished?  I've been told in the past to use a separate thread or an async for loading resources, but I'm confused as to how to handle it correctly and keep everything sync'd between it and the GL thread (if "sync'd" is the correct term in this context).

Any help would be appreciated.

Code example

Showing onCreate and doInBackground from Activity Class

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        //Request full screen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        super.onCreate(savedInstanceState);

        //Create a displayMetrics object to get pixel width and height
        metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        width = metrics.widthPixels;
        height = metrics.heightPixels;

        //Create splash-screen object and pass in scaled width and height
        splash = new SplashScreen(MainActivity.this, width, height);

        //Create dialog that will show splash-screen
        loading_dialog = new Dialog(MainActivity.this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);

        //Create and set View
        myView = new MyGLSurfaceView(MainActivity.this);

        //Create a copy of the Bundle
        if (savedInstanceState != null){
            newBundle = new Bundle(savedInstanceState);
        }

        //Create splash object

        goSplash = new DisplaySplash(newBundle);
        goSplash.execute(); //Start asyncTask

        setContentView(layout);

    }

And....

    @Override
    protected Void doInBackground(Void... params) {
        createObjects();
        initialise();
        return null;
    }

Showing onSurfaceCreated from GLRenderer Class

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

    //Eek! Running before AsyncTask has finished on slower devices! :(
    res.loadResources();
    res.setTextures();
    res.RecycleBitmaps();

}


texts:
I am trying to make an object child of a Group, but this object has a draw method that calls opengl to draw in the screen.

Its class its this

public class OpenGLSquare extends Actor
{

      private static final ImmediateModeRenderer renderer = new ImmediateModeRenderer10();

     private static Matrix4 matrix = null;
     private static Vector2 temp = new Vector2();

public static void setMatrix4(Matrix4 mat)
{
    matrix = mat;
}

    @Override
public void draw(SpriteBatch batch, float arg1)
{
    // TODO Auto-generated method stub
    renderer.begin(matrix, GL10.GL_TRIANGLES);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x0, y0, 0f);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x0, y1, 0f);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x1, y1, 0f);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x1, y1, 0f);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x1, y0, 0f);

    renderer.color(color.r, color.g, color.b, color.a);
    renderer.vertex(x0, y0, 0f);

    renderer.end();

}
}

In my screen class I have this, i call it in the constructor

MyGroupClass spriteLab = new MyGroupClass(spriteSheetLab);

                OpenGLSquare square = new OpenGLSquare();
                square.setX0(100);
                square.setY0(200);
                square.setX1(400);
                square.setY1(280);
                square.color.set(Color.BLUE);
                square.setSize();
                //spriteLab.addActorAt(0, clock);
                spriteLab.addActor(square);
                stage.addActor(spriteLab);

And the render in the screen I have

@Override
public void render(float arg0)
{
    this.gl.glClear(GL10.GL_COLOR_BUFFER_BIT |GL10.GL_DEPTH_BUFFER_BIT);
    stage.draw();
    stage.act(Gdx.graphics.getDeltaTime());
}

The problem its that when i use opengl with parent, it resets all the other chldren to position 0,0 and the opengl renderer paints the square in the exact position of the screen and not relative to the parent.

I tried using batch.enableBlending() and batch.disableBlending() that fixes the position problem of the other children, but not the relative position of the opengl drawing and it also puts alpha to the glDrawing.

What am i doing wrong?:/


texts: In Unity, on an Android device, CaptureScreenshot writing to Phone, but persistentdatapath linking to the external card

texts:
I'm using CaptureScreentshot() to get an image. But when I try to access it on an Android device it's giving me:
Could not find file "/storage/emulated/0/Android/data/appname/screenshot.png"

When I go the external storage, it's not there, but rather on the phone storage. So why is persistentdatapath accessing something different?

My code is the following:
byte[] Bytes_File = System.IO.File.ReadAllBytes(currentScreenshotPathname); with thepathname obtained using:
currentScreenshotPathname = System.IO.Path.Combine(Application.persistentDataPath, currentScreenshotName);

Is there anyway to make the persistenDataPath go to the phone storage rather than emulated to read the file? I've tried changing the WriteAccess perimission to Externalas well as Internal in the player settings, but it's still the same.

Edit: Here's what's happening:
PersistentDataPath is /storage/emulated/0/Android/data/myapp/files/, but the screenshot is being saved to /mnt/sdcard/Android/data/myapp/files, despite the documentation saying that it should save to the PersistentDataPath.


texts: Moving script not working after SetActive/Pause change

texts:
I have a pause menu for my game which instantiates a texture and sets a text frame to active and slides both objects onto the screen using the code below:

Instantiating the menu texture and activating the text frame:

public void MenuPressed ()
{
    Vector3 newPosition = new Vector3 (-13, -0.06f, -2);
    Quaternion newRotation = Quaternion.Euler (0, 0, 0);
    Instantiate (menu, newPosition, newRotation);

    menuButton.SetActive (false);

    textFrame.SetActive (true);

    Time.timeScale = 0;
}

Moving the menu items:

float xLimit = -5;
float speed = 0.6f;

void Start ()
{
    StartCoroutine ("MoveMenu");
}

IEnumerator MoveMenu ()
{
    while (true)
    {
        transform.position += Vector3.right * speed;
        if (gameObject.name == "Main Text Frame")
            xLimit = -7;
        if (transform.position.x > xLimit)
            yield break;
        yield return new WaitForEndOfFrame ();
    }
}

Now this all works fine, but the issue that I have is on a multiple pause situation. When the pause button is pressed and spawns the menu and activates the text, the game pauses as expected. One of the options on the menu is to resume playing, when the pressed the game carries on as expected.

The problem I am having is that if the pause button is pressed again, the menu texture spawns in and slides on screen as intended, but the frame for the text does not. The frame gets set active but does not actually move.

Any ideas for how to fix this?

P.S

Here is the code I use to resume the game after it had been paused

public void Button1Pressed ()
{
    Time.timeScale = 1;
    GameObject menu = GameObject.FindWithTag ("Menu");
    Destroy (menu);
    gameController.paused = false;
    textFrame.SetActive (false);
    menuButton.SetActive (true);
    textFrame.transform.position = new Vector3 (-15.2f, -4.0f, -2.5f);
}


texts: Why do my Box2D bodies not fall, even though world.step is called?

texts:
I have SFML set up with a Box2D world that has gravity, but my bodies won't
move.  I std::cout'ed the position of the body in the game loop, but it's always at (0, 14)!

No errors or warnings, just no movement when there's supposed to be.

I'm quite new to Box2D, so I'm unsure if I'm doing this correctly. What mistake am I making?

main.cpp:

#include <SFML\Graphics.hpp>
#include <Box2D\Box2D.h>
#include <iostream>
#include <vector>

#include "Box.h"

sf::RenderWindow window;

int main(int argc, char* argv[])
{
    // Initialize stuff here since the things here will only run on startup
    b2Vec2 gravity(0, 9.8f);
    b2World world = b2World(gravity, true);

    // Initialize entities
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0.0f, -10.0f);
    b2Body* groundBody = world.CreateBody(&groundBodyDef);

    b2PolygonShape groundBox;
    groundBox.SetAsBox(50.0f, 10.0f);
    groundBody->CreateFixture(&groundBox, 0.0f);

    Box box;
    box.init(&world, sf::Vector2f(0.0f, 14.0f), sf::Vector2f(15.0f, 15.0f), sf::Color::White);

    sf::RenderWindow window(sf::VideoMode(1200, 840), "Title");

    while (window.isOpen())
    {

        sf::Event e;
        while (window.pollEvent(e))
        {

            if (e.type == sf::Event::Closed)
                window.close();

        }

        // Drawing

        world.Step(1 / 60, 8, 3);

        window.clear();

        box.getSfShape().setPosition(sf::Vector2f(box.getBody()->GetPosition().x / 30.0f, box.getBody()->GetPosition().y / 30.0f));
        box.getSfShape().setRotation(box.getBody()->GetAngle());

        window.draw(box.getSfShape());

        //std::cout << "X : " << box.getSfShape().getPosition().x << " Y : " << box.getSfShape().getPosition().y << std::endl;
        std::cout << "X : " << box.getBody()->GetPosition().x << " Y : " << box.getBody()->GetPosition().y << std::endl;

        window.display();

    }

}

Box.h:

#pragma once

#include <Box2D\Box2D.h>
#include <SFML\Graphics.hpp>

class Box
{

public:
    Box();
    ~Box();

    void init(b2World* world, sf::Vector2f position, sf::Vector2f dimensions, sf::Color color);

    b2Body* getBody() { return body; }
    b2Fixture* getFixture() { return fixture; }

    sf::RectangleShape getSfShape() { return sfmlShape; }

private:
    b2Body* body = nullptr;
    b2Fixture* fixture = nullptr;

    sf::RectangleShape sfmlShape;

};

Box.cpp:

#include "Box.h"

Box::Box()
{

}

Box::~Box()
{

}

void Box::init(b2World * world, sf::Vector2f position, sf::Vector2f dimensions, sf::Color color)
{
    // Creates a body definition
    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set(position.x, position.y);

    // Create the body into the world
    body = world->CreateBody(&bodyDef);

    // Create the box for the body
    b2PolygonShape boxShape;
    boxShape.SetAsBox(dimensions.x / 2.0f, dimensions.y / 2.0f);

    // Create a fixture for the body
    b2FixtureDef fixtureDef;
    fixtureDef.shape = &boxShape;
    fixtureDef.density = 1.0f;
    fixtureDef.friction = 0.3f;
    fixture = body->CreateFixture(&fixtureDef);

    sfmlShape.setFillColor(color);
    sfmlShape.setPosition(body->GetPosition().x / 30.0f, body->GetPosition().y / 30.0f);
    sfmlShape.setRotation(body->GetAngle());
}


texts:
I'm trying to implement rewarded video ads in my game using both unity ads and admob. For admob, once the ad is ready, the watch ad button's interactibality is set to true.This works properly for admob but I'm unable to implement the same in unity ads. Here is the admob code:
public class GoogleAdmobScript : MonoBehaviour
 {
   string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
   private RewardedAd rewardedAd;
   public Button watchAdBtn;

void Start()
{
    MobileAds.Initialize(initStatus => { });
    RequestRewardBasedVideo();
}

void Update()
{
    if (rewardedAd.IsLoaded())
    {
        watchAdBtn.interactable = true;
    }
}

This is what I have in the UnityAds script:
public class UnityAdsManager : MonoBehaviour, IUnityAdsListener
{
  string Unity_ID = "123456";
  bool test_mode = true;
  string myPlacementId = "rewardedVideo";
  public Button unityAdBtn;

void Start()
{
   Advertisement.AddListener(this);
   Advertisement.Initialize(Unity_ID, test_mode);
}

void Update()
{
    if (Advertisement.IsReady(myPlacementId))
    {
        unityAdBtn.interactable = true;
    }
}

The unity ad button is always greyed out. Not sure what's going wrong. Can someone please help?


texts: How to reduce lag when rendering 40,000 sprites in Unity?

texts:
I am attempting to render 40,000 sprites: a grid of 200x200 with each grid node having a sprite renderer. All the way zoomed out I get about ~20 frames per second.

What would be the best way to optimize this? Eventually I want to have an even larger grid. The grid has to be changeable — I need to be able to change the ground/floor for that specific grid node.


texts: I'm developing game in marmalade sdk in c++. I have player in the area.and I wanna make him jump when i pressed a button.When I use this player.moveUp(5px); it just go up 5px, but he has to fall down back. so that when i use these: player.moveUp(5px); and player.movedown(5px); it do nothing.Because the fps is 30 and it's performing so fast. how i can fix that?


texts: How can I prevent other applications from interrupting my game's exclusive fullscreen mode?

texts:
I am developing a game using D3D 11.

When I  got a pop-up message from a chat client (HipChat), my game's full screen mode is disabled because IDXGISwapChain::Present returns DXGI_STATUS_OCCLUDED. How can I avoid or prevent this? I don't want my game's exclusive full-screen access interrupted.


texts: How to model an Attack( ) action? How to model combat? In general, how objects communicate?

texts:
I never understood how would you elegantly describe two people talking in OO. I think this question extends to how similar objects communicate in general. I am designing a game now and Units have to attack each other.

My first idea was something along the lines:

public class Unit {
   public void attack(Unit targetUnit) {
      //calculates damage base on this unit stats
      targetUnit.takeDamage(damage);
  }

  public void takeDamage(int damage) {
    this.health = health - damage;
  }

}

And then later:

Unit whiteKnight = new Unit();
Unit blackKnight = new Unit();

//a possible combat interaction
whiteKnight.attack(blackKnight);
blackKnight.attack(whiteKnight);

Is this acceptable? Is this the standard?


texts: Cocos framework gives large Android builds than cocos2d-x

texts:
This question is regarding Project Architecture and workflow. I have an installation of cocos2d-x and Cocos Studio with Cocos Framework ( version 3.6). I carried out different build tests with hello world ( only 1 sprite in a scene) as follows:

Cocos Framework Android Build [ release ] : 9.2 mb
Cocos2d-x Android Build [ release ] : 2.06 mb
cocos Framework Game Source Directory : 379 MB
Cocosd2d-x Game Source Directory : 600+ Mb

After a debug version of windows build

Cocosd2d-x Game Source Directory : 4+ GB

I want to work with the cocos2d-x native workflow but its huge source is actually a problem for Github  / bitbucket hostings and/or project migrations.
So the questions are:

Why is there a huge difference in the android builds by using pre-compiled header?
How can I have Lowest Android builds with precompiled headers (cocos Studio / Framework )?


texts: How to Access MouseLook In Unity 5 with JavaScript

texts:
I'm following a tutorial to make a horror game. In the 8th tutorial I got stuck with the Mouselook option, he is using an other version of unity and I'm using Unity 5.

In Unity 4, MouseLook was a script attached to FPController, but in Unity 5, MouseLook has changed to become a part of FPController Script (in C#) as an object.

Now I need to access that, how to do that?

The file I am using is here: http://ryandome.weebly.com/ (named pausemenu.js)

And the error is in line 238 where it's unable to get the FPS controller's Mouselook option:

firstPersonControllerCamera = gameObject.Find("First Person Controller").Find("FirstPersonController");
print(firstPersonControllerCamera);
mainCamera = gameObject.FindWithTag("MainCamera").GetComponent("MouseLook");
firstPersonControllerCamera.enabled = false;
mainCamera.enabled = false;


texts: I'd like to pay an artist to create art assets for my game.  Is it common for the client (myself in this case) to exclusively own all the artwork that I pay the artist to create and deliver?  How can I make sure of this?


texts: Deploying MonoGame without OpenAL or Installer

texts:
I just shipped my first working MonoGame in-development game to one of my friends. He got some OpenAL DLL crashes, until he installed OpenAL.

Is there a way to include the OpenAL dependencies somehow with my game? I noticed Visual Studio already copies MonoGame, OpenTK, Tao.SDL, etc. to the bin directory.

Edit: XNA/MonoGame/VisualStudio already creates all the required DLLs, content, etc. in bin; it's only OpenAL that doesn't appear (there's no DLL). What's the best way to handle this without creating an installer?


texts: What should be contained in a game scene graph?

texts:
Would you help me to clarify, please, what what exactly should be contained within a game scene graph? See the following list, please:

Game Actors? (obviously yes, all the objects changing state should be the major prart of the Scene Graph)
Simple static game ojbects? (I mean ojects places in the background that do not get animated, neither do they collide)
Game Triggers?
Game Lights?
Game Cameras?
Weapon Bullets?
Game Explosions and Special Effects?

The above considered object types. Now to the coverage of the scene graph:

Should a scene graph contain the whole game level map since the level start, or should it contain only the visible portion of the map? If the second is true, it would mean that scene graph would be continuously updated, by adding/removing game objects, as the player moves. However, containing only the visible are of the map obviously would be much faster to traverse and update.


texts: How to render specific FBO Texture attachment (assume attachment1) with 2 attached

texts:
Create FBO & its textures like normal.

// FBO & Texture
glGenFramebuffers(1, &mFbo);
glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
glGenTextures(2, mTexture);

for(int i=0; i<2; i++)
{
    // Init texture
    glBindTexture(GL_TEXTURE_2D, mTexture[i]);
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, SCREEN_W, SCREEN_H, \
        0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glBindTexture( GL_TEXTURE_2D, 0 );

    // attach to FBO
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_TEXTURE_2D, \
        mTexture[i], 0);
}
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glUseProgram(0);

Bind FBO and render it inside draw loop.

// Preparing FBO texture.
glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GLuint at0[1] =  {GL_COLOR_ATTACHMENT0};
GLuint at1[1] = {GL_COLOR_ATTACHMENT0+1};

glDrawBuffers(1, at0);
// Filled texture attachment0 less white (transparency = 0.5f)
GUtils::VideoDriver::GetInstance()->DrawFillRect(glm::vec2(0,0), \
        SCREEN_W, SCREEN_H, glm::vec4(glm::vec3(1.0f/(1)), 0.5f));

glDrawBuffers(1, at1);
// Filled texture attachment0+1 white.
GUtils::VideoDriver::GetInstance()->DrawFillRect(glm::vec2(0,0), \
        SCREEN_W, SCREEN_H, glm::vec4(glm::vec3(1.0f/(1)), 1.0f));

glBindFramebuffer(GL_FRAMEBUFFER, 0);

After all things I did above:

texture attachment0 (mTexture[0]) will be filled in less white.
texture attachment1 (mTexture[1]) will be filled in white.

Right?

I cannot understand when render FBO texture:

glBindTexture(GL_TEXTURE_2D, mTexture[index]);
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0 );
glBindTexture(GL_TEXTURE_2D, 0);

mTexture[0] , screen = white. (It must be less White)
mTexture[1] , screen = black. (It must be White)

Firstly, Did i do a right way to render attached FBO texture or am I misunderstood fbo attachment?

Lastly, How can I fix this?


texts:
I was wondering about texture optimization in XNA 4.0.

Will the the contentmanager send the texturedata to the GPU directly when the texture gets loaded or do I send the texture data to the GPU when I declare a texture in my shader.

If that's the case, what happens if I have 5 shaders all using the same texture, does that mean that I send 5 instances of that texture data to the gpu or am I simply telling the GPU what preloaded texture to use?

Or does XNA do the heavy lifting in the background?


texts: Can't open scripts in Unity 2019.2.11.f1 version

texts:
I'm using Visual Studio 2017, Unity Hub to 2.1.3 and just created a project using Unity's 2019.2.11.f1 version.

Once trying to open a script in Unity, it doesn't open and then I'm forced to use Task Manager to End Unity's task because can't even close it normally due to not being able to interact with the screen. No errors or warnings, VS doesn't open, can't interact with Unity anymore.

This doesn't block me from working, it just isn't as convenient as before.


texts: computationally Intensive routine, ThreadPool or new Thread?

texts:
I had to write a computationally expensive routine that runs in 20-30ms. This routine cannot run in the main thread since it would kill the frame rate. The routine runs on demand, when some data change.

I wonder what would be better to use in this scenario. While I think ThreadPool will be all right, I wonder what would happen on an extreme scenario where just one core is available. Would it be better than to create a new thread every time and set the priority to below normal? I wonder though if, in this case, I would end up with the routine struggling to complete within a decent time (although waiting 1-2 seconds would be all right)

My guess is that the ThreadPool is always better in a multi-core scenario, however I wonder if in a single core scenario, creating a thread with lower priority could be a better solution (since I don't care if the computation last longer than excepted).


texts: Are dice-rolls for damage calculation bad design for a tactic focused game?

texts:
I'm trying to come up with a combat system for a turn-based RPG that is inspired by pen & paper RPGs, but with more importance on positioning and strategy.

I feel like in games where a good strategy is important, a dice roll for damage calculation like in Dungeons & Dragons, etc is really bad, because your best strategy can and (eventually) will be ruined by a bad roll or a very good roll of the enemy.

The two most obvious solutions to prevent the player from this frustration are to do a fixed damage calculation without dice or to reduce the impact of the dice rolls, but they both just don't feel right.

So is it considered bad design to do a dice-based calculation model or is there a better approach to combine those two key features?


texts: Monogame/SharpDX - Shader parameters missing

texts:
I am currently working on a simple game that I am building in Windows 8 using MonoGame (develop3d). I am using some shader code from a tutorial (made by Charles Humphrey) and having an issue populating a 'texture' parameter as it appears to be missing.

Edit I have also tried 'Texture2D' and using it with a register(t0), still no luck

I'm not well versed writing shaders, so this might be caused by a more obvious problem.

I have debugged through MonoGame's Content processor to see how this shader is being parsed, all the non 'texture' parameters are there and look to be loading correctly.

Edit This seems to go back to D3D compiler.

Shader code below:

#include "PPVertexShader.fxh"

float2 lightScreenPosition;

float4x4 matVP;

float2 halfPixel;

float SunSize;

texture flare;

sampler2D Scene: register(s0){
    AddressU = Clamp;
    AddressV = Clamp;
};

sampler Flare = sampler_state
{
    Texture = (flare);
    AddressU = CLAMP;
    AddressV = CLAMP;
};

float4 LightSourceMaskPS(float2 texCoord : TEXCOORD0 ) : COLOR0
{
    texCoord -= halfPixel;

    // Get the scene
    float4 col = 0;

    // Find the suns position in the world and map it to the screen space.
        float2 coord;

        float size = SunSize / 1;

        float2 center = lightScreenPosition;

        coord = .5 - (texCoord - center) / size * .5;
        col += (pow(tex2D(Flare,coord),2) * 1) * 2;

    return col * tex2D(Scene,texCoord);
}

technique LightSourceMask
{
    pass p0
    {
        VertexShader = compile vs_4_0 VertexShaderFunction();
        PixelShader = compile ps_4_0 LightSourceMaskPS();
    }
}

I've removed default values as they are currently not support in MonoGame and also changed ps and vs to v4 instead of 2. Could this be causing the issue?

As I debug through 'DXConstantBufferData' constructor (from within the MonoGameContentProcessing project) I find that the 'flare' parameter does not exist. All others seem to be getting created fine.

Any help would be appreciated.

Update 1
I have discovered that SharpDX D3D compiler is what seems to be ignoring this parameter (perhaps by design?). The ConstantBufferDescription.VariableCount seems to be not counting the texture variable.

Update 2
SharpDX function 'GetConstantBuffer(int index)' returns the parameters (minus textures) which is making is impossible to set values to these variables within the shader. Any one know if this is normal for DX11 / Shader Model 4.0? Or am I missing something else?


texts: how to ignore physics collision of some objects in box2d

texts:
I know this sounds silly but I would like some objects to follow physics while others not to collide each other.

I tried to achieve them by setting their position exclusively. But then it will ignore all physics.

Is what I am trying to do even possible?


texts:
so I'm starting with Unity , I followed the john lemon tutorial , and I wanted to apply what I learn on a model on my own coming from blender.
Everythings works , animation , rotation , but not translation . For some reasons my character doesn't move at all .
It might have to do something with root motion since I have apply root motion in grey with written just after "handled by script" . Not sure what to do ..
I found something about character in place,  I think I'm in this case but I'm not sure how to use it in my script ..
https://docs.unity3d.com/Manual/ScriptingRootMotion.html

If you ask I'll give you my project .

EDIT :

ok so I made some advances :

 void OnAnimatorMove()
{
        m_Rigidbody.MovePosition(m_Rigidbody.position + m_Movement * m_Animator.deltaPosition.magnitude * 10000);
        m_Rigidbody.MoveRotation(m_Rotation);
        Debug.Log("m_Animator.deltaPosition.magnitude: " + m_Animator.deltaPosition.magnitude);

}

m_Animator.deltaPosition.magnitude is actually always equal to 0 , explaining why my charachter doesn't translate but why is it always equal to zero ?


texts: My Unity game's timers are messed up when it's played in the browser, and the tab/page is out of focus?

texts:
I've made some timer classes, which just basically:

hold an elapsed time value,
and when they are updated, Time.deltaTime is added,
and their update is called in MonoBehaviours' Updates.

And an issue appeared:

On one machine with Firefox, streaming my game, the tab was out of focus for 30 seconds,

And the timers stopped after a while.
The time after which the timers stopped, always varied.

On one machine with Firefox, tabs out focus didn't do much thing, but browser out of focus did.

On every run, the effect was random, sometimes time stopped, sometimes slow, etc.

On my machine, both with Chrome and Firefox, both with swtching tabs and switching windows...

Time went at like 30% speed when out of focus, and when switched back, everything was normal again.

Why?


texts:
I'm creating my GUI controls in Unity 5.3 I have a joystick in which overlays a swipe pad.  Originally all of the controls were working fine.  However, now the touch pad is overlaying the Joystick.

In previous verisons you could focus the window

GUI.FocusWindow(0);

I've tried reassign the order by making one a child of the other and vise versa yet nothing works.

Does anyone know how to control the Z index of the controls, or make one overlay the other.  I've looked at the GUI depth documentation, but I don't see how I could apply that here.

Does anyone know how to control the depth of cross platform controls in unity?


texts: How can I ensure reasonably spaced out enemies

texts:
I have a simple javascript game and I'm initializing their positions on the y axis using random numbers. How can I ensure that they are reasonably spaced apart?
My simple algorithm is:

 y = (Math.random()*1000%600);

However I frequently get enemies almost directly on top of each other. This is a huge problem for the game, since it's a word game and the enemies have text on their center, that if overlapped makes them impossible to kill since you can't see the words. Any advice would be appreciated! I'm pretty new to making games in general so this has all been a learning experience for me!


texts: I have two textures 1 and 2, and a "mask" image 3. I'd like to interpolate between the two textures by using the mask image, and get something like 4. I'm not really sure where to start, as I never did "blending" like this before. Can I do this with the SpriteBatch class, or do I have to make my own shader for this effect?


texts:
I just created a tile map for my game, and its a side profile game. The game looks sort of like Terraria, where there is blocks you can place and break. I want the player to be able to collide with the blocks, and I don't know how to achieve something like this.

The game is in Javascript but I can understand other languages so feel free to give examples in the language of your choice.


texts:
I'm trying how to work out how to Rotate a Vertex using Quaternions, using a scientific calculator, or on paper. Exam preparation.

My lecturer has given us this;
Quaternion = (-0.5, 0, -0.7071067, 0.5)
Vertex = (23, 10, 18)

The way it's been explained to us is like this;

We have a vertex called p
We have a quaternion called q
We store p within a quaternions vector component, we'll call this K
K = (0, p)
Finally we do the normal quaternion multiplication
p' = qKq-1

I'm just trying to work out how I break this down so it's easier to understand so I am able to find out the result. I know how to do quaternion multiplication, but it seems confusing as I only have one w component in the quaternion, and only the x, y,z in the vector.


texts: How to apply a texture to an object by face rather than the entire object? (unreal 4)

texts: I am trying to apply different textures to a model I have by face rather than the entire object. I am only able to add one material to the entire object. How can I apply different textures to different faces of my model separately? I imported my model from blender. For reference, I have a detailed building with a roof, windows, etc. that is all one object and I would like to texture different parts of the building with different megascans separately. Would appreciate any advise.


texts:
I begin to learn graphic programming on directx12. I try to make a camera wich can move dans rotate around the world.

I take this code as a basis:
https://www.braynzarsoft.net/viewtutorial/q16390-transformations-and-world-view-projection-space-matrices

I try lot of method, but every time I finish on the same problem, my camera move and can rotate (on Y only for the moment). But when I move after the control still relative to my basis orientation than my new one.

I dunno if it come from how I handle movement (During waiting answer I will try to make my movement base on a target vector) Or how I multiply martix.

This is the actual point of my code. I use this source to not use LookAtLH():
https://www.3dgep.com/understanding-the-view-matrix/

void UpdateCamera() {

    XMVECTOR cUp = XMLoadFloat4(&cameraUp);

    if (GetAsyncKeyState('Z')) {

        cameraPosition.y += 0.001f;

    }
    else if (GetAsyncKeyState('S')) {
        cameraPosition.y -= 0.001f;
    }

    if (GetAsyncKeyState('Q')) {
        cameraPosition.x -= 0.001f;
    }
    else if (GetAsyncKeyState('D')) {
        cameraPosition.x += 0.001f;
    }
    if (GetAsyncKeyState('A')) {
        rotation += 0.0001f;

    }
    else if (GetAsyncKeyState('E')) {
        rotation -= 0.0001f;
    }

   if (GetAsyncKeyState('P')) {
        cameraPosition.z += 0.001f;

   }
    else if (GetAsyncKeyState('M')) {
        cameraPosition.z -= 0.001f;

    }
    XMMATRIX translationMat =     XMMatrixTranslationFromVector(XMLoadFloat4(&cameraPosition));
    /* XMMATRIX rotYMat = XMMatrixRotationAxis(cUp, rotation);*/

    float cosPitch = cos(0.0f);
    float sinPitch = sin(0.0f);
    float cosYaw = cos(rotation);
    float sinYaw = sin(rotation);

    XMFLOAT3 xaxis = { cosYaw, 0, -sinYaw };
    XMFLOAT3 yaxis = { sinYaw * sinPitch, cosPitch, cosYaw * sinPitch };
    XMFLOAT3 zaxis = { sinYaw * cosPitch, -sinPitch, cosPitch * cosYaw };

    XMVECTOR eye = XMLoadFloat4(&cameraPosition);

// Create a 4x4 view matrix from the right, up, forward and eye position vectors
    XMMATRIX viewMatrix = {
        xaxis.x,yaxis.x,zaxis.x,0.0f,
        xaxis.y,yaxis.y,zaxis.y,0.0f,
        xaxis.z,yaxis.z,zaxis.z,00.0f,
        -XMVectorGetX(XMVector3Dot(XMLoadFloat3(&xaxis), eye)), -XMVectorGetX(XMVector3Dot(XMLoadFloat3(&yaxis), eye)), -XMVectorGetX(XMVector3Dot(XMLoadFloat3(&zaxis), eye)), 1.0f
    };

    XMStoreFloat4x4(&cameraViewMat, viewMatrix);// XMMatrixInverse(nullptr, translationMat * rotXMat));

}

void Update()
{

    UpdateCamera();
     ///....

}


texts: What is some game development literature purely in javascript?

texts: I'm mainly interested in the videogames development in pure javascript, since nowadays there's so many books about htm5 and javascript I couldn't find any book about game development with javascript only.


texts:
I have tried to search around google, Bing, and Minecraft forums. I wand to ADD a NEW mob to the game.
------------ requirements for the answer -------

it has to be compatible for 1.16.4
it has to be how to add a new mob not change an existing
no spam
it cannot be a mod to add this to Minecraft
I want it to be in my resource pack
If I have to create a new pack, that is fine


texts:
I am currently following Unity's 2D Roguelike tutorial.

In that tutorial, I have Player, Enemy, and Wall Prefabs, which all belong to a Layer called BlockingLayer.

The Player and Enemy Prefabs both have a script inheriting from a script called MovingObject.

While writing the MovingObject class, I was meant to write the following line of code:

public LayerMask blockingLayer;

Later on, after creating the Player and Enemy scripts and attaching them to their respective Prefabs, I was supposed to set the blockingLayer to BlockingLayer from within the editor.

I thought this was stupid, because the Prefabs already belonged to the correct Layer, otherwise they couldn't interact with one another, so I changed the variable to private and instead added the following line to the Start() method:

blockingLayer = gameObject.layer;

However, suddenly collisions no longer worked. The Player and Enemy could now walk through each other as well as through Walls. Using the Visual Studio debugger, I noticed the following:

Setting the blockingLayer via the editor yielded following value: 256.
gameObject.layer has a value of 8.

Obviously, the two layers are completely different, which explains why my modification didn't work. Still, I believe that setting the Layer twice — once on the GameObject, and once on the script — is dumb.

How do I get the correct Layer programmatically?


texts: How do I generate a sphere mesh in Unity?

texts: I'm making a game and I need a way to generate a sphere mesh in Unity for whatever reason. It needs to be generated by code and not be a pre-made sphere or a sphere primitive as I need to edit in generation later on.


texts: Is there a definitive reference on Pinball playfield design?

texts: I'm looking at designing tables for Future Pinball but I'm not sure where to start as I've little background in game design per se. I've played scores of pinball tables over the years so I've a fairly good idea of what is "fun" in those terms. However, I'd like to know if there is a definitive "bible" of pinball design as far as layout and scoring/mode design goes. I've looked but there doesn't seem to be anything really coherent that I could find. Is it simply a lost art or am I missing some buried gem?


texts: Making Edges of Hand-Drawn Tileset Match Up

texts:
I'm making a tile-based platformer. A friend at college is doing all my art, and so far it's beautifully hand-drawn. The problem is, I can't seem to make the edges of the tilesets match up. He measures them meticulously to get sections to match up, but, due to variations in his art medium, tiles that aren't next to each other in his drawing don't match up. For example, he's drawn a basic 9-slice tileset, and the top-to-center, left-top-to-left-center, right-top-to-right-center, etc. all connect perfectly because they're touching each other in his drawing. But when I clip the tiles apart and put them together in other variations or try to put other "change-up" tiles together (any tile that wasn't touching in his drawing), the larger features fit together because of his measurements, but you can see an obvious seam where they join.

I've been using the heal tool in my graphic editor to fix the seams and re-export the tiles with edited edges to fit together correctly, and it works well, but when I heal the edges for one seam, it makes another seam appear.

Note: I don't want a solution to fix the seams at runtime using graphical filter magic or something on the code side. I'm looking for a solution to process the images and export them so that they fit together.

[EDIT:] Here's one of the tiles for reference. It tiles along the bottom of a block of stone.

And here's a 9-slice thumbnail of an early stage of the tileset:

[Edit again:] To be clear, it's not the big-ish things (stone sides, grass, etc.) connecting that's my problem. My artist already measures everything to make it match up. It's the variations in shading and impreciseness of the physical medium that's the problem.


texts: How to show a canvas text when i click an UI button on Android

texts:
I am trying to show a text when i click on a ui button but i don't know how to implement this. On PC platform I have a collider per object and when the player stay and click the E button, a canvas text appear on screen, but i don't know how to do this on Android. I want something like Resident Evil old style action button, opening doors and getting object description. How could i do this?

The Script

public class readingNote : MonoBehaviour {

    public AudioSource audio;
    public AudioClip collectSound;
    public  bool playerNextToKey = false;
    bool hasCollided = false;
    public GameObject pic;
    public GameObject text;
    public GameObject notePad;
    private Collider other;

//  void Start () {
//      pic.SetActive(false);
//      text.SetActive (false);
//
//  }

    public Button yourButton;

    void Start()
    {
        pic.SetActive(false);
        text.SetActive (false);
        Button btn = yourButton.GetComponent<Button>();
        btn.onClick.AddListener(TaskOnClick);
    }

    void TaskOnClick()
    {
      //can't text.SetActive(true); because when i get out the scene, text is showing up (I use the same button to open doors and get text description).
    }

    void OnTriggerStay ( Collider other) {

        if(other.gameObject.tag == "Player") {
            //if(Input.GetKeyDown(KeyCode.E)) {
                text.SetActive (true);
                pic.SetActive(true);

                AudioSource.PlayClipAtPoint(collectSound, transform.position);
            //}

        }
    }

    void  OnTriggerExit ( Collider other  )
    {
        if (other.gameObject.tag == "Player")
        {
            //enter = false;
            //print("close");
            playerNextToKey = false;
            hasCollided = false;
            pic.SetActive(false);
            text.SetActive (false);

        }
    }

}


texts: How do I make my iOS game free for users who 'like' it on Facebook?

texts:
I've seen a game for free on iOS when the user 'likes' a page. Though it appears the promotion was run by Apple, not the developers of the game being given away.

How can I make my game free for a Facebook 'like'?


texts:
To save texture bind there is the technique to use a sprite sheet which combines several sprites into one texture. Now if I have more sprites than which will fit into one sprite sheet (limited by GL_MAX_TEXTURE_SIZE), can I just use a texture array with multiple sprite sheets and still use only one texture bind?
Is the limiting factor for the amount of sprites the gpu memory?


texts: General pointers and advice in creating inventory structure?

texts:
I am working on text-based Diablo-like RPG, where each weapon and armor has unique stats and names and there is a lot of overlap. Ie I can generate Silver Sword with 40 damage, but I can also generate Silver sword with 20 damage. So those items can't obviously be stored as one value. I am thinking of storing the items in multidimensional array where one column would store weapon name and the other column would be used for storing the damage. Same for armor etc. But I feel this may get cumbersome and spiral out of control very quickly.

Is there any other data structure I could use and have more flexible and efficient solution?


texts: Is it possible to develop games using Google's App Inventor?

texts:
Google's App Inventor is a WYSIWYG application development environment for Android.
It allows you to control logic of your program using jigsaw type pieces.

Is it possible to develop games using
this technology?
Are there any obvious potential pitfalls?
What are the limitations of using this technology as compared to programmatic development for Android (such as using Java)?

A screenshot showing how behaviour can be controlled using the blocks editor:


texts: How to handle multiple clipping rectangles in a CanvasItem?

texts:
Let's say I have a CanvasItem that needs to draw the background first, occupying the entire item rect, and then draw all its content within a smaller rect leaving a margin.

How should this be done in the NOTIFICATION_DRAW within _notofication?

This is what I've tried:

void MyCustomItem::_notification(int p_what) {

    case NOTIFICATION_DRAW: {
        // Enable clipping
        VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);

        draw_background();

        // Clip to margins
        VisualServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), true, Rect2(
            Point2(
             MARGIN_LEFT,
             MARGIN_TOP
            ),
            Size2(
             width - MARGIN_LEFT - MARGIN_RIGHT,
             height - MARGIN_TOP - MARGIN_BOTTOM
            )
        ));

        draw_stuff();
    }

The problem with this is that it will clip everything to the margins including the background.


texts:
I'm struggling with getting the depth layer to work properly.  No matter what I do, the line is drawn over the top of the circle texture.

public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Begin(
            SpriteSortMode.BackToFront,
            BlendState.AlphaBlend,
            null,
            null,
            null,
            null,
            Camera.getTranslation());

        // Draw all planets
        foreach (PlanetNode p in planets)
        {
            p.Draw(spriteBatch);
        }

        spriteBatch.End();
    }

PlanetNode's Draw:

public void Draw(SpriteBatch spriteBatch)
{
    // Draw forwarding line
    if (resourceForward)
    {
        double dist = Math.Sqrt(Math.Pow(location.X - forwardTo.location.X, 2) +
                                Math.Pow(location.Y - forwardTo.location.Y, 2));
        float angle = Utility.GetAngle(location, forwardTo.location);
        spriteBatch.Draw(Textures.BlackPixel, new Rectangle((int)location.X, (int)location.Y, (int)dist, 1), null, Color.Black, angle, Vector2.Zero, SpriteEffects.None, 0.9f);
    }

    // Draw Planet
    if (mouseOver)
    {
        Color c = new Color(color.R + 0.2f, color.G + 0.2f, color.B + 0.2f);
        spriteBatch.Draw(Textures.Planet, position, null, c, 0f, texOrigin, SpriteEffects.None, 0.5f);
    }
    else
        spriteBatch.Draw(Textures.Planet, position, null, color, 0f, texOrigin, SpriteEffects.None, 0.5f);

    // Draw overlay text
    Vector2 size = Textures.TextFont.MeasureString(resources.ToString());
    spriteBatch.DrawString(Textures.TextFont, resources.ToString(), new Vector2(position.X - size.X / 2, position.Y - size.Y / 2), Color.Black);
}


texts: best way of rendering more 3D models in three.js that not slow down page?

texts:
I am in the way of creating a 3D web game using threeJS library. This is a multi-player game that players are 3D human models in game, and I need to add a human 3D model for each player that enters the game. Additionally, I want to animate the humans while they walking, but the problem, here is that adding a 3D model and animating that for each player will slow down the game or maybe cause the browser to crash.

question: what is the better way of showing and animating the player's models that will not slow down the game?


texts: Free Moddable 2d game with good community and tools

texts:
Disclaimer: I'm okay with making this a community wiki, as I see a lot of benefit in having a place to ask this question and get good answers from people who have experience.

I would like to mod a 2D game. Having never modded a 2D game before (unless you count Starcraft custom maps back in 199x), I am looking for a game/system that has:

A good community: this means I can ask questions if I get stuck and expect a (decent) answer in roughly a day.
Solid tools: I would ideally prefer clicking and creating content over diving into optimized C++ to make changes. The better the tools, the faster you move.
Scripting language: Ideally, access to some scripting language above and beyond the main tools is an ideal middle-ground between high-level puritan tools (SC level editor) and low-level coding.
Free: I'm looking for something I can try out free, or very cheap.

It also goes without mention that I want something current; I'm sure I can mod Super Mario Brothers, Link to the Past, etc. (SNES-era games) but that's pretty worthless to me.

And please don't say "Starcraft (1)" :)


texts: I tried to find tutorials about skeletal animation or books that talk about subject to implement it, but I couldn't find any tutorials except talking md5 animated files. I would like tutorials that talk about that subject.


texts: Visual Studio not adding the header file to the Solution explorer

texts: I'm having trouble with my Unreal Visual Studio 2019 project.  I created a new header file, and saved it in the same folder my other ones are in.  (I didn't add these, they were in the starter project of the video course I'm following.) For some reason, the file is not showing in the solution explorer, and IntelliSense isn't working in the particular file.  How do i fix this?  sorry if it's obvious, I'm not an expert at Visual Studio.


texts:
I have displayed an image at the center of the screen with libgdx. If I swipe left, the image should move to the left; and, if I swipe right, image should move to the right.

Subsequent swipes to the left should move the image left. The same should happen for right. I used GestureListener.

It works to some extent in the sense if I swipe left first image moves left. But after that if I try to swipe right the image still moves left.

So how do I implement the expected behavior?

class MyGestureListener implements GestureListener {
    @Override
    public boolean fling(float velocityX, float velocityY, int button) {
          if (velocityX>0)
              iX += 20;
          else
              iX -= 20;
          System.out.println("iX: "+iX);
          return true;
    }
}

// ...
Gdx.input.setInputProcessor(new GestureDetector(0.0f, 0.0f, 0.0f, 5f, new MyGestureListener()));

// ...
batch.draw(splashTexture, iX, iY);


texts:
I'm working on a 3D maze game using libGDX. I'm using MeshBuilder to render the walls. All walls are a single part made using a ModelBuilder in the create():

    ModelBuilder modelBuilder = new ModelBuilder();
    MeshPartBuilder meshBuilder;
    Vector3 corner00 = new Vector3(),
            corner10 = new Vector3(),
            corner11 = new Vector3(),
            corner01 = new Vector3(),
            normal = new Vector3();
    modelBuilder.begin();

    Texture wallTexture = new Texture("wall.PNG");
    wallTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
    wallTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    Material material = new Material(new Material(TextureAttribute.createDiffuse(wallTexture)));
    meshBuilder = modelBuilder.part("room1", GL20.GL_TRIANGLES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal |
                    VertexAttributes.Usage.TextureCoordinates, material);
    Array<Wall> walls = level.getWalls();
    for (Wall wall : walls) {
        Vertex v1 = wall.getV1();
        Vertex v2 = wall.getV2();
        meshBuilder.rect(corner00.set(v1.getX(), v1.getY(), 0), corner10.set(v2.getX(), v2.getY(), 0),
                corner11.set(v2.getX(), v2.getY(), 10), corner01.set(v1.getX(), v1.getY(), 10),
                normal.set(wall.getNormal(), 0));
    }
    Model worldModel = modelBuilder.end();
    instance = new ModelInstance(worldModel);

I do this in order to decrease the number of draw calls. But I came across a texture-mapping problem:

The wall texture is stretched. How can I make it repeat the texture instead of stretching?
Thanks


texts: Does 2D Platformer games still have popularity among gamers?

texts: I'm currently working on a 2D platformer game that i wanted to put out as my first game but seeing the popularity of other games made by Voodoo and others are quite distressing and made me ask myself this question and now you guys. will the 2D Platformer games that had the popularity will have any popularity for developers to take interest and make some living out of it in the for future projects or can they work on the more popular games like color bump 3d.


texts: Displaying 2 textures on the same surface?

texts:
I'm messing around with XNA in a very simple Minecraft-esque world I'm making and I'm wondering how I can do the "breaking the block" visuals in XNA.

If you're unfamiliar with the game, you begin interacting with the cube and based one what tool you're using, the block will take X amount of time to break. There's about 10 different stages of cracking that the cube will display before the cube breaks. I'm curious about how to display those 10 stages of cracking on top of the original skin of the block.

I know the game works using a Sprite sheet to color the blocks. This sprite sheet does not include every possible design at every possible stage of breaking the block, each stage is a different sprite with some transparency.

In short, how can I quickly and efficiently overlay a texture on a surface that already has a texture?

Do I have to combine them? If so, how?


texts: How to make Djikstra algorithm remember path?

texts: I understand how dijkstra algorithm works but I don't know how I should figure out path. How can I get nodes that are on the shortest path?


texts: How can I store in-game money so that nobody can manipulate the amount?

texts:
People get coins for completed tasks(for example completing a level) in my game. In addition, they can purchase coins(they need to pay for that with real money) in the app store. With these coins, people can purchase different items in the game.

Is it easy for somebody to manipulate the amount of coins when I store it as an integer variable in a text file on the device(iOS and Android phones and tablets)?

What is the best way in MonoGame/Xamarin to store the amount of coins so that nobody can manipulate it afterwards?


texts: How do I make a GameObject carry across only 2 specific scenes?

texts:
I have a GameObject in my main menu and help scenes that I want to carry across both scenes but be destroyed on all other scenes. I am having multiple issues with it such as it wont destroy on other scenes or when I go back to the previous scene it will generate 2 GameObjects and so on. Here is the script:

public class DestroyObject : MonoBehaviour
{
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        SceneManager.sceneLoaded += OnSceneLoaded;
    }

    void OnSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode)
    {
        if ((scene.name == "Help") || (scene.name == "Main Menu"))
        {
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }
}


texts: How can I create beautiful, random, abstract images?

texts: To generate random, beautiful, abstract images – which algorithms are not too complex and give good results?


texts: How to resize an image texture according to the size of a sprite in directx9 or slimdxDirect3d9?

texts: I want to know that is there any way of resizing our texture to the size of a sprite in slimdx direct3d9 or directx9. That is if my image size is 1024x768 and sprite size is 500x500, how can i resize the image in slimdx to display it fully on the sprite without any cropping.


texts: Screen management: How to switch between screens

texts: How can I switch between different screens that implement Screen?


texts:
To boil my question down to the simplest form, I fear I am oversimplifying how mat4 perspective works.  I am using

mat4.perspective(45, 2, 0.1, 1000.0)

(the binding is WebGL fwiw).  With a fovy of 45, and an aspect ratio of 2, I expect to have a fovx of 90.  Thus, if I position my camera at (0, 0, 50), looking towards the origin, I expect to see a cube positioned at (50, 0, 0) (45 degrees) right at the very periphery of my screen, half on, half off,.  Instead, a cube at (50, 0, 0) is totally off screen, and my actually periphery occurs at about (41.1, 0, 0).

What am I missing here?

Thanks,
nick


texts:
The following code is a snippet of how I'm auto-updating an object whenever a setting changes in the inspector window (for a scriptable object). It's currently not working, but It will work if I put the two lines Editor editor... and editor.OnIns... inside the using block. I'm confused on why this is.
    public void DrawSettingsEditor(Object settings, System.Action onSettingsUpdate)
    {
        Editor editor = CreateEditor(settings);
        editor.OnInspectorGUI();

        using (var check = new EditorGUI.ChangeCheckScope())
        {
            if (check.changed)
            {
                onSettingsUpdate();
            }
        }
    }

See https://pastebin.com/d0NumWZv for all the code for this class.


texts:
Engine: Unity

3D tool: Blender

Since the start of my game dev endeavour, I can't seem to decide on the type of animation system I want to use.

Can someone please give me reasons why you would NOT use root motion and maybe a real world example, because currently I see no reason to not use root motion.
I understand the loss of control when using root motion, but from my understanding, the amount of control is "enough".

Treadmill motion(stationary animations) seems like it wont look good enough because you have to perfectly match your move speed to animations. I just need either a resource or proper answer on the specifics about why you would use one over the other or a blend(treadmill for walking, root for jumping etc).

Appreciate any help provided.


texts: Custom extensible file format for 2d tiled maps

texts:
I have implemented much of my game logic right now, but still create my maps with nasty for-loops on-the-fly to be able to work with something. Now I wanted to move on and to do some research on how to (un)serialize this data. (I do not search for a map editor - I am speaking of the map file itself)

For now I am looking for suggestions and resources, how to implement a custom file format for my maps which should provide the following functionality (based on MoSCoW method):

Must have

Extensibility and backward compatibility
Handling of different layers
Metadata on whether a tile is solid or can be passed through
Special serialization of entities/triggers with associated properties/metadata

Could have

Some kind of inclusion of the tileset to prevent having scattered files/tilesets

I am developing with C++ (using SDL) and targetting only Windows. Any useful help, tips, suggestions, ... would be appreciated!

Result of the discussion below

I have been designing my map file format the last few hours and came up with a skeleton (contains only layers for now - I'll leave the rest to everyone designing his/her own format) which I wanted to share with everyone interested - if you have the same intentions you can get some kind of inspiration. The full-size screenshot can be downloaded at Imgur.


texts: Scripting language with class instance support

texts:
I have come across the need to use a scripting engine for my C++ game, but after experimenting with many languages since the last few days, nothing has truly stood out as the obvious choice for a language and/or binding library.

I would like have the ability to

call methods of a specific Game instance from within the scripting language,
call arbitrary functions in the scripts from C++, and
test for function existence in the scripts using strings.

Lua looks nice, but I'm unsure of its ability to do 1 and 3. Python and Boost::Python are great, but the same applies. Regardless, here's an example of an ideal implementation.

C++

class Game
{
    ...
    void printNumber(int arg);
};

int main( )
{
    Game *game = new Game();

    // Make method available to script
    functionRegister("printNumber", game->printNumber);

    // Test and call function in script
    if ( functionExists("greet") )
        functionCall("greet", "Hello world");
}

Script pseudocode

function greet( greeting )
    print( greeting )
    game.printNumber( 42 )
end

The output may be

Hello world
42

Is there a language and library that will pull this off?


texts: OpenGL ES - DrawCalls count - bottleneck?

texts:
I am newbie to OpenGL ES (so far, I used mainly DX11). Now for my scene, I have about 100 draw calls. I can use instancing, but only about half of objects can be instanced, so draw calls count would be about 50 - 60 / frame. Every object is max. 700 triangles (I use low-poly models)

What is some kind of limit of drawcalls per scene (targeting iPhone 4 like performance devices) ? So far I am running my code via ATI GLES on Windows, but there is a lot of power from my CPU and GPU.

Or is there a way, how to find bottleneck of my application ? I know gDebugger is for OpenGL, but with ES version it behave sometimes weird (a lot of warnings in calls I dont have in my code, so I suspect them to be from ATI layer code).


texts: Converting A 3D Rotational Vector Into A 3D Forward Heading Vector

texts:
I need to do a raycast which accepts a Vector3D StartPos and a Vector3D EndPos.

I have available to me the characters position and the cameras rotation in 3D vectors.

I need to somehow compute a 'forward heading' from the cameras rotation and apply it to the players position and multiply by some large number to get my EndPos vector however I can't figure out the math behind it, I know I can use sin() and cos() here which is the approach i'd like to take.

irr::core::vector3df CamRotation = GetOwner()->GetRotation();
irr::core::vector3df StartPos(GetOwner()->GetPosition().x(), GetOwner()->GetPosition().y(), GetOwner()->GetPosition().z());
irr::core::vector3df EndPos(0, 0, 0);

I've experimented around with using sin() and cos() in different combinations throwing in negative signs into places but quite frankly I don't know how to properly use those functions.


texts: Dictionary of common names for code objects

texts:
I'm looking for a common dictionary of terms (much like design patterns have a common language for how things interact) that are specific to games.

For instance, if I'm making a game of pong with a high level of complexity, I want to name things accordingly.

I've seen some visual objects that a user can interact with called a widget, some non-interactive ones called a doodad (back when I played with starcraft map editor anyway). Is there a proper name for the frame rate clock? Is there a proper name for the game clock (the clock that is about the movement of objects in the world but not the visual drawing)?

I just want a dictionary so I can speak the same language and not make up things as I go. I'm concerned I'm going to create things named doodads, whosits, whatsists, and flim-flams... and I don't want to do that.


texts: LibGDx android : Show animation on button click

texts:
I am trying to create an application using libgdx where i need an animation to be played on pressing an image button, i've been able to achieve it using this code

   if(slapBossFlag==true) {
        currentFrame = animation.getKeyFrame(timePassed, true);
            batch.begin();
            timePassed += Gdx.graphics.getDeltaTime();
        Gdx.app.log("time","time is"+timePassed);
            batch.draw(currentFrame, screenWidth / 2 - ((currentFrame.getRegionWidth()) / 2), screenHeight / 2 - ((currentFrame.getRegionHeight()) / 2));
            batch.end();
            slapBossFlag = false;
    }

the problem is the animation goes by too quickly.

i've tried setting timePassed to zero when slapBossFlag is false, and that didnt work.

Can anyone help?


texts: Unity: Simple “pass through” geometry shader

texts:
I would like to implement a geometry shader that does nothing, just for the purpose of learning and to go ahead with that and do something useful with it.

I currently have:

A compute shader creating "particles".
A vertex shader doing the transformation
A fragment shader...

This is the shader file:

StructuredBuffer<float3> particles;

struct fsInput {
    float4 pos : SV_POSITION;
};

fsInput vert(uint id : SV_VertexID)
{
    fsInput fsIn;
    float3 worldPos = particles[id];
    fsIn.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0f));
    return fsIn;
}

//[maxvertexcount(1)]
//void geom(point fsInput p[1], inout TriangleStream<fsInput> output)
//{
//  fsInput fsOut = (fsInput) 0;
//  fsOut.pos = p[0].pos;
//  output.Append(fsOut);
//}

float4 frag(fsInput fsIn) : COLOR
{
    return float4(1.0, 0.2, 0.2, 1);
}

I'm drawing my particles with this call:

Graphics.DrawProcedural(MeshTopology.Points, NUM_PARTICLES);

In my understanding, which is quite limited due to the perfect documentation of geometry shaders, my geometry shader should do nothing. Just forward the points to the fragment shader. However, if I use that shader (comment in those lines), I wont see my particles anymore. Without the geometry shader, I can see every particle.

So the first question is, where is the error? The second question is: Can I, starting with points and using the geometry shader, go from points to a, for example, cube? Or should I do it in the compute shaders? But if so, which MeshTopology should I use to draw the data from the compute shader as Cube, Sphere, etc...?

Thank you for help!


texts: I found Font Squirrel, and while it claims to have fonts free for commercial use, i can't find a license or legal pages anywhere. Are these fonts really usable for commecial use like they say?


texts: Procedural generation of heightmap for non rectangular surface

texts:
I'm working on procedural generation of terrain for a continent, meaning I need a wide range of hills, mountains and valleys generated around the continent. For mountains I've adopted Amit's algorithm for island generation, which produces quite good looking mountain with very clear ridges, slopes and everything else mountain tend to have. Now my problems is with some smoother hilly terrain.

Due to a hexagonic nature of my continent, the mesh is subdivided into triangles. Also due to needing multiple mountains/hills/valleys I also split my continent into sectors, which are then stitched together easily due to the fact the edges of the sectors always have zero elevation. So the constraints are the following:

The surface is hexagonal, this actually is less of a problem, since I can still generate elevation for "square" grid and use bilinear interpolation on "real" hexagon verts.
The surface is not a square, this I have absolutely no idea how to deal with.

Now most of the terrain generating algorithms always generate the terrain on a square surface, midpoint displacement, noise, you name it. Also they don't generate zero values on the edges, which is a strict requirement for me.

Now I would really like to adopt the double simplex noise approach, but once again, I need a way to force it to always generate zeroes outside of the bounds of my polygonal sector (which obviously varies), and smooth values inside the bounds, which would form nice hilly terrain. Question is... is it even possible, or should I be looking for a diferent approach?


texts: How to draw geometric shapes to a texture?

texts:
How can I create a texture containing a geometric figure using SDL2?

I saw there is a way to convert Surface to Texture, and I also saw that there is a way to draw directly to the screen using DrawRect() / FillRect() functions... I'm not sure if the geometry has something similar. Ultimately I want to have a texture to render.

The way I'm making my engine draw is to read game objects' texture and copy it to the render using render.Copy(texture, rect1, rect2).

This makes me wonder if there's a way for my game object to hold a texture containing a rect, circle, or triangle texture. I couldn't find in the SDL wiki or tutorials online.


texts:
How do I make my libGDX game resolution/density independent? Is there a way to specify image sizes as "absolute" regardless of the underlying density?

I'm making a very simple kids game; just a bunch of sprites displayed on-screen, and some text for menus (options menu primarily). What I want to know is: how do I make my sprites/fonts resolution independent? (I have wrapped them in my own classes to make things easier.)

Since it's a simple kids game, I don't need to worry about the "playable area" of the game; I want to use as much of the screen space as possible.

What I'm doing right now, which seems super incorrect, is to simply create images suitable for large resolutions, and then scale down (or rarely, up) to fit the screen size. This seems to work okay (in the desktop version), even with linear mapping on my textures, but the smaller resolutions look ugly.

Also, this seems to fly in the face of Android's "device independent pixels" (DPs). Or maybe I'm missing something and libGDX already takes care of this somehow?

What's the best way to tackle this? I found this link; is this a good way of solving the problem?: http://www.dandeliongamestudio.com/2011/09/12/android-fragmentation-density-independent-pixel-dip/

It mentions how to control the images, but it doesn't mention how to specify font/image sizes regardless of density.


texts: Placing items randomly in a dynamically generated terrain

texts:
I'm currently working on a 'Tiny wings' like game. I've already asked about the angle of the items in curved lines and i solved (thank you for responses),i'm currently placing the items in random positions, but the terrain it's dynamically and i don't get this working.

I've a vector with the points of the terrain, and i'm doing something similar to this (Iterating trough vector):

if( _SPManager && i % 15 == 0 && i != 0 )
{
    if (  _settings.specialPoints && _currentPoints < _settings.specialPoints )
    {
        _SPManager.addPoint( _hillsPosition[i].x , _hillsPosition[i].y );
        _currentPoints++;
    }
}

But it isn't working as i expected. It isn't displaying the right number of items (Always shows less than i specified).

How do i should place the items?

Thanks :)


texts: In my previous question, I asked about why people don't program on the GPU. Now I am learning about fluid dynamics with this article. They say that it should all be done on the GPU. The game engine that I use is Unity, and I know that shaders are run on the GPU. But is there any way to program (other than shaders) on the GPU?


texts:
Is there a way to update the location of an image?

I'm currently calling my image dynamically using:

itemImage = display.newImage(inventory[t.ID][1])

t. being my target ID.

But in order for Storyboard to properly work, I need to change its location in my code to above my function, rendering its dynamic properties useless. Is there a way to update it like you can do with .text?

something along the lines of:

itemImage.image(inventory[t.ID][1])
itemImage.imageUpdate(inventory[t.ID][1])

etc...


texts: How can I detect enclosed areas in an arbitrary set of overlapping lines

texts:
I have game where there can be arbitrary lines, these lines can overlap. I want to find out first if there are any enclosed shapes created by overlapping lines, and then I want to fill the enclosed shape.
The best guess I have at doing this comes from this other post: determine if a set of tiles on a grid forms and enclosed shape. From what I can gather this would be, given a graph you can detect loops. However I can't quite figure out how to construct the graph from my data.
Is this a good way to go about solving this problem? And if so, any pointers on how I might get there given a list of collisions?


texts: I know there's a breakdown of Sonic the Hedgehog physics found here, and I was wondering, does there exist a breakdown of any of the Mario games? Something similar to this but for Mario is what I'm interested in!


texts: Unity networking, make player disappear for all clients

texts:
As title says I need to make the player disappear when he gets in car. Right now, it works as a single-player, but since I am new to unet I don't really know how to achieve this, I tried some ways, but they didn't work. Here is script:

 [Client]
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     //so if we hit car
     if(hit.collider.tag == "Vehicle")
     {
         //if we pressed "E"
         if (Input.GetKeyDown(KeyCode.E))
         {
             //call method to disable some stuff taht should be disabled, like: controller, shoot, weapons etc.
             if (isServer)
                 CmdCall(inVehicle, hit);
             else
                 RpcCall(inVehicle, hit);
         }
     }
 }
 [Command]
 void CmdCall(bool invehicle, ControllerColliderHit hit){

     RpcCall(inVehicle, hit);
     }
 [ClientRpc]
 void RpcCall(bool invehicle, ControllerColliderHit hit)
 {

     disable(inVehicle, hit);
 }

  I can't see any errors in console but I cant enter play mode cause there are some compiler errors, which again i cant see in console. thank you for any tip, comment, downvote, upvote, or hint :)

--Nick.


texts: What is glViewport for and why it is not necessary sometimes?

texts:
I develop my game most of time under ArchLinux. I have decided to try it on the Ubuntu 16.04 recently. The situation I came across was really strange:

No glGetError()s at all.
No errors, warnings, anything bad in the gl debug output.
All assertions that I made for all bad situations did not trigger.
glClear successfully cleared the buffers I specified, but:
glDraw* did not draw anything.

Luckily I have found a solution which was to set glViewport. However, I don't quite understand, why is it necessary for drawing in Ubuntu but not necessary in ArchLinux? The also difference is between graphics adaptors: on archlinux I use NVIDIA 1060, on Ubuntu I use integrated HD Graphics P530 (Skylake GT 2).

If it is important, I use SDL2 with opengl 4.4.


texts: Are there any games that contain a machine learning AI?

texts: Can anybody here give a reference to commercial AAA games that implement a machine learning AI?


texts: Handling collision with LWJGL rectangles

texts:
I'm testing collision with other rectangles so I can implement it into my current project. The problem is the rectangle starts at the right x and y, but I'm not sure where exactly they are. I'm pretty sure they're starting from the x and y point and the height is going either up and down. My current ortho makes the y axis start from the bottom of the screen but I'm not sure how their rectangle calculates. How can I improve this class so for each side the bottom rectangle touches, it turns a certain color to identify collision.

public class a {

    static int playerX = 400;
    static int playerY = 400;

    static int enemyX = 100;
    static int enemyY = 100;

    public static void main(String[] args) {
        try {
            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setTitle("collision");
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
            Display.destroy();
            System.exit(1);
        }

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, 640, 0, 480, 1, -1);
        glMatrixMode(GL_MODELVIEW);

        Rectangle rl = new Rectangle(playerX, playerY, 10, 20);

        Rectangle r2 = new Rectangle(enemyX, enemyY, 200, 10);

        float c2 = 0;//color

        while (!Display.isCloseRequested()) {
            glClear(GL_COLOR_BUFFER_BIT);
            rl.setX(playerX);
            rl.setY(playerY);

            r2.setX(enemyX);
            r2.setY(enemyY);

            if(rl.intersects(r2))
            {
                c2 = 1f;
            } else if(!rl.intersects(r2))
            {
                c2 = 0f;
            }

            if(Keyboard.isKeyDown(Keyboard.KEY_A))
                playerX -= 1;
            if(Keyboard.isKeyDown(Keyboard.KEY_D))
                playerX += 1;
            if(Keyboard.isKeyDown(Keyboard.KEY_W))
                playerY += 1;
            if(Keyboard.isKeyDown(Keyboard.KEY_S))
                playerY -= 1;

            System.out.println(playerY-100);

            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

            glColor3f(0, 1, 0);

            //PLAYER

            //l
            glBegin(GL_QUADS);
            glVertex2f(playerX, playerY     -10      );
            glVertex2f(playerX + 10, playerY    -10  );
            glVertex2f(playerX + 10, playerY - 100    );
            glVertex2f(playerX, playerY      - 100    );
            glEnd();
            //r
            glBegin(GL_QUADS);
            glVertex2f(playerX + 100, playerY   -10           );
            glVertex2f(playerX + 110, playerY        -10      );
            glVertex2f(playerX + 110, playerY - 100            );
            glVertex2f(playerX + 100, playerY      - 100       );
            glEnd();
            //top
            glBegin(GL_QUADS);
            glVertex2f(playerX + 10, playerY     -9               );
            glVertex2f(playerX + 100, playerY       -9       );
            glVertex2f(playerX + 100, playerY - 20          );
            glVertex2f(playerX + 10, playerY      - 20           );
            glEnd();
            //bot
            glBegin(GL_QUADS);
            glVertex2f(playerX + 10, playerY          -90          );
            glVertex2f(playerX + 100, playerY    -90          );
            glVertex2f(playerX + 100, playerY - 101        );
            glVertex2f(playerX + 10, playerY      - 101         );
            glEnd();

            glColor3f(c2, 1, 0);
            //ENEMY
            glBegin(GL_QUADS);
            glVertex2f(enemyX, enemyY);
            glVertex2f(enemyX + 200, enemyY);
            glVertex2f(enemyX + 200, enemyY - 10);
            glVertex2f(enemyX, enemyY - 10);
            glEnd();

            Display.update();
            Display.sync(60);
        }
        Display.destroy();
        System.exit(0);
    }

}

I just made it so OpenGL set its position to the rectangle instead of the rectangle to OpenGL.


texts: Is a SQLite Database Suitable to Store the Building Blocks for Dynamic Content?

texts:
I am trying to make my own game for fun, it is basically a 2d side scrolling shooter, with dynamically generated enemies, levels, loot, and some other things. Currently I have dozens of XML files that define pretty much everything when it comes to the content, along with some constraints to keep things sane. Often times certain things like Weapons or Monsters are composed of several randomized sub components, that get picked out of a pool, according to factors such as rarity, the player level, and the game level.

Currently the way I have it setup, is where during initialization the game creates several factory classes (stuff like WeaponFactory and EnemyFactory), these parse the XML and store the XML's data in a more manageable format. Creation is simply done by invoking a create method, and passing the required parameters (i.e. player level, monster level, etc), these parameters are taken into consideration for what should be generated.

Anyways I was wondering if it would be a better idea to use a SQLite database to store all this information? I have looked around, and it seems to be a mixed response. Does anyone have any sort of insight into this? I am using C++ and OpenGL currently.

EDIT

I probably should have been more clear, I was more or less asking is it actually a usable way of doing this kind of stuff. My main concerns lie in the fact of choking the Database with requests. Reality is this game will never see the light, and has technically been done as of a few weeks ago, however I decided to go back retool the engine to use Box2D Physics. This is more a learning process, than anything.


texts: Size of an image imported with FreeImage

texts:
I'm having abit of a brainfart and I can't quite grasp what I'm doing wrong.
It's quite simple, I am importing an image with FreeImage (http://freeimage.sourceforge.net/) which has a method FreeImage_GetBits that returns a pointer to the first byte of the image data. I then try to load all the data into memory using (bitsperpixel / 8) * pixelsWidth ' pixelHeight, like this:

uint32_t bitsPerPixel           = FreeImage_GetBPP(bitmap);   // resolves to 24
uint32_t widthInPixels          = FreeImage_GetWidth(bitmap);  // resolves to 1024
uint32_t heightInPixels         = FreeImage_GetHeight(bitmap);  // resolves to 1024

// container is a std::vector<uint8_t>
pkgMaterial.mTextureData.insert(pkgMaterial.mTextureData.begin(), FreeImage_GetBits(bitmap), FreeImage_GetBits(bitmap) + ((bitsPerPixel/8) * widthInPixels * heightInPixels));

I have a jpg which is 31 kilobytes in size on disc. Yet when I load it using the above formula, I see the vector is then filled with 3145728 bytes, which is approx 3145 kilobytes. What am I doing wrong?


texts:
In XNA I am building my own textbox, and listbox.

For the textbox, I want it to render all text it can, and then cut off at the end of the textbox. But I don't want it to cut whole letters. I want it to cut exactly where the pixel limit is, so that if I write "SPAAAAAAAACE", and the size is 50 for instance, then it will only render "SPAAAA" and then a half A, or whatever is remaining in the pixels.

For my listbox, it's kind of the same thing. If I am scrolled half down, one element needs to be only half-visible.

How can I do this? Is it possible to add something to a buffer, and then before drawing it, clearing a specific rectangle from the buffer again?


texts:
I am working in a simple bouncing ball game. The ball moves right to left at a constant speed and back when it collides with the border of the display. But it jumps every time the the user clicks and then it falls. I apply no friction or something of that kind so when the ball bounces it has to have the exact opposite speed it had when it collided, but due to acceleration, when the frame rate is low it accelerates more than it should and bounces at a greater speed (and higher position), and when the frame rate is too high it bounces at a lower speed (and lower position). This obviously doesn't affect horizontal movement because there is no acceleration in there.

double current_time = SDL_GetTicks();
//for my convenience this is global variable
deltaTime = current_time - *previous_time;
*previous_time = current_time;

//Apply motion in x and y
ball.x += ball.x_speed * deltaTime / 1000;
ball.y += ball.y_speed * deltaTime / 1000;

//Accelerate
//Not quite sure where this should go for physical correctness
ball.y_speed += 1.5 * deltaTime;

ball.rect.x = (int) ball.x;
ball.rect.y = (int) ball.y;

So I now want to know how to make the speed be constant even if the frame rate isn't when I collide with the ground (obviously without getting rid of gravity acceleration).

Update

I didn't find any other relevant code to show you but I will provide a broader look at how I process and display the objects in the game.

I am using SDL to create this game. So I create this struct as a game object:

typedef struct PHYS_Object
{
    SDL_Rect collider;
    int x_speed, y_speed;
    //These two are the exact position of the object
    double x, y;
    int usesGravity;
    SDL_Texture* sprite;
}PHYS_Object;

Then in the main function before entering the main loop I create the objects and provide all the needed information like the image it's gonna use, the position etc... and store the objects that move in an array and objects that collide in other array (some of them are in both).

then in the main loop it goes like this:

//Abbreviated code
while(!quit)
{
    if(is_clicked(&button_1))
    {
        react_to_click();
    }else if(is_clicked(&button_2))
    {
        react_to_click();
    }else if(is_clicked(&play_button))
    {
        ball.y_speed = -250;
    }

    //Now move all the objects in the array
    //according to their speeds and position
    //See the code above
    PHYS_ApplyMotion(moving_objects_array);

    //Now detect and react appropriately to the
    //collisions produced after motion occurred
    PHYS_DetectCollisions(colliding_objects_array);

    SDL_RenderClear(renderer);
    SDL_RenderCopy(everything);
    SDL_RenderPresent(renderer);
}