texts: How did they make the screen move in Dangerous Dave?

texts:
I've made games in BASIC when I was a child, and I was curious about how the graphics were done in the 1988 version of Dangerous Dave made in C++; especially because they didn't have any worthwhile graphics packages those days.
Remember how when Dave reached the edge of the screen, the entire screen graphic used to move leftward in a sweeping motion? I remember reading that Romero had used a special technique to do that.
I've been wanting to create something like Dave, and was wondering

what graphics package/method they
used for Dave?
and how to make the entire screen
graphic move like they did?


texts: Is there a way to use the UnityEngine.UI with SteamVR and the Vive?

texts: I recently got into developing VR games using the Vive as my standard platform. Now I would like to design some UnityEngine.UI elements that would be interactable via the built in pointer scripts that come with the SteamVR module from the Unity Asset Store.  However, I can't seem to find any kind of built in method for allowing interaction between the pointers and buttons, scroll bars, etc.  I have also been unable to write anything myself that would do the trick, it's almost as if the Unity UI is just not designed to interact in a VR environment at all.  Does anyone have a method for using the UnityEngine.UI in a VR environment?  If so, can you please point me in the right direction?


texts: How many threads should I have, and for what?

texts:
Should I have separate threads for rendering and logic, or even more?

I'm aware of the immense performance drop caused by data synchronization (let alone any mutex locks).

I've been thinking of taking this to the extreme and doing threads for conceivable every conceivable subsystem. But I'm worried that may slow things too. (For example, is it sane to separate the input thread from rendering or game logic threads?) Would the data synchronization required make it pointless or even slower?


texts:
I'm not sure why my gravity isn't working... Can pleas anyone help??
Here my code:
import pygame

pygame.init()

white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)
black = (0, 0, 0)
red = (255, 0, 0)

w = 500
h = 500

x = 15
y = 480

vel = 5
screen = pygame.display.set_mode((500, 500))

square = pygame.image.load(r'/Users/lanik2009/Downloads/square.PNG')
square = pygame.transform.scale(square, (46, 40))
triangle = pygame.image.load(r'/Users/lanik2009/Downloads/triangle.PNG')
triangle = pygame.transform.scale(triangle, (46, 40))

def player():
    screen.fill(black)
    screen.blit(triangle, (80, 460))
    screen.blit(square, (180, 460))

jump = False

gravity = False

running = True

while running:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    keys = pygame.key.get_pressed()

    if keys[pygame.K_LEFT]:
        x -= vel

    if keys[pygame.K_RIGHT]:
        x += vel

    if gravity == True:
        y = 480

    if jump == True:
        gravity = True
        y -= 5

    if event.type == pygame.K_UP:
        y == 480

    if keys[pygame.K_UP]:
         jump = True

    player()

    pygame.draw.circle(screen, white, (x, y), 10, 500)
    pygame.display.update()

pygame.quit()


texts: Combinations for tiling two textures together

texts: Hi I need to create seamless ground with grass and dirt. I can make two textures connect seamlessly one to another. My question is how to figure out all the combinations, like (left, top, bottom, left-bottom, right-botton-left and so on)? Is there some kind of guide? Thank you in advance.


texts: How to bind more texture array objects into shader?

texts:
I can't find information if it is posiible, to bind few texture array objects into shader. Any searches for "array of texture arrays" or "multiple texture arrays" end with how to use texture array object.
I'm creating a texture array object in this way:

glGenTextures(1, &array_texture_object_A);
glBindTexture(GL_TEXTURE_2D_ARRAY, array_texture_object_A);
...
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);  //unbind

Texture array object is distinguishable by texture width, height and bits per pixel.
When I want to load texture with different size I create anoter texture array object:

glGenTextures(1, &array_texture_object_B);
glBindTexture(GL_TEXTURE_2D_ARRAY, array_texture_object_B);
...
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);  //unbind

And my question is how to bind array_texture_object_A and array_texture_object_B into shader.
(For example I have diffuse map in array_texture_object_A and specular map in array_texture_object_B).

For binding function (glBindTexture) first argument - target, has only GL_TEXTURE_2D_ARRAY enum, there is no something like GL_TEXTURE_2D_ARRAY_0, GL_TEXTURE_2D_ARRAY_1 etc. End now I'm stuck at this point.

Many thanks for any help.


texts: How can I manage entities(in entity component system) using Lua scripts?

texts:
Suppose I have a code like this in C++

// Game.cpp
Entity* hero;
Entity* witch;
... // entity initialization

if(/player near witch/) {
    if(hero->get<HealthComponent>()->getHealth() < 100) {
        say("Let me help you");
        witch->get<GraphicsComponent>()->setAnimation("witch.heal");
        hero->get<HealthComponent>()->setHealth(100);
    }
    else {
        say("Go away!");
    }
}

Suppose I want to put this code into Lua script, so I make an "interact" function in C++

void interact(Entity* first, Entity* second);

And call it like this:

interact(witch, hero);

Then I can call lua script, which gets first and second entity IDs and does something like this:

-- Script.lua
function interact(firstId, secondId)
    if(getHealth(secondId) < 100) then
        say("Let me help you")
        setAnimation(firstId, "witch.heal")
        setHealth(secondId, 100)
    else
        say("Go away")
    end
end

And then I can define wrapper functions in C++ like this

void setAnimation(int firstId, const std::string& animationName) {
    Entity* e = entities[firstId];
    e->get<GraphicsComponent>()->setAnimation(animationName);
}
// etc.

and call it from Lua. But this gets quite troublesome as I need to write lots of binding and wrapping(like "setAnimation") functions. Is there any other methods to control entitity behaviour using Lua?


texts: How to use "weighted average easing" correctly with variable framerate?

texts:
I often use a weighted average for smoothly animating numerical values to a target value, like so:

frame(dt) {
    value = ((value*someFactor) + targetValue) / (someFactor+1)
}

As you can see dt (delta time) is not used at all, so the result is not the same for different framerates. How can dt be applied correctly here?


texts: Level selection view - similiar to Angry Bird's

texts:
I am making game and need to prepare view for level selection. Could you recommend me some opensource library which could I use? I need icons to vibrate after long pressing one of them, some callbacks after choosing them, possibility to prepare custom icon's view, page control and horizontal scrolling. I was trying to use OpenSpringBoard but weirdly couldn't see scrollview and pagecontrol working in this project - it seems that there's possibility to use only one page. On the other hand, myLauncher(https://github.com/dlinsin/myLauncher) isn't so easy to include in project, as I need a seperate view with some delegate methods.

I need to be compatible with >iOS 4.2


texts: I'm trying to develop my own transformation gizmo (with x, y & z handles/arrows the user can grab and move, like in game engines), however, I'm not sure how I should calculate the 2D mouse delta along the 2D angle of the grabbed handle axis. I already have converted the base and tip of the handle/arrow to screen-space, and have calculated the screen-space points' angle between the screen-space base and tip. I'm just stuck on taking the X & Y mouse delta and getting the acceleration of the delta along that 2D angle. I've made a little visualization;


texts:
I'm making a multiplayer game built upon a lockstep system and I'd just like a better grasp on the concept. My main question is on how to get every command to simulate at the same time on every client, or rather, on the same points in each client's timeline. I'm using a fixed update of 10 frames per second for simulating every object's position from movement commands (Click and move style) the same way. How do I tell all clients to execute all commands at the same relative time to the first command?
Note I'm using Unity3D and a sufficiently accurate physics implementation. I just need to get across every command at the correct time.


texts: My game is just about finished! What do I do now?

texts:
I have an HTML5/canvas game just about finished and ready to launch. It's a 2d game in which you explore and disrupt a procedurally-generated landscape, crafting items and structures to survive. I have to finalize the 'ending' and fix a few bugs, but the game is pretty much ready for players.

The game will be free to play on the web, and I plan to begin working versions for iOS and the Mac App Store. I will also continue to add content to the game even after it launches.

Can anyone recommend things that I should remember to do before launching the game? Thanks!


texts: Creating a 3rd Person Flying Camera for 3D asteroids game

texts:
In order to learn PyOpenGL and test out an engine I am developing, I am trying to write a 3D asteroids flying space shooter game. Currently, I am implementing the camera using a "look at" function positioned right behind the player's ship. The player is able to control the yaw and pitch with the left+right and up+down arrow keys respectively. The results look like this (forgive the placeholder art):

And here is the code snippet in my Player class that implements that:

from pyorama.entity import Entity
from pyorama.math3d.vec3 import Vec3
from pyorama.math3d.mat4 import Mat4
import math

class Player(Entity):

    def __init__(self, model, camera):
        self.model = model
        self.center = self.model.mesh.compute_bounding_sphere().center
        self.model.transform = self.model.transform.translate(-self.center)
        self.camera = camera
        self.key_down_status = {"Left": False, "Right": False, "Up": False, "Down": False}
        super(Player, self).__init__()

    def update(self):
        messages = super(Player, self).update()
        for message in messages:
            if message.event_type == "key_down":
                key = message.data["key_name"]
                if key in self.key_down_status.keys():
                    self.key_down_status[key] = True
            if message.event_type == "key_up":
                key = message.data["key_name"]
                if key in self.key_down_status.keys():
                    self.key_down_status[key] = False

        self.model.transform = self.model.transform.translate(self.center)
        if self.key_down_status["Up"]:
            self.model.transform = self.model.transform.rotate_x(-0.01)
        if self.key_down_status["Down"]:
            self.model.transform = self.model.transform.rotate_x(0.01)
        if self.key_down_status["Left"]:
            self.model.transform = self.model.transform.rotate_y(0.01)
        if self.key_down_status["Right"]:
            self.model.transform = self.model.transform.rotate_y(-0.01)
        self.model.transform = self.model.transform.translate(-self.center)
        self.model.transform = self.model.transform.translate(Vec3(0, 0, 0.1))

        right = self.model.transform.data[0:3]
        up = Vec3(*self.model.transform.data[4:7])
        forward = Vec3(*self.model.transform.data[8:11])
        position = Vec3(*self.model.transform.data[12:15])

        temp = self.model.transform
        self.model.transform = self.model.transform.translate(+self.center)
        right = self.model.transform.data[0:3]
        up = Vec3(*self.model.transform.data[4:7])
        forward = Vec3(*self.model.transform.data[8:11])
        position = Vec3(*self.model.transform.data[12:15])

        self.camera.view = Mat4.look_at(position - 20 * forward, position, up)
        self.model.transform = temp

As you can see, the ship stays perfectly still behind and the world rotates around. As a result, it looks very unnatural, as if a 2D ship sprite was simply glued onto the screen!

So my question is, how are third-person cameras in flying games typically implemented? What would a keyboard+mouse control scheme look like that controls yaw, pitch, roll, banking, acceleration/deceleration, etc? Would the camera controls for the camera be separated from moving the ship? Any help would be greatly appreciated.


texts: Spotlight turns off on and based on distance and angle, even in editor

texts:
I have cloned a spotlight 3 times.  The original and one clone are near eachother and both work as expected.  However, the other two are a few meters away, and behave oddly.  I initially noticed in the player, but it also happens in the editor. If you get a few meters away they go out. I eventually noticed it also happens based on angle, as demonstrated below.

I am relatively new to Unity, but I've asked the other devs and they are stumped.  What could cause this?


texts: What is eigenvalue decomposition and why would it be useful in games?

texts:
In various math libraries developed for game engines, I see 2x2 and 3x3 square matrices having this function (along with some helper functions). I tried to find information regarding it but did not come across game specific material (wikipedia entry is quite heavy and does not relate to games).

It would be great if in your answer, you could provide an example or two on how it is used in games.


texts:
I want to combine A* pathfinding with evasion, pursuit, and fleeing.  For example, if I tell an agent to move to a position and avoid enemy agents on the way, it will create an A* path towards that point, and try to move along the path while also trying to avoid enemy agents.

There are plenty of tutorials online about A* and plenty of tutorials about steering behaviors, but I can't find anything that talks about using the two in unison.

Is the following the correct way to implement this?

Calculate the agent's destination vector as a vector from the agent's current position to the A* path's next waypoint.
Calculate the agent's steering vector using standard steering calculations.  For example, when evading an enemy agent, the steering vector will point directly away from the enemy agent.  If multiple agents are being evaded, the steering vector will be a sum of those two evasion vectors.
Calculate the agent's movement vector as the sum of the vectors from step 1 and step 2.  Move the agent according to this vector.
Repeat steps 1-3 each frame.
Periodically calculate a new A* path for the agent since best the path to destination may change as the agent moves around while evading enemy agents.

Assuming the above is correct, I have a follow-up question.  I tried implementing the above behavior and a problem I'm running into is when an agent is trying to avoid an enemy who is directly in between him and the destination.  In this case, the steering (evasion) vector points in the opposite direction as the destination vector.  Adding those two vectors together results in a zero vector, so the agent doesn't move.  How should I handle this?  Should I force to the agent to move perpendicularly to the enemy in this situation to break out of this cycle?


texts: How to determine the visibility of a single vertex, given a viewpoint?

texts:
I have a 3D triangle mesh, and I want to know, given a viewpoint (defined by a model, view and projection matrix), if a certain vertex is visible or not.

My approach was to render the mesh using standard software rasterization (I can't use OpenGL/DX), i.e. project all the triangle vertices to screen-space, then loop through each triangle's bounding-box and rasterize/shade the pixels inside the triangle (using barycentric coordinates). I'm also using a z-Buffer here, and the rendering works fine.

To find out if a certain vertex point is visible, my naive idea was then to just project that vertex from 3D to 2D using the same matrices, and comparing the z-value I get for that pixel to the value in the z-Buffer.

However, this approach does not work, I get vertices flagged as visible that should be invisible and vice versa.

I believe this is because of the following: When I render the triangles, I loop over the bounding-box of the triangle and set the color and depth value by interpolating a value between the 3 triangle vertices, using barycentric coordinates. Thus, the depth value written to the z-buffer for a given point (x, y) on screen is a linear combination of the z-value of the 3 vertices that make up the triangle. In contrast to that, when I project the single vertex later, I render the exact point, independent from any triangles, and thus get a different z-value for the same (x, y) location on screen.

Is my assumption on why it is not working correct, and how would I correctly determine the visibility of a vertex in the mesh?

Update: Let me clarify what's going on with this picture:

Let's say v0 = (1.1, 1.1), v1 = (6.7, 2.1), v2 = (3.7, 6.7) after projection to screen-space.
When rendering/rasterizing the triangle, I have a loop

for x = 1 to 7 // from floor(min(v0.x, v1.x, v2.x)) to ceil(max(v0.x, v1.x, v2.x))
    for y = 1 to 7 // same for y
        current_pixel_center = (x+0.5, y+0.5); // we want calculations to use the center of pixels
        alpha = ..., beta = ..., gamma = ...; // calculate the barycentric weights for current_pixel_center
        if all 3 bary. weights > 0 // means the pixel is inside the triangle
            z_value_of_curr_pixel = alpha * v0.z + beta * v1.z + gamma * v2.z;
            // Do the z-test and then draw the pixel at position (x, y), and set the z-buffer at (x, y) to the new value 'z_value_of_curr_pixel'

So the pixel at position (1, 1) in my drawing gets some color and z-value based on the barycentric weights calculated for this point, it is close to v0 so probably something like alpha = 0.95, beta = 0.02, gamma = 0.03.

Now, in contrast to that, I am later interested in knowing if the single vertex v0 is visible (I don't have any information about triangles at that point). So I project the vertex v0 which will land at (1.1, 1.1) in screen space and end up with a z-value as well. However this z-value will be different than the one that is in the z-buffer for this pixel, because the z-value in the z-buffer has been calculated using the barycentric weights of the triangle for the middle point of the triangle. So I can't determine if the vertex v0 is visible or not.

To rephrase: The z-value in the z-buffer is from the red dot in the image (produced when rendering the triangle), and it is different from the z-value of the projection of the vertex v0 which is exactly at position v0.


texts: Can I use glTranslate and glRotate when my GLSL Version over (#version 120)?

texts: I was using "GLSL Version #120". But now i am trying to do one tutorial and it is using "gl_ClipDistance[0]" inside of vertex shader. And "GLSL Version #120" doesn't support "gl_ClipDistance[0]". Now i need to change GLSL Version with over #120 for example #330 . I also have to change "gl_ModelViewProjectionMatrix" inside vertex shader. But my question is i need to change glTranslate,glRotate,glLoadIdentity etc ?


texts: `setVelocity` allows body to pass through bodies

texts:
In my game, I'm using cocos2d-x and I wanted to have an object that changes direction immediately, so I used setVelocity() on the physics body to do that.

However, when I do that it can run through my physics body that surrounds the screen.  It bumps into it, but ultimately, it gets through.  I tried increasing how thick this other body is, and that does successfully prevent it from getting all the way through, but it still makes progress into the body before getting ejected out.

So, for now, I have changed it to move by calling applyImpulse().  With this method, it hits the edge and works the way I'd expect.  However, the movement behavior is different than I'd like for this case.

Some have said that they increased the number of substeps taken by the physics engine.  I could do that, but it feels like something else is wrong.

Has anyone run into this before?


texts:
I've been following the tutorial for amazon iap v1 (because it seems a lot easier than amazon iap v2) but when I built the android app and went onto the shop screen the app just force closed. Here's all the code:
For CurrencyAmount.cs:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using System;
    using System.Collections.Generic;
    using AmazonCommon;

    public class CurrencyAmount : MonoBehaviour {

        public Text coinText;
        public Text diamondText;
        public int coins;
        public int gems;
        public string[] items;
        // Use this for initialization
        void Start(){
            AmazonIAP.initiateItemDataRequest(items);
        }
        void Update () {
            coins = PlayerPrefs.GetInt("CoinAmount");
            gems = PlayerPrefs.GetInt("DiamondAmount");
            coinText.text = coins.ToString ();
            diamondText.text = gems.ToString ();

        }
        void itemDataRequestFailedEvent()
        {
            // If you get this response, either retry or stop purchase attempt.
            Debug.Log( "itemDataRequestFailedEvent" );
        }
        void itemDataRequestFinishedEvent( List<string> unavailableSkus, List<AmazonItem> availableItems )
        {
            // Do not continue with the purchase attempt if the your SKU is in the list of unavailable SKUs!
            Debug.Log( "itemDataRequestFinishedEvent. unavailable skus: " + unavailableSkus.Count + ", avaiable items: " + availableItems.Count );
        }

        void purchaseFailedEvent( string reason )
        {
            // The reasons for failure on a Consumable are:
            // INVALID_SKU
            // FAILED
            // You should log the reason, but in every case, do not entitle content
            Debug.Log( "purchaseFailedEvent: " + reason );
        }
        //This is connected to the buttons
        public void BuyGems(string nameOfPackage){
            AmazonIAP.initiatePurchaseRequest( nameOfPackage );
        }

        void purchaseSuccessfulEvent( AmazonReceipt receipt, int GemsToBuy )
        {
            // On successful purchase, you may entitle content
            Debug.Log( "purchaseSuccessfulEvent: " + receipt );

            // You should preserve the token for use with
            // Receipt Verification
            string purchaseToken = receipt.token;
            gems = gems + GemsToBuy;
            PlayerPrefs.SetInt ("DiamondAmount", gems);
            PlayerPrefs.Save ();
        }

    }

here's the link for amazon sdk


texts: screen coordinate not working with pixel values

texts:
I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why.

If I draw a line that goes from 0,0 to 100, 100 for example, I would expect it to draw a line from one corner of the screen to a little way in. I would expect it to treat these numbers as screen coordinates. Instead, the line is huge! A line of about 2 long fills the whole screen. Why is this? How can I modify my shader to 'think' in screen coordinates?

// a struct for the vertex shader return value
struct VSOut
{
float4 Col : COLOR;    // vertex color
float4 Pos : SV_POSITION;    // vertex screen coordinates
};

// the vertex shader
VSOut VS(float4 Col : COLOR, float4 Pos : POSITION)
{
VSOut Output;
Output.Pos = Pos;    // set the vertex position to the input's position
Output.Col = Col;    // set the vertex color to the input's color

return Output;    // send the modified vertex data to the Rasterizer Stage
}

// the pixel shader
float4 PS(float4 Col : COLOR) : SV_TARGET
{
return Col;    // set the pixel color to the color passed in by the Rasterizer Stage
}

// the primary technique
technique10 Technique_0
{
// the primary pass
pass Pass_0
{
    SetVertexShader(CompileShader(vs_4_0, VS()));
    SetGeometryShader(NULL);
    SetPixelShader(CompileShader(ps_4_0, PS()));
}
}


texts:
Maybe I shouldn't be asking for this but I cant find any tutorial about it. How do I get the key pressed and the character representation of it in Xorg like in Win32 that I know ESC_KEY is the ESC_KEY no matter the keyboard layout. Right now I only can get the physical key but not the virtual key.
Edit:
I am using xlib and I dont want to use a higher level library like glfw or sdl since I want to learn to interface with xorg


texts:
I am making a little turn based strategy game in pygame, that uses a grid system as the main map to hold all the characters and the map layout. (Similar to Fire Emblem, or Advance Wars)

I am trying to determine a way to quickly and efficiently (i.e. without too much of a slow down) check if there are any characters within a given range of the currently selected character.

So to illustrate:

O = currently selected character
X = squares within range

Range of 1:

    X
  X O X
    X

Range of 2:

     X
   X X X
 X X O X X
   X X X
     X

Range of 3:

      X
    X X X
  X X X X X
X X X O X X X
  X X X X X
    X X X
      X

Now I have to tell the user who is in range, and I have to let the user choose who to attack if there are multiple enemies in range.

If I have a 5x5 grid, filled with " " for empty and numbers for the characters:

[ ][ ][ ][ ][4]
[ ][1][ ][ ][ ]
[ ][ ][ ][ ][ ]
[ ][ ][2][3][ ]
[ ][ ][ ][ ][ ]

Depending on which character the user selects, I would like to show the user which other characters are in range. So if they all had a range of 3:

1 can hit 2
2 can hit 1 or 3
3 can hit 2
4 cannot hit anyone.

So, How do I quickly and/or efficiently run though my grid and tell the user where the enemies are?

PS- As a bonus, if someone could give an answer that could also work for a minimum distance type range, I would give them a pat on the back and a high five, should they ever travel to Canada and we ever meet in life.

For example:
Range of 3 to 5: (- is out of range)

          X
        X X X
      X X X X X
    X X X - X X X
  X X X - - - X X X
X X X - - O - - X X X
  X X X - - - X X X
    X X X - X X X
      X X X X X
        X X X
          X


texts:
As a Defrag player, I would like to add advanced movements to my (simple) game, in particular strafe jumping. I currently have basic fps movements (WASD and free look to be clear), but how can I add quake-like movement techniques?
This article explains very well the theory behind it, but I really don't know where to start to actually implement it.


texts: Can a local multiplayer iOS game display differently for each device?

texts:
I've seen games which display different data for two devices, but not more than two.

If possible, can it be accomplished using GameKit?

EDIT:
More specifically, I was thinking local multiplayer via bluetooth or wi-fi on an iOS device. Most games I've seen display the same screen synchronized across all of the devices.

I understand games that network across the internet do this, often using a server, but I haven't seen any examples of a 3+ device local multiplayer iOS game. I just want to make sure it wasn't some kind of limitation.


texts:
Every time I try to click on the button, nothing happens. I am linking some picks to help everyone answer my question.

I have added a event system. I have a canvas. The button is set to interactable.


texts: Can't get the current animation state name (hash or .IsName) to work

texts:
I have some hard times trying to get the current animation state name in Unity, to perform specific actions while I'm in a certain state.
I want to know when I'm the "ThoughtsStill" state, I only have the default layer (Base Layer):

To do this, here is what I tried:

AnimatorStateInfo curr_state = _animator.GetCurrentAnimatorStateInfo(0);
if (curr_state.shortNameHash == Animator.StringToHash("ThoughtsStill"))
{
    Debug.Log("I'm in ThoughtsStill state").
}

which is not working.

I also tried with IsName() method but it is not working too (both tried to compare "Base Layer.ThoughtsStill" and "ThoughtsStill").

I'm certain that I'm going in this ThoughtsStill state but I don't know why I can't get it.

Do you guys have any ideas or leads?

Thanks !


texts: How to get a smooth path for a vehicle in a 2D top down map?

texts:
I am making a 2D tile based game which involves having AI that needs to traverse the map avoiding obstacles in a natural and smooth path (NOT NECESSARY THE SHORTEST)

The orientation of the vehicle is also important in the example above the initial orientation of the vehicle is to NORTH but the orientation of the vehicle at the destination doesn't matter.

All I could do now is to compute the path using A* or a BFS fill through the center of the tiles.

This is an example of a desired path:


texts: How to get light level (brightness) of a particular location?

texts:
I'm making a 2D top-down survival game similar to Rimworld, I'm trying to emulate a day-night system.
Many features depend on whether any tile is light (or dark) enough, based on time of day or other light sources such as torches, so I'm wondering if there's an easy way to detect how much light there is on a certain tile without making a whole system that tracks light on a per-tile level (or maybe the latter option is better)?
I am using Unity 2020.3.6f1 and the URP, which means I'm going to be using the 'new' 2D lights.
EXAMPLE:
When it's nighttime, I'm going to disable the global light (sun) so those tiles will be pitch black.
When it's daytime, the global light will have an intensity of 1 so that tile will have 100% brightness (look normal).
When it's nighttime, but there's a torch, the tile where the torch is sitting on will have 100% brightness, and that will slowly fade to 0% over a span of 5 tiles.
Making a system that updates every single tile in the game with information about the light level seems pretty expensive. Is there a way we can observe a block "graphically", or in other words, literally look at the pixel on the screen, and determine it's alpha value to check for light level?
Any suggestion is super welcome.
EDIT:
Every tile does not need to know its brightness every frame, but they do need to know it less often. Some examples are:

A plant checking every couple of frames to see if it can grow
A character checking every couple of frames to see if he's in the dark (and if he is, he needs to start panicking)

More importantly, I need my characters to make decisions based on light amount. For an example, if there is a job that needs to be done at a certain location, a character should first check the light level of that location before going to do it.


texts: In order to define boundary of each tile, I need to have individual image of the tile. Is there any way to extract each image of tiles from a tileset?


texts: How are 3D models created in video games?

texts:
How are 3D models in games designed and displayed? Is it all code? Drawn on paper, then on a 3D graphics software, then... what?

Of course, game programmers won't define every vertex of every shape(/object,) they want to be drawn, all in code (whether in Direct3D or OpenGL.) So, do the game designers have tools to use, like Maya or something like it of proprietary 3D graphics softwares out there; they "draw" the model in that software, export it in whatever format, then programmers parse it via code and automatically enter the decoded/parsed raw vertices of the object/model?

I have Googled much but I couldn't find something solid to explain how this aspect of professional video games is worked on.


texts: How should I interpret these DirectX Caps Viewer values?

texts:
Briefly asking - what do the nodes mean and what the difference is between them in DirectX Caps Viewer?

DXGI Devices
Direct3D9 Devices
DirectDraw Devices

The most interesting for me is 1 vs 2. In the Direct3D9 Devices under HAL node I can see that my GeForce 8800GT supports PixelShaderVersion 3.0. However, under DXGI Devices I have DX 10, DX 10.1 and DX 11 having Shader model 4.0 (actually why DX 11? My card is not compatible with DX 11).

I am implementing a DX 11 application (including d3d11.h) with shaders compiled in 4.0 version, so I can clearly see that 4.0 is supported.

What is the difference between 1 and 2? Could you give me some theory behind the nodes?


texts: When will the computational powers be strong enough to let play big games like Battlefield, COD from cloud?

texts:
Is there any current service similar to Steam but without having to download any games?  In other words, buy digital rights to play and play from the cloud?

How much bandwidth would be necessary to play it purely online, and how fast must the network be?

Do you think it will become a reality in near future (for example, in the next 10 years)?


texts: Same game logic on two separate graphic libraries

texts:
What code philosophy/structure of abstraction/program design would allow a game to be used with both 2D and 3D graphics (separately) WITHOUT having to re-code the Game logic?

We're talking taking the same code, changing a minimum of things (for example, exchange filenames for 2D assets with filenames for 3D assets), and maybe plugging in a few specialisations of a base class per generics/templates.

To put it in a real context where it makes sense: imagine a LAN-multiplayer game where there is one top-notch, performance-hungry 3D client for the players with some really good gamer rigs, and a more humble 2D client for the old dusty boxes that someone found in their attic. But it's still the same game - the same events are registered (someone picked up a coin), the same Network protocol is used, the worlds are proportional, etc.

To put it in a MVC context: The Controllers are the exact same (pressing the "Up" key will set the players acceleration at 3.5 units/second), the Views are totally different (2D versus 3D), and the Model is the same except for anything directly related to graphics (a collision check for the environment is performed every 5 seconds, and it uses the same algorithm. Note that this would mean there IS a Z-coordinate for all the Game Objects in the 2D version, but it's just ignored or displayed to the user in another way, for example by a shadow that is displayed further left when the player is in the air).

What makes this such a fascinating topic is that it would FORCE the developer to have a very clear idea of how his data is structured and how control flows. Note that this does not imply using anything other than a graphics library like SDL, D3DX or OpenGL. No game engines!

Since this is a mostly theoretical question, I'll leave programming languages out of it, but if you want to give an example you can use any language you like, C++ if you want to go the whole hog, or even Brainfuck if you feel up to the challenge (Any concrete answers will be appreciated, as well as any abstract ones!).


texts: Why do I get "function not supported" exceptions for OpenGL 3.2 functions using LWJGL?

texts:
I am currently having an issue trying to initialize a frame buffer using LWJGL. When I try to call GL32.glFramebufferTexture(int, int, int, int) it throws a "Function is not supported" error. I have checked to make sure that the function is supported on my system using an OpenGL Extensions Viewer.

Here is the exact error:

Exception in thread "main" java.lang.IllegalStateException: Function is not supported
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58)
at org.lwjgl.opengl.GL32.glFramebufferTexture(GL32.java:389)
at com.domain.name.graphics.GameWindow.startRendering(GameWindow.java:145)

Line 145 in GameWindow looks like:

GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, colID, 0);

colID is set as such:

colID = GL11.glGenTextures();

Any help would be very welcome.

System info & proof of function support:


texts:
Currently in our game we use a 4 directional movement. Some abilities are triggered on mouse click and "fired" in the direction the player has clicked.
For this, I have split the screen in 4 sectors (like 2 diagonal cuts) to determine in which general direction the player has clicked.

Back then, I found a short helper class for this:

public static class Triangle
{
    private static Vector2 topLeft = new Vector2(0, 0);
    private static Vector2 topRight = new Vector2(Orbs.graphics.PreferredBackBufferWidth, 0);
    private static Vector2 bottomRight = new Vector2(Orbs.graphics.PreferredBackBufferWidth, Orbs.graphics.PreferredBackBufferHeight);
    private static Vector2 bottomLeft = new Vector2(0, Orbs.graphics.PreferredBackBufferHeight);

    //Return true if p1 and p2 are on the same side of BA
    private static bool SameSide(Vector2 p1, Vector2 p2, Vector2 A, Vector2 B)
    {
        // Convert points to Vector3 for use the Cross product, which is Vector3-only
        Vector3 cp1 = Vector3.Cross(new Vector3(B - A, 0), new Vector3(p1 - A, 0));
        Vector3 cp2 = Vector3.Cross(new Vector3(B - A, 0), new Vector3(p2 - A, 0));
        return Vector3.Dot(cp1, cp2) >= 0;
    }

    //Return true if the point p is in the triangle ABC
    private static bool PointInTriangle(Vector2 p, Vector2 A, Vector2 B, Vector2 C)
    {
        return SameSide(p, A, B, C) && SameSide(p, B, A, C) && SameSide(p, C, A, B);
    }

    public static string GetAndSetPlayerOrientationByClickedSector()
    {
        Vector2 playerCenter = new Vector2(//getPlayerCenter);
        Vector2 mouseWindowPos = Microsoft.Xna.Framework.Input.Mouse.GetState().Position.ToVector2();

        if (PointInTriangle(mouseWindowPos, topLeft, playerCenter, topRight))
            return "North";

        if (PointInTriangle(mouseWindowPos, topRight, playerCenter, bottomRight))
            return "East";

        if (PointInTriangle(mouseWindowPos, bottomRight, playerCenter, bottomLeft))
            return "South";

        if (PointInTriangle(mouseWindowPos, topLeft, playerCenter, bottomLeft))
            return "West";

        return "";
    }
}

Now, we are extending our movement in eight directions and therefore I need to extend this helper class to return the diagonal directions (SouthEast and so on) as well.

I am not even sure if this is doable properly with this approach, but I guess I only need to define the points of the additional triangles.
Any suggestions on how to solve this are welcome.


texts: Accessing entity config data without singleton

texts:
Every entity has some stats which change over time and some which are static for a given type of entity. For example current hp vs max hp: lets say humans have max 100hp, then every human would have an int hp member, but it doesn't make sense to have a const int max_hp=100 for all the humans since it's always the same thing.

That can be solved by using static member variables, but here's the catch: I want to load all the stats such as max_hp from a config file when the app starts, which precludes use of static.

The only way I know how to reconcile these two things is to use a singleton object, which provides entities their stats via something like singleton::instance().model("human").stat("max_hp"). However, every mention of singletons I have ever seen has been in the context of warning against their use. And I wouldn't want to use it anyway, because then my entity update methods lose referential transparency.

So in short:

I want to avoid duplicating data.
I want to load that data from file.
I want to avoid global state.
Update methods must be pure functions.

What strategy can I use to meet these requirements?

I require update methods to be pure because my engine is built around the concept of updating every entity in parallel, and the way to do that is to have entity.update be a pure function which takes an immutable reference to the world and returns a new entity [0]. So every entity starts its update by making a copy of itself, which is then mutated as it goes through the update process, until finally being returned to the world to become the manifestation of that entity in the new generation. Now that would be a lot of copying if only the dynamic data were copied! But to also copy all the (duplicate) static data every frame is just crazy, and I'm looking for the approach which would let me copy only the dynamic stats while still having access to the model data.

[0] https://www.youtube.com/watch?v=Uooh0Y9fC_M


texts: Creating smooth lighting transitions using tiles in HTML5/JavaScript game

texts:
I am trying to implement a lighting effect in an HTML5/JavaScript game using tile replacement. What I have now is kind of working, but the transitions do not look smooth/natural enough as the light source moves around. Here's where I am now:

Right now I have a background map that has a light/shadow spectrum PNG tilesheet applied to it - going from darkest tile to completely transparent. By default the darkest tile is drawn across the entire level on launch, covering all other layers etc.

I am using my predetermined tile sizes (40 x 40px) to calculate the position of each tile and store its x and y coordinates in an array.

I am then spawning a transparent 40 x 40px "grid block" entity at each position in the array

The engine I'm using (ImpactJS) then allows me to calculate the distance from my light source entity to every instance of this grid block entity.

I can then replace the tile underneath each of those grid block tiles with a tile of the appropriate transparency.

Currently I'm doing the calculation like this in each instance of the grid block entity that is spawned on the map:

var dist = this.distanceTo( ig.game.player );
var percentage = 100 * dist / 960;

if (percentage < 2) {
    // Spawns tile 64 of the shadow spectrum tilesheet at the specified position
    ig.game.backgroundMaps[2].setTile( this.pos.x, this.pos.y, 64 );
}
else if (percentage < 4) {
    ig.game.backgroundMaps[2].setTile( this.pos.x, this.pos.y, 63 );
}
else if (percentage < 6) {
    ig.game.backgroundMaps[2].setTile( this.pos.x, this.pos.y, 62 );
}
// etc...

The problem is that like I said, this type of calculation does not make the light source look very natural. Tile switching looks too sharp whereas ideally they would fade in and out smoothly using the spectrum tilesheet (I copied the tilesheet from another game that manages to do this, so I know it's not a problem with the tile shades. I'm just not sure how the other game is doing it). I'm thinking that perhaps my method of using percentages to switch out tiles could be replaced with a better/more dynamic proximity forumla of some sort that would allow for smoother transitions? Might anyone have any ideas for what I can do to improve the visuals here, or a better way of calculating proximity with the information I'm collecting about each tile?

(PS: I'm reposting this from Stack Overflow at someone's suggestion, sorry about the duplicate!)


texts: HTML5 canvas multiplayer game with node.js and Isogenic engine

texts:
I want to create a multiplayer game using Isogenic engine i understand that this technology uses html5 and canvas for rendering graphics in frontend and node.js for backend. I started working on how the game should work and what i need to accomplish what i want. I understand that node.js goes well with noSQL dbs. My question is what should i use SQL or noSQL for the game?

Game will be multiplayer RPG with heavy accent on chatting feature, so i have many thing to store. But i cant figure out which one should i choose. What would be benefits of choosing eather? Maybe i should think about other solution? Any tips would be much appreciated. :)

EDIT: What i actually meant was, can mongoDB store user personal data, like passwords, emails. Is there security issues? Because i know node.js is not the best for communicating with relation databases.


texts: How to make a Sprite be displayed always behind everything else?

texts:
What I am in need to achieve is to have a Sprite always facing the camera identically to what happens with any simple game UI object, but instead of always displayed above everything else, it should be always displayed behind everything else.

How can I achieve that in Unity using C#?

Regarding the always-behind rendering, I tried setting the Sprite's "Order in Layer" to 0 or to negative values, with no success. I also tried setting all game objects to a greater value than the sprite's:

    go.GetComponent<Renderer>().sortingLayerName = "Test";
    go.GetComponent<Renderer>().sortingOrder = 1;

That did not work as well.

What would be the correct way of making a sprite to be always displayed behind everything else (other sprites, GUI and 3D meshes) - preferably not having to resort to shaders, if possible?

PS:regarding the effect of the Sprite always facing the camera as in a game UI, I suppose it will be only a matter of updating its rotation towards the camera - but I would be happy to find out if other approaches are avialable/more suited to the task.


texts: Why does WorldToScreenPoint return "strange" results?

texts:
I would like to show a menu to the right side and at the same y coordinate as a certain gameobject (shown as a green cube in the screenshot).

Therefore I'm trying to get the screen coordinates of the object in my scene using WorldToScreenPoint.

The code I'm using is this:

Vector3 nPos = new Vector3(GlowCube.position.x + GlowCube.localScale.x, GlowCube.position.y, GlowCube.position.z);
Vector3 nOff = Camera.main.WorldToScreenPoint(nPos);

The resulting values however don't look right to me.
I have created a red rectangle in order to demonstrate where the coordinates "nOff" would actually be in the screen:

At first I thought I get these strange results because the GlowCube is parented to the case, but since I use GlowCube's world coordinates (GlowCube.postion...) and not its local coordinates (GlowCube.localPosition...), I thought that this wouldn't matter.

What am I forgetting here?

Thank you!


texts:
I've made a simple game in pygame/pymunk. Currently my maps consists of lists with functions, e.g

ground_segments = [ground(position, size, shape...), ...]

I have equally built up lists for planks, stones, trees etc. And althoug it works, it is a bit tideous to work with.

I tried first tried making a tile-based map editor and .txt files to read/write to, but having a grid of letter felt limiting to wha I could add. Since I had a working concept of importing lists with the information I tried to build on that, but stopped once I realised I couldn't edit the contents of map.py fromlevel_editor.py. Is there a workaround for that or do I need anothter concept? If so, any suggestions?


texts: How to correctly represent a bone system?

texts:
I'm currently representing my bone system as follows, in pseudocode:

root = {}
root.rot = v3(0,0,0)
root.pos = v3(0,0,0)

function create_child(parent,rot,length):
    child_bone = {}
    child_bone.rot = parent.rot + rot
    child_bone.pos = parent.pos + v3(0,0,bone.length).rotate(child_bone.rot)

This works for most situations, but sometimes I get weird occasions where rotating a parent bone makes the child bones rotate wildly. What is the proper mathematical representation of a bone system?


texts: Browser game - small models with tileable textures vs one big model and one big texture

texts:
I am few years behind in terms of browser capabilities. I plan to combine 3D with pixel art, and I am going to use Unity to make a browser based game.

I have made a stage that is one model and has around 1k poly's. Then I made a large 2048x2048 texture for it. Lots of that texture is tileable, I'd say that I could fit unrepeated parts on a 256x256 texture while the rest is just repeated content. This looks like a huge waste when I just tile it manually in photoshop on a big texture file and I feel like I am doing something "dirty".

But when I would split that one model into 100 models and tile them separately with 32x32 textures, that would make more sense, but would increase model count from 1 to 100.

What is the correct way to do this? Lots of models with tiled textures, or screw it and make one big model with one large texture? Or maybe performance now is so great I don't even need to care and just do whatever?

Thanks


texts: Using a GLSL fragment shader to draw a texture in the middle of a quad

texts:
I'm not sure how possible this is, but I'm trying to use a fragment shader to draw a portion of a texture in the middle of a quad. This is all 2D. The quads consist of four vertices from (0, 0) to (width, height). The modelview matrix is transformed to position the quads.

I have a sprite sheet of 32x32 icons and a 32x32 quad that one of the icons is mapped to. In a vertex shader, I'm creating a 2 pixel 'border' around the quad by moving it's vertices out by 2 pixels. In a fragment shader, I want to display the texture with it's original size, in it's original position; basically, there should be no visible difference between the original 32x32 quad and the 36x36 quad. The result should be an invisible 'border'.

The only solution I can come up with is calculating the window coordinate for the corner of the quad in the vertex shader, then passing it to the fragment shader and subtracting it from gl_FragCoord, in order to get the position of each pixel relative to the corner of the quad. With this information, I can display the texture in the center of the quad, with it's original size.

Is there any easier way to accomplish this?


texts: Create entity from template in component-based engine

texts:
For my project I would like to use a component-based entities in C++. My current implementation is split to these parts:

Systems - Contain a map of components of certain class and operate on these. For example PhysicsSystem has a vector of PhysicsComponents.
Components - A component contains some public variables and a maybe a constructor to initialize them.
Entities - An entity for me is just an Id. It is however not stored anywhere, instead only its components are stored in systems in map (where key is entityId and value is pointer to the component).

My problem is creating instances of different objects in my game. I would like to define objects in XML (could be any text file format). For performance reasons this file should be parsed only once when the program is run.

That means I should create some template from it in my ObjectFactory and associate it with a name. Then I would simply call factory.CreateObject("Player") to add new entity to the game.

I am not really sure how to implement this without too much overhead code. Another concern is, that the I don't want my factory to know about the systems themselves. But because my components are stored in the systems and not an Entity object, I will need to use some messaging system to pass new components to their appropriate system.

My question is, how would I implement the object spawning with template for each object type? And how do some engines describe their objects with configuration files?


texts: Transforming position in y-axis (going in the middle) in Unity

texts:
I am making a 2d game where an object goes up, down or in the middle with given Input.

But when the object goes to the middle with GoMiddle() it starts glitching and it can't go back up or down

Vector2 Pos;
public bool DownKeyPressed = false;
public bool UpKeyPressed = false;
public bool MiddleKeyPressed = false;

// Use this for initialization
void Start()
{

}

// Update is called once per frame
void Update()
{
    Pos = transform.position;

    UMDCOntroller();

    transform.position = Pos;
    print(Pos.y);
}

void GoDown()
{
    if (Pos.y >= 1.2f)
    {
        Pos = Vector2.Lerp(Pos, new Vector2(Pos.x, Pos.y - 1.2f), 0.1f);
    }
    else
    {
        DownKeyPressed = false;
    }

}

void GoUp()
{
    if (Pos.y <= 2.8f)
    {
        Pos = Vector2.Lerp(Pos, new Vector2(Pos.x, Pos.y + 1.2f), 0.1f);
    }
    else
    {
        UpKeyPressed = false;
    }

}

void GoMiddle()
{

if(Pos.y < 2)
    {
        Pos = Vector2.Lerp(Pos, new Vector2(Pos.x, Pos.y + 1.2f), 0.1f);

    }

else if(Pos.y >= 2) {

        Pos = Vector2.Lerp(Pos, new Vector2(Pos.x, Pos.y - 1.2f), 0.1f);

    }
    else
    {

        MiddleKeyPressed = false;
    }

}

void UMDCOntroller()
{

    if (Input.GetKeyDown(KeyCode.S))
    {
        DownKeyPressed = true;

    }

    if (DownKeyPressed)
    {
        GoDown();
        UpKeyPressed = false;

    }

    if (Input.GetKeyDown(KeyCode.D))
    {

        MiddleKeyPressed = true;
    }

    if(MiddleKeyPressed)
    {

        GoMiddle();

    }

    if (Input.GetKeyDown(KeyCode.W))
    {

        UpKeyPressed = true;

    }

    if (UpKeyPressed)
    {

        GoUp();

    }

}

I am asking this question again because I didn't receive an answer

Thanks


texts: How do I change a sprite using code from another node?

texts:
I'm trying to make a program in Godot where the player can put a bunch of images into a folder, and when the button is pressed, have the image appear as a sprite on the screen. With the current code, the directory for the image is printed when the button is pressed, but the image sprite simply does not appear. No error messages come up either, so I'm stumped as to what the problem is. Here is the code:
extends Button

func _pressed():
    var cards_order = [] #creates the array

    var path = "assets/cards/" #defines a path
    var dir = Directory.new() #creates a directory
    dir.open(path) #sets the directory to the defined path
    dir.list_dir_begin() #begins listing the directory
    while true:
        var file_name = dir.get_next() #sets the var "file_name" to the next entry in the directory
        if file_name == "":
        #break the while loop when get_next() returns ""
            break
        elif !file_name.begins_with(".") && !file_name.ends_with(".import"):
        #get_next() returns a string so this can be used to load the images into an array. Also stops .import files from being added
            cards_order.append(load(path + file_name)) #loads the next file into the array
    dir.list_dir_end()

    randomize() #changes the randomization

    cards_order.shuffle() #shuffles the array

    var card_sprite = cards_order.front() #sets card_sprite as the first item in the array

    print(card_sprite.get_path())

    $"/root/CardSprite".texture = load(card_sprite.get_path())

Any help with this would be greatly appreciated!


texts: Is there a way to set a pallet for colours in an SVG image and change them at runtime for one gameobject?

texts:
in the latest beta build for unity they introduced the ability to import svg files. What I'd like to know is if there is a way to identify all svg shapes by colour, and then change those colours, as if you were changing a class in CSS.

I suspect that you can go into an svg file, find where the text for colour is found and then change it, but I'm worried it'll change it for any object that use that svg file instead of changing it by gameobject.

The thing I'd like to do here is have customizable characters in a fighting game, where you can go into the menu and change their colours on a slider. so if I can identify like 3 colours in an svg and list them, and then edit those values in runtime or load, I'll have what I need


texts: How to implement Meshlab's rotation manipulator?

texts:
I want to implement a rotation handle/manipulator mechanism that would enable user to rotate a 3D model exactly like Meshlab does.

Unfortunately I don't fully understand how does the rotation gizmo work. In particular I don't understand how to make the model rotate only around the Z axis. Open Meshlab and try rotating only the blue circle to see what I mean. Rotations around the X and Y axis are easy to understand for me though.

How does one recreate the rotation mechanism of Meshlab, i.e. how exactly does horizontal and vertical panning translate to changes in angles?


texts: Is there a way to reimport an asset with new import options?

texts:
I'm trying to help out a friend with an Unreal issue.  He has a character model that's been imported and used in a map.  A bunch of work has already gone into setting up the scene before anyone noticed that the model was imported without morph targets, because for some bizarre reason Unreal's FBX importer has morph target import turned off by default and hides the option behind an "advanced options" section so you don't even notice it.
UE4 does offer the ability to reimport an asset, or even to reimport the asset with a new file, in the asset's right-click context menu, but neither of these actually fixes the problem because they don't pull up the import options dialog box that you get when importing a new model!  This makes it impossible to reimport the model with the morph targets turned on.
I could import the FBX as a new asset, which would give the import options box, but the existing asset is already in use, in multiple different places, and there doesn't appear to be any easy way to tell it "replace all instances of this model with that model."
Is there any good way to fix this that doesn't involve tearing everything down and rebuilding it from the ground up?


texts: "Solve" a game algorithmically -- creating bots (and making them smart)

texts:
EDIT :  at first I gave a lot of context for this question, explaining why I wanted to create a bot. I'm sorry it distracted people from my "actual" question.

My question is pretty simple : how does one create a bot for a game ? (Especially... on a mac, if it's possible -- though I can use a Linux virtual machine if needed).

Is it interfaced with the application, or just "watching" the screen and extracting information from it (as if it was taking pictures and analyzing them to get informations such as your HP, your position, etc.) ?
Could I use python to code it, or are there specific languages ?

The forementioned context :

Since I started programming, I've wanted to try to create algorithms that would be able to "play" (or even "beat") video games. Many games require only logical choices, more and more complex as the difficulty grows, which seems perfect for algorithms.

I currently enjoy the game "Pixel Dungeon" a lot (see here), but it's not always nice to you (and you die. A lot.). A few researches on the internet show that a lot can be achieved just by following simple guidelines.

So I figured maybe this would be a good game to try and create bots to play it. In the long term, I would like to let bots play, extract data out of it, and modify my algorithms according to these data.
I am really enthusiast about this, but also really novice.

(maybe this belongs more to https://stackoverflow.com/ ?)


texts: Check every body's position and delete or not (box2d performance specific)

texts:
I have a simple game with a platform (a ground that's not infinitely long). During the game I have about 10-30 balls on average that'll fall off the platform. There's gravity so I think they'll keep falling until the end of the game. My question is should I put a function that check if position within boundary in the render() function,  render() function is called in every frame. Or should I leave those balls falling. And let box2d keep on calculating their speed and velocity etc?

So basically I'm wondering which cost less, checking every body's position or calculating dropping object's velocity and position. I think they happen with same frequency, once per frame.

Or is this trivial for 10-30 balls and I can ignore it?


texts: Nvidia Nsight 4.6 VS Edition. The Graphics debugger can't find glew32.dll

texts:
I'm trying to debug some textures and FBO's with Nvidia Nsight 4.6 VS Edition.
But when I select either "Start CUDA debugging" or "Start graphics debugging" I get an error.

"The program can't start because glew32.dll is missing for your computer. Try reinstalling theprogram to fix this problem"

The application runs just fine when I'm not using Nsight. What might be my problem?

My system;
Windows 7 x64 bit.
Nsight 4.6 x64 bit.
GTX 580 with lastest drivers.
OpenGL version 3.3.
Building a Win32 application. (Tried to change the build target to x64 but that just resulted in a bunch of linking errors for glfw and glew)


texts: Mesh Triangulation that is insideoutside aware

texts:
am working on an algorithm for procedural generation of 3D meshes for caves in a side-scroller game.

The algorithm nicely computes contours and also points inside the caves that are supposed to be anchor points for the mesh. A sample for this can be seen in the following image:

The idea is that each of those anchor points has a distance to the view-pane depending on their distance to the contour. This way the caves have a roughly spherical shape in 3D.

This is also the reason I added those anchor points because having triangles from wall-to-wall would not enable me to have actual 3D caves.

However, the problem now is how to make the triangles. I found a nice implementation of the Delaunay triangulation algorithm. However that yields me the following mesh:

Obviously this algorithm is not aware of what's inside my cave and what is not and thus forms triangles completely outside of the caves. Pruning those outliers does not yield good results because then the contours of the caves are interrupted.

I have heard of "ear cut" algorithms that can work with concave shapes like my outlines. However those are not compatible with the anchor points I require.

What I'd need is a triangulation algorithm that allows me either to add anchor points inside the figure, or that allows me to limit the maximal length of vertices thus computing anchor points on its own.

Is such an algorithm known?

Huge thanks!


texts: Unity3D - Determining if a spherical object is grounded using raycast

texts:
I'm making a game revolving around moving a ball around a space. My game has a jump mechanic, so I need to know when I'm grounded in order to determine when I'm able to jump. Best way to check this is to setup raycast from ball's origin and make it constantly face downwards. However, I'm running into an embarrassing issue: the ball keeps rotating, so I'm not able to find a constant downward ray to use for finding the ground.

I started making code that looks similar to this, which the object's local transform:

bool grounded = false;
Ray ray = new Ray(transform.position, -transform.up);
RaycastHit hit;

if(Physics.Raycast(ray, out hit)){
//determine if object is on ground
grounded = true;
}

This caused the issue I stated earlier, where the ray would point downward but only relative to the object's current rotation. In other words, if the ball was upside-down, the ray would be pointing upwards.

My current code for this look similar to this, which now uses world space to determine what is 'down':

bool grounded = false;
Ray ray = new Ray(transform.position, -Vector3.up);
RaycastHit hit;

if(Physics.Raycast(ray, out hit)){
//determine if object is on ground
grounded = true;
}

However, in this instance, the ball raycast actually points directly to position Vector3(0,-1,0), which is even weirder than my initial problem and shouldn't be an issue based on other posts about this issue.

The only other way I can think of to properly determine whether the object is grounded is to see if it collides with anything. However, the other reasons I want to determine whether the player is grounded using raycast are:

for determining whether the player is over an endless pit (e.g. if they fell off the world) in order to start a kill/respawn timer
to ensure the player can perform a move equivalent to a butt stomp while in the air

If anyone knows how to perform a raycast on a spherical object in Unity, it's be much appreciated.


texts:
I'm prototyping a 2D platformer/brawler game for uni and I'm having some trouble with creating collision/bounding boxes. This is most likely going to end up on a Vita so I do have some library constraints as well as performance implications.

None of this has yet been implemented but is all theory.

My idea was to have the artist create a sprite sheet for the character animation and then a second identical sprite sheet with the corresponding  collisions in a solid colour (e.g green for where the character can be hit and red for dealing damage, near the foot if kicking etc.)

With this, I would then parse the collision sheet and generate the various collisions required storing them in the character model. This is the point I feel would be most inefficient.

While I think this is a possible solution, I was wondering if there was a more standard way of doing this or a more efficient way as I feel this would have severe performance problems.


texts: Releasing a demo in an unfinished state?

texts:
I'm a fairly unexperienced game developer, (despite having some coding abilities) as i never really had the opportunity to launch more than 1 "finished" game.
So in terms of getting the word out, marketing or even getting usefull feedback of players, i have very little experience.

Now, i'm working for almost 3 years on a game which i'm developing in my spare-time. Despite its pretty long development cycle it is a fairly "simple" game.

The question i'm asking myself multiple times (and more frequently as time goes on) is:
- When should i release a demo? (Should i release a demo at all?)

I don't want the players to play it now and loose interest afterwards after the game finishes. (as it will take maybe another full year until it is even remotely finished.)
But at the same time i know that i have to do something in terms of marketing (it is going to be a free game, but i would like to reach as much people as i can) as despite the 3 year long development cycle, not many people know about this project. (Which isn't really optimal, as i have a potential target audience which i know would like a game of this type.)

My strategy up to this point was to simply develope it in my spare time, not having a demo at all and only showcasing (meaningfull) progress of the game in youtube videos (This videos are released every 2 or 4 months, depending on how much time i have to develope the game...) and only release the game after it is more or less finished.

Its a very strage scenario for me to be in. I would love to let people know about the project (like every other dev), but at the same time i fear that people will be put down by its quality (alpha-state) and that they aren't going to be interested in it afterwards after they played it. (The only thing you can currently do is to "free-roam" > no objectives whatsoever.)

So my question is:
Am i to worried about this stuff? Should i release a demo? (Now or later after it's more polished?)
What are your experiences in releasing games or using demos?


texts: How do I split a texture into differently shaped pieces with libgdx?

texts:
I want to split a texture into variously shaped pieces with libgdx, like the pieces of a puzzle game. TextureRegion.split() is not an option, as it splits into equally sized rectangular texture regions.

The "Similar Questions" section here is helpful (particularly this question How do I break an image into 6 or 8 pieces of different shapes?), but I'm not sure yet if it's possible to implement the solution with libgdx.

Any pointers?


texts: (LibGdx) Get mouse position in ENTIRE game

texts: I'm trying to get the mouse position IN GAME. By that I mean not the position on the screen, but inside the window. I've been using Gdx.input.getX(), but that's not INGAME. How do I do this?


texts: UI looks different between editor and in game

texts:
I am very confused about Unity's UI system.

This is how my inventory menu looks in the Editor:

And this is the view in game:

Settings

Can someone please explain why this happens?


texts: Organising gameobjects into multiple lists

texts:
I have a very simple little game that consists of a player, zombies, food, and treasure. It's all automated. The player will walk towards a zombie and shoot within a certain distance, which costs energy. If the player goes below a certain energy level, it will find the closest food item and walk towards that and once the player has reached it, the player will gain energy, and continue to move towards zombies and shoot them, until all are dead and the player will movie towards the zombie.
This is meant to be a way of learning object oriented programming for a class, so standard functional concepts such as ECS do not apply (and its so simple that would be overkill). Currently I have an array of GameObjects that all other objects such as player, zombie etc inherit from that gives them a position and an image to render (I'm aware an object shouldn't be responsible for its own rendering). All GameObjects are put into this array so I can interate through it and rendering everything which works fine. But not every entity requires an update, so I made an updatable interface, allowing classes that require updating to implement. So now i'm in  a situation where there are two lists, renderable game objects, and updatable game objects. My problem arises when the player must operate on a specific subset of entities at a time. e.g. find all the zombies or all the food items to determine which is the closest. So would it be better then, to have arrays of zombies, and arrays of food items instead that I can pass to the player to operate on? And since only 2-3 game objects will need to actually be updated, should I just not bother putting them into a list to be updated and just keep a list of all renderables, with seperate lists for all zombies and food items etc?
Any thoughts on how this could be best designed would be appreciated.


texts:
I tried removing the Unicode Whitespaces in the string using words[len].Trim() but still there's still an extra character.

Every letter represents the coordinate of where the letter is. As you can see there's an extra coordinate/value and it is always located at the end of the string. (dont mind the '# tries')
Can you help me Identify what is the extra invisible unicode and what to do in order for it to be removed?

private string[] FisherShuffle(string[] words) {
    int len = words.Length;
    while(len > 0) {
        float index = Mathf.Floor(Random.Range(0f, 1f) * len);
        len--;
        var temp = words[len].Trim();
        words[len] = words[(int)index];
        words[(int)index] = temp;
    }
    return words;
}

UPDATE:
I have found out that the ASCII value is 13. I also have tried using TrimEnd('\n','\n') & words[len].TrimEnd(System.Environment.NewLine.ToCharArray()) to no avail

private string[] FisherShuffle(string[] words) {
    int len = words.Length;
    int index;
    string temp;
    while(len > 0) {
        index = (int) Mathf.Floor(Random.Range(0f, len));
        len--;
        //temp = words[len].TrimEnd('\n','\r');
        temp = words[len].TrimEnd(System.Environment.NewLine.ToCharArray());
        words[len] = words[index];
        words[index] = temp;
    }
    return words;
}


texts:
I am clueless with regards to animations. I have a simple rendering engine that renders models, sprites, skyboxes and whatnot; but everything is simply static with no animations whatsoever. With my engine written in C++ and OpenGL I will have to learn how to implement animations accordingly; but any OpenGL book or tutorial I look for doesn't explain animations. It's probably one of those topics which being so complex requires its own book or something.

Does anyone know any great resources to explain how I can programme animations? I'm not interested in learning how to design them, rather just the technical side of it, you know: bones and all. I would also welcome tips as to the general concept of modern animations in OpenGL. If it also means much, I use assimp as my model loader. Suffice it to say, how does a programmer animate a model to 'run' or 'jump'?


texts: What is the simplest 3D file format to parse?

texts:
I want to parse Blender-Made Files directly into my homemade Lisp program. I've been pulling data out of .X3D files manually. Is this the best format to focus on writing a parser for?

Thanks!


texts:
I'm having trouble understanding exactly what glMultiDraw* does, and when it should be used.

Is it to be used if I have one VBO with multiple objects in it or do I use it with many VBO's?

It would be great if someone could give a real example of how to use this is a VAO/VBO as all the stuff I've found on google just explain what the function does rather that how to use it practically.


texts: Several years ago motion capturing was only possible for big name studios due to cost.  Now it seems that it is moving into the realm of indie developers due to lowering costs and better technology.  I've researched it a bit and seen two major options:  IPISoft and iClone which both cost several hundred dollars and use fairly cheap hardware(Kinect or PS3 eye).  I was wondering if anyone could recommend any other alternatives?


texts: Access Android Camera.Parameters from Unity

texts:
I would like to access the android defined class

Camera.Parameters.getHorizontalViewAngle()

from a Unity3D c# script but my java skills are limited. Can anybody offer any help?
I have this code:

using UnityEngine;

#if UNITY_ANDROID
public class CameraParametersAndroid
{
    public static float HorizontalViewAngle { get; protected set; }
    public static float VerticalViewAngle   { get; protected set; }
    public static int   numCameras      { get; protected set; }

    static CameraParametersAndroid()
    {
        AndroidJavaClass unityPlayerClass = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"),
                         cameraClass = new AndroidJavaClass ("android.hardware.Camera"),
                         cameraParametersClass = new AndroidJavaClass ("android.hardware.Camera.Parameters"),
                         cameraInfoClass = new AndroidJavaClass ("android.hardware.Camera.CameraInfo");

        AndroidJavaObject currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
        object[] args = {currentActivity};

        AndroidJavaObject camera = cameraClass.CallStatic<AndroidJavaObject>("getCamera", args);

        if (camera != null)
        {
            AndroidJavaObject cameraParameters = camera.Call<AndroidJavaObject>("getParameters");

            numCameras = camera.Call<int>("getNumberOfCameras");
            HorizontalViewAngle = cameraParameters.Call<float>("getHorizontalViewAngle");
            VerticalViewAngle   = cameraParameters.Call<float>("getVerticalViewAngle");

        }
        else
        {
            Debug.LogError("[CameraParametersAndroid] Camera not available");
        }
    }
}
#endif

but not even the getNumberOfCameras() call works.


texts: How does Texture2D.GetData return coloured pixels?

texts:
I'm trying to work out how the pixels are stored in the returned array but I'm not having a lot of luck (and thus my calculations don't seem to be working).

I realize that the pixels are stored in one long continuous array but are the pixels grabbed width first or height first? I've tried drawing out the "pixels" of a texture on paper to calculate where the pixels should be based on the single array but I'm not getting expected results.

My assumption is the following:

Assuming I am using i to specify rows and j to specify columns that any given pixel in a 2D texture can be calculated by the sum of i * j or is this incorrect?


texts: 2d block based game storing water simulation

texts:
I am making a 2d block based sandbox game like terraria.

I'm trying to think where is the better place to store water in, data structure wise.

That is, to store it in the block world array, or to store it in its own sparse data structure. Does doing this have any benefits?

If I store it in the world array I have to store the fluid level (which would be like 16 levels possible). The other way I could simply have a fluid cell struct or something.

It might make things more clear separating it, but not sure if it would possibly affect performance either way.

In a game like this, the simulation is of course usually done via cellular automata (just in case that affects which data structuring I should use)


texts: Easiest Way To Implement "Slow Motion" and variable game speed in XNA?

texts:
I have an XNA 4.0 game that I want to be able to switch into slow motion and back again to full speed every now and then.

So if you kill an enemy the game switches into slow motion as they explode and then goes back to normal.

What is the easiest way to do this in XNA 4.0 without having to alter all my existing code that relies on GameTime?

I have some code that relies on the TotalGameTime, which will be wrong unless I get XNA to slow down. Is there anyway to avoid refactoring that code?

Thanks!


texts:
I used a php server to communicate with my unity application . I want to send post data with content type so that my php server can use the approriate variable for the content type , for example if i send post request with content type "file" , my php server can use $_FILES[][] instead of $_POST[], and i am a beginner and i'm too skeptical to use $_POST[] to handle upload request from unity application to server .
My best guess is that i must use something from WWWForm to achieve it , but in my opinion the documentation isn't friendly enough for beginner like me . Can someone here lend me a hand to achieve this ? (sending post request with content type)
Oh , also , i'm sorry for too much using php in my example , below is how i achieve it in html, i can achieve it in html by using something similar to this code :
(this html send POST request to upload a pictures with "file" as it content type)

<form method="POST" enctype="multipart/form-data">
<label>
Browse Image
<input type="file" name="pictures" style="display:none">
</label><br>
<button name="upload">
Upload Now
</button>
</form>

Please forgive me if my english is too bad , thank you .


texts: Resources on expected behaviour when manipulating 3D objects with the mouse

texts:
In my animation editor, I have a 3D gizmo that sits on the origin of a bone; the user drags the mesh around to rotate the bone.

I've found that translating the 2D movements of the mouse into sensible 3D transforms is not near as simple as i'd hoped.

For example what is intuitively 'up' or 'down'? How should the magnitude of rotations change with respect to dX/dY? How to implement this? What happens when the gizmo changes position or orientation with respect to the camera? ect.

So far with trial and error i've written something (very) simple that works 70% of the time. I could probably continue to hack at it until I made something that works 99% of the time, but there must be someone who needed the same thing, and spent the time coming up with a much more elegant solution.

Does anyone know of one?


texts: How to make a PROPER main menu (or any other UI windows/modals) in Unity?

texts:
So, I'm currently learning both about Unity for the first time as well as the 'new' 2D UI system, but I'm having a hard time figuring out how to make windows, modals/dialogs, main menus etc. which are not only functioning, but also modular, reusable and written following proper coding standards. Most how to's, blogs, Q&As or tutorials I find only cover the most basic parts of UI development (e.g. how to drag a button from the toolbar to the scene window in 2 hours).

So basically, I'd like to have a main menu which meets those (very common) requirements:

A button which 'starts' the game (e.g. by simply loading another scene)
A button which 'quits' the game, but also opens up a confirmation dialog before
A button which opens up an options dialog, which again is composed of multiple parts (audio, video...)
and finally, it should be possible to go back to the previous screen using a 'back key/button', for example Escape

What I started with is a canvas which I called GameMenu. This canvas has several nested canvases, such as

MainMenu
OptionsMenu

OptionsMenuAudioPart
OptionsMenuVideoPart

CancelMenuModal

Then I created a menu script which works as some sort of state machine:

public class MenuScript : MonoBehavior {

    private GameObject _currentStateObject;
    private GameObject _previousStateObject;

    public void SetState(GameObject newStateObject) {
        if(newStateObject == null || newStateObject)
            return;

        if(CurrentStateObject != null)
            CurrentStateObject.SetActive(false);
        _previousStateObject = _currentStateObject;
        CurrentStateObject = newStateObject;
        CurrentStateObject.SetActive(true);
    }
}

Every button has now an event trigger attached which calls the SetState(...) method on MenuScript.

However, I've got the following problems:

How do I pass multiple parameters to methods invoked by event triggers? As soon as I add another parameter to SetState(...), for example bool isModal = false to tell the method that it shouldn't disable the previous state, then it disappears from the event trigger action selection menu.
How to I register key press events within the event triggers? It's easy by script (Input.GetKey(...) etc.), but I didn't find one on the event type selection.
How do I make e.g. event triggers conditionally? So that certain events cannot be called when certain states are active?

I know I can solve all those problems within the script and make a fully functional main menu which does exactly what I want, but then...

I cannot use it for something else
I don't use the new Unity UI system, which makes me wonder what's the purpose of it
I got to reference all involed game objects (the canvases, buttons etc.) in script, which makes it not really 'extendable' anymore as this means for every changed requirement, I have to alter the script (e.g. a new state, menu, button etc)

The main goal in the end is a script which I can use for all kinds of UIs without writing the same logic over and over again just because it's another scene, game state etc.


texts:
I was working in the next scene, the font I used has worked well in another scene, but why when I go back to this "main menu" scene does the font look destroyed (previously show well)?

Screenshot :

I tried everything from resizing, reinputting text, and redownloading the font asset but it keep show like this. Any thoughts?


texts: Why are my animated objects (from Blender) always playing at the global origin in Unity?

texts:
I created and animated a sledgehammer in Blender 2.67b using an armature. The sledgehammer has one animation (created using the Action Editor) called "Idle". I parented the imported sledgehammer to an empty GameObject and set the sledgehammer's position to (0, 0, 0). I then moved the parent GameObject to where I want it in the scene. When I launch the game, the animation plays but the sledgehammer child always re-positions itself to be at the global origin, no matter where I place the parent GameObject. See the image below:

Notice how the sledgehammer's position goes from (0, 0, 0) to (-1087, -3, -1149).

The armature has a single bone and has the sledgehammer object as a child. I've spent about 4 hours looking this up on the Internet, but it seems like parenting the animated mesh to an empty GameObject worked for everyone else except me. Anyone else experience this? I've tried both .fbx and .blend files.


texts: How to achieve rendering at huge distances?

texts:
These days I was reading some information about the upcoming GTA V technology, in particular, how it is able to truly render all buildings you can see without a draw distance cap or any faking.

Since I will soon be prototyping a big city environment, I wanted some advice on this topic. We're talking about a really big city, with simple geometry but fully lit and shadowed. My doubt comes in particular to the projection matrix, which imposes a maximum draw distance (the zFar parameter).

Now, at the same time, I read everywhere that zFar should be as small as possible for better rendering results, in particular related to depth buffer issues etc, because of the floating point issues.

So, assuming my computer can render this big city in a stable framerate, how should I approach the problem of rendering parts of the city which I can see REALLY far away, fully lit and shadowed? Shadow maps also seem to have problems with low depth buffer precision..

Thanks


texts: Counting multiple touches using Cocos2dx 3.2

texts:
I'm trying to count the number of active touches in screen in order to perform an an action in case that there are two touches:

auto jumpListener = EventListenerTouchAllAtOnce::create();
    jumpListener->onTouchesBegan = [=](const std::vector<Touch*>& touches, Event* event)
    {
        CCLOG("Multi-touch detected %d", touches.size());
        if(touches.size() == 2)
        {
            this->_player->jump();
        }

    };

But even if I'm touching with two fingers, I get that only 1 touch has been made, any suggestions?


texts:
I am developing a platformer game with the XNA framework, like "Metroid", but in 3D. I have to draw models, and I have the question of the title. I read many posts, and I know that the main data structures for draw polygons are octrees, quadtrees, BSP and Portals; but I read and read, and I don't know what is best.

What data structure should I use for a 3D platformer game?


texts: Unity - Small holes of light seems to go through my blender mesh

texts:
So, I am currently working on a low-poly terrain in Blender which will be flat-shaded in Unity. It all works great, however I am working on a cave for the terrain, and I seem to be getting these small odd light artifacts:

I have tried to highlight them with the read circles. If you look carefully, you can see the small holes.

The odd thing is, the entire mesh should be completely solid. Here's a screenshot of the cave entrance in blender (which is the floor I'm looking at in Unity)

All normals of the faces seems to be facing correctly, and mesh has simply been modelled by extruding edges from existing parts of the mesh, so there shouldn't actually be any actual holes.

Does anyone have any experince with this kind of problem?


texts: What is the difference between D3D12 structures/functions with terminal 1 in the name and without?

texts:
I could not figure out the difference between for instance
CD3DX12_DESCRIPTOR_RANGE and CD3DX12_DESCRIPTOR_RANGE1.

Why do both exist? Which should I use? Is there a general rule of behavior/usage/recommendation for all structures and functions with both naming?


texts:
When i call gldrawarrays with a large set of data will the function return only after drawing all the vertices or will it happen asynchronously b/w cpu and gpu?

Also how does vsync work. Aren't they related?


texts: Pseudo-magnet implementation with chipmunk

texts:
How should I go about implementing "natural" magnet on a certain body in chipmunk space? Context is of simple bodies lying in the space (think chessboard). When one of the figures is activated as a magnet - others should start moving towards it.

Currently I'm applying force (cpBodyApplyForce)to the other figures with vector calculated towards the activated figure. However this doesn't really feel "natural". Are there any known algorithms for imitating magnets?


texts: In OpenGL, what does it mean to make a context current?

texts:
I have a few questions :

1 - What does it mean to make a context current? Does it mean that all subsequent OpenGL calls will apply to that context/window?

2 - With GLFW3, how to use multiple windows (say, 2)? Is it enough to create 2 windows/contexts, make the context current on the first one, draw things, then make the context current on the second window, and draw things?

3 - How does it all fit together with an OpenGL loading library (like gl3w)? When I initialize gl3w once after creating the contexts, will the OpenGL calls work on the context that is current even if I change it alot or will I have to re-initialize gl3w each time I make another context current?


texts: Collision detection problems using AABB's

texts:
I implemented a simple collision detection routine using AABB's between my main game sprite and various platforms (Please see code below).  It works great, but I'm now introducing gravity to make my character fall and it's shown up some problems with my CD routine.

I think the crux of the matter is that my CD routine moves the sprite back along the axis in which it has penetrated the least amount into the other sprite. So, if it's more in the Y axis than the X, then it will move it back along the X Axis.

However, now my (hero) sprite is now falling at a rate of 30 pixels per frame (It's a 1504 high screen - I need it to fall this fast as I want to try to simulate 'normal' gravity, any slower just look weird) I'm getting these issues.  I will try to show what is happening (and what I think is causing it - although I'm not sure) with a few pictures: (Code below pictures).

I would appreciate some suggestions on how to get around this issue.

For clarification, in the above right picture, when I say the position is corrected 'incorrectly' that's maybe a bit misleading.  The code itself is working correctly for how it is written, or put another way, the algorithm itself if behaving how I would expect it to, but I need to change it's behaviour to stop this problem happening, hope that clarifies my comments in the picture.

My Code

public boolean heroWithPlatforms(){

    //Set Hero center for this frame
    heroCenterX  = hero.xScreen+(hero.quadWidth/2);
    heroCenterY  = hero.yScreen+(hero.quadHeight/2);

    //Iterate through all platforms to check for collisions
    for(x=0;x<platformCoords.length;x+=2){

    //Set platform Center for this iteration
    platformCenterX = platformCoords[x]+(platforms.quadWidth/2);
    platformCenterY = platformCoords[x+1]+(platforms.quadHeight/2);

    // the Dif variables are the difference (absolute value)
    // of the center of the two sprites being compared (one for X axis difference
    //and on for the Y axis difference)
    difX = Math.abs(heroCenterX-platformCenterX);
    difY = Math.abs(heroCenterY-platformCenterY);

    //If 1
    //Check the difference between the 2 centers and compare it to the vector (the sum of
    //the two sprite's widths/2.  If it is smaller, then the sprites are pverlapping along
    //the X axis and we can now proceed to check the Y axis
    if (difX<vecXPlatform){

    //If 2
    //Same as above but for the Y axis, if this is also true, then we have a collision
    if(difY<vecYPlatform){
        //we now know sprites are colliding, so we now need to know exactly by how much
        //penX will hold the value equal to the amount one sprite (hero, in this case)
        //has overlapped with the other sprite (the platform)
        penX = vecXPlatform-difX;
        penY = vecYPlatform-difY;
        //One sprite has penetrated into the other, mostly in the Y axis, so move sprite
        //back on the X Axis
        if (penX < penY){hero.xScreen-=penX*(heroCenterX-platformCenterX>=0 ? -1 : 1);}
        //Sprite has penetrated into the other, mostly in the X asis, so move sprite
        //back on the Y Axis
        else if (penY < penX) {hero.yScreen-=penY*(heroCenterY-platformCenterY>=0 ? -1 : 1);}
        return true;
        }//Close 'If' 2
        } //Close 'If' 1
    }
    //Otherwise, no collision

    return false;
    }


texts: Boat passing under a bridge in a 2D tile based RTS

texts:
I'm writing a 2D tile based RTS. And I want to add a 'pseudo 3D' feature to it - bridges over the rivers.

I havent't start any coding yet, just trying to think how it fits the collision detection model. A boat passing under the bridge and a unit moving over the bridge will eventually occupy the same cell on the map. How to prement them from colliding?

Is there a common approach to solve such a problem? Or I need to implement a 3D world to do this?


texts: Box2D: Efficient method to create b2Chainshapes for a tile-based map?

texts:
I'm working on a platforming game with tile based levels. I store the collision model for my tileset in an array.

This is how the collision model for a 4x4 tilesheet would look like (I can't post pictures yet so this link will have to suffice: Tileset example). The red dots are the vertices of the b2ChainShape.

When I load a level, I look up the collision model for each tile and create a b2Body at the corresponding place. The problem is that between the tiles, my character can experience a "bump" because it gets stuck on the edge of the shape of the next tile's body.

Is there an existing algorithm to connect the bodies of neighbouring tiles to a single b2ChainShape? Or should I ditch the idea of tile-based collision models all together and simply create the collision model for the whole map with the Tiled map editor? I don't create the the collision map with the Tiled map editor at the moment, because it is very time consuming for slopes and hills.


texts:
I'm trying implement A* Start path finding in my games(which are written with JavaScript, HTML5 Canvas). Library for A* Start found this - http://46dogs.blogspot.com/2009/10/star-pathroute-finding-javascript-code.html and now I'm using this library for path finding. And with this library, I'm trying write a simple test, but stuck with one problem. I'm now done when in HTML5 canvas screen click with mouse show path until my mouse.x and mouse.y. Here is a screenshot:

(Pink square: Player, Orange squares: path until my mouse.x/mouse.y)

Code how I'm drawing the orange squares until my mouse.x/mouse.y is: http://pastebin.com/bfq74ybc (Sorry I do not understand how upload code in my post)

My problem is I do not understand how to move my player until path goal. I've tried: 'http://pastebin.com/nVW3mhUM

But with this code my player is not beung drawn.(When I run the code, player.x and player.y are equals to 0 and when I click with the mouse I get the path player blink and disappear)

Maybe anyone know how to solve this problem?

And I'm very very very sorry for my bad English language. :)


texts: Connecting android game with website to show user scores on logon

texts:
How do I make my android game users logon to my website to see their scores? I can create fb login in app and website, but I need to show the score of the particular user in the website.
An example: A user opens my game,sees a login page(saves data online) or sign in as guest(saves data locally), plays sometime. If user goes to my website using the login, they should see their scores there.
This should be achievable by using Google play services. How do I make the user login to my website using google play login?. Is that even possible?


texts:
I am writing a Tower Defense for Android.
Right now my LevelScreen contains a Background-Actor which is pan-able and some zones to buy Towers - after buying them you can upgrade them further.
When you click a Zone or a Tower, a small overlay on the bottom appears (another actor) - click it to buy.
My main Problem was that the overlay stayed where you clicked and didn't move when you pan the Screen.
I solved this by changing the overlay's draw method to

batch.setProjectionMatrix(game.batch.getProjectionMatrix());
batch.draw(texture,actorX,actorY);
batch.setProjectionMatrix(levelScreen.stage.getCamera().combined);

I set it backwards for further Actors who should stay where they are - Towers for example - but I kinda don't know what I am really doing.

I am now only able to fire the touchDown Event on these actors when I pan to the bottom left of the Screen and click where the Actor's Icon is.

I tried a few things:

-Adding another Stage as a HUD(I couldn't Access the lower stage anymore or the other way around)

-Moving the actor.x and actor.y along (I was unable to even find where the actor went)

-Adding another camera (led to nothing)

-Updating the actors Position using

stage.getCamera().unproject(myPoint)

(same as when I tried to move the actor)

So, which is a good way to implement what I look for? Basically,
TL;DR:
I am looking for a way of letting some Actors stay relative to Screen while moving some Actors with the world while panning around.

I am pretty sure there a similar questions but None of them really helped me and I have restricted Internet-Access (for example I can't Access badlogicgames.com).


texts: How to switch screens when a button is pressed? LibGDX

texts:
Currently working on a game for school and I ran into a problem. I created a Main Menu for my game with the buttons (Play, Level Picker, and Settings). What I'm trying to do is when the "Play" is pressed it will switch to a different screen where the user will play. The menu is under the name of MainMenu and the screen I want it to switch to is called StartGameScreen. I've tried looking online for my answer but can't seem to find something that will work. If it helps here's my code for the play button. Any help would be fantastic!

TextButton playButton = new TextButton("Play", (com.badlogic.gdx.scenes.scene2d.ui.Skin) skin); // Use the initialized skin
playButton.setPosition(Gdx.graphics.getWidth() / 2 - Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 2 + (playButton.getHeight() + buttonOffSet));
playButton.addListener(new ClickListener() {

    @Override
    public void clicked(InputEvent event, float x, float y) {
        System.out.println("play game button clicked");
    }
});
stage.addActor(playButton);


texts: For normal mapping, why can we not simply add the tangent normal to the surface normal?

texts:
I am looking at implementing bump mapping (which in all implementations I have seen is really normal mapping), and so far all I have read says that to do this, we create a matrix to convert from world-space to tangent-space, in order to transform the lights and eye direction vectors into tangent space, so that the vectors from the normal map may be used directly in place of those passed through from the vertex shader.

What I do not understand though, is why we cannot just use the normalised sum of the sampled-normal vector, and the surface-normal? (assuming we already transform and pass through the surface normal for the existing lighting functions)

Take the diagram below; the normal is simply the deviation from the 'reference normal' for any given coordinate system, correct? And transforming the surface normal of a mapped surface from world space to tangent space makes it equivalent to the tangent space 'reference normal', no?
If so, why do we transform all lighting vectors into tangent space, instead of simply transforming the sampled tangent once in the pixel shader?