texts: Preventing Excessive Movement Speed in Visual Studio

texts:
I just decided to give coding a go, and I am using C# in Visual Studio 2017. After some online tutorials, I tried to make a Windows Form App with simple movement. The only problem I have is that if you hold down a key for around a second, the player suddenly moves super quickly in that direction.

private void inGameKeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.A)
        {
            MoveSpeedX -= 3;
        }

        if (e.KeyCode == Keys.D)
        {
            MoveSpeedX += 3;
        }

        if (e.KeyCode == Keys.W)
        {
            MoveSpeedY -= 3;
        }

        if (e.KeyCode == Keys.S)
        {
            MoveSpeedY += 3;
        }
    }

The movement code. How can I fix this issue? Any help would be appreciated! :D

P.S. If you could also show me a way for more efficient movement, that would be greatly appreciated as well! :D


texts: When pausing an XNA Xbox game and showing a "pause menu", which controller buttons should I use?

texts:
I'm making a simple 2D XNA game for Xbox 360. My game can be paused by pressing the Start button on the Xbox controller. While paused, a simple menu pops up with options like Resume and Exit to Title Screen. The way I've currently programmed it, the menu options can only be selected with the A button on the Xbox controller, but I've found that I intuitively want to press Start to resume the action again.

I think it's a given that Start pauses the game and displays the pause menu, but once the pause menu is displayed, I can think of 3 options for dealing with input:

Menu options can be selected with the A button. Start does nothing.
Menu options can be selected with the A button or the Start button.
Menu options can be selected with the A button. Start resumes gameplay regardless of which menu option is selected.

What's the best control scheme to pause a game and accept input on a pause screen menu? Are there any guidelines or standards to help choose between these options?


texts: Calculate mipmap level in a loop with varying iteration?

texts: How can I calculate the correct mipmap level in a shader?  It needs to be used in a loop which runs a variable number of times so the compiler will not allow me to use Sample or the derivative functions, instead I have to use SampleLevel and manually specify a level.  I tried a simple distance based one but that doesn't look very good and doesn't fix all the problems (such as looking at them at a sharp angle), I thought I could use the dot product of the normal with the direction the pixel is going but I'm still not sure on the correct thresholds etc or if there's a better way.


texts: Would it be possible to randomize LOD distance in unity like in BOTW grass

texts: I was studying the BOTW grass shader and noticed how the grass appears uniform at a distance but complex up close. From watching gameplay it appears the LOD is randomized to make the transition between the two types of grass smooth. I can't find any way to do something like this in unity and am wondering if anybody has advice, or can guess as to how they did it. Thanks!


texts: Is naming convention a good base for a sorting and tagging system for game assets?

texts:
TLDR: what are the pros and cons of using a naming convention for tagging and sorting game assets?

for the UI to search and handle it
for devs and gamers to move files around

I am building a game that is designed to be moddable under UE4.
I am going to have tons of assets (clothes, hairs, jewleries and their textures materials and whatnot) to deal with.
This has to be organised well to avoid issues later on, and for the UI to be able to handle it in a user friendly way.
Eventually the game has to be localized for a bunch of non-latin character systems, too.
The easiest way would be to use a prefix/suffix system when naming the assets, which would come in the game in as Blueprints, containing the asset and some extra data as well. This would be a requirement for modders.
For example:
tag_othertag_clothname.uasset
tag          |name

And then all I do is just search tru the name of the asset. I feed it the text the user typed for the name part, and the tags as strings for the tag part, and than hide the tag part from the user.
I set up a test scene and it does work ok with 500 assets, running the search every time you hit a button.
Later on I can store tag data in json or just as a plain string in the Blueprint.
The issue is that as the number of tags grow, the length of the string grows too, which can be a problem later on.
I thought about using strings and json files to store the tagging data in the Blueprint as well.
I would like to have 2 categories of tags by default

region or body part: head, torso etc ---> makes searching and
categorizing very easy but not as efficient, can be appied to nearly all asset types

asset type: cloth, jewlery, armour, etc

My questions are:
In your experience

are there pitfalls of using a prefix suffix system, for example security, performance, ease of use etc? if yes what are they?
what are the alternatives - I thought of using databases, but I don't have much experience with them, not sure which one works best with a high number of Blueprints, I saw quite a few on the Marketplace...

I 'd like to make it as simple as it can be, no overcomplication or overengineering.
I just want it to be usable, user friendly and easily extendable as the project grows.


texts: How do I create a simple HUD, with ImageButton and background, using LibGDX?

texts:
Here is my HUD class:

public class UpperPanelHUD extends Table {

    private final TextureRegion textureRegion;
    private ItemButton itemButton;
    private Maze maze;

    public UpperPanelHUD(Maze maze) {
        this.setBounds(0,  RandoMaze.MAZE_HEIGHT+2, RandoMaze.MAZE_WIDTH, 2);
        this.maze = maze;
        this.textureRegion = Assets.gameAtlas.findRegion("Panel_Up");
        this.itemButton = new ItemButton();
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        super.draw(batch, parentAlpha);
        itemButton.draw(batch, parentAlpha);
        batch.draw(this.textureRegion, this.getX(), this.getY(), 11, 2);
    }
}

and here is my ItemButton:

public class ItemButton extends ImageButton {

    private TextureRegionDrawable textureRegionDrawable
            = new TextureRegionDrawable(Assets.gameAtlas.findRegion("Key"));

    public ItemButton() {
        super(new  TextureRegionDrawable(Assets.gameAtlas.findRegion("Key")));
        this.setBounds(0, 0, 1, 1);
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        super.draw(batch, parentAlpha);
        batch.draw(this.textureRegionDrawable.getRegion(), this.getX(), this.getY(), 1, 1);
    }
}

itemButton is drawn without relation to its parent UpperPanelHUD, and I need it be positioned inside UpperPanelHUD.


texts:
I know BOX2D uses meters, and AS3 uses pixels.

I'm trying to create objects which are limited to the stageWidth.

If I do this variable:

for (var i:int = 0; i<(stage.stageWidth); i++){...}

The animation will freeze, and this output appears:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Box2D.Collision::b2BroadPhase/CreateProxy()
at Box2D.Collision.Shapes::b2Shape/CreateProxy()
at Box2D.Dynamics::b2Body/CreateShape()
at com.actionsnippet.qbox.objects::CircleObject/build()
at com.actionsnippet.qbox::QuickObject/init()
at com.actionsnippet.qbox::QuickObject()
at com.actionsnippet.qbox.objects::CircleObject()
at com.actionsnippet.qbox::QuickBox2D/create()
at com.actionsnippet.qbox::QuickBox2D/addCircle()
at BOX2D_Test_Tutorial_fla::MainTimeline/frame1()

Does anyone know how to fix this?

Full Code:

    [SWF(width = 350, height = 600, frameRate = 60)]
import com.actionsnippet.qbox.*;
var sim:QuickBox2D = new QuickBox2D(this);
sim.createStageWalls();
// make a heavy circle
sim.addCircle({x:3, y:3, radius:0.4, density:1});
// create a few platforms

// make pins
for (var i:int = 0; i<(stage.stageWidth); i++){
//End
     sim.addCircle({x:1 + i * 1.5, y:18, radius:0.1, density:0});
     sim.addCircle({x:2 + i * 1.5, y:17, radius:0.1, density:0});
     sim.addCircle({x:1 + i * 1.5, y:16, radius:0.1, density:0});
     sim.addCircle({x:2 + i * 1.5, y:15, radius:0.1, density:0});

//Mid end

      sim.addCircle({x:0 + i * 2, y:14, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:13, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:12, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:11, radius:0.1, density:0});
      sim.addCircle({x:0 + i * 2, y:10, radius:0.1, density:0});

}
sim.start();
sim.mouseDrag();


texts:
For my game, I create game scene for which I set HUD to it.

First my game scene use BoundCamera, so I use hud to set score text, dollar text and setting button.
Now on game scene when I touch on setting button, the child scene (setting scene) come up because I attached it to game scene.

I use child scene because of pause/resume functionality added to the setting scene.

When child scene display on the screen at the same time hud content also displayed on the sceeen. But I don't want that hud content of my child scene (setting scene).

From other post of this forum I found that made hud.setVisible(false).

But this solution does not work for me because the touch area of hud's children remain active even though it were not displayed on the screen. So when player touch on these areas the effect of touch become available even if the hud is not displayed on the screen.

Also I like to mention that my development platform is AndEngine.
I hope someone give me best guidance on this.


texts: In Unity, how can I register a custom file type that is always opened with my game?

texts:
I want my players to be able to create their own scenes as custom levels, save them as files (say custom1.gamelevel), and open them directly in my game program by double-clicking the level file, rather than having to go through the steps of opening the game, browsing to the file in my menus, and then loading that scene/level.

I already have loading custom levels covered. I just need a way to associate this custom file type with my game which can open it.

I am mainly interested in a Windows-based solution.

How can I do this?


texts: The right way to start out in game development/design

texts:
I'm a 19 year old student looking for some help in the field of game development.

This question may or may not seem a bit overused, but the fact is that game development has been my life long dream, and after several hours of search I've realized that I've been going in circles for the past three or four months whilst doing such research on how to really get down and dirty with game development, therefor I decided to ask you guys if you could help me out at all.

Let me start off with some information about me and things i've already learned about GameDev which might help you out on helping me out (wordplay!):

I'm not an expert programmer, but I do have knowledge on how to program in several languages including C and Java (Currently learning Java in my degree in Computer Engineering), but my methodology might not be most correct in terms of syntax (hence my difficulty in starting out, i'm afraid that the starting point might not be the most correct, and it would deploy a wrongful development methodology that would be to corrected later on, in terms of game development or other projects).
I have yet to work in a project as large as a game, never in my learning curve of programming I've done a project to the scale of a video game, only very small software (PHP Front-ends and Back-ends, with some basic JQuery and CSS knowledge).
I'm not the biggest mathematician or physicist, but I already know that is not a problem, because there are several game engines already available for use and integration with home-made projects (Box2D, etc).
I've also learned about some libraries that could be included in said projects, to ease out some process in game development, like SDL for example.
I do not know how sprites, states, particles or any specific game-related techniques work.

With that being said, you can see that I have some ideas on game development, but I have absolutely no clue on how to design and produce a game, or even how game-like mechanics work. It does not have to be a complex game just to start out, I'd rather learn the basic of game design (Like 2D drawing, tiling, object collision) and test that out in a language that I feel comfortable in which could be later on migrated to other platforms, as long that what I've learned is the correct way to do things, and not just something that I've learned from some guy on Youtube by replicating that code on the video.

I'm sorry if my question is not in the best format possible, but I've got so many questions on my mind that are still un-answered that I don't know were to start!

Thank you for reading.


texts: Fastest way to render isometric world with moving entities?

texts:
I've got an isometric diamond-shaped world.
The world consists of isometric planes like rooms. The walls and floors of the rooms and all obstacles and items in the rooms are isometric entities.
So I have a list with each existing object in the world. Each object has its own coordinates. x, y, and z.
x is from top to right bottom, y is from top to left bottom, z is straight up into the air.
Each object has also an isometric width and height as property.

Now I have to render the world correctly. I'm quite sure the only hard step is to sort each object by its depth, and this isn't that hard when nothing changes in the world. But of course everything changes...
I want to figure out a sorting system which is very fast, so it doesn't do too much unnecessary work. I ended up with multiple articles, saying a pigeonhole sort is the way to go. But is this really the right solution?
And doesn't this cause rendering glitches? I also read that I should use topological sorting. (https://en.wikipedia.org/wiki/Topological_sorting).


texts: How can I make 3D games in 4K that are a few megabytes?

texts:
I would like to make 3D games in 4K that are a few Megabytes (MB) in download size.

Is there a way to use 3D Vector Graphics in games to reduce the file size ?
Or is there any other way to achieve the same level of compression achieved by Flash(.swf) and Swift3D ?


texts: GLSL, all in one or many shader programs?

texts:
I am doing some 3D demos using OpenGL and I noticed that GLSL is somewhat "limited" (or is it just me?). Anyway I have many different types of materials. Some materials have ambient and diffuse color, some materials have ambient occlusion map, some have specular map and bump map etc.

Is it better to support everything in one vertex/fragment shader pair or is it better to create many vertex/fragment shaders and select them based on currently selected material? What is the usual shader strategy in OpenGL or D3D?


texts: Android - Google play - enable download app for devices that supports opengl extension

texts:
I am using OpenGL ES 2 in my game. However, for simplicity i have used some extensions like VAO. Is there a way, how to disable dowloading of my app for devices, that do not support this (and other) extensions?

I can check it in code, but that is a little late, when user already bought my game and it wont work.


texts:
I'm writing a plugin for unity, I need to send a texture from ios to unity.
There is a UnitySendMessage function which takes char* as parameter, but I didn't find a way to convert id<MTLTexture> to char*.

How can I send id<MTLTexture> from ios and receive it in unity?

My current code :

//ios side ...
_texture = CVMetalTextureGetTexture(texture);
UnitySendMessage(CALLBACK_OBJECT, CALLBACK_TEXTURE_READY,_texture);//error
//...

//unity side
private void OnTextureReady(string texture_str)
{
   IntPtr texture = new IntPtr(Int32.Parse(texture_str));
   int width = 256;
   int height = 256;
   rawImage.texture = Texture2D.CreateExternalTexture(width, height,
   TextureFormat.ARGB32, false, false, texture);
}


texts: How do I check if a window has focus in SDL2?

texts:
Is there a replacement for SDL_GetAppState function in SDL2 from older SDL versions? Why was it removed? I want to use it so I can check if the user has focused the framebuffer window or not.

I found it in the documentation of the SDL 1.2.15 (Documentation page) but it seems like it disappeared in SDL2.X.


texts: Scaling entity by screen height (simulating depth on orthographic camera)

texts:
i want my entities to be at 100% scaling (for example 128x128 pixels) when they are at 40% of the screen height (for example 480 pixels at 100%), so when they are at 41%, they are at 99% scaling (126,72x126,72 pixels).

any idea of how i can achieve this?
thanks


texts: C++ - Assimp - OpenGL vertex data feed problem

texts:
I'm getting a very weird problem where OpenGL doesn't use the hardware to render anything, so I get just a cleared blank screen.

Here's some code:

//Mesh.hpp
template <typename T>
struct Vertex
{
    glm::tvec3<T> Coordinate;
    glm::tvec3<T> Normal;
    glm::tvec2<T> TextureCoordinates;
};

using FVertex = Vertex<float>;
using DVertex = Vertex<double>;

class Mesh
{
public:
    explicit Mesh(aiMesh*, const aiScene*);
    explicit Mesh(const Mesh&);
    explicit Mesh(Mesh&&);
    virtual ~Mesh();

    Mesh& operator=(const Mesh&) = delete;
    Mesh& operator=(Mesh&&) = delete;

public:

public:
    virtual void Render(const uint32_t&);
    virtual void SetupMesh();

private:

private:

protected:
    std::vector<FVertex> VertexBuffer;
    std::vector<uint32_t> IndexBuffer;
    std::vector<Texture> Textures;

    gl::GLuint VAO;
    gl::GLuint VBO;
    gl::GLuint EBO;

protected:

};

//Mesh.cpp

//This is how I feed the buffers. I've double checked, and the
//data imported from a Wavefront file is inside the VertexBuffer and IndexBuffer,
//and it is correctly loaded.
void Mesh::SetupMesh()
{
    gl::glBindVertexArray(VAO);
    gl::glBindBuffer(gl::GL_ARRAY_BUFFER, VBO);
    gl::glBindBuffer(gl::GL_ELEMENT_ARRAY_BUFFER, EBO);

    gl::glBufferData(gl::GL_ARRAY_BUFFER, VertexBuffer.size() * sizeof(Realms::FVertex), &(VertexBuffer.at(0)), gl::GL_STATIC_DRAW);
    gl::glBufferData(gl::GL_ELEMENT_ARRAY_BUFFER, IndexBuffer.size() * sizeof(uint32_t), &(IndexBuffer.at(0)), gl::GL_STATIC_DRAW);

    using Realms::FVertex;

    gl::glVertexAttribPointer(0, 3, gl::GL_FLOAT, gl::GL_FALSE, sizeof(FVertex), (void*)(offsetof(FVertex, Coordinate)));
    gl::glVertexAttribPointer(1, 3, gl::GL_FLOAT, gl::GL_FALSE, sizeof(FVertex), (void*)(offsetof(FVertex, Normal)));
    gl::glVertexAttribPointer(2, 2, gl::GL_FLOAT, gl::GL_FALSE, sizeof(FVertex), (void*)(offsetof(FVertex, TextureCoordinates)));
    gl::glEnableVertexAttribArray(0);
    gl::glEnableVertexAttribArray(1);
    gl::glEnableVertexAttribArray(2);
 }

void Mesh::Render(const uint32_t& glProgram)
{
    gl::glBindVertexArray(VAO);
    gl::glDrawElements(gl::GL_TRIANGLES, IndexBuffer.size(), gl::GL_UNSIGNED_INT, &(IndexBuffer.at(0)));
}

I've used a debugger to make sure the data inside the buffers is correct and accurate, that the vertex array object, buffer object and element object are all correctly generated and bound. Since my engine concept always chunks it down to drawing Meshes, nothing is being rendered. Here are the vertex and fragment shaders using GLSL:

 //VERT
 #version 330 core

layout (location = 0) in vec3 triangle;
layout (location = 1) in vec3 normals;
layout (location = 2) in vec2 TextCoords;

uniform mat4 ProjectionMatrix;
uniform mat4 LookAtMatrix;
uniform mat4 ModelMatrix;

void main()
{
    gl_Position = ProjectionMatrix * LookAtMatrix * ModelMatrix * vec4(triangle, 1.0);
}

 //FRAG
#version 330 core

out vec4 FragColor;

void main()
{
    FragColor = vec4(0.6, 0.3, 1.0, 1.0);
}

I've made sure the ProjectionMatrix, LookAtMatrix, and ModelMatrix are all  correctly sent to the vertex shader.


texts: How to access "move" values from move node in Rain behavior tree?

texts:
I have a blend tree for the NPC that takes an "input magnitude" value--0 to 1.0--for how fast the character should move...and an "angular input" float-- negative pi to positive pi--for how fast the character should turn.

How do I get the rain behavior tree to update these values correctly in the behavior tree "set parameter" leaves?

I see that I can set the parameter with some kind of variable name, but I don't see where I can specify that variable with a script...and I don't see how I can access the "move" instructions given from the move node on the behavior tree, and use them to set the variables either.

How would I accomplish this steering with Rain?


texts: My collider is not following my humanoid animation: how to do ?

texts:
I've a "Zombie" charachter and the following hirearchy:

I put a Capsule collider on parent Zombie_01.
When I kill the zombie, my "Zombie dead" animation is played, Zombie fall to ground, but the capsule collider stay standing.

So my question is: where I've to put capsule collider ? Or, what am i wrong ?

Thanks


texts: Generate random number biased to an input value

texts:
I've got enemies with a difficulty rating from 0 to 1. I want to generate a random reward that tends to increase as the difficulty rating rises, but still be possible to have a value anywhere in the range. Essentially, the average should increase with the difficulty, but maintain the full randomness range.

One attempt was to simply multiply a uniform random number by the difficulty, but this puts a cap on the output. What is the best approach to accomplish this?


texts: Conversation tree and question locking/unlocking

texts:
I have been having issues with managing a conversation tree. I am using PAWN as a scripting language (I have no other options, unfortunately) and I use MySQL databases to store user and game data.

My current issue is storing game conversation trees using SQL. Currently, I have the following table:

TABLE NAME: dialogue
ID: global ID of conversation option
Prompt: question or sentence shown on player's screen
Answer: NPC's answer
[some other stuff related to conditions and mood checks, etc.]

Now, my problem is the following. Suppose I greet the NPC, this would be something like this:

ID: 1
Prompt: Hello there.
Answer: Hi, how's it going?

I want my conversation tree to progress after the player greets the NPC. This is not problematic, I simply use an additional SQL table for that:

TABLE NAME: dialoge_unlock_lock
ID: global ID of dialogue element
Unlocks: option this element unlocks
Locks: option this element locks.

My problem is the following: suppose I greeted the NPC, this would unlock 5 conversation options for the player to choose from (they would have IDs 2-6 for this NPC, and perhaps 241-245 for another NPC). I choose question #2, this would unlock question #8 and lock question #7.

How could I check what questions the player has locked in the current dialogue tree? In this example, I don't want the player to just see question #8, but I want him to see every question that is currently available to him (that is, questions 2-6 & 8).

I have been sitting on this for days and I can't figure out a way to do it. This pretty much sums up my attempts, any help would be greatly appreciated.


texts: How can I extract a list of Minecraft items and recipes?

texts:
I'm designing a robust system for resolving item dependencies in Minecraft and to do so, I need to maintain a database of items and recipes.  Right now, this database has to be hand-crafted (no pun intended); I would like to know if it is possible to somehow query the Minecraft jars (or perhaps more realistically, grep through them) to extract this data automatically.

How can this be done?  The project is currently in Python, but it can still be ported to Java without much fuss at this stage.  (For the curious.)


texts:
On selecting camera, I get the camera preview.

In Unity, while editing the scene, I wish to switch in such a perspective view that is exactly visible by the main camera.

Is there a short cut to change the view?


texts: Improving bouncing logic - Atari breakout clone

texts:
I'm creating an Arkanoid clone using Haxe and Openfl. I'm thinking the bouncing algorithms could be improved. But I'm not sure how to handle those. I was hoping you guys could help.

    private function bounceBall():Void {
    var direction:Int = (ballMovement.x > 0)?( -1):(1);
    var randomAngle:Float = (Math.random() * Math.PI / 2) - 45;
    ballMovement.x = -1 * Math.cos(randomAngle) * ballSpeed;
    ballMovement.y = Math.sin(randomAngle) * ballSpeed;
}

Since I've never coded anything in Haxe I followed a tutorial to build a pong game. This is one of the functions that was used in the pong exercise. I think it's causing the ball to bounce left/right and rarely up or down. Can you guys help me out? How can I recreate the arkanoid bouncing ball logic?

You can find the rest of the source Here


texts:
I am programming a bossfight in gamemaker, and I want my boss to shoot multiple fireballs simultaneously, but all in a bit of a different direction, a little bit like this, from rogue soul:
It (obviously) doesn't work, and I have been trying for over an hour.
My script is:

//in the create event of fireball 1
direction = hero + 10
speed = 12

//in the create event of fireball 2
direction = hero + 5
speed = 12

and so on.

It just refuses to work. The fireballs go a completely random direction, independent of where the hero is.


texts: Vulkan best practices validation feature

texts:
During instance creation, debug utils enabled with best practices feature, I get the following somewhat cryptic message from the debug utils callback:

[ UNASSIGNED-BestPractices-vkCreateInstance-specialuse-extension ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x2dc65ef4 | CreateInstance(): Attempting to enable extension VK_EXT_debug_utils, but this extension is intended to support the following uses: use by applications when debugging, and it is strongly recommended that they be otherwise avoided.

Further info: this is Debian Linux. I have installed the vulkan dev packages from the repositories, but not the lunarg things. I filled out VkDebugUtilsMessengerCreateInfoEXT and VkValidationFeaturesEXT, linked the former to the .pNext field of the latter and the latter to the .pNext of the VkInstanceCreateInfo struct. CreateInstance and CreateDebugMessenger return without error.
I am struggling with the deeper meaning of the message. I assume it means that best practices feature is not enabled (unassigned), but why does the validation layer tell me not to enable debugging other then for, well, debugging ? Sounds like too much information ... what does it mean ?


texts: How to implement GIF insertion in Unity? "XYZ App doesn't support image insertion here"

texts:
I'm making an Android App with Unity, which has a chat service in it.

And I would like to handle sending images or GIFs via Gboard.

Currently when the user selects a TextField, his keyboard comes up, which is let's say GBoard.

And now when I click on a GIF or a Sticker, it says

  XYZ App doesn't support image insertion here

So how could I implement it?

Or more precisely, how can I define what method will be be called in my application when the user tries to send a GIF?

Because my first thought to implement it, is like it's done in all other apps:

every GIF would be in a separate message, and when the user clicks on a GIF it instantly sends a special GIF message, which will be rendered for example as an animated texture.

But how could I subscribe to this event in the first place?

Thanks in advance!


texts: LibGDX moving game window with mouse drag

texts:
TL;DR

How can I move window with mouse without tide effect.

Long Version

So when I tried to move my game window via InputListener(just to test if it would work). I got some strange result. The window goes back and forth between last two locations when mouse drags and while button is held.

Game Part

Gdx.input.setInputProcessor(new InputAdapter() {
    int b;
    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
        b = button;
        // TODO Auto-generated method stub
        Rectangle.tmp.set(0, 0, 100, 100);
        if (Rectangle.tmp.contains(screenX, screenY)) {
            lastx = screenX;
            lasty = screenY;
            System.err.println("Touch ( " + screenX + " , " + screenY + " )");
        }

        return true;
    }

    @Override
    public boolean touchDragged(int screenX, int screenY, int pointer) {
        if (lastx != null && tr != null) {
            tr.translate(screenX - lastx, screenY - lasty);
            System.err.println("Drag  ( " + lastx + " - " + screenX + " , " + lasty + " - " + screenY + " )");
            lastx = screenX;
            lasty = screenY;
        }
        return true;
    }

    @Override
    public boolean touchUp(int screenX, int screenY, int pointer, int button) {
        lastx = null;
        lasty = null;
        System.err.println("Up ( " + lastx + " , " + lasty + " )");
        return true;
    }
});

DesktopLauncher Part

Game.tr = new Translator() {

    @Override
    public boolean translate(int x, int y) {
        Display.setLocation(Display.getX() + x, Display.getY() + y);
        return true;
    }
};

PS: What I try&tried to make may look stupid.

Edit: Actually I noticed that window moves less than actual mouse movement.
Edit2: When I move the movement code to touchUp I get exact result as movement.


texts: How to create mipmap for Unity3d textures loaded with www?

texts:
When I load a texture using the code below:

WWW www = new WWW(textureName);

yield return www;

renderer.material = new Material(Shader.Find("Diffuse"));

Texture tex = www.texture;
tex.filterMode = FilterMode.Trilinear;

renderer.material.mainTexture =tex;

The texture does not come with mipmaps, how can I tell unity to generate the mipmaps?


texts: I'm developing a 3D game similar to the Roller Ball game from Unity's tutorials mixed with a runner type game like Subway Surfers.  The game uses the arrow keys for control.  When the player hits the left or right arrow key, I want the player to do a 90 degree turn and have the camera stay behind the player.  My questions are, how would I do this?  Would I need to do this in my player controller script and just change the rotation?  Or would I need to add some controls to the camera and change the rotation of the camera every time the player hits the right or left key?


texts: C++ OpenGL More textured objects equals less FPS

texts:
So I'm creating a game engine with many features, last time I focused on textures.

When I finished implementing some new code (Made by myself) I created new Entity with texture, and it was working really nice.

But If I create 2 or more textured objects game starts lagging..

1 Cube without texture = > 60 FPS
1 Cube with texture = > 60 FPS
2 Cubes without texture =  > 60 FPS
2 Cubes with texture = 40-50 FPS
10 Cubes without texture = > 60 FPS
10 Cubes with texture = 20 FPS
100 Cubes without Texture = > 60 FPS
100 Cubes with Texture = < 1 FPS
10000 Cubes without Texture = > 60 FPS

I'm using GLSL sampler2D, texture UV from VBO, here is my renderer code:

bool textured = false;

if(entity->hasComponent("MaterialComponent"))
{
    MaterialComponent *materialComponent = (MaterialComponent*) entity->getComponent("MaterialComponent");

    if(materialComponent->material != NULL && materialComponent->material->texture != NULL) textured = true;
}

if(component->cullFaces)
{
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
}

if(textured) glEnable(GL_TEXTURE_2D);

glBindVertexArray(component->model->vaoID);
glEnableVertexAttribArray(0);
if(textured) glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);

//glDrawElements(GL_TRIANGLES, component->model->getVertexCount(), GL_UNSIGNED_INT, 0);

if(textured)
{
    MaterialComponent *materialComponent = (MaterialComponent*) entity->getComponent("MaterialComponent");

    if(materialComponent->material->texture->textureID == 0) glGenTextures(1, &materialComponent->material->texture->textureID);

    glBindTexture(GL_TEXTURE_2D, materialComponent->material->texture->textureID);

    SDL_Surface *surface = IMG_Load(materialComponent->material->texture->textureFile->getPath().c_str());

    if(!surface) Error::throwError("Cannot load texture file!");

    S32 colorMode = GL_RGB;

    if(surface->format->BytesPerPixel == 4) colorMode = GL_RGBA;

    glTexImage2D(GL_TEXTURE_2D, 0, colorMode, surface->w, surface->h, 0, colorMode, GL_UNSIGNED_BYTE, surface->pixels);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
   // glGenerateMipmap(GL_TEXTURE_2D);

    glActiveTexture(GL_TEXTURE0);

    glUniform1i(baseShader->loc_sampler, 0);

    SDL_FreeSurface(surface);
}

glDrawElements(GL_TRIANGLES, component->model->getVertexCount(), GL_UNSIGNED_INT, 0);

if(textured)
{
    //glBindTexture(GL_TEXTURE_2D, 0);
    glDisable(GL_TEXTURE_2D);
}

glDisableVertexAttribArray(0);
if(textured) glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);
glBindVertexArray(0);

if(textured) glDisable(GL_TEXTURE_2D);

if(component->cullFaces)
{
    glDisable(GL_CULL_FACE);
}

So I can create new TextureAsset for each cube or I can use one TextureAsset for each cube, it makes no difference about FPS.

I'm creating new TextureAsset like this:

TextureAsset *textureAsset = new TextureAsset(new FilePath("PATH_TO_TEXTURE"));

Then putting it inside Entity' MaterialComponent:

MaterialComponent *materialC = (MaterialComponent*) cube1->getComponent("MaterialComponent");

materialC->materialAsset->texture = textureAsset;

I think there is something bad inside my renderer method, it happens only if there is more than 1 textured object. Maybe I have to clean-up texture in different way?

I'm using SDL2, SDL2_image and GLEW.

If you need more code - just tell me.


texts: "Loaded resource as image file, this will not work on export" - what does this mean

texts:
I'm sure it is something unrelated is why my program won't work, but I still want to know:

core/image.cpp:1746 - Loaded resource as image file, this will not work on export: 'res://ball.png'. Instead, import the image file as an Image resource and load it normally as a resource.

What does this actually mean!? What is it telling me to do?!


texts: What are common methods for organizing game objects?

texts:
I'm in the early stages of developing a game in C++.

As of currently, I've defined a base GameObject class that is the base class for any interactive item in my map (e.g. enemies, loot, projectiles, etc.). When these items are created, I want to give them to an ObjectManager class. The ObjectManager class is responsible for iterating over each object and calling abstract methods like "update" or "render".

Originally, I planned on storing all objects (or references to the objects) in a single container. I would then iterate over this container.

However, I'm starting to have second thoughts about whether or not this is a good idea. I've come up with two reasons why this might be a bad idea:

1.) Regarding object collision, it makes sense to only perform calculations between certain objects on whether or not they've collided. For example, I would want to determine if the main character has collided with a loot item. However, I would never to want to calculate if a loot item has collided with another loot item (at least in my case).

2.) Object pools. Referencing this article, it has come to my attention that continuously allocating/de-allocating memory is expensive. Because of this, it is a common technique to use object pools that request memory upfront and then manage that memory without actually deleting it. One of the comments made in the article is that the objects that exist within the pool must all be the same size (or each pool slot must be big enough to accommodate the largest object).

Both of these examples make me think having a single container that houses all GameObject is a bad idea.

Instead, it seems like it would make more sense to have different containers for each type GameObject type. For example, it would make sense to have a container for enemies, loot, projectiles, etc. This way I would have more control in iterating/comparing only on objects that make sense for certain object types (e.g. don't try to calculate collisions between two loot items).

The problem I'm facing however is that I don't know how to break up these containers. Should all projectiles go in a single container? However, what if I later decide to create a "fire projectile" that performs some kind of "burn" logic. Would this require a new container to then to iterate over all fire projectiles? Essentially, I don't know how granular my containers should be.

I haven't come across any reference material on this topic. Any advice would be appreciated.


texts: How to implement a network proximity checker in Unity using LLAPI?

texts: I'm trying to implement a network proximity checker using my own functions in Unity, using LLAPI. How can I implemnet a network proximity checker, with similar functionalities than the ones in the HLAPI proximity checker?


texts: Godot / GDscript label text not updating every frame like intended

texts:
I am very new to Godot and coding in general, so I apologize in advance for any simple mistakes. I am trying to have my text display the variable ammodisplay on my object Marine. When I launch the game, the text sets to 7 (the correct value) but as I play the game and the variable changes, the text does not update with it. Any insight as to how I can fix this? Thanks in advance!
extends Label

var NODE = load("Marine.tscn")
var ammo = NODE.instance()
var ammod = ammo.ammodisplay

func _process(delta):
    text = (str(ammod))


texts:
Recently I started working on a game with the spritekit engine. My question is not about spritekit in specific though, but generally about game engines.

When I write a loop and run it (eg while i < 100000) my cpu usage goes to 100% normally, but when I run the test game there is no changes especially on cpu usage, why? (I know game engines run in a loop that includes logic and graphic commands.)


texts: Testing whether two cubes are touching in space

texts:
Does anyone have any clean ideas on testing whether two cubes in 3D space touch? By touch I mean, touch at corners or on a face or on an edge. Say that the cubes are axis aligned and there is no nesting of the cubes. So either the cubes touch or they don't. There is no overlap of the cubes at all (except of course possibly an edge or corner point).

Everything I have thought of ends up needing a ton of cases. Also numerical stability is a factor. I don't want to just test == on all the edges/points.

I guess I could utilize some sort of epsilon instead of testing whether something == 0. The main thing however is minimizing the number of cases to test.


texts: What colors to choose for colorblind people?

texts: I'm creating a game. Color coding is its main gameplay feature. What colors should I choose so the game will be colorblind-friendly? (I need 4 colors)


texts: How can I check if someone bought a non-consumable product on iOS/Android?

texts:
In my application are 10 free levels, everyone can play them without doing in-app purchases. But if you want more levels, then you need to buy once a non-consumable product in the application. After you purchased it, you will have access to all levels that are currently available and to all levels that will be released during the next weeks.

But how can I know if someone bought the non-consumable product?
Is it necessary to send at every reboot of the application a request to the Apple App Store to check if the current Apple ID has bought the product?


texts: Loading TextureRegion with filter diff from that of texture it came from

texts:
I am using libgdx .
While packing my texture atlas I have set the filter for mag and min to Nearest . But for just one region I wish to draw it with linear filter . Is it possible to have different filters for texture region than that of texture atlas it came from.


texts:
Is it possible to create a terminal application which uses cocos2d? I've tried to make one using cocos2d 2.x, but it requires a MacGLView to be initialized.

I need it so that I could program a terminal application that generates a screenshot given a TMX file and an optional preferred width or height parameter (for resizing). Then I can automate the generation of map previews for my game, instead of manually taking screenshots. It's not practical to load the actual TMX and resize it inside the game (what I'm currently doing), because each TMX file has 7 layers, my tile sheet is huge, and I have lots of levels.


texts: How to pass PNG image data directly to SDL?

texts:
Well passing just external PNG to SDL is very easy with the SDL_image library. I have a class that does just that. The code looks like the following:

SDL_Surface* Texture::LoadImg(const char *filename) {
    SDL_Surface* Image = IMG_Load(filename);
    if (Image == NULL ) {
        printf("Unable to load picture%s\n",SDL_GetError());
        return NULL;
    }
    return Image;
}

Later on I can just call it with

//some code
SDL_Texture* Texture = SDL_CreateTextureFromSurface(Renderer,LoadImg(filename));
//some code

But I don't have just a PNG file. I have a binary file that consist of many PNG files inside. Basically I combine binary(PNG) files into one larger file. Later on I just open that binary file and load pictures into memory from one single file. So now I have an array of vectors or pointers or any other types (depending how you read the binary file). Now I need to pass this from memory into SDL or SDL_image to load it as texture. How would I pass already loaded PNG (binary) data into SDL to use as an SDL_Texture?


texts:
I have a direction vector on which I have to apply some rotation to align it to positive z-axis.
To use Matrix.CreateRotationX(angle) of XNA, I need the angle for which I'd have to compute cos or tan inverse.

I think this is a complex task to do. Also, eventually those are also converted to sin(angle) and cos(angle) in the matrix.

Is there any inbuilt way to create rotation matrix from a 3D vector?

However, I can write the function but still asking if there is one already there.


texts: Cocos2dx - Touch not recognized on Android

texts:
I'm having trouble with a touch listener not picking up touch events on android, but doing fine in windows (mouse input). I've got a Node listening for touches (not a Layer), but from what I've been seeing around it seems having it on a Layer isn't a requirement anymore?

Setup

void DodgePlayerController::setupPlayerInput()
{
    CCLOG("DodgePlayerController::setupPlayerInput()");
    if (myPawn)
    {
        Pellet* myPellet = dynamic_cast<Pellet*>(myPawn);
        if (myPellet)
        {
            CCLOG("DodgePlayerController::setupPlayerInput() !!2!!");
            //setup the player input and events (should build some sort of player controller)
            auto listener = EventListenerTouchAllAtOnce::create();
            listener->onTouchesBegan = CC_CALLBACK_2(Pellet::setTargetPosition, myPellet);
            listener->onTouchesMoved = CC_CALLBACK_2(Pellet::setTargetPosition, myPellet);
            listener->onTouchesEnded = CC_CALLBACK_2(Pellet::clearTargetPosition, myPellet);
            listener->onTouchesCancelled = CC_CALLBACK_2(Pellet::clearTargetPosition, myPellet);

            auto dispatcher = getEventDispatcher();
            dispatcher->addEventListenerWithSceneGraphPriority(listener, this);
        }
    }
}

When logging on Android, I'm getting through both CCLOG messages correctly (I have a 'disablePlayerInput()' which isn't being called, so the listener shouldn't be removed). This all works fine in the windows application, but when I load it in Android the touches aren't picked up (Pellet::setTargetPosition also has a log message which doesn't get thrown in android).

Anyone know what I might be missing?


texts: How can I profile and debug my usage of D3D10?

texts:
I've been working on D3D 10 for about 6 months and I have accumulated a basic framework. The thing is I get frame rate spikes.

Even when I have a simple cube on the screen each side with its own texture, every now and the the frame rate drops suddenly.

Any tips to try and find out what is causing it?


texts: How to limit and direct player's view in VR?

texts:
We are making a VR game where the player will look at the world through the eyes of his character who sometimes moves on his own, so the player is only observer.

The character will rotate his body on his own and we need to change the orientation of player's camera to look where the character looks. For example, the girl takes his hand and leads her way. It would be very unrealistic if the player's head will be turned 180 from his body and he will walk backwards.

It'll allow us to avoid exhausting head rotations. Is it a good idea to guide his view by force by limiting camera euler angles relative to the direction of the body?


texts: How can I display a 3d object and my player on a canvas?

texts:
The main goal is to animate my player with animator on a canvas.
The problem is that any 3d object (my player, a cube) I drag over the canvas is transparent/not seen.
The main camera is set to Clear Flags : Depth Only and Culling Mask to Everything.
The Main Menu Canvas is set render mode to Screen Space Camera and I selected the main camera.
The Main Menu Background Material is set to New Material I created and on the new material I added a shader I created that make this image to be blur.
The main camera settings screenshot :

And the Canvas settings :

And the Main Menu Background settings :

You can see in all the screenshots in the scene view top left that my player and the cube both are transparent on the canvas.
Now if I change the Main Camera Clear Flags to SkyBox then I see my player and the cube but also they are not looking like they should be with the texture/materials and also I don't want the Main Camera to be the clear flags on SkyBox I want the objects to be over the blur image so the Main Camera should be clear flags depth only.
The main goal again is to put my player on the canvas with the blur image and animate my player. This is for my main menu.

The canvas that will display the player if the player will be on his own canvas should be transparent and only display the player so the canvas will not overlap the other cnavas with the blur image.

I want to animate using animator the player not only to display it as static object.

This is a screenshot of what I mean I used paint to cut my player and put it on but the player canvas should be transparent or without a canvas the player should be on like the ui button on the left :

Another screenshot. On the top it's the scene view window the player the ui button and the blur image.
On the bottom the game view window the ui button is on the blur image.
I want the player to be the same as the ui button on the blur image and then to animate the player. Not like in my other screenshot the player should not have a skybox background or something it should be like the ui button on the blur image:


texts: Toggle action for gamepad triggers, whilst being held down

texts:
I'm doing a small fighting game project, as up now every button command in my map code is occupied with their designated functions. All except the triggers; as up now they only have their basic "press n hold" actions assigned; "sidestep" for the [LT] and "jump/fly" for the [RT].

However there are still two more actions that I would like to implement to the triggers "if possible"; they being, "Block" for the [LT] and "Fly up" for the [RT].

That being said, is it possible to somehow, add a "tap toggle action" to the triggers while they're still being held? If yes please let me know.

For Tom Tsagk: Yes, I'm trying to cause an event while holding down a button "this case a trigger", but 'not' by pressing another button for the execution, "since every other button is occupied doing something else".

What I'm trying to attempt is: when holding a trigger down, to be able to give small "taps" to the trigger without the need let go.


texts: Are there tutorials which teach you to paint textures for 3d model UV maps in photoshop?

texts:
Are there tutorials out there which show how to paint textures for models in photoshop with their UV maps? I already have 4 years experience with modeling in 3ds max and I'm dying to learn how to paint textures for my models. U have photoshop with me but the problem is i don't know how to start or how my textures should look like.

For example this is a model that I'd like to practice painting textures for but it is too bland:

I'm currently using plain 3ds max mental ray materials for it right now but it just looks too bland and plain and I'd like to make more stylised like the following:


texts: When creating a game, what are some architectural desgin concepts I can use to be able to port my game from single to multiplayer?

texts:
I am a software developer but, I mostly develop games in Unity. I have experience creating single player games as well as multiplayer games. I am at a crossroads where I am in the middle of development of a proof of concept or small demo and all of a sudden I am asked to turn it into a multiplayer game without prior knowledge of this I turn around and say it would add 50% to development time because I basically have to start over from scratch because I didn't necessarily take into account that later down the road they might want to change the experience from single to multiplayer.

So with all of that out of the way, are there any different methodologies out there that would make it easier on the developer to port a game from single player to multiplayer?

I have thought of a possible way of doing this by just setting the game up as single player, however, making my functions where they are easily able to wrap them using Commands and RPCs. But I find this may or may not help me and is only dependent on what the requirements are.

My biggest time killer when it comes to porting these PoC's is typically the UI. Most of the time my requirements are so that the UI will be the same shared UI for all clients and having to update it for each action performed on it and dealing with handling ClientAuthority. (Any tips for dealing with this would be greatly appreciated too) Think of this as something like, making something with Legos in multiplayer and having shared instructions based on the step the user is on.

Summary

What are different ways that I can design a small demo/concept where I can easily port it to multiplayer later on, or make my game where it is "multiplayer friendly" ? Or should I try to stay away from this type of thinking altogether and just develop a single player aspect and just develop a multiplayer aspect, arguments for and against this concept are sought after.


texts:
I am using GLFW for the input in my game. I just started learning it and I have encountered a problem. The problem is the input, I have a callback function, where I check for keypresses. I want the program to toggle wireframe mode when the user press 1, therefore I have this code:

if(key == '1' && action == GLFW_PRESS)
{
    wireframe = !wireframe;
}

The problem is that I am Czech and we obviously have different keyboard layout - I use english keyboard layout for programming and when I press 1 it works, however, when I press the same key on czech layout it doesn't work, probably because we have to press Shift along with the '1' key to actually get the 1 on the screen. It may seem obvious that it does not work, but when I used SFML it worked.

I also tried replacing the '1' with 49 or 0x0031, but the result is the same.

Is there a solution or do I have to set the layout manually by the system API?

Thanks in advance.


texts: When to use AI prediction in a Fighting Game

texts: I am making a fighting game AI that can predict the player's next move using a N gram predictor. Once I have the prediction, when do I use it ? Do I wait till player makes a move and then use the prediction ? What about distance from the player ? How do I make the use of my prediction look realistic ?


texts: get tetrahedron centroid velocity if vertex velocities known

texts:
If i have a tetrahedron and i know the velocities of the 4 vertices, how can I find the velocity of the Centroid?

I know how to get the result if i know the velocity of the Centroid (i can use Barycentric coordinates to find the vertex velocities).


texts: How to be two while creating game assets

texts:
A friend and I are developing our first game, he as a graphic artist and I as a developer.
I'm confident with his drawing art and he his confident with my development skills, but the discussion comes when we are designing other art assets togethert, such as sound, music, screenplay, gameplay...

We often argue on subjective matters, such as "It would be better if there are more narratives" or "In my mind the music is too peaceful".

How would you recommend to collaborate on these art work?


texts: Picking tiles in an isometric diamond map

texts:
I am rendering a isometric map with the following code:

for(var x = 0; x < MAP_WIDTH; x++) {
        this.map[x] = [];

        for (var y = 0; y < MAP_HEIGHT; y++) {
            var screenX = xOffset - (x - y) * TILE_WIDTH_HALF;
            var screenY = yOffset + (x + y) * TILE_HEIGHT_HALF;

            this.map[x][y] = game.add.sprite(screenX, screenY, 'tile');
        }
 }

Where the offsets are defined as followed:

xOffset = (GAME_WIDTH / 2) - TILE_WIDTH_HALF
yOffset = 0;

I have been using the math from the following page I stumbled upon but for some reason I can't seem to correct my coordinates for the offsets I have given.

I've tried picking the following ways:

var mouseX = this.game.input.mousePointer.x;
var mouseY = this.game.input.mousePointer.y;

var xOffset = (GAME_WIDTH / 2) - TILE_WIDTH_HALF;
var yOffset = 0;

var wPX = (2 * (mouseX - xOffset - TILE_HEIGHT_HALF) - mouseY) / 2;
var wPY = (2 * mouseY + (mouseX - xOffset - TILE_WIDTH_HALF)) / 2;

var x = Math.floor(wPX / TILE_WIDTH);
var y = Math.floor(wPY / TILE_HEIGHT);

Although for this code my Y coordinate actually picks correctly, it doesn't make sense to me, and I can't seem why it would. Also the X coordinate is completely off.

I have also tried implementing using the following mathematical snippet

map.x = (screen.x / TILE_WIDTH_HALF + screen.y / TILE_HEIGHT_HALF) /2;
map.y = (screen.y / TILE_HEIGHT_HALF -(screen.x / TILE_WIDTH_HALF)) /2;

Where I would define screen.x and screen.y as my mouse.x and mouse.y, again without result. I have read some things about inverse matrices but I would have no idea on how to actually use a matrix. I hope one of you could give me a few nice tips or hint me in the correct direction.


texts:
I'm working on a top down fishing game. I want to implement some physics and collision detection regarding the boat moving around the lake. I would like for be able to implement thrust from either the main motor or trolling motor, the effect of wind on the object, and the drag of the water on the object.

I've been looking at the farseer physics engine, but not having any experience using a physics engine, I am not quite sure that farseer is suitable for this type of thing(Most of the demos seem to be the application of gravity to a vertical top/down type model).

Would the farseer engine be suitable? or would a different engine be more suitable?


texts: How can I use D3DXLoadMeshFromX with Direct3D 11?

texts:
I'm trying to write some class for loading meshes from X files.

But I can't use the function D3DXLoadMeshFromX because its third parameter is LPDirect3DDevice9.

In my D3D initialization code I don't have variable of this type. Did I initialize D3D incorrectly? How can I call this function?


texts: Is HTML5 and Canvas good for rapid prototyping of games?

texts: Are there frameworks and processes for HTMl5 that can be used for the rapid prototyping of 2D games?


texts: Turning a sprite such that it rotates in the direction that's most efficient

texts:
I have a sprite that moves from waypoint to waypoint. It turns to face its velocity vector, but not instantly (there's a rotation speed).

The problem I'm having is, from one direction to another, the sprite will often turn in wild, unnecessary ways instead of appearing like you might expect a car to appear (turn such that the minimum delta in angle occurs).

Right now I'm using the following formula to calculate the rotation float for the current velocity:

MathHelper.PiOver2 + -Math.Atan2(anotherVector.Y - vector.Y, -(anotherVector.X - vector.X));

And then I lerp the current rotation by the new rotation by the rotation speed (10f):

rotation = MathHelper.Lerp(rotation, targetRotation, 10f * (float)gameTime.ElapsedGameTime.TotalSeconds);

But unfortunately, it's causing the sprite to spin in wild directions before reaching the correct angle. Any suggestions?


texts:
I am looking to create a similar tunnel effect in COCOS2D (iOS). Could anyone suggest any pointers?

ref Video 1

ref Video 2

Till now I have tried with several ring shape sprites with decreasing scale and positioned center to a same point and keeping Z decreasing as well for each smaller sprite.

With that, animating it with CCScaleTo and changing the size to 2.0 with animation duration but it does not come anyway near to the tunnel effect shown in the reference.

Thanks,
sam


texts: What are good solutions for serialization in C++?

texts: I'm curious what solutions game developers have come up with for serializing the different types of data that they deal with for their games. Do you guys use some monolithic GameObject hierarchy that houses a serialization interface for derived types, use sort of custom RTTI-based solution, perform explicit stream serialization for certain classes, or use some of the open source solutions (boost::serialization, s11n, etc).


texts: In a team of 2 people (one front end, one scripting), is there any way I could write scripts without the use of Unity all together?

texts: So, I'm curious whether or not it would be possible to write scripts for a Unity game without using Unity itself, but using a third-party IDE, such as Visual Studio. My reason for this would be the following: I have a very low-end laptop, so I can not run Unity in any usable fashion. So I'm wondering if I could do the programming only part for the game without using Unity? By this, I mean writing the actual code and sending it over some online platform to be integrated with the Unity environment. And I know, this would not be productive at all.


texts: How to create a font from an image for a game?

texts:
I found a font in a free pack of sprite as an image:

I'm wondering what would be the best way to use it in a game?

Is there tools to create a font from this image? Do i have to code it myself? I think of using this only for area with few text (like menus) so maybe a simple system converting a string to a sequence of image representing letters would be enough and it's not worth trying to use a complex font system?

What do you think?


texts: Help for sorting cars that are 1 lap behind the others (latecomers)

texts:
Think of 22 cars running in circuit.

I can sort them based on the order they reach the finish line.

I start to have problems, because over time, the faster cars start to reach the slower cars.

Making the cars slower latecomers/laggards/lapped (blue flag in F1).

Event (collision car with finish line):

other.position[other.collision]=pilot;
other.lap[other.collision]=timeLap;
other.timeTotal[other.collision]=timeTotal;
other.collision+=1;

if(other.collision>22){
    other.collision=1;
}

OBS - The collision event (shown above) is performed on the car. Every variable (other.) Is because it belongs to the finish line.

I use a variable that serves to define which array index will be defined (other.collision).

Draw Event (Finish Line):

repeat(22){
    draw_text(1280,100+(20*(i-1)),string(position[i]));
    draw_text(1430,100+(20*(i-1)),string(lap[i]));
    draw_text(1530,100+(20*(i-1)),string(timeTotal[i]));
    i+=1;
}

i=1;

What happens is that when the first car overcomes the last one, it ends up having the index 22. Becoming the last and vice versa.

I tried to use the time, but the faster car does more turns in less time. Time equals or does not work correctly. So I would also have to use the amount of laps.

That's when I got completely confused.

I am trying to use arrays to order them with the bubble sort, but I didn't get anything functional..

I tried a few more things, but I got lost and I don't even know how to explain it to you.


texts: Optimizing data structure for my text adventure?

texts:
In my text adventure I'm making, I store the story data in a hashtable (I'm using unity's javascript/unity script since I'm more comfortable with the syntax than C#).

The problem is, the way I structure the hashtable means that it gets incredibly bloated very quickly (I've used the same structure in all of my text adventures across multiple languages. It quickly grows to nearly 1k lines long) which makes it hard to edit in the future (especially if I need to go back to edit certain parts later on)

Here's the hashtable as it's currently structured:

public static var story = {
    "0":
    {
        "text":"",
        "choices":
        {
            "response1":
            {
                "text":"",
                "nextPart":"1"
            },
            "response2":
            {
                "text":"",
                "nextPart":"2"
            },
            "response3":
            {
                "text":"",
                "nextPart":"3"
            }

       }
    },
    "1":
    {
        "text":"",
        "lastPart":"0"
    },
    "2":
    {
        "text":"",
        "lastPart":"0"
    }
};

If anyone could help me optimize the structure of the hashtable that'll make it so it's more easier for me to edit it in the future, that would be great

Quick information for parts that may not be self-explanatory:

"lastPart" indicates to the hashtable parser that the player has died
and the number refers to the part where they chose the
response/choice.
"nextPart" refers to the part of the story the response leads to.


texts: How to lerp all members of array in Unity 5?

texts:
I've an array of gameobjects called cards and I have this code to run when clicking a button

public void mover()
{
  for (int x = 0; x < cards.Lengh; x++)
  {
    cards[x].transform.position = Vector3.Lerp(
      cards[x].transform.position,
      new Vector3( Random.Range(2.5f, 15.5f), 1.5f, Random.Range(-5.2f, -13.5f)),
      CardMoveSpeed * Time.deltaTime);
  }
}

But when I click on the button it moves instantly.

How can I move all of them smoothly (by using lerp)?

I read about using co-routines but I don't fully understand how to implement it in this situation.


texts: How to execute game logic every 100ms but render as fast as possible?

texts:
I have created a simple snake clone and would like to execute game logic every 100ms while rendering as fast as possible. How can I achieve this when the program might run with very different frame rates?

For example when compiling the code to a native executable I have over 1000 where I can just wait until 100ms are passed before executing the next logic step. But when compiling to asm.js I get frame rates of about 20 which means the period between two logic steps could be everything from 100ms to 149ms which would result in visible stutter (one movement is faster than another).


texts: glutPostRedisplay() does not update display

texts:
I am currently drawing a rectangle to the screen and would like to move it by using the arrow keys. However, when I press an arrow key the vertex data changes but the display does refresh to reflect these changes, even though I am calling glutPostRedisplay(). Is there something else that I must do?

My code:

#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/freeglut_ext.h>
#include <iostream>
#include "Shaders.h"
using namespace std;

const int NUM_VERTICES = 6;
const GLfloat POS_Y = -0.1;
const GLfloat NEG_Y = -0.01;

struct Vertex {
    GLfloat x;
    GLfloat y;
    Vertex() : x(0), y(0) {}
    Vertex(GLfloat givenX, GLfloat givenY) : x(givenX), y(givenY) {}
};

Vertex left_paddle[NUM_VERTICES];

void init() {
    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

    left_paddle[0] = Vertex(-0.95f, 0.95f);
    left_paddle[1] = Vertex(-0.95f,  0.0f);
    left_paddle[2] = Vertex(-0.85f,  0.95f);
    left_paddle[3] = Vertex(-0.85f,  0.95f);
    left_paddle[4] = Vertex(-0.95f,  0.0f);
    left_paddle[5] = Vertex(-0.85f,  0.0f);

    GLuint vao;
    glGenVertexArrays( 1, &vao );
    glBindVertexArray( vao );

    GLuint buffer;
    glGenBuffers(1, &buffer);
    glBindBuffer(GL_ARRAY_BUFFER, buffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(left_paddle),
        NULL, GL_STATIC_DRAW);

    GLuint program = init_shaders( "vshader.glsl", "fshader.glsl" );
    glUseProgram( program );

    GLuint loc = glGetAttribLocation( program, "vPosition" );
    glEnableVertexAttribArray( loc );
    glVertexAttribPointer( loc, 2, GL_FLOAT, GL_FALSE, 0,
                           0);

    glBindVertexArray(vao);
}

void movePaddle(Vertex* array, GLfloat change) {
    for(int i = 0; i < NUM_VERTICES; i++) {
        array[i].y = array[i].y + change;
    }
    glutPostRedisplay();
}

void special( int key, int x, int y ) {
    switch ( key ) {
    case GLUT_KEY_DOWN:
        movePaddle(left_paddle, NEG_Y);
        break;
    }
}

void display() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glutSwapBuffers();
}

int main(int argc, char **argv) {

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(500,500);
    glutCreateWindow("Rectangle");

    glewInit();
    init();

    glutDisplayFunc(display);
    glutSpecialFunc(special);

    glutMainLoop();
    return 0;

}


texts: How should I structure my menu / game loop?

texts:
I'm trying to decide on how to structure my main game loop  - every example I've seen of the game loop looks a bit like this:

while (true) {
    UpdateGame();
    DrawGame();
}

i.e. it ignores the menu.  Should my game loop look like this:

if (ShowMenu() == Play) {
    PlayGame();
}

PlayGame() {
    while (true) {
        UpdateGame();
        DrawGame();
    }
}

ShowMenu() {
    while (true) {
        HandleUserInput();
        DrawMenu();
    }
}

(I.e. the menu and game have separate loops), or should I structure my loop as such:

while (true) {
    switch (state) {
    case Menu:
        MenuLoop();
        break;
    case Game:
        GameLoop();
        break;
    }
}

GameLoop() {
    HandleUserInput();
    DrawMenu();
}

MenuLoop() {
    HandleUserInput();
    DrawMenu();
}

I.e. one big outermost loop. (or does it not really matter?)

For what its worth I'm using SDL / C (although I'd like to think that the question is language agnostic)


texts:
If all players are spawned at random positions the same distance from adjacent players, the number of players will be proportional to the likelihood of their spawn positions being unfair.  The closer players spawn to the centre of the map, the more likely they are to encounter other players and the less likely they are to survive, compared with players on the edge of the map.  Assume all players are spawned at the same time.

Is there a way to shape spawn points, or change the map, so that:

All players have a limited number of adjacent foes.
All players have equal chance of encountering adjacent foes.
Map size does not have to increase proportional to the number of players.
These limitations are not enforced with arbitrary impassable spaces.

The answer does not have to be perfect, just obviously better than the alternative.  Out of the box thinking welcome.


texts: What is the efficient way to sync TextureProgress with a Timer not in the UI?

texts:
I want to use a TextureProgress which reflects the state of a Timer.
I have tried to emit signals:

FROM: the Node2D._process() which owns the Timer with emit_signal("time_left_changed", timer.time_left)
TO: the UI

but it seems to make huge impact on performance.


texts: libGDX game crashes on Android without any mention of crash in logs

texts:
No mention of any issue in process logs, an application just turns off during loading assets (~3% of all assets loaded). It works fine on desktop.

Only thing that seems related in global logs is this:

09-01 15:15:25.261 824-22928/? W/ActivityManager: Force removing ActivityRecord{911979f u0 xxx.xxx.xxx/.AndroidLauncher t664}: app died, no saved state

I suspect there might not be enough of memory, but why there is nothing in logs? I tried limiting JVM memory on PC to 512MB and it runs fine. But I am not entirely sure if this limit covers also native memory. Could that be the reason why it runs with limit set and yet crashes on a mobile device with 2GB memory?


texts:
Basically I am working on following application of android version
Party Games: Drinking Wheel

For this I want to rotate wheel and want to stop wheel at specific point. But I want this with gradually decreasing speed. For example at start I have speed of 10 then at stop time it at 0. So wheel stop smoothly.

At presently I have working code but it stop suddenly.

registerEntityModifier(new RotationModifier(desireTime, 359f,
            desireRotation, new IEntityModifierListener() {

                @Override
                public void onModifierStarted(IModifier<IEntity> pModifier,
                        IEntity pItem) {
                }

                @Override
                public void onModifierFinished(
                        IModifier<IEntity> pModifier, IEntity pItem) {

                    mPointer.stopRotation();
                    showWindowAfterSomeTime(randomSegment);
                }
            }, EaseLinear.getInstance()));

I want some help in this. Thanks for your time.


texts:
I'm working on a few features for a strategy engine I'm making. I'm trying to figure out the best spots to separate the components, as either option will provide the same amount of coupling, with the same effectiveness.

For example, all players have a Damage component, a Player component, and a HealthBar component:

abstract class Damage
{
    protected abstract void sendDamage(Player targetPlayer, int rawDamage);
    public abstract int calculateRawDamage(Attack attackUsed);
    public abstract void receiveDamage(int rawDamage);
}

class Player
{
    List<Armor> equippedArmor;
    List<Buffs> currentBuffs;
    public Damage damageComponent;
    public List<HealthBars> healthBarComponents;
}

abstract class HealthBar //can be inherited for mana or health bar
{
    protected Color color;
    public float percent; //0.0 - 1.0
}

When a player receives damage, I need to show a red number floating up from their head, indicating the amount of damage. This can either be implemented in HealthBar, or in Damage. It fits damage better, but then healing works in the same way, and wouldn't be called from damage. I could abstract damage into something like ChangeValue, which would change mana, health, etc in any direction, or I could use the abstract HealthBar class to show this number being changed.

I'm trying to think of a general rule that would solve this and other problems, where two classes use the same function equally. This is an oversimplified version of my classes, but it makes more sense this way.

How should I handle functions, where two classes have equal use?


texts: Should I make game engines to be a good "game programmer", or is it more important to build games with Unity/Unreal?

texts:
Do I need to make game engines to be a good "game programmer" in general, or is it more important to build games with Unity/Unreal and learn coding along the way or both?

I am going into a Computer Science program and want to be a software developer, preferably in the Game Industry.

I was thinking I should learn C++ first as it is the most used in Game Development and then try to make my own Game.


texts: Unity - Particle System Shuriken - Setting particles in code with random row in texture animation?

texts:
Good day, I'm attempting to randomly generate a space scene (quite large actually) in Unity through C# code mainly. So far, I've gotten stunning results up to what image #2 will show you. However, now I'm looking to expand the look with more random particles. So, I've made a texture atlas of 8 in a vertical row, which works on the random setting if you have an emitter and the particle system is called with PS.Play();

Assigning different materials would only work on a per particle system basis(which would be new texture PER cloud, so to speak) which is not what I want. So, my question:

How can I use the Shuriken Particle System's Texture Sheet Animation functionality through code, without having an "active" particle system? More precisely, I wish to use the 'Random Row' feature of it to assign random textures to each particle.

Since I can't share my code (due to policies), here is a bit more info on how I do it:

I create an array with coordinates for each cloud.
Assign a particle system to that cloud.
Randomly generate all the particles for the cloud with relative offsets.
Use PS.setParticles(particlesArray);

Using a Texture Atlas consisting of the letters A to H to test, only B showing on all particles.

Using a Texture Atlas consisting of the fog particles to test, only 2nd showing on all particles.

Thank you @DMGregory for the help, I've tested it multiple times and it works perfectly now, I've also went ahead and tweaked a few of my settings just to get a more "clear" space:


texts: How do you draw a random irregular polygon in java? (Asteroids)

texts:
I am coding an Asteroids game in Java. In the real arcade game, asteroids are made of irregular shapes like this:

When I code, I can only set asteroids to 1 or another specific shape, like this:

I want to make all of the asteroids in my game of totally randomly generated shapes, and I am already tired of designing specific shapes of my own. Here is a snippet of my code that generates the asteroid's shape. P.S: The image does not show it, but I am using the Polygon class and constructor which only enables me to input 2 int[]s and a number of sides.

   public void makeShape() {
    int x = (int) this.x;
    int y = (int) this.y;
    this.shape = new Polygon(new int[]{x - 15, x - 30, x - 10, x - 13, x,x + 10, x + 10}, new int[]{y - 30, y - 15, y + 5, y + 30, y + 35, y + 30, y}, 7);
}

I have tried putting all of the variables on Math.random(), but it outputs nothing but a scribble, even if I were using the Polygon class.


texts: How can non-CG shader code in Unity be included?

texts: In Unity shaders, #include, #define, and other preprocessor commands seem to not be able to be used outside the CGPROGRAM section of the shader. Since these are required for compiling multiple shader variants, and a large portion of the shader is non CG, this would be incredibly useful to reduce shader duplication. Do these commands exist outside CG?


texts:
Let's say I got an object A and object B in a 2D game.
I create a vector leading from A to B. It's name is AB.

How can I make A move along the vector AB and reach B?

One way I was thinking of doing this, is calculate the angle between AB and the x axis, and then move the object every game-loop cycle in that angle, using trigonometry.

I would calculate that angle by making a new normalized vector (1,0) (the x axis), normalize AB, and then get the angle between them by getting their dot product and using arccos on it.

But is there an easier way to make an object follow the path of a vector?

EDIT:

In this question: Make objects follow a strict path (Xna), the way someone suggested to move an object along a vector, is like so:

position += direction * speed * elapsed;

Where:

position = current position of the object.
direction = a normalized vector pointing in the direction of the
destination.
speed = a scalar to decide how much to advance the object every
cycle of the game-loop. (Is this a 'scalar'? Am I using this word correctly?)
elapsed = what is this?

I get everything but elapsed. What is this? Is this necessary?

Anyhow, is this method a good method? Would you recommend it?

Thanks


texts: Profiling unity games on Android devices

texts:
I would like to profile our Unity mobile game on Android devices in a way similar to profiling Unity games on iOS with Instruments.

I am aware of how to do this using Unity's profiler, I would however like to use a third party profiler for the following reasons:

to validate Unity's profiling data
to have more visibility into how the app is running, including Unity's functions, etc.
the largest lag spikes cause unity's profiler to run out of samples. I'm however very interested in precisely these spikes
I'd like to have profile data for longer periods than unity records for
I'd like to do analysis over time (not just detailed data for each frame, but also aggregated over a time span)

Essentially I'd like as much visibility as possible to make Android on-device profiling as comprehensive as possible. As close to Instruments on iOS as possible.

So far I've tried with DDMS, but could only get visibility into Andoid OS functions and seeminly nothing in the actual apk - at least nothing I recognised. I tried with mono2x and il2cpp, with all debug features that I'm aware of in build and player settings enabled.

The game is developed with Unity 5,4 with Mono2x.

All help is appreciated. I've listed my intents above, so even if profiling on device is not possible in this way on Andoid, alternate solutions to the listed intents are still very appreciated. Thanks!


texts: Text Adventure - Engine actions based on dialogues

texts:
Building forward my text adventure i stumbled upon how to actually drive the actions that can be caused by dialogs. I wrote the dialogues and the logic around handling them already, but i'm missing a key about how to turn a dialogue into an 'engine' specific action (like spawn item, drop, buy, sell).

My game is absolutely based on JSON therefore even dialogues are stored there:

An Option is what a player can choose by typing one of the defined Keywords for currently displayed dialogue.

Response is what a player sees when option is chosen

Goto is where the dialogue goes next after an option is chosen

Script is nothing more fancy than a list of strings with integers that get mapped into a std::map<std::string,int> and later passed for the execution. Think of it as of flags.

Let's look at the example below - where you could buy something from inn keeper.

In above situation, you can talk to the keeper and choose:

"1" to buy item "1"
"2" to buy item "2"
"back" to get back to previous dialogue (with a goto)

Let's say i want to choose option "1" and it boils down to the design now.

How would you turn that "1" into a real engine action of buying an item?

What i did.

As you might have seen i have defined a Script within the option of the dialogue, this would be just a map (string to int) of attributes passed to an interpreter.

Then the interpreter executes that based on 'action_type' - which is defined in json, mandatory and describes type of action like here:

Some questions then:

1) Is it the valid approach to write my own interpreter - maybe i can use it somewhere else? or i should start thinking about external scripts - which actually require me to focus on adding library and learning it, instead of doing the game itself.

2) Which class should be really responsible for actually executing the script with the data passed from dialogue.

Dialog class itself ?

std::string CDialogue::Process(const std::vector<std::string>& rvArguments)

Npc class handling talk action ?

void CEntityNPC::HandleTalk(CEntity *pFromWho, const std::vector<std::string>& rvArguments)

Command class that handles talk command?

void CCommandTalk::Execute(CEntity *pPlayer,const std::vector<std::string>& rvArguments)

3) Maybe you can think of a different way to handle this situation? Basically a translation of a text(json) data into a game logic.


texts: Independent game developer career advice

texts:
I recently left my full-time job for an independent game development career.  So far things are going well:  I've created two games for the iPhone (one has been in the app store for a month or so and the other has been in review for about a week).  I'm working on a third game now.  Each time the game development life cycle is shorter while the product quality is higher.  However I am not yet making a living from my games.

My savings can support me for another year.  Here's my general plan:

make a few more games
in 8-9 months look for a job in the game industry (if my games are not paying the bills yet)

How would you proceed in this situation?

Perhaps you would look for a game dev job immediately.  Or you would move somewhere with a lower cost of living hence maximizing your time to work independently.  Or something else.


texts: How can I create a flexible system for tiling a 2D RPG map?

texts:
Using libgdx here.  I've just finished learning some of the basics of creating a 2D environment and using an OrthographicCamera to view it.  The tutorials I went through, however, hardcoded their tiled map in, and none made mention of how to do it any other way.  By tiled map, I mean like Final Fantasy 1, where the world map is a grid of squares, each with a different texture.

So for example, I've got a 6 tile x 6 tile map, using the following code:

Array<Tile> tiles = new Array<Tile>();

tiles.add(new Tile(new Vector2(0,5), TileType.FOREST));
tiles.add(new Tile(new Vector2(1,5), TileType.FOREST));
tiles.add(new Tile(new Vector2(2,5), TileType.FOREST));
tiles.add(new Tile(new Vector2(3,5), TileType.GRASS));
tiles.add(new Tile(new Vector2(4,5), TileType.STONE));
tiles.add(new Tile(new Vector2(5,5), TileType.STONE));

//... x5 more times.

Given the random nature of the environment, for loops don't really help as I have to start and finish a loop before I was able to do enough to make it worth setting up the loop.  I can see how a loop might be helpful for like tiling an ocean or something, but not in the above case.

The above code DOES get me my final desired output, however, if I were to decide I wanted to move a piece or swap two pieces out, oh boy, what a nightmare, even with just a 6x6 test piece, much less a 1000x1000 world map.  There must be a better way of doing this.

Someone on some post somewhere (can't find it now, of course) said to check out MapEditor.  Looks legit.  The question is, if that is the answer, how can I make something in MapEditor and have the output map plug in to a variable in my code?  I need the tiles as objects in my code, because for example, I determine whether or not a tile is can be passed through or collided with based on my TileTyle enum variable.  Are there alternative/language "native" (i.e. not using an outside tool) methods to doing this?


texts: Using raw vertex information for sprites rather than SpriteBatch in XNA

texts:
I have been wondering whether using SpriteBatch is the best option. Obviously for prototyping or small games it works well.
However, I've been wanting to apply techniques such as shaders and lighting to my game. I know you can use shaders to some extent with SpriteSortMode.Immediate, but I'm not sure if you lose power using that.

The other major thing is that you cannot store your vertex data in the graphics memory with buffers.

In summary, is there an advantage of using VertexTextureNormal (or whatever they're called) structs for vertex data for 2D sprites, or should I stick with SpriteBatch, provided I wish to use shaders?


texts: Random 2D point in rectangle, but not in a polygon

texts:
I have a static rectangle and dynamic polygon. I need to generate a random 2D point in that rectangle, but not in a polygon. This is what I mean:

Green is where random point can be generated and red is where it can't be generated. I'm not really familiar in this thing, so I ask for an algorithm. It also must be fast and efficient, because it's going to be on mobile platform and might be generated few times a second. I could check if point is in polygon, but how do I move it away from polygon to make it still "feel random"?
Thanks.
P.S. polygon will always have 4 vertices.


texts: align local Y to be parallel with global Y during or after slerp

texts:
I am using the following function to have a globe rotate a point on its surface to face the global Z toward the camera. This works fine, but after each rotation  the Y axis seen as a green line is not vertically aligned.

I believe this is how slerp between two unit vectors works, it takes the shortest path.

I would like to know how can I achieve this rotation whilst getting the globe to rotate itself so that Y is at least parallel to the global Y?

        function rotateToHub(continent){
            var speed = 2000;
            var z = new THREE.Vector3(0, 0, 1);

            point = continent.position.clone().normalize();

            var q = new THREE.Quaternion();
            q.setFromUnitVectors(point, z);

            var duration = {t: 0};
            var tween = new TWEEN.Tween(duration)
                .to({t: 1}, speed)
                .onStart(function(){
                    slerp = true;
                })
                .onUpdate(function(){
                    earthContainer.quaternion.slerp(q, this.t);
                })
                .onComplete(function(){
                    slerp = false;
                    update();
                })
                .start();
        }


texts: Disney BRDF - where is metallic factor input into BRDF?

texts:
Burley states about metallic parameter:

"This is a linear blend between two different models. ..."

What are the two models? I can't see this described in the Frostbite or the Unreal papers either.

Is it simply a blend between the diffuse and specular terms or a scaling factor on the specular term?

Disney Paper


texts: Using SurfaceFormat.Single and HLSL for GPGPU with XNA

texts:
I'm trying to implement a so-called ping-pong technique in XNA; you basically have two RenderTarget2D A and B and at each iteration you use one as texture and the other as target - and vice versa - for a quad rendered through an HLSL pixel shader.

step1: A--PS-->B
step2: B--PS-->A
step3: A--PS-->B

...

In my setup, both RenderTargets are SurfaceFormat.Single.

In my .fx file, I have a tachnique to do the update, and another to render the "current buffer" to the screen.

Before starting the "ping-pong", buffer A is filled with test data with SetData<float>(float[]) function: this seems to work properly, because if I render a quad on the screen through the "Draw" pixel shader, i do see the test data being correctly rendered.

However, if i do update buffer B, something does not function proerly and the next rendering to screen will be all black.

For debug purposes, i replaced the "Update" HLSL pixel shader with one that should simply copy buffer A into B (or B into A depending on which among "ping" and "pong" phases we are...).
From some examples i found on the net, i see that in order to correctly fetch a float value from a texture sampler from HLSL code, i should only need to care for the red channel.

So, basically the debug "Update" HLSL function is:

float4 ComputePS(float2 inPos  : TEXCOORD0) : COLOR0
{
  float v1 = tex2D(bufSampler, inPos.xy).r;
  return float4(v1,0,0,1);
}

which still doesn't work and results in a all-zeroes ouput.
Here's the "Draw" function that seems to properly display initial data:

float4 DrawPS(float2 inPos  : TEXCOORD0) : COLOR0
{
  float v1 = tex2D(bufSampler, inPos.xy).r;
  return float4(v1,v1,v1,1);
}

Now: playing around with HLSL doesn't change anything, so maybe I'm missing something on the c# side of this, so here's the infamous Update() function:

_effect.Parameters["bufTexture"].SetValue(buf[_currentBuf]);
_graphicsDevice.SetRenderTarget(buf[1 - _currentBuf]);
_graphicsDevice.Clear(Color.Black); // probably not needed since RenderTargetUsage is DiscardContents
_effect.CurrentTechnique = _computeTechnique;
_computeTechnique.Passes[0].Apply();
_quadRender.Render();
_graphicsDevice.SetRenderTarget(null);
_currentBuf = 1 - _currentBuf;

Any clue?


texts: Using A*Pathfinding on terrain created by scripts?

texts:
I'm looking to use A* Path-finding as a method of navigating my game terrain. Trouble is, my terrain is built upon play using a script and A* grid does not detect this, therefore marking all nodes as "un-walkable".

I'm wondering if anyone knows a solution for this or an alternative path finding method. I have tried enabling the terrain to spawn on edit more using ExexcuteInEditMode, but this does not seem to work either.

The terrain was generated through a fantastic guide called Procedural Terrain Tutorial.

Would greatly appreciate any help I'll be able to get.

I've attached some screenshots for clarity :


texts:
I have read this tutorial about how to mask sprites using Cocos2D 2.0. http://www.raywenderlich.com/4428/how-to-mask-a-sprite-with-cocos2d-2-0

But the author talks about OpenGL ES textures and vertices as they were common knowledge. My knowledge about OpenGl is zero raised to infinity.

All I want is to use a rectangle to mask a sprite to it. How I would do in Photoshop using a rectangle as mask (yes, I want to clip a sprite to the rectangle bounds and no, I do not want to use the ClippingNode solution, that do not works for animation/scaling etc.).

So, can you guys translate the klingon language used in this tutorial and tell how a solid rectangle can be used to mask a sprite in Cocos2D?

I am desperate, as my username states. I am searching this for a week and have tried several solutions without satisfactory results. Please help me.

Thanks!


texts:
I have a space fighter AI. I need to determine how to pitch, yaw and roll the craft to aim at the target.

My current solution:

To obtain the Yaw angle to position the target above the fighter, here are my steps:

Project the target vector onto the local XZ plane of the fighter.
Vector3.Angle(transform.forward, projectedVector)

The problem is that Vector3.Angle always return a positive angle

^ T        T ^
|/          \|
F            F

(F - Fighter, ^ - forward, T - Target)

both of these return the same angle

My current solution is to

Cross product transform.forward and targetYawVector
Dot the result against transform.up
if < 0, its one direction, where > 0 its the other. (switchable)

Same is done with roll and pitch

Issue:

This current solution does too much computation. Doing a stress test with ~300 units slows the simulation down to sub 30 FPS on a 3 year old computer. (I am assuming that players will have older computers)

Question:

Is there a better way to obtain the direction of an angle without needing to do all these?


texts: How can I detect if a gamepad stick has been pushed to the limit?

texts:
As in the question, really. I want to be able to detect if a gamepad has it's analogue input pushed as far as it can go in any direction.

Given x and y axis values in the range [-1, 1] (-1 being left and down respectively), how can I account for all of the angles between horizontal and vertical, as this means that I can't simply check if abs(axis) == 1.

As I'm unaware of how it might affect it, the engine I'm using is UE4, so any answer could take that into account.


texts: Intersecting ORCA lines finding non-optimal solution for fast units

texts:
I've decided to implement my own algorithm for optimal reciprocal collision avoidance. It doesn't use linear programming, but iteratively projecting velocity on intersections of ORCA lines and checks if it is collision-free. It works great for relatively slow units, but fast units tend to stop under certain circumstances.

The problem arises when there are two or more obstacles with the same velocity, and their velocity obstacles are intersecting with each other, and the goal velocity is inside the both velocity obstacles, and the goal velocity is close to the edges of both of the velocity obstacles rather than the truncated parts.

So, according to the ORCA lines, the closest collision-free velocity sometimes becomes not optimal, or locally optimal, which can cause a unit to slow down or go backward or even stop (when obstacles have zero velocity) while there actually exists a better collision-free velocity but is left out due to ORCA lines.

I've read some papers, but none of them mentioned such problem.
I've also tried to inspect the library which the original algorithm resides, but I was unable to understand it.
I've tried merging obstacles into single bounding obstacle, which worked when the problematic obstacles were only two, but when there were more of them, it caused a very big obstacle, which blocked the whole way the agent was supposed to use.

If anyone is familiar with the concept and can let me know how to deal with the issue, or if anyone has another idea, I'll be glad.


texts: Simulate shake, tilt and multi-touch in Unity WebGl app

texts:
I am developing a multi-platform game in Unity.
It works great on Android and also on WebGL (haven't yet checked iOS).
My problem is that in some of the levels I need to use mobile-specific actions like shake, tilt and multi-touch.
Is there any way to simulate this in a WebGL app?
Examples of what I need:
Tilt to move an object without touching the object. The idea is to "sail" the object from the top of the screen into a basket at the bottom avoiding some obstacle on the way.
Tilt to cause an object to move across the screen
Shake to cause something to break.
Multi-touch to select two objects at the same time.


texts: File Path conflicts on GitHub with Unity

texts:
I am getting file path errors when a contributor is making commitments to GitHub. All of these errors are file path related or extra white space on the same lines.

This should be something in the .gitignore, but I can seem to locate it. Has anyone had similar issue with this?


texts:
I'm looking for a tutorial about how to implement a horizontally scrolling background with various objects that auto-scrolls as your character/player moves just like various car/motorbikes games.

I'll have images for various obstacles, objects along the path. I'm concerned if I load everything on start of game. /i would want these to be loaded for visible area as the player moves (or appears to move).

Though I'm looking for a tutorial in android and I'm new to opengl, but I welcome any sort of help.


texts:
I'm using winforms with xna.
Everything's working so far except for the drawing because invalidate won't refresh the screen unless repeated. This is the initial code I had:

        protected override void Draw()
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            tileSheet.Draw(spriteBatch);
            foreach (Image img in selector)
                img.Draw(spriteBatch);
            spriteBatch.End();
        }

I placed a breakpoint and it is calling the draw method but nothing is changing on the screen but when I do this:

protected override void Draw()
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        spriteBatch.Begin();
        tileSheet.Draw(spriteBatch);
        foreach (Image img in selector)
            img.Draw(spriteBatch);
        spriteBatch.End();

        Invalidate();
    }

It works! but the problem is that everything gets frozen and it seems to get caught up in an Invalidate loop. But why does the latter work but not to former? I've been working at this for hours now and I can't understand what's going wrong :/.

I feel like it's something simple but I can't wrap my head around it.

ps. I've also tried Update and Refresh and they don't work either.


texts: Is there performance difference between OnCollisionEnter and OnTriggerEnter? I have around 12 objects all calling OnCollisionEnter when in fact OnTriggerEnter could work as well. So I wonder if the are is any difference PERFORMANCE WISE between the two


texts: Code for making Material offset follow Bone transform not exactly working

texts:
In my game, I have an Eye Bone that is constantly moving.

I'm trying to make a material attached to the eye (pupil material) move in relation to the Eye bone's transform.

This Script is indeed moving the Material's offset, but it is seemingly ignoring the offsetMultiplier bit. For instance, if I set offsetMultiplier to 0, the material offset never equals 0 but instead keeps exactly following the Bone transform numbers.

What might be the mistake here?

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

public class EyeBoneMatOffset : MonoBehaviour
{
    public Transform targetBone;
    public Material mat;
    public float offsetMultiplier = 0.0f; //0 for testing purposes

    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        //Create a vector to offset the material
        var offset = new Vector2(targetBone.transform.localRotation.eulerAngles.x * offsetMultiplier,
                                 targetBone.transform.localRotation.eulerAngles.y * offsetMultiplier);

        //Apply the offset
        mat.mainTextureOffset = offset;
    }
}

Script inspector set up:

Edit:

I'm having issues getting the Eye(Pupil) Material to correctly move with the Eye bone movement.

You can see that when I hit play, the script does get the Eye Material to Initially move, but then it is (visually) frozen instead of moving back and forth. The goal is for it to correctly Eye Track the cube.

As a sidenote, for the Eye Material's X and Y offset, the visually correct range of its pupil movement is -0.45 to +0.45 (X), and -0.45 to -0.45 (Y). So it's weird to me that the X and Y offset of the Eye Materials are shown to be moving within that range (which should be good!), yet are not actually moving visually except for when the game first starts.