texts:
I have a collision detection implemented in my game. Now I have spawning of units in a class Spawn:

public class Spawn {

    private double x;
    private double y;

    private String team;

    private String meta;

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public String getTeam() {
        return team;
    }

    public void setTeam(String team) {
        this.team = team;
    }

    public String getMeta() {
        return meta;
    }

    public void setMeta(String meta) {
        this.meta = meta;
    }

    public void spawn(AbstractActor actor) {
        actor.setPosition(new Point(x, y));

    }
}

and I call spawn() method for every unit. I have multiples spawns btw but that's not important.

However when a unit (AbstractActor) gets spawned, it's spawned on x, y. But when the second unit gets spawned it's spawned on the same location and none of these units can move (because of my collision detection implementation). AbstractActor has Point getPosition(), void setPosition(Point position), double getRadius(), which are maybe required in calculation (notice that I use radius so every unit has CircleCollider).

How would you implement spawning on different places close to the x and y. For now maximum players are 5 for one spawn but mostly 3 will be used.

Btw spawn() gets called at the beginning for every player and then if player dies after some time he respawns so the spawn() function gets called then too.

Thank You in advance for your help.


texts: What is a correct step by step logic of exporting scene with baked occlusion for loading it at runtime?

texts:
I wonder what is a correct step by step logic of exporting scene with baked occlusion (Culling data) for loading that scene at runtime (on fly from the internet for example))?

So currently my plan looks like this:

I create prefabs
Place them onto my scene (into Hierarchy) (say create 20 buffolows and some hourses and some buildings)
Create empty prefab and drag all my scene objects from hierarchy onto it
Export prefab

So generally I put all my scene objects into one large prefab and export it but it seems that all objects that were marked as static get this property turned off when loading them at runtime and so no Frustum Culling, and no Occlusion culling happens.

So I wonder what is a correct way of exporting Scene + Objects + Occlusion (and other culing) data for future load of such scene at runtime?

I wonder about current 3.5.2 Pro and future 4 Pro versions of U3D.


texts: How can I detect sprite collisions out of screen?

texts:
I am creating an Android game using andEngine library.

I have enemies coming from out of the screen into the screen. I already know how to detect collisions, but is there any method I can use to detect when my enemies (sprites) collide with another sprite before entering the screen? The sprites I want to detect the collision with are on the corners of the screen.


texts: How to give and remove authority of an object between multiple clients (Or how to let the client controller push a rigidbody)

texts:
I'm doing a cooperation FPS game in which players can push big rigidbody cubes with their rigidbody characters (the one from the standard assets).

The problem is that the player hosting the game has authority on these cubes positions and so when the client tries to push them, he really struggles and the result is 100% disappointing.

So i'm searching a way to pass authority from the server to client and vice versa when the cube is touched by a player.

I'm using Unity 2018.2

Have a nice day.


texts:
I have a DirectX11 application, which has multisampling / anti-aliasing enabled.  However, I want to add an effect that requires a render-to-texture step.  When I add this extra step, I lose all anti-aliasing.  Here's basically what I'm doing:

1) render scene to texture

2) render texture to screen (with some effect, say blurring or something).

I've tried enabling multisampling on the render texture, but i'm not sure how to get it to work.  I've made it use 8 samples and specified D3D11_DSV_DIMENSION_TEXTURE2DMS, but apparently that step required me to use Texture2DMS in the shader.  But now I don't know how to sample a Texture2DMS in the shader, because I can't just pass in the textures coordinates, I have to pass in a sample index, which I don't know how to calculate.

How to I use render to texture effects while preserving multisampling / anti-aliasing?


texts: How can I find out which Androids suffer from the Scrolling Button bug?

texts:
When developing in Unity, there is a bug where if you put a Button on a Scroll View, the scroll is hyper-sensitive on some Androids. This makes the button depress immediately after pressing it, because it thinks you are trying to scroll. This can be resolved by reducing the scroll sensitivity on the ScrollRect.

I do not want to reduce the sensitivity on all Android devices. For example, on the newer ones such as the Pixel, it works perfectly. Reducing the sensitivity actually makes it feel mildly less responsive.

How can I find out which models/operating systems that this bug exists on? I would prefer to just not release to those versions. (They are far and few between, but enough to make their 1 star reviews hurt badly.)


texts: How it the level of detail texture loading called

texts:
Borderlands 2 uses this technique:
https://www.youtube.com/watch?v=NDKOndosFAg

Some games use techniques to load textures progressively in some level of detail way.
I can not find any material on this topic or any terms.
How is it called and how is it done?


texts:
I am working on a game developed using Scenekit (iOS). I am facing some strange issues with collision physics.

I have added one 3D table (with a hole at its center) to the scene. I am setting physics shape of this 3D model using following code:

SCNBox* tableBody = [SCNBox boxWithWidth:(5*golf.scale.x) height:(0.5*golf.scale.x) length:(9*golf.scale.x) chamferRadius:0];

table.geometry = tableBody; //table geometry

//physics shape scale
NSValue *shapeScale = [NSValue valueWithSCNVector3:SCNVector3Make(table.scale.x, table.scale.y, table.scale.z)];

//physics shape options
NSDictionary *shapeOptions = [NSDictionary dictionaryWithObjectsAndKeys:shapeScale,SCNPhysicsShapeScaleKey,SCNPhysicsShapeTypeConcavePolyhedron,SCNPhysicsShapeTypeKey, nil];

//physics body
table.physicsBody = [SCNPhysicsBody bodyWithType:SCNPhysicsBodyTypeStatic shape: [SCNPhysicsShape shapeWithNode:table  options:shapeOptions]];

I am adding one 3D ball on top of this table.

Issue:
The Ball collides with 3D table mesh triangles and changes directions

Image showing 3D table's physics shape:

I have following questions:

How can I stop collision of ball with these lines?
Are there any modification to the physics can be done? I want the hole to be part of the physics shape so that the ball can fall into the hole.

I would appreciate any suggestions and thoughts on this topic. Thank you.


texts: what are the essential things to be looked upon in game design

texts:
I've made a couple of games now.

Starting from basic hobbyist projects like snake , I advanced into platform based games, board games, turn based games. While doing the latter of these projects I had to spent a lot of time redesigning certain concepts, sometimes even throwing away certain logic. So always I've felt the time wasted could have been avoided or at least reduced, if I had properly planned each and every stage of my game.

Though i can try to do it on paperwork or by a word file with bulleted points. I think there ought to be some other way of game design.

Do help me with suggestions and other game design patterns being followed, either as an indie-game developer or as a game company. I can learn from both. I am not looking for game design e-books, since there is already a thread for that. I would like to get suggestions and game design patters.
Thank you.


texts: I am a high school student taking computer science as a subject, and someone who is very interested in the game development industry. I am currently writing an essay on Raytracing and Z-buffering by comparing them and deducing the right situation for each of them. I was wondering if the developers could help me answer a question of in what specific situations those two are used specifically. I already know how both of them work. Also, do developers prefer another method than these two or is there a way to combine both to make an even more efficient 3D graphics algorithm? Thanks a lot!


texts:
I've been working on making this slash attack for my character in the unity engine. The whole point to this script is to put the damage range in sync with the slashing animation. The slash is completely horizontal and is scripted out make enemies bounce back. I have most of that but what I really need to restrict it on x axis. If I haven't explained it enough let me give you an example of what its doing. When an enemies in front of me but above the area my swing attack shouldn't be able to reach. I use my swing attack and it still does damage anyways. what I need is a way is restrict my hit detection range between two angles rolling around the x axis. I'm sorry if I didn't explain this so well just tell me if I need to make something more clear.

this is the code I've come up with what I've got it doings is it applies damage it can tell if an enemy is in front of it (uses the dot product for that) it can even knock said enemy backwards

void Knockback(){

     Vector3 grenadeOrigin = transform.position; // I'm building this controller using explode for knock back
// and this stuff was based off of a grenade script
     Collider[] colliders = Physics.OverlapSphere (grenadeOrigin, radius);
     foreach (Collider hit in colliders){
         Rigidbody rb = hit.GetComponent<Rigidbody>();
         if (rb){
             Vector3 dir = (rb.transform.position - transform.position).normalized;
             float direction = Vector3.Dot(dir, transform.forward);
             Debug.Log(direction);
             if (direction >0.1){// this is where i tell if something is in front of me
                 rb.AddExplosionForce(power, grenadeOrigin, radius, 0);
                 //This is where we apply force to our enemy and various other rigid bodies
                 hit.gameObject.SendMessage("Damager", Damage, SendMessageOptions.DontRequireReceiver);
                 //This is where we apply damage to the enemy
             }
         }
     }
 }


texts: Pressing two on-screen buttons at the same time, with the same touch - Android Unity Event-Triggers

texts:
OK so I have this code working and the methods are being called at the times I'd expected (ie. when the mouse hovers over the button and stops hovering over it)

But when I test it on an Android device, it is not possible to press both buttons at once. The only button that gets pressed is the one where the touch-down happened.

 public class EventHandlerThrust : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
 {
 public static EventHandlerThrust instanceOf;

 [HideInInspector] public bool isButtonPressed = false;

 void Start()
 {
     instanceOf = this;

 }

 public void OnPointerEnter(PointerEventData eventData)
 {
     isButtonPressed = true;
     Debug.Log("OnPointerEnter Interfaceyyyy called.");
 }

 public void OnPointerExit(PointerEventData eventData)
 {
     isButtonPressed = false;
     Debug.Log("OnPointerExit Interfaceyyyy called.");
 }
 }

So is it possible to allow the user to press both buttons by holding his thumb over both at the same time, using the Event Trigger System? Or do I have to implement some other kind of Input system?


texts:
I am currently learning C# with Unity 2D but I have come across an issue after following a tutorial.

I am trying to get my camera to follow my player within the game but also to get my background looping so I dont have to have it miles long. I have added a boxcollider2D to outside left edge of the camera to pick up the background and then loop it to the right hand side before the camera gets there but for some reason it chucks it quite far to the right so I have areas with nothing showing but the player.

The only difference from the tutorial is that he was using 6 panels of background/ground whereas I am only using 1 big background sprite and 1 long ground sprite.

Heres my code for my looper;

public class BGLooper : MonoBehaviour {

    int numBGPanels = 2;

    void OnTriggerEnter2D(Collider2D collider){

        float widthOfBGObject = ((BoxCollider2D)collider).size.x;

        Vector3 pos = collider.transform.position;

        pos.x += widthOfBGObject * numBGPanels - widthOfBGObject / 4f;

        collider.transform.position = pos;

    }
}

Please help me so I can carry on creating my game :)


texts: Fragments never falling into spot light's cone

texts:
I am using GLSL version 1.20 with OpenGL 2.1 .

I am trying to compute when a fragment falls into the area of a spot light. I have already set all the light values with glLightfv and glLightf, also the material. This is how I initialize the spot direction and spot cutoff:

float spotCutoff= 5.0;
vector<GLfloat> spotDirection= vector<GLfloat>{0,0,0,1};
// I use [0,0,0,1] because the object is in the [0,0,0] position
// but I also have tried (in vain) many other values.
glLightfv(GL_LIGHT0,GL_SPOT_DIRECTION,spotDirection.data());
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,spotCutoff);

In the fragment shader I use a function to know if the fragment is inside this cone:

bool isRayInsideCone(vec3 Light)
{
    // Light is taken from the vertex shader and normalized.
    // It is exactly computed as normalize(lightPos - eyePos)
    // With lightPos= gl_LightSource[0].position.xyz ,
    // and eyePos= gl_ModelViewMatrix * gl_Vertex (re-normalized in
    // the fragment shader).
    vec3 D= normalize(gl_LightSource[0].spotDirection);
    return dot(-Light,D) > gl_LightSource[0].spotCutoff;
}

But the problem is that this function returns false for every fragment. I can test this by just doing something like this:

if(isRayInsideCone(Light))
{
    gl_FragColor= some_color;
}
else
{
    gl_FragColor= other_color;
}

I just guess what I'm doing of wrong.


texts: How do I move my infinite runner player when the game zone shares the screen with a match 3 game?

texts:
So I am seeking to make a Match 3 with an infinite runner element. The match 3 portions are all already totally done, but I'm running into trouble figuring out how to best approach the Runner portion.

I'm not entirely new to Unity, but I'm newer, though I'm not new to programming.
This is what the game generally looks like:

(Source)

My problem is I am unsure the best way to do the movement. My immediate thought was, I should have the player run in place, and the world move around him, so that the camera and the match 3 portion don't have to have any movement.

Is there another option that is simple that I'm over looking? Following the player as he moved seems like it would be really weird for the match 3 dots, as the camera is flying off into the X along with the player, and keeping the dots up with them sounds like it would be more trouble than its worth.

Any help is appreciated, thanks!


texts:
I've been playing around with VBOs as of late (mostly because my game necessitates it), and I've found the need to add new vertices to a VBO, but not necessarily at the end. The game in question is a Terraria port, and when a player updates the world, the VBO needs to be updated. Up until now, I've been using glBufferData() to update the array, but it's time I switch to glBufferSubdata() or glMapBuffer() I'd like to be able to update a certain "chunk" of the world when a block in it is modified, but this could potentially result in adding more or less vertices than are already in the appropriate memory section. If a player places a "block," more memory would need to be allocated, resulting in any proceeding vertices being shifted over x indices. My only thought would be to allocate enough memory for each chunk to be completely filled with blocks, but I haven't yet found a way to do that. Would anyone be able to point me in the right direction?

EDIT: To clarify, pushing new VBO data to the graphics card (which is what causes the lag spike) takes 11-12ms the first couple of times, and 1-4 every time after. This also raises the question: why does the graphics card seemingly need to be "broken in?" In other words, why is there such a huge delay at first?


texts:
I'm making a game similar to Dwarf Fortress and I've run into a large problem from the start. How can you store such a large amount of land on disk. With every voxel holding an integer with the 28 MSB representing its type and the 8 LSB having flags like transparency or if it can be walked through a world similar to dwarf fortress would take up almost 18 000 GB. chunks(16 X 16 X 256 voxels) regions(64 X 64 chunks) and world(128 X 128 regions).

I know about Run Length Encoding which could save a lot of memory but its unpredictable because I don't know how many different block types there will be. However it will definitely use less memory so I will use it. I also thought that if I use Perlin Noise for everything I could regenerate everything from scratch if the player came close and only store the areas the player changed (and maybe towns because regenerating them could be time consuming) so I could definitely save a lot of memory there.

I read that Dwarf Fortress doesn't use Perlin Noise or anything like that, and it seems that it generates the whole map at once and saves it with data like erosion from rivers. Can anyone suggest another method that I could use to store a map as much expansive as the one in dwarf fortress?

Ok so it thought of a way to store rivers erosion, as a heightmap of subtractions to the terrain height and only store the heightmap of chunks that have rivers and also use run length encoding, then generate everything else that the player didn't change each time.


texts: How to duplicate Blender glow and reflection effects in Unity?

texts:
I am trying to make my game more interesting by making a background with this NEON tunnel made of glowing lines.

Since I am not a good 3D artist, I choose to hire some freelancers, and they made a model that looks great in Blender. I have all that I need...but when I import my object into Unity, it does not have any effects, any colors, any glow or any "mirror" reflection.

The biggest problem is that I cannot find any other freelancer who actually knows how to fix this problem.

This is how it shows up in Blender when my freelancers made it, and it looks perfect:

I want to have the same effects, same look, same colors, same glow in my Unity project, but I don't know how to actually import this object and reproduce that same look.

This is all zip folder which contain pictures, object in blender file, same object in .fbx,.obj.mtl and in many more formats.. but seems like any of those models doesn't work in Unity because I bet Unity needs more modifications...

I hope someone will help me step by step to achieve my goal.


texts: Robust line of sight test on the inside of a polygon with tolerance

texts:
Foreword

This is a followup to this question and the main problem I'm trying to solve. My current solution is an hack which involves inflating the polygon, and doing most calculations on the inflated polygon instead. My goal is to remove this step completely, and correctly solve the problem with calculations only.

Problem

  Given a concave polygon and treating all of its edges as if they were
  walls in a level, determine whether two points A and B are in line of
  sight of each other, while accounting for some degree of floating point errors.

I'm currently basing my solution on a series of line-segment interection tests. In other words:

If any of the end points are outside the polygon, they are not in line of sight.
If both end points are inside the polygon, and the line segment from A to B crosses any of the edges from the polygon, then they are not in line of sight.
If both end points are inside the polygon, and the line segment from A to B does not cross any of the edges from the polygon, then they are in line of sight.

But the problem is dealing correctly with all the edge cases. In particular, it must be able to deal with all the situations depicted below, where red lines are examples that should be rejected, and green lines are examples that should be accepted. I probably missed a few other situations, such as when the line segment from A to B is colinear with an edge, but one of the end points is outside the polygon.

One point of particular interest is the difference between 1 and 9. In both cases, both end points are vertices of the polygon, and there are no edges being intersected, but 1 should be rejected while 9 should be accepted. How to distinguish these two? I could check some middle point within the segment to see if it falls inside or not, but it's easy to come up with situations in which it would fail.

Point 7 was also pretty tricky and I had to to treat it as a special case, which checks if two points are adjacent vertices of the polygon directly. But there are also other chances of line segments being col linear with the edges of the polygon, and I'm still not entirely sure how I should handle those cases.

Is there any well known solution to this problem?


texts: Getting position of finger along a screen

texts:
I'm trying to get a list of Vector2 position by tracking my finger and then tracing them with a prefab (Basically just gestures). I have appended an onGUI function to help print out the list of vectors.

However, the attached code does not work and only prints "System.collection.Generic.List'1[UnityEngine.Vector2] when my finger moves along the screen.
I know I'm missing something; any help would be greatly appreciated.

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

public class line : MonoBehaviour
{

    List<Vector2> movePos = new List<Vector2>();
    private float lastFingerRelease;
    public String printer;

    void Start()
    {

    }

    void Update()
    {

        if (Input.touchCount > 0)
        {

            Touch touch = Input.GetTouch(0);

            if(touch.phase == TouchPhase.Began && Time.time - lastFingerRelease > 2)
            {

                printer = movePos.ToString();

                movePos.Clear();
            }

            else if (touch.phase == TouchPhase.Ended)
            {
                lastFingerRelease = Time.time;
            }

            movePos.Add(touch.position);
        }

    }

   void OnGUI()
    {
        GUI.Label(new Rect(0, 0, 1000, 1000), printer);
    }

}


texts: How can I rotate a cylinder so the top points at specific transform?

texts:
I have a GameObject (goA) with a LineRenderer that has a single line drawn, on which I'd like to place cylinders so the top of the cylinder points to each end of the straight line that the cylinder sits on, (similar to a cylindrical bead on a straight piece of string, or a Candlestick chart).

The cylinder GameObject (goB) is a child of the goA which the LineRenderer is sat on (goB.transform.parent == goA.transform).

goA is not rotated itself, and the Line drawn could be any angle relative to the GameObject, and it would be a bit of a hassle to refactor so that the Line is always vertical and instead rotate goA, and it seems this should be an easily solvable problem!

I'm attempting to use either LookRotation or LookAt on the cylinder but for whatever reason all permutations I can think of simply are not working.

Thanks for any advice!


texts: Having trouble with btGeometryUtil::isPointInsidePlanes

texts:
I'm in the process of parsing a BSP file to create btConvexHullShape objects for each brush. I've seen a few examples of how to do this on Github and they all use the getVerticesFromPlaneEquations function. This function in turn uses isPointInsidePlanes. The problem I'm having is that isPointInsidePlanes returns false for every potentialVertex, leaving me with an empty verticesOut array.

I'm looking at the code for isPointInsidePlanes, and it seems like it is checking the vertex against ALL planes in the brush which I find confusing.

For example if the brush is a simple rectangular prism, you wouldn't expect the point that results from the intersection of 3 planes to be inside all 6 planes, right? Shouldn't it only be checked against the 3 planes that intersected to locate it?

Now this file hasn't changed in 9 years, so either I'm doing something very wrong or nobody uses this function. I'm going to assume I'm wrong for the time being.

TL;DR: Why does isPointInsidePlanes check the point against every plane equation and not just the 3 that intersect to create it? Should I not even be using the getVerticesFromPlaneEquations function and instead be using something else?

EDIT: Added link to code

Here is a link to the relevant source file:
https://github.com/bulletphysics/bullet3/blob/master/src/LinearMath/btGeometryUtil.cpp

Specifically, on line 175, the planeEquations array is passed to isPointInsidePlanes which then compares the point against every plane in the array.


texts: Monogame project runs in VS but hangs when run via .exe

texts:
I've been working on a monogame project for a little over a week and had no problems. Today I went to test out the project outside of Visual Studio, by running directly from the .exe in the release folder. When I click on the .exe I get the cursor icon indicating something is loading, but nothing ever does. No window shows up, even though I see processes related to my game in the task manager. Also when I try to end mygame.exe in the taskmanager it doesn't work and the process still sits there.

I've tried both a Windows and Windows OpenGL monogame project and both hang once I click the exe. Does anyone have any idea why this may be or any steps I might take to track down the issue?

I'm using Windows 7, Visual Studio Community 2015 and the latest Monogame Build. My project references Farseer Physics, Lidgren, Json .Net, and my own Utility class library.

Edit: I tried creating a brand new Monogame project and run it without debugging in VS and it hangs the same way running from the .exe does. Also the project runs when placed on my laptop which also has monogame installed so it's nothing wrong with the project.


texts: Is it possible to have vehicles with physics like GTA in an MMO game?

texts:
I haven't seen any MMO games with vehicles with realistic physics and that could achieve high speed, why? Is it because of network bandwidth limitations?

Second Life has vehicles, but physics are poor and max speed is pathetic.


texts:
I want to make something already done by a lot of games , which is when I am taking so much hits from enemy red screen drawn like the following  , using XNA 4.0:

after it's drawn and I am still alive I want to be removed slightly as in the call of duty !!!


texts: Why do computer games differ so much in size?

texts:
There are alot of PC games out there that have (seemingly) roughly the same graphics (with bump-maps, shaders, etc), sound complexity and play-through time yet one of them needs 4GB space while the other 13GB.

Why is that? Why to they differ so much in size?


texts: How can I improve my touch slide mechanic to be more smooth and fluid?

texts:
I have the following C# code, but it leaves me with two problems:

void FixedUpdate()
{
    if (Input.touchCount == 1)
    {
        this.transform.Translate(Input.touches[0].deltaPosition.x * 0.009f, 0, 0);
    }
}

Firstly, the gameobject (which is a sphere in my case), has a tendency to leave the ground and fly into the air. Additionally, it is not as smooth and snappy but fluid as I would like it to be.

If you look at some of the following gameplay videos, you will see the kind of movement I am looking for.

"Splashy!" Gameplay
"Sky Ball" Gameplay
"Balls Race" Gameplay

More specifically, from actually playing each of the above games, there is a certain "ratio" that seems to be operating in regards to each swipe gesture and the actual movement of the ball. That is, the ball does not go exactly where the finger goes, for it is slightly ahead, if that makes sense. What I mean is, the device is only so wide, yet for that width, the ball can always reach it's required destination on either end of the horizontal axis. This must mean that for every pixel the finger moves, the ball moves a little bit more to fit that pixel density of the screen. In other words, in the case of "Splashy!", it's clear that even if the finger moves the entire distance across the screen, the ball moves more than double that distance.

By "smooth", "fluid", and "snappy", I mean that the swiping gesture is very responsive. It moves where you want it to and does not over or undershoot. Additionally, the "snappy" effect is present when you stop swiping. The ball seems to "snap" into it's end position.

My question, then, is what is the best way to improve my script as to achieve the polished mechanic I am looking for, as is depicted in the above videos? Also, how can I keep the sphere on the ground without constraining any axes on the rigidbody? I am using Unity3D with C#.

I would appreciate any help you could provide. Thank you.


texts: Cannot build project for Xbox, using XNA

texts:
I'm trying to build a project for Xbox, and when I try to Package as an XNA Creator's Club Game I receive the following errors:

The best overloaded method match for 'Pong.MessageBoxScreen.MessageBoxScreen(Microsoft.Xna.Framework.Game, string)' has some invalid arguments.

Argument 1: cannot convert from 'string' to 'Microsoft.Xna.Framework.Game'

Argument 2: cannot convert from 'bool' to 'string'

        /// <summary>
    /// Event handler for when the Unlock Game menu entry is selected.
    /// </summary>
    void UnlockMenuEntrySelected(object sender, PlayerIndexEventArgs e)
    {
 #if XBOX
        try
        {
            Guide.ShowMarketplace(e.PlayerIndex);
        }
        catch (GamerPrivilegeException gamerPrivilegeException)
        {
            const string message = "Please use Xbox Live account.";

            MessageBoxScreen promptForPurchase = new MessageBoxScreen(message, false);
            ScreenManager.AddScreen(promptForPurchase, e.PlayerIndex);
        }
 #else
        const string message = "Unlock Full Game (Xbox Only)";
        MessageBoxScreen unlockMessageBox = new MessageBoxScreen(Game, message,      false);
        ScreenManager.AddScreen(unlockMessageBox, e.PlayerIndex);

 #endif
    }

Everything within the #if XBOX area is grayed out, I suppose because it is surrounded by that tag.

What do you think is suddenly causing these issues, and how can I correct it?


texts:
I am trying to learn pygame.
In order to do that, I have downloaded one of their examples :

http://rpg-world.googlecode.com/files/rpg-world-src-0.93.tar.gz

And started to run it in debug mode.

However, I have discovered quite quickly that unlike a classic program, it is hard to debug a computer game, because of the fact that it is hard to control the player by sending keyboard press events.

Any suggestions?


texts: Move and rotate one object to another C++ [3D]

texts:
I have two object, need attach 'TWO OBJECT' to 'ONE OBJECT'.

I have vectors 'angle' 'origin' of ONE and TWO objects.

I tried do "TWOOBJECT.origin += ONE.origin - ONE.oldorigin", this just attach coordinates, but not rotate with one object....


texts: Visual Studio 2010 C++ & OpenGL project cannot detect .lib files

texts:
So I'm trying to start a C++, OpenGL project on Visual Studio 2010, and I have put glut.h and glut32.dll in the project directory, along with the glut.dll and glut32.lib files in a folder named "glut" in the project directory.

I have also gone to "Porject Properties -> Linker -> Input -> Additional dependencies" and I have typed in "glut32.lib" at the end, and made sure I am not missing a semicolon.

when I try doing

#include "glut.h"

in the Main.cpp file, it complains

error LNK1104: cannot open file 'glut32.libkernel32.lib'

Am I missing any files? What am I doing wrong here?


texts:
I am having some problems with some vector math.

Imagine a square and coming from each corner of the square is an invisible vector, which starts at the square's centre and ends at the edge of the screen.

   \          /
    \   a    /
     \______/
     |      |
  d  |      | b
     |______|
    /        \
   /    c     \
  /            \
THIS IS A VERY CRUDE IMAGE AND THE ANGLES OF THE VECTORS ARE NOT EQUAL

There are 4 areas: a, b, c and d

I would like to say that if you touch within one of the areas then something happens.

Is there a simple way to do this?


texts: Dealing with sprite loading and setting in an entity-component system

texts:
I've just started using an entity-component system for the first time and I'm having trouble making some decisions.

Currently I've got a SpriteComponent that holds a sprite, a ContentManagerComponents that holds an instance of a content manager so systems can load the content they need, and a SpriteSystem that requires both components and only has a method to set the sprite, possibly loading it beforehand (sprite rendering and animating is taken care of by other systems).

This kinda looks good, but my main concern is... how is a system that's not SpriteSystem supposed to set the sprite?

Here are my options, as I see them:

Have systems that need to change the sprite comunicate with SpriteSystem somehow. Probably a bad idea since it introduces a dependency between systems (?).
Move the method to set the sprite to SpriteComponent. Problem is, the method needs a content manager to load the sprite if needed.
Get rid of ContentManagerComponent and give SpriteComponent a content manager. But the content manager doesn't only load sprites.

Any help is appreciated.


texts:
I am looking for ways to improve my traffic AI for endless racing game.

Currently, I have hard coded situations where randomly cars will be spawned ahead of user bike depending on position of player.

The thing most bothering me is how to provide user challenging situations where he will feel fun to play. Good example of such AI can be found here,
https://www.youtube.com/watch?v=CJozc6PA9lI

What are the ways you guys would go on implementing Traffic AI for endless racing? What's your suggestion on same.


texts: Game object appears to accelerate too slowly

texts:
thank you for checking out my issue! I am trying to develop a game in java, but I have run into a problem. I would like to keep the physics as realistic as possible, so I am using a fixed time-step and 2D vectors to apply the force of gravity to a square. However, when I run the game it appears that the square is accelerating way to slowly. It could be that my physics concepts are flawed but I am pretty positive that my vector math is accurate, so I am having trouble finding the root of the problem. Hopefully I am not completely crazy and simply wasting your time, all help is very much appreciated.

Here is the main game loop:

private static void startLoops() {
    double targetFPS = 60.0;
    double targetUpdates = 60.0;

    //  accumulators for update/render
    double updateTime = 0.0;
    double renderTime = 0.0;

    //  variable to compare to accumulated cycle time
    //  desired time between updates in nanoseconds
    double targetDelta = 1000000000/targetUpdates;
    // desired time between frames in nanoseconds
    double targetFrame = 1000000000/targetFPS;

    // start time of the cycle
    double startTime = System.nanoTime();

    int updCount = 0;
    int frameCount = 0;
    double lastTime = System.nanoTime();

    while(shouldRun) {
        double curTime = System.nanoTime();
        //  end time of the previous cycle
        double cycleTime = curTime - startTime;
        startTime = curTime;

        updateTime += cycleTime;
        renderTime += cycleTime;

        //  input is checked every cycle
        cWrangler.updateInput();

        //  starts updating if enough time has passed
        //  while loop in case 2 full time-steps are accumulated
        while (updateTime > targetDelta) {
            double deltaTime = 1.0/60.0;

            //  do any updating here
            cWrangler.update(deltaTime);

            updCount++;

            updateTime -= targetDelta;
        }

        //  starts rendering if enough time has passed
        while (renderTime > targetFrame) {
            //  do any rendering here
            cWrangler.render();

            frameCount++;
            renderTime -= targetFrame;
        }

        if(curTime - lastTime >= 1000000000) {
            System.out.println("Frames: " + frameCount + ", Updates: " + updCount);
            lastTime = curTime;
            frameCount = 0;
            updCount = 0;
        }
    }
}

Please let me know if this question has been asked elsewhere. I am having trouble searching for a solution to my problem because I can't figure out the cause. Also, feel free to direct me to any resources you my think are helpful.
Thanks again for taking some time to read through this!


texts: glsl directional light specular seems to be relative to origin not camera

texts:
I've been using the LearnOpenGL tutorials to calculate directional light. The diffuse works perfectly fine but the specular seems only work properly when the camera is near the origin and the specular is applied the same to all objects.

When I look at the second to last object i expect the specular to be the same as the object around the origin but instead it seems reacts to the origin and not the camera.

My guess is it's something to do with converting something to model space instead of camera space but as i'm new to glsl i'm lost as to where to look first.

Vertex shader:

#version 330 core

layout (location = 0) in vec3 vertexPosition;
layout (location = 1) in vec2 vertexUV;
layout (location = 2) in vec3 vertexNormal;

out vec3 VectorWorldPosition;
out vec2 UV;
out vec3 Normal_cameraspace;

uniform mat4 MVP;
uniform mat4 V;
uniform mat4 M;

void main()
{
    gl_Position = MVP * vec4(vertexPosition, 1.0f);

    VectorWorldPosition = (M * vec4(vertexPosition, 1.0f)).xyz;

    Normal_cameraspace = vertexNormal;//(M*V* vec4(vertexNormal, 1.0f)).xyz;

    UV = vertexUV;
}

Fragment Shader:

#version 330 core

in vec3 vertexWorldPosition;
in vec2 UV;
in vec3 Normal_cameraspace;

out vec4 color;

struct DirectionalLight{
    vec3 position;
    vec3 ambient;
    vec3 diffuse;
    vec3 specular;
};

struct Material{
    sampler2D diffuse;
    sampler2D specular;
    float shininess;
};

uniform DirectionalLight dirLight;
uniform Material material;

uniform vec3 viewPos;

vec3 CalcDirectionalLight(DirectionalLight light, vec3 normal, vec3 viewDir);

void main()
{
    vec3 output = vec3(0.0f);

    vec3 norm = normalize(Normal_cameraspace);

    vec3 viewDir = normalize(viewPos - vertexWorldPosition);

    output += CalcDirectionalLight(dirLight, norm, viewDir);

    color = vec4(output, 1.0f);
}

vec3 CalcDirectionalLight(DirectionalLight light, vec3 normal, vec3 viewDir)
{
    vec3 lightDirection = normalize(light.position);

    float diff = clamp(dot(normal, lightDirection), 0.0, 1.0);

    vec3 reflectDir = reflect(-lightDirection, normal);

    float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);

    vec3 ambient = light.ambient * vec3(texture(material.diffuse, UV));
    vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, UV));
    vec3 specular = light.specular * spec * vec3(texture(material.specular, UV));

    return (ambient + diffuse + specular);
}

I'm using light position here when the tutorial asks to use direction. My thinking is that relative to the origin, position will be equal to direction. This works fine for diffuse so it should it work for specular.


texts: Giving a Bomberman AI intelligent bomb placement

texts:
I'm trying to implement an AI algorithm for Bomberman. Currently I have a working but not very smart rudimentary implementation (the current AI is overzealous in placing bombs).

This is the first AI I've ever tried implementing and I'm a bit stuck. The more sophisticated algorithms I have in mind (the ones that I expect to make better decisions) are too convoluted to be good solutions.

What general tips do you have for implementing a Bomberman AI? Are there radically different approaches for making the bot either more defensive or offensive?

Edit: Current algorithm

My current algorithm goes something like this (pseudo-code):

1) Try to place a bomb and then find a cell that is safe from all the bombs, including the one that you just placed. To find that cell, iterate over the four directions; if you can find any safe divergent cell and reach it in time (eg. if the direction is up or down, look for a cell that is found to the left or right of this path), then it's safe to place a bomb and move in that direction.

2) If you can't find and safe divergent cells, try NOT placing a bomb and look again. This time you'll only need to look for a safe cell in only one direction (you don't have to diverge from it).

3) If you still can't find a safe cell, don't do anything.

for $(direction) in (up, down, left, right):
    place bomb at current location
    if (can find and reach divergent safe cell in current $(direction)):
        bomb = true
        move = $(direction)
        return

for $(direction) in (up, down, left, right):
    do not place bomb at current location
    if (any safe cell in the current $(direction)):
        bomb = false
        move = $(direction)
        return

else:
    bomb = false
    move = stay_put

This algorithm makes the bot very trigger-happy (it'll place bombs very frequently). It doesn't kill itself, but it does have a habit of making itself vulnerable by going into dead ends where it can be blocked and killed by the other players.

Do you have any suggestions on how I might improve this algorithm? Or maybe I should try something completely different?

One of the problems with this algorithm is that it tends to leave the bot with very few (frequently just one) safe cells on which it can stand. This is because the bot leaves a trail of bombs behind it, as long as it doesn't kill itself.

However, leaving a trail of bombs behind leaves few places where you can hide. If one of the other players or bots decide to place a bomb somewhere near you, it often happens that you have no place to hide and you die.

I need a better way to decide when to place bombs.


texts: Managing large amounts of data and processes for an economy management game

texts:
I'm making a management game in the vein of Anno or Stellaris, but I'm unsure how to manage all my data efficiently.

Short example: the player controls multiple islands. Each island has factories on it. A factory has inputs, a process that does something with the inputs, and outputs. The process depends on the inputs and the outputs and other parameters. The outputs could be another factories input. A factory needs human workers. Human workers have stamina ... ... ...

So the question is: how do you manage so much data and processes programmatically? And it's not only about running many processes simultaneously, they also depend on each other and the data, use each other, inform each other - on each tick. You also need the ability to get information out of those sub processes and put data into it at any time.

I'm struggling to come up with a system/codebase that could handle those things. I've choose C#/dotnet core since I assume it has something to do with threading, but I still haven't got anything that works.


texts:
So, listening to this very smart piece of advice, I've already completed a basic Tetris game. Moving on, I started a small breakout. But suddenly : a nightmare came. Collisions.

Since I've been struggling with this a lot, I read a bunch of article of the web. Being a beginner, I thought that, in the first approach, I would only use Rectangle to detect collisions.

Right.

Now I still have some problems.

First of all, all the articles I stumbled upon on the Internet told me how to detect collisions, e.g. checking if objects A and B collided with each other. But it is not what I really need. In order to respond properly, I need to tell my objects if the collision happened on the X or Y axis and then setting the new velocity according to some rules. The problem is that there are so many possibilities when making the distinction between types of collisions that I don't think I've taken the right path.

The second point (which, I believe, is really tied with the first) is the pattern in which the detection and the resolution of a collision happen.
Right now, I have a CollidableObject classes and a CollisionDetector classes which knows about these objects. Each frame, the detector is looking for collision (or at least for me, is trying) and when he finds one, it alerts each collided object, saying "Hey you ! You've have collided with Z on the X axis, change that velocity now." and the object abides.

The main issue right now is that I can detect the collision axis and therefore, when saying "Hey you ! You collided !", I cannot respond properly. In which direction should my velocity change ?

I've been thinking a lot about this lately, trying to figure it out on my own, but I haven't find something that I liked so I am asking here now.

Thank you for your answers !

(Note : I don't know if this is relevant, but I'm coding in C++ using SDL)


texts: Entity Component System: Retrieving components quickly

texts:
Possible Duplicate:
  Retrieving components from game objects (entities)

I'm working on an entity-component-system game at the moment. I've looked in particular at the Artemis framework and a c# port of it but I am writing my own implementation of the pattern.
http://gamadu.com/artemis/manual.html

I'm puzzled as to how components are retrieved from the EntityManager.
As far as I can tell I have two options:

Assign each type of component a static ID, that is used as the index of the component (my entities are held as EntityComponent[entityID][componentIndex]) but I'm concerned that in a situation where an entity has a component of ID 9, that I will then have size the array to 10 and have 9 empty elements preceding the sole component, consuming memory unnecessarily.
Alternatively I could write a generic method e.g EntityManager.GetComponent(int entityID)
but this would require a look up or OfType<> call against the entities components.

Surely there is a more efficient way. What am I missing?
Artemis includes a ComponentMapper class but I struggle to understand what it does.
I want to ensure the basics of the system work as efficiently as possible.
Many thanks in advance for any feedback.


texts: Deferring royalties for assets until revenue is earned

texts:
I am developing a game and I want to use some assets that are available online for a fixed price, I want to sell my game and actually make money off of it. I have contacted the owners and they will sell it to me for a fixed price to use commercially. However, I am on a very limited budget and don't really want to pay up front for the assets.

What I want to know is how to defer the costs contingent on whether I make any money. In other words, they give me the models, and then I promise to pay them back out of the first revenue. If the project dies, I'm  not out any money.

Other than my word as an honest guy, how could I convince them to agree to this? Would they charge me more because of risk involved?


texts: Acceptable sound quality: stereo needed for an Android game?

texts:
I have various simple short sound effects (damage sound, dying sound, thunderbolt, fanfare, breaking) for a game that is developed for Android currently.

I use OGG files: 96kbps VBR, 44.1KHz, 2 channels (that means stereo, right?).

I read the other stackexchange topics about "acceptable sound quality", but they're too general, address too many things. My experience is that even with 80kbps, my effects sound OK. But I tested it on a limited number of Android devices (including a Sony Ericsson Xperia Neo and a HTC Desire HD). My questions:

For mobile phones and tablets, generally, what parameters are recommended? Won't my 80kbps sounds be bad on a newer device (such as a modern tablet)?
I don't hear any difference between stereo and mono (2 channels vs. 1 channel, right?), is there any noticeable difference at all for mobile phones / tablets? (in terms of the player experience) May it worth it at all? I assume that stereo sounds take much more in memory (when they're decoded to PCM), despite of the fact that the compressed OGG size is practically the same.

Reacting to Roy T.'s great comment:

Actually, I couldn't measure the PCM size (Android decodes OGG
internally), but I thought that stereo will take more space than
mono when uncompressed
After throwing out one of the WAV channels in Audacity, and re-exporting it:

The new WAV file size is half than before
The OGG file size is practically the same as before

The sound effects and game music was recorded by my friend who is an experienced hobby musician/composer, but he knows little about computers & software so he just gave me some high-quality WAV files generated via his hardware.These were stereo, but if I check them in Audacity, both channels appear to be exactly the same.Can I consider them the same (=> moving to mono), or might there be some unnoticeable differences to the human eye?


texts: How best to detect device performance capabilities and set quality setting accordingly when using Unity

texts:
I am developing a Mobile game for Android and iOS on Unity.

Currently Im in the optimisation stage of development and trying to work out what is the best way to detect device capabilities, with the aim of then setting an appropriate quality setting.

OS/platform detection is simple, but how can I detect between a high performance android device and a low or medium performance device at runtime?

I did find this question that is similar https://stackoverflow.com/q/21565468/4148676 but the question is old, the answers not great and hoping there's a better way in the last 4 years of solving the problem.

The only other solution I have is monitor the average FPS and adjust the quality based on the frame rate.

Any advice would be appreciated.


texts:
I am trying to load textures from a different thread but it fails everytime on this following method:

D3DX10CreateShaderResourceViewFromFile

Turning off my multithreaded routines make the textures load correctly.

How do I allow the device to load from a texture from a different thread?


texts: I have a pproblem with materials and their texture. I have a model with 1 material called 'Car_Jack', after i put my .blend file into unity, unity adds 'Car_Jack__Car_Jack_UV', which is white material without textures. I have the only one UV map, called 'Car_Jack_UV'. What is wrong with Unity/Blender?


texts: Is it possible to physically locate a game console?

texts: In theory, is it possible to locate an Internet-connected console?  After all, Google Maps can find my computer's location.  Can a console connected to the Internet be found in the same or a different way?


texts: Multiple, independent animations for one character

texts:
I'm using XNA, and I'm well versed with the skinnedModel sample. I'm starting to make my own models and animations. I'd like to be able to take animations that apply to different, independent body parts and combine them.  For example:

Let's say I have some animations for my characters body:

running
walking
standing

I also have some animations for my characters face:

frowning
smiling

Ideally, I'd like my character to have any facial expression when doing any action. So, they could be:

walking while smiling.
walking while frowning.
running while smiling.
running while frowning
... and so on ...

However, I'm not sure how I should best manage this.  I know that I could make N*M different animations (where N is the number of body animations and M is the number of face animations) and import them all, but this seems like a lot of work as the number of animations starts to increase.

If anyone has a smart way to handle this, I'd love to hear it.


texts: How to instantiate cubes at every given positions


texts:
I'm studying Unity3d, coming from a 2d background, and I'm a bit confused how some things work.

I'd like to slide a non-kinematic rigidbody, i.e. "just move it forward", like if it was hovering over the terrain. Applying a force makes a ball rotate forward, while I wanted it to slide forward without rotating, also unless that force is huge, a cube just won't move (for the same reason).

I understand there are kinematic objects which are "easier" to "just move", but I both think I might really need non-kinematic ones, and I think I need to understand them anyway.

edit: I did try to use some "rotation constraints/freeze", but they just prevented the sphere from moving at all.


texts:
I have created a minimap for my top-down Shooter and it is showed on the top-left corner of the window. The problem is that if I press anywhere upon the minimap, its like pressing somewhere on the normal game as I have used views to make it. Is there any way to make the minimap inactive?

Thanks in advance.


texts: "The server isn't currently responsive" error when trying to log into Unity Hub

texts:
I had reinstalled Unity and Unity Hub to fix package manager error, and when I try to log into Unity Hub after it installs, i get the following error

"The server is currently unresponsive"

I tried to log in through both Google and facebook, but it didn't work (i created my account through those methods)

How do i fix this?


texts: Calculating the bouncing ball bounce height while on platforms

texts:
I tried to calculate the bounce height for the bouncing ball however it ends up shaking against the moving platform after it finishes bouncing. grav_val in this case is 0.1872 to prevent it to shake from normal surfaces after it finishes bouncing as a temporary fix.
yspeed = -max(0,(rounding(abs((yspeed + platform) / 2) - (grav_val) , 0.1)) + platform);

What the rounding function does is just rounds by a factor of whatever the second argument's number is.
return (input / factor) * factor

Finally, platform is the vertical speed of the platform that moves up, so let's hypothetically say it's in the speed of two for example:
platform = 2;

So, basically I want it to fully diminish until it hits to zero regardless of yspeed adding itself because it does right now due to gravity and the platforms. Rewrites or new methods would be appreciated.


texts:
I'm trying to make a simple multiplayer experience with Game Maker, using a local network, and the basic idea is to use Game Maker's built-in networking functions.
Using a simple client-server pattern, I want to create a server only if there is no active server in my local network. My idea is to scan all the IPs from 192.168.0.0 to 192.168.255.255 (inelegant, I know, I'll figure out a way to determine "192.168.x.x" after solving this problem, maybe looking at the subnet mask). Here is the code:
var n1 = 192;
var n2 = 168;
var n3 = 0;
var n4 = 0;
var server = -1;
var ip = "";

while(n3 <= 255 && server < 0){

    ip = string(n1) + "." +
         string(n2) + "." +
         string(n3) + "." +
         string(n4);
    show_debug_message("Trying " + ip);
    server = network_connect(global.socket , ip, port );

    n4 += 1;
    if(n4 > 255) {
        n4 = 1;
        n3 += 1;
    }
}
if(server >= 0)
    show_debug_message("Found! Here you are: " + ip);
else
    show_debug_message("No IP found, man!");

And that's the problem: the first IP doesn't work, the game freezes for a minute and then all the others tries will fail, even the right one, with this error:

trying 192.168.255.254
ioctlsocket failed with error: -1
Error (0x    2736): Could not set socket option

My tries:

I tried starting with the right IP and it works, so, the connection works.

I tried lowering the timeout to one second and the effect is what I expected: after one second the first attempt fails and all the latter fail as well

Any idea to check the connection before actually try it? Thanks in advance!


texts: Object destroyed when applying WebCamTexture across Photon

texts:
This script turns the texture from WebCamTexture into a byte array to send across Photon as an RPC. However, when it is called, it displays the WebCamTexture for 1 frame before destroying the entire GameObject it is applied to. The gameobject is this case is a prefab with a cube that is instantiated after joining a room.
edit: I should add that it only crashed when called on a prefab. When applied to an in scene object, it works.
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using Photon.Pun;
  using Photon.Realtime;
  using System.Text;
  using ExitGames.Client.Photon;
  using System;
  using UnityEngine.Timeline;
  using System.Security.Cryptography;

public class CameraTry6 : MonoBehaviourPunCallbacks
{
WebCamTexture backCam;
public Texture2D CamThing;
public Texture2D _TextureFromCamera;

// Start is called before the first frame update
void Start()

{
    if (backCam == null)
        backCam = new WebCamTexture();

    if (!backCam.isReadable)
    {
        Debug.Log("Unable to read camera.");
        return;
    }

    if (!backCam.isPlaying)
    {
        backCam.Play();

    }

    if (backCam.isPlaying)
    {
        InvokeRepeating("Starter", 2.0f, 2.0f);
    }
    else
        Debug.Log("the webcam is not working. unable to send.");

}

// Update is called once per frame
void Update()
{

}

void Starter()
{
    StartCoroutine("Camsend");
    Destroy(CamThing);

}

IEnumerator Camsend()
{
    //if (backCam.didUpdateThisFrame)

    yield return new WaitForEndOfFrame();
    Debug.Log("Frame is over");
    Texture2D _TextureFromCamera = new Texture2D(backCam.width,backCam.height);
    int[] frame = new int[3];
    frame[1] = backCam.width;
    frame[2] = backCam.height;
    _TextureFromCamera.SetPixels(backCam.GetPixels(0,0,backCam.width,backCam.height));
    _TextureFromCamera.Apply();
    //GetComponent<Renderer>().material.mainTexture = _TextureFromCamera;
    byte[] bytes = _TextureFromCamera.GetRawTextureData();
    Destroy(_TextureFromCamera);
    int id = photonView.OwnerActorNr;

    Debug.Log("Local camera bytes:" + bytes.Length + "from" + photonView.OwnerActorNr);
    this.photonView.RPC("NetMess", RpcTarget.Others, "rcving the texture from ", id);
    photonView.RPC("CamRcv", RpcTarget.All , bytes, id, frame);

}

[PunRPC]
public void CamRcv(byte[] bytes, int pid, int[] frame)
{

    //yield return new WaitForEndOfFrame();
    if (photonView.OwnerActorNr == pid)
    {
        //StartCoroutine("LoadTexture");
        //LoadTexture();

        Debug.Log("Recieved byte from " + pid + " array length: " + bytes.Length);
        //yield return new WaitForEndOfFrame();
        Texture2D CamThing = new Texture2D(frame[1], frame[2]);
        CamThing.Apply();
        CamThing.LoadRawTextureData(bytes);
        CamThing.Apply();
        GetComponent<Renderer>().material.mainTexture = CamThing;
        CamThing.Apply();
    }

     /*
    IEnumerator LoadTexture()
    {
        yield return new WaitForEndOfFrame();
        Debug.Log("Recieved byte array length: " + bytes.Length);
        Texture2D CamThing = new Texture2D(backCam.width, backCam.height);
        Debug.Log("Recieved byte array length: " + bytes.Length);
        CamThing.LoadRawTextureData(bytes);
        CamThing.Apply();
        GetComponent<Renderer>().material.mainTexture = CamThing;
        Destroy(CamThing);
    }
    */
}
[PunRPC]
void NetMess(string mess, int pid)
{
    Debug.Log(mess+pid);

}
  }


texts: tex2Dlod to limit max mip level to use for a texture (atlas)

texts:
I'm developing a 3D multitexturing terrain engine in C# on Monogame (XNA) plateform. I would like my engine works on Windows XP or upper, so on DirectX 9c minimum.
Monogame allow me to build a DirectX 9c version of my engine, equal or less than a SM 2.0 (4_0_level_9_1) shader model.

Because there are not texture arrays on SM 2.0 and for performances, I use a texture atlas with each mipmaps build manually (to apply aliasing to each textures individually). My vertex structure contains textures coordinates of the texture atlas.

That's all right ? Fine :)

In my case, the texture atlas looks like that (textures unity: 512x512 count: 6 total: 1024x1536):

So, normally there are 11 mipmaps for this texture size, but I have just generated 10 mipmaps to avoid textures bleeding. The last mipmap of the texture atlas is not set.

My pixel shader code look like this:

float4 MutiTexturing_PS(MultiTexturing_VSOut input) : COLOR
{
    float4 _color;

    _color  = tex2D(TextureAtlasSampler, input.TextureUV1) * input.TextureOpacity.x;
    _color += tex2D(TextureAtlasSampler, input.TextureUV2) * input.TextureOpacity.y;
    _color += tex2D(TextureAtlasSampler, input.TextureUV3) * input.TextureOpacity.z;
    _color += tex2D(TextureAtlasSampler, input.TextureUV4) * input.TextureOpacity.w;

    return saturate(_color);
}

The result is that:

You can see at the background a gradient of dark: this is normal because the lastest mipmap is not set, so texture is transparent. I've have already tried to set the latest mipmap of texture atlas with the lastest generated mipmap (size: 2x3) but... the shader is more smart ! It knows the lastest mipmap must have a 1x1 size and and based its working area on that. So, the dark gradient become a red color.

To avoid the trouble, the only best solution that I have seen on the web is to use tex2Dlod (but if you have a better solution I take). This function return a color of a sampler texture at specified coordinates (like tex2D) but you can also specify the mip level to use. So, after lots of search, I found most frequently this function on the web to calculate the level of mipmap to use with the textures coordinates:

float GetMipmapLevel(float2 textureUV)
{
    float2 dx = ddx(textureUV * TextureAltasWidth);
    float2 dy = ddy(textureUV * TextureAltasHeight);
    float1 d = max(dot(dx, dx), dot(dy, dy));

    return log2(max(d, 1)) * 0.5f; // I can clamp mipmap here :)
}

But by changing my pixel shader code to use tex2Dlod(sampler, float4(texUV.xy, 0, LOD)) and GetMipmapLevel(texUV), I have this result:

I have adjust the calculation by using: return log2(max(d, 1)) * 0.75f;
You can see at the background, a similar result of tex2D function but ... the hill at foreground is to blured !

This is (finally) my question, how can I adjust the mipmap level calculation to get the same result as the tex2D ? How the tex2D function does it ?

If your solution need to use a SM 4.0, I think I'm ready to leave the DirectX 9c support but I'm sure that's possible to do in SM 2.0...
Resources link that can help other pepole in my case:
http://xboxforums.create.msdn.com/forums/p/82969/502102.aspx
http://xboxforums.create.msdn.com/forums/p/51280/309977.aspx


texts: How I add gap between Instantiated objects?

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

public class SavedGamesSlots : MonoBehaviour
{
    public GameObject saveSlotPrefab;
    public float gap;

    private Transform slots;
    private string[] imagesToLoad;

    // Start is called before the first frame update
    void Start()
    {
        imagesToLoad = Directory.GetFiles(Application.dataPath + "/screenshots", "*.png");
        slots = GameObject.FindGameObjectWithTag("Slots Content").transform;

        for (int i = 0; i < imagesToLoad.Length; i++)
        {
            var go = Instantiate(saveSlotPrefab);
            go.transform.SetParent(slots);

            Texture2D thisTexture = new Texture2D(100, 100); //NOW INSIDE THE FOR LOOP
            string fileName = imagesToLoad[i];
            byte[] bytes = File.ReadAllBytes(fileName);
            thisTexture.LoadImage(bytes);
            thisTexture.name = fileName;
            GameObject ChildGameObject = go.transform.GetChild(1).gameObject;
            ChildGameObject.GetComponent<RawImage>().texture = thisTexture;
            var raw = go.GetComponent<RectTransform>();
            raw.anchoredPosition = new Vector3(1 + 1 * gap, 6, 0);

        }
    }

    // Update is called once per frame
    void Update()
    {

    }
}

The way I'm doing it now is not working it's moving all the objects to the same position and not adding
equal gap's between them.
In the loop I tried to do it this way in this line :
raw.anchoredPosition = new Vector3(1 + 1 * gap, 6, 0);


texts:
In my code-base I need to link the vertex declarations from a mesh to the attributes of a shader. To do this I retrieve all the attribute names after linking the shader. I use the following code (with some added debug info since it's not really working):

int shaders[] = { m_ps, m_vs };
if(linkProgram(shaders, 2))
{
    ASSERT(glIsProgram(m_program) == GL_TRUE, "program is invalid");

    int attrCount = 0;
    GL_CHECKED(glGetProgramiv(m_program, GL_ACTIVE_ATTRIBUTES, &attrCount));

    int maxAttrLength = 0;
    GL_CHECKED(glGetProgramiv(m_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttrLength));

    LOG_INFO("shader", "got %d attributes for '%s' (%d) (maxlen: %d)", attrCount, name, m_program, maxAttrLength);

    m_attrs.reserve(attrCount);

    GLsizei attrLength = -1;
    GLint attrSize = -1;
    GLenum attrType = 0;

    char tmp[256];
    for(int i = 0; i < attrCount; i++)
    {
        tmp[0] = 0;
        GL_CHECKED(glGetActiveAttrib(m_program, GLuint(i), sizeof(tmp), &attrLength, &attrSize, &attrType, tmp));
        LOG_INFO("shader", "%d: %d %d '%s'", i, attrLength, attrSize, tmp);
        m_attrs.append(String(tmp, attrLength));
    }
}

GL_CHECKED is a macro that calls the function and calls glGetError() to see if something went wrong. This code works perfectly on Windows 7 using ANGLE and gives this this output:

info:shader: got 2 attributes for 'static/simplecolor.glsl' (3) (maxlen: 11)
info:shader: 0: 7 1 'a_Color'
info:shader: 1: 10 1 'a_Position'

But on my Nexus 7 (1st gen) I get the following (the errors are the output from the GL_CHECKED macro):

I/testgame:shader(30865): got 2 attributes for 'static/simplecolor.glsl' (3) (maxlen: 11)
E/testgame:gl(30865): 'glGetActiveAttrib(m_program, GLuint(i), sizeof(tmp), &attrLength, &attrSize, &attrType, tmp)' failed: INVALID_VALUE [jni/src/../../../../src/Game/Asset/ShaderAsset.cpp:50]
I/testgame:shader(30865): 0: -1 -1 ''
E/testgame:gl(30865): 'glGetActiveAttrib(m_program, GLuint(i), sizeof(tmp), &attrLength, &attrSize, &attrType, tmp)' failed: INVALID_VALUE [jni/src/../../../../src/Game/Asset/ShaderAsset.cpp:50]
I/testgame:shader(30865): 1: -1 -1 ''

I.e. the call to glGetActiveAttrib gives me an INVALID_VALUE. The opengl docs says this about the possible errors:

  GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.

This is not the case, I added an ASSERT to make sure glIsProgram(m_program) == GL_TRUE, and it doesn't trigger.

  GL_INVALID_OPERATION is generated if program is not a program object.

Different error.

  GL_INVALID_VALUE is generated if index is greater than or equal to the number of active attribute variables in program.

i is 0 and 1, and the number of active attribute variables are 2, so this isn't the case.

  GL_INVALID_VALUE is generated if bufSize is less than 0.

Well, it's not zero, it's 256.

Does anyone have an idea what's causing this? Am I just lucky that it works in ANGLE, or is the nvidia tegra driver wrong?


texts: Best technique to create oldschool (fake 3D) racing game?

texts:
What would be a good approach to develop the render system for an oldschool type racing game that uses a pseudo 3D scenery, like for example Outrun or Lotus Esprit Turbo Challenge? There's an endless scrolling road and scenery graphics are placed like billboard items, etc. I think you get the idea.

Are these developed in a similar way like Mode7 or is there a different technique behind it? Does the technique has a specific name I could search for on the web? I need to develop something like that in Flash.


texts: How can I run a Phaser engine game without a window?

texts:
I'm currently creating a multiplayer game using the HTML5 framework Phaser.

It's a game where zombies spawn on the map and players have to shoot them to kill them. The zombies target players that are closest to them.

Currently, I'm having my an issue with my design strategy. I'm not sure if this type of game is possible with Phaser due to the movement tracking.

At present, the client is handling all of the player movement, so whenever a player moves, it broadcasts it to the server which sends it to all of the other clients.

However, I would like for the zombies and the bullets to be controlled by the server exclusively. The server then updates each client with the velocity of each zombie and their current position. My reasoning is that anything that isn't player input should be calculated by the server. This will prevent issues such as two clients saying that a zombie died at different times and then trying to communicate with one another, having bullets at different locations at the same time, or zombies spawning at separate times between clients.

Here's an example of a zombie class:

function Zombie(game, data){

this.game = game;

this.id = data.id;
Phaser.Sprite.call(this, this.game, data.x, data.y, 'zombie');
this.anchor.setTo(0.5,0.5);

this.animations.add('right', [0,1,2,3], 7, true);
this.animations.add('left', [4,5,6,7], 7, true);
this.game.physics.arcade.enable(this);
this.body.collideWorldBounds = true;

this.health = data.health;
this.maxHealth = data.maxHealth;
this.speed = data.speed;
this.target = this.game.player;
this.waiting = 100;

this.name = "zombie";
this.healthBary = 20;
this.healthBar = this.game.add.sprite(this.x, this.y + this.healthBary, 'player_health');
this.healthBar.anchor.setTo(0.5, 0.5);
CollisionManager.addObjectToGroup(this, 'baddies');
this.game.add.existing(this);

}
Zombie.prototype = Object.create( Phaser.Sprite.prototype );
Zombie.prototype.constructor = Zombie;
Zombie.prototype.update = function(){

this.updateHealthBar();

                this.moveTowards(this.target);

Zombie.prototype.uTarget = function(target) {
    this.target = target;
};
Zombie.prototype.moveTowards = function(target){
var x = target.x - this.x;
var y = target.y - this.y;

var mag = Math.sqrt((x * x) + (y * y));

var nx = x / mag;
var ny = y / mag;

this.body.velocity.x = nx * this.speed;
this.body.velocity.y = ny * this.speed;

if(this.body.velocity.x >= 0){
    this.animations.play('right');
}
else if(this.body.velocity.x < 0){
    this.animations.play('left')
}

}
Zombie.prototype.updateHealthBar = function(){
this.healthBar.x = this.x;
this.healthBar.y = this.y + this.healthBary;

var p = (this.health / this.maxHealth);
p = parseFloat(p.toFixed(1));
this.healthBar.frame = 10 - (p * 10);
}
Zombie.prototype._damage = function(amount){
this.health -= amount;
if(this.health <= 0){
    this.kill;
    this.die(true);
}
}

Zombie.prototype.die = function(points){

if(this.game){
    //this.game.baddie_die_sfx.play();
}

WaveManager.onMap--;
CollisionManager.removeObjectFromGroup(this, "baddies");
if(this.healthBar){
    this.healthBar.destroy();
}
socket.emit("kill zombie", {id: this.id});
this.kill();
this.destroy();
}

The problem is that I can't create a Phaser game object on the server (as it's running on a Linux server) because there's no window that can be used. The bullets and zombies need to be Phaser objects for the sake of collision detection, but I can't do that on the server.

I know that I could create a vector of zombies and bullets server-side that would have the information for each bullet/zombie's position at any given time and then update the client, but then I wouldn't be able to use the CollisionManager in Phaser.

Right now, it seems like my only solution is to create my own collision detection system. Are there any alternative ideas?


texts: Calculate initial velocity of a 3d vector-based projectile

texts:
Okay, so I got a Projectile with 2 Vectors, position and velocity.
I now want to calculate the initial velocity for it in order to reach a specific point on the map.

Or actually, how high has the start z-velocity to be (because x and y are probably defined by a speed variable) in order for the projectile to hit the marked position.

The projectile is influenced by a constant gravity vector.

All calculations are done 32 times per second.

I want this, because I don't want to use a parabola function, so the projectile can still be influenced by other sources, simply adding some velocity.

I didn't really find anything referring to that topic and would be glad for every helping answer, Thanks.


texts: My game will be a turn based game which will need a server gateway in order to send requests. What would be better for the server: using REST HTTP GET for making the requests? Or using WebSocket which enables you to have an active connection?


texts: How to find position of the edge of an object?

texts:
I have two planes and I want to put both planes one after another so that I can form a road. I set them from the editor and that was very easy but I wanted to do this from code. So in the code:

void Start() {
  secondRoad.position = firstRoad.position;
}

But this just set the second plane in the center of the first plane, kind of overlapping. But I want the second plane to be placed next to the first plane where it ends right the edge of the first plane. How will I do this?


texts: P2P card game: Shuffling without knowing the final order?

texts:
So, I am conceptualizing a P2P trading card game. The issue is the network: knowing the identity of a card is giving a major advantage, so both clients need enough information about a card that they know it exists, but not so much that the "value" or "specialties" of a card can be determinated.

The basic approach to that is simple: each client has a public and a private key for each card, and to decrypt the card you need all private keys associated to that card.
Whenever a card is played the appropriate key is send over, whenever a card is drawn the other players send the needed keys over.

However there is a issue: the start state is known and from it you could determine which card is which, what makes the whole thing a bit pointless.
How do I shuffle cards over the network so that the client doesn't know the actual end state (without knowing the keys)?


texts: Unity: how do I make an input only available to the code?

texts:
I have a simple function attached to a button. I then decided to change it by adding an input. The problem is that the function won’t run unless I specify the input in Unity via the inspector. I don’t want to do that because it will affect the function and I have already changed it inside. I already set the input when I run the function so there’s no need to set it again in Unity; this is a problem because the input is going to be different depending on different scenarios. How can I overcome this?

public void Eruption(string biome)
{
    if (biome == “sea”) {
        // do something
    }
}


texts: There are lots of popular games now-days that enable a player to construct a word while opposing some limitations. If player constructs a valid word successfully, he gets a point. For this a big amount of English words is needed so that the game would be able to check if such a word exists in English. Where can I take such a bank of words? And how big the size will be? Would it we good for mobile games?


texts: Standard key bindings for movement along three axes?

texts: I understand that the WASD keys are standard for moving a character along two axes (left/right, up/down) because in the QWERTY layout, they are arranged like the arrow keys. I want to make a game where the character can move along three axes, i.e. also front/back. Are there standard key bindings for this as well?


texts:
I am trying to create my own action in Behavior Designer. However i cannot seem to get the game object that designer is attached to. if i attempt to do:

protected Combatant enemyCombatantObject;

public override void OnAwake()
{
    enemyCombatantObject = GameObject.GetComponent<Combatant>();
    base.OnAwake();
}

It gives me an error:

  the property or indexer 'Task.GameObject' cannot be used in this
  context because it lacks the get accessor

Can anyone tell me how to get the GameObject that the script is attached to?


texts: What is the most efficient method to write a multiple choices story?

texts:
I’d like to tell a story through a video game, and I’m starting to write it. But I got like 8 characters, some of them dies, some don’t, player has important choices changing the way characters talk to him or interact to eachother and I’m looking for an efficient way to get the story on paper before starting to code.

Do you guys know a clever way to write this ? I tried to make a file for each path, but its a bit messy


texts:
I have a canvas that draws the letter 'a' with a box:

 var cxt = document.getElementById('someCanvas').getContext('2d');
 cxt.strokeRect(someX, someY, someWidth, someHeight);
 cxt.fillText('a', someX, someY);

if I want to animate this to move and not leave the previous drawn canvas behind, I will need clearRect and re-draw it again:

 cxt.clearRect(someX, someY, someWidth, someHeight);
 //cxt.strokeRect..
 //cxt.fillText..

However, with drawImage, I can just increment its x/y without needing to clear/re-draw it again:

 cxt.drawImage(src, someX, someY);

I was wondering, would there be any performance difference of these two methods if I wanted more letters/others? Does drawImage clear itself the same way as clearRect?


texts: Will we see a trend of stereoscopic 3D games coming up in the near future?

texts:
I've noticed that the trend of movies is diving into the world of movies with 3-dimensional camera.For me it provoked a thought as if it was the same feeling people got when they saw a colour movie for the first time, like in the transition from black and white to colour it is a whole new experience. For the first time we are experiencing the Z(depth) factor and I really mean when I said "experiencing".

So my question is or maybe if not a question, but Is there a possibility of a genre of 3d camera games upcoming?


texts: Character Models: Single Mesh vs. Individual Parts

texts:
I was looking up 3D character models from various games (Battlefield 3 and DMC to be specific), just as research work and upon importing the model into Blender3D, I found that every part of the model was a separate mesh/object (head, armor vest, legs, hands, etc.).

This got me thinking: Why didn't the artist model them as a single object?

I think that would be better because:

You can save a few polygons in your model [*].
Doesn't animating separate parts [**] cause clipping issues as one mesh may not deform in sync with neighboring mesh?

[*] All parts were overlapping each other = the armor vest was overlapping chest polygons, which were not visible and thus wasted.

[**] All polygons and edges connected to each other.


texts: How to properly use fixture filter mask bits?

texts:
In the below code, I've created a mask value for the MASK_bullet. Which ~CATEGORY_BULLET cannot collide with bullet, CATEGORY_ENEMY can collide with bullet and so on. Now the problem is, it is not behaving the way as expected.

public static final short CATEGORY_ENEMY = 0x0002;
public static final short CATEGORY_MAP_OBJECT = 0x0008;
public static final short CATEGORY_BULLET = 0x00032;

public static final short MASK_BULLET = ~CATEGORY_BULLET | CATEGORY_ENEMY | CATEGORY_MAP_OBJECT;

How I set the category and mask.

FixtureDef fixtureDef = new FixtureDef();
fixtureDef.filter.categoryBits = CATEGORY_BULLET;
fixtureDef.filter.maskBits = MASK_BULLET;


texts: Unity & CSharp - Placing Instantiated Object in the Direction of Player

texts:
So, I am making a Minecraft ripoff.
I have a raycast that hits a block. It then places a block inside of that block. I am trying to make it place next to the block in the direction the user is facing.
I got some of that figured out. I use:
Math.Round();
to round up the floats. My problem is figuring out what axis to round on. I need it to depend on the direction the player is facing to figure it out.
I tried doing a complicated algorithm to figure out which face of the collider the player is facing, but that didn't work out that well....

How do I solve this? I can't figure it out.


texts: Calculating instantaneous speed and acceleration for a simple car software model

texts:
I am trying to model a speedometer and tachometer for a simple software model of a car dashboard. I want this to be relatively simple, so for my purposes I won't likely simulate variables such as drag (or, assume that drag is a constant). But I would like to know the general formulas for:

1) Calculating the RPM, depending on a position of a graphical slider representing the accelerator.

2) Using this information to find the instantaneous speed (or, magnitude of instantaneous velocity?).

I am not sure, in the case of 2), what other independent variables I need to consider. Do I need to consider the frequency of rotation of the wheels (assuming a fixed radius), in addition to the  RPM?

If anyone can give me a rough explanation plus relevant formulas, or alternatively direct me to other trusted resources online (I have had a hard time sifting through info and determining the accuracy), it would be much appreciated.


texts: Make a platform appear and disappear constantly

texts:
I am building a platformer. In this game, I need one of my platforms to constantly activate and deactivate.

Here is how I have tried to code this so far, but it causes Unity to freeze:

void Update(){
    for (i = 0; i <= 2; i++) {
        platform.SetActive (false);
        if (i >= 1 ) {
            i--;
            platform.SetActive (true);
        }
    }
}


texts: How do I generate a 2d grid-based map without screwing it up?

texts:
I'm relatively new to the mechanics of game development - catching up fast, but there are still some things that escape me. For example: generating a fully-accessible map on a 2d grid.

See the example at http://crawl.s-z.org. Each floor map starts with dozens of winding labyrinthine passages and randomly drops in points of interest - temples, boss lairs, bazaars, etc. I know there's a lot of factors that go into this: generating passages that always have at least one exit (no isolated tunnels in the walls), making sure passages have at least a one-cell-width wall between them and adjacent parallel passages, and dropping points of interest in such a way that they connect to the dungeon.

I've taken a shot at it, and it's very easy to ranomly place lines in a 2d matrix that represent passages - but they're never guaranteed to connect, and it's not nearly as elegant as the maps at the above example.

I suppose my question is, what do I need to know to reproduce the example at crawl.s-z.org? I know this is a large question - I'd be fine with someone handing me a link to a reference site and telling me to learn it there. I'm just new enough at this that I don't even know what terms to google - maybe there are names for different generation processes? Available techologies are JS (jQuery) and PHP, so a solution tailored to one of those would be ideal. Thanks!


texts: Rotating Sprite Around A Point Without Messing Its Drawing Point

texts:
I am trying to draw and rotate an arrow sprite based on a point,around a static circle body without messing its drawing starting point. Arrow should be  directed to the same direction with user touch point,static body center vector.

Let me explain it with an example.

This is how i calculate arrow drawing point:

fun powerIndicatorDownPointCalculator(playerPosition: Vector2,touchPosition: Vector2,distanceBetweenTouchPointAndPlayer:Float):Vector2{
  // player position is static body center,touch position is touch point.

    val playerPositionHolder = playerPosition.cpy()

    val abVector = playerPosition.sub(touchPosition);

    val normalizedAbVector = Vector2(abVector.x/distanceBetweenFingerAndPlayer,abVector.y/distanceBetweenFingerAndPlayer)

    Gdx.app.log("normalized ab vector",normalizedAbVector.toString())

    var pointToAddX  = 90*normalizedAbVector.x
    var pointToAddY  = 90*normalizedAbVector.y

    var newPointX  = playerPositionHolder.x + pointToAddX
    var newPointY = playerPositionHolder.y + pointToAddY
    Gdx.app.log("NEW POINT", Vector2(newPointX,newPointY).toString())

    return Vector2(newPointX,newPointY)

}

Here is a simple gif showing it:

https://i.ibb.co/TvHBMh9/MNML-November19-041320-AM.gif

This is how i calculate C point to use later on rotation(?)

 fun calculateAimingPoint(playerPosition: Vector2,touchPosition: Vector2):Vector2{
//playerPosition is staticbody center
        val abVector = playerPosition.sub(touchPosition);

        val secondPos = blackBody.position.cpy()
        val cPointPosition  = secondPos.add(abVector)
        return cPointPosition

}

This is what i wrote for rotation but for sure it is wrong since not working as i wanted:

var angle = atan2(aimingPoint.y - blackBody.position.y, aimingPoint.x - blackBody.position.x ) *180/ PI ;
//aiming point is C point, blackBody is static body
  if (angle > 90)
  {
      angle = 450 - angle;
  }
  else
  {
      angle = 90 - angle;
  }

// powerIndicator.setOrigin(????) // setOrigin is for rotation but i dont now what to write here.

  angle = angle*-1
  powerIndicator.rotation = angle.toFloat()

What i actually wanna achieve is this:
https://i.ibb.co/gDM9H3L/MNML-November19-042729-AM-2.gif


texts: How would I implement a level for a vertical shooter game

texts:
I've been working in my free time on a vertical shooter similar to Xenon 2 Megablast. It's a tribute of sorts to the game that destroyed a considerable part of my childhood.

I've got the basic stuff in place - weapons, enemies, collision detection and a scrolling background. Now, I want to design the levels.

I want to create some kind of an engine which can render a level based on some kind of (say) textual description so that I can easily create levels. Are there any articles or links to how platformer/vertical shooter levels can be stored as files and loaded by the game engine? I'm not looking for completely solutions but ideas and starting points so that I can try to do it myself.

Specifically, how would you store the level of a platformer game like Prince of Persia or a shooter like Xenon 2?


texts: The title pretty much sums it up. I'm using delta time to move my objects and every few seconds the delta time will spike and all the objects will jump forward. Should I just Interpolate the delta time to eliminate spikes, I don't want to do this because it could cause other problems but it could be a solution


texts: Color of Image changes to white between 2 positions using Color.Lerp - Unity

texts:
Hi I have an empty object barHolder that I move between 10 and 98 on x-axis. It has 2 child images roundBar and bar. I am trying to change the color of roundBar and bar when the object is moving. On x=10 the the color will be red and on x=98 it will be green. Here is what I have done so far:

    public GameObject meterBarHolder;

    public GameObject barRoundHead;
    public GameObject bar;

    public Text meterSpeedText;
    int currentSpeed;

    Color maxColor = new Color(21, 193, 25, 255);
    Color minColor = new Color(229, 85, 85, 255);

    float totalSpeed;

    float speedPercentage;

    float pos;
    //--------------//

    private void Start()
    {
        totalSpeed = (float)PlayerPrefs.GetInt("speed");
    }

    // Update is called once per frame
    void Update()
    {
        currentSpeed = int.Parse(meterSpeedText.text);

        speedPercentage = (float)currentSpeed / totalSpeed;

        pos = 88 * speedPercentage;

        if(pos < 10)
        {
            meterBarHolder.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(10f, 0f, 0f);
            changeColor(0);
        }
        else if(pos > 98)
        {
            meterBarHolder.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(98f, 0f, 0f);
            changeColor(1);
        }
        else
        {
            meterBarHolder.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(pos, 0f, 0f);
            changeColor(speedPercentage);
        }

    }

    void changeColor(float x)
    {
        bar.GetComponent<Image>().color = Color.Lerp(minColor, maxColor, x);
        barRoundHead.GetComponent<Image>().color = Color.Lerp(minColor, maxColor, x);
    }

The problem is that when ever I click play the color changes to white.

For reproducing the problem totalSpeed=120 and meterSpeedText changes between  0 and 120. The rest are calculated in the code.

Here is a gif to give an idea what I am trying to do:


texts: How can I tell whether an object is moving CW or CCW around a connected path?

texts:
Lets say we have a jagged shape:

And two creatures moving along it's outline.

Then we smooth the shape completely by pulling the corners out.

We get this:

It is easy to see now that Orange is moving CW and green CCW. How can I tell in which direction they are moving without smoothing out the shape?

New image


texts: How Would You Animate a 3d Characters Face (With Textures)

texts:
So I'd like to do a low poly style of modeling, and one of the corners I'd like to cut is on head geometry. Specifically, making the details of the face a texture (like a Mii or a character in Animal Crossing for example).

How would you go about accomplishing animating the face? Getting it onto the model in the first place?

I'm using Unreal Engine to learn and working on my 3d modeling skills at the same time, so knowing a general workflow would give me some structure to work with.


texts: How can I calculate the future position of my moving object?

texts:
I'm relatively new to games development and I have a 2D game where the playing area is an enclosed rectangle with width w and infinite height. In the playing area there is a ball. A gravity force of strength G acts on the ball. The ball starts at position p and has an initial velocity of v.

How would I calculate the position the ball will be at when it reaches the specified height h. I have a function setup using the following parameters:

bool CalculateXPositionAtHeight(float height, Vector2 position, Vector2 velocity, float Gravity, float width, float& xPosition);

The playing area doesn’t have any boundary at the top, so no
collision ever happens with it.
The ball can be considered as a point.
There are no precision issues and everything can easily fit in a float.
There is no air resistance.
All collisions are perfect without any energy loss.
If the ball hits the bottom it won’t bounce.


texts: XNA Content Loading works on my machine but not others

texts:
I'm using XNAWinForm series 2 from App Hub for some task that needs 3d rendering.
It works fine on my PC, but I have problems in running this code on other machines.

I installed XNA framework redistributable on that machine, I tried 32 and 64bit computers and still its not working.
Even the code on app hub is not working on other machines.

What should I do?


texts:
As one cannot play around with threads themselves, the user-made code that uses unity's API is executed on the main thread. I'm sure unity uses some sort of thread management on its own though.

Thing is, I wrote some basic UI animation toolkit (rotate, scale, lerp alpha, move and tie events etc) that - as being user code - runs on the main thread, taking up CPU power, even if they are not vital to be completely synchronized with the logic. (Event connected to them only start other animations).

I would like to know if Unity uses another thread for animations as well and if so, is it possible to mark this UI toolkit to be executed on that thread or - as I said - user code with unity api can be only ever executed on the main thread?


texts:
I'm running in circles here trying to figure out how to implement game states!

Many of the articles I have read use an abstract class that game states inherit, and another "manager" class that handles pushing/popping game states.

This is fine I guess, but for the game I'm planning on making, I can only imagine I'll have MANY classes, alot of which are nearly identical. For example, I have one game state which is basically a view of my scene with a few GUI buttons. Another game state gets entered when the user clicks the "Terraforming" button, which allows the user to modify the terrain. Both of those have many similarities - they are both rendering the same scene, the controls are the same, much of the GUI is the same except for a new window that contains terraforming controls, and mouse clicking is handled differently. It sounds silly to completely reconstruct a new game state when 90% of it will be identical.

Am I thinking about this the wrong way? Or is there a better solution for managing game states?


texts: I want to create this type of fixture in one body. Here square and circle both are different fixtures but attach to one body. How do I do this?


texts:
I managed to draw a 3d cube using triangles like this:

    protected override void LoadContent()
    {
        basicEffect = new BasicEffect(GraphicsDevice);
        VertexPositionColor[] vertices = new VertexPositionColor[8];
        short[] indices = new short[36];
        vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly);
        indexBuffer = new IndexBuffer(graphics.GraphicsDevice, typeof(short), indices.Length, BufferUsage.WriteOnly);
        Color Color1 = Color.DarkRed;
        Color Color2 = Color.Pink;
        float width = 2;
        float height = 1;
        float depth = 0.5f;

        vertices[0] = new VertexPositionColor(new Vector3(0, 0, 0), Color1);
        vertices[1] = new VertexPositionColor(new Vector3(width, 0, 0), Color1);
        vertices[2] = new VertexPositionColor(new Vector3(width, -height, 0), Color1);
        vertices[3] = new VertexPositionColor(new Vector3(0, -height, 0), Color1);
        vertices[4] = new VertexPositionColor(new Vector3(0, 0, depth), Color1);
        vertices[5] = new VertexPositionColor(new Vector3(width, 0, depth), Color1);
        vertices[6] = new VertexPositionColor(new Vector3(width, -height, depth), Color1);
        vertices[7] = new VertexPositionColor(new Vector3(0, -height, depth), Color1);

        indices[0] = 0; indices[1] = 1; indices[2] = 2;
        indices[3] = 0; indices[4] = 3; indices[5] = 2;
        indices[6] = 4; indices[7] = 0; indices[8] = 3;
        indices[9] = 4; indices[10] = 7; indices[11] = 3;
        indices[12] = 3; indices[13] = 7; indices[14] = 6;
        indices[15] = 3; indices[16] = 6; indices[17] = 2;
        indices[18] = 1; indices[19] = 5; indices[20] = 6;
        indices[21] = 1; indices[22] = 5; indices[23] = 2;
        indices[24] = 4; indices[25] = 5; indices[26] = 6;
        indices[27] = 4; indices[28] = 7; indices[29] = 6;
        indices[30] = 0; indices[31] = 1; indices[32] = 5;
        indices[33] = 0; indices[34] = 4; indices[35] = 5;

        vertexBuffer.SetData<VertexPositionColor>(vertices);
        indexBuffer.SetData(indices);
    }

I have two questions:

As you can see i am using float width = 2; float height = 1; float depth = 0.5f; but why "width = 2" looks like 80 pixels instead of 2? I want the cubes to be 72x24x12, i can't figure out how to calculate the pixels from the field of view / aspect ratio. To draw the cube on different positions i am using world = Matrix.CreateTranslation(10.0f, 10.0f, 0.0f);, is that the correct way to do this ?
How can i draw each face of the cube a different color? (Right now i know how to give color to each vertice, see Color1 variable). Right now i am using 2 different BasicEffects, is there any better way perhaps ?


texts: Restrict Up/Down rotation, detect angle upwards/ downwards

texts:
I have an object using Quaternion.LookRotation() to look at target object, I would like to be able to restrict the rotation by being able to set the range that the object can rotate at, for example from 45 degrees to 180 degrees, this would mean the object does not rotate lower than 45 degrees and does not rotate higher than 180 degrees, currently my code looks like this:

void Start(){
    baseRotation = transform.localEulerAngles;
}
    Vector3 targetPos = Target.position;
    Vector3 dif = targetPos - obj.position;
    dif.z = 0;

    Quaternion lookAngle = Quaternion.LookRotation(dif, obj.up);
    print("angle: "+ Quaternion.Angle(lookAngle, Quaternion.Euler(baseRotation)));
    if (Quaternion.Angle(lookAngle, Quaternion.Euler(baseRotation)) < rangeMax - rangeMin)
    {
        targetR = lookAngle;
    }
        obj.rotation = Quaternion.Lerp(obj.rotation, targetR, Time.deltaTime * 100);
}

However this code makes sure that rotation both upwards and downwards equally does not exceed the same angle, which is not quite what I want, as I said I would like to set the start angle and the end angle. How would I do that? Could you post the code that would give me an idea?

Thanks in advance!


texts: Single texture or one texture per light for shadow mapping

texts:
The basic implementations of shadow mapping that I have seen create a depth texture for each light source affecting the scene. I'm just curious as to why this might be done rather than using and reusing a single texture for all of the lights in the scene so as to save on memory.

To clarify, is there any benefit in the following:

for light in lights
    render scene depth to light.shadowTexture // One texture object per light
end

for light in lights
    render scene with light (blended)
end

as opposed to:

new Texture shadowMap // One texture object, written to by all lights

for light in lights
    render scene depth to shadowMap
    render scene with light (blended)
end


texts: How to balance damage dealt by opponents in a strategy game?

texts: Consider the following situation: you are developing a RTS, with different races opposing each other, with different kinds of abilities (e.g. Starcraft). How should I go about in balancing the damage, speed, cool down times etc. of the respective troops/units? Are there any good resources on that or sort of test-beds?