texts: Poor mobile performance when running from Eclipse

texts:
So after weeks of thinking my rendering code was bad, I accidentally discovered the following:

Running my game on a Nexus S

From Eclipse (Debug as -> Android application): 12fps
From the device
while still attached to USB (getting log info in Eclipse still):
24fps
From the device while not attached via USB: 56fps

I was wondering if anyone else has issues like this?  I mean, the problem really isn't a problem since the final release build will likely have good performance, but for the time being I don't want to have to keep (un)plugging my device in and out when testing code all day long.

Is there some remedy for this or does anyone have any input/advice?

Thanks.


texts: So I have an object that is bouncing around the screen randomly, physics still works on it so it will speed up or slow down depending on what it hit and when. To try to normalize the speed I want to apply force or drag when ever it goes above or below the thresh hold. My question is, do I need to make note of the direction the object is moving to add force? Or can I just add force to the way it is currently traveling?


texts:
I keep reading in the game development community that the idea of a game is 1% and the execution of the game is 99%.

Do you believe that to be true? Not necessary in those percentages..

I always thought that a great idea is invaluable and it makes a game successful even though the execution is simplistic.


texts: How to move a Box2D body towards a mouse click?

texts:
In a top down game using Box2D, I would like the player's Box2D body to rotate towards the mouse click, and then move to a point on mouse click (move, not teleport). I have worked out the rotation part, but cannot figure out the movement.

Every time the screen is touched, the target point (mouse click) is updated:

if (Gdx.input.isTouched())
{
    Vector3 tmp = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
    touch_prev = touch_target;
    touch_target = new Vector2(tmp.x, tmp.y);
}

Here is the Rot2D class:

package com.elsealabs.ghostr;

public class Rot2D {

   public static Rot2D fromDegrees(double angle) {
      return fromRadians(Math.toRadians(angle));
   }

   public static Rot2D fromRadians(double angle) {
      return new Rot2D(Math.cos(angle), Math.sin(angle));
   }

   public static Rot2D fromVector(double dx, double dy) {
      float length = (float) Math.sqrt(dx * dx + dy * dy);
      return new Rot2D(dx / length, dy / length);
   }

   public double getAngle() { // radians
     return Math.atan2(sin, cos); // atan2(y, x)
  }

   public double cos, sin;

   private Rot2D(double cos, double sin) {
      this.cos = cos;
      this.sin = sin;
   }

   public Rot2D load(Rot2D that) {
      this.cos = that.cos;
      this.sin = that.sin;

      return this;
   }

   public Rot2D copy() {
      return new Rot2D(cos, sin);
   }

   public Rot2D rotate(Rot2D that) {
      double cos = (this.cos * that.cos) - (this.sin * that.sin);
      double sin = (this.cos * that.sin) + (this.sin * that.cos);

      this.cos = cos;
      this.sin = sin;

      return this;
   }

   public static double cross(Rot2D a, Rot2D b) {
      return (a.cos * b.sin) - (a.sin * b.cos);
   }
}

(Source)

I am showing these because it may be helpful, but what I need to get working is the movement. I do not want to use setTransform, as it may end up letting the player travel through walls.

Using the vectors below, and any other variables needed, how would I move the player gradually towards a point on mouse click?

private Vector2 touch_prev = new Vector2(0, 0);
private Vector2 touch_target


texts: pause Menu only working in one scene and not in others

texts:
Hi I'm working on a game for a school project but I'm still pretty new at game dev, I decided to add a pause menu to my game but for some reason, it only works in one of the scenes in unity, and I can't tell why it won't work on any of the other ones
Here is a video showing the problem: https://youtu.be/28fD9UEtfpg
and here is my script just in case
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;

public GameObject PauseMenuUI;

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        if (GameIsPaused)
        {
            Resume();
        }
        else
        {
            Pause();
        }
    }
}

public void Resume()
{
    PauseMenuUI.SetActive(false);
    Time.timeScale = 1f;
    GameIsPaused = false;
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
}

void Pause()
{
    PauseMenuUI.SetActive(true);
    Time.timeScale = 0f;
    GameIsPaused = true;
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
}
}


texts:
I'm making a 2D sidescrolling game in Unity where the player shoots at obstacles while running. But nothing I try seems to get the collision detection to work. This is the obstacle script:

void onCollisionEnter2D(Collision2D col)
{
    if (col.gameObject.tag == "circle")
                    Destroy (gameObject);
    }

the circle tag refers to the projectile being shot at the obstacle


texts: GLES2 rendering performance for different iPad generations

texts:
I'm using C++/GLES2 for iPad only (no iPhone). The only device I own is an iPad2 and I do not plan to support iPad 1.

Can anyone help me understand realistic goals/limits on iPad 2/3/4 in terms of polygon count, etc?


texts: Engine with Terrain and Indoor Areas (BSP-like)

texts:
I'm not really a graphics programmer, but I used to toy around with Truevision3D 6.5 a few years ago. It wasn't too bad, but TV3D was just going nowhere so my foray into 3d game dev ended there.

I know nothing of XNA. I think it's time to get up to date.

My goal is to be able to render chunks of terrain from heightmaps (big huge terrain a la Morrowind) and BSP-like indoor areas (think Quake, so moveable objects like doors included).

I googled for "xna engine", "best xna engine" but the quantity of results is a bit scary for a xna-impaired like me.

Can anyone recommend a xna engine (or a combination of libraries) to achieve the desired result? If you targeted similar features, can you share your experience?

(and for a laugh, has anyone tried TV3D 6.5 here?)

Edit: I'm looking for something xna-related.


texts: What's a proper way to change colors of a sprite on the fly in libGDX?

texts:
I have found a great tutorial series on creating a simple 2D side scroller, Super Mario Brothers, in this case, and I believe I can adapt it fairly well to create a Megaman clone(something I am quite familiar with so that I can focus on learning the code and not necessarily the mechanics).

What has been challenging me is how to swap colors on Megaman when the chosen weapon is changed.  I've found a  few options, but I am unsure which one is viable.

Having each color as a separate sprite sheet

PRO:

simplest implementation I believe

CON:

increased footprint size of overall app

Converting the texture to a Pixmap, changing the colors I want, convert back to a texture and render as normal?

PRO:

no increase in app size

CON:

Is this done on reach render cycle or can I change it once and forget about it until a new weapon change?

Shaders

PRO:

??

CON:

From what I am reading, it sounds like they can only change on color at a time? Do I use 2 shaders?
They can only be applied wholly to the render and not per sprite?

Thanks.


texts: Is there a significant importance in what axis I chose in my top down 2.5D game?

texts:
I have read several posts stating what seems like a "standard" in how to chose your 2d axises in a 3d engine. It is often Y up on screen and X right on screen. However, in these examples I often see that it's a scene set up like a platformer, where the player sees the world from the side.

I'm developing a top down 2.5D (locking depth axis but keeping perspective on camera) game and I have it setup so that Z is up on the screen and X is right on the screen. To me it makes sense as Y is height in the world and thus would approach the camera. I will make use of the 3d world at certain times and I feel that it would be confusing to not have the standard axises then...

Is there something I'm not thinking about here?


texts: How to make an existing Editor window floatable

texts: I added a second inspector window tab to Unity and locked it. I tried moving it to another desktop on my Mac but it doesn't move to the next desktop. How can I make a duplicate Inspector Window floatable?


texts:
I'm writing a game, and I need to simulate a the path of a cannon ball.
I imagine I would have the initial velocity vector, and a vector for gravity.
Is there a good tutorial on how to do this?
(maybe I need to read some high school text books?)


texts: How can i add a description of gameobject when click on the gameobject?

texts:
I have this DetectInteractable working script attached to Player (FPSController).

I'm using tag to detect interactable objects, each object i want to be interactable i change his tag in the editor to "Interactable". ( Maybe there is a better way to do it without using tag ? It's working but many told me not to use tag. )

I'm using Raycast to hit a gameobject detect if it's "Interactable" and if it does i display on the gameobject his name. For example "Security Door" or "Screen Monitor" or "Surveillance Camera"

Now i want to do that if i hit a gameobject with the raycast and it's "Interactable" if i will click the mouse left button it will display a description text description about the gameobject. But this time i want to use some gui box so it will be in front of the screen in the middle and not on the gameobject.

The problem is that i need to create a script for every "Interactable" gameobject and make that if i click on a button it will display a description.

Then how do i make the script and how can i make that when i attach the script to each gameobject it will make in the inspector a box of text so i can enter and type there the description of the item(GameObject) ?

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

public class DetectInteractable : MonoBehaviour
{
    public Camera cam;
    public float distanceToSee;
    public string objectHit;
    public Image image;
    public bool interactableObject = false;
    public Canvas canvas;
    public Text interactableText;

    private RaycastHit whatObjectHit;
    private RotateObject rotateobj;

    private void Start()
    {
        rotateobj = GetComponent<RotateObject>();
    }

    private void Update()
    {
        Debug.DrawRay(cam.transform.position, cam.transform.forward * distanceToSee, Color.magenta);

        if (rotateobj.rotating == false)
        {
            if (Physics.Raycast(cam.transform.position, cam.transform.forward, out whatObjectHit, distanceToSee))
            {
                if (whatObjectHit.collider.gameObject.tag == "Interactable")
                {
                    image.color = Color.red;
                    objectHit = whatObjectHit.collider.gameObject.name;
                    interactableObject = true;
                    interactableText.gameObject.SetActive(true);
                    interactableText.text = whatObjectHit.collider.gameObject.name;
                    print("Hit ! " + whatObjectHit.collider.gameObject.name);
                }
                else
                {
                    image.color = Color.white;
                    interactableText.gameObject.SetActive(false);
                    print("Not Hit !");
                }
            }
            else
            {
                image.color = Color.white;
            }
        }
    }

    public class ViewableObject : MonoBehaviour
    {
        public string displayText;
        public bool isInteractable;
    }
}


texts: Pass equations into shaders to define graphics - HLSL or other shaders

texts:
Is it possible with HLSL (or other popular shader languages) to pass instead of an image, an equation that would define the pixel color / position output by the shader? This would allow for more dynamic drawing of smooth shapes that could be sampled with infinite detail. They would also by able to change and morph in real time.
Not sure how this is possible without passing a string with the eq to the shader and having it parse it. Seems like that might lose all the performance gained by putting it onto the GPU.


texts: How to disable BoxCollider2D on all prefabs?

texts:
I made a prefab that when hitting one object will disable it's box collider2d and enable it after hitting a different object.

It works find when there's one prefab, but when there's move, it only works on a single instance of the prefab and non of the others.

How do I set it to disable every box collider2d on every prefab object of that type? Thank you!

public void ChangeGreen()
{
     //Turns box collider2d on
     ColorBlockerController blockerScript = GameObject.FindGameObjectWithTag("PinkBlockerTag").GetComponent<ColorBlockerController>();
     blockerScript.PinkBoxOn();
}

public void ChangePink()
{
     //Turns box collider2d off
     ColorBlockerController blockerScript = GameObject.FindGameObjectWithTag("PinkBlockerTag").GetComponent<ColorBlockerController>();
     blockerScript.PinkBoxOff();
}


texts:
How can I get clickable buttons working in SFML? I've failed figuring it out on my own. At first I tried just putting in text and then I tried an image for the Exit button. Neither of them work in the sf::Event::MouseMoved event. I want the exit button to highlight a different color when I mouse over it but it just flickers every time the mouse moves whether its in the coordinates or not. Also, doing a sf::FloatRect = exitButtonImage.getRect(); seems to not work either.

#include <SFML\Graphics.hpp>
#include <SFML\Audio.hpp>
#include <string>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1024, 622), "Survival Game", sf::Style::Default);

    sf::Texture background;
    sf::Sprite backgroundImage;

    if (!background.loadFromFile("Alaskan Wilderness.png"))
        std::cout << "Error: Could not display Alaskan Wilderness image" << std::endl;

    backgroundImage.setTexture(background);

    while (window.isOpen())
    {
        sf::Font font;
        if (!font.loadFromFile("MATURASC.TTF"))
            std::cout << "Can't find the font file" << std::endl;

        sf::Texture exitButton;
        sf::Sprite exitButtonImage;
        if (!exitButton.loadFromFile("Exit Button.png"))
            std::cout << "Can't find the image" << std::endl;
        exitButtonImage.setPosition(50.0f, 500.0f);

        float exitButtonWidth = exitButtonImage.getLocalBounds().width;
        float exitButtonHeight = exitButtonImage.getLocalBounds().height;

        exitButtonImage.setTexture(exitButton);

        sf::Text startText;
            startText.setFont(font);
            startText.setStyle(sf::Text::Bold);
            startText.setString("Create New Game");
            startText.setFillColor(sf::Color::Black);
            startText.setCharacterSize(48);
            startText.setPosition(50.0f, 320.0f);
        sf::Text loadText;
            loadText.setFont(font);
            loadText.setStyle(sf::Text::Bold);
            loadText.setString("Load Game");
            loadText.setFillColor(sf::Color::Black);
            loadText.setCharacterSize(48);
            loadText.setPosition(50.0f, 380.0f);
        sf::Text settingsText;
            settingsText.setFont(font);
            settingsText.setStyle(sf::Text::Bold);
            settingsText.setString("Settings");
            settingsText.setFillColor(sf::Color::Black);
            settingsText.setCharacterSize(48);
            settingsText.setPosition(50.0f, 440.0f);

        sf::Event Event;
        while (window.pollEvent(Event))
        {
            switch (Event.type)
            {
            case sf::Event::Closed:
                window.close();
                break;
            case sf::Event::MouseMoved:
                sf::Vector2i mousePos = sf::Mouse::getPosition(window);
                bool mousePositionExit = mousePos.x == exitButtonWidth && mousePos.y == exitButtonHeight;
                if (sf::Mouse::getPosition(window).x > exitButtonImage.getGlobalBounds().left &&
                    sf::Mouse::getPosition(window).x < exitButtonImage.getGlobalBounds().left +
                    exitButtonImage.getGlobalBounds().width && sf::Mouse::getPosition().y >
                    exitButtonImage.getGlobalBounds().top && sf::Mouse::getPosition(window).y
                    < (exitButtonImage.getGlobalBounds().top + exitButtonImage.getGlobalBounds().height));
                {
                    exitButtonImage.setColor(sf::Color(250, 20, 20));
                    window.draw(exitButtonImage);
                }
                break;
            }
        }

        window.clear();
        window.draw(backgroundImage);
        window.draw(exitButtonImage);
        window.draw(startText);
        window.draw(loadText);
        window.draw(settingsText);
        window.display();
    }
    return 0;
}


texts: In JBox2D, where is the correct place to interact with Body objects? step() method?

texts:
QUESTION: In an application, where is the appropriate place to put the code to interact with the Body objects?

By 'interact' I mean

Get position
Determine actions
Apply impulse

Would it be appropriate to use the step() method to process the interactions?

I'm guessing responding to collisions would be done in the listeners.

Background:
Disclosure: I'm very new to JBox2D, and haven't used Box2D at all.
I'm using the Testbed JAR in my application so that I can see the Bodies interact.
The Body objects are controlled by simple AI, not user input.
I skimmed through the box2d v2.3.0 user manual to get a basic understanding of the objects in the world.
I didn't find any hints on where to put the decision logic.


texts: Making a 3d scene in my game(stereographic double projection). I was looking for a Direct X version of a LH or RH Matrix for oblique projection. Does directx have a function or will I have to make my own?


texts: Simple curiosity about glDrawElements function

texts:
I've written a very simple OpenGL program displaying a white cube. To do the job done I recovered vertex position and indice data from an OBJ file that describes my cube. Here's the OBJ file content :

o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
usemtl BoxMtl
s off
f 1 2 3
f 5 8 7
f 1 5 6
f 2 6 3
f 3 7 4
f 5 1 4
f 4 1 3
f 6 5 7
f 2 1 6
f 6 7 3
f 7 8 4
f 8 5 4

According to the OBJ file the vertex array is translated in C by :

static GLfloat position[24] =
{
    1.000000, -1.000000, -1.000000,
    1.000000, -1.000000, 1.000000,
    -1.000000, -1.000000, 1.000000,
    -1.000000, -1.000000, -1.000000,
    1.000000, 1.000000, -0.999999,
    0.999999, 1.000000, 1.000001,
    -1.000000, 1.000000, 1.000000,
    -1.000000, 1.000000, -1.000000
};

And the index array by :

static GLuint indices[36] = {
    0, 1, 2,
    4, 7, 6,
    0, 4, 5,
    1, 5, 2,
    2, 6, 3,
    4, 0, 3,
    3, 0, 2,
    5, 4, 6,
    1, 0, 5,
    5, 6, 2,
    6, 7, 3,
    7, 4, 3
};

Now the code to initialize the VBO for the vertex array :

GLuint vertex_vboId;
glGenBuffers(1, &vertex_vboId);
glBindBuffer(GL_ARRAY_BUFFER, vertex_vboId);
glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(GLfloat), position, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

The one for the IBO :

GLuint indexId;
glGenBuffers(1, &indexId);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexId);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 36 * sizeof(GLuint), indices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

And finally the code to render the scene in the main loop (here the white cube):

glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertex_vboId);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, OFFSET_BUFFER(0));
glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexId);
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, OFFSET_BUFFER(0));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

Here's the output :

Until here there's no problem ! But my objective is to render the same cube but this time with a texture (a uv map) and with a UNIQUE call of glDrawElements like above.

To do the job done, I've first created a uv mapped cube on Blender and exported a new OBJ file but, this time, with vertex texture (vt) like below :

o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.626059 0.265705
vt 0.626059 0.487398
vt 0.404365 0.487398
vt 0.626060 0.930786
vt 0.404365 0.930786
vt 0.404365 0.709091
vt 0.847752 0.487397
vt 0.847753 0.709091
vt 0.626059 0.709091
vt 0.182672 0.487397
vt 0.626059 0.044011
vt 0.404366 0.265704
vt 0.182671 0.709091
vt 0.404366 0.044011
usemtl BoxMtl
s off
f 1/1 2/2 3/3
f 5/4 8/5 7/6
f 1/7 5/8 6/9
f 2/2 6/9 3/3
f 3/3 7/6 4/10
f 5/11 1/1 4/12
f 4/12 1/1 3/3
f 6/9 5/4 7/6
f 2/2 1/7 6/9
f 6/9 7/6 3/3
f 7/6 8/13 4/10
f 8/14 5/11 4/12

So I wonder if it's possible to use glDrawElements with two kinds of indices (v and vt) in a unique indice array (with a size of 72 this time). I tried several way without any success. Or maybe I have to use glDrawArrays... I'm really lost. Thanks very much in advance for your help.


texts:
I'm building some somewhat involved UI stuff using the Shapes vector package.
I need to be able to detect clicks on a circle, but also need to be able to click on things right next to that circle in all directions (it's a large circle).
I can limit the detected clicks to within the circle by simply using a square and checking distance of click from center of circle. But this still obscures clickable things behind the square but outside of the circle (in the corners of the square).
How can I detect those?
Thanks!


texts: How can I place images on the terrain in SC2 maps?

texts:
I have seen this video where there are logos of the clans rendered on the ground in StarCraft 2.

How can I add images of my own in a custom map?


texts: General Octree question: What do you actually store?

texts:
Ok, So I'm experimenting with various terrain generation methods, primarily in Unity, but i'll admit to not use all its features because I started learning about Game Dev in XNA YEARS ago. So, I made a blocky setup like minecraft several times, and made it ineractive. Kool Beans... I did it in chunks, not an Octree method. I've also had a broken version of Marching cubes, but it really wasn't broken, it made the look I was going for at the time.

So I've never really worked with Octrees, and I started reaseaching Dual Contouring and Surface Nets, and a lot of em talk about Octrees. I get the idea logically, but I kinda don't understand some basic "Mechanics" of Octrees, and finding "basic" answers to some of these topics is rough.

So, sticking really to just Octrees, what kind of data to really store in em? I mean, I get I literally could break up a 3D array of strings, but I'm asking about best practices and practicality. I've been using an array of bools generated by another object, really because I'm really trying to make something that does more "computing" than "hashing", and I was thinking bools would be the smallest type to store if I'm going to "blow it up" with other techniques.

So, when I first create this bad boy, and give it a 3D array of data, Do I really go through a method of recusivly testing each value before I "break" the "Master Node" into "Children nodes"? Or Do I start by testing each value in pairs, building Up to larger children nodes?

Any other pointers would be appreciated.


texts: What are the pros and cons of using larger tiles in a 2d game with freely placed entities?

texts:
I am working on a 2d game with the Godot Engine and I'm about to start drawing the tiles for the ground tileset. These will be used solely for the purpose of painting the ground because the trees, houses, etc in the map would be loaded into their individual entities and will be place-able anywhere.

My question is should I draw smaller or larger tiles for the ground? What would be the pros and cons of doing so? Memory consumption? Faster loading? Etc


texts: How can I tell if a set of tiles form an enclosure?

texts:
I have this tile-based game I've been messing around with and I want to have a way to check if a set of wall tiles make an enclosed space.

Here's some more details:
I have a tile map. Each tile has an ID. If you have a set of IDs like so:

0,0,0,0,0
0,1,1,1,0
0,1,2,1,0
0,1,1,1,0
0,0,0,0,0

0 is grass, 1 is wall, and 2 is floor. Assuming these have a spot in a 2d array, how can I find and confirm if whether or not the floor tile is surrounded by walls. This method has to be scalable as well. So if the floor area is 2x2 it would still work.

I've already tried implementing a way to check it, but I failed on my first couple of tries. Any recommendations?


texts: With this MMOG architecture, how can I avoid losing games when the server goes down?

texts:
I am fairly new to game designing and am trying to design game engine architecture for MMOG poker game. My major problem is scalability. Old Legacy code written in python runs everything on single process. Clients and server talks using xml based protocols. Following is old architecture.

admin -> DB (mysql) <-> backend <-> game-engine + login-server <-> client

I came across old reddit post and particular comment. What I feel, I need similar kind of architecture. So I am planning to implement following architecture along with admin and db.

backend cluster ( to interact with db)
Player Server cluster (handles player authentication and events from clients)
gamelogic server cluster (executes game logic)
redis-cluster (for caching states of ongoing tables)
directory-service + routing server(all clusters will talk with it and all communication will be done through it. initially planning to go with single such server and later make it distributed. Something like this. please see section 'Distributed Directory Service' and 'Distributed broker')

I need to build it using Twisted because of client constrains and legacy codebase.

In this architecture I am confused at one point particularly. Suppose I have multiple tables on one game-logic server and it goes down. How can I address this situation without losing game?


texts: Object have the same "speed" all time JavaScript

texts:
I try to create a 2D game with a big map and multiple objects. The player is always in the middle of the screen and all the other objects is moving around so it feels like a big map.

I want the player to always move after the mouse location. I have modified the mouse location to (0,0) by this:

                var mouseX = 0;
                var mouseY = 0;
                if (e.pageX < window.innerWidth/2) {
                    mouseX = -(window.innerWidth/2-e.pageX);
                }else{
                    mouseX = e.pageX-window.innerWidth/2;
                }
                if (e.pageY < window.innerHeight/2) {
                    mouseY = -(window.innerHeight/2-e.pageY);
                }else{
                    mouseY = e.pageY-window.innerHeight/2;
                }

That is working just fine. When it comes to the moving part i can't relly get it to move with the same "speed". I have made some animations to explain how it is now and how i want it to be.

How it is now:

DC is the speed that my player would go and as you can see it is moving the most when its closest to x=0 and y=0, i have done it like this so far:

            var all = mouseX + mouseY;
            clientsID[key]['x'] += mouseX / all * speed;
            clientsID[key]['y'] += mouseY / all * speed;

But as i know it is not working well. Here is a animation to show how i want it to be:

DA would be the speed and it's always 1 because it's radius of the circle. But as i don't know how far the mouse is from the center (mouse is E on the last animation) i have to scale it down somehow.

Does anyone know how to get how much i have to add x and y so the speed always will be the same?

Thank you

EDIT: See the solution under here


texts: Can glTexImage2D() use an already existing memory block?

texts:
Can I use glTexImage2D() and / or glTexSubImage2D() (or maybe there's some other method I don't know about) with an already existing block of memory, instead of always uploading the changed pixels? I already have the changed pixels somewhere in memory, and I'd like to send a pointer to that location if possible.

The problem is that I'm likely going to update a large amount of pixels, and uploading all of them introduces a lot of overhead and wasted memory. And since the application will only run on a mobile device without dedicated GPU memory, all I'm doing now is copying a big chunk of memory to another location of the same memory...

Also, I'm looking for a solution that would work on iOS devices, since the application will only run on iOS.


texts:
I created 10000 array and assigned value 1 and 0 to it, then used gizmos to generate 10000 cubes. I paint it black or white depending on the assigned value.
After that I use the bubble sort algorithm to sort the cubes, expecting all black cubes pieled on the bottom but when I run it, the sorting does not happen and I can't spot where my mistake is.
    using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    int x;
    int y;
    int z;

    int[,] array1 = new int[100, 100];
    int temp;
    // Start is called before the first frame update
    void Start()
    {

        for (x = 0; x < 100; x++)

        {
            for (y = 0; y < 100; y++)
            {
                array1[x, y] = Random.Range(0, 2);

                Debug.Log(string.Format("{0},{1},{2}", x, y, array1[x, y]));

            }
        }
        OnDrawGizmos();

    }
    void OnDrawGizmos()
    {

        for (x = 0; x < 100; x++)
        {
            for (y = 0; y < 100; y++)
            {
                Vector2 pos1 = new Vector2(0 + x, 0 + y);
                Gizmos.DrawCube(pos1, transform.position);
                Gizmos.color = (array1[x, y] == 1) ? Color.black : Color.white;
            }
        }
    }

    void update()
    {
        for (z = 0; z < 100; z++)
        {
            for (x = 0; x < 100; x++)
            {
                for (y = 0; y < 100 - z; y++)
                {
                    if (array1[x, y] > array1[x, y + 1])
                        temp = array1[x, y];
                    array1[x + 1, y] = array1[x, y];
                    array1[x, y] = temp;

                }
            }
        }
        OnDrawGizmos();
    }
}


texts:
I'm writing my own game in DirectX using C#. I'm at the point where I'm implementing my own textbox, written from scratch. It has the very basic functions for now, but works well. I want, however, to be able to input non-English text using Microsoft's IME (such as Japanese or Korean).

I've spent quite a lot of time looking for tutorials and documentations. I found a lot of functions (mainly contained in imm32.dll), but I can't really figure out how to make them work in order to make the input work:

my problem is that I can't use the IME inside my own textbox (contained in the DirectX Window form) as it is disabled. How do I tell the IME that my textbox can get input from keyboard and therefore get the IME enabled? Is there any method I should call?

I already tried stuff like ImmGetContext() and ImmAssociateContext(), using my window form as handle, but with no real results.


texts: General Sequence of Events for a 2D shooter

texts:
I'm having some trouble understanding ways to sequence events in my game. Assume the game is data driven, what is the best way to control the events?

Do I have some sort of EventSequencer that loads all the possible events for a level and the enemies? If so, would it be a list of events that I 'fire' off one at a time into the game engine and when the event is completed or finished, remove the event and fire the next one?

My thoughts were similar to the above questions: Build an event sequencer that manages what event is running and loads the proper event (enemy wave, boss battle, etc)...

I'm just not sure if this is a good idea.


texts: What do you use to create sprite graphics?

texts:
Possible Duplicate:
  What tools do you use for 2D art/sprite creation?

What do you folks suggest for creating sprite graphics and sprite sheets?

I fiddle with pixelformer and tilestudio.

Pixelfromer has a kicken interface, it is quick and easy to make graphics, but a bit cumbersom if you want to make a spritemap.
Tile Studio is a interesting mix or tiles and maps, but it is a bit buggy and basic.

The Adobe series, just don't really seem to handle tiny graphics well.

(there is a previous posting of this question existing,  but it is a year old and I was hoping for further/updated input from the community)


texts: How to calculate the position of an attached model after rotation?

texts:
I'm programming a basic game on XNA. I started to place an object (eg weapon) attached to the right arm of my player. When I move my character forward behind left or right all right. But when I rotates my equipment is not positioned correctly.
I am fully understands it is necessary to recalculate the new position based on the rotation done but I do not see how.
Here is my code and pictures

        //Function that will draw the current item selection in the player's hand
private void draw_itemActionInUse(Model modelInUse)
            {

                int handIndex = skinningData.BoneIndices["Hand_Right"];

                Matrix[] worldTransforms = animationPlayer.GetWorldTransforms();

                Matrix rotationMatrixCalcul = Matrix.CreateRotationY(player.Rotation.Y);
//Here I calculate the new position of the item, but it does not work
                Vector3 newPosition= Vector3.Transform(new Vector3(player.Position.X, player.Position.Y + 4, player.Position.Z ), rotationMatrixCalcul);
                foreach (ModelMesh mesh in modelInUse.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {

                        effect.World =
    worldTransforms[handIndex]
    *
    Matrix.CreateScale(2)
    *
    Matrix.CreateRotationY(player.Rotation.Y)
    *
    Matrix.CreateTranslation(newPosition);

                        effect.View = View_;
                        effect.Projection = Projection_;

                        effect.EnableDefaultLighting();
                    }

                    mesh.Draw();
                }

            }

Figure A:
position: x:0;y:0;z:0
angle : 90
Figure B:
position: x:2;y:4;z:0
angle : 90

Figure A:
position: x:1;y:0;z:1
angle : 35
Figure B:
position: How calcul this position ?
angle : 35


texts: Detect if two objects are going to collide

texts: I am working on a car game where I am to create an AI. In the game there are other cars and a few objects moving around that I do not want to crash with, I have the speed, position and direction of all objects including my own car, but how would I go about calculating if my car is on a collision course with another object given my current speed and the other objects current speed? I tried coming up with an algorithm myself but I'm not very good at algebra.


texts:
I have been having trouble linking sfml to qt creator I have downloaded the pre-compiled libraries and headers for MINGW on the sfml website here : http://www.sfml-dev.org/download/sfml/2.3.2/

This is my .pro file

QT       += core gui opengl

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = SFML_MapEditor
TEMPLATE = app

SOURCES += main.cpp\
        MainWindow.cpp

HEADERS  += MainWindow.h

FORMS    += MainWindow.ui

INCLUDEPATH += "C:\VsIncludes\SFML\SFML-2.3.2\include"
DEPENDPATH += "C:\VsIncludes\SFML\SFML-2.3.2\include"

LIBS += -LC:\VsIncludes\SFML\SFML_QT\SFMLLIBS\

CONFIG(debug, release|debug): LIBS += -lsfml-window-d -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-system-d -lsfml-network-d
CONFIG(release, release|debug): LIBS += -lsfml-window -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-system -lsfml-network

Here is the project files where the binaries are read

Now my problem lies in the loadFromFile() function.
When I do run the program with the loadFromFile() function
it will immediately give me this error:

C:\Users\Alex\Documents\QT_Projects\SFML_MapEditor\main.cpp:14: error: undefined reference to `_imp___ZN2sf7Texture12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_4RectIiEE'

However when I run the program without loadFromFile()
it will run without a hitch

My main.cpp file

#include "MainWindow.h"
#include <iostream>
#include <QApplication>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <QDebug>

void SFML_Test()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "HELLO SFML");

    sf::Texture tex;

    if (!tex.loadFromFile("Default_Texture.png"))
    {
        return;
    }

    sf::Sprite sprite(tex);

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

        while (window.pollEvent(e))
        {
            if (e.type == sf::Event::Closed)
            {
                window.close();
            }
        }

        window.clear();
        window.draw(sprite);
        window.display();
    }
}

int main(int argc, char *argv[])
{
    /*
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
    */

    SFML_Test();

    return 0;
}


texts:
When an enemy dies in my game, it drops an item on the ground. Enemies may drop multiple items. Currently, the item will always drop a set distance directly below the origin of the enemy when it dies. Therefore, if multiple items are dropped, I only see the most recently dropped item on the ground. Moreover, each item has a UI label clamped to some offset distance above the item. As such, I only see the UI label of the "most recently" dropped item. Because every item dropped by an enemy drops at the same physical location, and because I haven't added code to deal with this kind of thing, the physical game objects overlap with each other and the UI labels of those items overlap with each other.

My question is pretty general. What are the best ways to modify my code such that

1) If multiple items are dropped, there will appear to be multiple game objects on the ground (Close enough to the origin)?

2) The UI labels attached to each item will appear as close as possible to that item without overlapping with the other items' UI labels?

I would appreciate direct assistance or references that deal with this kind of thing. Thanks.


texts: Elegant solution for coloring chess tiles

texts:
I am re-developing a chess game I wrote in Java, and was wondering if there is an elegant algorithm to color chess tiles on a numbered chess board.

Right now my solution uses if else statements to determine if the tile is on an even or odd row, and based on that, if it should be a light or dark square.


texts: How can I load an image into the back buffer?

texts:
How can I load and display an Image?...
I have tried something but it didnt.. worked.. this is what I've tried..

File : StrikeOps_main.cpp .. void : render_frame :

Intro::DisplayIntro(d3ddev, introPath.c_str(), Surface, BackBuffer);

File : Intro.h

class Intro
{
public:
    static void Intro::DisplayIntro(LPDIRECT3DDEVICE9 d3ddevice, LPCSTR path, IDirect3DSurface9 *Surface, IDirect3DSurface9 *BackBuffer);
};

File : Intro.cpp

void Intro::DisplayIntro(LPDIRECT3DDEVICE9 d3ddevice, LPCSTR path, IDirect3DSurface9 *Surface, IDirect3DSurface9 *BackBuffer)
{
    D3DXIMAGE_INFO Info;

    D3DXGetImageInfoFromFile(path, &Info);
    d3ddevice->CreateOffscreenPlainSurface(Info.Width, Info.Height, Info.Format, D3DPOOL_SYSTEMMEM, &Surface, NULL);

    D3DXLoadSurfaceFromFile(Surface, NULL, NULL, path, NULL, D3DX_FILTER_NONE, 0, NULL);

    d3ddevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);
    d3ddevice->UpdateSurface(Surface, NULL, BackBuffer, NULL);
}

then on StrikeOps_main.cpp , void : CloseD3D :

Surface->Release; and BackBuffer->Release; (yes they are declared as globals on StrikeOps_main.cpp


texts:
Today I was trying to make a test camera, with a new method(I usually use gluLookAt)

So I got a problem,

void GameDraw()
{
    glPushMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90, WIDTH / HEIGHT, 0.001, 10000.0);
    pitch += 1;
    glRotatef(pitch, 1.0, 0.0, 0.0);
    glRotatef(yaw, 0.0, 1.0, 0.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    s->bind();
    test->drawMesh();
    glPopMatrix();
}

And my draw function is:

glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, nullptr);

if it isn't working with glDrawElements is there any alternative to use?

Edit: Disabling shader it works fine, but how I can use this with Shader

Please don't use glm examples, because I don't like to use it, I feel more comfortable by using the my math


texts: AI using character controller makes unwanted change to it's y position

texts:
The enemy parent object does not have any colliders except for the character controller. It starts out with y = .57 and immediately jumps to y=1.6355 because of my call to CharacterController.Move(.)

A code snippet is as follows:

myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(targetPos - myTransform.position), rotationSpeed*Time.deltaTime);
Vector3 forward = myTransform.TransformDirection (Vector3.forward);
character.Move (forward * moveSpeed * Time.deltaTime);

The above occurs in my update function. I am reluctant to post more code because this is for an assignment.

I feel like I've tried everything. Using rigidbodies, I fixed this problem but then the enemies began to overlap when they got close. So I reverted back to character controllers. In either case I have been trying different ways of keeping y constant, freezing it, making the y rotation component zero, you name it.

One other thing I'll note is that the enemy moves to this y position regardless of where it is initially placed. My main character also starts a distance in the sky and falls down. It so happens that the y position it ends up is this same one that the enemy teleports to.

EDIT: Also I am on Unity 5.2
EDIT 2: This is for a script I use to make the AI follow my player. It is similar to many you will find just googling, because I based it off of those. I have even tried other people's scripts and had the same problem.
EDIT 3: If I put the enemy lower to the ground (say y=.55) he will not pop up like before. However, he doesn't move toward the player anymore.


texts:
I'm at the stage in my game development where I need to make a HUD or GUI. I've never gotten to this part, so I don't know how its done. I tried rendering a simple quad at a fixed position on the screen, but there's a problem. To make my camera work with orthographic, I use this:

public void lookThrough()
{
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(position.x, position.x + Display.getDisplayMode().getWidth()/zoom, position.y + Display.getDisplayMode().getHeight()/zoom, position.y, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

I don't see how I would be able to make something fixed on the screen using this method? Any way around this? Thanks :)


texts: How do I sync entity ids with the server and client?

texts:
I'm continuing my experimentation with entity component design by making a multiplayer space/trading/combat game with python and panda3d. My component system is a simple version of java's artimis. The entity id is stored in a simple list with it's position as its id. Components are stored in a second list of dictionaries with the position as the entity id. Components are then mapped in a {Class: instance} dictionary.

The client will only know about entities near it's local space. Entities to be networked will have a ClientComponent which tracks what clients that object is broadcasting to. The server and client sends updates with the entity id of the object being acted on, then the action type, followed by the relevant data and yes, the server will check if it is a valid action by the client. The client needs to have a local copy of the relevant entities and components but I am running into issues on how to set this up.

My initial reaction is to just use the entity id's from the server on a client. The client will probably need its own entities for elements like the UI which can interfere with a future entity from a server. I could reserve the first 64-128ish entities for client local use only, but that seems very awkward
Next though was to have the client generate the entity ids locally and have a map of client vs server entity ids. The problem here is that some components will have an id of what entity owns it, which can make the mapping system fall apart and hard to debug.

Here are my two questions. Is there a better way to set up the network protocol where I wont run into this issue. If not, what is a decent solution for the client to know the server's entity ids.


texts: How to show the bow string stretching animation (?)

texts:
I was wondering how the animation in the angry birds of pulling the slingshot is done. One similar animation is available in this game but with a bow and arrow. I think both of them use the almost similar technique for it.

I tried to search for this on Google and all I got was the trajectory related stuff like calculating the trajectory of object once it is thrown. I could not find anything related to how the animation (?) for stretching the slingshot/bow string with respect to the force applied by user the bow string is achieved.

Can anybody point me in right direction in how to achieve that effect. Tutorials are welcome!


texts: Render specific part of a texture in OpenGL (2D Sprite Sheet)

texts:
I've looked at this answer to find out how to render just a part of a texture:
C++ Opengl render part of an image

I tried that, but the problem is, this is how I render my texture:

glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(x, y);
glTexCoord2f(1, 0); glVertex2f(x + w, y);
glTexCoord2f(1, 1); glVertex2f(x + w, y + h);
glTexCoord2f(0, 1); glVertex2f(x, y + h);
glEnd();

I tried doing this to render the top left quarter:

glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(x, y);
glTexCoord2f(0.5, 0); glVertex2f(x + w, y);
glTexCoord2f(0.5, 0.5); glVertex2f(x + w, y + h);
glTexCoord2f(0, 0.5); glVertex2f(x, y + h);
glEnd();

But it just totally messes up and makes my texture bigger and cut off. What I want is to just draw a part, like you would on a sprite sheet. I've been messing around with those lines for awhile and I just can't seem to find out how to do what I want.

I've been messing around with this:

// yeah i know this math is crappy and weird but im trying EVERYTHING at this point,
// it draws until the dcw (width) just fine but i cant seem to integrate cx/cy...

double dcw = double(cw) / double(w);
double dch = double(ch) / double(h);

double dcx = double(cx) / double(dcw);
double dcy = double(cy) / double(dch);

std::cout << "dcw:" << dcx << "\n" << "dch:" << dcy << "\n";

glBegin(GL_QUADS);

//bottom right
glTexCoord2f(0, 0); glVertex2f(cx, cy);
//top right
glTexCoord2f(dcw, 0); glVertex2f(cx + cw, cy);
//top left
glTexCoord2f(dcw, dch); glVertex2f(cx + cw, cy + ch);
//bottom left
glTexCoord2f(0, dch); glVertex2f(cx, cy + ch);


texts: Get internal and external IP addresses in Unity 2018.2.0?

texts:
Unity 2018.2.0 makes the Network class obsolete.  I have used "Network.player.ipAddress" in my code to get the local LAN IP address.

    internalIP = Network.player.ipAddress;
    externalIP = new WebClient().DownloadString("http://icanhazip.com");

What code should replace this?  What would be best practice for getting internal and external IP addresses for manual LAN and internet direct connections between server and client?

Internal/external IP addresses are needed so players can load the game, then tell their friends what their IP is to direct connect.


texts: How do I keep enemies from clumping up into one area?

texts:
I am making a zombie game and as I was making it I noticed the zombie AI starts to clump up into one mega zombie in one area. I was wondering how I could keep the zombies from doing that and instead make a horde like formation. I don't know how I would implement this and I don't know where to put it in my game logic so if you could give me some ideas or hints that would be fantastic.

Thanks in advance!


texts: Can UNet do Rigidbody2D prediction? (i.e. using gravity)

texts:
Having a NetworkTransform with transformSyncMode set to SyncRigidbody2D (as opposite to a plain SyncTransform) I assumed it would try to sync all physics, hence handling gracefully forces, especially gravity.

What I got instead, is a very simple linear interpolation, which smooths out the gravity, so that jumping up and down looks incredibly unnatural: I would have expected this wish a SyncTransform of course, but, given the name I would have expected SyncRigidbody2D to solve this sort of problem…

So, am I missing something and might I have some value set wrong, or what?


texts: Detecting if line crosses rectangle in python. Need speed boost

texts:
I am currently writing a top down man vs robot shooter. The game works now, but if I have a decent sized level it runs slowly when you are being chased by robots. While just roaming around it can go at full 60 fps, but with the robots on your tail it slows down immensely.

I have traced the source of the problem to the part of the code where the robots decide whether or not their sight of the player is obstructed by a wall. This code works by seeing if the line segment formed by the center of the robot and the center of the player intersects a wall.

I have written this algorithm to see if a line segment goes through a rect:

for wall in wall_rects:

    #is wall between the robot and player:
    if man.rect.centerx < wall.rect.centerx < self.rect.centerx or\
    man.rect.centerx > wall.rect.centerx > self.rect.centerx or\
    man.rect.centery < wall.rect.centery < self.rect.centery or\
    man.rect.centery > wall.rect.centery > self.rect.centery:
        r = [] #are the corners above or below the line between the man and robot
        r.append((self.rect.centerx-man.rect.centerx)*(wall.rect.top-man.rect.centery)\
          - (self.rect.centery-man.rect.centery)*(wall.rect.left-man.rect.centerx))
        r.append((self.rect.centerx-man.rect.centerx)*(wall.rect.top-man.rect.centery)\
          - (self.rect.centery-man.rect.centery)*(wall.rect.right-man.rect.centerx))
        r.append((self.rect.centerx-man.rect.centerx)*(wall.rect.bottom-man.rect.centery)\
          - (self.rect.centery-man.rect.centery)*(wall.rect.left-man.rect.centerx))
        r.append((self.rect.centerx-man.rect.centerx)*(wall.rect.bottom-man.rect.centery)\
          - (self.rect.centery-man.rect.centery)*(wall.rect.right-man.rect.centerx))
        if not(max(r) < 0 or min(r) > 0):
            #if all of the corners are not on the same
            #side then the line does go through the wall
            break
    else: #IT SEES YOU! >:D

however it is not near fast enough to check all 450 some walls there are in my test level. My difficulty is either making it faster or having it find out which walls are worth checking for sight-line blockage. I tried checking the distance between the wall and robot to see if it is closer to the robot than the man, which slowed it down more.

Any suggestions?

EDIT:
I forgot to mention that in this game, while the walls are placed on a grid with 25X25 pixel squares, you are free to move any distance in any direction, and so are the robots, but it looks like the suggestions below will still likely help.


texts: How can I create a tile-based game map from a large source image?

texts:
I'm trying to make a huge tile-based map for my game. I've authored a large source image of the map and saved it, but now I'm unsure how to break this up into tiles and render it as a grid so I can have tile-based movement and mark certain tiles as collision, et cetera.

How should I go about this?


texts: Is SVG a viable technology choice for web-based game?

texts: I have started to read up about the web technology available for doing web-based game with only Javascript, but I have no where got feedback about SVG with HTML5. Is is a viable choice ? Does it performs well compared to other technique like Canvas, DOM & CSS Transformation, etc.


texts: When should I set a texture as a shader resource in order to read it?

texts:
I'm writing a Direct3D 11 HLSL shader with SharpDX. What I want to do is write the depth to a texture in one pass and read it in the next one. After declaring the texture, do I have to set the depth texture and the shader resource view per frame, or just once when attaching?

this.depthStencilShaderResourceVariable = this.effect.GetVariableByName("DepthTexture").AsShaderResource();
this.depthStencilShaderResourceVariable.SetResource(this.depthTextureShaderResourceView);


texts:
I'm looking for high quality original 2D sprite collections which are animated where appropriate.  (IE not simply collections I can buy, we want original work).

I've had a look online but am struggling to find out where I can hire such people!

Where do I find such people?
How much should I expect to pay?


texts:
In the game i am creating as an hobby (learning is the primal goal of it all) i plan to implement a space ship that the player can enter and use to explore it. I tried to search the internet for the concept of vehicle implementation but i couldnt find anything worth mentioning, and before I start writing the code I really want a clear idea of what I strive for. So id like to ask the pro game developers how should I look at a vehicle, should I think of it as a player's body extention with different mechanics? or should I just think of it as a usable exterior object? What kind of link should be between the player and the drivable vehicle? How do games usually do it, like GTA 2 and that kind of games?

Main Question: What is the basis of vehicle implementation?

P.S. I dont think its important to mention but the game is 2D and top-down perspective, so i guess GTA 2 can be a close reference to what i wanna do, although the gameplay is very different, but ye, the vehicle implementation i want is similar to GTA 2 although i only plan to do a space ship for now.


texts:
How can i do "realistic" plastic material in Unity 3d , using standard shader or other shader ?

Can you suggest me options ?

Thanks


texts: Having player names over models in 3d space

texts: I wanted to have in my multiplayer game, the players name's over their models, however I am faced with the question of how? Should I create a new Canvas object for each game model or just use 1 main canvas and move their names around relative to position in 3D world space? My aim is to have an open world game.


texts: Would a Python game run on multiple platforms?

texts:
I have plans to write a game in Python and probably some SQL.
I'm concerned about how versatile my program will be when I finish it, ideally I'd like it to run on Windows, Mac, Android, and iPhone... however I have a feeling the phones would be off-limits for this sort of thing.
How would I go about writing a program that runs on multiple platforms?
Is this even feasible for a beginner programmer?


texts:
I've been arming my engine with error checking code. I'll try to describe this situation to my best abilities. Whenever i load a shader and there's an error (file doesn't exist, compilation error, anything that could go wrong) i delete the shader and set the pointer to 0 (can't think of annother way to make sure i don't try to attach or delete trash by accident). I don't want to stop the program if this happens, because somebody might delete or modify a single file by accident in the game folder and don't want to render the whole game unusable because of that.

Now the thing is, is there a default behavior in the situation where i attach shaders to a program that have the pointer equal to 0?

In my program, if i attach a vertex shader equal 0 and a fragment shader equal 0, then OpenGL will use the default program (will display everything white):

This is a rotated cube that's dimensions are in clip space already, rendered without perspective projection or depth checking. It's loaded from an .obj file.

Now, if i attach a proper fragment shader, but the vertex shader will be 0, i get this:

Which is what i would expect, all the fragment shader does is outputs a vec4(1.0, 0.3, 0.7, 1.0), there's no vertex shader so OpenGL uses the default one (is this a correct assumption?).

Now, however, if i attach a correct vertex shader, but i attach a fragment shader equal to 0 (or i won't attach a fragment shader at all) i'll get this mess:

Something you can't see is that this model is contantly being painted different colors, so on my screen it looks like an acid trip with black horizontal lines going through.

I'm confused a bit, because i would expect the cube to just be white. I'd like to point out that my shader code is bare bones, i'm not exchanging any variables between vertex and fragment shaders. Checking if the pointer is not equal to 0 doesn't change anything, the linked program acts the same as if i gave it a pointer equal to 0. The weirdest thing to me is that it's always nicely shaded, it's not just trash.

EDIT: Maybe the default fragment shader expects a gl_ value from the vertex that i'm ommiting to set? That would kind of explain why the surface is nicely shaded, the fragment shader expects a smooth in, but that value is just trash, because i didnt' set it.

Now is this an "undefined behavior" or is this how it's suppoused to work?


texts: Unity3d - c# - changing FPSInputController controls through script

texts:
For a game I am making I would like the user to be able to change the controls (in game NOT through the clunky launch window (wich i disabled)) I have the system working but don't know how to change the controls for FPS controller. I am okay with writing my own version of the FPSInputController but I don't really know how to do that (the good way (using the CharcaterMotor)) I looked at the original FPSInputController script but that used axes (from the "conventianal" input settings in unity) and I don't really know how to do that with:

if (Input.GetKey(controls.forward))


texts: Collision resolution when moving in two directions

texts:
I am making a bomberman clone and I'm having problems regarding moving on both x and y axis (pressing down+left, down+right, up+left). Here is a video to demonstrate the problem. I use Tiled for the map. Below is the code:

private void checkCollision(float delta) {
    player.getVelocity().scl(delta); // dont mind
    Vector2 position = player.getPosition();

    if(player.isMovingRight()) {
        Array<Rectangle> tiles = getTiles((int)(position.x/TILE_SIZE + 1), (int)(position.y/TILE_SIZE - 1),
                (int)(position.x/TILE_SIZE + 1), (int)(position.y/TILE_SIZE + 1));
        for (Rectangle tile : tiles) {
            if(player.getRectangle().overlaps(tile)) {
                System.out.println("overlap right");
                player.setPosition(tile.x - player.getWidth() , player.getPosition().y);
            }
        }
    }
    if(player.isMovingLeft()) {
        Array<Rectangle> tiles = getTiles((int)(position.x/TILE_SIZE - 1), (int)(position.y/TILE_SIZE - 1),
                (int)(position.x/TILE_SIZE + 1),  (int)(position.y/TILE_SIZE + 1));
        for (Rectangle tile : tiles) {
            if(player.getRectangle().overlaps(tile)) {
                System.out.println("overlap left");
                player.setPosition(tile.x + tile.width, player.getPosition().y);
            }
        }
    }

    if(player.isMovingUp()) {
        Array<Rectangle> tiles = getTiles((int)(position.x/TILE_SIZE - 1), (int)(position.y/TILE_SIZE - 1),
                (int)(position.x/TILE_SIZE + 1), (int)(position.y/TILE_SIZE));
        for (Rectangle tile : tiles) {
            if(player.getRectangle().overlaps(tile)) {
                System.out.println("overlap up");
                player.setPosition(player.getPosition().x, tile.y + tile.height);
            }
        }
    }
    if(player.isMovingDown()) {
        Array<Rectangle> tiles = getTiles((int)(position.x/TILE_SIZE - 1), (int)(position.y/TILE_SIZE + 1),
                (int)(position.x/TILE_SIZE + 1), (int)(position.y/TILE_SIZE + 1));
        for (Rectangle tile : tiles) {
            if(player.getRectangle().overlaps(tile)) {
                System.out.println("overlap down");
                player.setPosition(player.getPosition().x, tile.y - player.getHeight());
            }
        }
    }

    player.getVelocity().scl(1/delta);

}

private Array<Rectangle> getTiles(int startX, int startY, int endX, int endY) {
    TiledMapTileLayer layer = (TiledMapTileLayer)level.getMap().getLayers().get(1);
    Array<Rectangle> rectangles = new Array<Rectangle>();
    for (int x = startX; x <= endX; x++) {
        for (int y = startY; y <= endY; y++) {
            Cell cell = layer.getCell(x, y);
            if(cell != null) {
                Rectangle rect = new Rectangle(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE);
                rectangles.add(rect);
            }
        }
    }
    return rectangles;
}

To reproduce the problem shown in the video: Try to collide (coming from up) with one of the blocks that is not on the sides, press both down and left. Try again but press down and right. For the third one, make sure you are colliding with the top wall by pressing up then press left (both are pressed). It can also be done on the bottom wall by pressing down and left.


texts: DrawString and Render graphics after custom time

texts: I want to draw String after some second like "Boss is incoming",and after the string is disappeared i want to draw the Boss.I have the graphics and the string so my question is how to add timer for string and graphics?


texts: Designing PHP RPG game: Should I use multiple classes for each type of item or a single table?

texts:
I'm making a text-based role playing game written in PHP.

I have a hard time figuring out how to handle items in game - there will be a few types of objects (weapon, machine, tool, building etc) each of these types will have its own stats, attributes etc, and items itself.

My initial plan was to make a interface and abstract class called Object

interface IObject
{

   public function takeObject() {};
   public function dropObject() {};
   public function examineObject() {};
   // etc
}

abstract class WeaponObject implements IObject
{
   // Some generic properties valid for this type of objects
   public $name = "";
   public $weight = 0;
   public $damage = 0;

   // etc
}

and then make another class for each item that extends the base Object

e.g

class HuntingBow extends WeaponObject
{
   //
}

But there's a problem I think. There's going to be a lot of objects in the game - and that means a lot of classes, and composer need to load them all. So I think that performance may decrease significantly?

My second idea was to make a generic table called objects

In which I would store every item. But setting up object attributes, handling stats, etc, would be a nightmare.

Is the first idea the best way to approach the problem? Is there a better way of doing thins that I don't about?


texts: I am newbie in programming and I am making a tower defense game 2d. My problem is I want to make a restriction to place a tower only, if the mother tower is in place or within its range. I'm sorry if my explanation is a bit confusing. For example, you can oly place a certain tower within the range of the mother tower and only if that mother tower is placed. I don't exctly know if I have to create a function for this or create a range game object for the placement attached to the mother tower. Any help and tips would be appreciated, thank you. This is by the way unity C#.


texts: Unity 3d: Animating Offset on a Quad is causing stretching issue only with iOS devices - Using Wrap Mode: Repeat

texts:
I added a 3D Object > Quad and added a graphic on it with the Wrap Mode set to Repeat. I'm animating the Offset to scroll the repeating image for a parallax effect. Everything is working perfectly with in Editor and Android devices. On iOS devices, the image shows fine and then stretches as the offset is changing. I'm attaching 2 screen shots of the image import settings - Quad settings, and the issue on the iPhone. Below is my code:

 public float scrollSpeed = 0.05f;
 private Vector2 savedOffset;
 Rigidbody2D player;

 void Start () {
     GameObject player_go = GameObject.FindGameObjectWithTag("Player");

     if (player_go == null)
     {
         //Debug.LogError("Couldn't find an object with tag 'Player'");
         return;
     }

     player = player_go.GetComponent<Rigidbody2D>();

     savedOffset = GetComponent<Renderer>().sharedMaterial.GetTextureOffset("_MainTex");
 }

 void FixedUpdate()
 {
     if(player.GetComponent<BirdMovement>().dead)
     {
         return;
     }
     float vel = Time.fixedTime * scrollSpeed;

     float y = Mathf.Repeat(vel, 1);
     Vector2 offset = new Vector2(y, savedOffset.x%1);

     offset.x = (float) System.Math.Round (offset.x, 3); //Mathf.Round (offset.x * 10) / 10;

     Debug.Log ("Offset:" + offset.x);
     if (offset.x > 1) {
         offset.x = 0;
     }
     GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", offset);
 }

 void OnDisable()
 {
     GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", savedOffset);
 }


texts: using rperp or perp to find perpendicular of a vector

texts:
i have code local coordinate

Vec2 velo = Vec2(100,0);
Vec2 Heading = velo.getNormalized();
Vec2 side = Heading.perp();
Vec2 trans = Vec2(12,12);

then i can generate toWorldCoordinate for trans vector:

word.x = heading.x* trans.x + heading.y * trans.y + pos.x;
word.y = side.x* trans.x + side.y * trans.y + pos.y;

im trying to apply example from book: game ai by example, using cocos2dx.
in cocos2dx we have rperp and perp for aplying perpendicular.
and in my POV,  cocos y is pointing up then we should use (-y,x) that is perp function.

but its seem the actor movement y is reversed then.
im realy confused with concept right hand / left hand. using rperp is fix the issue. but im still not understand why rperp should be used? afaik to make y pointing up we should use perp (-y,x) which is (1,0).perp = (0,1);// the destination is upward


texts:
I have created the below tilemap in tiled and I am wondering about a good approach to "separate" these two different heights in the map. I would like to keep it tile based, so adding a object layer for collision detection is a no for me.

I would like the player to move from the low ground to high ground using the ladder. But as you can see, two walkable tiled adjacent to each other should not be "connected" since they are on different heights.

Since I can only add properties to the tile in the sheet and not on the map itself afaik, I cannot mark the heights on my map. So I guess I have to work with different layers for each height. Check if the layer the player currently on has a tile or something, if that is even possible.

The reason I do not want to use a object layer is simple. My creatures move from tile to tile and I just want to check if that tile is walkable and on the same height level. No need to test vs a rectangle or polygonal object.

What I am actually looking for is having properties per coordinate. This would make it a lot easier (pseudo code):

tileMap[x][y].floorCount;
tileMap[x][y].walkable;

instead of:

map.getLayer(player.currentLayer).layerMap[x][y].tileExists;
map.getLayer(player.currentLayer).layerMap[x][y].walkable;

I simply cannot add properties to a "global" tile (tiled seems to only allow me to add properties to the tile on the sheet which is carried over to every usage of it. This image uses that same corner tile as in the above image, only this time the player is allowed to cross it, or perhaps hop over it.


texts: How to move a line of sprites in a sine wave?

texts:
So, I'm spawning a horizontal line of enemies that I would like to have move in a nice wave.  Currently I tried:

 Enemy.position.X += Enemy.velocity.X;
 Enemy.position.Y += -(float)Math.Cos(Enemy.position.X / 200) * 5;

This...kind of works.  But the wave is not a true wave.  The top and bottom of one pass are not the same (e.g. 5 for the top, and -5 for the bottom (I don't mean literal points, I just meant that it's not symmetrical)).

Is there a better way to do this?  I would like the whole line to move in a wave, so it looks fluid.  By that, I mean that it should look like each enemy is "following" the one in front of it.  The code I posted does have this fluidity to it, but like I said, it's not a perfect wave.

Any ideas?

Thanks in advance.


texts: Drawing simple geometric figures with DrawUserPrimitives?

texts:
I'm trying to draw a simple triangle based on an array of vertex. I've been searching for a tutorial and I found a simple example on riemers but I couldn't get it to work.
I think it was made for XNA 3 and it seems there were some changes to XNA 4?

Using this example:

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/The_first_triangle.php

I get this error:

  Additional information: The current vertex declaration does not
  include all the elements required by the current vertex shader.
  TextureCoordinate0 is missing.

I'm not english so I'm having some trouble to understand everything.

For what I understand error is confusing because I'm trying to draw a triangle color based and not texture based and it shouldn't need a texture.

Also I saw some articles about dynamic shadows and lights and I would like to know if this is the kind of code used to do it with some tweaks like culling because I'm wondering if its heavy code for performance in real time.

    public void LoadContent()
    {
        effect = Game.Content.Load<Effect>("Effect1");
        playerVision = new VertexPositionColor[3];
        playerVision[0].Position = new Vector3(-0.5f, -0.5f, 0f);
        playerVision[0].Color = Color.Red;
        playerVision[1].Position = new Vector3(0, 0.5f, 0f);
        playerVision[1].Color = Color.Green;
        playerVision[2].Position = new Vector3(0.5f, -0.5f, 0f);
        playerVision[2].Color = Color.Yellow;
    }

    // comes from draw method
    private void drawPlayerVision(GameTime gameTime, SpriteBatch spriteBatch)
    {
        effect.CurrentTechnique = effect.Techniques["Pretransformed"];
        Game.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, playerVision, 0, 1, VertexPositionColor.VertexDeclaration);
    }


texts: Super-quick MIDI generator with nonrestrictive license?

texts:
I'm working on my Ludum Dare entry and trying to figure out how in the world I'm ever going to get background music. I found WolframTones, but the license is too restrictive:

  Unless otherwise specified, this Site and content presented on this Site are for your personal and noncommercial use. You may not modify, copy, distribute, transmit, display, perform, reproduce, publish, license, create derivative works from, transfer, or sell any information or content obtained from this Site. For commercial and other uses, contact us.

But I really like the interface! It's a lot like sfxr - click a genre and download a song. That's so cool. Is there another program that does this same sort of thing but without a restrictive license, so that I can generate a bgm and use it in my game?


texts: Game Development Degree vs Computer Science Degree

texts: I'm at the point in my life where I'm starting to look at schools, and was hearing a lot of mixed things about schools such as Digipen or Fullsail that target game development specifically. As someone who is planning on becoming a programmer and getting into the games industry, would getting a game development degree be better than a traditional computer science degree?


texts: EnemyAI rotating on Y-axis in opposite direction

texts:
After a battle flag has gone off and the player has entered an enemy's battle zone I want to keep track of the player when it moves and make sure the enemy's Z-axis is always pointing towards the player.

Upon the player entering the battle zone, the enemy automatically marks the player as its target However there is a chance that the Z-axis may not be pointing towards the enemy's target when the battle is first initiated. I decided to shoot a ray cast from the Z-axis of the enemy when the battle flag goes off and rotate the enemy until the ray and the player intersect thus telling me that enemy's Z-Axis is lined up correctly.

the enemy always has a reference to its current target. My idea was that as once the enemy spots its target initially, it can save the position of the most recent spotting and then take the delta of the CurrentTargetPosition.x and the LastSpottingPosition.x If the delta is positive rotate right and if the delta is negative rotate left.

THE ISSUE:
my math or logic must be flawed somewhere because although it works sometimes, other times the enemy will randomly rotate itself in the opposite direction and the ray cast will essentially take the long route to hit the player instead of the shortest route as intended. Also the Local Origin of the enemy and the player are at different height respectively but I dont think that should matter in my case Code Below.

//create ray from enemy position orgin and point it on the Z-Axis
        Ray ray = new Ray(CurrentEnemyTransform.position, CurrentEnemyTransform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 50f))
        {
            Debug.DrawLine(ray.origin, hit.point);

            //ray hits current enemy target
            if (hit.transform == CurrentTargetTransform)
            {
                //check if enemy has seen its target before while in this battle
                //or is it the first time
                if (enemy.hasTargetLastPosition)
                    //replace old last seen position with most recent spotting
                    enemy.ReplaceTargetLastPosition(hit.transform.position);
                //or add the first spotting of target while in this battle
                else enemy.AddTargetLastPosition(hit.transform.position);
            }
            //ray is not intersectiing with the enemy's current target so rotate to look for it
            if (hit.transform != CurrentTargetTransform)
            {
                //check if enemy has seen its target once before in battle
                if (enemy.hasTargetLastPosition)
                {
                    //since last spotting has my target moved more to the left or right?
                    if (enemy.targetLastPosition.value.x > CurrentTargetTransform.position.x)
                    {
                        //rotate right
                        CurrentEnemyTransform.Rotate(-Vector3.up, 5f, Space.Self);
                    }
                            //rotate left
                    else CurrentEnemyTransform.Rotate(Vector3.up, 5f, Space.Self);
                }
                //never seen target yet during this battle so default rotation to right till you found it
                else CurrentEnemyTransform.Rotate(-Vector3.up, 5f, Space.Self);
            }


texts: How to move player based on existing Game state?

texts:
I'm trying to build a basic platforming game in C++ using SDL, and I've encountered this issue enough to know that there's something I'm missing.

What I'm working with, at the most basic level, is two classes, a GameState class that manages everything, and a Player class, that will move around.

The main GameState object will have a list of obstacles that the Player cannot move into, so I want my Player move() function to take a GameState* in order to move based on various components of it.

However, I'm hitting a problem I've seen a bunch of times -- a circular dependency issue. The problem is that the GameState object needs to have a Player member variable to update as the game runs (so I need to import the Player header to it), but I need to import the GameState header into the Player header in order to have my move function take a GameState* as a parameter.

This doesn't work. Normally I'd just settle and have the Player's move() function just take a list of obstacles, but I'm kind of hitting this issue all over the place and there are multiple instances where I want to access other variables stored in the GameState. Is this kind of behavior even possible? I've been racking my brain for a solution but I don't really know what the best way to fix this is, so I thought I'd ask.

Thanks in advance!

Edit: a simple example in code of what I'm talking about:

//in GameState.h
class GameState{
public:
    // ...
    Player* plr;
};

//in Player.h
class Player{
public:
    // ...
    move(GameState* state);
};


texts: Why are the images distorted in iOS build?

texts:
I'm working on a match three game. But, when I generate iOS build, the images are distorted and completely unrecognizable.
However, the issue happens only on some systems. I tried it on an iMac running El Capitan and Xcode 7.2, a Mac mini running Mavericks and Xcode 6.1. On these systems, the images were distorted.
I tried on another Mac mini running Mavericks and Xcode 6.1 and there was no distortion.
This is how undistorted images look:

And this is how the distorted images look:

I'm clueless as to why this happens. Please provide some help. Thanks


texts: How can I make custom character face editor In my game In an optimal way?

texts:
In many games there Is section as customize character that you can make your own character.I always love to know how can I make something like It.

Even old game have this feature? but how ?

For Implementing It I need accurate separation for communating between values and facial parts size.
So first I made multiple height-map based on facial parts for modifying by vertex shader and work correctly but this method Isn't optimal.can I Implement It just by one texture?

then I tried by using colorful mapping texture for detecting facial parts, but I have problem for getting color values from mapping texture In my shader code.

mapping texture:

My problem Is that my vertex shader Isn't match with my mapping texture.for example If I change _NoseLength other parts will changes.how can I tell to vertex shader which part is nose,forehead,lip,cheek,... In my colorful mapping.

Here Is my Shader Code:

Shader "Custom/Extrude" {
        Properties {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _ModTex ("Vertex Modify", 2D) = "white" {}
            _NoseLength ("NoseLength ", Range(-0.05,0.01)) = 1.0
            _LipSize ("LipSize ",  Range(-0.05,0.01)) = 1.0
            _CheekBones ("CheekBones ", Range(-0.05,0.01)) = 1.0
            _ForeHead ("ForeHead ", Range(-0.05,0.01)) = 1.0
            _EyeSize("EyeSize", Range(-0.05,0.01)) = 1.0

        }
        SubShader {
            Tags { "RenderType"="Opaque" "Queue" = "Transparent"}
            Cull off
            CGPROGRAM
            #pragma surface surf Lambert vertex:vert
            #pragma target 3.0

            sampler2D _MainTex;
            sampler2D _ModTex;

            uniform fixed _NoseLength;
            uniform fixed _LipSize;
            uniform fixed _CheekBones;
            uniform fixed _ForeHead;
            uniform fixed _EyeSize;

            struct Input {
                float2 uv_MainTex;
            };

            void vert(inout appdata_full v) {
                float4 lipSize = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).g;//Green
                float4 nose = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).b; //Blue
                float4 eye = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).r; // Red
                float2 cheek = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).rg; // Yellow
                float2 forehead = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).rb; // Purple
                v.vertex.y += _LipSize * lipSize;
                v.vertex.y += _NoseLength * nose;
                v.vertex.y += _EyeSize * eye;
                v.vertex.y += _CheekBones * cheek;
                v.vertex.y += _ForeHead * forehead ;

            }

            void surf (Input IN, inout SurfaceOutput o) {
                half4 c = tex2D (_MainTex, IN.uv_MainTex);
                o.Albedo = c.rgb;
                o.Alpha = c.a;
            }
            ENDCG
        }
        FallBack "Diffuse"
    }


texts: Raycasting center of camera is not working: why?

texts:
In my game i'm using Unity First Person controller.
I check every second what I am looking with the following code:

 cam = Camera.main;
 RaycastHit hit;
 Vector3 CameraCenter = cam.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, cam.nearClipPlane));
 if (Physics.Raycast(CameraCenter, transform.forward, out hit, 5))
 {
      WhatIamLookinTag = hit.transform.tag;
 }

The problem is that isn't working if move Up and down player "view" (so i move up and down mouse..)

I need the object that is in screen center (based on what am i looking).

Why ?


texts:
I want to learn android game development. I dont have any programing knowledge. So should I learn JAVA and eclispe to develop games for android.

Or should I learn Unity 3d. And is knowledge of java programing is necessary to develop android games in unity? Or knowledge of Javascript/UnityScript will do. Can I develop android games in unity with just JavaScript knowledge??

what are the benefits of unity over Java/eclipse and vice versa when talking of android game dev??


texts:
So I am making a snake game as final assignment for semester 1 of my game dev study.

We have to write it in C# in Visual Studio 2015. I am using the .NET 3.5 framework.

So basically how my snake works is as follows:

I made a vector2 List to store the snake parts. It starts only with the head obviously. When collission with the food occurs, I add a vector2 to the list. I draw a rectangle in the paint function and I make it take over the last position of the previous snakepart. That is how my snake works and how my snake gets longer as you eat the food.

I am having trouble with the snake collision itself though.

This is the code I came up with to check if the snake collides with itself:

for (int i = 1; i < Snake.Count; i++)
{
    if (Snake[0].X > Snake[i].X + (i * 64) || (Snake[0].X + (i * 64)) < Snake[i].X || Snake[0].Y > (Snake[i].Y + (i * 64)) || (Snake[0].Y + (i * 64)) < Snake[i].Y)
    {
        SnakeCollission = false;
    }
    else
    {
        SnakeCollission = true;
    }
}

So I check whenever the snake is NOT having collission, then snakecollission is false, else it's true.

What happens now though is that when I eat one piece of food, the snakecollission turns true, while the snake is not touching itself.

This is the link to my complete code: http://pastebin.com/gVUuazQN

Any help would be appreciated, I hope I have given an understandable description :)


texts: LibGDX drawing map using tiles without space

texts:
I am making a board game. To draw the map on the board I use different tiles.
On some screen the map looks good but on some other screens there is a space between the tiles.
How can I do so there won't be any space between the tiles?

I am designing my game with the size 480x800. To fit other screens I stretch it.

My tiles looks like this:

I draw the map using a for loop to draw the tile in different (x,y) position on screen.

Here is what I mean with space between tiles:
Screen with 240x400

Screen with 360x600, here there is no spacing between tiles.

I use camera and the screen to draw I don't use stage. I have also tried to use Viewport but I get the same results.

  cam = new OrthographicCamera();cam.setToOrtho(true, gameWidth, gameHeight);
  batcher = new SpriteBatch();
  batcher.setProjectionMatrix(cam.combined);
  shapeRenderer = new ShapeRenderer();
  shapeRenderer.setProjectionMatrix(cam.combined);

How can I do to solve the problem?


texts: Difference between [P2P] Relay Servers and Dedicated Game Servers?

texts:
I came across this unity Unity conference video on buillding multiplayer games https://www.youtube.com/watch?v=CuQF7hXlVyk
Form, this image we can see there are 3 P2P methods

and 1 Direct client server model

So what is the difference between P2P Client server and Dedicated game servers

These are the my understandings,

In P2P Client Server relay is just used to connect with players in order to over come NAT issues, In this model one of the client hosts the game
In direct dedicated game server game instance of game runs on server and clients connect to that game.

Enlighten me!
Thanks!


texts: Clipping a windows draw area - Direct x 9 and c++ - 2D using D3D

texts:
DirectX 9, C++... Let me set the scene:

I have a 16:9 image.
I have a 16:10 screen.
I want the 16:9 image to be drawn so that it is vertically centred within my 16:10 screen.
My 16:9 image is 1920 x 1080.
My screen is 1920 x 1200.

Easy:

float topOffset = ( 1200 - 1080 / 2 )

But what if my screen was 1400 x 900

I have to resize the image and get its new height, then do the above again:

float newHeightForScaledImage = ( 1080 * 1400 ) / 1920

Okay so now I have a topOffset for both widescreen cases. I draw all of my images and interactive objects at their ( y position + the topOffset ).

New problem is that the menu is also needed to take into consideration, so I use that systemmetricssomething call which returns 20 which I then subtract from the topOffset... Okay my drawing is vertically centred... perfect!

Question is, regardless of my entire game now being vertically centred (in the most crazy long hauled way possibly known to man), I can still draw outside of the game area into the black zone that now exists.

I know I am approaching this wrong, but I am too new to this to know any better.

How do you guys vertically centre your games if they are a different ratio to the artwork you have created for the backgrounds etc?


texts: How can I achieve a bullet tracing effect similar to the one in Planetside?

texts:
I've noticed that bullet tracers in Planetside 2 don't show up close -- every time I see them, it came from a barrel a ways away. I don't believe Planetside traces every bullet either, because then it'd look really weird.

I'm not sure what the exact parameters are, so how can I achieve a similar affect?


texts: Removing the contains ads label from the google play store

texts:
So previously in my Unity android game we had ads. Now I'm creating a demo version of the game from that project. I have succesfully removed all other permisions but the 'contains ads' still shows up on the google play store page. I have disabled the ads service from the services tab in the editor. I have comented or deleted all references to UnityEngine.Advertisements. Exporting the project to android studio results in this manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.LeadersPlay.LeadStreet" xmlns:tools="http://schemas.android.com/tools" android:versionName="1.26" android:versionCode="45" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" android:isGame="true">
    <activity android:label="@string/app_name" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false" android:name="com.LeadersPlay.LeadStreet.UnityPlayerActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <meta-data android:name="unity.build-id" android:value="21447188-7121-4c3e-8f0e-6602ae1caa74" />
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="android.max_aspect" android:value="2.1" />
  </application>
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

Where I cant find a single reference to adverts. I have also waited for the new version to be refreshed in the store.


texts: How can I handle the combination of multiple shader effects?

texts:
To be able to work efficiently with effects, is there a good way to combine multiple reusable "base" effects to achieve a more complex final result?

For example, say I have an effect that handles multi-texturing and one that handles ambient lighting. I'd like to combine them to achieve a final "ambient-lit multi-textured" effect.

This seems troublesome unless effects somehow can share information. When I just use the multi-texturing effect, I get the result I want. But when I afterwards apply the ambient lighting effect to intensify the color some value, it uses just uses the color from the ambient effect.

Is there a way to solve this? So that each effect can be individual and somehow not screw up the other effect? Or do I have to resort to manually writing one large effect file that lacks any flexibility?


texts: Skeletal Animation - Caching global bone transforms

texts:
Very often I see skeletal animation implemented like this:

On Init - store bone's local transforms and inverse bind pose
On Update - traverse the skeleton tree, multiplying local transforms on the way (and inverse bind pose)

However, it is more efficient to pre-calculate global poses from local transforms and just reassign them at specified time point to constant buffer.

What is the benefit of keeping all those local matrices? Does it have any meaningful application in other systems like physics, collision detection?
People still choose the first scenario and that actually keeps me puzzled.


texts: How do we add a spell in Skyrim with the Creation Kit that can spawn several variants of the same NPC?

texts: I am thinking of adding a spell that can summon a Nord, but I want it to have a random chance of spawning a female nord. I also want the NPC to appear in different armors, have different tattoos and different hairstyles. Is it possible to do this without using a script? What's the easiest way to achieve this?


texts: How to increase the acceleration of an object on the Y axis?

texts:
So far I am able to make the character fall at a constant rate but I am unsure how to make the character accelerate while falling.

When the character is falling I have a line of code as such:

position.y -= 7f;

How can I change my implementation such that the character falls faster over time?


texts: How do I make a quake-style camera tilt in Unity?

texts:
I want to make a retro-styled game with a modern look to it, and to do so I wish to make a quake-styled camera tilt. By that I mean when moving sideways the FPS Camera tilts a little bit, and the returns to default when letting go of the key. I have little to no scripting knowledge.

https://www.youtube.com/watch?v=scSea_v7JHA

Notice how in the video when moving to the side the camera tilts a little-bit.


texts: Paddle will not *continue* to move, pong game, XNA

texts:
I'm making a pong game, and my paddles no longer continue to move after holding down the left thumbstick or dpad down. It simply moves once with each press. I think it is because I'm not checking for a LastKeyPressed anymore now that I've begun to use a new input class, which uses arrays to check for which controller is being uses, and that's not what I was using before.

I've got to store the previous state, but I'm not sure of how to o that with these arrays.

// From my input class:

  public Input()
    {
        // Get input state
        CurrentKeyboardState = new KeyboardState[MaxInputs];
        CurrentGamePadState = new GamePadState[MaxInputs];

        // Preserving last states to check for isKeyUp events
        LastKeyboardState = new KeyboardState[MaxInputs];
        LastGamePadState = new GamePadState[MaxInputs];
}

    /// <summary>
    /// Helper for checking if a button was newly pressed during this update.
    /// The controllingPlayer parameter specifies which player to read input for.
    /// If this is null, it will accept input from any player. When a button press
    /// is detected, the output playerIndex reports which player pressed it.
    /// </summary>
    public bool IsNewButtonPress(Buttons button, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
    {
        if (controllingPlayer.HasValue)
        {
            // Read input from the specified player.
            playerIndex = controllingPlayer.Value;

            var i = (int)playerIndex;

            return CurrentGamePadState[i].IsButtonDown(button) && LastGamePadState[i].IsButtonUp(button);
        }
        else
        {
            // Accept input from any player.
            return IsNewButtonPress(button, PlayerIndex.One, out playerIndex)
                    || IsNewButtonPress(button, PlayerIndex.Two, out playerIndex)
                    || IsNewButtonPress(button, PlayerIndex.Three, out playerIndex)
                    || IsNewButtonPress(button, PlayerIndex.Four, out playerIndex);
        }
    }

    // Tells the left paddle to move down
    public bool LeftDown(PlayerIndex? controllingPlayer)
    {
        PlayerIndex playerIndex;

        return IsNewKeyPress(Keys.Down, controllingPlayer, out playerIndex)
               || IsNewButtonPress(Buttons.DPadDown, controllingPlayer, out playerIndex)
               || IsNewButtonPress(Buttons.LeftThumbstickDown, controllingPlayer, out playerIndex);
    }

    // Tells the left paddle to move up
    public bool LeftUp(PlayerIndex? controllingPlayer)
    {
        PlayerIndex playerIndex;

        return IsNewKeyPress(Keys.Up, controllingPlayer, out playerIndex)
               || IsNewButtonPress(Buttons.DPadUp, controllingPlayer, out playerIndex)
               || IsNewButtonPress(Buttons.LeftThumbstickUp, controllingPlayer, out playerIndex);
    }

// And now from my Gameplay class:

public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
........
input.Update();
            // Controls movement of the bats
            if (rightBat.GetType() != typeof(AIBat))
            {
                if (input.LeftDown(ControllingPlayer))
                {
                    leftBat.MoveDown();
                }
                else if (input.LeftUp(ControllingPlayer))
                {
                    leftBat.MoveUp();
                }

                if (input.RightDown(ControllingPlayer))
                {
                    rightBat.MoveDown();
                }
                else if (input.RightUp(ControllingPlayer))
                {
                    rightBat.MoveUp();
                }

// From my bat class, so that you see what the MoveUp and MoveDown functions do:

    public Vector2 GetPosition()
    {
        return position;
    }

    public void MoveUp()
    {
        SetPosition(position + new Vector2(0, -moveSpeed));
    }

    public void MoveDown()
    {
        SetPosition(position + new Vector2(0, moveSpeed));
    }


texts: WebGL game won't go into fullscreen mode on iOS devices

texts:
I have built my game and hosted it on itch.io. it works well on PC browsers and on the mobile Android browser.
The problem appears when I try to launch it on an iOS phone: the game won't go into full screen (it's supposed to go into it automatically). I added a button that's supposed to switch to full screen but it doesn't respond (the button does work on PC and Android though).