texts: How to handle a negative coordinate 2d map with a growing map size

texts:
I love this procedural generation theory and have been messing around with it. However I'm having trouble wrapping my head around how to store my map data. Usually I store my map data in a 2d array and that works in a limited space. However my map grows as the player explores new territory. So the size of the map changes and what's more the array will only support positive indices. So if the player tries to explore west or north he runs into a black abyss of nothingness. But I what more map to generate in those directions. Unfortunately those are the negative coordinate parts of the map. Is there a way to support a negative coordinate as the player explores new area? Here is an example of the problem in action.

https://76295db93db3812642fa5ba984c042fa81ffc37c.googledrive.com/host/0B6H3TRExU5M9eEkyd2FreHhiNlU/

Try moving West or north and you'll run into the edge of the map.


texts: What causes some computers to have no or slow OpenGL, and how to fix it?

texts:
I am using Java with JOGL to create OpenGL enhanced 2D graphics.  The graphics operations I use are nothing fancy, and should be supported by almost any recent graphics card.  For example, my game runs great on a Netbook.

I was hoping the game would run on most computers.  It runs fine on my own computers.  However, I found some computers have very slow performance (apparently software fallback, yielding about 2 frames per second).  I ran a LWJGL app on one such computer. It doesn't run at all (it reports something like
org.lwjgl.LWJGLException: Pixel format not accelerated, you can find various forum threads complaining about this but no apparent solutions, except the suggestion that it is a driver problem).  Other OpenGL software does not seem to work, either.  I also found that my Flash version of the game with exactly the same graphical effects performs pretty well full-screen on that same computer.  The computer in question has a recent ATI card but unfortunately I have no access to the driver manager.

The problem appears fairly widespread.  I think it is very unfortunate that OpenGL does not always provide access to graphics features found on most computers.  This makes it less attractive for casual 2D games, which I expect to run on any computer.

Did any of you run into this problem and manage to fix it?  AFAIK, both NVidia and ATI provide OpenGL as part of their standard driver sets, but maybe there are some exceptions?  Is this problem caused by third party drivers not supporting OpenGL, and can the problem be fixed by installing better drivers?  How many other graphics cards are out there without OpenGL drivers?

EDIT: As a final note, I can conclude that OpenGL is just not well supported on Windows machines.  Microsoft seems to have been doing their best to keep it off their platform, for example by deliberately leaving out OpenGL drivers in some Windows driver bundles. Get the vendor drivers, and you get OpenGL; get the standard drivers that Windows downloads for you, and you don't.  This has been causing no end of trouble for others as well. For example, for implementing WebGL, Web browsers use Angle, which is an OpenGL ES emulator for DirectX. So, what we'd really need is something like Angle, only for full OpenGL.


texts: Capping neighbour height difference on heightmap?

texts: I am generating a heightmap with some basic perlin noise but I need to cap the differences between each neighbouring value. A cardinal neighbour can only be -1, 0, +1 in difference while diagonal neighbour can range from -2 to +2. What is a good approach to make sure the map is generated within these rules? Does perlin or a small extension help me do this or should I make 2nd pass after the map is generated by perlin or simplex? I am currently doing the latter where I go over each tile and change it's cardinal neighbours according to it's own value but it is going over the same position/number very often.


texts: How to disable static friction in Box2D?

texts: I'm making a 2D platformer. One of the issues is that when the character hits the ground, there's an initial pause and then the character finally slows down to a halt. I believe the initial pause is because the coefficient of static friction is higher than the coefficient of kinetic friction. How can I set the coefficients to be equal or disable static friction?


texts: when I try to change the fullscreen mode in construct it randomly says "Construct is not responding". that's all the details I really have.


texts: Ball Speed is not increasing as per code

texts:
I am working on small project , but now I have a problem . The problem is The Player speed (Ball speed) is not increasing as per the code .

In the beginning ball speed increases , but as the time goes the speed becomes constant .

I made Gravity as -50 in Y - Axis .

So here is the C# Script attached to the ball :-

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

public class Ball_Script : MonoBehaviour
{

// Ball Physics Variables
private Rigidbody Ball_Rigid;
public float Ball_Speed = 10f;
private float Speed_Change_Time = 1.0f ;

// UI Text
public Text My_Ball_Speed_Text ;
public Text My_Key ;

// Use this for initialization
void Start ()
{
    Ball_Rigid = GetComponent<Rigidbody>();
    My_Ball_Speed_Text.text = Ball_Speed.ToString () + " km/h";
    My_Key.text = "No Key Pressed";
}

// Update is called once per frame
void Update ()
{
    // Restart game
    if(transform.position.y < -7.0f)
    {
        Application.LoadLevel(0);
    }

    // Ball Automatic Movement script Starts here
    Speed_Change_Time_Interval ();
    Ball_Rigid.AddForce (new Vector3 (Ball_Speed * -1 * Time.deltaTime, 0, 0));
    // Ball Automatic Movement script Ends here

    if(Input.GetKeyDown(KeyCode.LeftArrow))
    {
        Ball_Rigid.MovePosition(new Vector3(transform.position.x , transform.position.y , transform.position.z - 1.0f));
        My_Key.text = "Left Arrow Pressed";
    }

    if(Input.GetKeyDown(KeyCode.RightArrow))
    {
        Ball_Rigid.MovePosition(new Vector3(transform.position.x , transform.position.y , transform.position.z + 1.0f));
        My_Key.text = "Right Arrow Pressed";
    }
}

// This Fixed update stops the ball from bouncing
void FixedUpdate()
{

    Vector3 currentVelocity = Ball_Rigid.velocity;

    if (currentVelocity.y <= 0f)
        return;

    currentVelocity.y = 0f;

    Ball_Rigid.velocity = currentVelocity;
}

// This function increases the ball speed in every 1 second
void Speed_Change_Time_Interval ()
{
    Speed_Change_Time = Speed_Change_Time - Time.deltaTime;

    if(Speed_Change_Time <= 0)
    {
        Ball_Speed = Ball_Speed + 10;
        Speed_Change_Time = 1.0f;
        print(Ball_Speed);
        My_Ball_Speed_Text.text = Ball_Speed.ToString ()+ " km/h";
    }
}
}

Here FixedUpdate () stops the ball from bouncing and  Speed_Change_Time_Interval () function  increases the ball speed in every second . But it works some extent . Then there is no change in speed of the ball . Here is the video of the game ( Recorded with Jing , so file is in .swf format . Sorry for that :( ) Link :- http://www.mediafire.com/download/ibk4ffjm3y6i96y/Ball_Vid.swf

File size = 9.28 MB

So what is the problem of this script . If my method is wrong / not good please suggest me a good one :).

Hope you will help me to figure it out .

Thanks ,
Regards

NB :)


texts:
How do you generate combinations in slots to achieve a wanted probability of the user winning?

Say, you decide that he should win $200. How do you generate combinations that'll cause winnings approximately $200?


texts:
So far I've seen the only way to set boundaries on box2d world which is to create rectangular shapes and place them at the edges of the screen, is there any other way? Perhaps I can set boundaries with some formula instead of shapes?

Why I'm asking: suppose my "world" looks like a rectangular box without top constraint so any object is ultimately constrained on left, right and bottom sides but can appear infinitely high.


texts: How can I check if the ray is hitting specific objects names?

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

public class Map : MonoBehaviour
{
    public Camera mapCamera;
    public Text objectWasHit;
    public GameObject mouseOvered;
    public float distanceToHit = 1000;

    private Camera[] cameras;
    private List<GameObject> objectsToHit = new List<GameObject>();

    // Use this for initialization
    void Start()
    {
        cameras = Camera.allCameras;

        GameObject levels = GameObject.Find("_Level");
        foreach (Transform child in levels.transform)
        {
            child.gameObject.AddComponent<UnityEngine.MeshRenderer>();
            objectsToHit.Add(child.gameObject);
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            if (mapCamera.enabled == false)
            {
                foreach (Camera cam in cameras)
                {
                    cam.enabled = false;
                }
                mapCamera.enabled = true;
            }
            else
            {
                foreach (Camera cam in cameras)
                {
                    cam.enabled = true;
                }
                mapCamera.enabled = false;
            }
        }

        bool rcHit = false;
        Vector3 mouse = Input.mousePosition;
        Ray castPoint = mapCamera.ScreenPointToRay(mouse);
        RaycastHit hit;
        Debug.DrawRay(castPoint.origin, castPoint.direction * distanceToHit, Color.magenta);
        if (Physics.Raycast(castPoint, out hit, distanceToHit))
        {
            rcHit = true;
            if (mouseOvered != hit.collider.gameObject)
            {
                mouseOvered = hit.collider.gameObject;
            }
            objectWasHit.text = mouseOvered.name;
        }

        if (!rcHit && mouseOvered != null)
        {
            mouseOvered = null;
        }
    }
}

Now it's hitting every gameobject and then display the object that was hit name:

objectWasHit.text = mouseOvered.name;

But I want it to display the name of the object/s only if it hit one of the objects in the List objectsToHit.


texts: How can I create a fade effect between scenes in Libgdx?

texts:
I have implemented a screen fade with Scene2D.  It currently fades fades out of one screen to black, then then from that black into the next screen.  It would be really awesome if I could fade straight from the first screen to the new screen, without the black state between.  Is this possible?

I tried using the parallel method but it just did everything all at once.  I want it to kind of morph through the screens.


texts:
I'm making a management sim game, something along the lines of Roller Coaster Tycoon. I want to know what the best way to structure my world objects is so to maximise performance.

Let's say I have 5,000 people in my game I could:

Make an object and store them in an array like so;

class person() {
    this.x = 0;
    this.y = 0;
    this.thirst = 15;
    this.hunger = 15;
    // etc.. add methods:
    public findPath(int destX, int destY) {
    // and so on
    }

    people = new person[5000];

for (int = 0; i < 5000; i++) {
    people[i] = new person;
    }

Or should I make an object of people that contains many byte arrays representing attributes of people like so:

class people() {
    this.hunger = new byte[5000]
    this.thirst = new byte[5000]

    getThirst(int i) {
        return this.thirst[i]
        }

 // and so on....

Or am I totally off the mark?


texts:
If I have a 20x10 grid (640x320) where tiles are 32x32

The grid are rendered:

for (var y = 0; y < 10; y++) {
  for (var x = 0; x < 20; x++) {

    var tileX = Math.round(Camera.x / 32);
    var tileY = Math.round(Camera.y / 32);

    var tile = Game.map[tileY][tileX];

    rect(x * 32, y * 32, 32, 32);

  }
}

The camera follows a Player object and is in the middle on the canvas.

Camera position (x) are calculated such as:

Player.x - Camera.x + 320 > 640
   Camera.x = Player.x - 320;

When the camera moves, it looks kinda solid (since it moves a whole tile). How can I make the movement a bit smoother? (Perhaps showing part of the next tile on either side, rather than the whole at once)


texts: Unity's CharacterController vs. Rigidbody with Collider

texts:
With a few friends I started to make a 3D game in the style of the old platformers à la Super Mario 64 / Spyro / Banjo Kazooie.

So now we are thinking about the controls and how to do them.

There seem to be two mutually-exclusive options: Giving our character a rigidbody and however many colliders we want OR
using a character controller.

At the moment we have a rigidbody with a collider which technically works, but we have to make our own grounded check, and movement, while those two in particular are relatively easy to implement.
If we start to use a character controller OTOH, we won't have all the collisions anymore and programming logic needs to be applied in a different way.

Let's take a jumppad as example:

If we use a Rigidbody, the jumppad itself checks if someone is standing on it, and if so it increases the jumpstrength while that someone stands on it.
If we use a CharacterController, we'd have to check not only if we are standing on a jumppad, but also on which one, to determine the actual jumpstrength, as they might differ between pads.

So, is there a clear winner to use in a 3D platformer with fighting elements or do we have to work with limitations on either and just have to work around them?


texts: How hard is it to edit an xml based database in a Unity3D game?

texts:
I want to make an item database in xml for my game.

I was thinking about encrypting it, but I don't know how hard is it to edit the database.

I want my database to be moddable, but hard to screw up for average users.

(~I don't want kids to make the game unplayable, then unable to fix it)

Should I encrypt the database? Or will it just annoy the "modders", while the average players wouldn't find the database even when it isn't encrypted?

TL;DR How hard is it to get a raw xml file from a standalone build?


texts: Unity - UI - Raw Image with Texture becomes Smaller after Build

texts: I am a beginner in the game development world, I have just one quick problem with the UI, as you can see during the Unity Player, the UI (Raw Image w/ Texture) is normal in size but when I build my game to APK or EXE and run it, the UI is small. Why is this happening and how to fix it?


texts: Color variation for trees in Unity Editor

texts:
I am reading a book on Unity. I met a topic about color variation option for the trees in the terrain. I went to try it on my own in the editor, but was disappointed when did not find it. So my question is where can I find the color variation option or what can I use instead?

Here is screenshot from the book and from my editor.

I am using 5.6.1f1 Personal (64bit) right now. Here is what I found on an issue so far.


texts:
I'm having a problem with GUI.DrawTexture() and I'm looking an alternative function to draw 2D Texture Images. The problem I have is that my textures draw above all other objects and when my camera moves, the images move with the camera, keeping their relative position inline with the cameras position.

using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using UnityEngine;

public class AnimatedGifDrawer : MonoBehaviour
{
public string loadingGifPath;
public float speed = 1;
public Vector2 drawPosition;

List<Texture2D> gifFrames = new List<Texture2D>();
void Awake()
{
    var gifImage = Image.FromFile(loadingGifPath);
    var dimension = new FrameDimension(gifImage.FrameDimensionsList[0]);
    int frameCount = gifImage.GetFrameCount(dimension);
    for (int i = 0; i < frameCount; i++)
    {
        gifImage.SelectActiveFrame(dimension, i);
        var frame = new Bitmap(gifImage.Width, gifImage.Height);
        System.Drawing.Graphics.FromImage(frame).DrawImage(gifImage, Point.Empty);
        var frameTexture = new Texture2D(frame.Width, frame.Height);
        for (int x = 0; x < frame.Width; x++)
            for (int y = 0; y < frame.Height; y++)
        {
            System.Drawing.Color sourceColor = frame.GetPixel(x, y);
            frameTexture.SetPixel(frame.Width - 1 - x, y, new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A)); // for some reason, x is flipped
        }
        frameTexture.Apply();
        //frameTexture.LoadImage.
        gifFrames.Add(frameTexture);
    }
}

void OnGUI()
{
    GUI.DrawTexture(new Rect(drawPosition.x, drawPosition.y, gifFrames[0].width, -gifFrames[0].height), gifFrames[(int)(Time.frameCount * speed) % gifFrames.Count]);
}

}

The code above is designed to draw animated GIFs using System.Drawing.dll in Unity


texts: Very subtle HLSL syntax change causes compliation error

texts:
The following HLSL works and compiles:

texture2D renderTarget;
float h; // declared here

sampler GetRenderTarget = sampler_state
{
    texture = <renderTarget>;
};

float3 GetHsvFromRgb(float3 c)
{
    float4 k = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    float4 p = lerp(float4(c.bg, k.wz), float4(c.gb, k.xy), step(c.b, c.g));
    float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;

    return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

float3 GetRgbFromHsv(float3 c)
{
    float4 k = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    float3 p = abs(frac(c.xxx + k.xyz) * 6.0 - k.www);

    return c.z * lerp(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y);
}

float4 ShadeVertex(float3 p : POSITION0, inout float2 t : TEXCOORD0) : POSITION0
{
    return float4(p, 1);
}

float4 ShadePixel(float4 p : POSITION0, float2 t : TEXCOORD0) : COLOR0
{
    float4 c = tex2D(GetRenderTarget, t);
    float3 hsv = GetHsvFromRgb(c);

    hsv.x = (int)h; // compiles and works

    float3 rgb = GetRgbFromHsv(hsv);

    return float4(rgb, h);
}

technique Simple
{
    pass FirstPass
    {
        VertexShader = compile vs_3_0 ShadeVertex();
        PixelShader = compile ps_3_0 ShadePixel();
    }
}

However, if I remove the cast from the h variable it causes an exception:

float4 ShadePixel(float4 p : POSITION0, float2 t : TEXCOORD0) : COLOR0
{
    float4 c = tex2D(GetRenderTarget, t);
    float3 hsv = GetHsvFromRgb(c);

    hsv.x = h; // removing int cast causes compilation exception

    float3 rgb = GetRgbFromHsv(hsv);

    return float4(rgb, h);
}

This doesn't really make any sense to me. The h variable is being set to 1 in code. The int cast is not what I actually want to do, I was just testing various things trying to understand why I couldn't assign the h variable value directly. Exception I get after removing the int cast is:

  (51,18): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression

More confusingly, if I cast to a float, it goes back to not working:

float4 ShadePixel(float4 p : POSITION0, float2 t : TEXCOORD0) : COLOR0
{
    float4 c = tex2D(GetRenderTarget, t);
    float3 hsv = GetHsvFromRgb(c);

    hsv.x = (float)h; // also an exception

    float3 rgb = GetRgbFromHsv(hsv);

    return float4(rgb, h);
}

Not sure what is going on or what I'm doing wrong, any insight?


texts: How to manage game components and their attributes?

texts:
Currently I am working with cocos2d for the iPhone. I want to make my game structured and  consequential. How to manage all the game components?

What do I mean with game components? A game component is e.g. the terrain or any other object like a character that is drawn on the scene. These components have attributes and duties like "let's clean up that place" or something similar.

So actually I want to wrap a component with all its attributes to make the code reusable. E.g. think of terrain. There may be a terrain in the front. Behind this terrain there is another terrain, e.g. hills, it's still terrain but just with maybe another color.

How do I accomplish that in cocos2d? In my scene there is a draw method where I normally would draw the terrain. But if I would put everything that is drawn in that method it would get confusing.

It would be cool to create an object of a terrain class and add this to the scene which would draw the terrain automatically. How do I do that? What would be the parent class of the terrain class?


texts: How to stop car from slipping backwards on a slope?

texts:
I am trying to simulate a car in Unity, the slope of the road is high so the car slips backwards. Is there any physics property which can stop this from happening?
Thanks in advance.


texts: How do I stop off-screen tiles of a 2D tilemap from being rendered?

texts:
I am seeing lag because I render all tiles in my map at once.  How can I exclude off-screen tiles from being rendered?

My tiles are 32×32 and my player is always in the centre of the screen.

Here is my render method:

JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("assets/maps/"+map+".json"));
JSONObject jsonObject = (JSONObject) obj;

for(int x = 0; x < worldWidth; x++) {
    for (int y = 0; y < blocksHeight; y++) {
        Object out = jsonObject.get("x"+x+"y"+y);
        String f = out.toString();
        int i = Integer.parseInt(f);
        g.drawImage(GetImage.ReturnImage(i), x*Size.Tile, y*Size.Tile);
    }
}


texts: When try to save game on an xbox with xml serialization i get a code 4 error. I made sure t oadd all the xml referances and there is no errors until i run the game. Any suggestions?


texts: How do I make a progress bar with letters that get "filled in"?

texts:
I want to make a progress bar made of text! I have two images: One with the text in gray, the other coloured:

As my game is loading, I want the letters to "fill up" with color:

They would start out gray, then fill in.

I was thinking of overlaying a transparent rectangle over the gray image, then stretching the transparent rectangle to match the progress. But then the background will be coloured too. I want only the letters to be coloured!

How can I do this?


texts: MMORPG game server data storage performance

texts:
When writing a MMORPG game server...

Which storage design is better:

Should I only save character data from specific times?

On character log-out.
User disconnect.
From time to time. (every few minutes)

Should I save it immediately? Which would make writing be more extensive.

Other things:

What is the best practice when dealing with data on a real time
MMORPG game?
Which database is best with being multi-platformed in mind?


texts: How can tell if a player has performed some action in UDK?

texts:
For simplicity, let's say that I want bots to kill me when I enter a room without greeting them. So in this case I would need to store, somewhere, the variable didGreet, which should be changed when I send the message "Hello." Then, when any pawn sees me, he will check the didGreet variable and if this was false he would start firing at me.

I've heard that this should be done using the GameInfo class, but unfortunately I don't know how to create, access and change variables there. How can I accomplish this?


texts:
I'm trying to make custom 2D softbody physics that can interact with other Unity colliders.
My starting point was to implement a custom spring joint capable of connecting two entities ("particle") together.
With these joints and with 4 particles I made a simple rectangle. The 4 particles are created inside a GameObject used as a container, to which I applied the RigidBody2D and PolygonCollider2D components.
So the displacement of the particles is relative to the container.
If I apply forces directly to the particles the figure deforms correctly and works quite well, but the problem is that I don't know how to get the forces directly from the collider or the rigid body.
What I would need is to deduce from the collisions the forces to be applied to the particles, and at the same time keep the standard behavior of the collision.
Do you have any suggestions on this?


texts: How to implement drawing only to the specific area of the window?

texts:
I'm trying to implement "canvas" where I will display loaded texture and select specific parts of it so I can put them on tilemap, I'm also trying to add zooming and panning only in "canvas" part of the window. I've tried using view and viewport but setting viewport size is what I'm struggling with the most. What I've tried:
First I set the view to be size of the window and its center is offset by (-250, -20) - this the point where properties window ends (x = 250) along with main menu bar (y = 20):
m_view.reset(sf::FloatRect(-250.0f, -20.0f, get_window().getSize().x, get_window().getSize().y));

Then if window has been resized I process the Resized event:
if (event.type == sf::Event::Resized)
{
    m_view.reset(sf::FloatRect(-250.0f, -20.0f, event.size.width, event.size.height));
    get_window().setView(m_view);
}

But if I want to implement panning (moving the view) and zooming I need to set viewport so it will only render in "canvas" area. I can try to set viewport's FloatRect manually but what if window will get resized? How do I deal with this problem?

Godot TileSet/TileMap Editor as reference


texts: How can I render 3D objects and particle systems in front of a Screen Space - Overlay Camera?

texts:
I am using Unity 2019 with the Universal Render Pipeline.  I have a canvas that is using Screen Space - Overlay render mode.  I cannot change my render mode to Screen Space - Camera, because it is not currently supported by the Universal Render Pipeline.

How can I have a particle system, or any other 3D objects, render on top of my canvas?


texts:
So I'm working on a LibGDX game, and when a bullet body collides with a block, I want to destroy the bullet. I'm calling:

Globals.gameMan.world.destroyBody(bullet.body);

and for whatever reason, the entire game crashes after this. I'm given a message with the option to debug twice, and when I click it, nothing happens. Thank you, and sorry for the noob question.


texts: How to disable Camera from tilting when following a game object?

texts:
I have a game character object which is followed by camera. Camera is child object of Character.

Using rigid body makes the character tilt in slopes and camera tilts too.

how do i stop camera tilting when character tilts?


texts: Why a point light not cast shadow on my moving object, but only on static?

texts:
In my Unity3d scene i've two light: a directional (sun, outside the window) and a point light.
In my scene, I can see shadow correctly, also if i "play" with settings like Intensity or Range.
But in Play mode, my moving player don't cast shadow when hitted by my point light, but cast shadow  correclty when hitted by directional light.

The image here is explicative: the shadow you see is from a chair, hitted by the point light.
My player instead, hasn't shadow.

What am i wrong ?


texts: What are the Starting Games I need to make?[Best steps for a beginner Game Developer?]

texts:
Possible Duplicate:
  What are good games to “earn your wings” with?

Hai,
     I'm new to the genre "Creating Games".Previously i had done only porting.I need some suggestion's for making a game.

  What are the basic game logics i need to start with?
             - Should i write Tic-Tac-Toe game? - Actually this seem very basic to me.

I'm totally confused on where to start with.I like to create big games but after starting i feel the game is too heavy to handle.
Can any one list out the basic needs of a Game Play programmer?
I don't mind using any platform (Flash,c++,objective-c) but i need to know what are the game logic's i need to know before i start a big game.


texts:
I want my character to aim with the mouse so, arms and head must move following mouse cursor and when the character is stand still it could change its stance a bit to accommodate the arms position. I used to use skeletal systems and in this situation I would use a bone that would move both arms at once but it seems Unity animation only supports tweenings. Can this be done with this system?

On the other hand how would you setup the character to easily make it follow shooting position with head and arms without moving all elements from code? As an example, if I had bones I would have set one parent bone for arms and use it to move both at once, etc. I guess IK and constrains is the way to go.


texts:
So I'm trying to have some form of input in my game and I understand all the keyPresses and whatnot but the only issue is I have no idea of adding a textfield to the game. JTextfield doesnt seem to appear so I started taking keypresses and adding them to a string but this proves to ether be too slow or too fast. Is there any way of adding a textfield to the game?

I'm using just plain java and swing.

Here is a code snippet:

JFrame frame = new JFrame("Game");
    //Sorts out JFrame variables and settings.
    frame.setLayout(null);
    setBounds(0,0,800,600);
    frame.add(this);
    frame.setSize(800,600);
    frame.setResizable(false);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            gameRunning = false;
            System.exit(0);
        }
    });
    frame.addKeyListener(this);
    addKeyListener(this);
    addMouseListener(this);
    addMouseMotionListener(this);
    int columns = 25;
    TextField localTextField = new TextField("Text", columns);
    Insets insets = frame.getInsets();
    Dimension size = localTextField.getPreferredSize();
    localTextField.setBounds(25 + insets.left, 5 + insets.top,
                 size.width, size.height);
    frame.add(localTextField);
    frame.setVisible(true);
    //Double Buffer set up.
    createBufferStrategy(2);
    strategy = getBufferStrategy();

Ok, so I pressume the only way of doing this is the way in which I'm currently doing it.While the text box is open it adds all keypesses together with a slight delay between each key press. I just thought that there might have been an easy method of doing this.


texts:
As I know animations are actions. Now I need to play animation frame by frame. Say I have an animation from N frames. each frame should be played after t delay. Now I want to play animation frame by frame, each frame advance the animation's state. How I can do this?

And what about playing actions frame by frame advancing the state in general.

I ask because I use ECS, and I deal with frames.

P.S. I want to do something like this:

Action * a = MoveTo(initialPoint, finalPoint, durationOfAnimation);

a->play(0.001 seconds);
a->play(0.003 seconds);
a->play(0.02 seconds);
a->play(0.67 seconds);
a->play(0.06 seconds);

And see the animation.


texts: Multipass shaders and switching between passes

texts:
As mentioned here Effects should be avoided in DX11. If I understand correctly, that includes techniques and passes defined in *.FX files. So when doing a multipass shader (like the always-mentioned toon shader) I should create 2 separate shaders (for 2 passes), set the first one, render geometry, set the second one, render the geometry again. Correct so far?

But what I'm concerned about is that whether or not the technique/passes in Effects are just a syntactic sugar and offer no performance improvement whatsoever. Or the whole Effects in general. Do they?

GLSL version 4.20 or sth about that has subroutines which allow to switch the function in the shader and avoid changing the shader which does improve performance. Is there anything similar in DX?

Edit: Here [link] it says:

  Since performance is crucial in shader programs, avoiding a conditional statement or a shader swap can be very valuable. With subroutines, we can implement the functionality of a conditional statement or shader swap without the computational overhead.

Also this post seems to confirm it.


texts: Why would someone chose midpoint displacement over perlin noise for 3D terrain generation?

texts: I myself am creating a terrain generation algorithm and would be interested in knowing why others have chosen midpoint displacement over perlin noise. Minecraft is an example where midpoint displacement was preferred. If anyone knows why I would be glad to hear it.


texts: How to move a Entity without moving its children in AndEngine?

texts: I have a Entity in AndEngine and when I move it, all child move together with it. Which is great. But, sometimes, I need to move it without moving its children. Is it even possible? And, if it is, how can I do so?


texts: Trouble with Index Out of Range Exception

texts:
I'm trying to make a textbox for a small game and I've run into an issue. I'm using drawString, which doesn't support \n so I've made an array of strings for multiple lines like so. Also, there is a global int called lettersShown that will be important later.

int lettersShown = 0;
String[] result = new String[] {" "," "," "," "," "," "," "," "};

In the constructor of the class, I then created a random event containing an array of 8 strings(Sorry if this is long and poorly formatted, its just for testing purposes.)

travel.add(new Event(this, new String[]{"You walk along a winding dirt
road,", "exposed to the scorching of the sun.",
            "Every so often, you pass the remains", "of blasted homes
and dilapidated", "hovels. The air is especially arid",
            "today, and by the time the sun drifts", "down into the horizon
you find", "yourself parched."}, -20,0,0,0));

So after I did that, I created a method to draw each line in order.

public void drawText( int x, int y, Graphics g) {

    for(int i = 0; i <result.length; i++) {
        g.drawString(result[i].substring(0, lettersShown), x, y);
        if(result[i].length() > lettersShown) {
            lettersShown++;
    }
        //lettersShown = 0;
        y+=15;

    }
}

This method works perfectly for any arrays that only have one string, such as this one:

travel.add(new Event(this, new String[] {"You traveled to a new city"},
0,0,0,0));

However, the second it starts to render an event with multiple lines, I get this exception

Exception in thread "Thread-1"
java.lang.StringIndexOutOfBoundsException: String index out of range:23
at java.lang.String.substring(String.java:1963)
at mains.EventManager.drawText(EventManager.java:149)
at mains.Game.render(Game.java:185)
at mains.Game.run(Game.java:87)
at java.lang.Thread.run(Thread.java:748)

I've been trying so many things to fix this seemingly small issue and I'd rather not resort to just having a ton of strings and drawing each of them one at a time so any guidance or anyone who can identify the problem would be greatly appreciated. Thanks!


texts: Code Logic's execution with respect to time Events

texts:
I have to show complete 24 hours cycle in Unity3d Scene. Where different kind of task will be executed in different Times.

Suppose

at 2pm I have to move a car,
at 6pm An Aeroplane will land on airport
at 07:07pm I have to open the door of Market's Buildings
and so on different task/works execution at different timing.

Now, I have some basic animation e.g., car, Aeroplane and door etc.,. Now I am confuse that how to play and stop my animation according to the time. And time can also be
changed manually using GUI. If currently 6pm (animation working) then user can switch to 8am to view 8am time's animation (or code execution). And User can also fast the timing to view complete hours in a single minutes or in an hour.

I can use if/else in Update Events but I guess this is not the right way to do and will be very difficult if I require to show significant number of works
in different time duration (which means significant number of if/else statements).  Just like below

void Update(){
if(time =1){
//logic
}
if(time =2){
//logic
}
if(time =3){
//logic
}
...//so on, tedious way
...//and also not possible if time require between the hours, suppose 06:06pm
}

What to do ? How to handle this?


texts: Which to use for game Development? SDL_Surface or SDL_Renderer

texts:
I'm relatively new to game development compared to the pioneers in this field, and my question, as stated in the title is, Should I Be using SDL_Surface for game development or SDL_Renderer, I know that SDL_Renderer is the new, and more efficient way, but i still do have a doubt...

Thanks in advance...
Random Developer


texts:
I have just started experimenting with godot. What I notice apk size generated by godot is too big which is 10MB considering fact my game does nothing it only moves some random blocks up and deletes itself.
I have generated only ARM64 in release mode .What I am missing?
Do I need to recompile godot with by disabling unwanted things?


texts: How to calculate direction from initial point and another point?

texts:
I'm making a simple game where I shoot things from a certain point on screen (A).

I tap the screen and shoot the projectile from initial point(A) to the tap point(B).

But I want the projectile to move along the same path instead and fly out of bounds of the screen.

How do I calculate a point that is on the same line that these two points, but further away?

This is a simple math, but I can't figure it out.


texts: Problem with textures using DirectX file format in Irrlicht

texts:
I'm using Irrlicht 1.8.1, and Blender 2.71 to create my animations. I've just create a simple cube, added a default material to it, and i've mapped a texture to it using UV unwrap, all that in Blender.

Then i use I to save rotation+location+scale,  when i pressa ALT+A, everything works fine, and when i press F12, i can see that the texture mapping are fine too.

When i export the mesh using OBJ format (which is not an animation) and load it as AnimatedMeshSceneNode or simple MeshSceneNode, Irrlicht render it as expected. Fine

But when i export the entire cube animation scene (checking the export animation option, and material option, etc) and loading it in Irrlicht (cube.x) the model is loaded and the animation started as expected but the TEXTURE ARE MAPPED INSIDE THE CUBE! Then the outside faces of the cube looks like transparrent letting you to see the texture mapped on the faces inside this cube.

Thought, I noted Irrllicht was able to load the well known "dwarf.x" animation model in its examples source codes.

Anyone knows how to fix this unwanted behaviour of the texture?


texts:
I writing this as I have run into a dilemma that I cannot readily answer.

  Specifically, how many threads is too many?

Background tl;dr:

Writing a game (Surprise.)
C++11, all server-side bits running on Linux server installs (headless)
Login server and chat server are on a single server
Database server/processing is its own server (eventually)
The world server is the 'master' server, in which zone 'servers' (threads) are spun up. Each zone 'server' is responsible for a specific planet and all that entails (npcs, entity lists, etc).

With that brief intro, is there a point in which there are too many threads? Assuming there are 10 planets (zone "servers"), each with their own thread, would there be any extreme problems (not performance bottlenecks) that need to be accounted for in this type of situation utilizing an 8 core server? Would the same problem persist at 16 cores?

The end goal would be to allow for up to three "instances" of each planet, with maybe 20 planets (~60 threads) in the end. I understand that this could cause CPU contention as each thread is waiting for CPU cycles, but not enough to effectively hang the system (excluding a zone server locking up). If the game progresses to that point, 32 core servers would be an (expensive) option.

Is there anything that I am missing or not understanding?

Thank you in advance!


texts: Should tiles be referenced statically when making a map or some other way?

texts:
I'm trying to think of a way to manage tiles in my game, so far I have a Tile class that has characteristics about the tile in question, a TileDictionary class to keep a list of tiles to use, and the map is simply just a Tile[,] array.

class Tile
{
    public Texture2D graphic;
    string name;
    bool walkable;

    public Tile()
    {
        name = "Dirt";
        graphic = null;
        walkable = true;
    }

    public Tile(string _name, Texture2D _graphic, Boolean _walkable)
    {
        name = _name;
        graphic = _graphic;
        walkable = _walkable;
    }

static class TileDictionary
{
    public static Tile DIRT_TILE = new Tile("Dirt",null,true);
    public static Tile STONE_TILE = new Tile("Stone", null, true);
    public static Tile CLAY_TILE = new Tile("Clay", null, true);

    public static void LoadTileGraphics(ContentManager content)
    {
        DIRT_TILE.setGraphic(content.Load<Texture2D>("tiles/dirt"));
        STONE_TILE.setGraphic(content.Load<Texture2D>("tiles/stone"));
        CLAY_TILE.setGraphic(content.Load<Texture2D>("tiles/clay"));
    }

Is this a good method? I see games like Minecraft using static Block instances to reference their blocks, but knowing that it was previously all magic numbers, I feel like this system was just a band-aid over the old system. Obviously all tiles would be loaded via the TileDictionary, but I am confused on how using this method would handle implementing and using more complex blocks that have functions tied to them or anything.


texts: Algorithm to select all cells inside rooms/regions

texts:
I have a 2d game map consisting of several 'rooms'

For example, here is a 2D map grid: (Brown cells = wall tiles)

If I click on a tile (that isn't brown), I would like to obtain an array of all the cells in the region that I clicked. (If the region is bounded by brown tiles, otherwise do nothing)

For example, there are two regions in the image above, both colored in grey. If I clicked cell (4,4) I would get a 4x5 array of cells starting at (3,3).

Does anyone know a good performance efficient algorithm for this? I need to account for non-square rooms ideally.


texts:
I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript.

I want to be able to do all of the graphics with SVG and need joystick input. I also need the libraries I use to be opensource and compatible with the BSD license.

I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG. Also, I'm aware of the previous conversations on this site regarding Qt for SVG game development.

I'm hoping to avoid Qt because of the size and complexity of making it a requirement. Also, Qt does not seem to have joystick input support, which would require that SDL or some other library also be used.

So my question can be summed up as this:

What is the best way to get SVG and joystick support in a 2D C++ library while minimizing dependencies as much as possible (preferably avoiding Qt altogether)?


texts:
I tried to make a game where you can destroy something when you swipe or tap. However, it says NullReferenceException & while the swipe control actually works, the gameobject can't be destroyed.

public class checkUp : MonoBehaviour {
private Swipe swipe;
private UIManager uiManager;

private void Awake()
{
    swipe = GetComponent<Swipe>();
    uiManager = GetComponent<UIManager>();
}

// Update is called once per frame
void Update()
{
    if (swipe.SwipeUp ) //NullReferenceException: Object reference not set to an instance of an object
    {
        Debug.Log("Passed!");
        uiManager.destroyed = true;
        Destroy(gameObject);
    }

Here's the partial code from swipe:

    if (swipeDelta.magnitude > 125)
    {
        //which direction?
        float x = swipeDelta.x;
        float y = swipeDelta.y;
        if (Mathf.Abs(x) > Mathf.Abs(y))
        {
            //left or right
            if (x < 0)
                swipeLeft = true;
            else
                swipeRight = true;
        }
        else
        {
            // Up or down?
            if (y < 0)
                swipeDown = true;
            else
                swipeUp = true;
        }
    }


texts:
I'm thinking about music for my brick breaker game, but I don't know how to choose any.

If I'd make a loop from a few seconds, I think it would get annoying very quickly. I also found some longer length tracks (about 2 minutes), but when this is over, it's going to be repeated anyway, just like when you'd select a new level, you'd have to listen to the same beginning of the song again.

I can't put an hour of music in my application, so what would you recommend I'd do for the music?


texts:
In this question I saw that I was running out of memory in D3DPOOL_DEFAULT in DX9EX. After changing my usage from D3DUSAGE_DYNAMIC to 0 (static usage), everything runs wonderfully with no DX9 error.

At the point in my load process where I would previously get DX9's out of memory error, I now see system memory start to grow. So I assume that the WDDM is managing my textures.

So my question is, am I really seeing memory management here? I read about the WDDM in Copying and Accessing Resource Data (Direct3D 10), but I'm not sure that pertains to DX9EX. Wikipedia says: WDDM drivers allow video memory to be virtuallized and video data to be paged out of video memory into system RAM.


texts: Vulkan vkEnumeratePhysicalDevices Returning Unexpected Device Count

texts:
In the machine I'm running I have two GTX 980 Tis.
When I query the physical device count with vkEnumeratePhysicalDevices it always returns 1 despite having 2 physical discrete graphics cards. When I use vulkaninfo the only device listed is GPU0 which is a DISCRETE_GPU / GTX 980 Ti.

This happens in Windows 10 as well as GNU/Linux 4.5 using Vulkan API 1.0.11 with proprietary Nvidia drivers.

Is this normal behavior and I'm not using the API correctly or is this a bug? I feel like I've made a glaring obvious mistake but I can't find anything in the Vulkan specification about it.

For clarity, this is exactly how I query physical device count:

auto deviceCount = uint32_t{0};
instance.enumeratePhysicalDevices(&deviceCount, nullptr);
// At this point deviceCount is 1

Also, to confirm that the OS sees the cards:

Windows 10:

C:\Users\matt>wmic path win32_VideoController get name
Name
NVIDIA GeForce GTX 980 Ti
NVIDIA GeForce GTX 980 Ti

Linux 4.5:

+------------------------------------------------------+
| NVIDIA-SMI 364.19     Driver Version: 364.19         |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 980 Ti  Off  | 0000:01:00.0      On |                  N/A |
|  0%   56C    P8    34W / 300W |    444MiB /  6140MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 980 Ti  Off  | 0000:02:00.0     Off |                  N/A |
|  0%   43C    P8    25W / 300W |     22MiB /  6143MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+


texts: What is the best way to implement dialogs in an xna game?

texts:
I want to implement some startup dialogs, for selecting game parameters, etc. The obvious (and I suppose naive) choice is to just use windows forms (I'm not really planning on porting this game to anything other than windows). But implementing this seems to be a real pain, i.e. can't use ShowDialog, and if I use Show() I have the question of how to return the result to the main loop.

I was wondering if there's an established way to implement dialogs (radio buttons, combo boxes, text boxes, etc) in XNA (maybe some libraries) or is it just a case of reinventing the wheel each time?

Just looking for some general advice on this issue before I spend too much time thrashing around trying different things.


texts:
I am creating endless running game. I want to zoom camera when player dies to the player. I have tried using camera.FieldOfView, but it does not work. Is there another way to zoom In camera to the object when particular condition becomes true.
Thanks in advance.


texts: Why are changes in one object applied to all objects in a list?

texts:
I've got two List:

BasicModels: As Content has to be loaded at the start of the game I instanciate and load all models into this list.
ModelsOnScreen: Every time when a Model is added to the screen I take the corresponding object out of BasicModels and put it into ModelsOnScreen. At the same time I write the ID of the Model at it's location in ModelsOnScreen.

So the problem is though I change the Id at a specific place in the list, changes are applied to all models in ModelsOnScreen.

 for (int i = 0; i < _game.Models.Length; i++)
        {
            if (assetName == _game.Models[i].name.ToString())
            {
                _game.modelsOnScreen.Add(_game.Models[i]);
                _game.modelsOnScreen[_game.modelsOnScreen.Count - 1].ID = nameCounter;
            }
        }

What could be the problem? My theory is that the Models I put into ModelsOnScreen are only references, no separate instances. If that is so, how could I solve this problem?

Any advice is welcome,

greets BC++


texts:
I have a software that performs volume rendering through a raycasting approach. The actual raycasting shader writes the raycasted volume depth into a framebuffer object, through gl_FragDepth, that I bind before calling the shader.

The problem I have is that I would like to use this depth in another shader that I call later on. I figured out that the only way to do that is to bind the framebuffer once the raycasting has finished, read the depthmap through something like glReadPixels(0, 0, m_winSize.x , m_winSize.y, GL_DEPTH_COMPONENT, GL_FLOAT, pixels); and write it to a 2D texture as usual glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, m_winSize.x, m_winSize.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, pixels) and then pass this 2D texture that contains a simple depth map to the other shader.

However, I am not entirely sure that what I do is the proper way to do this. Is there anyway to pass the framebuffer that I fill up in my raycasting shader to the other shader?


texts: ParticleSystem: Start Color > Random between two Colors, but without interpolation?

texts:
How can I set up a Particle System to use a random Color from a selection of two? I mean choosing one or the other.. not a random Color in-between these two.
I tried to use the option Start Color > Random between two Colors:

but I get interpolated colors:


texts: 2d starship combat, hit chances based on bearing and speed (vector)?

texts:
Thinking about a 2d strategy game, where you move your starships turn by turn and fire guns at each other.

Instead of the traditional approach of "range" lowering hit chances, im thinking about some sort of system that throws vectors at each other to calculate relative bearing and speed to calculate hit chances.

I.e. a fast, small ship is harder to hit than a slow, big chip, but in addition the relative bearing (im thinking: is the target flying straight towards your X/Y = good hitchance, or is it strafing very narrowly, low hitchances depending on speed).

Getting the relative the bearing (angle) on an approaching vessel would be easy using atan2, but how could this be translated it into a hitchance that goes up if the angle is like 330 to 30 degree and goes down if its different (as an example) ?


texts: Where can I find some beginners to learn and work with?

texts:
I am very new to game programming. I am currently studying Java (Android mainly) and I know what it takes to make a game, as well as how to render it via OpenGL. Finding some others at nearly my level I think would motivate me more and give me some experience to working with others. Do you know a good place to find some people?

Thank you in advance!


texts: Why transforming coordinates in dimetric games?

texts: What are the advantages of transforming coords, since you can still render isometric graphs having normal 2D coords?


texts: XNA C# Adding objects to List in another class

texts:
Hi all i started creating this XNA/C# version of Space invaders to get better at xna since i've only been using it for about 4 days.

I've managed fine till now..

So my problem is adding my Bullets to a List in another class.
So i've tried working out the solution for about 3 hours now and i hope you guys can help me.

In the Player.cs class i've got a method FireBullet() wich should create a new Bullet.cs class and add it to the list in Game1.cs (it does not do this when you debug) in theory this should work(i think).

Linking all the corresponding classes will take too much room so i've uploaded it to github

https://github.com/Breinss/Space-Invaders-XNA-C-

says C in title ran out of character ment to be C# ^^

Thanks in advanced!


texts: How can I make the code run only once when I release the key?

texts:
Im making a game in LWJGL 2 and Slick2d. Im trying to add an item to my inventory by releasing a key (the inventory system works properly, the part where I have to see if the button was RELEASED is difficult). Right now when I do...

if (Keyboard.getEventKey() == Keyboard.KEY_L) {
    if(Keyboard.getEventKeyState() == false){
        Inventory.addItem(1);
    }
}

... In my update method, Instead of it only calling the 2nd if statement once, ( because you can only release a key once) It just keeps going because the getEventKeyState variable stays false, but if Ive already released it once it should switch back to the opposite. Although I can do it by making it add an item when i hold the key, I cant exactly make it add only the 1 item, it keeps adding items while I hold it.

public static void addItem(int id){
    for(InventorySlot s : inventoryslots){
        if(s.getItem() == -1){
            s.setItem(id);
            System.out.println("Added item " + id + "!");
            break;
        }
    }
}

Thats the addItem method, and if I would approach this by making it add the item while holding, I would have to make it so that it adds it only once. Any suggestions please? Thank you


texts: Player moving back and forth when moving with camera LIBGDX

texts:
I have a problem. When in libGDX my player moves across the screen and the camera is moving after him the player jumps back and forth a bit. Player still moves forward but it looks goofy

I'm moving left-up

package com.qookie.miner;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx.*;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.audio.*;
import com.badlogic.gdx.Input.Keys;

public class MinerMain extends ApplicationAdapter {
SpriteBatch batch;
SpriteBatch b;
private OrthographicCamera camera;
private float timer;
private int rand;
Texture img;
Texture map;
FreeTypeFontGenerator generator;
FreeTypeFontParameter parameter;
BitmapFont font;
private int speed = 250;
GameObject player;

@Override
public void create () {
    batch = new SpriteBatch();
    b = new SpriteBatch();
    img = new Texture("images/player.png ");
    map = new Texture("map1_fixed.png");
    generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/VCR_OSD_MONO_1.001.ttf"));
    parameter = new FreeTypeFontParameter();
    parameter.size = 10;
    parameter.color = Color.WHITE;
    font =  generator.generateFont(parameter);
    generator.dispose();
    player = new GameObject(img);
    camera = new OrthographicCamera(800,480);

}

@Override
public void render () {
    update();
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //Normal rendering(map, player, objects, enemies)
    batch.begin();
        batch.draw(map,0,0);
        batch.draw(player.getTexture(),player.x,player.y);
    batch.end();

    // GUI rendering(always in the same spot on the screen)
    b.begin();
        font.draw(b,"0_01a",4,476);
    b.end();
}

public void update() {
    //batch.setProjectionMatrix(camera.combined);
    //camera.position.set(player.x+player.width/2,player.y+player.height/2,0);
    //camera.update();
    if(Gdx.input.isKeyPressed(Keys.W)){
        player.y += speed * Gdx.graphics.getDeltaTime();
    }

    if(Gdx.input.isKeyPressed(Keys.A)){
        player.x -= speed * Gdx.graphics.getDeltaTime();
    }

    if(Gdx.input.isKeyPressed(Keys.S)){
        player.y -= speed * Gdx.graphics.getDeltaTime();
    }

    if(Gdx.input.isKeyPressed(Keys.D)){
        player.x += speed * Gdx.graphics.getDeltaTime();
    }

    if(Gdx.input.isKeyPressed(Keys.ESCAPE)){
        Gdx.app.exit();
    }

    timer += Gdx.graphics.getDeltaTime();

    rand = MathUtils.random(10);
    batch.setProjectionMatrix(camera.combined);
    camera.position.set(player.x+player.width/2,player.y+player.height/2,0);
    camera.update();
}
@Override
public void dispose() {
    font.dispose();
    batch.dispose();
    img.dispose();
    b.dispose();
}
}

GameObject.java file:

package com.qookie.miner;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.math.*;

public class GameObject extends Rectangle {
private Texture txt;
public Texture getTexture() {
return txt;
}
public GameObject(Texture t) {
this.txt = t;
this.width = t.getWidth(); this.height = t.getWidth();
  }

}


texts: How many choices for attacks should a player be given?

texts:
If you remember the old Fallout 1 + 2 games, there you could select where to shoot/hit the enemy. But of all the choices, only chest or head made sense. Chest to maximize hit probability or, if a hit was almost certain, head for maximum damage. But one could also choose limbs etc.
In other games you can often attack with a standard attack or a variety of special attacks. Most of the time only one or two of them make sense.
I, as a programmer, always analyse a game for best strategy and "bang for the buck" so i naturally don't want to implement useless or silly choices in a game. But if i break it down to what really matters, i could write a bot that plays most games for me as many games are that simple.
Let's assume it is NOT possible to have several choices of equal value. How many choices should i present to a player with one or two being effective and several others being "duds" ?!
If i exaggerate this issue then you could make Fallout 1 a game where you move your character and click an enemy and thats it, best hit location is determined by the game as it mostly is obvious. But that removes the "i have options" feeling, i assume.
I am really somewhat lost with this.


texts: How to prevent Unity from triangulating faces of imported models?

texts:
I have an object that will be rendered with a wireframe shader. This means that line between vertices in a model would be drawn.

The problem is that Unity automatically triangulates all n-gons in my models. I want these n-gons to render as is.

Is there a way to prevent this?


texts:
I have a Box2D body which plays the role of the ground, and PolygonRegion, to give the body a texture. I want to texture repeat inside the PolygonRegion, to fill the whole body with a small image. However, there is a problem: the texture which I use stretches up, inside the PolygonRegion. Maybe it happens because the texture greater than the body.

How do I scale a texture within the inside of a PolygonRegion?


texts: Should we avoid a padding of transparent pixels around an image when creating Assets to be used in 3D Space?

texts:
Assuming we are creating Assets to be used on iOS in order to create textures that are then mapped to the surface of Quads in 3D Space, is below recommendation and its reasoning appropriate?

  Try to avoid unnecessary* transparent pixels whilst ensuring a Power of
  2 texture size.

  Since the texture will occupy the same amount of RAM
  whether it has its content spread across its entire surface or not,
  try to use as much of the available surface for the content as
  possible. This will improve visual quality when downsizing the texture
  (e.g. to generate Mipmaps).

  Example (for illustrative purposes,
  transparency is represented by a Gray color):

  *e.g.: a padding of transparent pixels around an image could be considered unnecessary if the texture will be resized anyway.


texts: How do I create a Dynamic Text Button AS3?

texts:
I am having difficulties creating a button that has Dynamic text in it for my interactive quiz game.

The text on the button has to change to show a selectable answer based off of what the current question is.

I have this all working well with plain dynamic text fields (and multidimensional arrays) but when  I try getting it to work in a button, flash doesn't recognize the textfield that I placed in the button and I get an error.

After doing some googleing I learned that it is normal for flash to not link to a textfield within a button movieclip.

I would be happy if there any strategies that you could suggest for me to achieve Dynamic Text Buttons.

Thanks!
Graeme


texts: JOGL runs extremely slow from a jar file on other machines.

texts:
I am currently messing around with JOGL and JBullet, with some success. I'd like to share what I've created with my friends. I created a jar file and a .bat to open it with the argument -Dsun.java2d.noddraw=true. The jar runs perfectly on my machine. It opens and runs on my friends system and my laptop, but at an extremely low frame rate. What is the cause of this and how can I fix it?

Also for some reason it loads the wrong textures for an object, again only when ran on another system. They are both Windows 8.1 x64 systems. The graphics drivers of all systems are up to date as well. This is really disconcerting because i want to be able to distribute this program, even if only amongst friends. .


texts: How can I implement smooth digging effects in a tile-based game?

texts:
I'm trying to make a Dig Dug styled game where you will be digging into a material. This is going to be a tile-based HTML5 game and I have decided to use the Phaser framework.

One way to do the digging mechanic is to break the play area into tiles and remove tiles as the player sprite collides. But I would like to have a smooth digging animation/physics, so it appears that the player character "carves" out the soil as it digs through. Any tips on how I should do this? Right now I have 15x15px tiles while the player is 45x45px, this sort-of fakes the smooth digging I want. Is there a better way?


texts: How can I tile Perlin noise to more accurately represent a world map?

texts:
I'm currently working on my game.
I would like to generate the world map with Perlin noise, and wrap it just like a real world map.
I've found a algorithm to create a map wrapped along X and Y axis:

Procedurally Generating Wrapping World Maps

The problem is that this map have no linear equator and poles. If you cross the north pole, you will end up in the south. A realistic map should be like this:

So when you cross the north pole you end up at the opposite longitude. So when you get an arial view of this flat map, you get something like this:

The problem is that I don't know how to generate a perlin noise that repeat itself like this. In the website I linked, they use a 4D Perlin noise. But I still can't figure out how to use it for my case.
Here is the code used in the link:

for (var x = 0; x < Width; x++) {
    for (var y = 0; y < Height; y++) {

        // Noise range
        float x1 = 0, x2 = 2;
        float y1 = 0, y2 = 2;
        float dx = x2 - x1;
        float dy = y2 - y1;

        // Sample noise at smaller intervals
        float s = x / (float)Width;
        float t = y / (float)Height;

        // Calculate our 4D coordinates
        float nx = x1 + Mathf.Cos (s*2*Mathf.PI) * dx/(2*Mathf.PI);
        float ny = y1 + Mathf.Cos (t*2*Mathf.PI) * dy/(2*Mathf.PI);
        float nz = x1 + Mathf.Sin (s*2*Mathf.PI) * dx/(2*Mathf.PI);
        float nw = y1 + Mathf.Sin (t*2*Mathf.PI) * dy/(2*Mathf.PI);

        float heightValue = (float)HeightMap.Get (nx, ny, nz, nw);

        mapData.Data[x,y] = heightValue;
    }
}

I'm currently using spherical coordinates, but the map is distorded at the poles.


texts: How to change the geometry of the scene in Unity?

texts: I'm trying to experiment with 3D spherical geometry in Unity, but it seems like Unity objects are inherently set in flat space. My first idea was to create a class inheriting from Transform that would override most of the methods, but I discovered that the transform member of a game object is read only so I cannot replace it with my custom class. I know this sort of thing is possible because the game Hyperbolica is being built in Unity using curved space. I have the math all figured out, I'm just not experienced with Unity. Anyone have other ideas for things I could try?


texts: How to generate a RGB * a texture for a glow effect in GLSL?

texts:
I would like to create a glow effect in GLSL, there is a tutorial that explains how we multiply RGB * a :

I have some questions :

is it an operation that is in a fragment shader, where RGBa is calculated each frame, and then we apply the blur at the end of the shader? The whole process in the same shader, called each frame? Or can we multiply RGBa in a separate process at the beginning of the game and send this texture to the fragment that will blur the result?

I have tried to translate the informations I found, but I am a beginner with the shaders, could someone put me on the right track here? Should we use a "buffer"? Here is my starting code :

GLuint CreateBufferForMixAB() {

    unsigned char * data;
    GLuint bindingPoint = 1, mixTex, buffer;

    glGenTextures( 1, &mixTex );
    glBindTexture( GL_TEXTURE_2D, mixTex );
    data = (unsigned char *)malloc( width * height );
    ...imageTex.rgb * alphaTex.rgb...

    glGenBuffers(1, &buffer);
    glBindBuffer(GL_UNIFORM_BUFFER, buffer);
    glBufferData(GL_UNIFORM_BUFFER, sizeof(mixTex), mixTex, GL_DYNAMIC_DRAW);
    glBindBufferBase(GL_UNIFORM_BUFFER, bindingPoint, buffer);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
    GL_UNSIGNED_BYTE, data);

}

Thanks


texts: How can I get the texture color data from GLEED2D's level file?

texts:
I've hit a little snag in my game. It's a 2D platform game and I need to check for collisions against the level. I'm using GLEED2D to create the map.
I'd like to do per-pixel collision checking, but I don't know how to get the texture color values out of the Level.cs file provided by GLEED2D.
If any one can point me in the right direction that be great -- or if they're are any better level mapping programs with similar features as GLEED2D that would be better to use for this type of game, that would be helpful as well.


texts:
I think I am almost there, but not quite. I am trying to transform a 2D point, (in the following example (100,100)) into 3D world coordinates, in order to draw my 3D Model named TestModel in XNA/Monogame. Here is my attempt:

Matrix[] transforms = new Matrix[TestModel.Bones.Count];
TestModel.CopyAbsoluteBoneTransformsTo(transforms);
ModelMesh mesh = TestModel.Meshes[0];
BasicEffect effect = (BasicEffect)mesh.Effects[0];
float Scale = 1.2f;

effect.View = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 6115.0f),
     Vector3.Zero, Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
    aspectRatio, 1.0f, 10000.0f);
effect.EnableDefaultLighting();

//here i am using the function to calculate the world coordinates from (100,100) Point
//it gives me modelPosition = {X:284,0316 Y:384,2054 Z:0,9999364} in this example
Vector3 modelPosition = graphics.GraphicsDevice.Viewport.Project(new Vector3(100, 100, 1),
   effect.Projection, effect.View, Matrix.Identity);

effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateScale(Scale) *
   Matrix.CreateTranslation(modelPosition);

//finally i draw the model
mesh.Draw();

I suppose this is the correct function to do it graphics.GraphicsDevice.Viewport.Project, so what exactly am I missing here ? Right now the model is drawn around (393, 444) in the 2D world (instead of (100,100) which is where i am trying to draw it)

Edit: I had wrong numbers before
Edit2: I think the correct function is Unproject, but i still can't get it drawn at (100,100)


texts: Include Box2D libraries to a cocos2d project (iOS)

texts:
I have a problem including box2D to my cocos2d project. I've tried different ways to do it with no success. This is what I've done:

I downloaded Box2D (Box2D_v2.2.1) to my project directory.
Dragged the Box2D directory (which includes -> /Box2D.h, /Collision, /Common, /Dynamics, /Rope) to my Xcode project (from Finder to Xcode)
Then I added #include "Box2D.h" to my .h file and got many errors... Here is where I started my research :P
I went to Project Settings and edited the attribute Header Search Paths (contained in the Search Paths section) specifying the path of Box2D. At this point, I builded the project and I got less errors.
After that, I renamed my .m file to .mm (I think this is because Box2D is written in C++ and with this, the compiler can treat it as it is). Still got errors.
Then I tried changing the attribute Always Search User Paths
(contained in Project Settings -> Search Paths) from YES to
NO. Still got errors.
As my last option I tried changing the attribute Compile Sources
As (contained in Project Settings -> LLVM GCC 4.2 - Language) from
According to File Type to Objective-C++.

By now I'm frustrated xD. I have 203 errors and most of them are in the .h files contained in the Box2d engine.

b2Timer.h - Expected '=', ',', ';', 'asm' or 'attribute' before 'b2Timer'

b2Distance.h - Expected specifier-qualifier-list before 'b2DistanceProxy'

b2Math.h - Cfloat: No such file or directory

And so on...

Thanks!!!


texts: How to get android permission call back in unity

texts:
I am using unity run time permission system and when i ask for specific permission at run time using this:

  Permission.RequestUserPermission("android.permission.WRITE_EXTERNAL_STORAGE");

then permission show up.

But now i want get permission callback that has user give the permission or not.
I know that i can check for it using this:

  Permission.HasUserAuthorizedPermission("android.permission.WRITE_EXTERNAL_STORAGE")

But i want some thing more convenient then this.


texts: Box2D Raycast - Getting position / angle of edge hit

texts:
I'm casting a ray in Box2D using b2World.rayCast how can I get the normal of the wall which was hit? Or better yet - the line start and end points?

The information returned is:
Fixture (fixture hit, and parent body)
Point ( Location of hit )
Normal (Normal pointing at new direction of ray - not the normal of the edge hit)
Fraction (0.0 - 1.0) of the point location along the array

However lets say I wanted to place something along the edge hit, previously I just iterated through the segments and did a line intersection test. However if the body is rotated this does not work.

How can I retrieve the line/edge information for the edge the ray hits with. For example, if i wanted to place texture along the wall or some kind of decal.


texts: IK bones stretching vertices to ground during animation (UE4, 3DS Max, using default skeleton)

texts:
I modified the 3rd person example skeletal mesh to a simplistic model in 3DS Max 2016 student edition, by deleting all but one faces and building thereon, thus leaving the hierarchy just as it is needed to re-import to UE4 without any changes and without touching the skin modifier.

In Unreal, the problem appears upon animation, where a vertex from each hand, and one from each foot, is stretched to the ground, and in Persona I see that it's the ik_hand_l and ik_hand_gun bones, as well as the two IKs of the feet, though due to overlapping names I can't make out the entire bone name.

Another issue I successfully dealt with was the model flickering, as suggested I deleted the physics asset and that was corrected, it seems to be a frequent problem so I don't think it's particularly related.

Here is the related post in the Unreal Engine forums with an image of the problem.


texts:
I was trying to implement the marching cubes and combine every little cube this way:

I get a cube of vertices depending on their surfaceLevel
I look for the ones that are below the surfaceLevel and get the edges that relates to them
get a vertice out of the edge using the formula on: http://paulbourke.net/geometry/polygonise/
I put every vertex i created based on the edges on mesh.vertices
I make the order on mesh.triangles based of the edge number on triTable
i combine everything
but i get this:

Here's my code: https://pastebin.com/jqetCk8r.
My guess was that the combine order of every marched little cube is not good.
I've got no idea know how to solve this.
ps: the triTable doesn't show in the pastebin, i copied it from the same link above.


texts: Removing Hinge Joint from script doesn't work

texts:
I'm facing serious problem with handling hinge joints dynamically in Unity.

I made bunch of chains and they are all linked for make something like "sealed door".

When I remove HingeJoint component at the runtime from Inspector, chains were unlinked and everything works fine.

But when I try same thing in the script, sometimes it works and sometimes not(And most of time doesn't work). And some condition just doesn't work.

There are two chain links so I need to remove two hinge joints, one named chain1 and one named chain2.

This is the code what am I tried:

Destroy(chain1.GetComponent<HingeJoint>());
Destroy(chain2.GetComponent<HingeJoint>());

Above code is just remove hinge joints but it doesn't worked always. So I added some delays:

IEnumerator RemoveHingeAfterTime(float delay, Rigidbody chainRB) {
    yield return new WaitForSeconds(delay);
    Destroy(chainRB.GetComponent<HingeJoint>());
}

...

StartCoroutine(RemoveHingeAfterTime(0.1f, chain1.GetComponent<Rigidbody>()));
StartCoroutine(RemoveHingeAfterTime(0.2f, chain2.GetComponent<Rigidbody>()));

Above code is just quite random, sometimes work sometimes not. Especially chain2 almost not works.

I adjusted time to fix this, but nothing works. "yield return null" or "yield return new WaitForFixedUpdate" also doesn't worked.

My doesn't worked means like this:

Also I toggled isKinematics and useGravity with same logic(just hope that physics works) but doesn't worked either.

I'm using Unity 5.6.1f1. Is this glitch? Is there a way to fix this?

Any advice will very appreciate it.


texts: Three points to normal notation (interpret the math)

texts:
From: Euclidian Space: Planes, I see the formula:

  Convert Three points to normal notation

  N = (p1-p0) × (p2 - p0)

  d = -N • p0^2

  where:

  N = normal to plane (not necessarily unit length) d = perpendicular
  distance of plane from origin. p0,p1 and p2 = vertex points x = cross
  product

When calculating the distance to the origin from the plane (d)...
A) how is the p0 squared?
B) how do I resolve the dot product of the vector (-N dot p0^2) to scalar distance?


texts: Unity facebook sdk 'Didn't find class "com.facebook.FacebookContentProvider"' any more fixes / workarounds for this?

texts:
How to replicate this error...

Create a new Unity project.

Import the facebook sdk unitypackage

Set your App Id for facebook via Facebook\Edit Settings

Using Assets\External dependency manager\Android, press 'Resolve dependencies', then press 'delete resolved libraries' (otherwise the build will fail at the gradle stage)

Build and run.

When the app tries to run I immediately get the error message on my phone 'app has stopped working'
and see this error in the logs ...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" on path: DexPathList[[zip file "/data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/base.apk"],nativeLibraryDirectories=[/data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/lib/arm64, /data/app/com.SandwichGeneration.MakeASquare--nLEHpzOYlwW6XKmGzPfIw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]

Suggested fixes I've tried from here

I've tried different combinations of old or new facebook sdks and old or new versions of Unity.

I've tried building from a few different machines to different Android devices.

I've deleted the external dependency manager included with the facebook sdk and used this one instead. In order to get this one to resolve I had to set a 'Custom Gradle Properties Template'in the player setting under publishing settings.

I've set a Custom Proguard file'in the player setting under publishing settings, and I added the following two lines to the file..
-keep class com.facebook.internal.* {*;}
-keep class com.facebook.* {*;}

So I've tried all the suggested fixes and various combinations thereof. I dont know what more I can do. Can anyone suggest anything else to try?


texts: Generate inner polygon from a parent polygon

texts:
I want to produce a polygon inside an arbitrary polygon. The inner polygon shall be distanced from the outer polygon with a fixed distance, d. I will use the inner polygon as a border for player movements, and the player radius will be 2 * d.

If the outer polygon contains sections with width less than 2 * d the inner polygon will not fill that space, or any space on the other side of that passage.

Keeping the distance to the outer polygon means that the inner polygon will form circles, by a number of segments, around sharp vertexes.

How do I generate the red polygon?


texts:
How to paint texture with white color? Example what I mean:

SpriteBatch.setColor changes tint only.


texts: What's the most recommended transmission format using websockets for a MMORPG?

texts:
(note: I'm not asking for the supported formats in the RFC, but the format I should develop to send/receive the messages, say, in the Application layer).

(note 2: Please help me retagging this post to reference internet, communication, client-server messages).

I am developing a game. Right now it is just a concept of a multiplayer game, tile-mapped, with role-playing characters.

The big problem here? It will be online-massive. My concerns are about lag and transmission. The front-end will be pure ActionScript3. The connection will be done with websockets.

Certain actions will be really quick like: walk, grab (item) and perhaps hit (attack) or execute another type of quick action (e.g. use a small, quick, item).

Considering that websockets are not plain sockets, and this is my first online game, my question is about the protocol to use.

Right now, I marshall the messages in the following format (this is just an example, since I did not develop the actual commands yet):

client ---> {'code': 'walk', 'kwargs': {'direction': 'left'}} ---> server
server ---> {'code': 'walk.ok', 'kwargs': {}} ---> client

As you can see, it is JSON format, sent via websockets. The processing backend is Tornado with Python 2.7. I developed a library to marshal and unmarshal these messages.

Assuming that, as an expected peak (with so much luck), I will have 1000 players mostly walking... will I have performance issues with this protocol I defined? Actually, I'm asking about

I want to avoid lag as much as possible, considering websocket transmission.

What format is more adecquate and performant for MMORPG games client-server communication for these really-quick actions? Actually I never developed one of these games and I'm concerned about the performance.


texts:
I hope you know GL Mathematics (GLM) because I've got a problem, I can not break:

I have a set of Euler Angles and I need to perform smooth interpolation between them. The best way is converting them to Quaternions and applying SLERP alrogirthm.

The issue I have is how to initialize glm::quaternion with Euler Angles, please?

I read GLM Documentation over and over, but I can not find appropriate Quaternion constructor signature, that would take three Euler Angles. The closest one I found is
angleAxis() function, taking angle value and an axis for that angle. Note, please, what I am looking for si a way, how to parse RotX, RotY, RotZ.

For your information, this is the above metnioned angleAxis() function signature:

detail::tquat< valType > angleAxis (valType const &angle, valType const &x, valType const &y, valType const &z)


texts: Why do asymmetric specular highlights appear in a scene with only ambient lighting in Unity?

texts:
I have a scene in Unity (2019.3.0f3 Personal) using the High-Definition Render Pipeline. There are no lights in the scene, and Baked Global Illumination is disabled. The skybox is a GradientSky. By all means, the lighting in the scene should be absolutely uniform, but instead there is a gradient from one side to the other.

This is what the scene looks like:

Though the effect is faint, you can see that the right side of the plane is slightly lighter than the left. The ground shader is HDRP/TesselationLit, and by bringing the Smoothness Remapping to max I can exaggerate this effect, as shown below. This is why I am under the impression the effect is specular in nature.

Interestingly, if I switch the camera to the Isometric mode, the effect disappears:

Finally, the effect appears to occur in world rather than camera space, as shown by the changes in lighting when I rotate my camera in increments of 90 degrees:

What is causing this effect, and how can I disable it?


texts: How to set an exact pitch in Minecraft Java 1.16.1 Resource Pack

texts:
I'm trying to make a resource pack in Minecraft Java 1.16.1. The pack will replace all of the Minecraft sounds with LoZ BotW sounds. The first thing I did was put the BotW pickup sound in place of the pop. I got it to play, and it workd, but...
The only problem is that the pitch alters a bit every time I pick up something. I found what I thought was an answer on the Minecraft wiki, the pitch: 1 tag.
So I did this:
"entity.item.pickup": {
    "sounds": [
      {
        "name": "random/pop",
        "pitch": 1,
      }
    ],
    "subtitle": "subtitles.entity.item.pickup"
  }

I went back into the game and it did not work. It still changed everytime I picked something up. I'm not completely sure that the pitch tag keeps it at that pitch, or it it just puts the base pitch at that, but still changes.
Can you help? You can see the pack here.


texts: Libgdx, tiled map - how to reload layer?

texts:
In the simple platform game I'm making, when player collects coin, its cell is set to null. Is it possible to recover all cells from layer "coins" after player dies? I have tried multiple things but none of them worked :/

Here is part of code responsible for collecting coins:

for (Rectangle coins : coins) {
        TiledMapTileLayer layer_coins = (TiledMapTileLayer)map.getLayers().get("coins");
        if(dotRect.overlaps(coins)){
            layer_coins.setCell((int)coins.x, (int)coins.y, null);
            coinsN++;
            Sounds.playCoin();
        }
    }

But when player dies and re-spawns, there are no coins if he collected them before. I tried reloading the map - it works fine, but loading after every death is unacceptable - it takes a lot of time.

EDIT: Now I have another problem, with loading TiledMapTile to put into cell...

TiledMapTile coinTile;

public void show() {
    TextureRegion mapTexture1Region = new TextureRegion(mapTexture1, 32, 0, 16, 16);
    coinTile.setTextureRegion(mapTexture1Region);
}

It gives me NullPointerException, and I have no idea why :/


texts: Memory strategy for multilayer, tilebased maps

texts:
I am currently developing a 2d mmorpg and am having some memory issues with regards to my tile based map.  The client takes a little while to load and then sits around 1GB ram, because I am loading each tile, for each layer, into memory.  My map is currently 1/3 of its expected size.

My map has multiple layers which are drawn on top of each other - ground, building, and object.  Each of these layers is stored in a separate short[] array.  My question is how can I do this better.

I have thought of some ideas:

Load zones into memory (i.e. 500x500) and when user goes into next zone disgard and load new 500x500
Load zones into memory (i.e. 500x500) and when user goes 250 tiles east disgard 0-250 tiles
Read from filesystem rather than memory

Can anyone give some suggestions and perspectives as to why, which above (or other ideas) work best?

Somes notes/issues I've found:

My game has 1 seamless world map(hard to split to zones)
Users can be teleported by GM/DEVs - but will usually only happen if they are stuck somewhere(potiential issues for storing chunks in memory)
My game is www.KisnardOnline.com for anyone interested.

Thanks anyone/everyone for taking a look and your help.


texts: Stop movement if transform.position.y == 0

texts:
Why does the following code not step the object's movement when its y coordinate reaches zero?

    public GameObject cube;
    private GameObject inst;
    public float speed=5;

    void Start () {
        inst = Instantiate(cube, new Vector3(0, 10.6f, 0),Quaternion.identity);
    }

    void Update () {

        inst.transform.Translate(speed * Vector3.down * Time.deltaTime, Space.World);

        if (inst.transform.position.y == 0)
        {
            speed = 0; //stop moving
        }
    }


texts:
I tried to search something about bird-like animal flight simulation but it looks like everything is spammed with flappy bird 2D questions.

I want to have in my 3D game bird-like animals with realistic flight, for example we have a scene where player attacked by predator birds and he must attack them with gun. When I say bird-like, I mean that animal has wings.

As I understand I need to apply force to bird object to compensate gravity force, but if I do this strictly, it looks very unnatural. So could someone provide good description or maybe links to good articles about such simulation for 3D game?


texts:
I have moved over to Mac for Unity development, and am aware you can still use Windows .dll files in your project. I use NuGet as a secure method of getting specific dlls, and have usually done this on Windows by manually downloading the .nukpg and extracting the .dlls using WinRAR, then putting the dlls in Unity. So far, I have thought of two ways to do this on Mac:

1.) Doing the same thing, but with a WinRAR alternative that can open .nukpg

2.) Using Visual Studio for Mac that has a NuGet interface built in with Unity

Has anyone done this, or found a solution for getting package from NuGet in Unity for Mac?


texts:
Thank you for taking the time to read my question, I will try to keep it as concise as I can.

I am making a 2D-platformer game. I am in the process of programming AI that can intelligently traverse their terrain. AI are able to jump, in a fashion similar to many other 2D-platformers:

When the AI jumps, it is given a fixed initial Y-Velocity.
The AI has a flexible time where it may ignore gravity to give it a variable jump height/air time. (This mimics the way that the player is able to jump, where the player character may jump higher if the player holds down the jump-button longer.)
After this time expires, or the AI "releases the jump button", gravity begins to affect the jump arc. The acceleration rate of gravity is also constant.
The velocity on the X-axis is constant.

Question: How would an AI find the minimum amount of time that it will have to "hold down its jump button" to clear an expanse between a starting jump point, and a desired target?


texts: Follow point of interest by applying torque

texts:
Given a body with an orientation angle and a point of interest or targetAngle, is there an elegant solution for keeping the body oriented towards the point of interest by applying torque or impulses?

I have a naive solution working below, but the effect is pretty 'wobbly', it'll overshoot each time, slowly getting closer to the target angle - an undesirable effect in my case.  I'd like to find a solution that is more intelligent - one that can accelerate to near the target angle then decelerate and stop right at the target angle (or within a small range).

If it helps, I'm using box2d and the body is a rectangle.

def gameloop(dt):
    targetAngle = get_target_angle()
    bodyAngle = get_body_angle()
    deltaAngle = targetAngle - bodyAngle
    if deltaAngle > PI:
        deltaAngle = targetAngle - (bodyAngle + 2.0 * PI)
    if deltaAngle < -PI:
        deltaAngle = targetAngle - (bodyAngle - 2.0 * PI)
    # multiply by 2, for stronger reaction
    deltaAngle = deltaAngle * 2.0;
    body.apply_torque(deltaAngle);

One other thing, when body has no linear velocity, the above solution works ok.  But when the body has some linear velocity, the solution above causes really wonky movement.  Not sure why, but would appreciate any hints as to why that might be.


texts: Creating a custom binary format for 3D meshes

texts: I've seen people saying it's better and faster to use a custom binary format for your 3D models, based on your needs, instead of using exchange formats. But, I'd like to know how to create a basic format, that contains just vertex and index data, how to write this data into a binary file and read it. Much obliged.


texts: I wrote an exporter for blender models that works great for meshes. I'm attempting to extend that to bones defined in blender. However I haven't found good information for exporting bone data. How can I access bone data? I'd like access all the vertices that the bone affects, the weight of each vertex and the matrix. Do I need to export anything else for skeletal animation and dynamic dismemberment?


texts:
I downloaded the FBX of this free model:

http://www.turbosquid.com/FullPreview/Index.cfm/ID/485548

Yet when i try and display it in my project

foreach (ModelMesh mesh in player.Meshes)
{
    foreach (BasicEffect beffect in mesh.Effects)
    {
        beffect.View = view;
        beffect.Projection = projection;
        beffect.EnableDefaultLighting();
    }
    mesh.Draw();
}

I end up with the teeth of the model way out from the body, and the eyes expanded so large they stick out the sides of the model.

Could someone tell me what i am doing wrong? Or is the model the issue?


texts: How do you combine multiple meshes into one in Blender?

texts:
I need to combine multiple meshes into one in Blender 2.8 (Just make them into a single mesh that looks like all of them in their normal positions). I am doing this mostly for performance improvement in my game, since the teeth are all separate.

Does anyone know how to do this?


texts:
I'm a novice programmer but I have completed a pre-university in web prog so I am not a total noob. I'm using Unity, but this is just C# for now.

This is my first big project and I need some professional insight to make sure the design is not flawed. Currently working on abilities in an turn based rpg game.

What you might need to know: Abilities need to be learned/chosen, they may have requirements(levels, weapontype, more/etc.) New abilities will be added to the game with updates.

This is still the primitive stage, but very important to me because this project is more about learning to do it right rather than just getting it done.

Here are the following classes where we create abilities:

public abstract class Ability {
  public readonly int id, multi, manaCost;

 public Ability(int id, int multi, int manaCost) {
   this.id = id;
   this.multi = multi;
   this.manaCost = manaCost;
 }
 public virtual void resolve(Actor user, Actor target){}
 //Would create more methods with different parameters based on different abilities
 //Example for multi target ability
 public virtual void resolve(Actor user, Actor[] targets){}
}

Pretty simple stuff, Actor is just a in-game character. resolve is where the ability effects will be coded

using UnityEngine;
public class Freeze : Ability {
  public Freeze() : base(0, 0, 3) { }

  public override void resolve(Actor user, Actor target) {
    int damage = 2 * user.attribute[2];
    Debug.Log (damage);
    target.damage(damage);

    /*System.Random rnd = new System.Random();
    if(rnd.Next(100) <= 35)
    target.state = new Frozen();*/
  }
}

the way I was planning to use abilities is, in the main script of the battle system
there would be an array that has all the abilities such as this:

Ability[] all_ability;
public void createAbilities(){
    all_ability = new Ability[2]; //size increased as we create more abilities
    all_ability[0] = new Freeze();
    all_ability[1] = new FirstStrike(); //and so on as we create more
}

The index of the array is also the id of the ability which allows us to easily access abilities.

So if an Actor wanted to use freeze, the id of freeze would be stored in Actor i.e. p1.actors[0].ability_ids array

so let's say i've got what ability the player chose, it would be something like this

int aId = p1.actors[i].ability_ids[j]; //would return 0 assuming he chose freeze
all_ability[aId].resolve(p1.actors[i], p2.actors[k]);

Everything works so far, no errors, and damage gets calculated correctly but this is a very simple ability and still much more to add like damage counters, animations, status effects etc.

What should I look out for? is there a much easier way to do this I dont know about? I guess my main concern is, as we learn in web programming, it is said to be very bad to hard code values and everything should come from databases, but, is that also true for a game since each ability can be quite different? As you can see, everything is hard coded here. I guess I just want tips on things I may have done wrong/if there is a clear better way to do this. Thanks for any and all replies!


texts: Inertia in flight simulation using box2d

texts:
I'm trying to simulate flight using box2d and libgdx.

The main problem I am currently experiencing is with inertia: since there is no air, the plane looks like it were drifting.

I wasn't able how to turn off inertia.

I have two ideas:

Imitate air resistance by applying force
Imitate flight using linear velocity without using any box2d physics

Are any of these two ways correct? Or maybe there is way to turn off inertia?


texts: Is there a way to set a range on a case argument in a switch statement in Game Maker: Studio?

texts:
Okay so I am making a tower defense game in GML and I came across a small problem when making a switch statement, I want to have anything from 1-10 to result in a variable changing to 1, anything from 11-20 result in the variable changing to 2, and anything 21-30 to change to 3. It would look something like this. Yes I know I'm new to coding..

switch(test)
{
    case (1-10):
        test = 1;
        break;

    case (11-20):
        test = 2;
        break;

    case (21-30):
        test = 3;
        break;
}

Except for the fact that that does not work and to actually do something like that, in my knowledge you'd have to make a case for every single number in the range which would take ~3 years. Help?


texts: Grid of buttons in Unity - button bounds are stretching beyond their visuals, capturing clicks meant for other buttons

texts:
I am using unity UI for the first time and trying to create a level selection menu just like Angry Birds.

I had successfully created the dynamic level selection menu. It was all good in the inspector but when I build and run it, something strange happens: when I click on the first button of the first row, instead of that button, the last button of that row got clicked.

I searched and found that the image was not stretching (because of preserve aspect property checked) but the bounds were stretching with the resolution so the bounds were overlaping and the wrong button was getting clicked.

There is a panel which is child of the canvas gameObject.
Buttons are child of panel gameObject.
Panel's anchors are set to stretch the canvas.
Buttons' anchors are set to stretch the panel.

Here is the code to create menu dynamically.

public class UITest : MonoBehaviour
{

    public Button button;
    public RectTransform parent;

    void Start()
    {
        SetupButtons();
    }

    void SetupButtons()
    {
        float x = -155;
        float y = 55;

        for(int i=1; i<15; i++)
        {
            var I = i;
            var btn = Instantiate(button) as Button;
            var btnRect = btn.GetComponent<RectTransform>();

            float width = btnRect.rect.width/5;
            float height = btnRect.rect.height/5;

            btn.transform.SetParent(parent, false);
            btnRect.anchoredPosition = new Vector2(x, y);
            btn.onClick.AddListener(() => Temp(btn, I));

            if(i%5 == 0)
            {
                y += (height);
                x = -155f;
            }

            else
            {
                x += -width;
            }

            //Debug.Log(width +", " + height);
        }
    }

    void Temp(Button btn, int i)
    {
        //Debug.Log("Clicked: " + i);
        Debug.Log(btn.GetComponent<RectTransform>().anchoredPosition + " " + btn.GetComponent<RectTransform>().rect);
    }
}

Here are some screenshots to better understand the problem.

I hope you guys have understood the problem please help me solve the problem.


texts: How do you make a single player game into a multiplayer one? For example: SA-MP San Andreas Multiplayer and the new Just Cause 2 Multiplayer. Before making the mod, did they need permission? How did they even know what to code without having the games source code? I have some ideas but I have no idea where to really start.


texts: Can I put real monuments like white house, statue of liberty in my open world game?

texts: I'm currently working on open world game. But I am confused about one thing that, is it ok if I put real monuments and sculptures like white house, statue of liberty etc. in my game? Please help if anyone knows and confident about his/her answer. Thanks in advance!