texts: OpenGL rendering to multiple windows, having 1 main loop for each window

texts:
I have written a little OpenGL framework in the past year that i would like to extend to support multiple windows in the near future. I have an idea about what I would like to do but I am not sure if that is possible so far.

I a nutshell the inner working of my framework is as following:

A window is created.
A render context for that window is created.
An application deriving from an interface is created.
window.run() is called, passing the application running in the window and the render context used as parameter.

sglr::W32Window w(nCmdShow);
w.create(L"DemoApp", sglr::DISPLAY_MODE::ENUM::WINDOWED, sglr::Resolution(800, 800));

sglr::W32Rendercontext r;
r.create(w, 4, 0, sglr::CONTEXT_TYPE::ENUM::DEBUG);

TestApp app;

return w.run(app, r);

The run method on the Win32 implementation looks like following (just some of the code):

        mRunningApp->onInit();

        // start message loop
        while (1)
        {

            while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
            {

                TranslateMessage(&msg);

                DispatchMessage(&msg);
            }

            // if message is WM_QUIT, exit loop
            if (msg.message == WM_QUIT)
                break;

            mRunningApp->onUpdate(mDt);

            mRenderContext->setAsCurrent();

            mRunningApp->onRender();

            mRenderContext->disableAsCurrent();

        }

    }

What I would like to do is to create a seperate window, rendercontext and application and start a seperate main loop by calling run() just like with the first window. I already have a seperate rendercontext for each window and know about setting it active before rendering to each window.
What possible solutions would exist to do that? Just running each run() method in a seperate threads sound like a kinda naive approach to me. (I admit I already tried it with failure :D)


texts: How does Navigation Mesh path-finding work?

texts: I want to understand how navmeshes work, how to implement them and why it is better than other types of pathing systems.


texts: Where can I find animated textures for free?

texts:
I'm looking for some animated textures, especially water textures that show movement.

After a bit of searching, I could only find this list. Although those textures are certainly not bad, there are only 4 to choose from. I was wondering if there is another website with free animated textures.

For static textures, I can find hundreds of websites which offer them for free, but for animated textures, websites seem to be rare.

Does anyone know of a website that offers free animated textures?


texts:
I'm writing a custom shader in unity 5 that requires a shadowmap (not just for drawing shadows but also for different computations involving scattering particles through fog). Does anybody know how to actually get the shadow map in unity rather than just using the fallback option? That is including the actual Z buffer not just the resulting 1's and 0's.

I could also use the depth buffer from the camera but that only appears to apply to camera used by the player rather than the second one I can add to replace the light (inside the light).


texts: From where does the game engines add location of an object?

texts:
I have started making my first game( a pong game )with ruby (Gosu). I'm trying to detect the collision of two images using their location by comparing the location of the object (a ball) to another one(a player).

For example:

if  (@player.x - @ball.x).abs <=184 && (@player.y - @ball.y).abs <= 40
            @ball.vx = -@ball.vx
            @ball.vy = -@ball.vy

But my problem is that with these numbers, the ball collides near the player sometimes, even though the dimensions of the player are correct.

So my question is from where does the x values start to count? Is it from the center of gravity of the image or from the beginning of the image? (i.e When you add the image on a specific x,y,z what are these values compared to the image?


texts: How do games handle rendering Asian unicode text?

texts:
I'm currently in the process of implementing text rendering in my game engine, and I decided to utilize AngelCode's BMfont to generate font textures, and then have OpenGL render textured quads for each character.  This worked great, even when rendering every single glyph supported by FreeFont (FreeMono in particular), until I tried to render Japanese (My Japanese font of choice is Noto, provided by Google).

Rendering every single glyph supported by FreeMono at 16px resulted in a single 1024x1024 8bit texture, perfectly reasonable considering how many languages are covered by it.  Rendering everything supported by Noto Japanese, at the same size, resulted in 13 times as many textures, and at this size most of the glyphs are too cramped to be readable (I can't read Japanese, but if I could I think I would still have a lot of trouble reading this text).

My question is twofold:

1) How do games, or mobile apps, handle small Japanese text?  Do they stick to a subset of the kanji, use a special font, or is there a minimum font size?

2) How do games typically handle the absurdly massive number of glyphs required by Japanese, Chinese, Korean, and other languages?  Do they use FreeType (or something similar) to render the text on-the-fly?

Note:  I tried Meiryo (which I do not have the license to use in my game) and the result was far more readable at 16px (still cramped though), but still required 14 textures to fit everything.


texts:
Possible Duplicate:
  Pseudo-code examples of A*?

Hey guys Iam making a TD game and now I am stucked in implementing A star algo. I know there are many 3d party softwares but they are difficult to understand and modify. I want to make own for my game. I need a step wise programming tutorial for implementing A* OR if someone has basic snippet. I am using unity and c#.


texts:
When I call SceneManager.LoadScene() it will set the loaded scene as active.  Can I load scenes at the game startup and just call SceneManager.SetActiveScene() during gameplay?

If so, is there a way to iterate through all the scenes in the Build Settings and load them?  Mine don't have a build index assigned to them until I have called LoadScene().


texts: How to make an EditorGUILayout.TextField accept multi-line input in a custom inspector

texts:
In a regular inspector:

[TextArea(4, 100)] [SerializeField] private string message;

Will expand a text field and let it accept multiple lines, with enter as opposed to needing \n. One the other hand:

script.message = EditorGUILayout.TextField("Message: ", script.message, GUILayout.Height(80));

Will also expand the text field, but does not allow for multiple line input. How can I get my custom inspector to behave the same way as the regular one and accept multi-line input?


texts:
I have some instanced geometry (basic tube meshes) laid out in a grid, and I have a noise texture (normal map) that I want to use to rotate my instances with.
So head pixel in my texture is a normal and I want to rotate each instance with the corresponding normal in a shader. How can I achieve that in a shader only?
Unless I am mistaking, there should only be a rotation around the X and Z axes.


texts: How to make the image move forward properly when rotated in my HTML5 game?

texts:
I am just trying to make a simple 2D racing game using canvas. It uses the W,S,A, D keys to move the car.  The W key should take me forward and the A and D keys will turn each way. I want the car to continue heading forward after being turned.  I am currently just multiplying the distance to move by the sin or cosine of the angle in order to find the x and y positions, but it is not reacting how I would expect. Thanks.

<!DOCTYPE html>
<head>
  <meta charset="UTF-8" />
  <title></title>
</head>
<body>
<canvas id="canvas_layer_01" width="3072" height="2048" style="border:1px solid #000000;">></canvas>

<script>
  var canvas = document.getElementById("canvas_layer_01");
  ctx = canvas.getContext("2d");

  car_image = new Image();
  car_image.src = 'http://i.imgur.com/Bl2p5KI.png';

  var key_pressed_a = false,
    key_pressed_d = false,
    key_pressed_w = false,
    key_pressed_s = false;

  var player_x = 50,
    player_y = 50,
    player_speed = 10,
    player_angle = 0,
    max_turn_angle = 10; // probably needs to change based on speed

  document.addEventListener("keydown", function(e){
    switch(e.keyCode){
      case 87:
        key_pressed_w = true;
        break;

      case 83:
        key_pressed_s = true;
        break;

      case 65:
        key_pressed_a = true;
        break;

      case 68:
        key_pressed_d = true;
        break;
    }
  }, false);

  document.addEventListener("keyup", function(e) {
    switch(e.keyCode) {
      case 87:
        key_pressed_w = false;
        break;

      case 83:
        key_pressed_s =false;
        break;

      case 65:
        key_pressed_a = false;
        break;

      case 68:
        key_pressed_d =false;
        break;
    }
  }, false);

  window.requestAnimFrame = (function(callback) {
    return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
      function(callback) {
        window.setTimeout(callback, 1000/60);
      };
  })();

  // http://stackoverflow.com/a/16546061/6716639
  function render_image(img, x, y, width, height, degrees) {

    //Convert degrees to radian
    var rad = degrees * Math.PI / 180;

    //Set the origin to the center of the image
    ctx.translate(x + width / 2, y + height / 2);

    //Rotate the canvas around the origin
    ctx.rotate(rad);

    //draw the image
    ctx.drawImage(img,width / 2 * (-1),height / 2 * (-1),width,height);

    //reset the canvas
    ctx.rotate(rad * ( -1 ) );
    ctx.translate((x + width / 2) * (-1), (y + height / 2) * (-1));
  }

  function updateGame() {

    if(key_pressed_w) {
      player_x += player_speed * Math.sin(player_angle);
      player_y += player_speed * Math.cos(player_angle);
    }
    else if(key_pressed_s) {
      player_y += player_speed;
    }
    else if(key_pressed_a) {
      player_angle -= max_turn_angle;
    }
    else if(key_pressed_d) {
      player_angle += max_turn_angle;
    }

    ctx.clearRect(0, 0, canvas.width, canvas.height);

    render_image(car_image, player_x, player_y, car_image.width, car_image.height, player_angle);

    requestAnimFrame(function() {
      updateGame();
    });
  }

  updateGame();

</script>

</body>
</html>


texts: How to compute the points of a CollisionPolygon2D?

texts:
Godot v3.3.1.stable.mono.official

I am trying to draw a CollisionPolygon2D programmatically but I cannot resize or write the PoolVector2Array property called polygon:
extends CollisionPolygon2D

func _ready() -> void:
    polygon.resize(1)
    print(polygon.size())
    polygon[0] = Vector2.ZERO

This code prints 0 and throws an error: Invalid set index '0' (on base: 'PoolVector2Array') with value of type 'Vector2'.


texts:
I'm making a game like Minecraft. I have a world made of blocks and I'm trying to implement a basic physic system that applies gravity and checks entities colliding with the blocks of the world.

I tried using Bresenham's algorithm, on player move, to get all blocks between, and then get the first solid and set the player on colliding position. That works well if the player is a point, but if it's a complex AABB and the block too, it becomes difficult.

Is there a simple way to make physic in a voxel world like Minecraft?


texts: How can I change a variable value in specific time duration according to animation clip time length?

texts:
I will change my question with more details to make it more clear:

In the Assets I created Animator Controller and Animation: Named them both FPSController. FPSController is the object I want to animate it's rotation on the Z from 50 to 0:

Then I opened the Animator window and dragged the Animation into the Animator window:

Then I opened the Animation window and recorded the clip: The rotation on Z is going from 50 to 0 in 7 seconds. I'm rotating the FPSController on the Z from 50 to 0:

This is the Animation part and this is working fine. The FPSController(player) is starting when the Z rotation value is at 50 and slowly move to 0.

Now The game is start when the whole camera is blurry. For this I'm using Post Processing. Next step was to create a profile of the Post Processing called it CC and this profile I dragged in the Hierarchy to the FPSCamera:

In the FPSCamera I dragged to it a script name Post Processing Behaviour and then dragged to the script in the Inspector the CC profile: This way the Post Processing effects affecting the camera view:

So to make it clear: I'm rotating on the Z the FPSController by animation. And on the FPSCamera I'm using the Post Processing for making effects.

This is how the game start. This is the game view screenshot. The game start when everything is blurry and the FPSController(player) is rotating to the right by 50 degrees:

Now the part of the animation of rotating the FPSController by 50 is working fine. While it's rotating the FPSController I want slowly by the same time in this case 7 seconds to change the blurry effect and make the picture clear once the animation end. The property of the  Post Processing CC profile I need to change is the focalLength. By default I start it with the value of 300. And I need in 7 seconds to change it from 300 to 0.

This is the script I ended with so far:
The script is attached to the FPSCamera:

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

public class DOFControl : MonoBehaviour
{
    public PostProcessingProfile postProcProf;

    public Animator anim;
    private float clipLength;

    private void Start()
    {
        AnimationClip[] clips = anim.runtimeAnimatorController.animationClips;
        foreach (AnimationClip clip in clips)
        {
            clipLength = clip.length;
        }

        InvokeRepeating("incrementSpeed", 300, 0.1f);
    }

    void incrementSpeed()
    {
        var dof = postProcProf.depthOfField.settings;
        dof.focalLength -= 1f;
        postProcProf.depthOfField.settings = dof;
    }
}

I'm getting the animation clip time length 7 seconds. But the part with the InvokeRepeating is not working. I want to incrementSpeed the focalLength down from 300 to 0 by 7 seconds. Not sure if using InvokeRepeating is the right way at all.


texts: Camera is centered on character, but doesn't show character in game window

texts:
I'm using Unity 4.6.3. I create an animation from sprite. When I press Play button, I see animation plays on scene window, but on Game Window, I don't see anything.

Here is Inspector for main camera:

Here is Inspector for Player:

I have checked that both z = 0 when execute. Please tell me which part I config wrong ?


texts: MMOFPS Choosing protocol for high-traffic network (UDP or TCP)?

texts:
my question about the player position sender protocol. In this article, he says "Never use TCP for networking a multiplayer game". Ok but UDP datas are not ordered. In this case, if somebody walking, his position will be received and sent to other players. While walking other players can see the player's NPC teleporting like movement. Some positions will be incorrect. Otherwise TCP isn't suitable, I agree but how can we use UDP? (UDP reliability?)

  EDIT (Question): There is an other problem. If player1 send his data to server this data can be lost. Otherwise if data received by
  server, server will send it back to other clients. In this case some
  datas can be lost again. Namely UDP creates an undefined position
  update (namely everybody -clients- can see player at different
  positions). What can we do about that?

EDIT: Oh, I'll use TCP for login-room like request because they are important (must be reliable) datas. There is no problem about this.

EDIT2: I don't know how can I use UDP for player positions.


texts: Using 2D Heightmap Data to generate terrain with the Marching Cubes Algorithm

texts:
The Marching Cubes (MC) algorithm works by taking 8 points of a cube with different density values and converting them into vertices and triangles based on a given iso level (threshold above which is considered solid area). It can create quite a smooth result. For example the following picture shows MC generating polygons using a 3D noise perlin function.

However 3D perlin noise is not very useful for generating terrain. 2D perlin noise is much better. One could use the following function to generate the density values at each corner of each cube sent through the marching cubes algorithm with an iso level of 0:

float IsoValue(Vector3 pos) {
    float gap = maxHeight - minHeight;
    float perlin = (Mathf.PerlinNoise(pos.x * frequency, pos.z * frequency) * gap) + minHeight;
    if(pos.y > perlin) {
        return -1f;
    }
    else {
        return 1f;
    }
}

It produces a jagged-looking result:

This is because unlike the 3d-noise function, the density values go straight from 0 to 1, and MC always generates vertices along a grid instead of at different heights in between the grid. How do I modify the above IsoValue function to not always give values between 0 and 1 (to make smoother looking terrain) depending on how close the generated noise is to the grid?


texts: Lost on OpenGL versions, which to start?

texts:
I was reading about OpenGL, and found out the Red Book is a great book for me to read to learn. I then read that even though they have 3.x and 4.x versions, I should still stick to 2.x so I don't create an artificial limit on who can play my game (older computers with older but powerful graphics cards would not be able to run 3.x and 4.x GL software).

So where do I start? I'm lost. Which book? I have no problem reading the 2.x version of the Red Book, which I believe is this one: http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321335732/ref=sr_1_2?ie=UTF8&qid=1290869828&sr=8-2
but I won't know whats deprecated :(

cry for help


texts: Turn a single player game into multiplayer game

texts:
hobbyist / indie dev here and I was wondering about network programming and making a game capable of multiplayer.

So basically I just haven't touched on network programming yet and really don't know much and have very little experience with coding multiplayer games. So with that in mind I have a project I want to make and I have all the key points pretty much on paper and a clear vision of what I want to make, I am also going to end up recruiting help (for such things as multiplayer capability more than likely as well as other aspects) since this is outside the scope of my ability to do alone.

I do not plan on having this game hosted by a central server I control and am leaning heavily on the side off a type of p2p connection like minecraft / starbound / terraria (I think those are p2p anyway) with that in mind is it extremely important that I code / build the game with multiplayer from the ground up or might I be able to work on other systems first such as game mechanics and the procedural world creation first and might it be easy to basically create a multiplayer system ontop of the game?

I guess the question is kind of broad but what it boils down to is might it be critical to focus on the networking / multiplayer first or is it a safe and(or) common practice to implement it later in development?


texts: I have 4 buttons, which on clicking,all of them does the same thing (each displays a different string read from an array to the button's text field). I want to have a single OnClick function to keep my code clean, instead of having 4 different functions for 4 different buttons. But I need to determine which button was pressed, How to do that inside OnClick Function?


texts: Optimizing HTML5 canvas transformed drawing in Javascript

texts:
I am trying to optimize my HTML5 game engine and have noticed that currently a majority of the time taken in the game loop can be taken when drawing transformed tiles.  I think this is because each transformed tile saves the state of the canvas, applies a transform, draws the tile, then restores the state of the canvas.  Fortunately I have (at least) 2 classes of tiles, and if I am only drawing un-transformed tiles, the game runs quite smoothly.  Take a look:

Slow with transformed tiles in the background: http://sgdk2.enigmadream.com/ben/JavaSampleo.html
Faster with no transformed tiles in the background:
http://sgdk2.enigmadream.com/ben/JavaSample.html

Sure you could say that drawing the extra tiles alone is responsible, but I have used Chrome profiling to confirm that XFrame (transformed frame) is consuming more than 50% of the time.  So here's the drawing code for XFrame:

XFrame.prototype.draw = function(ctx, x, y) {
   ctx.save();
   ctx.transform(this.m11, this.m12, this.m21, this.m22, this.dx+x, this.dy+y);
   ctx.drawImage(this.imageSource, (this.cellIndex % this.graphicSheet.columns) * this.graphicSheet.cellWidth,
      Math.floor(this.cellIndex / this.graphicSheet.columns) * this.graphicSheet.cellHeight,
      this.graphicSheet.cellWidth, this.graphicSheet.cellHeight, 0, 0, this.graphicSheet.cellWidth, this.graphicSheet.cellHeight);
   ctx.restore();
};

Now one thing I can imagine improving this is if I could determine that many of the tiles I was drawing were using the same transformation, and make the single transform span the drawing of many tiles.  It would be a challenge given my current design, but I might be up to it if it would make a difference.  However that is of little use because the position of the tile has to become part of the transformation if I want the location of the tile to be excluded from the transform operation, I think.  For example, if I want to draw a tile rotated 90 degrees at a coordinate of 64,32, I can't simply apply the rotation matrix and then draw at those coordinates because 64,32 will get transformed to something like 32, -64 (right).  So I have to apply the offset as part of the transform for all transformed drawing operations.  And since each tile is drawn at a different location, that means a different transform for each tile.

Any suggestions for optimizing tile drawing operations where transformations may be applied at the tile level in real time?


texts: Is it possible to compile an android game for pc desktop?

texts: If I have an android game based on java native libraries. Is it to possible to compile into a windows/linux executable without a 3rd party emulator?


texts: unity JsonUtility.ToJson returns empty string

texts:
I am trying to use Unity's built in json serialization.  It produces empty string.   I do not understand why.  (I was trying to use NewtonSoft Json.Net but that wasn't working either even though I was following instructions).

Here's the serialization code:

public class Player : MonoBehaviour
{
    void Start ()
    {

        Mission a = new Mission()
        {
            Id = 1,
            Name = "Speak to the Farmer",
            State = MissionState.OnGoing,
            Parent = -1,
            Type = MissionType.Main
        };

        string json = JsonUtility.ToJson(a);
        System.IO.File.WriteAllText("missions2.json", json);
    }
}

Here's the Mission class:

[Serializable]
public enum MissionState
{
    NotStarted,
    OnGoing,
    Finished
}

[Serializable]
public enum MissionType
{
    Main,
    Sideline
}

[Serializable]
public class Mission
{
    public Mission()
    {
        Parent = -1;
    }

    public int Parent { get; set; }
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public MissionState State { get; set; }
    public MissionType Type { get; set; }
}

here's the output:
{}

There are no exceptions thrown.  The file missions2.json is created.  But the data is as shown above.  What is wrong that the serialization produces nothing?

Thnx
Matt


texts:
I'm working on my own quadtree for use in games for physics (collision detection to be exact) but am unable to move an object from one node to another node.

What I'm doing is if some object is to be moved, I'm deleting it from its old position and adding a new object (with same property, such as width and height) to the new position. Is my approach correct or is there any other optimized process to do same?

The problem I'm facing is that if I move an object from node 0 to node 3 (both node being children of, for ex., root node) the root node container(I'm using std::vector) gets the object but it is not updated in the node 3's container.

Any solution to my problem? Though would be happy to try some other method too.

Thanks.


texts:
I am working out a concept of a game where I want to refer to movies. However, I am unsure if I can just refer to the real movie titles in the game or if I should change them slightly so that it becomes a parody of the movie for liablility / copyright reasons.

I know it is a bit on the risky side when you are using brands etc, but can I be held acountable for indirect damage to the sales of their movie?

Does this change when I use an API from a website (f.e. imdb / TheMovieDatabase)?


texts: Bounding box of a rotated rectangle (2d)

texts:
I can see this has been asked before in various ways. I am struggling to work it out though hence asking again.

2d sprite that moves and rotates. I'm looking to contain it in a bounding box as it appears that is the most efficient way to do collision detection.

I had no problems getting it to work without rotation but that is simple! Now the sprite rotates I can't seem to find the right way of writing the code.

To create a bounding box for the sprite, my understanding is I need to work out the 4 corners of the sprite after rotation and use these to work out the width + height of the correctly sized bounding box.

I've used the article here - http://msdn.microsoft.com/en-us/library/dd162943(v=vs.85).aspx - specifically the formula:

x' = (x * cos A) - (y * sin A)
y' = (x * sin A) + (y * cos A)

The code I'm currently using:

x1 = (positionX * Math.cos(rotation)) - (positionY * Math.sin(rotation));
y1 = (positionX * Math.sin(rotation)) + (positionY * Math.cos(rotation));

x2 = (positionX+width/2 * Math.cos(rotation)) - (positionY+height/2 * Math.sin(rotation));
y2 = (positionX+width/2 * Math.sin(rotation)) + (positionY+height/2 * Math.cos(rotation));

positionX and positionY is the current top left hand corner position of the sprite.

rotation is the radians the sprite has been rotated by (and rotation is from the centre).

width and height are of the sprite.

I thought the code above would give me the co-ordinates of the top left and top right corners of the rectangle, rotated appropriately. However, on my canvas, I'm drawing a line from x1,y1 to x2,y2 and it doesn't follow the sprite at all!

Any suggestions? Sorry for the long post!

Cheers!


texts:
I want to convert rotations given as quaternion from sensors to Unity. The sensors (documentation here) axis are the following ones:

Unity is the following one:

I don't know how to map axis other than Z is up for the axis. Note that I don't really mind if I have a global rotation offset. I just want the sensors (they are multiple ones) relative orientation to be the same in Unity that in real life

Given this other answer I think the following code should to the transformation:

Quaternion ConvertToUnity(Quaternion input) {
    return new Quaternion(
        -input.y,
        -input.z,
        -input.x,
        input.w
    );
}

Is that correct?


texts: How to calculate score in my game based on playtime and coins picked?

texts:
I've been trying to figure out a way to calculate the score in my game.... but nothing seems to work properly...

The score is to be calculated according to:

playtime
coins collected.

The playtime should be as low as possible and number of coins should be as high as possible.

For example:
Let's say an idle play for a level X has:

playtime = 15 seconds
coins = 20.

The score is 100.

Then what will be the score when the:

playtime = 20 seconds
coins = 14.

P.S.: Pardon me if the example is wrong but I can't figure out how to explain my problem...
Thanks in advance.


texts: Entity systems with mixed responsibilities (eg render + handle input)

texts:
I am using an entity system for my hobby game, specifically the Behaviour / Attribute model discussed in Radical Entertainment's Theory and Practice of Game Object Component Architecture presentation.

I have read discussions of this model here and here and I believe I understand it except for a specific case:

Say I am developing a top-down game that has has multiple units (entities) on screen. Each unit can be selected, which outlines the unit with a green box. Think Starcraft, where you can select units and then issue an order.

At the moment I have the classic RenderBehaviour which simply draws the entity. I now want to add a SelectableBehaviour. The SelectableBehaviour will have "logic" responsibilities such as ensuring the unit can be selected, deselecting the unit under certain circumstances (death events), etc.

My problem, essentially, is who is responsible for drawing the green outline around the unit when it is selected - the render behaviour, or the selectable behaviour?

I am trying to follow what the presentation says, which is that Behaviours should be very generic in their responsibilities. If possible I do not want to add code into the RenderBehaviour that says "if entity has selectable behaviour" because now my behaviour is no longer generic - in fact, this exact scenario is mentioned on slide 16 of the presentation (but it just says "don't do it").

I am basically being mindful of mixing "presentation with logic". The only thing I can think of at the moment is to have another behaviour that is responsible for rendering the select box.

I understand there are no hard and fast rules regarding entity systems but I am curious to hear how this can be handled neatly.


texts:
I'm seeing a lot of Modern Warfare (the first one) mods out there, and I've come across at least one post that says that Activision released official modding tools for CoD4, but I can't seem to find them, or any reference to them on official websites.

Have official tools been released? Or are all these modding tools the result of reverse engineering and clever hacking, ala Diablo 2? I'm interested in getting into modding myself, I used to do Duke3D maps with the Build engine back in the day, even had a book on it, and it'd be great if I could do


texts: Should I be using spritesheets, because of or despite of my vast number of images?

texts:
I am developing a 2D game, and I have a lot of sprites. I used 3D animations and models to render into 2D, to give them that "Fallout" or "Diablo" look to them. It is also easier than drawing by hand, lol.

I have already had to cut the framerate down to 15fps, which was the lowest I could lower without making them have a choppy look to them. However, it was sad due to how incredibly smooth 24 frames looked.

There are two reasons I did this:

1) Cut down on HDD space. The fewer the images, the smaller my total game will be.

2) Cut down on RAM consumption. The fewer images to load, the more likely I am to avoid issues bloating my RAM limitation.

However, if there was a way to compress the images in both HDD space and RAM, I would do so. I have tested it before, and most do not receive any change in quality when giving from RGBA8888 to RGBA5555 and only a little hit when converting to RGBA4444 in my TexturePacker program. I do not do this currently, because SFML seems to use the same amount of memory regardless of which type of .PNG image it is. I looked into researching how to load it differently, but failed to find anything on the subject.

I have read a lot about how to handle 2D video games. The consensus is overwhelming: Pack your Sprites into a Bigger Texture for great performance! So I pack my tiny sprites into a much larger spritesheet using TexturePacker.

However, I plan to have 10-15 animations per character, 5 directions to move, and 15-40 frames per animation (probably an average of 24). With 15 animations, 5 directions, and an average of 24 frames per animation; That is 1800 individual frames per character.
If packed in a sprite sheet, that is only 75 images instead. (One sprite sheet per Animation, per Direction. 15 * 5)

For the one huge boss character in the game, I cannot use a spritesheet and have to program a way to simply load in one image at a time. I do not know if I can do this for performance yet.

For the characters, I already pack them in a spritesheet. For a single character walking about, this seems to work most of the time, although sometimes it stalls. However, I attribute that to my ill conceived code that swaps out textures instead of preloading all textures for that character.

If I were to preload the textures, it makes sense for sprite sheets. I would only imagine it's a bad idea to preload 1800 tiny images for each character.

However, I imagine streaming them into and out of memory one at a time would be extremely fast, so I would only need to have a single image in memory at one time. Wouldn't this mean that at any given moment I would only have each character consume a few KB instead of 45+MB?

I imagine this would kill my performance, as streaming would need to be incredibly fast (15 images going into and out of memory and rendering, per second) and although the images would be very small- it might be a better idea to load character spritesheets into memory instead. But I will have to code a single-image stream-like render system for my larger boss character anyway.

I have been experimenting, but it is not a simple process. Especially given the fact I am working on other parts of the game engine that do not deal with graphics right now.


texts:
Since this wasn't clear enough, I've removed even more code. It kind of defeats the purpose I was aiming for, but I guess getting any answer relevant to the problem is better than none.

What I want: A cube to leave the ground with N velocity in the negative x direction, then gravity pulls it back down.

THE SETUP:

void Start () {
    rb = GetComponent<Rigidbody>();
}

void Update() {

    //Jump
    if (Input.GetKeyDown("space"))
    {
        jump = true;
    }
}

TEST 1 (I really thought this should work as it was the solution I saw in so many google results)

void FixedUpdate()
{
    if (jump)
    {
        rb.AddForce(new Vector3(0, 0, -5000f));
        jump = false;
    }
}

TEST 2 (Added ForceMode.VelocityChange)

void FixedUpdate()
{
    if (jump)
    {
        rb.AddForce(new Vector3(0, 0, -5000f), ForceMode.VelocityChange);
        jump = false;
    }
}

TEST 3 (Tried other ForceModes)

void FixedUpdate()
{
    if (jump)
    {
        rb.AddForce(new Vector3(0, 0, -5000f), ForceMode./*INSERT OTHER ForceModes*/);
        jump = false;
    }
}

TEST 4 ( I know, changing velocity directly is a bad thing, but seeing as what I want is the cube to move upwards at a certain speed, it made sense to try it )

void FixedUpdate()
{
    if (jump)
    {
        var vel = rb.velocity;
        vel.z += -5000f;
        rb.velocity = vel;
        jump = false;
    }
}

It's been a long day, I'm sure I left some other attempts out.

Can someone explain to me why the cube is teleporting from Z=0 to Z= -2 (or some other value depending on the magnitude of the force)?

I can understand if it was something having to do with impact force not having enough time to change the velocity, but then why did the position change so drastically? And why didn't changing the velocity work, even though I know that is a bad way to go about it?


texts: Why are these unity UI buttons only responding to the top half?

texts:
I'm instantiating UI objects with buttons on them into a scrollrect.  For some reason, all of the buttons will ignore their bottom half with the exception of the last prefab instantiated.  Below is a gif to show the problem. I have it set to turn red when the button is highlighted.  When the mouse isn't in a highlight position clicking will do nothing so I know it's not just a highlighting issue.

Here is the code that I'm using to instantiate the scene.

    //Instantiate the parent UI
    MyLoadGUI = (GameObject)Instantiate(LoadGUI);

    //Get the RectTransform of the scroll rect so I can add each level to the right thing.
    RectTransform[] rt = MyLoadGUI.GetComponentsInChildren<RectTransform>();
    RectTransform myRt = new RectTransform();
    for (int i = 0; i < rt.Length; i++)
    {
        if (rt[i].name == "Scroll Panel")
        {
            myRt = rt[i];
            break;
        }

    }
    //We're going to make 6 fake levels
    int levelCount = 6;
    int levelSize = 88; //How tall the levels are

    int height = Mathf.Max(levelSize * levelCount, 252);

    myRt.sizeDelta = new Vector2(myRt.sizeDelta.x, height);
    myRt.anchoredPosition = new Vector2(myRt.anchoredPosition.x, -height);

    for (int i = 0; i < levelCount; i++)
    {
        GameObject lsl = (GameObject)Instantiate(LoadSingleGUI);
        RectTransform rect = lsl.GetComponent<RectTransform>();
        rect.SetParent(myRt, false);
        rect.anchoredPosition = new Vector2(0, -37 - (i * levelSize));

        //Fill in fake details.  Doesn't run anything related to the button.
        lsl.GetComponent<LoadLevelBar>().BuildRandom();
    }

So, nothing that should be affecting the button that I can see.  I thought that the button was getting resized, but when checking in the scene the button is stretched all the way across the prefab.  Any ideas why the button isn't working properly?


texts: How do I compile Half Life 1 for Windows?

texts:
I want to compile the "Half Life 1" source code, but I don't have Visual Studio 6 or 2002 or 2003. There are a few projects which have ported the code to Visual Studio 2008, but they don't work. How do I compile it for Windows?

I am new to the game development scene; I know I probably shouldn't be jumping into something so advanced, but I want a fun project. If any one could point me in the right direction, that would be great!


texts: Ordering vertices of a face for correct triangle definition

texts:
I'm trying to ascertain the appropriate order of vertices for the face of a mesh that is programmatically created.  Currently the face is always a quadrangle, but eventually a face can consist of any number of vertices ≥3.  What I have are the Vector3 of the vertices, the Vector3 of the normal, and the Vector3 of both up and left.  Because these faces can have any rotation, they are not guaranteed to be (and will rarely be) completely perpendicular to any of the three primary axes.

I've looked at using dot products and matrices to try to remap them to a 2D coordinate system, but I could not quite get it right, and that rotation could also be problematic for faces on the "top" and "bottom" of a mesh.

As it is, I'm trying to find a formula that would use the vertices, the normal, up, and left to (in the case of a quadrangle) start with the upper-leftmost vertex if facing it from the normal direction and work clockwise from there.  I could use the ordered vertices to properly build triangles that would suit the normal and display properly.

I'm not bad with math, per se, but vector mathematics are outside of my comfort zone, which is in part why I'm going through this exercise.

TL;DR, I have a cube which is transformed and rotated randomly in 3D world space.  I've captured each face into an object that contains the vertices, normal, up, and left direction (normal for the face, up and left as far as the GameObject itself is concerned) and want to order the vertices for triangle mapping for the mesh.


texts:
I'm working on a game with maps that resemble lock and key puzzles. The AI needs to navigate to a goal that may be behind a locked red door, but the red key may be behind a locked blue door, and so on...
This puzzle is similar to a Zelda-style dungeon, like this picture:

To get to the Goal, you must defeat the Boss, which requires going over the pit, which requires collecting the Feather, which requires collecting the Key

Zelda dungeons tend to be linear. However, I need to solve the problem in the general case. So:

The goal could require one of a set of keys. So maybe you need to get either the red key or the blue key. Or there could be an unlocked door the long way around!
There could be multiple doors and keys of a kind. E.g. there could be multiple red keys in the map, and collecting one will grant access to all the red doors.
The goal may be inaccessible because the right keys are behind locked doors

How would I perform pathfinding on such a map? What would the search graph look like?
Note: the last point about detecting inaccessible goals is important; A*, for example, is extremely inefficient if the goal is inaccessible. I would like to deal with this efficiently.
Assume that the AI knows where everything is on the map.


texts: Calculate 2D tile map tiles within a "field of view" cone

texts:
I need to calculate which tiles make up a "cone", originating at my player and extending outward for a specific tile distance.

My player can only face North, South, East, West and I'm not sure yet on the angles I'll use for the cone.

I've found several posts/articles already covering this but they're trying to determine visibility and are a lot more complex than I need. I'm not lighting a room or calculating shadows/occlusions.


texts: Using Farseer Physics, how can I get objects to bounce at the correct angle

texts:
I am using the Farseer Physics engine in my MonoGame project. I have static walls which have "body" friction 0 and "body" restitution 1. I have dynamic objects, which are circles, with "body" friction 0 and "body" restitution 1. There is no gravity.

When I launch a dynamic object at a wall, it does not bounce in the way I would expect for a perfectly elastic, frictionless collision. The angle it bounces at should be the reflection (through the wall's normal vector) of the angle it arrives at.

Instead, the dynamic objects often slide along the wall:

In the diagram, the black line is the wall; the blue line is the desired path of the dynamic object; and the orange line is the current path of the dynamic object.

How can I make my dynamic objects bounce properly?


texts: OpenGL [LWJGL3] - Matrix4x4 not rotating correctly

texts:
I tried today to make my own matrix4f class because of that LWJGL 3 does not include a class for it. So I arrived at rotation and it does not seem to work. I tried using the old util from LWJGL 2 and then it worked fine. Here's a screenshot of how it looks like.

Here's a gif animation of how it looks.
It's supposed to be a cube but as you can see it stretches when it rotates. Not only the x axis but the y and z axis to.
Here's the code:

public Matrix4f rotate(Vector3f rotation) {
    Matrix4f xRotation = new Matrix4f();
    xRotation.setIdentity();

    float x = rotation.x;
    float y = rotation.y;
    float z = rotation.z;

    xRotation.m11 = (float) cos(x);
    xRotation.m21 = (float) -sin(x);

    xRotation.m12 = (float) sin(x);
    xRotation.m22 = (float) cos(x);

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

    yRotation.m00 = (float) cos(y);
    yRotation.m20 = (float) sin(y);

    yRotation.m02 = (float) -sin(y);
    yRotation.m22 = (float) cos(y);

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

    zRotation.m00 = (float) cos(z);
    zRotation.m10 = (float) -sin(z);

    zRotation.m01 = (float) -sin(z);
    zRotation.m11 = (float) cos(z);

    return multilpy(xRotation).multilpy(yRotation).multilpy(zRotation);
}

Can someone point the problem because I cannot find it.

Edit:
The multiplication and the projection code:

public Matrix4f multilpy(Matrix4f matrix) {
    // Row 0
    m00 = m00 * matrix.m00 + m10 * matrix.m01 + m20 * matrix.m02 + m30 * matrix.m03;
    m10 = m00 * matrix.m10 + m10 * matrix.m11 + m20 * matrix.m12 + m30 * matrix.m13;
    m20 = m00 * matrix.m20 + m10 * matrix.m21 + m20 * matrix.m22 + m30 * matrix.m23;
    m30 = m00 * matrix.m30 + m10 * matrix.m31 + m20 * matrix.m32 + m30 * matrix.m33;

    // Row 1
    m01 = m01 * matrix.m00 + m11 * matrix.m01 + m21 * matrix.m02 + m31 * matrix.m03;
    m11 = m01 * matrix.m10 + m11 * matrix.m11 + m21 * matrix.m12 + m31 * matrix.m13;
    m21 = m01 * matrix.m20 + m11 * matrix.m21 + m21 * matrix.m22 + m31 * matrix.m23;
    m31 = m01 * matrix.m30 + m11 * matrix.m31 + m21 * matrix.m32 + m31 * matrix.m33;

    // Row 2
    m02 = m02 * matrix.m00 + m12 * matrix.m01 + m22 * matrix.m02 + m32 * matrix.m03;
    m12 = m02 * matrix.m10 + m12 * matrix.m11 + m22 * matrix.m12 + m32 * matrix.m13;
    m22 = m02 * matrix.m20 + m12 * matrix.m21 + m22 * matrix.m22 + m32 * matrix.m23;
    m32 = m02 * matrix.m30 + m12 * matrix.m31 + m22 * matrix.m32 + m32 * matrix.m33;

    // Row 3
    m03 = m03 * matrix.m00 + m13 * matrix.m01 + m23 * matrix.m02 + m33 * matrix.m03;
    m13 = m03 * matrix.m10 + m13 * matrix.m11 + m23 * matrix.m12 + m33 * matrix.m13;
    m23 = m03 * matrix.m20 + m13 * matrix.m21 + m23 * matrix.m22 + m33 * matrix.m23;
    m33 = m03 * matrix.m30 + m13 * matrix.m31 + m23 * matrix.m32 + m33 *    matrix.m33;

    return this;
}

public static Matrix4f perspective(int width, int height, int fov, float zFar, float zNear) {
    Matrix4f matrix = new Matrix4f();

    float aspectRatio = (float) width / (float) height;
    float fovY = (float) ((1f / tan(Math.toRadians(fov / 2f))) * aspectRatio);
    float fovX = fovY / aspectRatio;
    float frustum_length = zFar - zNear;

    matrix.m00 = fovX;
    matrix.m11 = fovY;
    matrix.m22 = -((zFar + zNear) / frustum_length);
    matrix.m23 = -1;
    matrix.m32 = -((2 * zNear * zFar) / frustum_length);
    matrix.m33 = 0;

    return matrix;
}

Vertex Shader:

#version 400 core

in vec3 position;
in vec2 textureCoord;

out vec2 textureCoords;

uniform mat4 tranformation;
uniform mat4 projection;

void main(void) {

    gl_Position =  projection * tranformation * vec4(position,1.0);

    textureCoords = textureCoord;
}

Fragment Shader:

#version 400 core

in vec2 textureCoords;

out vec4 out_Color;

uniform sampler2D sampler;

void main(void) {
    vec4 color = texture(sampler, textureCoords);

    //if(color.a < 0.5) discard;

    out_Color = texture(sampler, textureCoords);
}


texts: How to sample from six cubemap images for a skybox in Shader Graph?

texts:
I'm trying to update a skybox shader to URP and reimplement it in Shader Graph.  The shader code itself is pretty straightforward, but I don't know enough about Shader Graph yet to set up the basic skybox.

It's a standard cubemap skybox made up of six textures for +x, -x, +y, -y, +z, and +z.

Trying to Google different variants of "unity shader graph cubemap skybox" turns up tons of noise and nothing actually useful that I can see.

Does anyone know what the basic node setup is I would need to input six images and output a skybox?


texts: How to calculate rotations for an object with scaling transformations?

texts:
I am working on implementing scaling transformations into a game engine (C++), which previously assumed only translations and rotations. Visually, the scaling works, but a lot of the game logic started to break.
For example: I have a turret, which is a composite object (turret base --> weapon). I need to change the turret's yaw and pitch so it faces the target when it fires. To do this, I first get the target position in object space by inverting the object transformation matrices (taking into account that the gun may be offset from the turret base), and I use the resulting point to calculate the necessary yaw and pitch.
void Rotate_Turret(Turret t, Vec4 targetPos)
{
    // Get the TF matrices
    Mat4 turretBaseTf = Get_Tf(t.TurretBase);
    Mat4 turretGunTf = Get_Tf(t.TurretGun);

    // Calculate target in the turret base space (for yaw)
    // "inv" transposes the rotation part and inverts the translation
    Vec4 baseSpaceTarget = inv(turretBaseTf) * targetPos;

    // Calculate yaw
    float relativeYaw = atan2(baseSpaceTarget.Y, baseSpaceTarget.X);

    // Get the offset of the gun from the base
    Vec4 gunOffset = inv(turretBaseTf) * turretGunTf.Translation();

    // Get the XY plane component of the base space target vector
    float targetDistanceXYBase = sqrt((baseSpaceTarget.X * baseSpaceTarget.X) + (baseSpaceTarget.Y * baseSpaceTarget.Y));

    // Get the vector components for the gun, taking the offsets into account
    float targetDistanceZGun = baseSpaceTarget.Z - gunOffset.Z;
    float targetDistanceXYGun = targetDistanceXYBase - gunOffset.X;
    float relativeTilt = atan2(targetDistanceZGun, targetDistanceXYGun);

    // Set the rotations
    t.Rotate(relativeYaw, relativeTilt);
}

This works fine at 1:1 scale, but as soon as I upscale the turret at the root level, it keeps shooting consistently above the target. I tried inverting the scale in the matrices in the above process, but it doesn't seem to work. What am I doing wrong?
Thanks in advance for the help!

I double-checked every bit of the math by calculating the angle directly between the weapon and the target position, and I compared that to the results of the code described above. I'm pretty sure I'm getting the correct results, so I don't get why it doesn't tilt the weapon correctly (the Z angle is correct, i.e it turns exactly toward me, but doesn't tilt the gun low enough).
The only thing I can think of is that somehow the resulting tilt angle itself needs to change based on scale, since a scaled matrix will have another rotation matrix applied to it afterward (i.e when I apply the rotation to the turret weapon to make it aim at the target)


texts: Bukkit shoot tnt where player is looking

texts:
Possible Duplicate:
  Bukkit shoot tnt & help with vectors

Hello. I want to shoot a piece of tnt from the players face and then let it explode when it hits the target block.

I set it up so where the player looks and type in /tnt [power] /cannon [power] or /t [power] it will blow up at the target block:

        if (cmd.getName().equalsIgnoreCase("cannon")) {
        if(!perrmissionCheck(sender, "Needs.cannon", "cannon")){
            return true;
        }
        if (!(sender instanceof Player)){
            sender.sendMessage(nameC+"You must be a player to preform this command.");
            return true;
        }
        Block block = ((Player) sender).getTargetBlock(null, 50);
        Location location = block.getLocation();
        float power = 4;
        if (args.length == 1){
            power = Float.parseFloat(args[0]);
        }
        sender.sendMessage(name+"BOOM!");
        block.getWorld().createExplosion(location, power);
        return true;
    }

That's all fine and dandy but I want it to appear in front of the user then start to move away towards the target block. And NOT blow up before it reaches the target block. Any help is greatly appreciated.

EDIT: I think it may have something to do with vectors but I have no idea how to use them.

Thanks.


texts: Difference between multiple AudioUnits and one AudioGraph with a MultiChannelMixer

texts:
I'm porting my game to iOS using MonoTouch, and I'm having some trouble getting sound output to work. SystemSound/AVAudioPlayer is way too simple for my needs (I need looping and multiple simultaneous sounds), and OpenTK is not trivial to get working, in addition for it not supporting audio decoding by itself.

So I've settled with CoreAudio, which seems to do the trick. I've downloaded some samples, and gotten it to play and loop some sounds. Now I want it to play multiple sounds at the same time.

I noticed that it was trivial to get multiple sounds by creating multiple AudioUnits, each one separately connected to RemoteIO, but this doesn't seem to be very efficient. You can also mix multiple sounds by creating a graph and mixing everything on a MultiChannelMixer connected to RemoteIO which seems to be the right way to do it.

But I'm basing my decisions on pure assumptions (and in my short iOS experience, I've seen my assumptions are usually wrong when it comes to iOS, like some kind of inverse Principle of Least Astonishment), so I would like to ask the CoreAudio gurus over here if there is a real difference between these two approaches, or if there is a "more correct" approach to do what I want.


texts: How to avoid many import iterations while generating sub assets?

texts:
I have a ScriptedImporter that generates other assets in the same directory.

Whenever it happens, import progress bar pops in again, this time like Importing (iteration N).

I've tried to use AssetDatabase.DisallowAutoRefresh to circumvent this behavior but that failed.

Question:

How to prevent subsequent import iterations and rather group them to happen all at once ?


texts:
Ok so i made this inventory script but the items are not picking up and not appearing in the inventory. Im new to c# so that is why im asking this question also ive never done an inventory before. I want the medkit to go in the medkit slot. And bandage in the bandage slot and so on. Here are my scipts.
Here is my inventory script attached to the player.
public class MedInventory : MonoBehaviour
{
    public bool[] isFull;
    public GameObject[] MedkitSlot;
    public GameObject[] BandageSlot;
    public GameObject[] CoffeeSlot;
    public GameObject[] SyringeSlot;
}

Here is the medical pickup script attached to the item pickup.
public class MedPickup : MonoBehaviour
{
    private MedInventory medInv;
    public GameObject itemButton;

    private void Start()
    {
        medInv = GameObject.FindGameObjectWithTag("Player").GetComponent<MedInventory>();
    }

    void OnTriggerStay2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            if (other.CompareTag("medkit"))
            {
                for (int i = 0; i < medInv.MedkitSlot.Length; i++)
                {
                    if (medInv.isFull[i] == false)
                    {
                        medInv.isFull[i] = true;
                        Instantiate(itemButton, medInv.MedkitSlot[i].transform, false);
                        Destroy(gameObject);
                        break;
                    }
                }
            }

            if (other.CompareTag("bandage"))
            {
                for (int i = 0; i < medInv.BandageSlot.Length; i++)
                {
                    if (medInv.isFull[i] == false)
                    {
                        medInv.isFull[i] = true;
                        Instantiate(itemButton, medInv.BandageSlot[i].transform, false);
                        Destroy(gameObject);
                        break;
                    }
                }
            }

            if (other.CompareTag("coffee"))
            {
                for (int i = 0; i < medInv.CoffeeSlot.Length; i++)
                {
                    if (medInv.isFull[i] == false)
                    {
                        medInv.isFull[i] = true;
                        Instantiate(itemButton, medInv.CoffeeSlot[i].transform, false);
                        Destroy(gameObject);
                        break;
                    }
                }
            }

            if (other.CompareTag("syringe"))
            {
                for (int i = 0; i < medInv.SyringeSlot.Length; i++)
                {
                    if (medInv.isFull[i] == false)
                    {
                        medInv.isFull[i] = true;
                        Instantiate(itemButton, medInv.SyringeSlot[i].transform, false);
                        Destroy(gameObject);
                        break;
                    }
                }
            }
        }
    }
}

Please help and thanks!


texts:
I've written a basic game using Cocos2D-x on XCode. It works fine on the iPhone. Now I'm trying to port it to Android. When I run the script ./build_native.sh
inside the proj.android folder, it gives me the following error:

jni/../../Classes/MemoryModeLayer.cpp: In member function 'void MemoryModeLayer::startNewGame()':
jni/../../Classes/MemoryModeLayer.cpp:109:25: error: 'time' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:109:25: note: suggested alternative:
/Users/abc/android-ndk-r9d/platforms/android-8/arch-arm/usr/include/time.h:40:17: note:   'time'
jni/../../Classes/MemoryModeLayer.cpp:111:5: error: 'random_shuffle' is not a member of 'std'
jni/../../Classes/MemoryModeLayer.cpp:112:5: error: 'random_shuffle' is not a member of 'std'
make: *** [obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/MemoryModeLayer.o] Error 1
make: Leaving directory `/Users/abc/cocos2d-x-2.2.3/projects/Game/proj.android'

In MemoryModeLayer.cpp I have the following:

std::srand(unsigned(std::time(0)));
std::random_shuffle(_xCod, _xCod + _numberOfRows);
std::random_shuffle(_yCod, _yCod + _numberOfColumns);

I've included the following headers as well:

#include <string>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <iomanip>

Also added using namespace std in the header file. Is there anything else that I should do?


texts:
I'm trying to figure out how to implement a simple ECS with an Archetype approach, similar to what Unity's ECS uses.
An archetype is just a category for entities that have a specific set of components.
Let's say I had three components, A, B, and C, and I had the following systems:

System 1 (Archetype requires component A)
System 2 (Archetype requires components A and B)
System 3 (Archetype requires components A and C)
System 4 (Archetype requires components A, B, and C)

Because components could be added and removed from entities on the fly, an entity switches archetypes whenever a component is added or removed.
I'm not quite sure what these archetype collections are supposed to look like. They must be arrays of some kind, but I'm not sure how to store and organize components in them that belong to a specific entity.
My question is, what would this look like in pure, vanilla C# code?
And could generics also help with this?


texts: Why one `colorKey` in `ParticleSystem` cannot be changed without a new Gradient?

texts:
My question is partly a continuation of this question. So, why I can't change just one GradientColorKey this way (without replacing the whole Gradient instance):
ColorOverLifetimeModule colorOverLifetime = _particle.colorOverLifetime;
MinMaxGradient color = colorOverLifetime.color;
color.gradient.colorKeys[1] = new GradientColorKey(new Color(1, 0, 0), 0.5f);
colorOverLifetime.color = color;

colorOverLifetime.color is MinMaxGradient struct, so I copy its value in a variable color.
The colorOverLifetime.color.gradient property is Gradient class and there is no need to copy it.
The colorKeys property is just an array of GradientColorKey struct. So, I assign a new GradientColorKey value to the array element that already exists.
Why shouldn't this work?


texts: Export Blender 3D animation to be played by Android OpenGLES

texts:
Below code snippet shows the way to export coordinate of bones:

def export_bone_matrix(armature, bone, label, file_handler):
  SystemMatrix = Matrix.Scale(-1, 4, Vector((0, 0, 1))) * Matrix.Rotation(radians(90), 4, 'X')

if (bone.parent):
    Export_babylon.write_matrix4(file_handler, label, (SystemMatrix * armature.matrix_world * bone.parent.matrix).inverted() * (SystemMatrix * armature.matrix_world * bone.matrix))
else:
    Export_babylon.write_matrix4(file_handler, label, SystemMatrix * armature.matrix_world * bone.matrix)

I have create a 3D character in Blender, and add keyframes in it by transforming
in some frames.  From the graph editor, you can easily tell the all displacement
of transformation - translate, rotate, scale are all measured with respect to the
original value in frame 0.

Is it possible to write OpenGL in Android to animate the same 3D animation in Blender?
I'd like to transform the 3D character - translate, rotate in each frame according to
the displacement value exported from Blender.

Below lists the python function to export translate, rotate displacement in each frame:

def get_bone_action_location(action, bonename, frame=1):
loc = Vector()
if action == None:
    return(loc)
data_path = 'pose.bones["%s"].location'%(bonename)
for fc in action.fcurves:
    if fc.data_path == data_path:
        loc[fc.array_index] = fc.evaluate(frame)
return(loc)

def get_bone_action_rotation(action, bonename, frame=1):
rot = Quaternion( (1, 0, 0, 0) )  #the default quat is not 0
if action == None:
    return(rot)
data_path = 'pose.bones["%s"].rotation_quaternion'%(bonename)
for fc in action.fcurves:
    if fc.data_path == data_path: # and frame > 0 and frame-1 <= len(fc.keyframe_points):
        rot[fc.array_index] = fc.evaluate(frame)
return(rot)

Or I need to transform the meshes with vertex group controlled by root bone by the
transform matrix - SystemMatrix * armature.matrix_world * bone.matrix?  And for those
controlled by child bones by the matrix in terms of (SystemMatrix * armature.matrix_world * bone.parent.matrix).inverted() * (SystemMatrix * armature.matrix_world * bone.matrix)?


texts: How to design the AI for a board game like Risk?

texts:
I am about to develop a web game that is similar to board games like Risk, and iOS games like Lux and Strategery. I am curious to know what the concept behind the AI for such games should be like.

I know it's going to involve a lot of move calculations and and calculating all possible options. But can someone elaborate on this please? I am actually a web programmer who usually develop websites and program logic to them, so game development is something new to me.

Also, my boss would like to implement different difficulty levels for the AI. What are the principles behind something like this? Would the difficulty level correspond with how many steps/turns ahead the AI would calculate for each movement? (Like easiest difficulty would be the AI only calculating all possible moves for this turn, whereas in the next level of difficulty, the AI would calculate all possible moves for this turn and the next turn?)

Thanks!


texts: Xbox thumbstick used to rotate sprite, basic formula makes it "stick" or feel "sticky" at 90 degree intervals! How do you get smooth rotation?

texts:
I am using a very basic formula to calculate what angle my sprite (spaceship for example) should be facing based on the Xbox controller thumbstick i.e. you use the thumbstick to rotate the ship.

In my main update method:

shuttleAngle = (float) Math.Atan2(newGamePadState.ThumbSticks.Right.X, newGamePadState.ThumbSticks.Right.Y);

In my main draw method:

spriteBatch.Draw(shuttle, shuttleCoords, sourceRectangle, Color.White, shuttleAngle, origin, 1.0f, SpriteEffects.None, 1);

As you can see it's quite simple, I take the current radians from the thumbstick and store it in a float shuttleAngle and then use this as the rotation angle (in radians) argument for drawing the shuttle.

For some reason when I rotate the sprint it feels sticky at 0, 90, 180 and 270 degrees angles.  It wants to settle at those angles. It's not giving me a smooth and natural rotation like I would feel in a game that uses a similar mechanic. PS: My Xbox controller is fine!


texts: LibGDX - draw bullet physics bounding box

texts:
I am very new to game development and I am trying to debug my 3d collision bounds. Could somebody give me an example on how to draw the collision bounds of an object in libGDX?

I assume it has something to do with btIDebugDraw but I can't find any examples on how to draw them.


texts: Drawing isometric map in canvas / javascript

texts:
I have a problem with my map design for my tiles.

I set player position which is meant to be the middle tile that the canvas is looking at.

How ever the calculation to put them in x:y pixel location is completely messed up for me and i don't know how to fix it.

This is what i tried:

 var offset_x = 0; //used for scrolling on x
 var offset_y = 0; //used for scrolling on y
 var prev_mousex = 0; //for movePos function
 var prev_mousey = 0; //for movePos function

function movePos(e){

    if (prev_mousex === 0 && prev_mousey === 0) {
        prev_mousex = e.pageX;
        prev_mousey = e.pageY;
    }

    offset_x = offset_x + (e.pageX - prev_mousex);
    offset_y = offset_y + (e.pageY - prev_mousey);
    prev_mousex = e.pageX;
    prev_mousey = e.pageY;
    run = true;

}

player_posx = 5;
player_posy = 55;
ct = 19;

    for (i = (player_posx-ct); i < (player_posx+ct); i++){ //horizontal
    for (j=(player_posy-ct); j < (player_posy+ct); j++){ // vertical

//img[0] is 64by64 but the graphic is 64by32 the rest is alpha space
    var x = (i-j)*(img[0].height/2) + (canvas.width/2)-(img[0].width/2);
    var y = (i+j)*(img[0].height/4);

    var abposx = x - offset_x;
    var abposy = y - offset_y;

    ctx.drawImage(img[0],abposx,abposy);
    }
}

Now based on these numbers the first render-able tile is  I = 0 & J = 36. As numbers in the negative are not in the array.

But for I=0 and J= 36 the position it calculates is : -1120 : 592

Does any one know how to center it to canvas view properly?


texts:
I'm developing (or rather butchering) plugin for Rust, which was build in Unity,  and I need to create a targeting system. Unfortunately I got stuck on WorldToScreenPoint and WorldToViewportPoint. It seems that the Camera.main is not what player sees and is not moving at all. Also it has different resolution from what the game is set up.

Unfortunately I can't use Unity and all the work needs to be done in VS.

Does anyone has a suggestion how to get a "proper" camera for this?

Thank you in advance

EDIT

As requested this is my code: Debug.log(Camera.main.WorldToScreenPoint(bAnimalNPC.transform.position).x.ToString())
Debug.log(Camera.main.WorldToScreenPoint(bAnimalNPC.transform.position).y.ToString())
Debug.log(Camera.main.WorldToScreenPoint(bAnimalNPC.transform.position).z.ToString())

The rest is just getting the bAnimalNPC and doing some checks.


texts:
I'm working on a platform game and my collision code is to picky. I can't exactly do aabb(?) because the map is represented as metatiles. (23-24 16x16 tiles make up a 300ish pixel resolution.) My game thus far simply takes the player's x/y coords and divides them by 16 to check the current tile the player is in. Thus far the only thing I have managed is a very picky collision by simply checking the divided values against weather the tile in the map is solid or not and setting a bool to the player being blocked in that direction. It works, but not solid as the x and y velocity of the player changes so much the hit point of the collision does as well. For example going left at a small speed seems pixel perfect yet full speed results in the collision taking place 5 pixels before the actual collision.

Can anyone point me in the right direction on this?


texts: What is an efficient method of collision detection for handling lots of objects?

texts:
In my game, I have plenty of objects that can collide. Literally, most of them can collide with each other. The problem I'm facing is that I can't come up with some good collision detection. How can I resolve collisions for lots of objects in such way that I don't end up with class that has more than 1000 lines of code with enormous conditional constructs like this?

    if (firstBodyUserData == "rocket"
            && secondBodyUserData == "car_body") {
        resolveRocketAndCarBodyCollision(firstBody, secondBody, contactData);
    } else if (firstBodyUserData == "rocket"
            && secondBodyUserData == "gas_tank")
        resolveRocketAndGasTankCollision(firstBody, secondBody, contactData);
    //...many more dumb lines of code for every particular object in my game

And don't forget about all these "resolving methods" after if statements.

To make question more specific, I use Box2D  with its ContactListener and Artemis-odb entity-component-system framework so I don't really have classes for my entities and that kind of exacerbates the problem but main question is in resolving bunch of different types of collisions.


texts: How to run different animations with same suffix for different public objects?

texts:
I would like to be able to run the corresponding animation (ending with "Get" in the title) for whatever item GameObject I plug into this treasurebox.

I made 2 prefabs for "item-get" animations today. Both GameObjects consist of 3 sprites: The image representing the item, and 2 lightray images that I enable/disable in alternation to get a halo effect (see animation below).

You can see the 2 prefabs and their corresponding animation components in the Project panel:

These next two images show how similar the animations are--they even both require two of the same sprites, flareA and flareB.

Here is the code I am currently using to set the state of the ItemBox GameObject and run the animations. You can see that while the itemGet prefab is public (that is, I can plug in whatever gameobject I want in the editor), line 27 explicitly calls for the animation belonging only to the turd item.

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

public class ItemBox : MonoBehaviour
{

    bool disabled = false;
    private Animator anim;
    public GameObject itemGet = null;

    void Start()
    {
        anim = GetComponent<Animator>();
        if (!disabled)
        {
            anim.Play("ItemBoxIdleState");
        }
    }

    void OnTriggerEnter (Collider other)
    {
        if (!disabled && other.gameObject.tag == "Player")
        {
            anim.Play("ItemBoxGetItemState");
            GameObject itemClone = Instantiate(itemGet, transform.position + new Vector3(0, 0.375f, 0), Camera.main.transform.rotation);
            itemClone.GetComponent<Animator>().Play("turdGet");
            Destroy(itemClone, 1.6f);
            disabled = true;
        }
    }
}

How can I change line 27 (the line before 'Destroy') so that it runs the appropriate "*Get" animation for whatever itemGet object I plug into the inspector? I think I am already close. I intend to make more items (not too many for now) and the animation I want to play will always be structured like "Get".

UPDATE 07/29/19:  I tried making a public AnimationClip object in the ItemBox script and putting that name in quotes for line 27 and thw script still works, but now I get an index error saying the animation state was not found. I don't think I can plug the name of the public variable into the .Play("") quotes and make it work; I think it only worked because there is only one animation for that item anyway. I ended up removing this new variable and just keeping the .Play("") part as empty quotes and it still works. I might decide to add more animations to these item objects later so I still need to know how to specifically play the animation that ends in "Get".


texts:
I'm currently using Mercury Particle Engine for the particle effects in my game, and I'm trying to create a sort of lightning whip - basically a lightning effect bound to a line that curves when the player moves. I know how to use the editor, and I have particle effects working in game. However, I'm completely lost as to where I should start for this specific particle effect.

Perhaps if I could find the code for it in a different particle engine, I could convert it, but I can't seem to find that either. What I did find was a lot of tutorials for creating the lines associated with lightning programmatically, which doesn't help in this case because I don't want it to be rigid. Perhaps it would be more like some sort of laser beam with crackling effects around it? I'm running into a wall as far as even beginning to implement this goes.


texts: Unity3D: Facebook login into the game + Verification on Server Side

texts:
I don't need to know the specific code required for that, but I want to understand at high level how can I implement that and what SDKs I have to use to achieve that.

Facebook PHP SDKs: Ok If I want to perform login with Facebook into my web page.
Unity3D's Facebook SDK: Ok If I want to perform login inside my App without a server (apart Facebook's servers of course).

What I want to achieve is:

User login into facebook from the App (just once, and eventually the option to log out on request of user, or to relog if login data expires)
Login is verified by my Server (actually a user should really have a facebook account)
Do not embed stuff like Facebook App ID in my App source code.

My server will store some data for each user and to identify users I need to be able to use some unique data provided by Facebook like session token etc. Of course the session token may change so I need anyway to be able to identify the user (to avoid losing memorized data).


texts: Scalling down libgdx game to fit a smaller screen appears only the half of the stage?

texts:
Hello I have made a game in 1280x720, but I want it to fit devices with smaller size, so far no luck with the current code it only shows the left half of the screen, it also does not work with bigger sizes, there it shows the scene in the left corner and the remaining is black screen, here is my code:

public class MenuStage extends Stage implements Screen {
private PlayStage playStage;
private UVeggFruit uVeggFruit;
private OrthographicCamera orto;
private Viewport vport;

public MenuStage(UVeggFruit uvf) {
    uVeggFruit = uvf;
    initMenu();

}

private void initMenu() {
    ButtonClickListener buttonClickListener = new ButtonClickListener();
    SceneLoader sc = new SceneLoader();
    CompositeItemVO sceneComposites = new CompositeItemVO(sc.loadScene("MainMenu").composite);
    CompositeActor UI = new CompositeActor(sceneComposites, sc.getRm());
    addActor(UI);
    UI.getItem("playbutton").addListener(buttonClickListener);
    UI.getItem("playbutton").addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            playStage = new PlayStage(uVeggFruit);
            uVeggFruit.setScreen(playStage);
        }
    });
    orto = new OrthographicCamera();
    vport = new ScalingViewport(Scaling.stretch, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), orto);
    vport.apply();

}

@Override
public void show() {
    Gdx.input.setInputProcessor(this);
}

@Override
public void render(float delta) {
    orto.update();
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    this.act();
    this.draw();
}

@Override
public void resize(int width, int height) {
    vport.update(width, height);
}

@Override
public void pause() {
}

@Override
public void resume() {
}

@Override
public void hide() {
     }
  }

Is it wrong that I put viewport in every stage, or I should put it in the application adapter and it will work for all stages? So basically what I want is that my stage renders as it would in 1280X720, but with smaller size, so how is this possible so I can see my whole stage no mater the screen size which is the general goal?


texts: How do I fix the bug where my Rigidbody gets stuck on the edge of two Colliders?

texts:
The boxes are standing right next to each other, but somehow, the player manages to collide with the ghost edge. I use AddForce to control the player with a Box Collider, though I also tried using a Mesh Collider, and I tried setting the player's collision to continuous. This also happens in 2D.

I've seen other people's posts about this bug, but I couldn't really understand how to fix it. How do I fix this?


texts: How to display a GUI Texture for a certain amount of time

texts: Is it possible to make a gui Texture display for a certain amount of Time.


texts:
I am designing a top-down racing game using canvas (html5) which takes a lot of inspiration from Micro Machines. In MM, cars can move off the track, but they are reset/destroyed if they go too far.

My maths knowledge isn't great, so I'm finding it hard to separate 3D/complex concepts from those which are directly relevant to my situation. For example, I have seen "splines" mentioned, is this something I should read up on or is that overkill for a 2D game?

Could I use a single path which defines the centre of the track and check a car's distance from this line? A second path might be required as a "racing line" for AI.

Any advice on methods/techniques/terms to read up on would be greatly appreciated.


texts: How to calculate the surface area of a mesh

texts:
I am looking for a way to calculate surface area of a 3D mesh object and found this code from a Unity forum:
 public float Area(Mesh m)
 {
     Vector3[] mVertices = m.vertices;
     Vector3 result = Vector3.zero;
     for (int p = mVertices.Length - 1, q = 0; q < mVertices.Length; p = q++)
     {
         result += Vector3.Cross(mVertices[q], mVertices[p]);
     }
     Debug.Log(result);
     result *= 0.5f;
     return result.magnitude;
 }

But the problem is that it is not providing the correct area as I have found from testing the fbx with Revit. Revit is showing a different surface area from what this code shows.
Here is a sample mesh
Front

Back

Top

Its surface area as calculated by the function above is 97.4913,while in Revit it's actually 52.811 \$m^2\$.
I don't know how revit calculate it but it provide area and volume information automatically (i have no idea how even revit works).


texts: What is "convexity" in the context of game design?

texts:
I have overheard game designers mentioning something called convexity in games. This seems to be a game-design-specific concept, different from (although possibly related to) that in geometry or game theory. Unfortunately there are very few sources online mentioning it, let alone a definition. From what I could gather, it has something to do with player choices.

So what is convexity? How does it manifest in a game? What's an example of it, or the lack of it? Is it a good thing, a bad thing, or if it depends, when is it good, when is it bad?


texts: How do I efficiently render the tiles of a tile map?

texts:
I've been working on a game, and I've been using Python with Pyglet to create it. I had an issue on how I could do effective tile based rendering. I tried cocos2d, however the API is very efficient and doesn't support maps which are larger than 1000x1000 tiles. I did some further research, and found you could make it so when you triggered an update, only sprites on the edge of the screen would update, however it is still buggy (it's not fully working).

Here is my code, and here's some relevant rendering code:

self.camera[0]-=amount
for a in range(self.window.height//self.block_size):
    self.sprites[(self.camera[0]//self.block_size)-1][a+(self.camera[1]//self.block_size)].batch = render
    self.sprites[self.window.width//self.block_size+(self.camera[0]//self.block_size)+1][a+(self.camera[1]//self.block_size)].batch = None

What approach should I use to render maps larger than 1000x1000 tiles?


texts: How can I save an XNA texture as a PNG file?

texts: I have a Color[,] variable and I already know how to convert it to a Texture2D. How do I then save it as .png image?


texts: How can I do something only after an animation has finished?

texts:
I'm making this 2D platform based game. Basically what I want is when the player walks into spikes (which have a "deadly" tag") it displays the animation that has the parameter of animate with the value of 3 and after that the player gets destroyed. So my question is:

How do I build a timer or something so that the object only gets destroyed after the animation is played (with no looping)?

This is the code I'm using now:

void OnTriggerEnter2D(Collider2D target) {
    if (target.gameObject.tag == "Deadly") {
        Die();
    }
}

void Die() {
    animator.SetInteger ("AnimState", 3);
    Destroy (gameObject);
}


texts: Forces on entities: remove all each update step, or remove on demand?

texts:
Following the answer to my question here, the way I apply forces on an entity, is each entity has a Map of forces (Vectors) and their IDs. Every update step, the acceleration vector is set to the sum of all the forces. Forces can be removed by using their unique ID.

In psuedocode:

class Monster extends MovingEntity{
    Vector position, acceleration, velocity;
    Map<String, Vector> forces;
    // .. stuff omitted

    public void update(){
        acceleration = new Vector(0,0); // zeroing the accleration
        foreach force in forces{
            acceleration.add(force);
        }
        velocity.add(acceleration);
        position.add(velocity);
    }

    public void applyForce(Vector force, String id){
        forces.put(id, force);
    }

    public void removeForce(String id){
        forces.remove(id);
    }
}

This works fine, but here is my dilemma:

Currently, after adding a force I have to remember to remove it. For example, psuedocode to demonstrate the way player input is handled:

if(playerInput.leftPressed()) player.applyForce(new Vector(2,0), "left");
// applyForce() internally deletes the previous force with the same name.
else player.removeForce("left");
// have to remember to remove the force. sometimes a little complicated

This can also be annoying e.g. when using steering behaviors. An AI agent may want to Seek somewhere, which applies a force on itself. But when it's done Seeking, it must remove the force.

I'm wondering if it would be a good idea to empty the forces Map at the end of each update step. In the update() method from before:

    public void update(){
        acceleration = new Vector(0,0);
        foreach force in forces acceleration.add(force);
        velocity.add(acceleration);
        position.add(velocity);
        forces.empty(); // emptying the forces list
    }

Returning to the steering behaviors example, this way an agent doesn't need to remove the Seek force when it's done seeking. Each update step, as long as it calls applyForce(..), it will Seek. But the first update step that it doesn't apply a force, there will be no force. All forces are deleted automatically. And since in games forces are constantly deleted and replaced with new ones, I think this seems natural.

What is your opinion? Reset all forces each update step? Or have entities and their environment manually remove forces when it's needed?


texts:
I have a shape containing vertices and triangles

I want to inflate that geometry using some radius to get something like that

I should move each point along vector center-vertex. I suppose each point should be moved using quadratic function (closer to center, further it will be moved)

How should I calculate the offset of each point?


texts:
Reading this article here, the author writes about chunk saving and using a lookup table and then saving each chunk in a region file, each region file having 4096 chunks and each chunk having 4096 bytes of data. He structures it so that each chunk in the region file is offset by 4096 bytes - perfect. So far so good, I've created this in C# easily.

My problem is now with compression. If I compress each chunk down, that is great, nonetheless I still have a region file that is full length in size based on each chunk being 4096 offset - so the file itself still looks full size despite each chunk being compressed and save within it's 4096 byte allotment. I don't want to compress the entire region file because that is extremely inefficient to have to always decompress 4096 chunks in a region just to get 1 chunk. It is better to compress each chunk individually before adding to region file.

Can someone suggest how I might work around this without resizing the region file? I do not want to resize a region file every time it is modified, which is also what the author of this article avoids too. File resizing would be too costly in performance.


texts: How to efficiently store and display a tile map on the web?

texts:
About
These are actually two questions in one. First of all I am looking for a way to efficiently store large amounts of tile data. The other aspect deals with querying the data set and displaying tiles. Let me give you some background first.
We are making a browser based multiplayer tycoon game using the CraftyJS library to render it to Canvas. In the background of the GUI we're running Yii Framework on PHP and it all connects to a Python random map generator and game engine.
This is how the first rough map render looks: http://i.imgur.com/khAXtl.png
Storing the map data
The game world is randomly generated each time the game starts. The size is 100x100 hexagonal tiles for each player. That means that for a three player game, there are 90.000 tiles created. Currently I just create a JavaScript array from which I render the map.
This works fine for rendering, but for any kind of interaction with the map we need to store which player owns the tile, what kind of structure is build on top of it, what's it's current price and so on. At first, at least for the prototype, we wanted to use MySQL, but after some testing, it's not exactly as fast as I'd like. Maybe an object store like MongoDB would be better suited for storing tile data instead of an SQL table. Or maybe something else?
Displaying the map
Another problem I see is moving around the map. Currently I'm creating Crafty entities for each tile even if it's not in the viewport. This is slow, because even though Crafty renders only the ones in the viewport, it stores and possibly iterates through  all the tiles on each render event. What I currently have is a drawn generated map which is very slow to load and stutters when you move around, now I'd like to make it playable.
My first idea was to load the displayed subset of tiles that are in the viewport. But  when a player would move the viewport to a blank area, I'd need to query the server and wait for the response back, only then can the map be rendered. This would be fine in a native application, but it's laggy in a web game.
The way to get smooth performance from the map could be preloading a bigger subset of tiles into a javascript array and use it as a cache. The player would have a few screens "cached" and when he moves the viewport, I'd load more tiles to the JS "cache".
Am I headed in the right direction? I would love to get some more information from someone who has done something similar. I am new to game development, but have been going through a lot of sources over the last couple of weeks.


texts: Dealing with field of view when zooming into a terrain from a height

texts:
I'm creating a tech demo featuring a small planet. The problem I'm having is that the planet doesn't really feel like the right "scale" when the camera in down on the surface, I think it could be the curvature of the surface of the planet.

I was wondering if anyone had any suggestions for adjusting maybe the field of view, or any other camera tricks to give the impression that, once on the surface, the planet is larger than it appears at the moment.


texts: How'd they do it: sphere effects in Osmos

texts:
I'm curious how the sphere effects were done in Osmos from Hemisphere Games.  Any ideas how the resolution independent zoom in was achieved?

Edit, more specifics on questions:

How do you render the spheres so they look good at full zoom out, and full zoom in?
How would one make the nice particle effects in 100's of spheres all at once?
How to construct your scene/spheres so the big spheres look round even at full zoom?

Gameplay video

Hemisphere Games


texts:
I've found a plethora of "modern" OpenGL (3.0+) tutorials for 3D, but I have found next to nothing when looking for information on how to use it for 2D game development. How can I get started using OpenGL for 2D gamedev?

Specifically, I'm interested in getting answers to the following topics:

How should I set up my various matrices for orthographic projection?
Are shaders as heavily used in 2D applications as in 3D ones? If so, what is their purpose in the 2D setting?
How should I handle the massive number of textures obviously required for a 2D game?

I apologize for the relatively broad question, but I've spent a long time searching and I've found very little useful information that applies to modern OpenGL.


texts: Using AR measuring techniques to allow free movement in a VR room

texts:
I am a Game Design student currently working on my graduation project. For this project, I want to develop a VR room, which can be walked through freely by using a smartphone. I already made a 1:1 scale replica of a meeting room (in Unity 3D) in the office I am currently working.

So I have been exploring different technologies that allow distance measuring techniques using markers and AR applications to measure distance between physical objects.

for example:
https://www.youtube.com/watch?v=Tk31uGo7xHo
https://www.ourtechart.com/augmented-reality/augmented-reality-tutorial-47-shapes-combined-trackers-unity3d-vuforia/

Now is it possible to use these methods to translate the measured distance into a vector 3 movement in a VR room? Also, is this relatively easy to do for a beginner programmer?

To be clear: The goal is to allow free movement through a pre-built 1:1 scale 3D room in VR by using a smartphone and markers in the physical room. Which hopefully will create some cool VR experience for the players.

Could anyone give me some advice? For example; is there anyone who already tackled this problem and is willing to share knowledge with me?

Thanks in advance


texts: Should I use one thread per game object?

texts:
I developing a simple real-time strategy game in a small team with no experience, and we're considering using one thread per game object (tank, soldier, etc). Is this a good idea or is it overkill?

The thread would call each object on each instant change (game timer, not graphic engine timer)

We're using Python with the Panda3D engine, meaning the GIL is probably going to reduce a lot the possible speed improvements.


texts: I am planing to develop a game, in fact a puzzle game, I have changed the graphics but the level design is all the same. For example, the original puzzle game have five aliens as the obstacle in the human way to airship, the aliens spit fire on human. So here I have changed the alien to chameleon, with same positions(the aliens position never change so as the chameleon's ) and exact strike range(stick its tongue out to catch) and exact measurement(tile) and also converted the human to honey bee. So my doubt is that will there be any issue on this, for I am rendering the exact level design? ( I have searched, but didn't get a precise answer for my doubt)


texts:
In the game I am developing, I have to calculate if my vehicle (1) which in the example is travelling north with a speed V, can reach its target (2). The example depict the problem from atop:

There are actually two possible scenarios: V is constant (resulting in trajectory 4, an arc of a circle) or the vehicle has the capacity to accelerate/decelerate (trajectory 3, an arc of a spiral).

  I would like to know if there is a straightforward way to verify if
  the vehicle is able to reach its target (as opposed to overshooting
  it). I'm particularly interested in trajectory #3, as I the only
  thing I could think of is integrating the position of the vehicle over
  time.

EDIT: of course the vehicle has always the capacity to steer, but the steer radius vary with its speed (think to a maximum lateral g-force).

EDIT2: also notice that (as most of the vehicles in real life) there is a minimum steering radius for the in-game ones too).


texts: How do I make a launcher for multiple executables?

texts: I'm trying to make a launcher for a game I like that compiles the vanilla version and the mods into one launcher. I want to make it so I can choose between the versions, maybe with a rudimentary GUI. The original versions of the game are in Java, but I'm converting them to .EXE with Launch4j, and that's working fine.


texts:
I'm considering separating my game simulation from the message loop. It seems odd to me to have other systems tied directly to the window in which my game is running. Most examples I see are implemented similar to the following (I'm glossing over details here, code is only meant to get the idea across)

... WndProc(...)
{
    //PeekMessage
    //Update input
    //Update timer
    //Update simulation
    //Update renderer
}

To increase separation of concerns, I'd like to move the update of input, simulation and renderer out of the specific window itself. This seems simple to accomplish

... WinMain(...)
{
    //Update window
    //Update input
    //Update timer
    //Update simulation
    //Update renderer
}

... WndProc(...)
{
    //PeekMessage
}

There is information that must be obtained from the window to be consumed by the rest of the game. Namely, input (if using the message system), window size, window focus, etc. I should be able to use callbacks or passing in references to state objects the window will update to get this information.

This approach allows me to separate each concern into it's own class. The window code is implemented in a Window class, input in Input, etc. I can use WinMain or a Game class to create each system and coordinate state between them.

Further, it allows me to divorce the renderer from the HWND itself. It seems smelly to me to have the renderer embedded directly within the Window. What if something happens to the window? What if I want to use the same renderer to output multiple views into separate windows (via CreateAdditionalSwapChain)?

The questions that arise from this:

Primary:

It seems I can just rebuild the swap chain to hook up to a new window. Do scenarios exist where the HWND could be invalidated or destroyed but I want to retain my rendering context? Or is this overkill?

Secondary:

Are there flaws to this approach I'm not considering?
Are there better implementations I'm not considering?


texts: Should I always prefer a Uniform Buffer Object to a uniform variable for per-model uniforms in OpenGL?

texts:
I was looking for a way to update uniforms for all of my scene objects efficiently and I came across the following gamedev stackexchange question, where the top answer gives a bonus tip. It states:

  So long as all your shaders agree on the layout and binding point of each such buffer then updating becomes a breeze. Models have no need to know anything about shaders at all. They need only update the model-view matrix in their constant buffer and the rendering pipeline will use it automatically

emphasis mine.

On the face of it, this seems like a preferable option; I don't have to worry about the uniform's location in a specific program object, or whether a program is bound to the current OpenGL context. I'll just establish a convention in my application for uniform variable names, update some global uniform buffer and render. This would also be nice if I have to support GLSL 1.5 and earlier, where I can't explicitly have a layout location qualifier in my vertex shader.

However, I read in this thread that some users disagree, saying that using UBO's over plain old uniforms incured an undesirable performance penalty.

Should I always prefer using UBO's over uniform variables? What are the pros and cons of each option for per-model uniforms?


texts: Use vsync event instead of a 16ms timer?

texts:
I found that in game development, most people set a timer that gets triggered every 16ms to do the rendering.

As an Android programmer, I'm familiar with the Choreographer. You set a callback that will do the drawing stuff, and each time vsync happens, the callback is called.

I know the original use of vsync is to prevent modifying the buffer when the front buffer and the back buffer are being switched. But don't you think making the drawing/render code have the same period as the actual screen refresh rate (in an ideal situation) is better?

So is there any reason why people don't prefer the vsync callback or vsync event based design?

One reason I can come up with is that if a monitor is 75Hz, it will be too high-frequency to do the rendering, right?


texts: How to dynamically animate a part of a 3d model towards something

texts:
I'm curious about how this sort of animation is typically done code-wise.

A few examples:

A character picks something up - only hand is animated towards the target
http://www.youtube.com/watch?v=rW-7uatehx4 see from 4:50 when the player picks up the weapon.
Character hangs from a ledge - hands are set to a specific location(the ledge)
http://www.youtube.com/watch?v=SOiwArn4Bmw right at the beginning.
Character looks at something - head is pointed at the target(npc looks at the pc)


texts: How do I implement level generation based on graph grammars?

texts:
I'm looking to do some pseudo-random map generation using graph grammars (graph rewriting).  However, most of what I can find online on this is purely academic and, while helpful, doesn't have any direct practical application.

For the uninitiated, the thousand-foot view of this is that say a dungeon room is generated, then based on a set of rules for that room, one rule is randomly chosen and applied adding more rooms.  From there, another specified room may go through the same or a different set of rules for additional growth of the map.

For the practical side of things, I'm thinking of storing the possible rules as arrays containing data about what additional rooms it contains, what order they are in, and which might also end up having a rule applied to it.  But then mapping this to 2D space, while it seems easy, may end up with some complications, such as what happens if rooms end up overlapping.

At any rate, I was hoping someone might have some insight into whether this might be done in a better fashion than an array for the rules.

The results from the rules will likely be added to a custom class that will hold the layout as it's built.

Thoughts? :)