texts: First Minecraft mod not working: make a new sword

texts:
I am making my first mod and cannot see what is wrong with it. I am using MCP and Modloader.
For my first mod I was going to make swords.

I started with making a new EnumToolMaterials

WOOD(0, 59, 2.0F, 0, 15),
STONE(1, 131, 4.0F, 1, 5),
IRON(2, 250, 6.0F, 2, 14),
LAPIS(3, 750, 7.0F, 2, 14),
OBSIDIAN(3, 1000, 7.5F, 3, 12),
EMERALD(3, 1561, 8.0F, 3, 10),//diamond
GREEN(3, 2000, 9.0F, 4, 10),//emerald
GOLD(0, 200, 12.0F, 0, 22);

then here is the mod class

public class _Mod_Yamiko extends BaseMod{

    /* mod itemts */
    public static final Item swordLapis = (new ItemSword(600, EnumToolMaterial.LAPIS)).setItemName("swordLapis");
    public static final Item swordObsidian = (new ItemSword(601, EnumToolMaterial.OBSIDIAN)).setItemName("swordObsidian");
    public static final Item swordGreen = (new ItemSword(602, EnumToolMaterial.GREEN)).setItemName("swordGreen");

    public void load(){
        //set images
        swordLapis.iconIndex = ModLoader.addOverride("/gui/items.png","/gui/swordLapis.png");

        ModLoader.addName(swordLapis, "Lapis Sword");
        //craft
        ModLoader.addRecipe(new ItemStack(_Mod_Yamiko.swordLapis, 1), new Object[]{
            " X ", " X ", " Y ",
            'X', Block.dirt,
            'Y', Item.stick
        });
    }

    public String getVersion(){
        return "0.1";
    }
}

Then I made a 16×16 .png image. I am not sure where to save it so I recompiled and reobfuscated, took the mod files and put it in my local Minecraft install, added the image where it be should be. No problems when playing but I cannot make the new sword.


texts: Should I develop the game first or get NDA?

texts:
So I have been working on my game for a while now. And I now I have other people contributing to the project. I fear that someone will tell their friends and/or family then my 'great' idea is lost.

So my question is should I wait and get a NDA ( Non Disclosure Agreement) or some other form of legal document that tells everyone one the project or who has ever worked on the project to be quite until its release?


texts:
I've been looking on the net since some time for generating a map for my isometric RTS game. The map should have biomes, humidity, wind directions and etc. But I couldn't find a correct algorithm or enough keywords to search for.

The algorithm used by AmitP in his blog is using Voronoi graphs, but I want a isometric algo without any of that. It could help me if someone clarified what algorithms or what techniques I should be looking for(probably with an example).

EDIT

I have already made some classes for implementing the map's height and all the data. But what I need is an example of using something like say noise or Perlin noise that was told. Most of the data of each cell of a map is in Terrain class. Its a collection of assorted values for a cell of the map. In the Map class there is a MutableList which I sort over through one for loop.

Can anyone give me an example of using Perlin map to generate a heightmap for the Terrain class, i.e., how to use that approach?

class Terrain(posX:Int,posY:Int,elevation:Double):Point(posX,posY,elevation) {
var terrainType: TerrainType? = null
var biomeType: BiomeType? = null
var locationType: LocationType? = null
var location: Location? = null

var score: Double = 0.0
var territory: Int = -1
var temperature: Double = 0.0
var humidity: Double = 0.0
}


texts: Unity is crashing without leaving a message at the start of my "game"

texts:
So. I like to code. I like to play Paradox Interactive games. One thing that I always wondered about was how exactly their implementation of their trigger evaluation/event evaluation system looked like. So I decided I would write myself an implementation and find out!

Now, I didn't want to manually parse their text files out. I could, but it would be an insane waste of time since other people have already developed efficient libraries for it. So I downloaded and set up this nice little library that handles the nasty little details.

I tested the parser to make sure it works. Worked like a charm. Then I started coding. A full day of planning, trial, and error later, I had a very early version ready.

Then I created a C# script with a basic implementation of my new library. I created a basic spherical mesh and dragged it onto my scene. I dragged said C# MonoBehaviour onto my object. I created a country class implementing my 'IScope' interface. I set the "scope chain" up.

I created a text file with the following contents:

trigger = {
    id = 5
    vassal = {
        id = 6
    }
}

It worked in the parser before. I then wrote the following code in my Start method:

void Start()
{
    ScriptBinding.Instance.ReserveTrigger("id", new CheckIDTrigger());
    ScriptBinding.Instance.ReserveScopeName("vassal");
    string path = Application.dataPath + "/ParadoxScriptingEngine/Tests/test_trigger.txt";
    Debug.Log(path);
    FileStream stream = File.OpenRead(path);
    c = new Country(5); //Declared as a class member. Implements IScope.
    tb = new TriggerBlock();
    ParadoxParser.Parse(test_script, tb);
    scope_chain = new IScope[10];
    scope_chain[0] = c; //ROOT
    scope_chain[1] = c; //THIS
}

And in Update:

void Update()
{
    Debug.Log("The trigger has evaluated to " + tb.Eval(scope_chain));
}

When I deactivate the script that launches the parser, the project runs. When I reactivate it and try to run it, the editor instantly crashes.

I have riddled my project with debug statements, but this is just starting to get ridiculous. I have traced through the entire program in my mind, but it is 17 files long all told, and without any data on the error I cannot possibly hope to debug it. The log files are empty as well.

Is there a way to get Unity to print ALL information on errors?

I know that the problem has to be related to my program, so perhaps the better question would be; what kind of problem will cause Unity to not print the error out? I know infinite loops will do it, but there is no way it is an infinite loop is causing this problem - I only used for each loops.


texts:
I'm trying to make a simple 3d tetris game, but I'm having trouble rotating my blocks.
The blocks are made up of 4 cubes (drawn with glutSolidCube()).
I can't figure out how I can rotate them and still have the axes point in the right direction for the cubes' movement.

This is the simplest form of what I've tried that clearly illustrates the problem when I run it

for(int i=0; i<4; i++){
    glPushMatrix();
    glRotatef(90.0, 1,0,0);
    glTranslatef(cubes[i]->xPos, cubes[i]->yPos, cubes[i]->zPos);
    cubes[i]->draw();
    glPopMatrix();
}

And this not only rotates the block, but rotates the whole system in the sense that now, the blocks are rotated in the right direction, but move in from the side rather than the top as if the axes have been rotated as well.
I've tried first translating to the point where they start falling, rotating and translating back, but they still just go sideways. (not included in the sample because the start location isn't the main problem here)

I sort of understand why this happens, but I don't know how to fix it.


texts:
Game Engine : Unity 5.1
Developing on Windows 7

Hello,

I am using Vectrosity to draw some some shapes on screen run time. I also need to fill these shapes and none of them are really trivial shapes. So after doing some research I figured the best way would be to do it by creating a run-time mesh. Now this almost works for me but has a big issue.

This is my process.

1) I have defined my complex shapes as a set of 2D vertices that I extracted from Illustrator. These vertices I feed to the Vectrosity's Catmul spline function to create my shapes.

2) I then project these vertices in the real space using ScreenToWorldPoint to get 3D vertices.

3) I then pass these vertices to a program that Triangulates these points to a mesh (I use the classic Triangulate script on wiki)

4) I then clean up a little and align

Now all this works well if the camera is not rotated and the forward vector of the camera is orthogonal to the XY plane. The moment I rotate the camera the alignment of the mesh and the vector lines is completely gone.

Here is the image of the vectorline and mesh when the camera is not rotated

And here is the image when the camera is rotated

Here is the function that projects the point into 3D space

 void DrawPolygon () {

     Vector2[] tempVerts = new Vector2[allLinePoints.Count];

     for(int i=0; i<allLinePoints.Count; i++) {

         Vector3 projectedPoint = Camera.main.ScreenToWorldPoint(new Vector3(allLinePoints[i].x, allLinePoints[i].y, 10.0f));
         tempVerts[i] = new Vector2(projectedPoint.x, projectedPoint.y);

     }

     polyTarget.SendMessage("Create", tempVerts);
 }

This message is sent to a generic Triangulation script. Here it is

using UnityEngine;
using System.Collections;
using System.Linq;

 public class CreatePolygon : MonoBehaviour {

 public Material meshMaterial;

 public void Create (Vector2[] verts) {

     Triangulator tr = new Triangulator (verts);
     int[] indices = tr.Triangulate ();

     // Create the Vector3 vertices
     Vector3[] vertices = new Vector3[verts.Length];
     for (int i=0; i<vertices.Length; i++) {
         vertices[i] = new Vector3(verts[i].x, verts[i].y, 0);
     }

     // Create the mesh
     Mesh msh = new Mesh();
     msh.vertices = vertices;
     msh.triangles = indices;

     msh.RecalculateNormals();
     msh.RecalculateBounds();

     // Set up game object with mesh;
     gameObject.AddComponent(typeof(MeshRenderer));
     MeshFilter filter = gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter;
     filter.mesh = msh;

     GetComponent<Renderer> ().material = meshMaterial;
     StartCoroutine (FlipNormal ());
 }

 public void ResetMesh (Vector2[] verts) {

     Triangulator tr = new Triangulator (verts);
     int[] indices = tr.Triangulate ();

     // Create the Vector3 vertices
     Vector3[] vertices = new Vector3[verts.Length];
     for (int i=0; i<vertices.Length; i++) {
         vertices[i] = new Vector3(verts[i].x, verts[i].y, 0);
     }

     // Create the mesh
     Mesh msh = new Mesh();
     msh.vertices = vertices;
     msh.triangles = indices;

     msh.RecalculateNormals();
     msh.RecalculateBounds();

     // Set up game object with mesh;
     MeshFilter filter = GetComponent<MeshFilter> ();
     filter.mesh = msh;

     GetComponent<Renderer> ().material = meshMaterial;
     StartCoroutine (FlipNormal ());
 }

 IEnumerator FlipNormal() {

     yield return new WaitForSeconds (0.1f);
     Mesh mesh = (GetComponent<MeshFilter> () as MeshFilter).mesh;
     mesh.uv = mesh.uv.Select(o => new Vector2(1 - o.x, o.y)).ToArray();
     mesh.triangles = mesh.triangles.Reverse().ToArray();

 }
}

Now this seems to be an obvious problem to have but I am just not being able to crack it. I have a feeling the solution is some mathematics that is completely escaping me right now. Can someone please help and point me to the right direction. I need to be able to align the mesh to the outline even when the camera is rotated.


texts:
I need to achieve the effect of a ball falling down into a pool then splashing in the water.

At first, I made a sensor to detect the collision between the ball and the water and then show the sprite of the spray.
But it's hard to change the sprite according to the velocity of the ball and the angle between the ball and pool.
So, I want to simulate the physical model of the water.

Now, what I can do is to add a particle system using Cocos2D to show the still water and add physical model to each particle. But, I don't think it is a good solution.
Any other I can do it? Waiting for you help.


texts: C# Convert List to multidimensional float

texts:
I have a list of Vector3 structs like this

List<Vector3> cloud

I want to convert this list into a 3 dimensional float array

float[,,] points

Where Vector3 is a struct of 3 floats ( x, y, z )

The points array should be a 3 dimensional float array containing each

float[Vector3.X, Vector3.Y, Vector3.Z]

in the cloud list. Thank you for your help.


texts:
I have enough experience in both C++ and Java, since I've been working on them a lot. My graduation project is, in my case, a game (I still have almost 8 months remaining). I already took down the basic ideas behind it, but I'm still unsettled on how to implement the whole project. The best method, in my opinion, was to perform low level operations such as window handling and OpenGL rendering using libraries implemented by me in C++ and more game-oriented features with Java.

So, basically I'm headed to create the game engine with C++ and any game related code with Java, through the use of the Java Native Interface to perform engine calls from the JVM. Can this be considered a good idea or it is that bad?


texts: Read custom content in MONO-GAME in a cross-platform way

texts:
using Mono-Game,

i have some custom content files in some binary format (not .xnb)
in run-time i need to read the content of those files.
i prefer to get a stream, but if something will give me a filled byte[] or something,
that's also fine..
this must be cross-platform as much as possible and work on PC \ Mobile \ consoles \ web \ what-ever-mono-game-offers

;

my efforts so far :

ContentManager.Load() does not read custom formats
subclassing ContentManager, and overriding OpenStream(string assetName) did not help - it expects the file i give it to end with .xnb
renaming all files to ".xnb" just for this is not possible for me, because some other proccess reads thease files and expects them the way they are
TitleContainer.OpenStream() seems to read files from the file system,
but im not sure how they will be packed when building for mobile devices for example.

(i know that in unity: for android, content is simply copied to a folder on the device,
but on iphone all content is packed to a binary package.. so reading from the file-system will not work)

(i dont have an iphone\ipad to test this on)
the simple "File.ReadAllBytes()" is no good for the same reason

;

My questions are :

am i right about TitleContainer's cross-platform limitation ?
what can i do ?

thanks.


texts: transfer 3d model processing from Xna to Android?

texts: I developed an XNA scenario in a desktop application and I need to make the same scenario in an Android app so I need to process data on the desktop computer and just display it in Android app using socket programming. For now, I can just transfer text from my desktop app to the android app, but how can I transfer a 3D model from XNA to Android? The model format is FBX.


texts: How to do draw a "visibility polygon" in 2D top-down Unity?

texts:
I've made a very simple 2D top down prototype with Unity. Now I want to expand the thing and add a feature where objects change when the player looks at them.

So I have to add a visibility polygon feature. I want to be able to get a list of objects (2d Colliders) which are in the Field of view of the player.

How I can do that?

I looked around and only found a tutorial which works with Physics2D.Raycast, but this seems to be only one ray as I need a field of view. Similar to the light of a flashlight.

I've drawn a sketch to illustrate my question:

In this case the list should contain the collider V1, V2 and V3 because the player can see them.

Edit:

I experimented with the sending a "fan" of Raycasts every 0,1 ° but this solution does have some problems. The accuracy depends on how far the collider is away. Also this is not the best performing solution. And there are problems with small objects.
As solutions like this: https://www.redblobgames.com/articles/visibility/ seems to be a lot of work just to reinvent something which is already out there I wonder if there is a built-in way in unity to help me to compute this area.


texts:
Please see attached screenshot.

Here's how it works.

A is a slider that goes up and down, and the red line uses the centre point of the A slider to draw its start point.

B is another slider, but this goes left and right (stops in the middle as shown below).

The current issue is, the red line should always rest on top of B like a see-saw. Currently the line's end point has a fixed x position so it is always in line with the green crosses below to the right. But I need to position the end Y point of the line correctly so that the line as a whole is resting on top of B at all times. Whether the user slides A or B.

My guess is I need to work out some form of distance calculation with angles. I have something along the lines of:

Called 60fps:

this.startPoint.x = this.verticalSliderModel.xPos;
this.startPoint.y = this.verticalSliderModel.yPos;
this.endPoint.x = 653;
this.endPoint.y = this.horizontalSliderModel.yPos;

var angle = Phaser.Math.angleBetween(this.startPoint.x, this.startPoint.y, this.endPoint.x, this.endPoint.y);

this.seeSawController.updateModel(this.startPoint, this.endPoint, angle, width);
this.seeSawController.updateView();

I then use html canvas to draw the line:

update(start:Point, end:Point, angle:number, width:number) {

    this.bmd.clear();
    this.bmd.ctx.beginPath();
    this.bmd.ctx.moveTo(start.x, start.y);
    this.bmd.ctx.lineTo(end.x, end.y);
    this.bmd.ctx.lineWidth = 4;
    this.bmd.ctx.stroke();
    this.bmd.ctx.closePath();
    this.bmd.render();
}

So yeah I want to calculate the green cross plot points moving forward.


texts: Workflow for authoring Pokémon-like game database content

texts:
I'm programming on a game that relies on a database for a lot of the creatures and items in the game (think Pokémon).
Currently, we have a Google Sheet that the designers are making. They will be using it to populate all of the items necessary for the game, so it acts as a 'source of truth'. However, to translate this into the database (SQLite) we'll need to write some code to pull the data, format it and put it into the database. The maintenance of this will also be pretty annoying, as we already need to maintain the database schema and the code representation (Unity C#). DB tables are can be static or dynamic, and the implementation on the Unity side for the DB is not an issue.
Before writing this code I'm exploring other options. I've looked into Microsoft Access (and similar programs) but they seem to be geared towards making applications now and don't have much in the way of SQLite integration.
I'm leaning towards using a visualizer tool like DB Browser for SQLite or SQLiteStudio, but the lack of cloud syncing might mean a janky solution with Google Drive or AWS.
I'm looking for a workflow that:

will be accessible for game designers (who have little to no SQL experience, but willing to learn)
will keep changes between designers synced
will be easy to manage and maintain for the codebase and SQLite database.

How can we solve this problem?


texts: Why do I get compile errors in every project, even new ones, and how do I fix them?

texts:
I downloaded the latest version of Unity as you can see in the snap.

I just created a new project and when I press the play button it shows compile error even if I have not created anything nor any script. I receive 4 blank errors in Unity and one non critical. I am not able to clear them except the non critical one.


texts: Unity3D - override main camera rendering for compositing effect

texts:
I'm fairly new to Unity and am having a bit of trouble understanding the rendering pipeline.

I need to render the scene to four "windows," so that the viewport shows a 2x2 grid of the scene, each with a slightly different projection matrix.

My first thought was to have a component that would create four RenderTextures, and, in OnPreRender(), iterate through them, setting the main camera's targetTexture property to each texture in turn and rendering the camera's view to that texture:

(Pseudocode)

public class CompositiongEffect : MonoBehaviour
{
    private Material m_material;
    private List<RenderTexture> m_textures;

    void OnEnable()
    {
        if (null == m_textures)
        {
            m_textures = new List<RenderTexture>();

            for (var i = 0; i < 4; ++i)
            {
                m_textures.Add(new RenderTexture(512, 512, 24));
            }
        }

        if (null == m_material)
        {
            m_material = new Material(Shader.Find("Custom/CompositingEffectShader"));
        }

    }

    void OnPreRender()
    {
        var cam = Camera.current;

        foreach (var texture in m_textures)
        {
            /// adjust cam projection matrix here...

            cam.targetTexture = texture;
            cam.Render();
        }
    }

    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Debug.Assert(
            null != m_material
            && null != m_textures
            && m_textures.Count == 4, "Texture list not initialized"
            );

        for(var i = 0; i < m_textures.Count; ++i)
        {
            var x = i % 2;
            var y = i / 2;

            var uniformName = string.Format("Texture{0}{1}", x, y);

            m_material.SetTexture(name, m_textures[i]);
        }

        Graphics.Blit(source, destination, m_material);
    }

}

The Image Effect m_material would then draw the 2x2 grid to the frame buffer in a single pass.

Is this a good approach? I suspect (perhaps incorrectly) that using an image effect for the last step would actually cause an additional scene render that never gets used.

The reason for this is the signature for OnRenderImage()

void OnRenderImage(RenderTexture source, RenderTexture destination)

implies that source is already a valid image when this is called. That image has to come from somewhere, and it seems that it would contain the full-resolution rendered scene already. Since I am already rendering the scene in the previous step, I'd like to avoid this additional render.

Am I interpreting the pipeline correctly? If so, how can I address this?

Thanks!

Edit

Can I disable the main camera, then do everything manually in my component as mentioned above? If the camera is disabled, to what should I attach my component? Perhaps the camera's parent gameObject?


texts: Can't draw lines in 2D space with GLFW and OpenGL

texts:
I'm trying to draw a grid in 2D space using GLFW and OpenGL but for some reason I only get this on the screen:

Here's my code:

#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

const int gridSize = 32;

const int SCREEN_WIDTH = gridSize*32;
const int SCREEN_HEIGHT = gridSize*16;

static void inputK(GLFWwindow* window, int key, int scancode, int action, int mods){
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE);
}

static void error_callback(int error, const char* description){
    fputs(description, stderr);
}

int main(void){
    GLFWwindow* window;
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(EXIT_FAILURE);
    window = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "MSSIN_no", NULL, NULL);
    if (!window){
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);
    glfwSetKeyCallback(window, inputK);

    while (!glfwWindowShouldClose(window)){
        float ratio;
        int width, height;
        glfwGetFramebufferSize(window, &width, &height);
        ratio = width / (float) height;
        glViewport(0, 0, width, height);
        glClear(GL_COLOR_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();

        glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

    //attempt to draw lines
    glBegin(GL_LINES);
    //horizontal
    for (int i = 0; i < SCREEN_HEIGHT; i+=gridSize){
        glVertex2f(0, i);
        glVertex2f(SCREEN_WIDTH,i);
    }
    //vertical
    for (int i = 0; i < SCREEN_WIDTH; i += gridSize){
        glVertex2f(i,0);
        glVertex2f(i, SCREEN_HEIGHT);
    }
    glEnd();

    glfwSwapBuffers(window);
    glfwPollEvents();

    }

    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}


texts: How many threads should an Android game use?

texts:
At minimum, an OpenGL Android game has a UI thread and a Renderer thread created by GLSurfaceView.  Renderer.onDrawFrame() should be doing a minimum of work to get the higest FPS.  The physics, AI, etc. don't need to run every frame, so we can put those in another thread.  Now we have:

Renderer thread - Update animations and draw polys
Game thread - Logic & periodic physics, AI, etc. updates
UI thread - Android UI interaction only

Since you don't ever want to block the UI thread, I run one more thread for the game logic.  Maybe that's not necessary though?  Is there ever a reason to run game logic in the renderer thread?


texts:
I'm pretty new to game development, having only written a simple 3d game for a class project, but I'd like to get started on a bigger project.

I'm writing an MMORPG to run in both the browser (WebGL) and natively (OpenGL ES 2). In choosing a GUI toolkit, I'm trying to find a style that work work natively and would be simple to emulate in WebGL.

I am considering using D or Go for writing my game, so interfacing with C++ libraries will be difficult, if not impossible. Of course, the language isn't the end goal here, so if using C++ will save considerable time, I'll bite the bullet and use that.

In order to reduce the amount of code I'll have to write for the browser, I'm considering using something simple like Clutter for basic abstractions, which I think will be pretty easy to emulate (layered canvases maybe?).

Does anyone have experience using Clutter for a 3d game?

Note:

I haven't used any game development libraries, and I only have limited experience with GUI libraries. I do have HTML+CSS experience, so maybe librocket is a viable solution?

Edit:

I'm also trying to be cross platform, so Linux/Mac/Windows.


texts: Changing the 3D model of the Unity ARkit face tracking demo

texts:
I was able to get the Unity ARkit face tracking demo working with an iPhone X to animate a face model in realtime:

I then tried to get it to work with my own 3D model, and imported the FBX file with the same blendshapes (though each blendshape has a different name from the original sloth model).  By using the hierarchy, ARFaceAnchorManager, and changing the Anchor Prefab I was able to select the model to use:

The problem is:

the rendered model is flipped along the z axis (it faces away from the camera, as shown below).  I've tried to apply a 180 degree rotation to the model in Unity's transform window, but it doesn't seem to do anything.
I'm unsure how to map the blendshapes coming from the iPhone app to the blendshapes in the FBX model - where is that done?  I couldn't find code that references these blendshapes.


texts: Turn-based combat AI with multi turn planning

texts:
My current AI system uses the now very common utility AI. I generate a list of possible actions, I then calculate fitness score for each action and generate a list of possible chains of actions (Move > Attack > Reload or Use Offensive Ability > Leap backwards). The sum of those scores are then sorted and I pick the most (or not, depending on how smart I want the particular AI player to be) appropriate chain to execute.

The issue that I've run into though is that I'm having issues with more complex interactions that require multi-turn planning. To give an actual example: one of my characters got two spells that can deal massive damage when used in the right order.

1) A buff ability that increases target's Mind attribute (cast on self)

2) A powerful spell that deals damage based on your Mind (cast on the enemy)

Both of those actions cost a lot of Action Points and so you can't execute them both in one turn. A very obvious combo is to use the buff and then the damage spell, but if both of those actions are available to the AI, then it always chooses to open with the second action. The buff itself, when considered in isolation, produces a very low fitness score.

A very obvious idea is to then to allow the AI to build chains of actions for two or even three turns ahead. However, this greatly increases the performance cost as I'd have to use similar heuristics for other players to get at least somewhat reasonable gamestate for the AI to go off of. I would also have to think of a fail-safe mechanic for when the player does something unexpected, thus ruining this long-term plan.

Another idea that I had is to let the designer define interesting combos and have the AI see if it can execute one, but it feels messy and a bit hard to implement with the current generic system.

How do the other games do it?


texts:
i know how to load text, but idk how to load texture from json..

this my c#:

 public void soalbegin(){
     filepath = System.IO.Path.Combine(Application.streamingAssetsPath, "soal.json");
     StartCoroutine ("Json");
     soaldata = JsonMapper.ToObject(jsonString);

 }

 IEnumerator Json(){
 if(filepath.Contains("://")){
     WWW www = new WWW(filepath);
     yield return www;
     jsonString = www.text;
     }
     else {
     jsonString = System.IO.File.ReadAllText(filepath);
 }

public void OnClick(){
         soalbegin();
 GameObject.Find("Panel/soal/gambar/Text").GetComponentInChildren<Text>().text = soaldata["data"][numbersoal]["soal"].ToString();//this to load text from json

//i need variable to load sprite / texture from link json
}

and this is my json:

 {
 "data":[
 {
     "id":"1",
     "soal":"siapa tokoh ini",
     "gambar":"//1.png",
     "jawaban":[
         "natsu",
         "shank",
         "goku",
         "gildart"
         ]
 }
]}


texts: Unity3D How to write to the back buffer AFTER the final pass of deferred rendering?

texts:
I've been using this script and shader from the wiki, and they work wonders; my only problem is using them in deferred rendering.

Now, the way this shader works is by writing to the depth buffer to hide anything behind an object with this shader applied, but for some reason this wasn't working when I tried to use deferred rendering for shadows and better lighting. The problem is addressed by Kuba in the final post of this topic.

The final pass of prepass rendering (the part that renders geometry the second time and applies the result of the lighting pass to it) is rendered in to a texture, then blit-copied into the back buffer, which overrides everything that was rendered there before.

My question is if there is any way to render after that final pass, so I can still use my depth mask to hide objects behind it. If there is no way to directly write after the final pass, is there another solution I can try? Perhaps blending the two cameras on my own and some how blitting that on to the screen?


texts: How to use multiple shaders with LibGdx + SpriteBatch

texts: I'm programming a 2D game libgdx. I'm using a SpriteBatch of course to draw some Sprites. Now I wanted to use multiple ShaderPrograms with the SpriteBatch, but unfortunately you can set only one `ShaderProgram at a time. For example, I wanted to draw the whole scene with a specific color and wanted to add a parallax effect to some sprites by manipulating the texCoords in the shader. I know in native OpenGL you can just enable as much shaders as you want before your draw call. But it seems that in libgdx it is not possible.


texts: Box2d bodies that are really close together, are getting “stuck”

texts:
I'm using a tiled tmx map, and I created a class that adds bodies to each tile within a certain layer. This has been working great so far except for when a character or an enemy moves around on the screen, its body gets stuck on an edge between two tiles.

This seems to happen "sometimes" and in certain spots. Jumping makes you unstuck but it's annoying when it happens, and I tried increasing the position iterations, but the problem keeps reoccurring.

Here's what my game looks like:


texts: Are July and August bad months to release an iPhone game?

texts:
After one year of indie game development I end my development cycle in summer time. I spoke recently with a marketing advisor and I was told me that I should never release something over the summer as everyone (especially in southern European countries) tends to go on holiday and not to read blogs/magazine etc..

I am not 100% sure about this as I personally would still read a tech magazine on the beach :).

Are there some statistics available on best time periods to release an iPhone game?

I am aware that many big companies tend to release games in the period between October/November but I can't afford waiting that long.


texts: Making character's skills and abilities as commands, good practice?

texts:
I am designing for a game that consist of characters who have unique offensive skills and other abilities such as building, repairing, etc. Players can control multiple of such characters.

I'm thinking of putting all of such skills and abilities into individual commands. A static controller would register all of these commands into a static command list. The static list would consist of all the available skills and abilities of all the characters in the game. So when a player selects one of the characters and click on a button on the UI to cast a spell or perform an ability, the View would call the static controller to fetch the desired command from the list and execute it.

What I'm not sure of however if this is a good design given that I'm building my game in Unity. I am thinking I could have made all the skills and abilities as individual components, which would then be attached to the GameObjects representing the characters in the game. Then the UI would need to hold the GameObject of the character and then execute the command.

What would be a better design and practice for a game that I am designing?


texts: When should you use a baseclass and a class as a datatype?

texts:
Im following a C# rpg game development tutorial atm and what confuses me is that I cant figure out when to use what.

The author writes different classes where 1 class derives from another so the derived class has all the properties of the bass class. With other classes when all the properties are needed from another class he just makes them a datatype

Example: both the monster and player class have currentHealth and and maximumHealth as properties from the LivingCreature baseclass. But then the author writes Item class as a public data type property in the InventoryItem class. Can someone explain to me when I should make a datatype and when I should I derive a class?

public class Monster : LivingCreature {
 public int ID { get; set; }
    public string Name { get; set; }
    public int MaximumDamage { get; set; }
    public int RewardExperiencePoints { get; set; }
    public int RewardGold { get; set; }
    public List<LootItem> LootTable { get; set; }

    public Monster(int id, string name, int maximumDamage, int rewardExperiencePoints, int rewardGold, int currentHitPoints, int maximumHitPoints)
        :base  (currentHitPoints, maximumHitPoints) {

        ID = id;
        Name = name;
        MaximumDamage = maximumDamage;
        RewardExperiencePoints = rewardExperiencePoints;
        RewardGold = rewardGold;
        LootTable = new List<LootItem>();
}

}
public class InventoryItem
{
 public Item Details { get; set; }
 public int Quantity { get; set; }

    public InventoryItem(Item details,int quantity)
    {
        Details = details;
        Quantity = quantity;
    }
}


texts:
I am building an interactive application in Starling for which a camera system is required. Since there is no existing camera system in flash and the addons for starling do not meet our requirements, I am writing my own. Basically, it moves and scales all assets depending on the position of the camera.

However, I am having trouble with zooming towards a specific point on the screen. Every object has a pivotpoint in the topleft corner - so it scales relative to the topleft corner. For all kinds of reasons, I cannot change the pivotpoint of the objects.

To compensate for this, the camera needs to move towards the point we want to zoom towards on the x/y-plane, but I cannot figure out how much it should move. Are there any known formulas for this? How do I calculate how the camera should move?

EDIT: I can actually move the pivotpoint to the center of the assets if that makes it much easier.

EDIT: This method is used on each sprite to update its position:

var zPos:Number = Number(this.z - Game.cameraZ);
var scale:Number = Game.focalLength / (Game.focalLength + zPos);
var correctedScale:Number = scale * (1 / (Game.focalLength / (Game.focalLength + this.z)));
this.scaleX = this.scaleY = correctedScale;
this.x = Game.cameraX * scale + this.defaultX * scale;
this.y = Game.cameraY * scale + this.defaultY * scale;


texts: Where should shaders and lights be in a component-based entity system?

texts:
Where should I put the shader and the light / shadow calculation? Should that be a component too?

And should the rendering system know how to handle them or should there be a separate light system?

I'm specifically talking about about a 2D system, but it should be the same in for 3D I think.


texts:
Every programming language has its standard library of containers, algorithms, and other helpful stuff. With languages like C#, Java, and Python, it's practically inconceivable to use the language without its standard lib.

Yet, on many C++ games I've worked on, we either didn't use the STL at all, used a tiny fraction of it, or used our own implementation. It's hard to tell if that was a sound decision for our games, or one simply made out of ignorance of the STL.

So... is the STL a good fit or not?


texts: Diagonal symmetry across a filtered array?

texts:
I wrote this code to randomly generate a square terrain that somewhat resembles an island. First, I randomly populated a square with grass tiles (1s) on a plane of water tiles (0s):

Then, I looped through each tile and changed its tile type according to its neighboring tiles(if a tile is surrounded by 4 or more water tiles, it becomes a water tile, otherwise it becomes a grass tile):

The results don't seem all that pleasing; not only is the terrain filled with holes and lack overall "togetherness", it is also weirdly symmetrical diagonally.

Here's the code:

private void SmoothMap (Chunk chunk)
{
    for(int row = 1; row < chunk.rows-1; row++)
    {
        for(int col = 1; col < chunk.cols-1; col++)
        {
            //if current tile is not null
            if(chunk.GetTile(row, col) != null)
            {
                //Check its neighboring tiles
                int neighboringTiles = GetSurroundingTiles(row, col, chunk);
                //System.out.println("Position: " + row + ", " + col);
                //System.out.println("Current tile type: " + chunk.GetTile(row, col).type);
                //System.out.println("Neighboring water tiles: " + neighboringTiles);

                if (neighboringTiles > 4)
                {
                    if (chunk.GetTile(row, col) != null)
                    {
                        chunk.GetTile(row, col).texture = GetRandomWaterTexture();
                        chunk.GetTile(row, col).type = Enums.tileType.Water;
                    }
                }
                else if (neighboringTiles < 4)
                {
                    if (chunk.GetTile(row, col) != null)
                    {
                        chunk.GetTile(row, col).texture = GetRandomGrassTexture();
                        chunk.GetTile(row, col).type = Enums.tileType.Grass;
                    }
                }
            }
        }
    }
}

private int GetSurroundingTiles(int r, int c, Chunk chunk)
{
    int surroundingTiles = 0;

    for(int x = c-1; x <= c+1; x++)
    {
        for(int y = r-1; y <= r+1; y++)
        {
            if (x != c || y != r)
            {
                if(chunk.GetTile(x, y) != null)
                {
                    if (chunk.GetTileCode(x, y).equals("0"))
                    {
                        surroundingTiles++;
                    }
                }
            }
        }
    }
    return surroundingTiles;
}

Does anyone know why it is the way it is? Or a better way to approach generating an terrain like this?

Here's the GetTile() code:

public String GetTileCode(int r, int c)
{
    Tile tile;
    ArrayList<Tile> chunk_row;
    if(tiles.size() > r && r >= 0){
        chunk_row = tiles.get(r);

        if(chunk_row != null && chunk_row.size() > c && c >= 0){
            tile = chunk_row.get(c);
            return tile.isGrass() ? "1" : "0";
        }
    }
    return "0";
}

1 is grass, and 0 is water.


texts: How to send components in an ECS System?

texts: I'm trying to send a CreateEntity packet from a server to client, but I can't figure out how to send the information about components over the network. I gave each component an ID, but then I realized I'd have to send the associated data (E.X size of entity for the transform, etc).  Is the easiest way to just create an Enum of entities and have the client create the components based on what it knows about the entities? I'd prefer to not do that as it makes modding much harder.


texts: ECS component dependencies / sharing and cache locality

texts:
I have been trying to wrap my head around how ECS works when there are components which are shared or dependent. I've read numerous articles on ECS and can't seem to find a definitive answer to this.

Assume the following scenario:

I have an entity which has a ModelComponent (or MeshComponent), a PositionComponent and a ParticlesComponent (or EmitterComponent).

The ModelRenderSystem needs both the ModelComponent and the PositionComponent.

The ParticleRenderSystem needs ParticlesComponent and the PositionComponent.

In the ModelRenderSystem, for cache efficiency / locality, I would like run through all the ModelComponents which are in a compact array and render them, however for each model I need to pull the PositionComponent. I haven't even started thinking about how to deal with the textures, shaders etc for each model (which will definitely blow the cache).

A similar issue with the ParticleRenderSystem.. I need both the ParticlesComponent as well as the PositionComponent, and I want to be able to run through all ParticlesComponents in a cache efficient / friendly manner.

I considered having ModelComponent and ParticlesComponent each having their own position, but they will need to be synched every time the models position changes (imagine a particle effect on a character). This adds another entity or component which needs to track and synch components or values (and potentially negates any cache efficiency).

How does everyone else handle these kinds of dependency issues?


texts:
I'm reading a fantastic article about game timer precision and here is a quote about 2/3 of the way into the article:

  If you start your game clock at about 4 billion (more precisely 2^32,
  or any large power of two) then your exponent, and hence your
  precision, will remain constant for the next ~4 billion seconds, or
  ~136 years.

He doesn't give a concrete example of this though.  Does this mean I would want to add 2^32 to the game clock value that I store at the beginning of each frame?  Or is there a way to actually set the clock in Windows so that the numbers start at 2^32?


texts: Should I use animated objects or use the physics engine on iOS scenes with lots of rigidbodies?

texts:
I have a scene with lots of houses and other objects. These objects will be bombarded from the sky. How to handle these kind of settings having in mind that you want the physics to be as realistic as possible.

In Unity3D, if I set all the objects with isKinematic=true and on collision I set it to false, then the physics isn't as realistic as I want it to be... Can you have these kind of scenes on iPhone? Should I have animated objects? I really don't know what is the best practice in this kind of scenes....


texts: SDL window crashes when mouse goes below a certain point

texts:
I added code to check the rgb values of my surface, and whenever i call the function it seems to work fine! the only problem is that whenever the mouse goes under y = 400 the entire window crashes... Right now the program outputs the rgb color of the pixel on the screen, and when it goes below 400 one or all of the pixel values are 0, and then the program crashes. I have no ideas why this is happening. Any help is appreciated! Heres the github repo! https://github.com/jcsq6/SDLGame not much has been done except a couple classes to make my life easier in SDL :)

int* texture::getPixel(int x, int y){
    static int Color[4];
    SDL_PixelFormat *fmt;
    Uint32 temp, pixel;
    Uint32 *pixels = (Uint32 *)Surface->pixels;
    Uint8 red, green, blue, alpha;

    fmt = Surface->format;
    SDL_LockSurface(Surface);
    pixel = pixels[(y * Surface->w) + x];
    SDL_UnlockSurface(Surface);

    temp = pixel & fmt->Rmask;
    temp = temp >> fmt->Rshift;
    temp = temp << fmt->Rloss;
    red = (Uint8)temp;

    temp = pixel & fmt->Gmask;
    temp = temp >> fmt->Gshift;
    temp = temp << fmt->Gloss;
    green = (Uint8)temp;

    temp = pixel & fmt->Bmask;
    temp = temp >> fmt->Bshift;
    temp = temp << fmt->Bloss;
    blue = (Uint8)temp;

    temp = pixel & fmt->Amask;
    temp = temp >> fmt->Ashift;
    temp = temp << fmt->Aloss;
    alpha = (Uint8)temp;

    Color[0] = red;
    Color[1] = green;
    Color[2] = blue;
    Color[3] = alpha;

    return Color;

}

it's worth noting that when I call this function, the input y and x values are the mouse's position.


texts: Compare responsibility among copy-left license

texts:
I have checked out many source about the free and open source licenses (Wikipedia), but what I really want to know what is our responsibility when we use the open source that has these licenses.
For example:

Zlib:
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgement in the product documentation would be appreciated but is not required. (from Irrlicht's readme.txt file)

LGPL:
dynamically linking to it from a closed source app is allowed, but also means any changes made to soft (which has LGPL) itself do need to be made available publicly. (source: from a comment)

GPL: The license for libmad is GPL, which means that in order to use it your application must also be GPL (source: from SDL Mixer README.txt file)

Please make a quick compare like that so I can understand fully about my responsibly when I use an open source software for my project.

PS:
In this question, I like to limit the comparison to the most popular copy-left licenses:

Apache License
BSD License
GNU General Public License
GNU Lesser General Public License
MIT license
zlib/libpng license


texts:
I am making a game very similar to Tank Trouble. I cannot get t the tank to collide with the maze in the map.

Let tx and ty = the tank x and y value.
Let x and y = the walls x and y value.
Let h and w = the walls height and width.

public boolean collidesWith(double tx, double ty)
{
    if ((tx - 55 > x) && (tx + 55 < x + w) && (ty - 55 > y) && (ty + 55 < y + h))
    {
        return true;
    }

    return false;
}


texts: Spotlights and Pointlights not working with Unity Render Pipeline?

texts:
I'm experimenting with URP, Render Pipelines, and Shaders for the first time recently and have noticed something odd. In the scene I'm building, Point Lights and Spotlights don't work. No matter what I do, they do not affect the environment at all, for static and nonstatic objects. I can't even use a Halo component to visualize them. They exist in the scene but don't do anything and even Lightmaps don't seem to register them.

I suspect that it's because of the render pipeline, but if I go to a blank scene and put a spotlight on an object, it works. I'm just very confused what's happening.

Any idea what might be happening?


texts: 2D AABB vs AABB side of collision and collision depth

texts:
I realize there have been a multitude of questions involving 2D AABB vs AABB collision, but the questions and responses always avoid the simple questions that make it difficult.

To keep things simple, we are going to assuming that AABB1 is a moving(vector velocity and direction known) rectangle that is much taller than it is wide, and AABB2 cannot move and is a smaller square.  If AABB1 were to move towards AABB2 from any angle how would you figure out which side of AABB2 it collided with?

Further, when calculating collision depth, I mean the distance it travels into the object on the x-axis and the y-axis.  When finding those distances, how would you find what point would you use as reference? From what I can tell, you couldn't just use one point for every collision because with AABB1 (it is much taller than wide), the top left point would be irrelevant when finding the penetration depth on a collision with the bottom right corner.

Another but less important question than the other two, how can you handle an object with a velocity vector with a high enough magnitude to move through an entire wall in one frame.  Say a wall is 50 pixels wide and a player is moving 100 pixels per frame, it could jump through the wall without triggering a collision.

If further information is needed to help solve my problems or understand the problem, please ask. I haven't found any post that helps and I don't have enough reputation to post pictures to elaborate in more detail.


texts: Getting neighbors of hex tiles in 3D space

texts:
I have a hex tiled model like attached below. Each of the hex tiles are separate objects meaning I can access each of the hex tiles individually inside Unity

Now in my program I want to be able to get the 6 neighboring tiles of the selected tile. At first I thought I would get the 6 edges of the current tile and then check to see if any of the remaining tiles have those edges in common but that would be very expensive if I want to compute neighbors of all the tiles.

Any ideas??


texts:
Here is the fragment shader code (MyShaders/Shader1.frag):

void main(){
   gl_FragColor = vec4(1.0,1.0,1.0,1.0);
}

And the vertex shader code (MyShaders/Shader1.vert):

void main(void)
{

    gl_Position=vec4(1.0,1.0,1.0,0.0);

}

And the .j3md material code:

MaterialDef Shader1 {
    MaterialParameters {
    }

    Technique {
        VertexShader GLSL100 GLSL150:   MyShaders/Shader1.frag
        FragmentShader GLSL100 GLSL150: MyShaders/Shader1.vert
    }
}

The error stack trace is:

WARNING: Bad compile of:
1   #version 110
2   #define FRAGMENT_SHADER 1
3   void main(void)
4   {
5
6       gl_Position=vec4(1.0,1.0,1.0,0.0);
7
8   }

May 01, 2018 3:35:57 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=MyShaders/Shader1.vert, defines, type=Fragment, language=GLSL100]
ERROR: 0:6: Use of undeclared identifier 'gl_Position'

And here is the code for instantiating the material:

Material mat=new Material(assetManager,"MyShaders/Shader1.j3md");

I think that the bug is somewhere in me not passing any gl_Position parameters into the shader, but how do I do that?

I am using JME3 and Java.


texts: Is it possible to have Ue4 render the graphics with a black line around everything similar to a cell shaded style, or would that require models specifically prepared for that purpose?


texts:
Im currently working on a 2D Game where the users can interact with specific nodes and are able to edit certain bits of information and I also plan for the users to be able to click buttons to set specific information.

My problem is that I do not know how to write code to create a side menu/UI system where information can be passed to it and displayed and also be edited by the system.

If anyone has any tutorials or material that they would be able to point me towards that they think would be helpful with this would be very appreciated as I do not know where to begin with this. Note that at the moment I am willing to swap from DirectX to OpenGL if that would be easier though I would prefer to stick to DirectX if possible

Thanks


texts: What is the most secure way to archive a GKScore to be re-submitted later?

texts:
I'm looking for the safest way to archive and store a GKScore that needs to be re-submitted to Game Center (say, because the user didn't have a network connection at the time the score was earned).  I would like to archive the GKScore instance in case the app is terminated before it can be successfully re-submitted to Game Center.

My worry is that if it's archived to an instance of NSData and saved in a .plist, it would be easy to manipulate.  Perhaps this worry is unjustified?

NOTE: I posted a similar question on Stack Overflow only to realize that it's better asked here.


texts: Is there a pattern for handling multiple game states?

texts:
I'm experimenting with writing a multiplayer game, almost from scratch (I'm using C++, OpenGL, ENet, and platform-specific APIs) with a client/server networking model where the server is authoritative.

The server and clients each run their own deterministic simulation of the game. The server sends periodic snapshots of the entire game state to clients. When a client receives the snapshot, it forgets everything it knows about the game (except for the player's input after the snapshot was taken), loads the snapshot, and replays the player input that was generated after the snapshot was taken.

Now, say I want to send deltas instead of full snapshots. The server needs to remember the previous snapshot it sent, so that it can compare the current snapshot against the previous snapshot. Clients also need to remember the previous snapshot to reverse the delta. Each snapshot is a copy of the complete game state, and the server and clients now need to handle at least two of them (the previous snapshot, and the current game state).

A game state conceptually follows this pseudo-code:

class GameState {
    vector<unique_ptr<GameObject>> objects;
    vector<unique_ptr<Player>> players;
    TerrainTile terrain[TERRAIN_WIDTH][TERRAIN_HEIGHT];
}

abstract class GameObject {
    vec3 position;
    vec3 velocity;
    abstract void doPhysicsTick();
    abstract void render();
}

class Player {
    GameObject controlledObject;
    string username;
}

class HumanCharacter extends GameObject {
    void doPhysicsTick() {...}
    void render() {...}
}

... etc ...

Is there a pattern to store multiple independent copies of the game state from different times, so that they can be easily compared?

What if I wanted the server to run an identical simulation to each client (delayed by network latency)? The server would then need to manage at least N+1 game states, where N is the number of clients - and they would be active simulations, rather than static copies.  (One practical use for such a system might be to only send values that the client has predicted incorrectly, rather than all values that have changed).


texts: For deferred rendering and SSAO, what coordinate system are the normals actually in?

texts:
So, I'm following the very helpful LearnOpenGL online tutorials, and I'm working on implementing SSAO. I don't have a deferred rendering pipeline, but I need to collect normals during my depth pass so that I can sample them for the SSAO effect.  I'm following this tutorial: https://learnopengl.com/Advanced-Lighting/SSAO, and referencing this one when needed: https://learnopengl.com/Advanced-Lighting/Deferred-Shading.
However, neither of these tutorials really explain what's going on with the normals. What is the normalMatrix being used in the shader?
mat3 normalMatrix = transpose(inverse(mat3(view * model)));
Normal = normalMatrix * (invertedNormals ? -aNormal : aNormal);

I'm not worried about the invertexNormals conditional, that's probably just something weird the author added for handling different conventions, but what the heck is going on with that normalMatrix? Why would we invert the view * model matrix? If we're starting with aNormal in object space (whether it's coming directly from a vertex buffer or from a normal map TBN calculation), I can't for the life of me figure out what coordinate system that resulting normal is going to end up in!
So, long story short, what coordinate frame should my normals be in if I'm to use them for SSAO? World space? View Space? Clip space? None of the above? If it's some weird coordinate system, can somebody help me get there? I'm probably more confused than I should be.


texts: Unity - how to switch between ratios in a Scene View?

texts:
I'm complately new to Unity, but I know what's going on, I've made some games with LibGDX earlier.

In GDX, to handle all resolutions perfectly I always create 5 different sets of backgrounds (cause they have to be perfectly sized) and I place UI widgets on percentage for each ratio independantly (hardcoded values). I was just checking what's the ratio on runtime.

As we know, there are only 5 possible aspect ratios for mobile devices (I target mobile only).

Now, when I started using Unity, the first thing I looked up was how devs handle ratios. I found some scripts in the web, which add pillarboxes which in my case is unacceptable.

So I thought - ok, let's do it my way, and make it for all aspect ratios.

And my question is:

Is there any option in Unity, which will allow me to 'switch' in the Unity Editor between ratios and the 'Scene View' will understand this and resize?

What I want to do is to create a 16:9 with the editor, then switch to 5:3, adjust elements for it, and remaining ratios too.

To be clear, I don't mean the 'preview', when you check the desired device and it shows how the game will look like.

Any help and tips are appreciated! :)


texts:
I am making a space game where you fly a ship.

I am trying to work out the physics for such a game and so far came up with:

var thrust; //between 1 & 100 how much the engines are pushing
var mass; // the mass of the spaceship
var speed; //the speed at which the spaceship is moving

Now big ships will have more mass to therefore take longer to speed up and longer to slow down once the thrust is off. Big ships will be slow because of the mass.

Small ships will speed up faster and slow down faster but also go faster.

How will I implement this into a game? I can do the keyevents, if up is pressed for 5 frames for example will I make the thrust raise to by 10 each frame(example) and then increase the speed of the ship based on some formula of the mass & thrust?

This is the game: Only UI and menus made but wan to get an idea of my physics before I implement the movement
http://www.taffatech.com/DarkOrbit.html


texts: Generating triangle indices for marching cubes mesh

texts:
So I am making a programily generating cave program and I have all the vertices but I have no idea how to solve for the faces of my mesh. My code:

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

public class MapGen : MonoBehaviour
{
    Mesh mesh;

    int[] triangles;

    public int xSize = 20;
    public int zSize = 20;
    public int ySize = 20;
    [Range(0f, 4.5f)]
    public float SurfaceLevel = 3.5f;
    Vector3[] interest;
    Vector3 old = new Vector3(0, 0, 0);
    public bool ShowAlg = false;
    [Header("Slows down the scene veiw dramaticly when in play mode!")]
    public bool ShowVert = true;

    // Start is called before the first frame update
    void Start()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;

        CreateShape();
        SolveFaces();
        UpdateMesh();
    }
    void CreateShape()
    {
        interest = new Vector3[(xSize + 1) * (zSize + 1) * (ySize + 1)];

        float seed = Random.Range(0.2f, 0.5f);
        Debug.Log(seed);

        for (int x = 0; x <= ySize; x++)
        {
            for (int i = 0, y = 0; y <= zSize; y++)
            {
                for (int z = 0; z <= xSize; z++)
                {
                    float ypn = (Mathf.PerlinNoise(x * seed, z * seed) * 2f);
                    float xpn = (Mathf.PerlinNoise(y * seed, z * seed) * 2f);
                    float zpn = (Mathf.PerlinNoise(x * seed, y * seed) * 2f);

                    if (ypn + xpn + zpn >= SurfaceLevel)
                    {
                        interest[i] = new Vector3(x, y, z);
                    }

                    i++;
                }
            }
        }
    }

    void SolveFaces()
    {
        triangles = new int[xSize * ySize * zSize * 9];

    }
    void UpdateMesh()
    {
        mesh.Clear();

        mesh.vertices = interest;
        mesh.triangles = triangles;

        mesh.RecalculateNormals();
        MeshCollider meshc = gameObject.AddComponent(typeof(MeshCollider)) as MeshCollider;
        meshc.sharedMesh = mesh;

    }
    private void OnDrawGizmos()
    {
        if (interest == null)
            return;
        for (int i = 0; i < interest.Length; i++)
        {
            if (ShowVert == true)
            {
                Gizmos.color = new Color (0.286f, 0.486f, 0.812f);
                Gizmos.DrawSphere(interest[i], 0.2f);
            }
            if(ShowAlg == true)
            {
                Gizmos.color = Color.green;
                Gizmos.DrawLine(old, interest[i]);
                old = interest[i];
            }
        }
    }
}

This script is placed on a empty Game Object with a Mesh Filter, Renderer, and a collider.
Note they do nothing without the faces.
I have set it up so the face array goes on the triangles variable and missing part of the script should go in the SolveFaces() function. Thanks in advance.


texts:
I have a set of vertices and another set of indices. Sometimes I find that I have duplicate vertices in my mesh.

I tried at first to check if two identical vertices were in the array of vertices but that didn't work because I remembered that more that if one vertex  represents multiple edges then the vertex would be validly represented as multiple vertices in the vertices array.

Then I remembered that the indices help represent how the vertices are structured but I didn't know how to use them. So I came here to ask how to use them to detect duplicate vertices in a mesh.


texts: How do I make a part of my map off limit?

texts:
I'm looking for a common way to make zones in my 3D map "off limit"? The kind of thing you see in eg Hitman games where NPCs will get suspicious if you step into certain areas. Will need several areas like this, corridors, rooms etc.
Is it just to create invisible collider objects that set an offLimits bool to true, or is there a preferable way?


texts: How to integrate admob ads in Unity 5.6.2f1

texts: I made the game space shooter. But i don't know how to integrate admob ads in Unity. I downloaded Google Admob ads Plugin for unity. But where i write the code don't know and how to implement it!!


texts: How to make object that moves with constant speed not overshoot the object it collides with?

texts:
To learn LOVE2D I am creating a simple project. Player moves the square with arrows keys until it hits the goal square, at which point the game is won.

function isCollision(x1,y1,w1,h1,x2,y2,w2,h2)
    return (x1<x2+w2)and(x2<x1+w1)and(y1<y2+h2)and(y2<y1+h1)
end

function love.update(dt)
    if love.keyboard.isDown("escape") then love.event.quit() end
    if isCollision(player.x,player.y,player.w,player.h,goal.x,goal.y,goal.w,goal.h) then
        gameOver=true
        if love.keyboard.isDown("space") then love.load() end
    else
        delta = player.speed*dt
        if love.keyboard.isDown("right") and player.x<=800-player.w then player.x=player.x+delta end
        if love.keyboard.isDown("left") and player.x>=0 then player.x=player.x-delta end
        if love.keyboard.isDown("down") and player.y<=600-player.h then player.y=player.y+delta end
        if love.keyboard.isDown("up") and player.y>=0 then player.y=player.y-delta end
    end
end

But sometimes the square overshoots the goal and it becomes lodged in the goal.

How do I make it so that engine detects when the player simply touches the goal and stops there, without moving further in the frame?

Disclaimer: Using a collision detection library like bump.lua would be too easy. I want to learn the relevant practices so that I can apply it to retro consoles and computers in the future.


texts: How do I synchronise real-time moves of players on a grid?

texts:
I'm working on a real-time game based on a grid. Each player can move a single square at a time. A server tracks the game state and notifies clients of changes.

It's possible for two players to make a conflicting move, such as attempting to move to the same square. How can I fairly resolve such conflicts when they happen?

My current approach is First come, first served: When the server receives a move, it immediately updates the game state to reflect that. It then discards any conflicting moves it receives later.

The problem is that the moment a move was received does not necessarily line up with moment it was sent. Players on a faster network connection will always have an advantage.

How can I deal with this?


texts: Is Batching Geometry Every Frame Always Slower Than Individual Draw Calls

texts:
I'm currently have an application that has ~10k draw calls.  I implemented a batching scheme where I group all objects that share material, vertex format, etc and pre-transform them by their world matrices and put all those objects in one vertex buffer / index buffer, and then draw them with DrawIndexedPrimitive (I do this every frame, since some objects might have moved / changed material etc).  However, this method is always slower than if I just had multiple draw calls.  Using VTune, it seems most of my time is spent computing the transformed vertices and copying the vertex/index data into the buffers.

My question is: Is this expected?  Do systems that perform batching typically cache the batched data or are there some that get away with batching every frame like I am attempting to do (and if so, are there any tips for what I might be doing poorly)?

My application is in DirectX 9, but I'm curious about solutions in other platforms as well (OpenGL or DirectX 11).


texts: Resources to learn programming rigid body simulation

texts: Where I can start learning about simulating rigid bodys 2d and 3d ?


texts: How do i move a 2D object with angle and speed variables in unity?

texts: I want to move an object with a certain angle and speed, is there a was to set this as an initial velocity so that it is still possible for the object to collide and bounce of other objects using its rigid body?


texts: Isometric Tile-Based Pixel Game Code Structure

texts:
I'm starting to hit some tricky bits in my Java project.

So far, I have drawn the following isometric tile:

And written some Java code to display it as a map:

I do this by looping over an array of tiles and drawing them on a JPanel. I have also implemented layers so that I can draw objects on top of the ground, etc.
So far I have set up some basic classes such as Tile and Level but I'm starting to hit some real complexities.

My question is, with such a project, should I be drawing everything in a normal 2d perspective and rotating them? Or is drawing them isometrically and overlapping them the correct approach?

Is anyone aware of any resources that I can follow that take a similar approach to myself? I've had a Google but everyone seems to take a different approach.


texts: What single word could be used to describe city adventures?

texts:
I am developing an urban racing simulator in a very "underground" stylized setting. It's name is The Underground King and you have the ability to either:

A) Race in a 2d side view.
B) Do something in the city.

Doing either of A or B will pass the day since it's assumed it takes all day to perform that action.
My issue is that while racing levels are caled Racing, the city action/adventure is called Event which is both too generic, and conflicts with my game engine's internal event systems.

I have tried to find a relevant replacement that is descriptive enough on what it is, whithout relying to medieval fantasy type tropes such as "Adventure" or cyberpunk's very own "Run".

What I could think of / narrow down are: Buisness or Biz, Happening, Venture, Risk, Encounter.
Here are some examples of the kind of things you can find:

You accidentally bump into a drunk thug who wants to start a fight.
A dog has something shiny and valuble looking in its bouth and wants to run away to bury it.
A suspicious-looking woman dropped a package in a trash can.
You get a tip about an abandoned but heavily locked garrage.
A rich businessman wants to put a bet on your next race but wants a guarantee.
While driving with your crew, you smell something burning (with random consequences):

Somebody is playing with matches.
The engine is burning.
Somebody tried to sabotage your car for the next race but it shortcircuited.
A rusted part finally started spinning again. The car has higher stats now.

I am looking for a single word term that can apply to any sort of event as written above which is generic enough to encompass anything you can potentially gain from, but specific enough to represent its something you can pursue or happen to you while you are present in the city.

Thanks!


texts: What method replaces GL_SELECT for box selection?

texts:
Last 2 weeks I started working on a box selection that selects shapes using GL_SELECT and I just got it working finally.

When looking up resources online, there is a significant number of posts that say GL_SELECT is deprecated in OpenGL 3.0, but there is no mention of what had replace that function.

I learnt OpenGL 1.2 in back in college 2 years back but checking wikipedia now, I realise we already have OpenGL 4.0 but I am unaware of what I need to do to keep myself up to date.

So, in the meantime, what would be the latest preferred method for box selection?

EDIT: I found http://www.khronos.org/files/opengl-quick-reference-card.pdf on page 5 this card still lists glRenderMode(GL_SELECT) as part of the OpenGL 3.2 reference.


texts: Unity: Loading screen without a coroutine (is it possible?)

texts:
I need to accomplish something specific but I'm not sure how to do it exactly:

My game has 2 scenes:

The main menu that has a couple of buttons...
... and the game scene that displays a different mesh (which is imported from a folder on the HDD at runtime) depending on which button you pressed and that also lets you walk around.

My approach for this:
Clicking on a button makes a script A call a static class B (used for sharing data between scripts), which then in turn creates an instance of another class C, which inherits from ScriptableObject and takes care of the whole "import and display the mesh" part.

Importing a mesh takes a while, so I'd like to display some kind of loading screen (a panel that overlays everything else in the 2nd scene) and this is where I'm stuck.

Importing a mesh accesses the Unity API, so I can't do it in an extra thread (or Task, which would be perfect) but I also can't use a coroutine because class C derives from ScriptableObject, not MonoBehaviour (which I can't use because I can't create a new instance then).

Another problem is that the game is stuck on the main scene with the button pressed and doesn't display the second scene until the mesh is loaded, so even if I set the loading panel active (loadingPanel.setActive(true)) before I start importing the mesh, it doesn't display it until after the model's already imported.

What can I do here? There's no need to display a loading screen while switching scenes, so I'm guessing that there's no point to load the second scene asynchronously, is there?


texts: Is it possible create an HTML5 mobile game without the user having internet connection?

texts: I trying to make a app for the Play Store and App Store. My app will be 2D, but will have 3D effects. Is it possible to program it in HTML5 without the user having internet connection? Also, are there any good tutorials on HTML5? Thank you in advance.


texts: MMO Server with C# asynchronous sockets performance

texts:
I have developed a 2D RPG MMO client / server. The server is developed in C# with asynchronous sockets. It is a pretty simplet implementation. The server gets the client's input / coordinates and broadcasts it to the other players. It is a very alpha stadium so that I only want to test performance to know if this way to go is good.

Now I am living in Germany, I have a static public IP (accessible via the internet) and deployed my game server on a Raspberry Pi 3 (it runs in the command line with C# / Mono). The only database access (write / read) is currently made, when a client connects or disconnects (store / load coordinates).

I made a speed test right now and have the following result:
Download Speed: 100840 kbit/s
Upload Speed: 8973 kbit/s
The Raspberry Pi is connected on a router (Fritz Box) via LAN and the port is set to  bridge mode (because of the public static IP).

Everything runs fine, but I tested it with ony two clients and when one client begins to move, the second client "sees" it maybe 1 second later. The movement is "lag free". But of course, it takes a lot of time until the signal arrives to the other clients.

My question now is, will I have the same issues later, when I rent a server? I really hope that this is what I should expect, when I run my server in my home network. Maybe this question is pretty difficult to answer, because I give you no source code of the server here, but as I said, when the clients get the signal, it is "lag free". The only thing I have is kind of a "delay".

Thanks in advice.


texts: UDK: Checking actor type in projectile ProcessTouch

texts:
So, to be brief, I'm trying to teleport a pawn when it's struck by a projectile (or damaged by any weapon in my game.)

Right now, I'm trying to just call Pawn.SetLocation in the projectile's ProcessTouch. That's a problem because ProcessTouch will hit any actor, not just a pawn. Additionally, any attempts to check the ProcessTouch's "Actor Other" throws errors.

I've tried a bunch of solutions (including making a event TakeDamage in the Pawn controller class,) but to no avail.

    simulated function ProcessTouch(Actor Other, Vector HitLocation, Vector HitNormal)
    {
         if (Other != Instigator)
         {
              //This is where the Other.TakeDamage goes if we are using a traditional gun.
              if (Other == Pawn);
              {
                   Other.SetLocation(0,0,0);
              }
         }
    Destroy;
    }

This code complains that Pawn's a bad expression. How else should I check actor type here?


texts: Drawing Sprites in Android OpenGL efficiently?

texts:
I want to basically give myself some sprite drawing functions (making use of openGL) such as;

draw(Texture,x,y)

I want to do this using OpenGL-ES 2.0 on Android. Since the textures can be varying sizes, I was thinking I would save the vertices along with the textures and pass them to the shaders every draw call using "glVertexAttribPointer". Is there a better(performance) way of doing this?

I would also make use of a model matrix to translate/rotate the sprites. Is this a normal thing to do for 2d rendering?


texts: How do I get consistent Xbox360 Controller input across Linux, Mac, and Windows?

texts:
I'm developing a browser plugin to provide joystick access to all browsers on all platforms. The issue that I'm running into is that OS X doesn't seem to provide Xbox 360 joystick input without installing some extra drivers, and even when those drivers are installed they map the buttons and axes completely differently than Windows and Linux.

I'm using xboxdrv on Linux, which has a pretty decent mapping and is very similar to the standard Windows XBox driver mapping. On windows XP using the default XBox Controller driver the order of the x and y axes are swapped. Is there an alternative driver that can be installed?

On OS X using Colin Munro's OS X Driver, the mapping is totally different though. The d-pad is mapped to the first four buttons and the axes are all switched.

What I want to know is what drivers do I need to install on each OS to get XBox 360 Controllers to register exactly the same as the do under Linux with xboxdrv.

OS: DRIVER
Linux: xboxdrv
Windows: ?
OS X: ?

The reason why I prefer the xboxdrv style of controller mapping is that the mapping is pretty much the same for any other random USB controller. The two primary axes are the same and the first 5 buttons are the same. This way the XBox controller will behave like an "enhanced" generic USB controller and any game logic won't need to know anything about the specific controller type. I want to be able to assume the basic axes and buttons will be mapped correctly (or at least consistently) and then use the extra buttons and axes for extra functionality.

The newer versions of the standard Linux X11 input also match exactly the xboxdrv mappings which is another reason that I prefer it.


texts: Rect Position doesn't reset if animation is canceled

texts:
I have a text component that displays a text with an animation. If I disable the GameObject while the animation is running, the Rect Transform doesn't reset to the original position, which makes the text appear revealed next time it has to come. How can I fix this?

This is how the settings look like:


texts: Return value from coroutine to non monobehaviour

texts:
I have a class which is not a monobehaviour (lets call it "Generation"), and as such running CoRoutines from within are not an option.

I have a monobehaviour (lets call this "TestScript") which needs to call a function within Generation. One parameter required is a Func>.  It then calls that Func multiple times, expecting a result in the form of a double. The problem, is that it takes time to return, it needs to run across many frames, and so it kicks off some Coroutines (as this is in the monobehaviour). I set it to return a Task so that I could use Threading.SpinWait.SpinUntil and only return after the coroutines have exited, but this just hangs the main Unity thread.

Here is the function I am calling:

        public void AssessGeneration(Func<NeuralNet, Task<double>> assessment)
        {
            foreach (NeuralNet neuralNet in neuralNets)
            {
                neuralNet.Fitness = assessment(neuralNet).Result;
                neuralNet.fitnessAssessed = true;
            }
        }

So, I've tried many other things, such as moving the SpinWait into the Generation class, but still hangs. I've tried calling the function in Generation within a Task on a new thread, but when it attempts to run the coroutines it complains about not being on the main thread.

So - I have a function, in a class not inheriting from MonoBehaviour. It is called from a MonoBehaviour, and must pass in a function which takes a parameter of type NeuralNet, and returns a double. It must return a double after a coroutine has finished, but I can't be blocking the main thread.


texts: Can I name a team with the name of their city to avoid trademark issues?

texts: I was wondering, if you want to make a NBA game on smartphones, without the license held by EA, the first solution seems to name your teams with a different name, such as "Chicragro Brulls" (this is just for the example), but would it be possible to just call your team with the name of the city, such as "Chicago vs. Dallas" ? I know the first solution was chosen by Pro Evolution Soccer, would you know any other game that don't use a license?


texts: I'm using Device Simulator from the package manager to test on mobile devices. I'm using a banner ad at the top center with the code Advertisement.Banner.SetPosition (BannerPosition.TOP_CENTER); For andoid devices I can see it but on IOS devices it is blocked by its top notches or the safe area the Device Simulator calls it. Is there a way to reposition the y axis to fit on IOS devices? Thanks


texts: How to fix odd artifacts at the edges of textures in DirectX 11?

texts:
In my DirectX 11 project, when I have textures they have odd artifacts at the edges. I've seen it before and searched online, but I can't find any DirectX examples that I can get to work.

You can see it on the skybox too. I'm assuming this is caused because the texture is too small and it's being expanded. I'm using the sampler state filter D3D11_FILTER_MIN_MAG_MIP_LINEAR. How can I fix this?


texts: Way to look up a chain of touching objects (power connections)

texts:
I'm having a bit of a logic problem. I have blocks that connect together for power and so when a block comes into contact with a block that is powered, it also becomes powered. It also keeps a list of connected blocks and checks that it's getting power from at least one block.

There are "source" blocks in the scene as well which are always powered and that serves as the starting point.

All of this works fine, unless we get a break in the middle. In that case, even though they aren't connected to a source block anymore the two blocks are connected to eachother and so they stay in the "connected" state.

My question is similar to this question but different in that my objects can attach in any orientation and have any number of connections. In this case, a sort of pathing would work since wire systems aren't going to have more than 10 or 15 connections total and only 1 wire system active at any time.

Here is the code if anyone is interested. Thanks in advance.

public class Conductor : MonoBehaviour
{

public bool isElectrified;
public bool isPowerSource;
public Material inactiveMaterial;
public Material activeMaterial;

private List<Conductor> _conductors;
private Renderer _renderer;

//====
//Unity Functions
//====
void Start()
{
    SetupPrivateVariables();
    CheckPowerSource();
}

void Update()
{
    ProcessConductors();
}

void OnCollisionEnter(Collision collision)
{
    ProcessNewCollision(collision, true);
}

void OnCollisionExit(Collision collision)
{
    ProcessNewCollision(collision, false);
}

//====
//Private Functions
//====
private void ProcessConductors()
{
    if(isPowerSource)
    {
        return;
    }

    bool connectedConductorPower = false;

    foreach (Conductor c in _conductors)
    {
        if (c.isElectrified)
        {
            connectedConductorPower = true;
        }
    }

    if(connectedConductorPower)
    {
        _renderer.material = activeMaterial;
    }
    else
    {
        _renderer.material = inactiveMaterial;
    }

    isElectrified = connectedConductorPower;
}

private void CheckPowerSource()
{
    if (isPowerSource)
    {
        isElectrified = true;
        _renderer.material = activeMaterial;
    }
}

private void SetupPrivateVariables()
{
    _renderer = this.GetComponent<Renderer>();
}

private void ProcessNewCollision(Collision collision, bool doAdd)
{
    if (isPowerSource == false)
    {
        Conductor otherConductor = collision.collider.gameObject.GetComponent<Conductor>();

        if (otherConductor != null)
        {
            if (doAdd)
            {
                _conductors.Add(otherConductor);
            }
            else
            {
                _conductors.Remove(otherConductor);
            }
        }
    }
}

}

Edit: I just found this question, which is similar but I'm not sure how it would handle a disconnect.

Edit 2: I ended up going with the accepted answer and built a "pulse" into the system. Basically power sources pulse down the chain and each object passes the pulse onto the objects they are connected to. If an object doesn't receive a pulse, then it shuts off since it knows it doesn't have power. This system isn't foolproof, and for large networks would slow down the framerate but my networks aren't very large and only a small handful of networks per scene. I went with this system for the accuracy it gives and flexibility. I can have any number of power sources and the network can spider out and loopback on itself without issue.


texts: How to Structure my Database for a HTML turn-based strategy game?

texts:
I'm making simple HTML socket game that I want to record over time.

It's a "risk" type game where individual tiles can be conquered, and the team with the most tiles is winning.

As of right now, I've finished most of the game, but the problem is that every time the server restarts all the server data is lost.

I want to use the database to store all the different teams and also of all the tiles that have been conquered, but I am also thinking of storing all the tile conquerings with timestamps so I can see the progression of how the map was conquered. (so I can theoretically play it back in time and see how the map began to evolve).

I also want it so on the event that the server crashes, the server can retrieve data from the database and go back to a previous world state (with which tile has been conquered by whom, etc.)

I'm very new to databases, and have only learned SQL in school because I had to.
I was considering using MongoDB (noSQL) for this, and seeing that I will only write at most every few seconds to the board, is this the right approach?


texts: Dealing with multiple prerequisites in goal orientated action planning using A*

texts:
I'm currently having difficulty reasoning about how multiple prerequisites are satisfied using the A* algorithm during planning.

Assuming the following actions (with prerequisites in brackets):

Get Material

Make Gloves (need material)

Get Iron

Make Axe (needs iron)

And the following goal (prerequisites in brackets):

Chop Tree (needs gloves, needs axe)

Now, assuming I am doing a backward search from the goal, as I understand it, I would start considering actions that have effects that directly correspond to the prerequisites of the node (this is where I think I'm going wrong).

The problem with that is, the first 2 actions to consider are Make Gloves and Make Axe. However, for this goal to be satisfied they both need to be done. If I only build my graph by linking effects to prerequisites, I only consider each of those actions once, and only choose one.

I.e. if I arbitrarily choose Make Axe that leads me to Get Iron, I don't have anything making me reconsider Make Gloves as Get Iron has no prerequisites.

For the actions and goal I had above there are many routes to solving it, below I have highlighted one to illustrate my point. As you can see, in this case I would need Get Iron to be done after Make Gloves even though their effects/prerequisites don't match in any way.

Can someone tell me where I'm going wrong in my thinking?


texts: Check whether an object is fully inside/overlapped by other objects in Unity3D?

texts:
I have structures made of voxels (cube gameobjects), and I want to make complex structures from them.

But I don't always want to place them on the grid. I want them to be more realistic, like diagonal:

(Don't mind those visual artifacts)

(If I would want to make a fortress like this on the grid, these diagonals would be ugly and zigzaggy.)

My problem is that due to this there would be double the voxels at the overlapping places. I want to remove every cube (for example from the selected wall object) which are being FULLY overlapped.

This way there won't be double voxels (only partially at the edges, which is fine) and it would look good as well.

How could I check this? I don't want to modify the structures manually because both the angle and the other object may vary, thus one structure would need lots of variations.


texts: Encapsulating Box2D C++ two virtually the same functions

texts:
I have two functions that are virtually the same with a few small differences in code, one to create a static body and one to create a dynamic body, however if I call both of them it results in a segmentation fault, but I'm not quite sure why as far as I know I'm not trying to redefine any objects (other than bbox which is a box2d * body).

I've tried debugging it it appears the issue is caused by b2FixtureDef but I again Don't know exactly what it is, From looking at the memory somewhere there is an allocation issue as 0xfeeefeee shows up in a dump of the registers.

as long as I only use one its fine but when I use two or more it crashes.
if someone could point me in the right direction ( the code is valid 0 errors and 0 warnings so I'm not looking for handouts )

void entity::setAsPlatform(float hx, float hy, b2World world)
{
   b2BodyDef platformDef;
   platformDef.position.Set(bbox_pos.x,bbox_pos.y);
   b2Body * platform = world.CreateBody(&platformDef);
   b2PolygonShape platformShape;
   platformShape.SetAsBox(hx, hy);
   b2FixtureDef platformFixture;
   platformFixture.shape = &platformShape;
   platform->CreateFixture(&platformFixture);
   bbox = platform;
}

void entity::setAsPlayer(float hx, float hy, b2World world)
{
   b2BodyDef platformDef;
   platformDef.position.Set(bbox_pos.x,bbox_pos.y);
   platformDef.type = b2_dynamicBody;
   b2Body * platform = world.CreateBody(&platformDef);
   b2PolygonShape platformShape;
   platformShape.SetAsBox(hx, hy);
   b2FixtureDef platformFixture;
   platformFixture.shape = &platformShape;
   platform->CreateFixture(&platformFixture);
   bbox = platform;
 }

and in main.cpp

entity platform("Platform", 20, 500);
platform.setAsPlatform(2.0f, 50.0f, world);

entity player("Player", 0, 20);
player.setAsPlayer(1.0f,1.0f,world);


texts: Cocos Creator - orientation change event in native build for iPhone and Android

texts:
I am making some Hybrid app which has some native part in Both iOS and Android and common functionality (which includes and games/animation and UI) which I make in Cocos Creator.

The problem I am facing while I am trying to change the device orientaiton from Portrait to Landscape of vice-versa.

I tried to get the current frame size or get notified about the change, but no success.

Anyone face this issue? Any ideas are welcome!


texts: How to make a 2D Soft-body physics engine?

texts:
The definition of rigid body in Box2d is

  A chunk of matter that is so strong
  that the distance between any two bits
  of matter on the chunk is completely
  constant.

And this is exactly what i don't want as i would like to make 2D (maybe 3D eventually), elastic, deformable, breakable, and even sticky bodies.

What I'm hoping to get out of this community are resources that teach me the math behind how objects bend, break and interact. I don't care about the molecular or chemical properties of these objects, and often this is all I find when I try to search for how to calculate what a piece of wood, metal, rubber, goo, liquid, organic material, etc. might look like after a force is applied to it.

Also, I'm a very visual person, so diagrams and such are EXTREMELY HELPFUL for me.


texts: TCP vs. Reliable UDP? Sending Reliable Packets in Fast-paced Multiplayer Games?

texts:
I'm currently working on a networking framework for Unity3D in order to simplify making multiplayer games. I'm using UDP for any kind of synchronisation and unimportant data.

My question is: how do I send reliable packets such as RPCs or object instantiation?
Should I use TCP for that or should I go about writing my own reliable protocol on top of UDP?

Thanks in advance!


texts: Can you use other gamepass ids on your own Roblox game?

texts: I'm creating a game on Roblox and I need to know if I can use other user's gamepass ids. And if I can will they work?


texts: In a shader, what is the meaning of ".xy?"

texts:
I'm trying to research this in Unity manuals online, and I'm finding plenty of references to .xy but not sure what it is.  While this is for Unity, I'm assuming this principal is more generic across all shader systems.

When we have a float3 variable called b and we say b.xy what are we getting?

Is it X * Y?

Is it a float2, with X & Y passed through? If this is the case, I'm also seeing b.xy / a.xy and I'm wondering how vector division works in shaders.


texts: How are simple smoke trails for rockets made?

texts:
I'm trying to make a simplistic 2d shmup, simple enough to be implemented with a widget toolkit (like Qt, for example), without requiring a game engine.

Everything fits except for the smoke trails for rockets. For me, a simplistic trail without billowing smoke effects would be sufficient. Basically just a long, curved line, which will begin to slowly and smoothly fade out after a while, starting from its rear end.

They are supposed to cross most of the screen, and they can go diagonally or in a curved path. Therefore, each one having its own image in its own transparent layer would be horribly inefficient, as there should be dozens of missiles moving at the same time on the screen.

I thought of using a particle system, but it would just take too many particles to do it nicely.

My current approach is to have one big image covering the entire screen with one matrix of the same size, the cells of the matrix representing a time-to-live for its respective pixel. For example, when a missile passes over a pixel, the pixel lights up, its time-to-live is set to 255, it ticks down every frame, and if it's below 100, the brightness of the pixel will be reduced in proportion. This allows for multiple missiles at the same time, and needs only one image layer.

However, still every pixel of the screen has to be recalculated at every frame, with time wasted on lots of places where there is nothing to be done, as the total area of the smoke trails is very small in relation to the total screen area.

Are there any better methods than the one I sketched? There have been games over 20 or 30 years ago which could do this very nicely, on very primitive computers.


texts: In Game Maker Studio, how do I make a sound play only once when I jump on a block?

texts:
In my Game Maker Studio game, jumping on a musical block should play a note. Currently, if I step on it, the note keeps repeating.

How can I avoid that? I only want the note to play once.


texts: Wierd behaviour upon limiting rotation on Y-axis

texts:
Okay, this is the code that works for a FPS camera, except it allows the player to flip it over by going under/over -/+90° rotation on Y-axis:

transformation->rotateObjectFromRight(glm::radians(angleX), glm::tvec3<GLfloat>(0.0f, 1.0f, 0.0f));
transformation->rotateObjectFromLeft(glm::radians(angleY), glm::tvec3<GLfloat>(1.0f, 0.0f, 0.0f));

transformation object holds the data required to construct the view matrix, among others, a quaternion representing the rotation.

The functions called will construct the quaternion with the given data and then multiply it with the rotation quaternion either from the left (relative to global axes) or the right (relative to local axes) side.

angleX and angleY are mouse X and Y offsets representing the angles to rotate around.

The first line yaws the camera around local Y-axis, while the second then pitches it around global X-axis, creating the characteristic FPS camera movement.

Okay. So far so good. This is the code that should limit the pitch to never exceed the +/-90 boundaries:

transformation->rotateObjectFromRight(glm::radians(angleX), glm::tvec3<GLfloat>(0.0f, 1.0f, 0.0f));

glm::tvec3<GLfloat> forwardVector = glm::rotate(glm::inverse(transformation->getRotation()), glm::tvec3<GLfloat>(0.0f, 0.0f, 1.0f));
GLfloat pitchAngle = forwardVector.y * 90.0f;
angleY = glm::clamp(angleY, -(pitchAngle + 90.0f), -(pitchAngle - 90.0f));

transformation->rotateObjectFromLeft(glm::radians(angleY), glm::tvec3<GLfloat>(1.0f, 0.0f, 0.0f));

First and the last line are the same. What happens here?

First I get the unit vector that lies on the Z-axis and rotate it so that it represents the forward vector of the camera. I then take the Y component of that vector (ranging from -1 to 1) and multiply it with 90 to get the degrees. Then I clamp the angleY so that current rotation combined with the new one never exceeds the +/-90° boundary.

If the rotation was about to flip the camera overhead, it would change the new rotation angle so the camera looks straight up. Similar thing for underfoot flipping.

However, the camera acts weird. It's fastest at pitch angles close to 0°, but gets progressively slower as the pitch nears +/-90°. If I move my mouse slower, the camera is faster, if I move it faster, it's slower.

It's as though it's discarding the too large/small angleY values instead of clamping them to the appropriate values (but it's not, and I can confirm via the debugger - all the calculated values look alright and are correct).

What could be amiss here to cause such weird movement?


texts:
Stupid stupid question but here we are..

so, I want to generate some random events for an iPhone game but I guess this could be applied to any game written with a framework that suppports calls to "C" functions as I am using CCRANDOM that calls the random(void) function from the C stdlib.h.

I have written a function "verifyEvents" that I call each time I load a particular view (game scene).

To associate a probability to an event I assigned a value to each event (e.g. kill player: 0.05, give extra bonus 0.08).

In the function I generate a random number using CCRANDOM_0_1() and if the number is less than the assigned value I trigger the event (below there is the code).

Is this the best approach or do you use something else in your games?

-(void) verifyEvents
{
    float value = CCRANDOM_0_1() ;
    float eventPValue = 0.05f;

    if(value<eventPValue){
        CCLOG(@"EVENT!");
    }
}

PS: CCRANDOM_0_1() is defined as following:

#define CCRANDOM_0_1() ((random() / (float)0x7fffffff ))


texts: Use an image as mask only where pixels are opaque

texts:
We are into a game where to build our tile map, we carve on an image with a mask (At first the whole map is an image, and we create holes on it with tiles to create the map and le the background show. It is like substracting instead of adding new tiles in any common tiled based game).

We have done this with just a tile that acts as a mask using stencil buffer. The problem comes when we want to mask with tiles where all their pixels are not opaque, for example a slope. The problem is that it applies the mask as if all the pixels in tile where opaque and we want to apply the mask in two differnet ways:

1) Keep the pixels of the big image where the mask pixels are opaque

2) Mask the pixels of the big image where the mask pixels are transparent (alpha==0)

I have read a lot of info about using stencil and alpha blending but can't make it work. Checking the pipeline order it seems that stencil is applied after the fragment color has been calculated. Is it possible to access the alpha value at stencil stage and write to the stencil as needed to just mask part of the image (tile in my case).

Update to add a visual example: