texts: Sample() returns (0, 0, 0) for normal map 90% of frames

texts:
I'm having some trouble reading the values from my Normal map in my lighting fragment shader.

The relevant part of the shader code is as follows:

Texture2D NormalGB : register(t0);
Texture2D DiffuseGB : register(t1);
Texture2D SpecularGB : register(t2);
Texture2D PositionGB : register(t3);

SamplerState NormalSampler : register(s0);

void GetGBValues(
    in int2 screenPosition,
    out float3 normal,
    out float3 diffuseAlbedo,
    out float3 specularAlbedo,
    out float specularPower,
    out float3 position)
{

    int3 screenPos3 = int3(screenPosition, 0);
    normal = normalize(NormalGB.Sample(NormalSampler, screenPosition).xyz); // HERE
    diffuseAlbedo = DiffuseGB.Load(screenPos3).xyz;
    float4 specularValues = SpecularGB.Load(screenPos3);
    specularAlbedo = specularValues.xyz;
    specularPower = specularValues.w * 50.0f;
    position = PositionGB.Load(screenPos3).xyz;
}

However, in 9 frames out of 10, normal is set to {0. 0, 0}. I've tried the code under the reference driver too, and get the same issue.

What's really weird is that if I change the line marked // HERE to a simple .Load call, the code works perfectly (except the obvious fact that I get no interpolation of normals). The sampler that is bound at time of the draw call (according to the graphics debugger) is:

D3D11 Sampler State (obj:18)
AddressU D3D11_TEXTURE_ADDRESS_WRAP
AddressV D3D11_TEXTURE_ADDRESS_WRAP
AddressW D3D11_TEXTURE_ADDRESS_WRAP
BorderColor (0.000f, 0.000f, 0.000f, 0.000f)
ComparisonFunc D3D11_COMPARISON_NEVER
Filter D3D11_FILTER_ANISOTROPIC
MaxAnisotropy 4
MaxLOD 340282346638528860000000000000000000000.000f
MinLOD 0.000f
MipLODBias 0.000f

Device obj:3

And finally, the normal-map (rendered to a texture by the previous pass):


texts: How can I draw a model with a color on WP7?

texts:
How can I draw a model with a color (and still be aware of the lighting)?

This is really straight forward when you can use shaders, but on Windows Phone you can't.


texts: ECS: Should Systems access only one component-type

texts:
Let's say I have a Transform-component-type, and a Color-component-type (to keep things simple).
I also have an entity E that is assigned both of these component-types.
To render E, my engine will internally have to bind a uniform-buffer containing both a mat4-transformation-matrix, and a vec3-color.
Now I think I heard conflicting opinions about whether there should be a strict 1-to-1 component_type-to-system relation, or whether it is considered more appropriate to have systems which act on multiple component-types.
In the latter case I'd know how to do things.
I would have a RenderSystem, which only considers entities which have both a Transform, and a Color component.
For the first case I don't have a solution though..
Both the TransformSystem and the ColorSystem wouldn't know how to render the entity, since they only hold a subset of what is required by the shader.
So I would just jump head-first into implementing my ECS as having one system potentially acting on multiple component-types, but I first wanted to hear from people having more experience with ECSs.
Are there good solutions in an ECS that maps systems 1-to-1 to components to achieve behavior that is the effect of the presence of multiple different component-types, or is a solution in which one system requires the presence of multiple component-types generally preferable?


texts:
Hello I am having an issue getting this equation to work, even with manually entering values replacing the variables.
I cannot seem to get it to work, I have tested that the variables are being updated and
working correctly and simpler equations are working and are able to be drawn, but when i try this all i am getting is "0.00"

yes this is working out profit made from bitcoin mining.

The original equation i am trying to get to work is
dailyprofit = 24/(d*2^32/(h*10^6)/60/60)*c

global.profit =(24/(global.difficulty * power(2,32)/(global.hashrate * power(10,6))/60/60)*global.reward);

any help or ideas would be greatly appreciated.


texts: Custom event doesn't update blueprint variables

texts:
Here's what I have:

To sum it up: calling the OnInteract event (which comes from an interface) prints the 'Proceed' variable. Clicking Fire sets the variable to true and prints it. 'Proceed' is false by default.
The problem is that the OnInteract event always prints 'false', even if the Fire event has been called. The Fire event correctly prints 'true', but if I call the OnInteract event later, it still prints 'false', even though logically the variable should be 'true'.
No outside entity is changing the variable. If I set the default value of the variable to 'true', it prints 'true'. The entire project is just the First Person template, a single blueprint actor whose entire event graph is what you see in the screenshot, and an outside entity calling the OnInteract event when I press the button.
Curiously, if I ditch the OnInteract event completely and replace it with InputAction Jump, the code works as expected and prints 'true'.
What's going on? This is so simple, and yet it has me beat.


texts: calculating the trajectory of an object in SpriteKit when an impulse is applied to it

texts:
I want to make a trajectory line of little balls of where the object is going to go after an impulse, sort of like what is in Angry Birds. I did some research and it seems that the physics in spriteKit are calculated just as in real life with si units and other stuff. Using the displacement formula ∆x = Vi∆t + 1/2a∆t^2 i used this formula to set the position of nine balls of where the object will be after the impulse.

This is what I have tried so far:

func calculateTrajectory(mass: CGFloat, force1: CGFloat, force2: CGFloat){

    for i in 0...8{

        var x = CGFloat()
        var y = CGFloat()

        let a1 = CGFloat(force1/mass)//I am taking the force applied to the object and calculating the acceleration from that
        let a2 = CGFloat((force1/mass) - 10)//I am subtracting 10 for y because of the -10m/s/s of gravity
        let t = CGFloat((i/16)^2)//I am taking the number that the ball is in the line and dividing it by 16 so the line can show where the object will be from 0-0.5 secnds

        x = 0.5 * a1 * t
        y = 0.5 * a2 * t

        trajectory.copiedNodes[i].position = CGPoint(x:ball.position.x + x, y: ball.position.y + y)

    }

}

I also use this in touches moved to do a drag back sling shot sort of thing.

calculateTrajectory(mass: (ball.physicsBody?.mass)!, force1: startPositionDrag.x - movedLocation.x, force2: startPositionDrag.y - movedLocation.y)

The force for calculation is the same as impulse that I will use to shoot the ball in touches ended:

ball.physicsBody?.applyImpulse(CGVector(dx:startPositionDrag.x - endPositionDrag.x, dy:startPositionDrag.y - endPositionDrag.y ))

When I calculate this the balls are not close to where the object goes, and when I make the time change for the balls a shorter time amount by dividing i by more, the balls get farther apart even though I am calculating their positions after less time. Is there any way I am doing this wrong? Are my conversions to CGFloat wrong? Please help me.


texts: How can I use IntelliJ to make Minecraft mods?

texts:
I'm starting out creating Minecraft mods with my son.

I've seen one YouTube tutorial which sets up project with Eclipse.

Since I don't like Eclipse much, I ask: how would I setup IntelliJ or Android Studio(if feasible) to develop Minecraft mods?

My son specifically want to create roller coaster mods.


texts: I have a question about 3D game models and copyright

texts:
I am making a game that is like a combination of minecraft and unturned. It is like minecraft as it is very block based. It is like unturned because it has vehicles and other unturned functionalities. This is what the player model would probably look like:

The player model is very similar to minecraft's Steve. It does however have some major differences that make it unique. For instance the eyes are not stationary and can actually look around. The mouth has two sets of teeth which act as the jaw line and lips that represent the mouth. Both the teeth and the lips can be animated for a "Talking" animation. The eyes also have eyelids which can close and open with proper animating skill. The player model can also be customized in game, as the hair style, beard style, eye color, skin color, hair and beard color, can be changed during game play. Unlike minecraft's character, It is not restricted to just helmet, chest plate, leggings and boots for armor. This model can change its shirt, pants, helmet, hat, pants, leg armor, armor boots, chest plate, backpack (If he equips one), gloves, shoulder pads, elbow pads, and any other piece of armor and clothing that can be used in game.

My problem is, even with the major differences in the model, will it still be too similar to Steve? Or is this model too different to have me sued for copyright/IP infringement?

Thanks for any input.

I just started working on the model again, This time the player can hold things and also wears shoes:


texts:
I am making a simple hangman game, I have a small list of words in a .txt file separated by new lines. I put the word list into the assets folder. How can I find the path to the word list so I can use:

string[] wordlist = System.IO.File.ReadAllLines("pathToFile");

Or is there another solution of converting the word list into a string array?


texts:
Is it possible to detect contact with every frame change when using an animation in SpriteKit? For example, if I have two nodes of a person walking, I want to detect contact with the ground each time the frame changes (the character is walking on a surface). Just can't seem to get it.

I've tried using a for loop to add a physics body and the contact and collision properties to each node, but that doesn't seem to work. It detects contact once, but that's it. Anyone have any ideas?

Thanks in advance!


texts: How do I convert a humanoid retargetted animation to a generic animation?

texts:
In my game, I use a Generic Rig model called "hero_generic".
I have a pistol-shooting animation.
This animation was created for another rig, so I need to use Humanoid retargetting to use it on my model.
To try out how it looks, I copy my "hero_generic" character, name it "hero_humanoid" and create a Humanoid avatar for it. Then I set the animation to "Humanoid", put it on an animation controller and put the animation controller onto the "hero_humanoid".
It works, the animation is now playing on my Humanoid character, but I don't want my character to be Humanoid.
I want to bake the animation out for my hero_generic character.
Unity doesn't provide any built-in option to do that.
How can I turn this retargetted animation to a generic .anim file?


texts: Does LibGDX share preferences with Android API?

texts:
Can I get a value from LibGDX preferences like this:

Preferences preferences = Gdx.app.getPreferences("someName");
int value = preferences.getInteger("intValue");

And then in the same project, in a different activity, do this:

SharedPreferences preferences = getSharedPreferences("someName",Context.MODE_PRIVATE);
int value = preferences.getInt("intValue",0);

So assuming there is a value already stored, would both methods retrieve the same value?


texts: Cocos2D: Change animation based on joystick direction

texts:
I'm trying to get my figure to look in the right directions, based on the input of the joystick. So if I tilt left it looks left and the left animation is used, if I used right, it looks right and right animation is used, if up, then up, down, down and so on. I just get animation for front and back. Also if I press up I see the back of the figure correctly, but it won't go back into the original state when I don't press up anymore.

-(void)applyJoystick:(SneakyJoystick *)aJoystick forTimeDelta:(float)
deltaTime {
    CGPoint scaledVelocity = ccpMult(aJoystick.velocity, 128.0f);
    CGPoint oldPosition = [self position];
    CGPoint newPosition =
    ccp(oldPosition.x + scaledVelocity.x * deltaTime,
    oldPosition.y + scaledVelocity.y * deltaTime);
    [self setPosition:newPosition];
    id action = nil;
   int extra = 50;
if ((int) aJoystick.degrees > 180 - extra && aJoystick.degrees < 180 + extra) {
action = [CCAnimate actionWithAnimation:walkingAnimLeft restoreOriginalFrame:NO];

} else if ((int) aJoystick.degrees > 360 - extra && aJoystick.degrees < 360 + extra) {
    action = [CCAnimate actionWithAnimation:walkingAnimRight restoreOriginalFrame:NO];
}

else if ((int) aJoystick.degrees > 90 - extra && aJoystick.degrees < 90 + extra) {
    action = [CCAnimate actionWithAnimation:walkingAnimBack restoreOriginalFrame:NO];

}
 else if ((int) aJoystick.degrees > 270 - extra && aJoystick.degrees < 270 + extra) {
action = [CCAnimate actionWithAnimation:walkingAnimFront restoreOriginalFrame:NO];
}

if (action != nil) {
[self runAction:action];
        }
    }
}


texts:
I've read two other threads here on movement:
Time based movement Vs Frame rate based movement?, and
When should I use a fixed or variable time step?

but I think I'm lacking a basic understanding of frame independent movement because I don't understand what either of those threads are talking about.

I'm following along with lazyfoo's SDL tutorials and came upon the frame independent lesson. http://lazyfoo.net/SDL_tutorials/lesson32/index.php

I'm not sure what the movement part of the code is trying to say but I think it's this (please correct me if I'm wrong):
In order to have frame independent movement, we need to find out how far an object (ex. sprite) moves within a certain time frame, for example 1 second. If the dot moves at 200 pixels per second, then I need to calculate how much it moves within that second by multiplying 200 pps by 1/1000 of a second.

Is that right? The lesson says:

"velocity in pixels per second * time since last frame in seconds.
So if the program runs at 200 frames per second: 200 pps * 1/200 seconds = 1 pixel"

But...I thought we were multiplying 200 pps by 1/1000th of a second. What is this business with frames per second?

I'd appreciate if someone could give me a little bit more detailed explanation as to how frame independent movement works.

Thank you.

ADDITION:

SDL_Rect posRect;
posRect.x = 0;
posRect.y = 0;

float y, yVel;
y = 0;
yVel = 0;

Uint32 startTicks = SDL_GetTicks();

bool quit = false;
SDL_Event gEvent;

while ( quit == false )
{
    while ( SDL_PollEvent( &gEvent ) )
    {
        if ( gEvent.type == SDL_QUIT )
            quit = true;
    }

    if ( y <= 580 )
    {
        yVel += DOT_VEL;
        y += (yVel * (SDL_GetTicks() - startTicks)/1000.f);
        posRect.y = (int)y;
    }

    startTicks = SDL_GetTicks();
    SDL_BlitSurface( bg, NULL, screen, NULL );
    SDL_BlitSurface( dot, NULL, screen, &posRect );
    SDL_Flip( screen );
}

That's code that moves a dot down the screen. I think I have everything correct so far. It moves down the screen but there is a bit of an odd thing that happens that I can't explain. The dot is supposed to stay at the y=580 when it gets to greater than that y-value. However, every time I run the program, the dot will end up in a different location, meaning a little bit to a lot more than 580, so the dot is halfway or more than halfway off the screen (the dot is 20 pixels, screen dimensions 800x600). If I do something like click and hold the title-bar of the program, and then release, the dot disappears off the screen. How come it's variable each time?
As for the titlebar problem I think it's because when I hold on to the titlebar, the timer is still running, and the time elapsed gets larger, resulting in a larger distance the dot moves in the next frame. Is that right?


texts: Scaling web game to suit any screen size

texts:
I've made a simple multiplayer game, and now trying to make it fit on any screen size. I've tried stretching it out to fit the browser size, but it just appears weird and distorted. I'm also trying to avoid having borders around the edges as it doesn't look particularly nice.

Is there a way to solve this that is fair to all players?


texts: Frustum culling only working at certain angles

texts:
So how I'm doing this is a little sketchy but I plan on changing it to either AABBs or spheres once I get it working. So the problem I'm having right now is that the frustum culling I've implemented is only working at certain angles and is not even close to accurate, personally I believe that the problem is at a calculation level. I am fairly new to 3D game development so I just whipped up this class fairly quickly based on some thread I read. My ViewFrustum class can be found here: https://www.dropbox.com/s/3b97bgcwoyh2oq8/ViewFrustum.java?dl=0

So all I'm doing outside this class is calling the update method from my renderer class and I have an ungodly amount of if statements checking if an entity's xyz is within the min and max xyz of the frustum (This is temporary).

So my main question is, am I calculating the frustum right or did I make any mistakes?

Values (when game starts, rotation matrix is a identity matrix) :

centerNear: [134.49167, 7.3502045, -271.4365]
centerFar : [134.49167, 7.3502045, -1170.7365]
points[0-7] :

[0] 2607.2214 1714.3507 -621.8992 1.0
[1] -2338.238 1714.3507 -621.8992 1.0
[2] 2607.2214 -899.70605 -1573.3379 1.0
[3] -2338.238 -899.70605 -1573.3379 1.0
[4] 136.4149 100.760254 -252.18294 1.0
[5] 132.56844 100.760254 -252.18294 1.0
[6] 136.4149 98.727104 -252.92294 1.0
[7] 132.56844 98.727104 -252.92294 1.0


texts: I have a Unity addon that generates noise via a shader. How can I use it besides just dragging it onto a mesh?

texts:
I'm probably asking this question wrong. I'm using Turbulence Library to generate noise as shaders. What I want to do is take the noise generated by these shaders and apply them to Texture2Ds that I'm procedurally generating.

What I want to do is take the value of each pixel from the noise, then while procedurally generating a texture, use to determine how much I put another color "on top of" another color in a procedurally generated mesh. I would post an example picture, but I can't do that since I can only post one link with my reputation.

I strongly suspect that I will just have to write my own shader from scratch, but is there no way to just take noise from a shader and apply it to a Texture2D so I can continue to use the Standard shader?


texts: How do I get an instance of KX_PolygonMaterial in Blender?

texts:
I've got a question concerning using Python in Blender's Game Engine.

Before I start I want to state that I'm trying to change the color of an object in Blender's game engine. To do this, I'm attempting to find a way to update the texture of the object (I basically want two or three states, red, (yellow), green).

What I'm doing right now is:

scene = GameLogic.getCurrentScene();
pingMeter = scene.objects['Ping Meter'];
mesh = pingMeter.meshes;
materials = mesh[0].materials;
material = materials[0];

However, when I do print(material.__class__.__name__) it outputs KX_BlenderMaterial. Shouldn't I be getting KX_PolygonMaterial if I'm running the Blender Game Engine? Is there anyway to change color or texture with KX_BlenderMaterial because I can't find anything in the documentation. Can I get an instance of KX_PolygonMaterial out of the code above?

...or should I just take a different approach all together?

Thanks!

EDIT: I'm using Blender 2.65 which uses Python 3 in case anyone is wondering.


texts: How do I create the terrain mentioned in GPU Gems 3

texts:
So, i want to create this style of terrain:
Nvidia GPU Gems 3 - Chapter 1

However, as much as I scour the web trying to find ways to implement this inside Unity, I can't find it.

My current understanding of 3d noise is that it is just an array of 2d noise that uses a range of -1 to 1 to determine density values (if there should be ground or air at a point in space (x,y,z), and 2d noise is just a heightmap of where you want the terrain to go.

I currently have generated simplex noise in unity that I think works (it seems to go through -1 to 1 when i call the coherentNoise() function): I would love some review on it however: pastebin.com/SiX2C31t (currently, I haven't implemented the marching squares algorithm either, would love some tips on that as well).

I've been looking at several forum questions and Unity answers, but never found anything.

All I want to do is create fascinating ridges and overhangs for an underwater terrain, and I also preferably would like to know how to do it with a lower LOD, (I want it to be low poly).

Thanks.


texts:
I was wondering how this works.

Do you load the complete map when the game starts up, or do you load parts of the map at runtime?

And how would you save the maps? Would it be in XML or some binary format?

Thanks!


texts: NullReferenceException problem when loading savegame in XNA 4.0

texts:
I want to enable my program to load "savegames", and I followed the tutorial on MSDN, but when I run my code, I get the NullReferenceException error. I use an xml file as my savegame data container, and it works, but at this point I have to rebuild my game every time I make some changes to that xml file, and I want to be able to do it during run-time. The xml file is stored in my Content folder.
This is the code of my load method:

   public void Otvori()
        {

            IAsyncResult rezultat = device.BeginOpenContainer("OtvaranjeDemo", null, null);
            rezultat.AsyncWaitHandle.WaitOne();

            container = device.EndOpenContainer(rezultat);
            rezultat.AsyncWaitHandle.Close();
            if (!container.FileExists(imeDatoteke))
            {
                container.Dispose();
                return;
            }
            Stream stream = container.OpenFile(imeDatoteke, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(PostavkeStanice));
            PostavkeStanice postavke = (PostavkeStanice)serializer.Deserialize(stream);
            stream.Close();
            container.Dispose();
        }

The compiler throws me the error at this line
"IAsyncResult rezultat = device.BeginOpenContainer("OtvaranjeDemo", null, null);"

Since this is a method in a game library, I thought it had something to do with variable definition scope, but I declared the variable in the game wide scope, and I use this method inside the Update method, so that should not be the problem?
Do you have any ideas?
Thanks


texts: How can I ensure the player learns all skills in a single open level?

texts:
I am making a game that only has a single level. It is a survival game. If there were multiple levels, I can have the player learn new skills gradually. For example, level one requires jumping, level 2 requires climbing, level 3 requires both.

As a single open-world level which is intended to be replayed multiple times, I am having trouble finding any linearity in which I can teach the player how to play the game a little bit at a time. I am tossing them to the wolves.

Is there a common strategy to force the player to learn all the necessary skills to succeed? Currently I have 4 directions which the player can travel from the starting point. Each of which teaches them something. But my fear is that they will learn a single way and then have no reason to learn the other three skills, as each skill is equally beneficial.

How can I force the player to learn all four gameplay skills when only one is required to succeed at the game? Keep in mind, because of mechanics of this particular game and there only being one level, they must have the ability to learn all 4 skills from the beginning.

I hope this is not too foolish of a question, but I am stumped on how to make the players learn all four skills without front loading a tutorial.

Reason for only one level is time and scope. Just can't make more. Gotta get this one right.


texts: In a top down game, once I have detected collision, how do I prevent it?

texts:
I'm making a top-down game in Java. I watched some videos, and this is the code I currently use when the player is colliding with an object:
x += -velX
y += -velY

When I apply force to a wall, the player dips into it, and can't move along the wall.
Does anyone have a better method?


texts: How do I perform a slice effect like Fruit Ninja?

texts: I want to do slice effect like in Fruit Ninja. Is there any class in Cocos2D like CCBlade? How can I use the CCBlade in Cocos2D on Android?


texts: different Scenes but each of them loads per frame

texts:
well i want to have something like restaurant that divided in 3 sections.and the user can switch between these but every Scene loads every frame.for example the character is in the first section and the player goes to second section and touch a customer and the character starts to go to the second section or have a button for kitchen but when the character goes to kitchen the costumers still load.i don't think that Application.LoadLevel (); could help.
thanks.


texts: Does anyone know what terrain generation algorithm is used here?

texts: Does anyone know what this terrain generation algorithm is called? I saw it in two places. One was on YouTube, and the other, on Wikimedia.


texts: How to create soft tires like in `Spintires`?

texts:
Here is an screenshot of a deformed tire in the game Spintires.

I would like to achieve a similar effect in my game
I'm using Bullet as the physics library, if that matters.


texts:
I have a camera:

//Map is a my object that wrapper of TiledMap class

In the create method:

this.renderer=new OrthogonalTiledMapRenderer(this.map.getMap();
this.camera=new OrthographicCamera();
this.camera.translate(map.getMapPixelWidth()/2, map.getMapPixelHeight()/2);
this.camera.update();
view=new StretchViewport(map.getMapPixelWidth(),map.getMapPixelHeight(), camera);
batch=new SpriteBatch();
In the update method:

this.renderer.setView(this.camera);
this.renderer.render();
this.camera.update();
batch.setProjectionMatrix(camera.combined);

ArrayList<RectangleMapObject> layer=this.getObjectsFromLayer("collision");//find collision layers
//Mouse coordinates
int x=Gdx.input.getX();
int y=Gdx.input.getY();
Vector3 coordinateScreen=new Vector3(x,y,0);
Vector3 coordinateWorld=camera.unproject(coordinateScreen);
Rectangle rectMouse=new Rectangle(coordinateWorld.x,coordinateWorld.y,20,20);
for(RectangleMapObject rect: layer)
if(Intersector.intersectRectangles(rectMouse, rect.getRectangle(), rectMouse)){
                    System.out.println("COLLISION MOUSE-MAPOBJECT ");}

public ArrayList<RectangleMapObject> getObjectsFromLayer(String layerName){

        ArrayList<RectangleMapObject> array=new ArrayList<RectangleMapObject>();

        MapObjects og=this.map.getMap().getLayers().get(layerName).getObjects();

        for(MapObject object : og)
            if (object instanceof RectangleMapObject)
                array.add(((RectangleMapObject) object));
        return array;
}

My problem is that the collision between mouse and mapobject never occurs Also if I click on the area where stands the MapObject. I think it is a problem of conversion of the coordinates of the mouse. Thank you for your time.


texts: Collision Detection/Response in Vector-based levels

texts:
I have a 2D side scroller whose levels are stored as vectors (that is, a bunch of lines) which looks like this:

How would I detect that I'm colliding with one of these lines, and react accordingly (say, slide down the slope, or stand still on a flat platform)? We can assume the player uses an AABB.


texts:
I am working on an entity-component system, and I am thinking about this communication protocol:

The physics component of a game object sends an UpdateMyState message, with its state attached.
The physics engine receives this.
The physics component sends a pointer to its data, and the physics engine changes the state. Because it is a pointer, no messaging back is required.

The standard way involves the physics engine sending back an UpdatedState message, with the new state attached. This will be processed by the physics component. I am not sure if my way is a good exercise. It is not a complete message-based system, but it decreases the amount of required messages, and it simplifies the system.

What are the advantages and disadvantages of using pointers to change data in my physics engine?


texts:
I recall Mojang stating they would release the source code of Minecraft sooner or later, but searching both on google and on Minecraft sites I wasn't about to find it.

So... is it available somewhere? With what license?

PS: not interested in sources decompiled from the binaries, only in genuinely officially released sources.


texts: Online service and/or application to develop a story line for an adventure game

texts:
My friends and I were talking about an adventure game. There will be a surplus of possibilities in the game and the player can pick from this wide variety of choices at each stage to do something. There will be consequences for each decision and that may or may not end the story.

The result would be somthing like this:

(picture from flashforward series S01E17)

If any of you watched heroes season 1 there is also similar time lines represented as strings in isaac mandez workshop. Sorry for bad quality examples but right now I can't think of any better one.

Do you know any website or application which we can use to create the timeline?

These features are required:

The ability to represent events as boxes.
The ability to connect distant events to each other.
The ability to move events on a scene freely
The ability to expand the scene easily
There should be some color options for the lines representing connections between events
Easily sharing the idea with one another
It's much more better to have a WYSIWYG editor
Easily explore in the large scene of events

In the end if you know any application which could let me create a board just like the one in my sample picture and please share it


texts: How do I cap rendering of tiles in a 2D game with SDL?

texts:
I have some boilerplate code working, I basically have a tile based map composed of just 3 colors, and some walls and render with SDL. The tiles are in a bmp file, but each tile inside it corresponds to an internal number of the type of tile(color, or wall).
I have pretty basic collision detection and it works, I can also detetc continuous presses, which allows me to move pretty much anywhere I want. I also have a moving camera, which follows the object.

The problem is that, the tile based map is bigger than the resolution, thus not all of the map can be displayed on the screen, but it's still rendered. I would like to cap it, but since this is new to me, I pretty much have no idea.

Although I cannot post all the code, as even though I am a newbie and the code pretty basic, it's already quite a few lines, I can post what I tried to do

void set_camera()
{
    //Center the camera over the dot
    camera.x = ( player.box.x + DOT_WIDTH / 2 ) - SCREEN_WIDTH / 2;
    camera.y = ( player.box.y + DOT_HEIGHT / 2 ) - SCREEN_HEIGHT / 2;

    //Keep the camera in bounds.
    if(camera.x < 0 )
    {
        camera.x = 0;
    }
    if(camera.y < 0 )
    {
        camera.y = 0;
    }
    if(camera.x > LEVEL_WIDTH - camera.w )
    {
        camera.x = LEVEL_WIDTH - camera.w;
    }
    if(camera.y > LEVEL_HEIGHT - camera.h )
    {
        camera.y = LEVEL_HEIGHT - camera.h;
    }
}

set_camera() is the function which calculates the camera position based on the player's positions. I won't pretend I know much about it.

Rectangle box = {0,0,0,0};

for(int t = 0; t < TOTAL_TILES; t++)
{
    if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT))
        apply_surface(box.x - camera.x, box.y - camera.y, surface, screen, &clips[tiles[t]]);

    box.x += TILE_WIDTH;

    //If we've gone too far
    if(box.x >= LEVEL_WIDTH)
    {
        //Move back
        box.x = 0;

        //Move to the next row
        box.y += TILE_HEIGHT;
    }
}

This is basically my render code. The for loop loops over 192 tiles stored in an int array, each with their own unique value describing the tile type(wall or one of three possible colored tiles).

box is an SDL_Rect containing the current position of the tile, which is calculated on render.

TILE_HEIGHT and TILE_WIDTH are of value 80.

So the cap is determined by

if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT))

However, this is just me playing with the values and see what doesn't break it. I pretty much have no idea how to calculate it.

My screen resolution is 1024/768, and the tile map is of size 1280/960.


texts: How can I programmatically add a Controller to an Animator during runtime?

texts:
I am trying to set the Controller of an Animator during runtime using a script.
When I click on the dot in the inspector manually, I can choose one called "Standard Walk", but have not found a way to automate it.


texts: I create a 3D character in Blender and animated it. How do I use it in my Game with LWJGL

texts:
I have a character and he is animated with the Skeleton or Bone Structure but I don't know how to animate him in my game from scratch.

I am using Java with LWJGL.

I am loading static Objects with the Obj file format but obj does not support bone animation.


texts:
I'm writing a 3D rigid body physics engine, I am using OpenGl for simulation.

Only convex objects are considered.

My question involves how to detect the point of collision, so that when I apply a response force, I can also calculate torque.

I have used SAT algorithm to detect collision according to this reference,

Everything seems to be work fine , But as i get SAT only gives for objects are they colliding? as well as by how much?, it does NOT give you a reference point at which to apply the response force (and thus calculate torque).

I have looked at

Resource 1

Resource 2

Resource 1

None of them seems to be an answer


texts:
I have a head-to-head game where two players communicate through a server based on TCP.

I am planning to implement a ping/pong mechanism in order to detect network disconnection situations. For example,

A pings B every 500ms.
If A receives no response from B, A shall consider B is disconnected.
If A receives no response from the server, A shall consider A is disconnected itself.

Do you think this ping/pong system is needed or other method is recommended?


texts: How to know which methods are associated with an event?

texts:
In Unity events are used as enhanced delegates.
This is extremely helpful in developing clean concise event management scripts.

However, when debugging said scripts and complex arrangements, is there a way I can see which methods are in an event at any one time?

Simplified Example:

Game manager

using UnityEngine;
using System.Collections;

public class EventManager : MonoBehaviour
{
    public delegate void ClickAction();
    public static event ClickAction OnClicked;

    void someMethod()
    {
        if(whatever = true && OnClicked != null)
        {
            //this is the event delegate:
            OnClicked();
        }
    }
}

gameObject script
(one of several scripts that can add methods to an event )

using UnityEngine;
using System.Collections;

public class TeleportScript : MonoBehaviour
{
    void SomeMethod()
    {
        EventManager.OnClicked += Teleport;
    }

    void SomeOtherMethod(){
        EventManager.OnClicked += Horses;
    }

    void OnDisable()
    {
        EventManager.OnClicked -= Teleport;
        EventManager.OnClicked -= Horses;
    }

    void Teleport()
    {
        Vector3 pos = transform.position;
        pos.y = Random.Range(1.0f, 3.0f);
        transform.position = pos;
    }

    void Horses(){
         instantiate(horses, new Vector3.zero, Quaternion.identity);
    }
}

etc. etc.,

I have used Debug.Log(OnClicked.Method); but this only returns one of multiple methods associated with an event.

So my issue is, that for debugging and general error resolution, how can I find out which method(s) are in the OnClicked() event delegate without/before running this delegate?

For example:

Debug.Log(OnClicked(listMethods));

  //Output to log:
  void Teleport();
  void Horses();


texts: I see free asset being sold on another site. How and where do I complain?

texts:
We all know that there are many repositories and marketplaces for 3D models on the internet. The specific problem I have now is with this 3D asset for sale on a site. It was made for sale a short while ago. The same model is available at another place for free under a CC license, and was first uploaded years ago. Furthermore, the same 3D model was made available for download for free under a personal use license at another place even earlier, about 6 years ago.

My problem is I don't know who to complain to or which person I should complain about. Normally my gut reaction when I see this sort of stuff is that the paid product has made its way around and been made available for free by someone. However it could easily be the other way around. The seller most who most recently uploaded the model looks suspicious. There is hardly any information that would reflect their knowledge of the actual model. Anyone who's done modelling of real objects before will know the extensive references one must use to make an accurate model

At least one person is in breach of copyright, and most likely the code of conduct on their respective site.

If for example the original author is Person 1, then Person 2 selling the model is breaching this license, because it's a non-commercial license. If on the other hand the original author is Person 3, then Person 2 may sell the model, but they need to fulfill the attribution requirement, which they haven't. If however the original author is Person 2 (the person selling the model), then the other two are in breach of the license.

Most likely the model (which appeared in 2013) is proprietary and copyrighted content and all three are in fact in violation of copyright (well, that's what I think is most likely). The asset may be ripped from a AAA commercial game, as was the case with a model I found recently which came from an ARMA military game.

I don't who to complain to or who to complain about. I thought someone could point me in the direction of the best way to go about this, as I think this community has some experience in handling 3D assets and licenses, and many of you who are in the industry or are experienced with this sort of misconduct might know the best way to approach this.


texts:
Suppose you have a nice way to move your 2D particles in order to simulate a fluid (like water). Any ideas on how to render it?

This is for a 2D game, where the perspective is from the side, like this. The water will be contained in boxes that can be broken in order to let it fall down and interact with other objects. The simplest way that comes to my mind is to use a small image for each particle. I am interested in hearing more ways of rendering water.


texts: How to determine what direction an object should orbit around another

texts:
I am creating a game in Unity with 2D. When a button is clicked a static object is attaching a hinge joint to a dynamic object, so the dynamic object orbits it. When the dynamic object gets attached, I am setting the dynamics objects transform.up vector to be pointing at the static object. Then, taking what ever the dynamic objects magnitude was and setting that as its velocity to the right. I do this because I want the dynamic object to orbit the planet at the same exact speed as when it wasn't orbiting.

The problem I am having, is I don't know how to determine if the object should orbit clockwise or counter-clockwise. It's easy for me to determine this when I look at an image, but I don't know how to via code.

Here is an example

Does anyone know how I can determine this?


texts: Libgdx: touchup fired even when figure not on texture

texts:
I've implemented a touchup listener for an actor in stage. Now what happens is that when user touch downs the sprite and releases finger, its all good. The problem is when user touch downs the finger, and drag it somewhere else (possibly to cancel the touch) and releases, it still fires the touch up event as if nothing ever happened. How do I stop that? Here's my code:

voiceToggle.addListener(new InputListener() {
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        System.out.println("touched");
        return true;
    }

    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        System.out.println(event); // still fires even if not on original touchdown element
    }
});


texts: How to move sprite on z-axis in 2D Unity

texts:
I am making a 2D game and I am having trouble in setting up a sprite movement. Here is a picture for reference what I want to achieve:

Now car is moving forward (I have done that using road and car animations). And time after time a traffic light comes. It gets larger when car comes close to it.
How can I do it in 2D. Because z-axis have no effect on it.
My camera is set to orthographic.


texts:
I have created a scene with a blue sphere inside of a white room of planes. The room is being lit by a point light above the roof, and the sphere is emitting a blue light.

How do I get the emission from the sphere to contribute to the lighting of the walls without making it static?


texts: Jagged transparency when rendering translucent textures (OpenGL 3.2 + GLSL)

texts:
Like most others, I'll start off mentioning that I'm still a beginner when it comes to OpenGL and GLSL programming. So bear with me on any dumb mistakes you may spot in the code ahead.

I'm basically trying to render a model of a girl whose hair is implemented with transparent TGA textures. In my code I've setup OpenGL 3.2 (core profile, no fixed function calls) with the following calls before rendering the model's geometry (in clock-wise order):

glEnable(GL_DEPTH_TEST);
glEnable(GL_DEPTH_CLAMP);
glDepthMask(true);
glDepthFunc(GL_LEQUAL);
glDepthRange(0, 1);
glClearDepth(1.0);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

In my fragment shader, I'm doing alpha premultiply of the textures coming in and I'm also discarding fragments with an alpha value lower than 0.5, like so:

vec4 SampledColor = texture2D(gColorMap, TexCoord0.xy);

SampledColor.rgb *= SampledColor.a;

if (SampledColor.a < 0.5) {
    discard;
}

FragColor = SampledColor * TotalLight;
FragColor.a = SampledColor.a;

The rendered image does display some transparency, but the model's hair looks jagged, here's a snapshot:

http://i32.photobucket.com/albums/d9/_Silencer/Samples/test_002.png

And here's the base texture being used to sample color values:

i32 . photobucket . com/albums/d9/_Silencer/Samples/sample.png

(note: photobucket only allowed me to upload sample as .png :P, but it's a TGA file).

I know for sure that the hard jaggies happen because I'm telling the shader to discard the fragment if falls below my arbitrary alpha threshold. What I'm wondering though is if there's any way to smoothly display the transparent pixels in the texture, pretty much like what can be seen on the right side of the rendered image, where the hair texture does blend in well with the gray background color.

I'm also pretty sure that I'm feeding an appropriate transparent image to OpenGL, but I can't find a way to get rid of the jagged artifacts.

Now, if I don't discard the fragment in the Fragment shader, the rendered hair texture will still appear transparent, but the "background" of the geometry adopts the background color of the color buffer, like so.

http://i32.photobucket.com/albums/d9/_Silencer/Samples/test_001.png

I've read that I may need to draw the geometry in sorted order according to the distance from the current viewpoint but I'm not sure how could I determine that with the hair chunks in this case.

So clearly I'm not understanding how to correctly handle translucent textures in rendered geometry. There has to be a nice way to do this since many games show this kind of textures correctly.

UPDATE The longer I continue investigating the subject, it seems that this is not a trivial problem. I may need to implement some sort of order independent transparency technique. I read that this can be done on OpenGL 4.0 capable hardware. What about OpenGL 3.3 hardware?

I appreciate any pointers or advice anyone could provide.

Thank you for your time and help!


texts:
I'm making my first real video game. You have to click either on the left or right side on time or else you lose (note: the code I'm about to post doesn't have the timing, don't worry about that, I haven't added it yet). My question is why when the player clicks a UI button that's on the left or right side based on where they're instructed to click, nothing... happens. This is the main script, and all of it is relevant because the whole game isn't done yet, and this small amount is just what I've created so far.
I have done my research. I have been looking up everything I can think of for the past day now.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Advertisements; // coming soon

public class Game: MonoBehaviour {

  public Button playBtn;

  public Button clickSideLBtn;
  public Button clickSideRBtn;

  public Text clickSideLTxt;
  public Text clickSideRTxt;

  public Image playIcon;
  public Image pauseIcon;

  private float correctSide = 0;

  private GameManager gameManager;

  private bool hasAnswered = true;

  private AudioSource audioData;

  private void setSideActive(float side, bool state) {
    if (state) {
      correctSide = side;
    } else {
      if (side == 0) {
        correctSide = 1;
      } else {
        correctSide = 0;
      }
    }

    if (side == 0) {
      clickSideLTxt.gameObject.SetActive(state);
      clickSideLBtn.gameObject.SetActive(state);
    } else {
      clickSideRTxt.gameObject.SetActive(state);
      clickSideRBtn.gameObject.SetActive(state);
    }
  }

  void Start() {
    audioData = GetComponent<AudioSource>();

    gameManager = GetComponent<GameManager>();

    pauseIcon.gameObject.SetActive(false);

    gameManager.gameIsStarted = false;

    setSideActive(0, false);
    setSideActive(1, false);

    StartCoroutine(HandleUpdate());
  }

  private IEnumerator HandleUpdate() {
    for (;;) {
      DoUpdate();

      yield return new WaitForSeconds(2.0f);
    }
  }

  void DoUpdate() {
    if (gameManager.gameIsStarted && hasAnswered) {
      hasAnswered = false;

      if (Random.value > 0.5f) {
        setSideActive(0, true);
        setSideActive(1, false);
        audioData.Play(0);
      } else {
        setSideActive(1, true);
        setSideActive(0, false);
        audioData.Play(0);
      }
    }
  }
  void OnEnable() {
    //Register Button Events
    playBtn.onClick.AddListener(() => playBtnCallback());
    clickSideRBtn.onClick.AddListener(() => clickSideR());
    clickSideLBtn.onClick.AddListener(() => clickSideL());

  }

  private void playBtnCallback() {
    if (gameManager.gameIsStarted) {
      gameManager.EndGame();
    } else if (!(gameManager.gameIsStarted)) {
      gameManager.gameIsStarted = true;
      playIcon.gameObject.SetActive(false);
      pauseIcon.gameObject.SetActive(true);
    }
  }

  private void clickSideR() {
    if (correctSide == 1) {
      hasAnswered = true;
      setSideActive(1, false);
      // yay, you did it right, don't do anything, other scripts keep the game alive until you tell it not to
    } else {
      gameManager.EndGame();
    }
  }

  private void clickSideL() {
    if (correctSide == 0) {
      hasAnswered = true;
      setSideActive(0, false);
      // yay, you did it right, don't do anything, other scripts keep the game alive until you tell it not to
    } else {
      gameManager.EndGame();
    }
  }
}


texts: Cocos2d patterns for simple texture management

texts:
I'd like to simplify the way I preload image resources in my Cocos2d based iOS apps. I've created a small object the just wraps a few of CCTextureCache's methods. It looks like this:

@interface TextureHelper : NSObject
+ (void) preloadTextures;
+ (CCTexture2D *) textureForImageNamed:(NSString *) imageName;
@end

@implementation TextureHelper
+ (CCTexture2D *) textureForImageNamed:(NSString *) imageName {
    return [[CCTextureCache sharedTextureCache] textureForKey:imageName];
}

+ (void) preloadTextures {
    // or could read from a directory...
    NSArray *imageNames = @[
    @"myImage1.png",
    @"myImage2.png"
    ];

    for (NSString *imageName in imageNames)
        [[CCTextureCache sharedTextureCache] addImage:imageName];
}
@end

The goal is to preload all images at start-up. Then during game play any sprites created on the fly won't cause images to be read from disk. What are some other  more common and/or more effective patterns for achieving this?


texts:
I am working on a game using libgdx and I have the following code that I want to optimize.

    Array<Bullet> enemyBullets = Enemy2.getEnemyBullets();
    for (Bullet bullet : enemyBullets) {
        c = bullet.getHitBox();
        debugRenderer.circle(c.x, c.y, c.radius, 5);
    }

Basically I just have a big array of objects that I want to preform some action on and I am not sure if this is the best way to do it. I'm not sure if it would be better to use a pool or try to use an iterator instead. I am just not really familiar with these things and I need some help.


texts: Fastest way to assign sprites to components in Unity

texts:
I'm using a sprite atlas and Unity's built-in sprite editor to tease out the individual images. Specifically, I have a single texture containing lots and lots of icons for armor, and I am assigning those to a Sprite[] field of a Component.

However, the process of manually assigning sprites to the component -- via drag and drop -- is tedious. Is there a faster way to do this? Perhaps a way I can bulk assign sprites to a component?

Update: This is the code of the final solution. In short, the easiest thing to do is to put the texture atlas in the /Resources folder and then programmatically access the sprites by name.

private void MergeTextureAtlas(string atlasName, Dictionary<ItemSubType, List<Sprite>> spriteLookup) {
    Sprite[] atlasSprites = Resources.LoadAll<Sprite>(atlasName);
    Assert.IsNotNull(atlasSprites, atlasName);
    Assert.IsTrue(atlasSprites.Length > 0, atlasName);

    int spritesLoaded = 0;
    foreach (ItemSubType itemSubType in Enum.GetValues(typeof(ItemSubType))) {
        string subTypeFriendlyName = ItemSubTypeHelper.GetSubTypeName(itemSubType);
        foreach (Sprite atlasSprite in atlasSprites) {
            if (atlasSprite.name.Contains(subTypeFriendlyName)) {
                if (!spriteLookup.ContainsKey(itemSubType)) {
                    spriteLookup.Add(itemSubType, new List<Sprite>());
                }
                spriteLookup[itemSubType].Add(atlasSprite);
                spritesLoaded++;
            }
        }
    }

    if (spritesLoaded == 0) {
        Debug.LogWarning(String.Format(
            "Found 0 new sprites in texture atlas '{0}'.",
            atlasName));
    }
}


texts:
I am making a game in unity that allows you to destroy terrain, The problem I am having is that the farther away that I get from the origin (0,0), The more inaccurate the point where the destruction occurs is. Is there a way to make it more accurate?

// Use this for initialization
void Start ()
{
    //The width and height of the heightMap
    xRes = TerrainMain.terrainData.heightmapWidth;
    yRes = TerrainMain.terrainData.heightmapHeight;

    //Getting the heightMap points
    saved = TerrainMain.terrainData.GetHeights(0, 0, xRes, yRes);
    heights = TerrainMain.terrainData.GetHeights(0, 0, xRes, yRes);
}

void TerrainDestruction()
{

    Vector3 actualPosition;

    actualPosition.x = MyPosition.x;
    actualPosition.y = MyPosition.y;
    actualPosition.z = MyPosition.z;

    //Getting the x and y position of the player
    int xPosition = (int)(actualPosition.x);
    int zPosition = (int)(actualPosition.z);

    Debug.Log("x: " + xPosition);
    Debug.Log("z: " + zPosition);

    heights[zPosition, xPosition] -= 0.001f;

    TerrainMain.terrainData.SetHeights(0, 0, heights);

    TerrainMain.terrainData.SetHeights(0, 0, heights);

}

void OnApplicationQuit()
{
    TerrainMain.terrainData.SetHeights(0, 0, saved);
}

// Update is called once per frame
void Update ()
{
    //Getting the actual Position of the player with respect to the terrain
    MyPosition = MyMouse.mousePosition;

    if (Input.GetMouseButtonDown(0))
    {
        TerrainDestruction();
    }
}


texts: Can you do a stencil glow with native GM:S commands?

texts:
I am looking to a stencil glow on GM:S with d3d_* functions.

I could not find anything how to access the stencil buffer though.

Is it even possible to access the stencil buffer without using an external .dll?


texts: How can I create a "fuzzy crayon" effect?

texts:
I spent sometime looking at Media Molecule's Dreams. In it, the user is allowed to  fuzzy crayon strokes in the mid air (in 3D space)(at the point of the video around 43:00).

How can I implement a similar effect? Is it a polygon with texture or some complex particle system? I believe it have something to do shader but not sure how.


texts: How can I implement path finding with obstacles between cells?

texts:
I'm trying to make a game at the moment and have some trouble with the A* algorithm for path finding.

In the picture the orange and rainbow cells are walkable, but the orange cells have walls around them that should not be crossed. I don't know how to define these walls for my A* algorithm.

So my player is going over the wall to get to the point (red path) but I want it to avoid the wall (green path).

I'm currently using this library: astar-javascript but I can't define "special" cells with it that could be crossed on one side only.

If anyone has an idea, thank you :)


texts:
Currently I've got a map like this:

It's pretty simple but what I want is that area of tiles to be random, with the number of tiles present being random (Within a minimum and maximum amount of tiles of course) and the positions of the tiles being random (but still all connected to each other), but I'm not exactly sure how I should go about implementing that.

I'm sort of looking for a system that will generate random sections of tiles, a bunch of tiles within a group at random positions around the screen with all these sections being connected to each other via a larger section of tiles.
Like the example shown in this perfect drawing I've quickly done:

Each square would be a group of tiles, they're all of different shapes and sizes but all connected together via another large (or small) group of tiles in the middle.

I have looked into grid map generation before making this post but all the information I found would tend to go over more advanced map generation methods that have multiple layers which is not really what I need for my game so I was wondering if someone would possibly be able to advice me on what the best method would be to do this?

I'd very much appreciate it.


texts: How to set a static size for an object in GameMaker?

texts:
I have many sprites with different sizes, and I have an object in which I set those sprites, but this object gets resized by the currently displayed sprite.

How can I set a fixed size for the object so that it can no longer change size?

Thanks for any help.


texts: How do I load a texture in OpenGL where the origin of the texture(0, 0) isn't in the bottom left?

texts:
When loading a texture in OpenGL, how do I specify the origin of the data I am loading?

For example, how would I load a Targa that has it's origin at the top left instead of the bottom left of the image?


texts: Make non-sprite render in front of sprite

texts:
How do I make the non-sprite (BasicSpellProjectile) render in front of the sprite (Tower 2)?

Note: The camera is located at z=-10.

The z positioning apparently doesn't do anything, and I am unable to set the sorting layer/order of the non-sprite as there isn't one such option.


texts: What is the class name in Unity's AddComponent?

texts: Unity's AddComponent() method has an optional parameter of a string.  This string is the className.  What is the class name?  What is it used for?  I could not find any documentation on this.


texts: Z axis for player movement is being incremented, but i don't know how

texts:
I'm currently learning and developing a 2D plataform game in Unity, but now i'm having some errors that i can't solve.

When I press the arrow keys to make my character move right and left, the Z axis is being incremented somehow,and the player is "getting into the screen", even though I didn't write anything about it in my script.

I read about the "Apply Root Motion" in the Animator segment, and I unmarked it as they said, but I think the error might still be there, but i'm not sure.

Does anyone know about it?

Here is a snippet of my code:

void Movement() {
    anim.SetFloat ("speed", Mathf.Abs (Input.GetAxis ("Horizontal"))); //Makes it record a value of speed between -1 and 1, so that the trigger of the animation can work.

    if (Input.GetAxisRaw ("Horizontal") > 0) {
            transform.Translate (Vector3.right * speed * Time.deltaTime);//speed * Time.deltaTime makes things smoother, it updates frame by frame, so that it does not jump all around
            transform.eulerAngles = new Vector2 (0, 0);
    }

    if (Input.GetAxisRaw ("Horizontal") < 0) {
            transform.Translate (Vector3.right * speed * Time.deltaTime);
            transform.eulerAngles = new Vector2 (0, 188);
    }


texts:
This is the code for Raycast:

RaycastHit hit;
Vector3 direction = transform.forward;

Debug.DrawRay(transform.position, direction * 200f, Color.red, 0.1f);

if(Physics.Raycast(transform.position, direction * 200f, out hit, 200f)) {
    if(hit.transform.tag == "Enemy") {
        // do something with enemy
    }
}

I'm shooting the ray to in front of the object, but it's not quite working to me.

These are the screenshots:

As you can see above second picture, shot the ray to forward, but actual ray wasn't forwarded.

I also rotated the ray z axis 90 or -90 degree, but stil not working. (Actually I tried to rotate each axis 90 and -90, but nothing seems work)

Vector3 direction = Quaternion.Euler(0, 0, 90) * transform.forward;  // Doesn't work
Vector3 direction = Quaternion.Euler(0, 0, -90) * transform.forward;  // Doesn't work either

What am I missing?


texts: How to make Line Renderer lines stay flat?

texts:
I've noticed that as I add more vertexes to a Line Renderer line the line twists and stops being a smooth line.

.GIF Here: http://i.imgur.com/hRAhCXM.gif

All lines are on the same z level, even if I remove the materials the lines still seem to twist.

I have no idea why it does this, or how to go about resolving it, any suggestions?C#


texts:
I use a C# script to move the vertecies of my quad around the world space.
It works perfectly fine, but when I move/ rotate the camera away, so it does not look at the position of the quad, the quad disappears.

I cannot change the size of the quad, since that would not work with my other scritps.

How can I force the camera to allway render the mesh of the quad?


texts:
I've been looking for a way to efficiently manage the pixels on a screen, but so far all I've found is along the lines of SetPixel(), in Windows, and drawing a rectangle 1px by 1px, in OpenGL. Both of these methods seem to be too slow, since I'm looking for a way to constantly update the pixels on the screen at at least 30 FPS.

I need a way to do this, so I can make a non-polygon based graphics engine. I'm sure this is possible, since OpenGL and DirectX can do it, but I have a suspicion I'm going to need direct access to the video memory. I just need some direction to work in, since I'm not really sure where to start. This is primarily to see if I can do it, since it seems like a good challenge.

How do I efficiently manage the pixels, on the screen?


texts: Calculating distance for Gauss Map optimized SAT

texts:
There's an optimization method for the separating axis test in 3D that uses Gauss Maps to discard certain redundant axes from the set of axes that need to be tested generated by edge-edge cross products.

A detailed presentation can be found here.
Along with some source code.

The presentation also states that using the Gauss Map method lets you compute the distance between the two polyhedra along the separating axis orthogonal to corresponding edges (i.e. ones that the Gauss Map method doesn't discard) in O(1).

This is done by considering the plane formed by the cross product of the two corresponding edges fixed on one edge, and finding the minimum distance from a vertex to the plane on the corresponding edge.

My question is:

Why isn't the distance found this way in the general case when testing the axis formed from the cross product of two edges (i.e. when not using the Gauss Map optimization)?

Generally the method I see used is projection intervals, or fixing the plane for the separating axis to its corresponding edge or face on one polyhedron, and ensuring all vertices of the other polyhedron fall outside.


texts:
I am trying to create a custom map format for my own little 2D RPG, so my question is rather how do I manage reading and creating a custom map format properly and flexible. First off, I am writing my code in Java. The idea was to have a class called 'TileMap'. This class defines a 2-dimensional integer - array where all my entities are stored ( I'm using an entity-system to realize my game ). I also want to save and parse some information about the size of the map before the actual reading process happens. The map file should look much like this:

#This is a test map
width=4
height=3
layercount=1
tilesize=32

[1;0;0;0]
[23;1;0;0]
[5;0;1;0]

where layercount is the number of layers the z-dimension offers. and tilesize is the size of every tile in pixels. Entities are defined in between the brackets. The pattern goes: [entity_id;x_pos;y_pos;z_pos]. I already wrote the code to parse a file like this but its not very flexible because you just have to put one tiny whitespace in front of the square brackets and the map can't load up.
I just need some few helpful tips to do this in a flexible way. Can anybody help me out?


texts: Comparing meshes and reducing duplication of data

texts: I'm writing a class that reads an obj file, indexes each mesh and creates a VAO and GameObject of the appropriate type. I've stumbled on a design issue. Objects of the same name (Tree_A001, Tree_A002) are currently skipped over, and their min and max extents are used to calculate their centre, and therefore where to position the a copy of that mesh. Not only does this mean I've read in the mesh twice, just to ignore all the data as soon as I've got the min and max, but in my case I have 230 trees. It works but takes 12-15 seconds to read in the file itself, and I've not been able to gleam the rotation or scale of said object. I understand that comparing the min and max extents of the duplicate mesh to the original could let me get the scale,  but as soon as the mesh is rotated in the scene file then it breaks. I'd like to do something more efficient than this however, and I'm stuck on what do to. What is the done thing in professional games, that allows multiple objects to be placed in a 3d modelling software, and their individual position rotation and scale to be kept? I've experimented with using single triangles to represent the position and scale etc but it makes designing the scene much harder as you can't see what you're placing. Thanks for any advice


texts: How are advanced graphics effects implemented?

texts: I'm curious how 3D effects like spells in Warcraft or Torchlight are implemented graphically. I just finished a book on Direct3D and feel pretty comfortable with it and 3D graphics in general, but I am not sure how I'd do something like have a character 'cast a lightning bolt' or some other spell graphically. I would assume it has to do with particle effects or animated texture coordinates, anybody able to give me some more specific insight? Thanks


texts: Moving the bulk of a recursive ray tracer function to the gpu, using DirectX12 not DirectX 12 DXR HLSL

texts:
So I'm wanting to generate images by ray tracing. I've done so, but the main ray function is recursive. I know one can make a non recursive function out of a recursive function using a stack, but is it possible to do in HLSL? I have the bulk of the function I'm using here:
color ray_color(
    const ray& r,
    const color& background,
    const hittable& world,
    const shared_ptr<hittable>& lights,
    int depth) {

hit_record rec;

// If we've exceeded the ray bounce limit, no more light is gathered.
if (depth <= 0)
    return color(0, 0, 0);

// If the ray hits nothing, return the background color.
if (!world.hit(r, 0.001, infinity, rec))
    return background;

scatter_record srec;
color emitted = rec.mat_ptr->emitted(r, rec, rec.u, rec.v, rec.p);

if (!rec.mat_ptr->scatter(r, rec, srec))
    return emitted;

if (srec.is_specular) {
    return srec.attenuation
        * ray_color(srec.specular_ray, background, world, lights, depth - 1);
}

auto light_ptr = make_shared<hittable_pdf>(lights, rec.p);
mixture_pdf p(light_ptr, srec.pdf_ptr);
ray scattered = ray(rec.p, p.generate(), r.time());
auto pdf_val = p.value(scattered.direction());

return emitted
    + srec.attenuation * rec.mat_ptr->scattering_pdf(r, rec, scattered)
    * ray_color(scattered, background, world, lights, depth - 1)
    / pdf_val;
}


texts: in an ECS framework why are components indexed via their name rather than an Enum?

texts:
I have been reading through a number of discussions on ECS framework and very often I see components being referred to via name rather than through a string object such as an enum or a struct.

I'm starting to build a test implementation myself and feel as though they should have a strong type rather than a string so that I can pick the component I am looking for from a list rather than 'guessing' with a string.

As an example you will often see:

Entity.GetComponent("Position");

rather than:

Entity.GetComponent(ComponentTypes.Position);


texts: How would I move an object using its velocity on a closed curve?

texts:
I want that an object follows a path, in Peggle game there are some pegs that have
movement in a closed path. How can i get the same result? I guess that I can use parametric curve but I need use the velocity and not the position (x, y).

I use NAPE and I have this in my gameloop:

//circunference
angle = angle + 1*(Math.PI / 180);
movableBall.position.x = radius * Math.cos(angle)+ h;
movableBall.position.y = radius * Math.sin(angle)+ k;

It works but I can not control the velocity, each movableBall must have its own velocity.
Besides, from docs of NAPE:

  "Setting the position of a body is equivalent to simply teleporting
  the body; for instance moving a kinematic body by position is not the
  way to go about things.."

I want to use:

movableBall.velocity.x =??
movableBall.velocity.y = ??

The final idea is to follow others paths like the Lemniscate of Bernoulli.


texts: In GameMaker Studio, how can I make an auto-updater for my game?

texts:
I would like to let players update their copy of my game by clicking a button, which would:

Check for updates
Download the update
Prompt the user to restart the game

I want to do this because my friends hate to re-download my game each time I make a change.

Is this possible with GameMaker? If so, how?

I have Dropbox premium, could I take advantage of that?


texts: Reliably synchronising SDL animation with VSYNC in windowed mode

texts:
I have an SDL/OpenGL program which creates a rendering context with PRESENTVSYNC enabled, then enters an animation loop which calls SDL_GL_SwapWindow each time around. On my own machine, the animation works fine at a sensible speed, but on my office machine it runs with no vsync delay at all resulting in the animation running at breakneck speed and tearing all over the frame. Adding a sleep() to the animation loop slows it down sensibly.

I know that I can use SDL_GL_GetSwapInterval to see if swapping is being synchronized or not, but is there a way to find out what the actual refresh rate of the screen is in order to know how long or short the sleep should be?


texts: How to render in an entity component system?

texts: I am currently working on a game in Java that uses an entity component system. The game currently has two separate update() and render() methods in the game loop however this does not seem to fit with my entity component system. From what I understand, each system in an ECS has an update method but what about say, a rendering system that draws sprites to the screen? How does rendering work with an ECS? One idea could be to have systems that draw on the screen implement a RenderSystem interface so that they are only used in the rendering method but I've never seen anything like this. Is there a certain way of doing this?


texts: When I use a font in my game, do I have to include its license in the credits?

texts:
For example, if I use this font from Google Fonts:
https://fonts.google.com/specimen/Open+Sans

This font is licensed under Apache License 2.0
But regardless of the license, if it allows commercial use, do I have to include a notice or the license in the credits? (assuming that I didn't modify the font)


texts: How to create a fog for baclgro6 which works on mobile devices?

texts: There is a forum entry, which explains how to create a high based volumetric fog, using soft particles ( How can I create a height-based volumetric fog? ). Unfortunately it doesn't work on mobile devices. Does anyone know a solution, how to create this effect which can be used for mobile?


texts: Unity 3D: How to stop/reset 2D sprite animation after releasing key?

texts:
Im following a tutorial to create animations with a 2D sprite character.
But i put in my own. Which has 8 animation positions.
For some reason when my guy walks around,then stop, the walkings animation continues to play out then resets to idles.

I need the animation to reset as soon as i release the key.

Im using Animator if you are wondering.

EDITED:
Original video with all the keys for each animations.
Youtube video

Second video with only 2 keys per animation, it was a test.
Second Video Here

Code Snipet!

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

public float speed;

private Animator _animator;
private Rigidbody2D _rigidbody2D;

// Use this for initialization
void Start () {
    _animator = GetComponent <Animator>();
    _rigidbody2D = GetComponent <Rigidbody2D>();
}

// Update is called once per frame
void Update () {
    CheckDirection();
}

void CheckDirection(){
    if (Input.GetKey (KeyCode.A))
    {
        WalkAnimation(-1,0,true);
    }
    else if (Input.GetKey (KeyCode.D))
    {
        WalkAnimation(1,0,true);
    }
    else if (Input.GetKey (KeyCode.W))
    {
        WalkAnimation(0,1,true);
    }
    else if (Input.GetKey (KeyCode.S))
    {
        WalkAnimation(0,-1,true);
    }
    else
    {
        _animator.SetBool("Walking", false);
    }
}

void FixedUpdate (){
    Move();
}

void Move(){
    float dirX = _animator.GetFloat("VelX");
    float dirY = _animator.GetFloat("VelY");
    bool walking = _animator.GetBool("Walking");

    if (walking)
    {
        _rigidbody2D.velocity = new Vector2(dirX,dirY) * speed;
    }
    else
    {
        _rigidbody2D.velocity = Vector2.zero;
    }
}

void WalkAnimation (float x, float y, bool walking){
    _animator.SetFloat("VelX", x);
    _animator.SetFloat("VelY", y);
    _animator.SetBool("Walking", walking);
}

}


texts: Modeling complex requirements for populating loot/drop tables

texts:
I have a set of items and a data structure that describes where and how those items may be dropped.  I'm looking to implement a roguelike/randomizer element to the game and want to include the special items that control progression.*  Ensuring the game remains completable is an absolute requirement but I'm having trouble handling all the different constraints that mixing up the progression item locations brings.
I'm looking for a way to model the requirements that isn't just hard-wiring them into the randomizer logic and hoping I got it right.  Preferably some kind of DSL that is processed and kicks out a partial drop table that at least guarantees completion is possible that I can slot less important items into afterwards.  Does this kind of modeling tool exist?
*: for reference the game is a Metroidvania-style platformer, so progression items are things that unlock traversal abilities like a double-jump, swimming, immunity to lava, etc.  They are not necessarily acquired in order though many are locked behind others in the vanilla game.

Detailed explanation of specific problem:
Let A,B,C,... be special progression items.
Each location in the drop table has a boolean constraint describing what items are necessary to access that location.  For example A | (B & C) would imply two possible paths: get A, or get B and C.
Early-stage locations are easy to model because they generally have no or very short constraints.  Later-stage locations become very complex as the boolean expression must expand to cover every possible progression path and very quickly become something like (A | B | C) | (D & (E ^ F)) | ... with another 4-5 terms following after.  Getting these constraints wrong means it's possible to generate an impossible-to-complete game.
Trying to handle the constraints in code quickly become intractable and very difficult to debug. Thus the search for a better way to model the constraints.
In the end it's a kind of recursive boolean satisfiability problem.  In theory I could build a giant expression for the entire game complete-able state and repeatedly run it through a SAT solver until completion is achieved or it stalls.  Food for thought in case anyone else has this same problem.


texts:
I'm trying to resize my small background sprite to match the screen width of the user's device.

This is what I'm trying

// Use this for initialization
void Start () {
    // Set filterMode
    SpriteRenderer sr = (SpriteRenderer) GetComponent("Renderer");
    sr.sprite.texture.filterMode = FilterMode.Point;

    // Get scaling
    float multiplier = Camera.main.rect.width / sr.sprite.bounds.size.x;

    // Scale
    transform.localScale = localScale * multiplier;
}

It seems there is a problem with the measure I get from the Camera width, I also tried Screen.width but it seems it returns the value in pixels.


texts: Why do my NPC's fall through the world when I select them as triggers?

texts: I'm making a game in Unity where when the player comes into contact with an NPC it will switch scenes. I have the code for it and made sure all NPC's have rigidbody as well as using gravity and convex. They do not fall through the world but as soon as I click the trigger box on the mesh collider they start falling straight through the world. The switching scenes code works fine - I tested it and it does switch the scene.


texts:
I am trying to get an object to slowly look at another object, that is, rotate slowly so its forward points towards the target position. Here is my code:

using UnityEngine;

public class LookAtTheDamnThing: MonoBehaviour
{
    public Transform target;
    public float speed;

    void FixedUpdate()
    {
        AimAtTarget();
    }

    public void AimAtTarget()
    {
        Vector3 direction = target.position - transform.position;
        Quaternion toRotation = Quaternion.FromToRotation(transform.forward, direction);
        transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, speed * Time.time);
        Vector3 fwd = this.transform.TransformDirection(Vector3.forward);
        Debug.DrawRay(this.transform.position, fwd * 50, Color.green);
    }
}

This results in the object looking kind of towards the target but never actually looking at it. I cannot for the life of me see my mistake. Can anyone help me?


texts:
This script for drive a car by arrows. I added a gun above it to aim at target. My issue here is the rotating of my gun effected by my drive when I turn left or right. How to stop the rotation of my gun to be effected by car turns ?

using UnityEngine;
using System.Collections;

public class RearWheelDrive : MonoBehaviour {

private WheelCollider[] wheels;

public float maxAngle = 30;
public float maxTorque = 300;
public GameObject wheelShape;

public Transform target;
public Transform gun_car;

// here we find all the WheelColliders down in the hierarchy
public void Start() {

    wheels = GetComponentsInChildren<WheelCollider>();

    for (int i = 0; i < wheels.Length; ++i)
    {
        var wheel = wheels [i];

        // create wheel shapes only when needed
        if (wheelShape != null)
        {
            var ws = GameObject.Instantiate (wheelShape);
            ws.transform.parent = wheel.transform;
        }
    }
}

public void Update()    {

    // Gun rotation
    Vector3 dir = target.position - gun_car.transform.position;
    Quaternion lookr = Quaternion.LookRotation(dir);
    Vector3 rotationy = Quaternion.Lerp(gun_car.localRotation,lookr, Time.deltaTime * 7).eulerAngles;
    gun_car.localRotation = Quaternion.Euler (0f,rotationy.y,0f);

   //    Drive
    float angle = maxAngle * Input.GetAxis("Horizontal");
    float torque = maxTorque * Input.GetAxis("Vertical");

    foreach (WheelCollider wheel in wheels)
    {
        // a simple car where front wheels steer while rear ones drive
        if (wheel.transform.localPosition.z > 0)
            wheel.steerAngle = angle;

        if (wheel.transform.localPosition.z < 0)
            wheel.motorTorque = torque;

        // update visual wheels if any
        if (wheelShape)
        {
            Quaternion q;
            Vector3 p;
            wheel.GetWorldPose (out p, out q);

            // assume that the only child of the wheelcollider is the wheel shape
            Transform shapeTransform = wheel.transform.GetChild (0);
            shapeTransform.position = p;
            shapeTransform.rotation = q;
        }

    }
}

}


texts: Architecture - how to refer to skills/abilities internally within code?

texts:
I have about 60 skills within my game, which are loaded from a JSON file. Each skill is a subclass of a skill object and has attributes like range, cost, target type, etc. Currently each skill has an integer index to identify the skill. Warrior skills begin at 100, wizard at 200, rogue at 300, etc.

Now I'm at a point where I'm implementing the mechanics of what these skills actually do, I have created an enumerated type with 60 integers corresponding to the indices from within a JSON file. And what I have right now is a switch statement with 60 cases:

enum SkillsEnum
{
    sPowerAttack = 100,
//59 more enums with skill names
}

-(void)doSkillActionWithTarget:(CharacterModel*)target
{
    DLog(@"Skill activated");

    switch (self.skillIndex) {
        case sPowerAttack:
        {
            //apply skill effect here
            break;
        }
     //59 more skills
     }
}

I'm working in Objective-C, an object oriented language and am interested if there's a better or more flexible to refer to skills within the game engine?

In other words, would there be any benefit from creating more specialized separate class hierarchies for skills, or passing them around as Maps/Dictionaries?


texts:
So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.

https://codepen.io/kingofdelphi/pen/vRZvxQ

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

shift the current block
find the blocks on top that touch the current block,
recurse each such block and goto step 1

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?


texts: Deleting a game object causing an access violation

texts:
I tried doing this but it cause an access violation.

void GameObjectFactory::Update()
{
     for( std::list<GameObject*>::iterator it=gameObjectList.begin() .....
          (*it)->Update();
}

void Bomb::Update()
{
     if( time == 2.0f )
     {
         gameObjectFactory->Remove( this );
     }
}

void GameObjectFactory::Remove( ... )
{
     gameObjectList.remove( ... );
}

My thoughts would be to mark the object to be dead then let the factory handle it the on next frame for deletion. Is it the best and fastest way? What do you think?


texts: How can I find the reflection of a point in a perpendicular line?

texts: From the image below I know the positions A and B. How can I find positions C and D and the reflection (Er) of an object E in the line CD? I saw the solution in How can I reflect a point about a line in Unity? but I don't understand it enough to apply it in my case. Please note that I'm trying to achieve this in 2D.


texts: Input and packets handling when using render interpolation

texts:
I'm implementing valve's networking model for my simple top down game but I have some design problems and I just can't think of good solutions. The one of the main ideas that there is a render time separate from simulation time. So for example I have interpolation time of 50ms (as my server update rate is 20Hz).

So, on client my simulation time is 1000ms and render time is 950ms. But I have some design problems... When the user presses a key (in example cast spell), the logical choice is to trigger it in the render time (950ms), but that's impossible since my simulation is in 1000ms already. I think that the solution may be to trigger input using simulation time (and use "lag compensation", so if spell casting time is 100ms, user casts it at the time when render is at 950ms, and it will start in simulation at time 1000ms as 50% casted spell). However I'm not sure, is it a good solution?

The second problem is about sending packets. So If my solution for the first problem is good, then I will send the newest packet from simulation (and don't bother with render time when sending packets). Is it good or should I send packets using render time (ie when simulation time is 1000ms I send to server packet from 950ms)?

The third problem is about receiving packets. When I receive packet when the simulation time is 1000ms, should I save it as packet received in 1000ms or 950ms? In valve networking model (which I use as I said), when server receives info "started casting spell" at server time 250ms, it is compensated by rtt/2 AND by client interpolation time... So I don't know how valve clients handle input, looks like they handle it at render time which I don't understand. Anyway, as I want to use my solution for handling input, I think that I shouldn't compensate for interpolation on server, yes? Or maybe I should compensate on server also by client interpolation time?

I hope that you can help me with my 3 questions. Thanks in advance!


texts: In Unity, how to get reference of descendant?

texts:
I'm trying to get descendant game object, not a child. Let's assume that I have a GameObject and it's hierachy looks like this:

Weapon
- Hands
- metarig
  - upper_arm.L
  - upper_arm.R
    - forearm.L.001
      - hand.L.001
        - weapon.L.001
          - AttackDetection(!)
- Sword

I want to access "AttackDetection" from Weapon(Root) in script. But when I try this:

void Start() {
    attackDetectionGObject = this.transform.Find("AttackDetection").gameObject;
}

It fails with this:

  NullReferenceException: Object reference not set to an instance of an object

Looks like transform.Find just looking up it's own child, not descendant. I try to find way to solve this problem, but there's nothing I found.

Any advice will be very very appreciate it.


texts:
How would I go about creating NPC Events/Scenes? For example, any RPG will have a ton of different in-game cut scenes where you can express a story line.

What I have thought of so far is having different triggers and a number indicating the state of the story the player is at. When the player hits one of these triggers I will check the state and progress from there. Am I sort of on the right page?

After that how do I animate the scenes? Do I just hard code them into the game? I was thinking this is where a scripting language might be handy? I'm not really sure

I realize this is probably a large question, but if someone could point in the right direction that would be great.

I'm using c# and XNA if that matters at all.


texts: Handling Multiple Items Interaction (in a 2-Players Game)

texts:
Back Story

I'm working on a 2-Players 2D game that players play multiple rounds ,until one win.

In each round, each player choose some items (1 or more) for his/her car ( e.g. shield, anti-shield, power-up, speed, ... ) and their chosen items are hidden for opponent. when both player get ready, they just sit and see what happen to their cars which move toward each other (each round).

Problem

As I said, there are multiple items (read "magics") with different effect in my game. Each Item's effect may differ depends on item which it interact with. each item have some positive effect and some cost.

  For instance, If player 1 uses "speed" item, his car may cause more damage to opponent's car ,whereas if opponent had used a "truck-bumper", this "speed" would cause player 1 to get more damage instead!

After writing all the rules and effects of each item on a paper, I need your helps to find a good and structural way to handle them in code (except many nested if-else ).

Finally

I need some kind of structure or coding style for converting these rules to code and determining the net result of items interaction in each round according to items relations.


texts: How do I port a simple 2D Monogame to MacOSX

texts:
I have made a simple Windows Monogame project (using the DirectX template).
What are the steps to port my game over to MacOSX?

If I need to change my Monogame project so that it uses a OpenGL template instead of the DirectX template please explain how.


texts:
Trying to decide the best course of action to implement the in view and out of view of players in a server/client 2D game. Below is some highlights of the system:

Map sliced into squares. Each square contains players and objects.
Check 2 square radius around player for other players/objects. Send full info states of these players/objects when in range.
Save that X player knows about each player/objects full data, only send position states thereafter.
Client Side: If player moves outside a set range, set it invisible. If player comes back in range, set visible.

Now my problem is the following scenario:

Player 1 sees Player 2
Player 2 walks out of set range. Player 1's client hides that player.
Player 2 continues on and is far far away.
Player 1 walks towards where Player 2 went invisible.
Player 1's client sees the last position we got from Player 2 and unhides it.

So how would I verify if the last position Player 1's client got of Player 2 is their real position? The following scenarios I've thought about:

Hide characters indefinitely if they are out of view and only show again if we get movement state. This doesn't work as there are many stationary objects and players may not always be moving.
On client set a flag on characters as "out of view" as they leave view. Don't show again unless the server says something is there. The server would have to keep track of that and resend proper information once a character gets back in view. It seems this is the only possible way to make it work, that the server would have to control this in view and out of view feature. Of course this seems like a ton of overhead for the server to do especially if not everything changes.

What is the proper way to handle this situation? I'd appreciate any feedback. Thanks.


texts: Implementing a movement and collision system with Vectors and Area

texts:
I've scoured gamedev for around 45 minutes, but I'm unable to find a detailed approach to implementing a movement and collision system for games - specifically, when to use which process, and what to do in them.
CONTEXT: I've made around 20 2-D games, most of which are physics simulators. I have a pretty good knowledge of AWT graphics (too deep into it to start javafx). My games are usually structured like this:
function 'move' inside a particular object:
    move the object
    if the object has collided into an immovable object like the ground:
        escape from the immovable object
        change velocity accordingly
    if the object has collided with a movable object:
        the current object should retrace its path to escape collision
        change both velocities accordingly and move each object with their velocity ONCE

call the function 'move' for each object

I'm completely uneducated in game development, and I've gotten a bit too comfortable with this flawed system because it has worked for almost every one of my games.

I've been studying a lot about game dev online, so I'm trying to make a system where every object moves freely once, then all their collisions are logged and resolved, in that order. But I'm still unsure how to resolve the collision.
This question: Collision Resolution is pretty much the same as mine, but I still can't understand when I should change positions and velocities. Should I change both at the same time on collision detection? What happens if you collide into an object, so you retrace your steps, but now you've collided with something else?
If anyone can link a more concrete question / answer, I'll be immensely grateful. I'm using vectors to store the position and velocity of each entity (player or npc), if that's helpful.
TL;DR
What property of an entity should I change on collision detection: velocity or position, or both? If the entity escapes the collision, but runs into a new one, should I resolve its new collision, or should I go on to solving the other collisions?


texts: How do I go about implementing different behaviors on items?

texts:
How do I go about implementing different items with different behaviors?

I plan on having an inventory where those items are stored, but I can't figure out how do I go about implementing different functionality for each item.
Can somebody help me figure out where to look or how to go about this problem?

(This is not a question about inventory implementation, or specific item implementation, but how to implement functionalities of each usable item.)


texts:
At some angle my mirror with planar reflection shows this result. Looks like it mix with the sphere reflection capture.
How to fix it?


texts: How to render a large tile-based 2D world efficiently (using JavaFX/ScalaFX or more generally)

texts:
I have a file tileset.png containing a dozen 32*32 tiles. When my game starts, it generates the world randomly with the available tiles and the size of the world can be changed, so I cannot have a hard-coded world texture.

So I have an \$n \times m\$ matrix, each of its element being a Tile. For the moment a so-called Tile is an ImageView(in JavaFX), which basically is a portion of my tileset (note that I only load the tileset image once and then generate all my tiles using it).

Now the very basic method that I'm using is, I store a boolean for each tile saying whether it is currently displayed on the screen. I also keep track of the total scale, that is the total amount of pixels that have been dragged yet. From this, for each tile that is to be displayed on the screen, I compute its \$(x,y)\$ position given the total offset and I add it to the scenne. Also for each tile that was displayed at the previous "iteration" but is not anymore, I remove it from the scene.

It is however quite laggy, especially when a lot of tiles need to be displayed at the same time or when dragging the map a lot.

I am sure I can drastically improve the performances but I cannot find how. I guess that having a different object for each tile isn't very efficient, yet as said before, I cannot have the entire map as a single image as it is randomly generated. So.. I still need each tile to be an object somehow?

I also saw a few things about using meshes or UV-mapping but I didn't really understand how to make it work here. Also, it was help for Unity. If anyone knows how to implement this in JavaFX/ScalaFX I would be glad to know, but otherwise I think I could adapt a general method in this specific library.


texts:
I tried to display a player image in a 800x600 window using PyGame but when I try it, the window just gets stuck (immovable with mouse drag, minimize,maximize and close button is stuck and not clickable).
I have no Idea for the reason.
Here's the code:
from pygame.locals import *
pygame.init()

fps = pygame.time.Clock()

WINDOW_SIZE = (800, 600)
pygame.display.set_caption("Game")
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 0)

player_image = pygame.image.load("Witch.png")
location = [0,0]

while True:

    screen.blit(player_image, location)

    pygame.display.update()
    fps.tick(60)

pygame.quit()

Please help me where I have made a mistake or what I should do. Thanks in advance.


texts: Saving a list of points into a text file

texts:
I recently posted a question about this, but was not really sure where to go. I've gotten some progress, and have generated some simple noise here:

http://pastie.org/5408655

That works well enough for me, but I would really like to be able to save the points into an ascii text file. currently it's formatted so that something like this:

11111111

11111111

11111111

11111111

would create a square. I need to save in this format with the points(and lines connecting them) generated in the method above.

Essentially, I need to write the array of points created in the first example to a text file formatted like the second example.
EDIT:
I ended up using serialization. This method makes it un-editable, but works for my purposes, I can really have good terrain generation now. here's my code: http://pastie.org/5455624 Everything is working excellently. Thanks to all those who helped


texts:
Hi I am creating my first game in NetBeans using Java, the game is going to be an RPG that will look a bit look Undertale on the surface in that there will be a menu, then a load game section and then will go onto a world where you can walk around.

I've used a JFrame and then a JPanel on top of that to contain the initial menu screen. Should I use another JPanel over the menu screen when I press load game or new game to go to those screens, or should I make a new JFrame altogether?

If you think like how Minecraft has a load game button which sends you to a screen that shows you all the games you can load up, would that be a new JPanel or a new JFrame?


texts: How to move rigidbody player to its facing direction with AddForce?

texts:
How can I move a rigidbody to its facing direction? I've already tried this:

rigidbody.AddForce (transform.forward * v, ForceMode.Acceleration);
// v is a public float which gets a new value in Update function:
v = Input.GetAxis ("Vertical") * Speed;

in FixedUpdate, but it doesn't move forward.

It should go on that blue arrow, but it spins on the red arrow.

Hopefully u understood. Any suggestions?


texts:
I'm curious about the data structures used when programming older games like Super Mario Brothers for NES and Super Mario World for SNES.  My understanding is that games of this period were written in assembly.  Did the programmers define/use any data structures?

For example: when a group of coins appears on the screen how are they stored?  Did the programmers just use arrays?  Or perhaps they had linked-lists?

Cheers!

Edit: I'm interested in various approaches... not necessarily a universal approach.

Edit 2:  In a few of my games I use a (potentially bad) approach towards collections and I want to know if any of the older games used a similar approach.  I like to do the following:

// statically allocated arrays (max number of coins is 4)
int coinsXs[4] = {0, 0, 0, 0};
int coinsYs[4] = {0, 0, 0, 0};

// bitset that keeps track of which coins are active
int coinsActive = 0;

// ...

// update the active coins in an update function
for(int i = 0; i < 4; i++){
    if(coinsActive & (1 << i)){
        // update ith coin
    }
 }


texts: How can I store and load large 3D environments (terrains or cities)?

texts:
I am interested in how a large area 3D environment in games like Grand Theft Auto V or Far Cry can be stored (on disk, in what file format) and how that data can be retrieved when it is used in a game. By "the environment" I mean only static objects like terrain with vegetation, city areas with buildings, et cetera. I'm not referring to temporary or moving objects like people or cars. I am not interested in scene rendering.

I guess it may be convenient to shard (horizontally partition) the data by location creating something like "tiles" because it is usually accessed by location and such tiling will help to keep data that is related together (and reads will be faster). Also I guess the data for sure is stored in some (compressed?) 3D format with the respect to tiling. There probably have to be mechanisms that will split one object to two (or more) parts if it does not fit into a single tile.

I have found a somewhat related question (How a 3D game map is stored and handled) but it only briefly answers small part of my question.