texts: how to make weapon charge up behavior using composition

texts:
I am trying to design different weapon behaviors.

Right now, there are 3 different types of weapon behaviors that i would like to implement.

When not pressing anything, weapon fires at a regular slow interval. When mouse Pressed, weapon fires at a rapid interval
when not pressing anything, weapon does nothing.  when mouse pressed, weapon charges up.  when mouse released, weapon fires
when not pressing anything, weapon charges up automatically.  when mouse Pressed, weapon fires, and then automatically the weapon charges up.

I'm sure there are more to add, but I'm just starting to learn about composition.  Can someone explain to me how I might generally write such behaviors for the weapons in a composition over inheritance manner?  I'd like to be able to simply swap out one weapon behavior for another just to see how the game might change, and I don't want to have to keep copying and pasting code which is what I seemed to be doing.

I'm guessing that I should use an interface (I'm using Java)  called WeaponBehavior perhaps?  So then should every base weapon implement this interface?  And then i put that interface somewhere within my weapon.run() loop that I have made?  (Heroes have weapons, and when heroes run, they run their weapons).  Or is it that there is a behavior object instead?  I think this is what I'm confused about.

I'd just like to know what skeleton code might look like as opposed to what I am currently doing, which is making the behaviors for each specific weapon that inherits from some base weapon.

abstract Class Weapon //implements WeaponBehavior??
{
// should I have an object called WeaponBehavior instead of implementing an interface?
Weapon()
{
}

void run()
{
  update();
  //behavior somewhere here?
  render();

}
void update()
{
  //does behavior go in here?
}
abstract void render();//how does the weapon look
abstract void fire(); // this has to be called at some point
abstract void handleMousePress(); //

}


texts: Unity: Creating a panel that stretches using anchors

texts:
Relative newbie to Unity so please excuse any oversights. I have a component (canvas/panel) that I'm wanting to add a panel to, so that when the parent component's height changes, the child panel's height changes to match. I've achieved this manually using the inspector (see top half of attached pic) to set the anchor points at min(0.5, 0) and max(0.5, 1) (pivot is unchanged at (0.5,0.5)).

I want to create that stretching panel in scripting, and have the following code that results in the bottom half of the attached pic where the rect transform's anchors aren't set at all.

GameObject panel2 = GameObject.Find("Panel2");

GameObject divider = new GameObject("RunTimeLine");
divider.layer = LayerMask.NameToLayer("UI");
divider.transform.SetParent(panel2.transform);

CanvasRenderer c = divider.AddComponent<CanvasRenderer>();

RectTransform rt = (RectTransform)divider.AddComponent<RectTransform>();

Image img = divider.AddComponent<Image>();
img.color = Color.red;

rt.localPosition = new Vector2(0f, 0f);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 20);
rt.anchorMin.Set(0.5f, 0);
rt.anchorMax.Set(0.5f, 1);

Any suggestions? I've also tried setting the min/max offsets and pivot but haven't been able to create what I've got manually in the inspector.


texts:
I know what it is and I'm using it as a frame counter for example. But when should I use it?

Does it make sense to say "I make all the input handling happen in a gamecomponent"? Is it flexible enough to add and remove fast in runtime? I see I can set the update order and draw order, but I guess to keep track of it an enum should be best like "GamePadInput = 0" or "MessageBox = 100".

Or should I just design simple, for example when I want to determinate if a messagebox is open checking "if (MessageBox.Active)" and then manually updating/drawing?

I'm a bit confused and can't decide what to do. I don't want to start designing the game and see later "oops". Maybe you can help me out :)


texts: How do reflections work for large flat surfaces?

texts:
I understand how reflections work for objects. A cubemap would be rendered around a certain point in 3D space, usually at the center of the object that the reflection is to be applied to, and that is the surrounding world it reflections.

But this leads to the question, what about large flat surfaces like floors and walls? If you're only rendering the cubemap from a single point in 3D space, reflections only work for a small area around this. If you walk down the hall and look at the same floor, the reflections would make no sense at all.

How are large, flat surfaces reflected?


texts:
I've made a Heightmap Generator that creates island heightmaps like in this picture:

I am dividing the grayscale ( 0 - 255 ) into 4 diferent parts ( water, sand, gras and forrest )
and after coloring those layers the heightmap looks like this:

As you can see, the "coast" is pretty noisy ( there are some sand-pixels on the edges, that are not connected to the island itself )

So my question is, How to smooth that noisy coast / beach ?

Is there any quick method that detects those "lonly" pixels and turns them into water ?

can i use the smoothing function below to smooth the final output ?

( I'm working with either a float[][] or a Color[][] array )

UPDATE

here is my smoothing function that i've implemented in my heightmap generation core.

i don't know if i can use this function for this purpose.

    public static float[][] GenerateSmoothNoise( float[][] baseNoise, int octave ) {
        int width = baseNoise.Length;
        int height = baseNoise[ 0 ].Length;

        float[][] smoothNoise = GetEmptyArray<float>( width, height );

        int samplePeriod = 1 << octave; // calculates 2 ^ k
        float sampleFrequency = 1.0f / samplePeriod;

        for( int i = 0; i < width; i++ ) {
            //calculate the horizontal sampling indices
            int sample_i0 = ( i / samplePeriod ) * samplePeriod;
            int sample_i1 = ( sample_i0 + samplePeriod ) % width; //wrap around
            float horizontal_blend = ( i - sample_i0 ) * sampleFrequency;

            for( int j = 0; j < height; j++ ) {
                //calculate the vertical sampling indices
                int sample_j0 = ( j / samplePeriod ) * samplePeriod;
                int sample_j1 = ( sample_j0 + samplePeriod ) % height; //wrap around
                float vertical_blend = ( j - sample_j0 ) * sampleFrequency;

                //blend the top two corners
                float top = Interpolate( baseNoise[ sample_i0 ][ sample_j0 ],
                    baseNoise[ sample_i1 ][ sample_j0 ], horizontal_blend );

                //blend the bottom two corners
                float bottom = Interpolate( baseNoise[ sample_i0 ][ sample_j1 ],
                    baseNoise[ sample_i1 ][ sample_j1 ], horizontal_blend );

                //final blend
                smoothNoise[ i ][ j ] = Interpolate( top, bottom, vertical_blend );
            }
        }

        return smoothNoise;
    }

and for those who are interested, i'm calling GenerateSmoothNoise() in this way ->

    public static float[][] GeneratePerlinNoise( float[][] baseNoise, int octaveCount ) {
        int width = baseNoise.Length;
        int height = baseNoise[ 0 ].Length;

        float[][][] smoothNoise = new float[ octaveCount ][][]; //an array of 2D arrays containing

        float persistance = 0.7f;

        //generate smooth noise
        for( int i = 0; i < octaveCount; i++ ) {
            smoothNoise[ i ] = GenerateSmoothNoise( baseNoise, i );
        }

        float[][] perlinNoise = GetEmptyArray<float>( width, height ); //an array of floats initialised to 0

        float amplitude = 1.0f;
        float totalAmplitude = 0.0f;

        //blend noise together
        for( int octave = octaveCount - 1; octave >= 0; octave-- ) {
            amplitude *= persistance;
            totalAmplitude += amplitude;

            for( int i = 0; i < width; i++ ) {
                for( int j = 0; j < height; j++ ) {
                    perlinNoise[ i ][ j ] += smoothNoise[ octave ][ i ][ j ] * amplitude;
                }
            }
        }

        //normalisation
        for( int i = 0; i < width; i++ ) {
            for( int j = 0; j < height; j++ ) {
                perlinNoise[ i ][ j ] /= totalAmplitude;
            }
        }

        return perlinNoise;
    }


texts: Knockback to zone on non-rectangular field

texts:
I have a playing field which is divided in 4 zones (as seen on the image below)

The player (blue) is on the second zone while there are 2 enemies (red) on the third zone. When the player throws an object and hits the enemy, the enemy is knockbacked in the next zone (4) but should stay within that zone.

If the enemy was being hit on the edge of the zone, I want him to still be in the zone 4 and not outside of it (if he got knocked back). I'm not sure if the direction of the hit matters in the calculation

Question: How can I find X?

Note that it can be on any shape of playing field (triangular, hexagonal, circular, ...)


texts: In a 2D platform game, how to ensure the player moves smoothly over sloping ground?

texts:
I'm developing a physics engine for a 2D platform game. I'm using the separating axis theorem for collision detection. The ground surface is constructed from oriented bounding boxes, with the player as an axis aligned bounding box. (Specifically, I'm using the algorithm from the book "Realtime Collision Detection" which performs swept collision detection for OBBs using SAT). I'm using a fairly small (close to zero) restitution coefficient in the collision response, to ensure that the dynamic objects don't penetrate the environment.

The engine mostly works fine, it's just that I'm concerned about some edge cases that could possibly occur. For example, in the diagram, A, B and C are the ground surface. The player is heading left along B towards A.
It seems to me that due to inaccuracy, the player box could be slightly below the box B as it continues up and left. When it reaches A, therefore, the bottom left corner of the player might then collide with the right side of A, which would be undesirable (as the intention is for the player to move smoothly over the top of A).
It seems like a similar problem could happen when the player is on top of box C, moving left towards B - the most extreme point of B could collide with the left side of the player, instead of the player's bottom left corner sliding up and left above B.

Box2D seems to handle this problem by storing connectivity information for its edge shapes, but I'm not really sure how it uses this information to solve the problem, and after looking at the code I don't really grasp what it's doing.

Any suggestions would be greatly appreciated.


texts: How to integrate PS3 & Xbox 360 games to Facebook?

texts:
After some research online, I am unable to find any concrete references for how to go about implementing Facebook functionality from either Xbox 360 or PS3 games.  There is apparently some degree of integration, but how does one go about hooking into Facebook's API from within a console title?

Is there any How To documentation online?  Or alternatively, is anyone aware of a developer that specializes in incorporating this type of functionality in an existing codebase?

For an answer unaffected by NDA, does anyone know of a company that specializes in integrating PS3 or Xbox games with Facebook?


texts: How do I get an xbox 360 controller to rumble?

texts:
I am interfacing with the controller using the windows HID API. It seems that its output report length, as provided by the HID driver, is 0, which means I can't send it anything (e.g. make the rumble work). I've also noticed that the input report doesn't include the state of the big "X" button. Am I wrong about this? Is there a workaround, a better API, a workable filter driver that doesn't involve making .infs, etc...?

As I need to support an arbitrary number of controllers (keyboards, mice, and anything for that matter), xinput isn't an option. Installing drivers is also not an option, unless it can be done silently without breaking the device for every other application.


texts: How can I load multiple scenes in background?

texts:
I want to queue the loading of multiple scenes in background and show all of them at the same time when all complete their loading.
The only idea I have by reading the docs is to root all objects in every scene I want to load this way in a single GameObject that is disabled by default and when all my LoadSceneAsync finishes its work, I can them activate each scene root GameObject.
Without doing that, I have all related scenes being loaded and being showed in the screen at different times and this is just not acceptable.
I'm creating this question because I believe there must be a better way to accomplish that rather than rooting all the scene into a single game object.


texts:
Is it possible to get a constant speed movement over a Bézier curve when its points are not kept symmetrical ?

Here white square (almost) moves at constant speed.
(red and green squares are control points)

Here travel time is much longer in the green part than in the red part. (control points moved)

Curve generation and white square movement is defined as follows :

    public void Update(...)
    {
        // White square movement
        _timeline += 0.01f;
        if (_timeline >= 1.0f)
        {
            _timeline = 0.01f;
        }
        _timelineVector2 = GetBezierPoint(_timeline, _p0, _p1, _p2, _p3);
    }

    // Also used for generating curve
    public static Vector2 GetBezierPoint(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
    {
        float cx = 3 * (p1.X - p0.X);
        float cy = 3 * (p1.Y - p0.Y);

        float bx = 3 * (p2.X - p1.X) - cx;
        float by = 3 * (p2.Y - p1.Y) - cy;

        float ax = p3.X - p0.X - cx - bx;
        float ay = p3.Y - p0.Y - cy - @by;

        float Cube = t * t * t;
        float Square = t * t;

        float resX = (ax * Cube) + (bx * Square) + (cx * t) + p0.X;
        float resY = (ay * Cube) + (@by * Square) + (cy * t) + p0.Y;

        return new Vector2(resX, resY);
    }


texts: How do I efficiently perform collision detection on an NxN rectangle grid?

texts:
I have a simple level that is constructed from an NxN rectangle grid. Some of the rectangles are walls, and some of them are the path. The player is allowed to move only on the path they are on and also the path rectangles on the grid. So I have two kinds of rectangles in the grid:

"path"
"wall"

The player is a sprite above the grid. I want to efficiently find if the player is colliding with the wall. I want to loop through the rectangles, to see if they intersect. What is the best method?


texts:
I'm pretty confident programming in Objective-C and C++, but I find Objective-C to be somewhat easier to use and more flexible and dynamic in nature.

What would be the pros and cons when using C++ instead of Obj-C for writing games in iOS? Or rather, are there any known problems with using Obj-C as compared to C++?

For instance, I suspect there might be performance issues with Obj-C compared to code written in C/C++.


texts: Get FVector from Blueprint tick function

texts: In my BluePrint Tick function for my character, I have a FVector that always changes, and in my C++ component, I want to get this changing FVector and use it in my C++ Tick function, is that possible to do?


texts: How to prevent constant adjustments form collision?

texts:
I'm try to clone a popular 2D platformer as a project. For both the player character and enemies, whenever I constantly check to see if they are walking on the ground or floating platforms, they "vibrate" or "Bounce" instead of walking smoothly, as gravity pushes them downward, and the platform pushes them upward. I have tried searching for this problem, but can't seem to find anything relevant to my problems (which probably means I am searching the wrong thing because I'm sure everyone runs into this problem at some point.)

Essentially, the player and enemies are always effected by gravity, but the collision acts against it and pushes them upward. I tried having a boolean that was set once they appeared to be on solid ground, but this made them float artificially once they walked off of floating platforms.

Here is the code for enemy collisons:

public void EnemyBlockResponder(IEnemy enemy, IBlock block, Rectangle intersection)
{
    enemy.YLocation -= intersection.Height;
}

I'm currently assuming that a side collision with a block will never happen for debugging.

Here is the Update method for the enemy:

public void Update()
{
    if (currentDirection == Direction.LEFT)
    {
        xLocation--;
    }
    else if (currentDirection == Direction.RIGHT)
    {
        xLocation++;
    }
    if (NoFloor())
    {
        yLocation += 3;
    }

    goombaSprite.Update();
}

Where NoFloor is a method that checks all the blocks on camera to see if the enemy is colliding with any of them.

Where is this code causing the sprite to continually bounce? I appreciate any help and criticisms. Thanks.


texts: Portable buffered keyboard input for XNA / MonoGame?

texts:
As a preliminary solution, I am currently using the Nuclex framework (see note below) in an C#/XNA game project for buffered keyboard input. Sadly, Nuclex relies on SlimDX.Directinput.dll and therefore to my knowledge can only be used under Windows OSs. However, I use MonoGame to target other platforms (Linux, OSX, etc.) and therfore I am looking for a portable way to integrate buffered keyboard input aross all platforms. Is there any?
Note:
This question originally linked to Nuclex on CodePlex, which has been in archive mode since 2017 and will be going offline soon.
The link now provided (mirror) goes to a copy of last version of Nuclex posted to CodePlex. Cygon appears to be maintaining development here.
A different branch is available here.


texts:
I am trying to calculate the reflection of a laser within a polygon. My current calculations are probably quite long-winded because I'm building on line intersection and other functions. The problem is that I'm using a point (x,y) with velocity(x,y) and trying to calculate where the point is after each reflection off a line - this is a problem because when the point reflects within very small corners I can't seem to calculate the final location and velocity of the laser point.

Is there a well known algorithm for calculating laser reflection in 2D within polygons?

Note: I would post my code but as stated above it's extremely long ATM.

My general logic is:

Call method with particle {x,y,velocity={x,y}}
Begin loop
  Check for intersections
  If no intersections then exit
  Get closest intersection to particle
  Update particle location, direction and velocity
End loop
Refresh particle velocity (to maintain speed)
Return particle

I was hoping there something a bit more concise for this (basic?) math problem.


texts: I have 90 obj for an animation and currently using LWJGL. How would I be able to load them in sequence for 3000 seconds (a frame every 33 milliseconds)?


texts: Workaround for reading and writing same texture?

texts:
To apply post effects, it is often needed to read the preliminary image, perform computations on its pixels and store the result in the same texture again. For example, think of a tone mapping or desaturation effect. The input and output should be the same texture, but this isn't allowed by OpenGL.

Therefore, what is a good workaround?

One idea I came up with but which isn't very satisfying is to have two image textures and automatically use them alternating. Also keeping track of which is the newer one to finally display it on the screen.


texts:
I am currently working on a game in XNA and MonoGame. This game is supposed to be a port of KidsCanCode's tutorial series of creating tile-based games in Python. Here is a link to one of the videos in the series I'm talking about: https://www.youtube.com/watch?v=3zV2ewk-IGU&index=4&list=PLsk-HSGFjnaGQq7ybM8Lgkh5EMxUWPm2i

My issue is that my player and camera don't move like how KidsCanCode's player and camera move (you can see KidsCanCode's player and camera movement by clicking on the link above). My camera and player are out of sync. The player can easily go outside of the camera.

Here is the camera code:

public class Camera
{
    public float Rotation { get; private set; } = 0;
    //private Matrix OldTransform;
    //public Vector2 Position { get; private set; }
    public float Zoom { get; private set; } = 1f;

    public int ScreenWidth { get; set; }
    public int ScreenHeight { get; set; }

    public int MapWidth { get; set; }
    public int MapHeight { get; set; }

    private Vector2 Position;

    const float Velocity = 280f;

    public void GetTransformation(out Matrix transform)
    {
        float x = -Position.X;
        float y = -Position.Y;

        transform =
      Matrix.CreateTranslation(new Vector3(x, y, 0));

    }

    public Camera(int screenWidth, int screenHeight, int mapWidth, int mapHeight)
    {
        ScreenWidth = screenWidth;
        ScreenHeight = screenHeight;

        MapWidth = mapWidth;
        MapHeight = mapHeight;
    }

    public void ApplyPositionFromSprite(Sprite sprite)
    {
        //Camera is supposed to center on sprite

        //Camera is always supposed to be ahead of player unless player is close to the edge

        float x = sprite.Position.X;
        float y = sprite.Position.Y;

        x = Math.Max(x, 0);
        y = Math.Max(y, 0);

        x = Math.Min(x, MapWidth - ScreenWidth);
        y = Math.Min(y, MapHeight - ScreenHeight);

        this.Position = new Vector2(x, y);
   }

Can someone tell me what's wrong with my code? Here is a link to the GitHub page.


texts: Should I avoid constructors/destructors in C++ when using custom allocators?

texts:
I'm currently building my first 2D game engine and have reached a point where some large-scale tests have shown that some form of custom memory management would be beneficial (object pools).

So I created an object pool but got stuck on the problem of calling the constructor and destructor of the objects allocated from that pool.

So I read this:
http://www.scs.stanford.edu/~dm/home/papers/c++-new.html

This seems to be a common problem when using custom allocators and there seems to be no nice solution to it within C++. I've also read on some other place that one should avoid "new" like the plague when creating a game engine. So, if that's the case, should I avoid constructors and destructors altogether? Should I fall back to a Init/Shutdown mechanism for my objects?

Appreciate any advice.

EDIT:
Besides the correct answer below, one solution to the problem (also mentioned by mikosz) that also allows the use of non-default constructors can be found here: http://anki3d.org/cpp-allocators-for-games/


texts: Feasibility of a project in certain languages

texts:
My current project is a very simple browser-based game. The player moves with the keys and draws a bow with the mouse to shoot arrows at approaching enemies. This seemed to me like the perfect game for a Python/PyGame implementation and it proved to be true - except if I want it browser-based (Desktop version already works perfectly).

Is there any way I can get Python/PyGame running from a server in a browser window? I tried Kivy but it seems to have problems handling PyGame.

Is there a way to use HTML, PHP or the like to get the Python/PyGame script running in a browser window by "translating" inputs to the Python script and vice versa translating returns into view changes?

Is there an alternative (JavaScript + additional libraries?) that offers me: PNG with Alpha handling readily implemented (I don't really want to use another few days to write that on my own...), easy catching of mouse/key inputs and an "easy-going" license policy that allows me to publish it donation-based without having to pay for a license?

Note: If I really have to change to another language anyway, then I'd prefer one where I can implement catching touch-screen inputs from mobile devices.

I'd really appreciate any advice on these questions as I'm really stuck with it until I know to which language I have to translate the Python/PyGame version.


texts: Should an actor know its position (or map should know it)

texts:
In a tile-based game (in this case MMO), should an actor (e.g., player) know its position, or should only the map know its position?

If an actor is placed on a grid map, it is placed on a specific position (x, y) and assigned to a cell in the map. Now, should I also store the actor's position inside the actor's data structure? It would allow to check the actor's position easily (just check it's data) but at the same time, I duplicate the same information in two places which is bad and could introduce a whole spectrum of bugs (e.g., if those two pieces of data are inconsistent)


texts: How do I integrate Nvidia Ansel into my Unity game?

texts: I want to be able to use the super high resolution image capabilities that ansel have to offer but I don't know how to add it as the only thing that i can find are C++ libraries on their website.


texts:
I am building a simple 2D game with SFML and have a GameState object that contains a Plane and a vector of Enemies. THe plane is represented by a triangle and the enemies by a rectangle. The plane object has bullets and I am wondering what is the most appropriate way of handling collision between the bullets and the enemies. The structure of the code is the following :

 GameState
    /\
   /  \
Plane Enemies
  /
Bullets

Every object has Render and Update and possibly HandleInput methods. The way I think that this could work is if I pass the enemies vector to the plane's update method which in turn calls the bullets update method and there I do the check. Is this ok ? Is there an easier and more solid method of doing it ?


texts:
So I'm trying to write a simple application with SDL 1.2 and OpenGL. This a stripped down version of the code containing the one problem I'm having.

//The headers
#include "SDL.h"
#include "SDL_opengl.h"

//Screen attributes
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;

//Event handler
SDL_Event event;

bool initGL()
{
    //Initialize Projection Matrix
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    //Initialize Modelview Matrix
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    //Initialize clear color
    glClearColor( 0.f, 0.f, 0.f, 1.f );

    //Check for error
    GLenum error = glGetError();
    if( error != GL_NO_ERROR )
    {
        printf( "Error initializing OpenGL! %s\n", gluErrorString( error ) );
        return false;
    }

    return true;
}

bool init()
{
    //Initialize SDL
    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
    {
        return false;
    }

    //Create Window
    if( SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL ) == NULL )
    {
        return false;
    }

    //Enable unicode
    SDL_EnableUNICODE( SDL_TRUE );

    //Initialize OpenGL
    if( initGL() == false )
    {
        return false;
    }

    //Set caption
    SDL_WM_SetCaption( "OpenGL Test", NULL );

    return true;
}

void render()
{
    //Clear color buffer
    glClear( GL_COLOR_BUFFER_BIT );

    glBegin( GL_QUADS );
        glVertex2f( -0.5f, -0.5f );
        glVertex2f(  0.5f, -0.5f );
        glVertex2f(  0.5f,  0.5f );
        glVertex2f( -0.5f,  0.5f );
    glEnd();

    //Update screen
    SDL_GL_SwapBuffers();
}

void clean_up()
{
    //Quit SDL
    SDL_Quit();
}

int main( int argc, char *argv[] )
{
    //Quit flag
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Wait for user exit
    while( quit == false )
    {
        //While there are events to handle
        while( SDL_PollEvent( &event ) )
        {
            if( event.type == SDL_QUIT )
            {
                quit = true;
            }
            else if( event.type == SDL_KEYDOWN )
            {
                //Handle keypress with current mouse position
                int x = 0, y = 0;
                SDL_GetMouseState( &x, &y );
            }
        }

        //Render frame
        render();
    }

    //Clean up
    clean_up();

    return 0;
}

Anyway the code has a problem with gluErrorString() and reports:

1>main.obj : error LNK2019: unresolved external symbol _gluErrorString@4 referenced in function "bool __cdecl initGL(void)" (?initGL@@YA_NXZ)

1>C:\...\Debug\sdl1.exe : fatal error LNK1120: 1 unresolved externals

I'm using Visual Studio C++ 2010 Express. I'm using SDL 1.2.15 and freeglut. I've added to the VC++ Directories both the SDL and freeglut library and include directories respectively and in the Linker general dependencies have added SDL.lib, SDLmain.lib, OpenGL32.lib, and freeglut.lib. And SDL.dll and freeglut.dll are included with the executable.

What's really baffling me is I can run SDL code with this same set up as well as OpenGL (if I include gl/glu.h and gl/gl.h manually), but trying to run them together has brought me to a screeching halt. If I comment out the line printf( "Error initializing OpenGL! %s\n", gluErrorString( error ) ); it works fine, but I have no idea why it can't seem to work with a simple thing like gluErrorString(), especially because gluErrorString() works fine in my OpenGL only code.

From what I understand #include "SDL_opengl.h" is supposed to include the opengl headers for me, and it seems to work for all but this one line, which I don't understand. If there's any further pertinent information needed I will provide it. Any help is greatly appreciated.


texts: How do I open the camera in a CCScene node in a Cocos2D application?

texts:
I am new to Cocos2D and I can't find the way to open the camera from the library. I want to open the camera in the my game, can any one help me with with this?

Thank you in advance.


texts: Need Guidance Making HTML5 Canvas Game Engine

texts:
So I have some free time this winter break and want to build a simple 2d HTML5 canvas game engine. Mostly a physics engine that will dictate the way objects move and interact(collisions, etc). I made a basic game here:

http://caidenhome.com/HTML%205/pong.html

and would like to make more, and thought that this would be a good reason to make a simple framework for this stuff. Here are some questions:

Does the scripting language have to be Javascript? What about Ruby? I will probably write it with jQuery because of the selecting powers, but I'm curious either way.
Are there any great guides you guys know of? I want a fast guide that will help me bust out this engine sometime in the next 2 weeks, hopefully sooner.
What are some good conventions I should be aware of?
What's the best way to get sound? At the moment I'm using something like this:

var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'paddle_col.wav');
audioElement.load();

I'm interested in making this engine lightweight and extremely efficient, I will do whatever it takes to get great speeds and processing power. I know this question is fairly vague, but I just need a push in the right direction.

Thanks :)


texts: Web workers for HTML5 game physics simulation?

texts:
A bit related to this question.

The idea is to guarantee the same physics behavior as much as possible. Would it be possible to run fixed time step physics on a web worker? The UI would update itself with different/variable refresh rate.

Has anyone tried such yet?


texts: Moving from A(x,y) to B(x1,y1) with constant speed?

texts:
I currently have something like:

float deltaX = point0.getX() - point1.getX();
float deltaY = point0.getY() - point1.getY();

And every 0.01 seconds I refresh my objects position like this:

object.setPosition(object.getX()-deltaX/100,object.getY()-deltaY/100);

So this moves my object from point0 to point1 in 1 second. What I need is having the 2 points, to be able to move the object from point0 ,facing(in the direction of) point1 with a constant speed. Thus, when I have a point closer to my initial point the object will move towards it with the same speed it does if I would have a farther point.
Any suggestions are appreciated. Thanks.


texts: C++ and SDL Trouble Creating a STL Vector of a Game Object

texts:
I am trying to create a Space Invaders clone using C++ and SDL. The problem I am having is in trying to create Waves of Enemies. I am trying to model this by making my Waves a vector of 8 Enemy objects.

My Enemy constructor takes two arguments, an x and y offset. My Wave constructor also takes two arguments, an x and y offset. What I am trying to do is have my Wave constructor initialize a vector of Enemies, and have each enemy given a different x offset so that they are spaced out appropriately.

Enemy::Enemy(int x, int y)
{
    box.x = x;
    box.y = y;
    box.w = ENEMY_WIDTH;
    box.h = ENEMY_HEIGHT;

    xVel = ENEMY_WIDTH / 2;
}

Wave::Wave(int x, int y)
{
    box.x = x;
    box.y = y;
    box.w = WAVE_WIDTH;
    box.y = WAVE_HEIGHT;

    xVel = (-1)*ENEMY_WIDTH;
    yVel = 0;

    std::vector<Enemy> enemyWave;
    for (int i = 0; i < enemyWave.size(); i++)
    {
        Enemy temp(box.x + ((ENEMY_WIDTH + 16) * i), box.y);
        enemyWave.push_back(temp);
    }
}

I guess what I am asking is if there is a cleaner, more elegant way to do this sort of initialization with vectors, or if this is right at all. Any help is greatly appreciated.


texts:
How to match obstacles with music in Unity?

I want to make a game like Beat Saber where game events are synchronized with the beats of a song.


texts: How to use 3 cameras simultaneously in Unity

texts: I'm working on a project that requires 3 panels, each rendering a game object.  There will be a search box and when the player enters a string, that key word will zoom to the tagged location on the each object in the 3 panels. How can I go about accomplishing this?


texts: How to design a character damage system with ECS architecture?

texts:
I am developing an game with ECS architecture and trying to design a character damage system.
Does the following design fits into ECS conception and will it be extendable in future?

I have an Actor component with health percent attribute and ActorsDamage system.

I also have an inventory system, so actors can use some food to increase their health.

When actors use inventory items, their Lua handlers executes and generates ActorHit event.

ActorDamage system receives this event and increases or decreases the actor's health.

Other game systems link actors' AI system or actors' keyboard control systems can also trigger hit events.

So, is this an appropriate design conception, or is there something I need to correct or improve?


texts:
I'm trying to write a Java class to generate Perlin Noise from a Cartesian coordinate. I'm trying to follow this tutorial but I am struggling to understand the theory.

Specifically, how do you divide coordinates into a unit square or unit cube?

My original though was to a find which was higher the X or Y, then divide one by the other, So either X = 1, y < 1, or Y = 1, X < 1. But doing this doesn't really make sense as the point would always lie on one of the cube/square vertices.

Can someone explain the math to me please.


texts: Rotate a Crosshair around a sprite - 2d worms style game?? (LibGDX)

texts:
I'm currently learning to code 2d games in Libgdx. Right now I'm making a kind of worms clone. I am using Box2d and have just my main sprite and a flat ground object so far.

What im stuck on is making the crosshair for the main character which I would like to rotate around him at a distance of say 90px when the player presses UP or DOWN key.

Here is the code I have so far but I havent even been able to attempt the rotation code at all:

package com.supermegabrobro.apoca.Sprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.supermegabrobro.apoca.Screens.PlayScreen;

    public class ArmyDude extends Sprite {
PlayScreen playScreen;
BodyDef bodyDef;
Body body;
FixtureDef fixtureDef;

boolean crossHairShowing = false;

Texture crossHairTexture;
float crossHairDistance = 30f;
float crossHairAngle = 45f;
Vector2 crossHairPosition;

public ArmyDude(PlayScreen playScreen){
    super(new Texture("armydude.png"));
    this.playScreen = playScreen;
    bodyDef = new BodyDef();
    bodyDef.type = BodyDef.BodyType.DynamicBody;
    bodyDef.position.set(0,0);   // TODO: Make this random

    body = playScreen.world.createBody(bodyDef);
    CircleShape circleShape = new CircleShape();
    circleShape.setRadius(getWidth() / 2);
    fixtureDef = new FixtureDef();
    fixtureDef.shape = circleShape;
    body.createFixture(fixtureDef);

    crossHairTexture = new Texture("crosshair.png");
    crossHairPosition = new Vector2(0,0);

}

public void update(float dt){
    setPosition(body.getPosition().x - getWidth() / 2, body.getPosition().y - getHeight() / 2);

    if(Gdx.input.isKeyPressed(Input.Keys.UP)){
        crossHairShowing = true;
    }
}

@Override
public void draw(Batch batch) {
    super.draw(batch);
    if (crossHairShowing){

    }
}
}

Any help is massively appreciated thanks.
(nb. I have read up on, and implemented in previous projects, normal rotation of sprites. But I beleive this is very different since I am trying to not rotate the actual sprite but instead draw a texture (of a crosshair) that rotates around this sprite.

I'm really stuck though my poor brain can't figure it out alone :(


texts: How to make a game object scale up from another game object

texts:
I have a GameObject. I'm trying to make another GameObject grow in scale from touching this GameObject, and when a set amount of scale is reached, destroy this GameObject. My problem is that when I access ScaleUp, it dosn't add any scale to the other GameObject.

How do I scale another GameObject? Here is my ScaleUp script:

using UnityEngine;
using System.Collections;

public class ScaleUp : MonoBehaviour
{

    public GameObject Player;
    public PlayerMovement PlayerScript;

    private float playerScaleX;
    private float playerScaleY;

    public float scaleUp = 10.0f;

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

        PlayerScript = Player.GetComponent <PlayerMovement>();

        playerScaleX = Player.transform.localScale.x;
        playerScaleY = Player.transform.localScale.y;
    }

    void OnTriggerEnter2D (Collider2D other)
    {
        if (other.tag == "Player")
        {
            playerScaleX += scaleUp;
            playerScaleY += scaleUp;

            Debug.Log ("GROW");
        }
    }
}


texts: Find the optimal position minimising the total path cost to multiple goals (A-star without a starting position?)

texts:
I have a 2D grid of discrete tiles, where some tiles (W) are impassable. Given a number of goals (G), what is the best way to find the position that minimises the total cost to all the goals?

Example:

.......G..
.WWW......
..GW......
...W....W.
.WWW....W.
........WG

I'm familiar with Djikstra and A-star, but I'm not sure how to apply it to this problem, or whether I should be using something else entirely.

The dumb brute force option here is to create a complete cost matrix for every goal, sum these to create a total cost matrix and then find the node or nodes with the lowest total cost. This would work fine, but I'm sure this could be done more efficiently using some sort of directed search.


texts:
I'm currently developing a puzzle game for Android that is sort of along the lines of Alchemy.

I was wondering what makes games like Alchemy or Bejeweled so addicting?  How do I keep players interested in the game to want to play it over and over?  Is it the scores?  Level advancement?  The challenges?  What should I be doing to try and keep a player engaged with a puzzle game since they are often quite repetitive?


texts:
I'm working on an inventory, and I've ran into some problems. Some code in my CollisionDetection class doesn't work properly.

My CollisionDetection class contains functions that involve mouse and item collision. You can pick up and place down items in your inventory, you can stack and split stackable items and you can replace items.

These is an example of the working function:

If you look closely you can see that the item that I'm holding with the mouse is drawn above the other item.

This is the example of the broken function:

I need to click twice before the item finally switches.

If you look closely you can see that the item that I'm holding with the mouse is drawn below the other item and the function doesn't work properly.

I think it has to do with the layer that the item is drawn on...

The stack/replace code (the whole function uses i which is the item. The function is started by a for loop that loops through the item and inventory tiles lists):

Item i2;
// Searches item 2
i2 = items.Find(x => x.itemBox.X == r.X + 9 && x.itemBox.Y == r.Y + 9 && !x.clicked && x != i);

// If the item intersects another item (item 2)
if (i.itemBox.Intersects(i2.itemBox))
{
  // If the item is stackable
  if (i.stackable && i2.stackable)
  {
    // Hiding one item visually
    if (!i.hide_Box_Def)
    {
      i2.quantity += i.quantity;
      i.hide_Box_Def = true;
      i.error = true;

      // Bool for changing the item state (picking up/ placing down)
      // But these 2 lines of code are not really used, I wrote these trying to fix this problem.
      i.m_Switch2 = true;
      i.watch.Start();
    }
  }
  // When the item is not stackable -> item needs to be replaced by another item
  else
  {
    // Item 1 (attached to the mouse)
    // clicked: a bool that attaches the item to the mouse
    i.clicked = false;

    // itembox: collisionbox for the item
    i.itemBox.X = i2.itemBox.X;
    i.itemBox.Y = i2.itemBox.Y;

    // Oldposition for the item
    i.oldPosition.X = i.itemBox.X;
    i.oldPosition.Y = i.itemBox.Y;

    // info bool: do/ do not show item info
    i.info = false;

    // Item 2 (in inventory)
    // mouse_Click_Left: bool that changes the item state (picking up/ placing down)
    i2.mouse_Click_Left = true;
    i2.info = true;
    i2.clicked = true;
    i2.itemBox.X = (int)coords.X - 15;
    i2.itemBox.Y = (int)coords.Y - 15;
  }

Summary:

The code works when the item that's attached to the mouse is above the other item.

The code doesn't work when the item that's attached to the mouse is below the other item.

UPDATE

I fixed the first problem, so I changed the question a bit.


texts: How can I convey a sensation of speed in space?

texts:
I'm making a game where you see a spaceship (in 3rd person) travelling at high-speed between planets (it takes 2-3 seconds move between them).

What effect could I use to convey the effect of extreme speed? I already know about the usual effects, change in FOV, white lines around the subjects, etc..

I'm asking about some things that are more space-like, I mean even if it's not how it would be perceived in real physics, I need it to look like it's fast and it's in space.

Don't hesitate to ask for clarification, my English is nowhere near being perfect, maybe I didn't convey my thought perfectly.


texts: How can I eliminate these white outlines on my sprites in libgdx?

texts: I'm recently started working on a game in libgdx, and I've run into the problem that my sprites tend to get a thin, whitish outline around them. This is especially a problem for me since I'm working with ragdolls, so I'm drawing arms as separate sprites from the main torso and ending up with ugly outlines around them. After some googling, I found out this was from the linear filtering I'm doing on my textures. Problem is, linear filtering overall looks much nicer than nearest filtering. After more googling, I found out I should be able to fix this problem with alpha premultiplication. Unfortunately, I have no idea how to go about this in libgdx. Alternatively, if someone knows another way to get rid of the outline, that would be great too. Here is a screenshot showing what I'm talking about (Images are standins and don't actually belong to me). If you look at the arm, there are clear outlines at the shoulder and elbow.


texts: How do I balance skill/luck in a forum game?

texts:
I am trying make a forum game where members of the forum can play daily, with role-playing elements, and tactical decisions. I've hosted werewolf games before, but I want this to be a little more involved. Mt new venture is a U-Boat game, where 10 members of the forum can sign up.  The game takes places in several phases, such as Patrol, Intercept, Attack, Evasion, Re-engage/Escape. In each phase the forum spits out some situations based on random numbers generated by the forum. The players make decisions and the results of their decisions advance the game to the next phase (or not).

For example: in the Patrol phase, the players basically roleplay, chat, and BS...entertain themselves. Each day the random number generator cranks out a number for contact. Let's say the RNG spits out a 90, which means enemy convoy spotted. (89 and less, no contact; 90 and up = contact).

The game moves to the Intercept phase, and the RNG spits out a number that tells the player the course of the convoy. In simple terms, the convoy can be moving away from the U-boat, parallel, towards, etc.

Here's where I need help: the players should make some kind of decision, such as "flank speed toward the convoy", "flank speed 45 degrees port" to intercept a convoy on a parallel course, etc. Now, how do I grade the decision?

How do I construct it so that the smarter/safer his choice, the better the results? Obviously, I cannot use the RNG for the outcome, there has to be some way to balance his skill in making a good decision.

Anyone have any ideas? I apologize if this is not the right place to ask this type of question.
thanks!
Neal


texts: Could I be going crazy with Event Handlers? Am I going the "wrong way" with my design?

texts:
I guess I've decided that I really like event handlers. I may be suffering a bit from analysis paralysis, but I'm concerned about making my design unwieldy or running into some other unforeseen consequence to my design decisions.

My game engine currently does basic sprite-based rendering with a panning overhead camera. My design looks a bit like this:

SceneHandler

Contains a list of classes that implement the SceneListener interface (currently only Sprites). Calls render() once per tick, and sends onCameraUpdate(); messages to SceneListeners.

InputHandler

Polls the input once per tick, and sends a simple "onKeyPressed" message to InputListeners. I have a Camera InputListener which holds a SceneHandler instance and triggers updateCamera(); events based on what the input is.

AgentHandler

Calls default actions on any Agents (AI) once per tick, and will check a stack for any new events that are registered, dispatching them to specific Agents as needed.

So I have basic sprite objects that can move around a scene and use rudimentary steering behaviors to travel. I've gotten onto collision detection, and this is where I'm not sure the direction my design is going is good. Is it a good practice to have many, small event handlers? I imagine going the way I am that I'd have to implement some kind of CollisionHandler.

Would I be better off with a more consolidated EntityHandler which handles AI, collision updates, and other entity interactions in one class? Or will I be fine just implementing many different event handling subsystems which pass messages to each other based on what kind of event it is? Should I write an EntityHandler which is simply responsible for coordinating all these sub event handlers?

I realize in some cases, such as my InputHandler and SceneHandler, those are very specific types of events. A large portion of my game code won't care about input, and a large portion won't care about updates that happen purely in the rendering of the scene. Thus I feel my isolation of those systems is justified. However, I'm asking this question specifically approaching game logic type events.


texts: What would be a good sport game for a beginner/intermediate game dev to make for practice?

texts:
I'm interested in making a sport game for practice, but giving it some fun twists sort of like nintendo does, (super strikers charged, mario golf.)  I'm planning on using unity, but since I am by no means an expert I'm trying to figure out a sport that will be reasonably easy to create.  I'm aware that its not going to be easy, but, for instance I'm not going to make a game like madden, which would have a ton of difficult stuff like play calls which involve predetermined paths and intelligence on both sides, in general way to difficult.  What would be a good sport to try a stylized version of?
I'm aware that this is a subjective question, but it isn't a question where any answer is as good as another, so I think it's allowed according to the guideline, but correct me if I'm wrong I guess.


texts: I am using Monogame 3.5 and i have simple model of cube. I use BasicEffect to draw it. I want it transparent so i use effect.Alpha = 0.5f. Is it possible to show all edges something like on picture?


texts: How to manage game-object script component and values in new updated model in unity

texts:
I have several objects/Models/FBX that contain different childrens and it attached several mono-behavior scripts with different values assigned publicly in the inspector (settings). SO of the assignments are manually drag-and-drop in the inspector.

Now the problem is each time we update the model in the project (FBX in the project) we have to drag and drop the model/FBX again in the hirarchy. It means that we have to attach all the scripts again with the values/Data (that we assigned in the inspector) again.

I am currently looking for the right way to do this job. Currently, I place both new and old Models in the scene and then one by one I copy-paste the old object's script component into the new objects by viewing every child of an object. Then, I delete the old one model from the hirarchy. It is a very time consuming process. I want to automate it. Just like Unity I should save all the information (Components and assignment) of a game-object in a separate file (meta file custom) and bring them again on button click. But its challenging as i dont know how to save assignments (refrence objects).

Note: I have to bring the fbx again in hierarchy because sometimes the object not properly update in the scene. Like mesh gets rotate or scaled in weird manner. Or sometime FBX childs are removed or add.


texts: How to Divide Responsibilities Between a Two-Man Group?

texts:
A partner and I are in the midst of creating a (not so) simple game via C++ and SFML (2D). We have both created some simple games (not together) and would like to start work on a more serious, larger project that challenges our abilities to program, interact with large code as well as working together without getting in each other's way.

The problem is the getting in each other's way- well, not yet at least.

We had our first group session today (us two working on the project, one to-be tester and a friend of ours) and wrote down some ideas. It's going to be a birds-eye perspective zelda-like (from SNES) game with a streamlined map and quasi-linear gameplay like Gothic (open world, but you'll likely get yourself killed if you wander around too much).

Needless to say, I'm not sure if we're aiming too high for the moment, but our biggest concern is the division of responsibilities. Our first impulse was to work on aspects of the game that had nothing in relation to the other (I would work on the menu, he would work on the map, for example).

Our next impulse was to work on closely-related things in a list-manner. (First the menu, then a map, then the character, then the monster, etc) so we can, piece-by-piece, see our code coming to life in an orderly fashion.

We haven't picked a VCS yet, but I'm thinking it's going to be Mercurial for the simple reason that I have heard good things of it (neither of us have yet to use a VCS).

Question:  What would be the proper way to divy up the responsibilities between the two of us? How should we start, how should we continue and how do we do it together with maximum efficiency? Any other tips would be greatly appreciated!


texts: Why does the code in Unity affect objects differently?

texts:
There are 2 objects made in a blender and imported into Unity.

Eye of the Cyclops.blend

Flask.blend:

The problem is that after using the code, which should create an object in the hand-body area (I'm still working on it), one object is created far from the character.

Example:

Everything is OK.

It's not ok.

Code:
PlayerInteraction:

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

public class PlayerInteraction : MonoBehaviour
{

    public GameObject target = null;

    public KeyCode interactKey;

    public GameObject itemHolder;

    private void Update()
    {
        if (Input.GetKeyDown(interactKey))
        {
            if (target == null)
            {
                return;
            }

            FoodBox food = target.GetComponent<FoodBox>();
            if (food != null && itemHolder == null)
            {
                food.Interact(this);
            }

            TableBox table = target.GetComponent<TableBox>();
            if (table != null)
            {
                table.Interact(itemHolder, this);
            }

        }
    }

    public void SetItem(GameObject c)
    {
        if (c != null)
        {
            Debug.Log("Взяли предмет!");
            itemHolder = Instantiate(c, transform.position + new Vector3(0f, 2.15f, -0.65f), Quaternion.Euler(-90f, 0f, 180f), transform);
        }
        else
        {
            Destroy(itemHolder);
        }
    }

    private void OnTriggerEnter(Collider col)
    {
        if (target != col.gameObject && target != null)
        {
            return;
        }
        else {
            target = col.gameObject;
            Debug.Log("Мы дошли сюда до " + target.name);
        }

    }

    private void OnTriggerExit(Collider col)
    {
        if (col.gameObject == target)
        {
            target = null;
        }
    }
}

TableBox:

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

public class TableBox : MonoBehaviour
{

    public GameObject itemHolder;

    private void Start()
    {
        if (itemHolder != null)
        {
            itemHolder = Instantiate(itemHolder, transform.position + new Vector3(0f, 1.9f, 0f), Quaternion.Euler(-90f, 45f, 0f),transform);
            Debug.Log("Мы создались!!");
        }
    }

    public void Interact(GameObject i, PlayerInteraction player)
    {
        if ((i == null || itemHolder == null))
        {
            player.SetItem(this.itemHolder);
            Destroy(this.itemHolder);
            //Debug.Log(itemHolder);
            this.itemHolder = i;

            if (this.itemHolder != null)
            {
                this.itemHolder = Instantiate(this.itemHolder, transform.position + new Vector3(0f, 1.9f, 0f), Quaternion.Euler(-90f, 0f, -135f),transform);
                Debug.Log("Мы ингридиенты из ТейблБокса!");
            }
        }
        else
        {
            return;
        }
    }
}

FoodBox:

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

public class FoodBox : MonoBehaviour
{

    public GameObject ingredient;
    private Animator anim;

    // Use this for initialization
    void Start()
    {
        anim = GetComponent<Animator>();
        anim.SetBool("openFoodBox",false);
    }
    public void Interact(PlayerInteraction player)
    {
        anim.SetBool("openFoodBox", true);

        if (anim.GetBool("openFoodBox")) {
            anim.Play("Opening");
            player.SetItem(ingredient);
            Debug.Log("Мы ингридиенты из ФудБокса!");
        }

        anim.SetBool("openFoodBox",false);
    }
}

There is also an assumption that this is due to the initial position of the models. Because for me, some models are stored normally vertically, and some lie horizontally.

I also add the prefab inspector:

Eye of the Cyclops:

Flask:


texts: Stopping sprites from toppling off platform

texts:
I am new to Unity and am trying to create a simple 2d platformer. I have applied a box collider to my player sprite and the floor/platform its standing on. Now when I go over the platform, it toppes off of it as expected, but I want it to simple fall off it instead of toppling. How can I do this?

Also I saw a video of Unity Live Training in which he was using a separate circular collider for the player's feet. When I did this, the sprite started rolling.

Can anybody help me with this?


texts: Is there a typical career path to learn game development "on the job"?

texts:
The extended version of the question is: what is the typical career paths that a developer without specific experience in game development should take if he/she wishes to work in the game development industry? In other words, what are the positions such a programmer might aspire to get hired for, in the game industry?

I am asking because it seems to me that - even without direct experience with 3D modelling, physics engines, shaders, etc... - for as much complex as these topics might be - they are still "just" top layers one can learn "on the job" if he/she has already good programming skills and experience in software design (for example during peer-programming sessions).

I have no knowledge whatsoever of the game industry, so maybe I am being naïve here, but for all the other programming jobs I previously took, I learned most of the specificics while working on concrete projects... so I wonder if there is a chance to do the same with game development.

Thanks for your time and advice! :)

PS: I don't know if this is important or not for answering the question, but scripting languages are the languages I am more proficient in.


texts: Is it feasible to create a game in godot using little to no GDScript

texts:
I am trying to get more into game development, I have very little experience with it. I've been messing around a bit with the Godot engine and am slowly starting to understand it more. I have some experience with C# and C++, both of which can be used with Godot (to my knowledge, correct me if I'm wrong), and it also has its own language, GDScript. From what I've seen the language looks a lot different from any I've used (C#, C++, and Java), and I really don't want to learn it, I especially don't want to learn a new engine and a new language at the same time.

So basically would it be possible to create a game in Godot using very little to no GDScript without missing out on features or making life a whole lot harder? Another way to word it could be 'is there any thing that is impossible or very much harder to do in C# or C++ than if you were using GDScript?'

Sorry if this is too broad or anything, I'll try to fix it if need be


texts: Why are some of my normals facing away from the camera?

texts:
I'm trying to use WebGL to render some simple models, and I'm running into issues where pixels near the edge of my model are passing normals to my fragment shader that point away from the camera. This is of course messing with my attempts to use physically-based shading, because BRDFs are only defined in the hemisphere around the normal vector. These normals aren't just slightly pointing away from the screen; if that was the case, I would chalk it up to floating-point error and clamp to acceptable values. But some of my pixels have v-dot-n values of -0.5 or less.
This happens on pretty much any mesh I try to render. I have verified that my vertex normals point away from the mesh. I have backface culling turned on. This happens with both perspective and orthographic projections. I have tested in both Firefox and Chrome. Everything else about my render looks fine.
My vertex shader looks like this:
precision mediump float;

uniform mat4 M;
uniform mat4 V;
uniform mat4 P;

attribute vec3 vertexPos_model;
attribute vec3 vertexNormal_model;

varying vec3 pos_world;
varying vec3 normal_world;

void main() {
    gl_Position = P * V * M * vec4(vertexPos_model, 1.0);
    pos_world = (M * vec4(vertexPos_model, 1.0)).xyz;
    // We can use M here instead of its inverse transpose because it does not scale the model.
    normal_world = mat3(M) * vertexNormal_model;
}

And my fragment shader looks like this:
precision mediump float;

uniform vec3 cameraPos_world;

varying vec3 pos_world;
varying vec3 normal_world;

void main() {
    vec3 n = normalize(normal_world);
    vec3 v = normalize(cameraPos_world - pos_world);
    float vAngleCos = dot(n, v);
    // This will highlight pixels whose view vectors are outside of the hemisphere around n.
    gl_FragColor = vec4(vec3(clamp(-vAngleCos, 0.0, 1.0)), 1.0);
}

Rendering with the fragment shader above gives me results like this:

Apologies if I'm missing something obvious!


texts: How often do big MMORPG update the physics?

texts:
As far as I understand, most big games use fixed timestep to have a stable simulation.

Regarding the game server, which "frame rate" do they impose? Or said it another way, what fixed timestep do they tend to use?

I know many would say: "As fast as they can get away with". I'd like to know how fast is that, if you have direct experience of established MMORPG.


texts: How do I define spawn patterns for a Fruit Ninja-esque game?

texts:
I'm creating a game somewhat similar to Fruit Ninja and others, where bombs are thrown up on the screen and you click or touch them to defuse (here is an example of the game).

There are four bomb spawn points and I want to pre-define launch patterns that are interesting and challenging to the player. I'm struggling to think of a good way of defining this data.

How can I pre-define launch times for up-to 4 spawn points in a way that the data is human-readable (so that I don't have to spend too long tweaking each value)?


texts: Correct order of operations when enabling/disabling Cg shaders in OpenG

texts:
I've started writing an Effect class which uses Cg shaders in OpenGL and I'm a bit confused about the order of operations when creating and rendering using Cg.

Currently, my Effect class contains CGprogram, CGprofile and an array of CGparameter variables which get populated on loading the Effect similar to this:

m_vertexProfile = cgGLGetLatesProfile(CG_GL_VERTEX);
cgGLSetOptimalOptions(m_vertexProfile);
m_vertexProgram = cgCreateProgramFromFile(g_cgContext, CG_SOURCE, fileName, m_vertexProfile, entryPointName, NULL);
cgGLLoadProgram(m_vertexProgram);[/color]

CGparameter param = cgGetFirstParameter(m_vertexProgram, CG_PROGRAM);
while (param)
{
    const char* paramName = cgGetParameterName(param);
    m_vertexParameters[m_vertexParamNum++] = param;
    param = cgGetNextParameter(param);
}

It's not exactly like this and this is only using a vertex shader but it contains the important code. Anyway, that's how I create the Effect and then when I want to use it during a render I use Enable() and Disable() functions before and after I draw the verts etc.

void Effect::Enable()
{
    cgGLBindProgram(m_vertexProgram);
    cgGLEnableProfile(m_vertexProfile);
}

void Effect::Disable()
{
    cgGLUnbindProgram(m_vertexProfile);
    cgGLDisableProfile(m_vertexProfile);
}

I'm not sure if this is the correct way to do it, though. Is it correct to enable and disable the profile for each shader? More to the point, do I actually want a profile per shader? I'm using the same profile for each shader so surely I could just have a global one and use that?

Any advice would be much appreciated.


texts:
As my first "real" project, I'm working on a game that I intend to be single-player, web-based, and primarily in text. I need the ability to save choices the players make, and to have certain variables increase based on those choices. (Like bravery increasing after a heroic choice is made, for example.) There's a very small inventory; not RPG-style elaborate. The big thing about it is the choice aspect; every choice impacts where the player can go/future success or failure in other situations/etc. So I really have to be able to save those. (Choice input was being done by simple buttons, but I'm not married to that.) I'd like the player to be able to close the browser, then come back to it later where they left off- so, a login system, too.

My biggest problem is that I feel like I'm getting jerked left and right on which language(s) to use for this. I started off with Python a few months ago and started getting comfortable in that, but then didn't like how hard it was to integrate it in to a website afterward. (Hard for me, anyway. I might just be stupid, or failing to find the right tutorials on it.) I got a book on Javascript ("The Good Parts"), but found it unhelpful for what I was trying to do and my skill level. Then I got a book on PHP and MySQL ("PHP and MySQL Web Development") and started getting used to that, thinking it would be useful for saving player choices, but now all I see when I google specific questions about mySQL with games is people saying, "You don't want to use MySQL for games." So have I been wasting my time on that?

What language would you use for a single-player web game that was text-based and had to save many player choices? Or was I already going the right direction to start with?


texts: Is it sensible to make all physics on GPU using transform feedback?

texts: I'm learning OpenGL and today I read something new to me. It's called transform feedback, and if I understand right, it can help to get information about vertex shader variables. And I read an example where a particle system was created, with collisions. After reading it I have a question: Is it sensible to make all physics like this, i.e. is there any kind of profit from this?


texts: Monogame + Render Target + antialiasing doesn't work

texts:
Is there any proper way to use antialiasing, while rendering to a RenderTarget2D and using Monogame?

I do this:

renderTarget = new RenderTarget2D(GameData.GraphicsDevice,
    pp.BackBufferWidth, pp.BackBufferHeight, false,
    GameData.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24,
    4, RenderTargetUsage.DiscardContents);

but AA is disabled despite setting multiSampleCount to 4. The hardware supports it and it works if rendering directly to the back buffer.

I googled around and it seems it used to work for XNA, but for Monogame I found this: https://github.com/mono/MonoGame/issues/1162

This link suggests it's an open issue and is from 2013. This is hard to believe for me, because it would effectively make using Monogame render targets unusable for most applications..


texts: Removing unecessary permissions from AndroidManifest that Unity+Plugins put in there?

texts:
My game has a lot of unnecessary permissions added to it, I suspect some are coming from plugins and some from Unity. I've looked at all the AndroidManifest.xml files and couldn't find any that use those permissions so I suspect it's added as a post build process or some other way by the plugins wrapped up in a binary or something.

Is there a way to remove those permissions in a post process build step?


texts: Game freezing when i create a body Box2D Libgdx

texts:
I'm implementing a Worms game using libGDX and Box2D and I'm  having a problem I didn't have until recently. When a player shoots, it creates a bullet body and applies a force to it. I have a step system to see what the player should be doing( move, select weapon, select angle and charge force). The methods involved with shooting in player are :

public void nextStep(){
    if ( turnStep == 0){
        startingPosition = player.getPosition().x;
    }
    turnStep++;
    if(turnStep > 5){
        turnStep = 0;
        chargeBar.dispose();
        movementBar.dispose();
        arrow.dispose();
    }
    if(turnStep == 1)
        movementBar = new MovementBar(getX(),getY(),world);
    if(turnStep == 3)
        arrow = new Arrow(getX() + tex.getWidth() /2, getY() + tex.getHeight() / 2,  world);
    if(turnStep == 4)
        chargeBar = new ChargeBar(getX(),getY(),world);
    if(turnStep == 5){
        shooting = true;
    }
}

public void shoot(){
    actualWeapon.shoot( arrow.getTip(), chargeBar.getCharge() , arrow.getAngle());
    shooting = false;
}

In my main game class, I have an update method where I do the world step and update other things, and I perform the shooting here

    world.step( 1/60f, 6, 2);
    if (playerWhoseTurnItIs.isShooting()){
        playerWhoseTurnItIs.shoot();
    }

Which ends up calling :

public void shoot(Vector2 pos, float force, float angle){
    isFlaggedForDeletion = false;
    body = BodyCreators.createBox( pos.x * PPM, pos.y * PPM, projectileTex.getWidth(), projectileTex.getHeight(), false, false, world, (short) BIT_PROJECTILE, (short) (BIT_PLAYER | BIT_WALL), (short) 0 , this);
    Vector2 f = new Vector2( force * MathUtils.cos(angle * MathUtils.degreesToRadians), force * MathUtils.sin(angle * MathUtils.degreesToRadians) );
    body.applyForceToCenter( f , true);
}

Everything used to work fine, and I didn't touch any of this while working, but now every couple of turns the bullet just appears and then freezes there, on the tip of the arrow, freezing my whole game.

Also, when I started having this problem I implemented the check after the world step, it just used to shoot when i called nextStep() and the turn was five, but since applying the check didn't actually solve the problem (I thought it was like when destroying bodies you can only do it after the step) I might revert the change.

If you need more information please ask, thank you


texts: Connect-three game: Increasing level-of-difficulty as play progresses

texts:
I'm writing a connect-three type game (think Chuzzle, but without all those nasty locks, and with no big chuzzles) and I'm trying to figure out how to increase the level of difficulty as play progresses.

As it stands, I've been adding an additional block colour/shape/type when the player advances to another multiple of num_blocks*1000, and it seems to work moderately well, aside from the fact that I keep running out of new colours/shapes/types that look distinct enough on the screen.
(currently, blocks only differ by colour, but I'm planning on adding a shaped highlight to help differentiate)

I'd like to know if manipulating the probabilities of each block type based on the blocks surrounding the new block in an attempt to minimize the chances of cascades and other types of easy matches would be a good idea.


texts:
I'm writing an AnimatedSprite class that has an Animation object (which itself contains a sprite sheet).

The AnimatedSprite plays certain animations during key input. My problem is that how do I cycle from one animation back to the original ? Is there a good method to do this?

Here is my Animation class. The AnimatedSprite just calls PlayAnimation

public class Animation
{
    public SpriteSheet SpriteSheet { get; set; }
    public bool IsActive { get; set; }
    public float FramesPerSecond { get; set; }
    public bool IsLooping { get; set; }
    public int FrameCount { get; set; }

    private int CurrentFrame { get; set; }
    private float ElapsedTime { get; set; }
    private float TimePerFrame { get { return 1.0f / FramesPerSecond; } }

    public Texture2D Texture { get { return SpriteSheet.Texture; } }
    public Rectangle Rectangle { get { return SpriteSheet.SourceRectangle(CurrentFrame);} }

    public Animation(SpriteSheet sheet)
    {
        SpriteSheet = sheet;
        FramesPerSecond = 20f;
        IsActive = true;
        IsLooping = false;
        FrameCount = SpriteSheet.NumberOfSprites;
        CurrentFrame = 0;
        ElapsedTime = 0;
    }

    public Animation(SpriteSheet sheet, int fps) : this(sheet)
    {
        FramesPerSecond = fps;
    }

    public virtual void Update(GameTime gameTime)
    {
        if (!IsActive)
            return;

        ElapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

        if (ElapsedTime > TimePerFrame)
        {
            CurrentFrame += 1;//move frame ahead one
            if (CurrentFrame >= FrameCount)
            {
                CurrentFrame = 0; //reset the animation;
                if (!IsLooping)
                    IsActive = false;
            }

            ElapsedTime -= TimePerFrame;
        }
    }

}


texts:
I've seen many tutorials for simple rectangle or circle-based collision detection with pygame.

But how can I do more complex collisions with arbitrary polygons?

Is the only option pixel-based collision detection?


texts: Isometric tiles on wrong positions if the mouse points at a negative world coordinate

texts:
I am using this approach:
http://clintbellanger.net/articles/isometric_math/
Basically, you can calculate the iso coordinates based on the screen coordinates.
What I am doing is, getting the actual world position the mouse is pointing at using get_mouse_global_position() and convert this position to isometric values.
Then I translate those coordinates back to world space coordinates to actually display the sprite.
Problem is, that when the world coordinates come from a negative position, the tiles get offset by almost an entire tile amount.
Here is the relevant code.
The get_coord() function returns the actual world position of the tile used to display the Sprite
func get_coord(pos : Vector2):
    var t = Vector2()
    var e = screen_to_iso(pos)
    t = iso_to_screen(e)
    print(pos)
    print(e)
    print(t)
    return t
    pass
var buildings

func screen_to_iso(pos :Vector2):
    var flipx = 0
    var flipy = 0
    var t = Vector2()
    var x_size = size/2
    var y_size = size/4
    t.x = int((pos.x/x_size) + (pos.y/y_size))/2
    t.y = int((pos.y/y_size) - (pos.x/x_size))/2
    return t
    pass

func iso_to_screen(pos : Vector2):
    var t = Vector2()
    var x_size = size/2
    var y_size = size/4
    t = Vector2((pos.x-pos.y)*x_size, (pos.x+pos.y)*y_size)
    return t
    pass

I can't seem to figure out a way


texts: Is there any list of game names anywhere, so i can choose a name for my game and avoid (legal) conflicts with other games as much as possible?


texts:
I'm quite new to java.

I was watching 2 video tutorials on how to make java game and read a couple articles about game loop. However, I'm still confused about how game loop actually works.

The first tutorial used code that looked like this (I modified some codes from the tutorial and commented on top):

/*
 * Game Loop of the game. It uses fixed timestep.
 * Optimal time represents time needed to update one frame.
 * Update time represents time actually taken to update one frame.
 *
 * By calculating the difference between optimal and actual time,
 * we can let Thread to sleep for the exact time we are aiming for, which is 60 FPS.
 */

public void run() {
    long now;
    long updateTime;
    long wait;

    final int TARGET_FPS = 60;
    final long OPTIMAL_TIME = 1000000000 / TARGET_FPS;

    while (isRunning) {
        now = System.nanoTime();

        update();
        render();

        updateTime = System.nanoTime() - now;
        wait = (OPTIMAL_TIME - updateTime) / 1000000;

        try {
            Thread.sleep(wait);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

This is quite easy to understand and I have no problem with using this game loop. However, the second tutorial used more complex game loop that I had a hard time understanding it:

public void run() {
    long lastTime = System.nanoTime();
    double amountOfTicks = 60.0;
    double ns = 1000000000 / amountOfTicks;
    double delta = 0;
    long timer = System.currentTimeMillis();
    int frames = 0 ;
    while (running) {
        long now = System.nanoTime();
        delta += (now - lastTime) / ns;
        lastTime = now;
        while (delta >= 1) {
            tick();
            delta--;
        }
        if(running)
            render();
        frames++;

        if(System.currentTimeMillis() - timer > 1000) {
            timer += 1000;
            System.out.println("FPS: " + frames);
            frames = 0;
        }
    }
    stop();
}

I do not understand the use of timer and frames variable and how delta is being used. Is timer and frames simply used for printing out the FPS on the console screen? Also, help me clarify the use of delta variable in this code.

The use of delta variable is quite different from the other game loop that I know of. From the articles that I read, I've seen a different use of delta. Here is what I tried to come up with on my own after reading the articles:

/*
 * Delta is ratio of how fast computer is running.
 * It is achieved by calculating:
 * (actual time) / (optimal time)
 *
 * This is passed to update method to calculate time taken
 */

public void run() {
    long lastLoopTime = System.nanoTime();
    final int TARGET_FPS = 60;
    final long OPTIMAL_TIME = 1000000000 / TARGET_FPS;

    while (isRunning) {
        long now = System.nanoTime();
        long updateTime = now - lastLoopTime;
        lastLoopTime = now;

        double delta = updateTime / (double) OPTIMAL_TIME;

        update(delta);
        render();
    }
}

Will the above code be fine as it is?

Out of these three sets of codes, which game loop would be the most optimal to use? I feel like the first set of code is too simple that it might not be as efficient as other two (not that it actually is, but just a feeling that I get).


texts: How to handle materials in an Entity/Component system

texts:
My E/C implementation is the basic one where Entities are just ID's, Components are data and Systems act on the Data. Right now I'm having trouble with object materials and rendering in general. For simple objetcs I have a ModelComponent, tied to a RenderSystem, ModelComponent has the vertex buffer ids that the render system uses. A simple MaterialComponent would probably have color or specular strenght, etc, but I wanted it to be flexible enough to allow for more than one render pass and general "effects" that are not as easy as a simple variable in the MaterialComponent.

Trying to solve these problems I came up with two solutions:

1 - Super-generic Material Component

Something like this:

struct Material : public Component
{
    ShaderData* shader;
    std::vector<std::pair<std::string, boost::any>> uniforms;
    [...]
};

and in the render system I would loop and pass the uniforms to the shader. I suppose this would be slow, but fast enough for my purposes.

2 - Another layer of abstraction, MaterialData

Having a class to wrap specific materials, that could be inherited by whatever specialized  material, the base class would have something like void set_shader_constants(ShaderData* d) but the implementation is up to each class, and the MaterialComponent would have a pointer to a MaterialData object.

I'm not sure which approach I would prefer, but neither of these touch the subject of multiple passes, or other complex rendering techniques.

Any idea on how to accomplish this?


texts:
I have two Actors on my stage in libgdx and and both have a InputListener. I override the touchDown method and it works fine. My Problem is that when I press my Actor Z and a second later Actor Y only Actor Z fires a touchDown event.

How do I solve this problem?
Or how did you solve the problem when you have some input actors/sprites on your screen and you wanted that the player can jump and move to the right at the same time?


texts:
i have a grid layout group containing buttons. My game must be playable with a joystick and so I have to navigate the buttons using horizontal/vertical input.

My problem right now is when the layout group first becomes visible. Once I click on a button (with my mouse), it becomes "selected" and I can navigate through the layout group with my keyboard and 'click' with spacebar. This functionality is all fine, except for the need to click the button with a mouse to set the first selection.

I've tried both of the following:

void buttonClicked() {
    Debug.Log("clicked");
}

void Start () {
  // this button is actually instantiated from a prefab,
  // not shown here
  Button btn = inventorySlot.button;

  btn.onClick.AddListener(buttonClicked);

  # attempt 1
  btn.Select();

  # attempt 2
  eventSystem.SetSelectedGameObject(
    btn.gameObject,
    new BaseEventData(eventSystem)
  );
}

both these commands do select the button, but they also inadvertently call the onClick, and the button is clearly being clicked because it changes color (I have configured this through button opts in the inspector).

My question is - how can I "select" the button without clicking it?

I perhaps should also note, I am populating the layout group with buttons at runtime. Each button is intantiated from a prefab in Start() (not showing that here). I only add the event listeners and try to select the button after it's already added to actual game objects in my scene.


texts: Is it possible to not pack asset files into archives when building a Unity game?

texts:
When I build a game in Unity, it packs the assets into strange data files with strange extensions like .split2 or .split1.

But what if I want to give the player the ability to replace textures and modify the game without reverse engineering these files?

I want the Assets folder as I see it in the editor to be accessible with the same files in the build.


texts: How collision boxes are assigned to object in 3D games?

texts:
Level designers make levels and then programmers import the models and use it but How and when collision boxes are generated for objects and models in the 3D map placed at random locations?

Thanks.


texts: Are there any good tools or suites out there that help with building AI/Robots for browser based games?

texts: I've found some HTML/Canvas/Javascript browser based games that I don't particularly enjoy playing, but which I think would be fun to write robots for. Are there any tools out there which help remove some of the tedium of the work, and get me closer to writing the actual AI portion of the code?


texts:
Using the tutorial: Components and Collision as a guide, to dynamically load a SphereShape the following is done:

AClass::AClass()
{
    // Create USphereComponent
    USphereComponent *sphere = NULL;
    sphere = CreateDefaultSubobject<USphereComponent>(TEXT("Root"));
    sphere->InitSphereRadius(1.0f);
    sphere->SetCollisionProfileName(TEXT("PhysicsActor"));
    sphere->SetSimulatePhysics(true);
    sphere->WakeRigidBody();

    // Create UStaticMeshComponent
    UStaticMeshComponent *mesh = NULL;
    mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    mesh->SetupAttachment(RootComponent);

    // Load asset from filesystem
#define ASSET TEXT("/Game/MobileStarterContent/Shapes/Shape_Sphere.Shape_Sphere")
    static ConstructorHelpers::FObjectFinder<UStaticMesh> asset(ASSET);
#undef ASSET
    if (asset.Succeeded())
        mesh->SetStaticMesh(asset.Object);

    RootComponent = sphere;
}

Now, when I try the same set of steps, but this time for an Actor that has a UDestructibleComponent instead of a USphereComponent:

AClass::AClass()
{
    // Create our UDestructibleComponent
    UDestructibleComponent *destructible = NULL;
    destructible = CreateDefaultSubobject<UDestructibleComponent>(TEXT("Root"));
    destructible->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
    destructible->SetSimulatePhysics(true);
    destructible->SetEnableGravity(false);
    destructible->WakeRigidBody(NAME_None);

    // Load asset from filesystem
#define ASSET TEXT("/Game/MobileStarterContent/Shapes/Shape_Cube_DM")
    static ConstructorHelpers::FObjectFinder<UDestructibleMesh> asset(ASSET);
#undef ASSET
    if (asset.Succeeded())
        UE_LOG(LogTemp, Warning, TEXT("It worked!"));

    RootComponent = destructible;
}

I receive the following errors:

ConstructorHelpers.h:105:20: error: cannot initialize a parameter of type 'UObject *' with an lvalue of type 'UDestructibleMesh *'
ValidateObject( Object, PathName, ObjectToFind );
                ^~~~~~

ConstructorHelpers.h:29:19: error: incomplete type 'UDestructibleMesh' named in nested name specifier
UClass* Class = T::StaticClass();
                ^~~

I've also tried adding .Shape_Cube_DM to the end of the string, similar to how the first asset was imported, but no luck. What is the correct way to load a DestructibleMesh from the filesystem and apply it to the UDestructibleComponent?


texts: Moving towards and switching targets in Unity with collision

texts:
I have these nodes set up for a ship to move towards over time with out looking stops then repeats in a sequence.

like so:

1 2 3 1 2 3 1 2...

THE PROBLEMS i keep having either come from the inability to switch direction or the ship ignores all collision which i would like to be able to shoot it with actual objects.

Ignores all Collision:

Vector3 currentPosition = thisShip.transform.position;
    Vector3 directionOfTravel = targetPosition - currentPosition;
    directionOfTravel.Normalize();
    thisShip.MovePosition(currentPosition + directionOfTravel * speed * Time.smoothDeltaTime);

This one works perfectly but because MovePosition is a kin to translate and actually teleports objects it ignores all collision which i need.

Can't Switch Direction:

Vector3 currentPosition = thisShip.transform.position;
        Vector3 directionOfTravel = targetPosition - currentPosition;
        directionOfTravel.Normalize();
        thisShip.AddRelativeForce(currentPosition + directionOfTravel * speed * Time.smoothDeltaTime, ForceMode.Force);

so in this one i try to stop the rigid body by returning its velocity to zero and it does stop for a second but continues in its original direction anyways.

thisShip.velocity = Vector3.zero; // Use this to pause object

I believe i need another method of movement (maybe use a CC) or maybe i can make AddRelativeForce work and be able to switch targets like MovePosition does. I'd really like to get this one thing done so i can move on to other parts of the project.


texts:
I have asked questions for this project before, but the jumping physics are a bit messed up. I cannot jump unless I hold down the W key, and then it just teleports me upwards. Does anybody know how to fix this glitch? Here's the code:

var canvas = document.getElementById("canvas")
            var ctx = canvas.getContext("2d")
            var x = 1
            var y = 0
            var xPos = 0
            var yPos = 0

            function updateVariables() {
            x = x * 0.9
            y = y * -0.9
            y = y + 0.5
            xPos += x
            yPos += y
            }

            function clear() {
            ctx.clearRect(0,0,600,600)
            }

            function Draw() {
            collisionCheck();
            clear();
            ctx.fillRect(xPos,yPos,10,10)
            ctx.fillRect(0,canvas.offsetHeight * 0.7,600,200)
            window.requestAnimationFrame(Draw)
            }

            function collisionCheck() {
            if (yPos > canvas.offsetHeight * 0.7 - 10) {
                yPos = canvas.offsetHeight * 0.7 - 10
            }
            }

            function right() {
                x = 2
            }

            function left() {
                x = -2
            }

            function jump() {
                y =+ 20
            }

            function detectKeys() {
                document.onkeypress = function (e) {
                    e = e || window.event;
                    console.log(e.key)
                    if (e.key == "d") {
                        right()
                    }
                    if (e.key == "a") {
                        left()
                    }
                    if (e.key == "w") {
                        jump()
                    }
                }
            }

            window.requestAnimationFrame(Draw)
            setInterval(updateVariables, 1)
            setInterval(detectKeys, 1)
<canvas id="canvas" width="500" height="140"></canvas>


texts: How powerful is modern hardware for complex, intensive 2D graphics?

texts:
I am embarking on a massive (image quality, file size, high frame count) project. I am still working on the basic engine, but have a big question that I would like answered before I begin testing. (It requires a lot of work to test, and possibly fail and have to recreate all sprite sheets, so an answer can help me save weeks of work if I'm wrong.)

The game is entirely in 2D, with 2.5D view. I want to eventually have 40 animations, which all have to be animated in 8 directions. I want each direction/animation to have its own sprite sheet. This equates to hundreds of spritesheets and thousands of files.

Before the obvious solution "Degrade quality for file size!" I would like to take every step possible to prevent degradation of quality, animation frame count, and image size.

Before my solution, one character was 350MB in ram (LOL!) but that was fixed quickly down to 10-20MB per whole character. That is...if I were to load ALL (40) animations in ALL directions (8). So if I were to load 320 sprite sheets into memory, it was going to be a ridiculously large amount per character in ram.

MY QUESTION IS THIS:

How much (of total sprite sheets) should I have loaded into memory at any given point?

Can I get away with loading ONLY the CURRENT spritesheet (Direction + Animation) into memory? Is modern hardware fast enough to constantly swap textures on the fly?

Players could, at any moment, change direction. This would change the entire spritesheet.
Same for animation. So within a split second, the game would have to load a specific new spritesheet, unload the old one (or unload it eventually), and render all within a split second. This would have to be done once for every character, anytime they animate or change directions in a real time game.

Fortunately, the amount of characters on screen at once will be limited by the fact the game is 2D, but I'd prefer to be able to cram in the maximum amount without performance issues on a mediocre computer.

Is texture swapping, file loading, instant rendering from HDD and memory-- all so fast with modern hardware that I wont even need to worry about ANY of this?

I just dont want to work on all of these spritesheets (from thousands of images I already have) only to find out my performance will be horrible and have to redo all spritesheets. Even to test, since I have a layering equipment system, is a time consuming task for spritesheet creation. That is, until I find a solution to process those faster (automation, i do it manually currently, using a program)


texts: I created a pland in Unity 3D and then tried to alter the material.  I looked at it's material component, but all the options are greyed out!  how do I fix this problem?


texts: Ensuring dash toward mouse position is always a consistent distance

texts:
I'm making a 2D game where the player character should dash toward the mouse position when the player clicks, but the dash is currently not a consistent distance each time.

Let's say you put the cursor far-right like x = 20, so the character moves 20 units. But if you put it closer, like at  x = 5, the character dashes only 5 units.

How can I limit the position input to just a direction, so the player character would travel the same distance, no matter where the mouse is positioned?

void FixedUpdate() {
    //...
    float xor = Input.GetAxis("Horizontal"), yor = Input.GetAxis("Vertical");

    if ((xor != 0 || yor != 0) && !dash)
    {
        rg2d.velocity = new Vector2(xor * speed, yor * speed);
        anim.SetFloat("speed", Mathf.Abs(xor + yor));
    }
    if(Input.GetKeyDown(KeyCode.Mouse0) && !fire)
    {
        //PUNCH
        dash = true;
        fire = true;
        StartCoroutine(Stop_Fire(0.5f));
        anim.SetTrigger("attack");
        fist.GetComponent<Collider2D>().enabled = true;

        Vector2 pos = (transform.position - Camera.main.ScreenToWorldPoint(Input.mousePosition)).normalized;

        rg2d.AddForce(-pos * punch_force, ForceMode2D.Impulse);
    }
}

// I call this function at the end of the attack animation, in the Animation window
public void Stop_Dash()
{
    dash = false;
    fire = false;
    fist.GetComponent<Collider2D>().enabled = false;
    rg2d.velocity = Vector2.zero;
}


texts:
I'm still a beginner, the example on skaslev's site require us to use glut as an interface to create a window.

For some reason, I'm required to create a window purely with Win32 api, but I am not sure of how to integrate it together with gl3w.c

Is there a guide or tutorial on how to do that? I've been searching for hours, seems out of luck :(


texts: How to add a callback to addAction in scene2d

texts:
Sorry if this is a newbie question, I'm still learning libgdx. I'm using scene2d and I am trying to fade a tooltip into my scene and fade it out after 4.5 seconds.

Everything is working in my code except that tooltip.setVisible() always overrides the fading animation. I'm wondering if there's a way to set up a callback function or if there's any way to tell when an action has completed so I can trigger setVisible after the fade animation has completed. I thought about setting up a second timer that triggers after 5 seconds, but that seems like a hacky way to do things.

Here's my TooltipListener class:

public class TooltipListener extends InputListener {

private Actor tooltip;
private InputListener inputListener;
private Timer timer = new Timer();

public TooltipListener(Actor tooltip) {
    this.tooltip = tooltip;
}

@Override
public boolean touchDown(
    InputEvent event,
    float x,
    float y,
    int pointer,
    int button
){
    tooltip.setVisible(true);
    tooltip.addAction(fadeIn(1f));
    tooltip.toFront();

    timer.scheduleTask(new Timer.Task() {
        @Override
        public void run() {
            tooltip.addAction(fadeOut(1f));
            tooltip.setVisible(false);
        }
     }, 4.5f);

    return true;
}

}


texts: How can I consistently identify location on a mesh from a raycast hit?

texts:
I am using RaycastHit.triangleIndex to identify a location on a mesh (very low poly). However, I have discovered that a given triangle on the mesh does not have the same triangleIndex value from one execution of the game to the next (index "1" maps to location "A" on the first run, but location "B" on the second run). It is consistent within a given game, but for my mapping to work I need it to be consistent across games.

Given that I am using Raycast, how can I consistently identify the same logical location on the model?

Notes:

The game object must be instantiated from a prefab (there are a variable number of them), so it could be that this is why the vertex order changes? Is there a way to instantiate with consistent vertex order?
If I need to ask the artist to recreate the asset with submeshes for each location, will I be able to consistently identify those?


texts: LWJGL GLFW hangs on native glfwInit call

texts:
For the past months I've been working on creating my own game engine for personal use in LWJGL using pieces here and there, especially from developer ThinMatrix's rightfully credited code, to learn as much as I can while building it. Only recently there has been strange behavior happening when I launch the engine from IntelliJ for testing:

After about 6-10 individual times I click run, all subsequent runs suddenly take about 60 seconds for the window to appear.

Whenever I restart my PC this hanging resets and I have another 6-10 runs before it hangs everytime again.

I located the issue to glfwInit, more specifically at the call to the native method:
  @NativeType("int")
  public static boolean glfwInit() {
      long __functionAddress = Functions.Init;
      return invokeI(__functionAddress) != 0; // Right here
  }

I also noticed that this issue only started when I attempted to implement text support in my engine using the STBTrueType library. It was perfectly fine before that. I tried removing the TrueType code but it didn't fix it.

Here's a list of things I've tried:

Clearing my temp folder in case a buggy or corrupted file was present.
Recompiling and rebuilding the entire LWJGL jars twice.
Building glfw.dll from the GLFW sources and replacing the glfw.dll in the native jars with the former.
Reinstalling Java and actually upgrading JDK versions (from 13.0.2 to 14.0.2)
Switching IDEs even if I suspected it wouldn't work.
Updating my NVIDIA drivers, and reinstalling them.

I'm quite confused as to what it could be, and I'd be more than happy to share code, thread dumps, or debug info if you deem it necessary. Here is the Github repository with the latest, "faulty" code (fault in quotes because I'm not too sure the code is the problem.)
Thank you very much for any guidance.
P.S: Please tell me if this is better asked in StackOverflow instead of here.


texts: How to change the default UDK game folder?

texts:
How can I change the default UDK game folder, the folder where it takes config files from?
Looking at the engine configuration files, it is taking it from %GAME%Game/, and when that's UDK, it loads from UDKGame, but how do I change the %GAME%?


texts:
I am developing a platformer game using SDL2 for graphics and Box2D for physics.
I am currently designing my levels and would like to know if it is better to make the static part of each level (ie: ground) one big (500+ units wide) polygon or to break each level up into multiple tiles just a few units wide.

The Box2D manual says that I should keep my objects small to avoid bugs in the floating point code but having a single large ground object seems like a resonable way of reducing the number of objects in the simulation.

So, can I make my ground object one large 500+ unit polygon or should I break it up into many smaller 1-2 unit polygons.


texts:
is it possible to obtain a material from another object?
I'm trying everything and nothing, the only thing I could get was just the color of another object
public MeshRenderer takematerial;
public GameObject[] Objects;
for (int i = 0; i < Objects.Length; i++) {
    Objects [i].GetComponent<Renderer> ().material = takematerial.material;
}