texts: Most effective way to perform dynamic list of actions?

texts:
I have a huge list of predefined game objects with different actions they do. What is the best (in terms of code simplicity and runtime performance) way to store, dynamically refresh and execute their actions after placement them in game in runtime?

Let's say GO1 every game turn creates copy of itself nearby. GO2 destroys all GO3's. GO3 adds resources. GO4 removes resources on its creation, etc. Each turn player instantiates one object from the list in the game world and after that they start to execute their actions. Player can build multiple objects of the same type, and there are hundreds of different gameobjects with hundreds of different types of actions. Objects can't change their actions in the runtime, for the sake of simplicity of this question. Each action can be very heavy on processor - for example, look through each other object. Having those be all executed at the same time is a problem itself.

Some ways I can think of (but having very little experience with the subject, I have no idea of their actual effectiveness):

  Assign every object a method on its own. Object initialisation list
  becomes very complicated and you can't really store it in xml-like
  file.
  Initialise objects with some kind of lambda or Action<> literal
  parameter. I can't imagine this is okay in terms of game resources,
  and probably is a hell for debugging.
  Initialise objects with a string of parameters. Simple to
  initialise, but parsing requires extra processor time.
  Initialise object with a struct-like list of actions. Simple to
  initialise, but number of childs in said mega-struct will become
  extremely big.
  Hardcode a mega-function with a lot of calls like "if (objectID ==
  GO2) then do" or cases. Sounds stupid, probably is.
  Unity-way: assign each instantiated object an own script, pass
  script name on initialisation, similar to p. 2. Most simple way, but
  can't be easy for a machine to execute. Also, changing object
  parameters will be complicated.

It should not matter, but I'm using Unity3D with C#.


texts: Intersecting dynamic bodies Box2D/Libgdx

texts:
Is that normal that while I'm jumping (by a player represented with a circle) on a dynamic bodies (boxes) they are interecting? It seems that there is some kind of diffraction. Is that any way to reduce this? Restitution is set to 0 for all.

The moment caught on a screenshot

And the moment after a collison


texts: What's the most memory efficient way to load a tiled map?

texts:
Currently I am working on a simple 2D platformer and I want to load a tiled map.

What I've started working on is loading the tiles using a text file. My first question is simple: is a text file the best way to load a map, and in what cases would different types of files be preferred?

I'm reading the file using a buffered reader. First of all I'm getting it to check the size of the map, then I'm using a second loop to create a byte array of that size. This is my code:

    try {
        BufferedReader findSize = new BufferedReader(new FileReader(filePath));
        String line;
        while ((line = findSize.readLine()) != null) {
            if(!line.startsWith("#")) {
                String[] values = line.split("\\s");
                if(values.length > rowSize)
                    rowSize = values.length;
                columnSize++;
            }
        }
        grid = new short[rowSize][columnSize];
        findSize.close();
    } catch(Exception e) {
        e.getMessage();
    }

    BufferedReader readTiles;
    try {
        readTiles = new BufferedReader(new FileReader(filePath));
        String line;
        short rowNum = -1;
        while ((line = readTiles.readLine()) != null) {
            if(!line.startsWith("#")) {
                rowNum++;
                String[] values = line.split("\\s");
                short y = 0;
                for(String v : values) {
                    grid[y][rowNum] = Byte.parseByte(v);
                    y++;
                }
            }
        }
        readTiles.close();
        initializeMap();
    } catch (Exception e) {
        e.getMessage();
    }

My second question is to ask whether this is the best way to do it. I've done some research and found that BufferedReader is faster than using the scanner, but I'm not exactly sure how I could shorten my code, and if it would be possible to create the array while checking its size. One way I've thought about doing it is through a list, but I'm not sure if this would be more efficient or even possible.

My third question concerns displaying the map. What would be the best way to do this? Should I create an array of BufferedImages and then assign each number in the current array to an index in that array?


texts:
My question is similar to a previous question. Consider the following clone of Starcraft: Change the artwork, sound, music, change the names of units. However, leave the unit hit points unchanged, unit damage unchanged, unit movement speed unchanged, change ability names but not ability effects.

Is that considered illegal? In other words, is copying the unit hit points, damage, etc. considered illegal even if everything else is changed?


texts:
So ive always had problems with buffers and never used them before. I read up on the topic online but since winbgim is so old i couldnt find any definite answers to the topic. So im gonna ask them here. I found getimage and putimage but i dont know if those are what im looking for. Maybe theres a much better option!

What i have done so far:

Ive searched for the answer online.
I looked through some posts here on the forum
I looked at the winbgim docs

My current code:

My current code is using the readimagefile function and it does work well. But the problem is that on systems that have an os greater than win7 ( i dont know why its fine on win 7 ) the disk is used 100% because it keeps reading the images over and over again from the actual files rather thier buffers.

Heres the decoder function i made. Its pretty messy. I just made it. Im still working on it. Its reading from a globally defined array ( I dont wanna use an dynamic array for personal reasons so i had to put it there because a [400][13] array kinda produces an stack overflow error )

Here it is:

 void decodelevelAndDraw(int minx, int maxx) {
    int x = 0, y = 0;
    while (y != 13) {
        while (x != maxx) {
            if (levelcode[x][y] == 1) {
                //x -= minx;
                readimagefile("question.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);
                //printf("Block added at %d;%d", x * 70, y * 70);
            }
            else if (levelcode[x][y] == 2) {

                if (levelcode[x][y - 1] == 2) {
                    readimagefile("DRECK.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

                }
                else if (levelcode[x + 1][y]== 2 && levelcode[x - 1][y] != 2) {
                    readimagefile("grass_side.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

                }
                else if (levelcode[x - 1][y] != 2 && levelcode[x][y - 1] == 2) {
                    readimagefile("dreck_side.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

                }
                else if (levelcode[x + 1][y] != 2 && levelcode[x][y - 1] == 2) {
                    readimagefile("dreck_side_right.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

                }
                else if (levelcode[x - 1][y] == 2 && levelcode[x + 1][y] != 2) {
                    readimagefile("grass_side_right.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

                }

                else readimagefile("grass.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

            }
            else if (levelcode[x][y] == 3) {
                readimagefile("1Punch.jpg", x * 70 - minx * 70, y * 70, 70 + x * 70 - minx * 70, 70 + y * 70);

            }
            x++;
        }
        x = 0;
        y++;
    }
}

More information:

So this is for a class project so i have to use the winbgim version of graphics.h . Im using visual studio 2015 community edition with a version identical to this one for the mingw compiler. If you need like the full project feel free to ask. I will send you anything you need.

So my question is:
How can i load an image into a buffer so it can be loaded quicker into the game without slowing down the dd?
Please add precise and full explanations so I understand the code instead of just copy and pasting it from your answer / some websites !
I am at a loss here and could really use some of your help.

Have a nice afternoon!


texts: How to transform a spherically-projected render into a perspective projection?

texts:
Suppose that you have a projection obtained by mapping spherical coordinates to a texture; example:

What is that projection called?
Is it possible to "fix" such texture so that it becomes a regular perspective projection?


texts: Baked lightmap: Parts of scene appear too dark

texts:
I'm having trouble setting up global illumination in my Unity 2021.1.1 URP project
Parts of my scene are appearing completely dark, I'm only using directional light and area light on the windows, here's the baked lightmap view:
In the corner as you can see it's completely dark

Here's the Shaded view:
The corner again

Generally the whole scene is pretty dark, it'd like to brighten it up a bit, but the corner is just horrendous.
Those are my lighting settings

Also the Environment settings as per request:


texts: Collision between a player and a solid block C++ SDL2

texts:
I am trying to implement a collision between a player and a solid e.g. a solid box.

bool Collision::Checkcollision(const SDL_Rect &A, const SDL_Rect &B)
{
    return A.y + A.h >= B.y &&
    A.y <= B.y + B.h &&
    A.x <= B.x + B.w &&
    A.x + A.w >= B.x;
}

if (CKeyboard::Get()->GetKey(SDL_SCANCODE_DOWN))
        {
             Vel.y += 1.0f;
        }
        if (CKeyboard::Get()->GetKey(SDL_SCANCODE_RIGHT))
        {
            Vel.x += 1.0f;
        }
        if (CKeyboard::Get()->GetKey(SDL_SCANCODE_UP))
        {
            Vel.y -= 1.0f;
        }
        if (CKeyboard::Get()->GetKey(SDL_SCANCODE_LEFT))
        {
            Vel.x -= 1.0f;
        }
        Position = Position + Vel.GetNormalized();
        SDL_Rect r1 = Sprite->Get_Rect();
        SDL_Rect r2 = Sprite1->Get_Rect();
        if (Collision::Get()->Checkcollision(r1,r2))
        {

            if (Vel.x < 1.f)
            {
                Position.x = Position.x - 1;
                Vel.x = 0;
            }
            if (Vel.x > 0.f)
            {
                Position.x = Position.x + 1;
                Vel.x = 0;
            }
            if (Vel.y < 1.f)
            {
                Position.y = Position.y - 1;
                Vel.y = 0;
            }
            if (Vel.y > 0.f)
            {
                Position.y= Position.y + 1;
                Vel.y = 0;
            }
        }

The problem is I still can move through the box if i keep pressing a key.
So the question is what is the best way to implement collision in SDL?
Thank you in advance


texts: How to automatically test a game's mechanics without duplicating work?

texts:
I've heard and read enough programmers firmly advocating automatic tests. According to many, tests are themselves part of a code's functionality, untested code is broken and/or legacy by definition, long-term manual testing is more time-consuming and provides far weaker guarantees against failures than automatic testing... etc.

I'm trying to hobbystically develop a turn-based Pokemon-like game. While talking to a far more experienced developer I said that when I add a new attack I run my game, go into 1v1 combat, use this move and see if it does what its supposed to do. His answer was: Why won't you instead write a test that goes into a 1v1 combat, uses this move and checks if it does what it's supposed to do? Doing what you're doing manually may be faster than writing tests if you do it once, twice, thrice. But after 10 times? One hundred times?

I'm thinking about what he said. I'm thinking and I still don't feel convinced. About any other kind of project, perhaps. But a game?

Assume I'm adding lifesteal to a monster's attack. Problem is I'll have to anyway boot my game and play it! To see if it feels right, if it plays right, if not for anything else.

Tests on the other hand add maintenance cost: for example, once I (for balancement reasons) change the lifesteal coefficient, I'll have to reflect that change in tests. (Or I won't have to reflect this change in tests if I copy&paste the formula, parametrized by attack strength, lifesteal coefficient, etc, but doesn't this defeat the purpose of testing?)

Automatic tests are supposed to replace manual tests; but given I have to manually play my game anyway, isn't this duplication of work?

Or is my thinking wrong? What am I missing?


texts: The best way to pass data between clients in a room

texts:
I am developing a backgammon game in Unity and tried to use Photon. But I could not find a step by step help for it and I also know that photon in real-time and it syncs data over 10 times per second. but I need to sync data after each moves.

Would you please show me the best way to do that.


texts:
Hello Friends.
This is my demo game screen-shoot. Here i am using three buttons. Right-bottom button is used for jump and left-bottom buttons used for move left and right.

I have some questions
1) should i use linearImpuls for jump body??
2) For move right and left which types of force i applied???

PLease tell me i am confusing to use linearImpuls, applyforce and linearVelocity.

Thanks in advance


texts:
I'm currently trying to add a melee-slash attack to my Sidescroller.

For that I decided to to have an invisible box-colliders infront of my character. My idea is to activate it when the attack-key is pressed and leave it active for the duration of the attack before turning it inactive again.

I know from a previous attempt with a dash instead (didn't work out on the movement for it) that my code for the attack-triggering in the player-script works just fine, so now in my box-collider infront of the player I have:

    public GameObject Player;
//public GameObject Box;
bool attack = false;
//Collider c;

void Awake ()
{
    Player = GameObject.FindGameObjectWithTag ("Player");
    //Box = GameObject.FindGameObjectWithTag ("AttackBox");
    gameObject.collider.enabled = false;
}

void Update ()
{
    Player pstats = Player.GetComponent<Player>();
    attack = pstats.attacking;

    if (!attack)
    {
        gameObject.collider.enabled = false;
    }

    if (attack)
    {
        gameObject.collider.enabled = true;
    }

}

And in my Enemy script I have

    void OnTriggerEnter(Collider collision)
{
    Player pstats = Player.GetComponent<Player>();
    if (collision.gameObject.tag == "Player") {
        collision.gameObject.GetComponent<Player>().PlayerHit();
    }

    if (collision.gameObject.tag == "AttackBox")
    {
        pstats.CurrentEXP += 25;
        EnemyDeath ();
    }

}

Though the hit isn't recognized.

The issue I see is that probably the OnTriggerEnter is the issue since the Enemy tends to be allready inside the attack-box collider when the attack is triggered. I tested a bit with the Debug-Log and the box is activated at least, so it should really be just the issue of calling the Trigger at the right time.

Are there any alternatives to OnTriggerEnter that would be working better?

edit:
I tried adding this right below my collision-part in the enemy-script:

    void OnTriggerStay(Collider collision)
{

    Player pstats = Player.GetComponent<Player> ();
    if (collision.gameObject.tag == "AttackBox")
    {
        pstats.CurrentEXP += 25;
        EnemyDeath ();
    }

}

void OnTriggerExit(Collider collision)
{
    Player pstats = Player.GetComponent<Player> ();
    if (collision.gameObject.tag == "AttackBox")
    {
        pstats.CurrentEXP += 25;
        EnemyDeath ();
    }
}

Though the hit is still not recognized.


texts: Human vs human android chess game design

texts:
First of all I am total amateur in game development and sorry for my poor English.
I want to make android human vs human chess game. So I am wondering how to design it?

scenario 1: User connect to server, find opponent and send moves to server using socket, so match is running on a server side. I think this is not good idea because move should be validated on client side - or do I have to validate moves on client side? I do not think this is good solution because game is seperated.

scenario 2: Using hole punching technique so server is needed only for connection between players, so game is running on android devices.

which approach do you suggest? Or is there any better solution? Which server is best to use?


texts: Resolving this kind of situation in my platformer (movement on slope with roof)

texts:
I'm building a simple 2D character controller based on raycasts. At this moment I'm trying to finish the player-ground interaction. For the ground I will be using edge colliders and no tiling information.

I have most code working but there's something I don't really know how to fix. Here is an screenshot explaining the situation:

As you can see, Player (purple rectangle) is on a slope. When player wants to move right the new x and y coords are calculated to set the player feet again on the slope (Blue rectangle). But, after this response has been applied to the player to make it out of the slope, It is pushed through the roof and some part of it is sticking out the edge collider (red box).

How do you handle this situation?

On the other hand, If there's any way to accomplish this in a simpler fashion I'm all ears :).

Cheers.


texts:
It's the first time I'm trying to implement the Phong lighting model. I'm pretty sure everything is working fine.

I was experimenting using different materials, meaning I played with Kd,Ks,Ka and Ns values when I came across this problem.

Whenever I use a material with alpha value less than one I get this weird result :

At first I thought it has to do with the normals of the model since they are all supposed to point away from the model but it doesn't seem to be the case.

Any ideas?


texts: Navmesh awkward path generation with string pulling due to "inner" vertices

texts:
I've identified a problem and a possible solution related to navmesh-based pathfinding. Before diving in, I'll preface my post with some questions to keep in mind as you read:

Is this a known problem that people have solved before?
Is there a term for the problem that could help me search for information related to it?
Is the solution I came up with an existing idea? If so is there a name for the algorithm or some other search term I could use to find more information?
Is there a better solution? If so, please point me to it.

For reference, I'm using images from http://jceipek.com/Olin-Coding-Tutorials/pathing.html#navigation-meshes and generally following the advice laid out there.

tl;dr of that blog post is

  Decompose your walkable area into a navmesh, treating convex polygons as nodes and their borders as edges so that you can perform an A* search to get from point A to point B. To translate from "node ids" back to real points, use string-pulling.

Here's a copy of the example space:

And an example generated path after performing string pulling:

So far so good.

But I realized this approach generates an awkward path in a situation like this:

In this situation, a trio of nodes are all adjacent to each other, and so the A* will generally choose a path directly from the starting node to the ending node, despite an intuitive understanding that the agent can move in a straight line from A to B which travels through a different polygon.

I've been working on a solution to this problem and so far my best idea is to apply a transformation to the nav mesh. My description of this will be a little hazy as I'm making up terminology to describe the approach...

Define a shared edge as a line segment that is shared by two convex polygons in the navmesh. Maybe a.k.a. a "portal" for string-pulling purposes.
Define an inner vertex as a vertex in the navmesh for which all attached line segments are "shared edges". The vertex in the center of the three polygons in the image above is an inner vertex.
Identify an inner vertex. Follow its attached shared edges to what I'll call neighbor vertex. (possible improvement; If the neighbor vertex is also an inner vertex, recurse to its neighbors until all of the neighbors are non-inner.)
Remove all shared edges from the navmesh that were traversed in the previous step, forming a new polygon whose border is defined by the neighbor vertices in the previous step. Redefine the edges accordingly (I'll hand-wave that)
Repeat until no inner vertices remain.

The result of this on the example above should result in this:

And with the same A-B path from before, the string-pulling should now result in a straight line:

I believe that as long as the navmesh has no inner vertices, all paths generated with the approach described in the linked blog post should seem "natural" and not have any surprise corners in what seems like open space.

Per my questions at the beginning of this post, I'm looking for more information, e.g. has anybody else solved this problem before, is there a better way to do it, and is there even a name/term for this problem?


texts:
What happens, in a behavior tree, when a priority node chooses another branch over a running branch?

Small example:

Priority 1: Fight
    Sequence:
        -Enemy near?
        -Fight!
Priority 2: Move
    Sequence:
        -Is there a hole?
        -Jump!
    Run 5m!

Now in the first iteration there is no enemy, but a hole, so the action Jump! gets executed. It's a rather lengthy animation so it returns running.

For what should happen in the next iteration I found kind of contradictory statements. According to this answer the priority node always begins at the first priority disregarding if another priority is running. In this article however while the examples follow the same scheme, the explanation also mentions that it's possible to lock the tree in the Running state until it's finished.

If the tree is locked in the Running behavior, the character can't react until he walked all the way to his walking target, so this can't be the right interpretation.

If always the first priority gets checked again, the character can react to enemies while he's running (he stops and fights) - that's the desired behavior. If however he's in the air jumping, he can not just stop and fight, he has to land first, so this time I can't choose priority Fight over Move!

How should I handle those cases? Am I even approaching it the right way?


texts: Implementing behavior in a simple adventure game

texts:
I've been entertaining myself lately by programming a simple text-based adventure game, and I'm stuck on what seems like a very simple design issue.

To give a brief overview: the game is broken down into Room objects. Each Room has a list of Entity objects that are in that room. Each Entity has an event state, which is a simple string->boolean map, and an action list, which is a string->function map.

User input takes the form [action] [entity]. The Room uses the entity name to return the appropriate Entity object, which then uses the action name to find the correct function, and executes it.

To generate the room description, each Room object displays its own description string, then appends the description strings of every Entity. The Entity description may change based on its state ("The door is open", "The door is closed", "The door is locked", etc).

Here's the problem: using this method, the number of description and action functions I need to implement quickly gets out of hand. My starting room alone has about 20 functions between 5 entities.

I can combine all actions into a single function and if-else/switch through them, but that's still two functions per entity. I can also create specific Entity sub-classes for common/generic objects like doors and keys, but that only gets me so far.

EDIT 1: As requested, pseudo-code examples of these action functions.

string outsideDungeonBushesSearch(currentRoom, thisEntity, player)
    if thisEntity["is_searched"] then
        return "There was nothing more in the bushes."
    else
        thisEntity["is_searched"] := true
        currentRoom.setEntity("dungeonDoorKey")
        return "You found a key in the bushes."
    end if

string dungeonDoorKeyUse(currentRoom, thisEntity, player)
    if getEntity("outsideDungeonDoor")["is_locked"] then
        getEntity("outsideDungeonDoor")["is_locked"] := false
        return "You unlocked the door."
    else
        return "The door is already unlocked."
    end if

Description functions act in pretty much the same way, checking state and returning the appropriate string.

EDIT 2: Revised my question wording. Assume that there may be a significant number of in-game objects that don't share common behavior (state-based responses to specific actions) with other objects. Is there a way I can define these unique behaviors in a cleaner, more maintainable way than writing a custom function for each entity-specific action?


texts: Find References In Scene of scriptable object unity asset shows incorrect results

texts:
I'm trying to work out why my game is loading a large sprite atlas that I don't think it should be. The snapshot view of the profiler shows that the atlas is loaded. The references pane shows that it's loaded through a scriptable asset object. That object does indeed reference the sprites in the atlas - but I don't think the object is referenced in the scene at the moment. The game boots to this scene, so the atlas should not be loaded.

I've replicated this profiling on both the editor and on android, so it's not an editor-only thing.

When I right-click on the scriptable object in the project view, while the game is running, and Find References In Scene, it shows a few game objects. None of these objects seem to reference the scriptable object. None even have monobehaviours with fields for this type of scriptable object. Some are new-UI button objects, that have Canvas Renderer, Image and Button scripts only. None of which could be referencing this scriptable object.

Has anyone seen this behaviour before? What's going on?


texts:
I am working on a game and I have a mesh that I use to block hallways and prevent the player from going that direction. They are placed vertically with slight angles. I'm having a problem that the player can jump up on these. The player needs to be on the ground all the time otherwise they will be able to avoid dying indefinitely. I have tried moving and rotating and no matter how its placed I can always seem to jump on it. I want to avoid adding more to the scene then what is necessary so I don't want to add another mesh or extra collision of some kind just to keep the player away from those points as that mesh already has collision. Unless it turns out that is actually a good way to handle this.

Is there a way I can prevent the player from jumping on these items? Or is there some other way I can handle if the player does jump up on them. Like maybe start damaging the player after a few seconds until they get down? What is a proper way of handling this?


texts: What are the networking possibilities with XNA and Xbox 360?

texts:
I know that XNA for Xbox 360 has limited access to networking, rumored to only allow communication via a propitiatory Microsoft protocol to other Xbox 360 units.

What are the networking possibilities XNA offers? How many Xbox 360 units can be connected to the same subnet? 16 maximum? Can any Xbox send data to any other Xbox on the subnet like Peer-to-peer communication? Can an Xbox communicate with XNA on Windows PC's as well? Are there any other devices you can communicate with?

And what about game servers? Can you setup your own multiplayer game server and have Xbox's connect to it and communicate freely? What platform would you write the game server code in? C++ on Unix? How many Xbox units can connect to a server at a time? If you cannot setup your own game server are there unofficial 'hacks' that enable indie developers to develop and run a game server?

Since I'm no Xbox developer (ie. I don't own a $10000 devkit) I cannot use C++ libraries like Zoidcom.


texts: I've started to develop a small roguelike game in LibGDX. I've also made a minimap class, which creates and updates the minimap as the player explores the dungeon, by using a Pixmap. The minimap class has an OrthographicCamera (currently unused), which will be used for centering the minimap on the player. The minimap is currently rendered with it's own SpriteBatch. Now I'd like to put the minimap on the upper right corner, and clip it, because it is so big, that it'd obscure the half of the screen. I'm not really sure how to do this clipping part. I assume I should use the ScissorStack class, but the LibGDX wiki is a bit uninformative for me.


texts:
I am new in OpenGL, I am making a game in 2D and I want the camera to follow the character.

I started with gluLookAt() but I read that I could just move the matrix with glTranslatef() and It should do the trick.

The problem is the camera only move the first time It is created but if I increment the X position and Y position It doesn't work. What I m doing wrong? I have incorrect concepts?

I tried it changing to GL_PROJECTION,GL_MODELVIEW, AND GL_TEXTURE,

If I do it on GL_PROJECTION all the items are gone ( thanks to the question answer link I understand that I cant take that way)

If I do it on GL_TEXTURE all the textures start to scroll ( but that is not what i want

If I do it on GL_MODELVIEW just nothing happen all the item are in the same site but if I quit the gl.glMatrixMode(GL10.GL_MODELVIEW) line above translatef It move the camera the first iteration and then stop to do it since the last object is on GL10.GL_MODELVIEW

Is at the start at different matrix state?

My render code:

public void onDrawFrame(GL10 gl)
{
    loopStart = System.currentTimeMillis();
    try
    {
        if (loopRunTime < SEngine.GAME_THREAD_FPS_SLEEP)
        {
            Thread.sleep(SEngine.GAME_THREAD_FPS_SLEEP - loopRunTime);
        }
    } catch (InterruptedException e)
    {
    }
    deltaTime = (float) ((System.currentTimeMillis() - aRestar)/1000f);

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glClearColor((78.0f / 255.0f), (192.0f / 255.0f), (203.0f / 255.0f), 0.0f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glTranslatef(x, y, 0f);

    perro.draw(gl);
    palmera.draw(gl);

    comprobacionesColision();
    actualizar(deltaTime);

    x +=0.05f;
    y +=0.05f;

    loopEnd = System.currentTimeMillis();
    loopRunTime = ((loopEnd - loopStart));

}


texts: Why would running WebGL app in Edge improve performance in Firefox?

texts:
I have a WebGL app (built using Unity 2019) which I'm testing locally in Firefox and Edge. If the app is only running in a tab in Firefox, it runs at 25 - 50 fps and has noticeable stutter. If I run the app in Firefox and Edge at the same time (each browser on its own monitor), the performance in Firefox significantly improves - it jumps up to 50 - 60 fps and stutter is eliminated.

Frankly, the results sound ridiculous even to me, but I've tested it over and over and it's 100% consistent. Opening the app in a tab in Edge immediately improves performance in Firefox. Closing the tab in Edge immediately reduces performance in Firefox.

I'm on Windows 10 with a GTX 2070 Super.


texts: Am I doing this node.js game loop wrong?

texts:
I have 2 arrays of JSON objects, actions and game objects.

At any time a user can make a request from the client which can add an action to the actions array.

I have a setInterval(function(){ }, 1000); that runs every second and first loops through all of the actions, doing them in order then dumping emptying the array. Then it for loops (on the length of the array) through all the objects and does change processing such as healing, repairing, consuming resources, updating location of travelling objects, etc.

Each game object is tied to a user and when it is done being modified it will push out to them using socket.io all the data they need for their current view (assuming they are in an active session still).

Is this right? Am I not taking advantage of the node.js event loop as well as I could for this?


texts: Godot Procedural map, Need help to avoid overlapping areas

texts:
I have piece of code that using a tile set, i can draw an area of what is going to be a small town/city.
The code seed_cities, make an X number of cities randomly on the map, whereas draw_city just paints the city over the screen.
My problem is that from time to time, 2 or more citites overlap in the map.
func seed_cities(num_cities):
    var initial_point
    var final_point
    for i in range(0, num_cities):
        initial_point = Vector2(int (rand_range(0, screen_size.x/10)), int (rand_range(0, screen_size.y/10)) )
        range_x = randi() % 10 + 5  # 5 being minium longitude
        range_y = randi() % 10 + 5  # 5 being minium longitude
        final_point = Vector2(range_x, range_y)
        var city_position = {
                initial_point: initial_point,
                final_point: final_point
        }
        cities.append(city_position)
        # TODO check if there is another city before
        draw_city(final_point,final_point)

now, i tried to use the function line_intersects_line_2d , but the appears an error saying that line_intersects_line_2d is not declared on the current class, so i have another method of checking if the cities overlap. i was thinking of using that or creating an area2D with code to check if there is a collision.
func draw_city(initial_point, final_point):
    for x in range(0,final_point.x):
         $Objects.set_cell(initial_point.x + x , initial_point.y,4)
         $Objects.set_cell(initial_point.x + x, initial_point.y + final_point.y,4)
    for y in range(0,final_point.y+1):
         $Objects.set_cell(initial_point.x, initial_point.y + y,4)
         $Objects.set_cell(initial_point.x + final_point.x, initial_point.y +y,4)

Any ideas on what i need to import to use line_intersects_line_2d?
What other way i can check if 2 cities overlap before saving it's position and draw them on the map?


texts: How can I start a new row when instantiating UI elements in a grid?

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

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

    private Transform slots;
    private string[] imagesToLoad;

    // Start is called before the first frame update
    void Start()
    {
        int counter = 0;

        imagesToLoad = Directory.GetFiles(Application.dataPath + "/screenshots", "*.png");
        //slots = GameObject.Find("Slots").transform;
        slots = GameObject.FindGameObjectWithTag("Slots Content").transform;

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

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

            if (counter == 3)
            {
                raw.anchoredPosition = new Vector3(1 , 0.3f, 0);
                counter = 0;
            }
            else
            {
                raw.anchoredPosition = new Vector3(1 + counter * gap, 6, 0);
            }

            counter++;
        }
    }

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

    }
}

Now it's creating a line of 3 objects but then when it's filled with 3 objects in a line I want it to move one step down and start a new line of 3 and so on.
The problem is I can't make it automatic move one step down with the right gap on the Y and start a new line.
I'm doing the new line with this :
raw.anchoredPosition = new Vector3(1 , 0.3f, 0);

but the result is that the fourth object is too much down :

And it should be like this :


texts: Coroutine wrong Behavior when scene is loaded.

texts:
Ok so I have this coroutine :

 IEnumerator ShowCharTraits()
    {

        while(!hasPlayerChosen)
        {
            yield return null;
            traitPanel.SetActive(true);
        }
        hasPlayerChosen = false;
        traitPanel.SetActive(false);
    //    Debug.Log("Got called! job done");

    }

It's being called like this from the awake method in my GameManager:

players = GameObject.FindGameObjectsWithTag("Player");
                foreach (GameObject g in players)
                {
                    ui_Controller.StartShowCharTraits();
                    g.GetComponent<PlayerToken>().isTurn = false;
                }

StartShowCharTraits() is a simple method that does this :

  public void StartShowCharTraits()
    {
        StartCoroutine("ShowCharTraits");
    }

Now, I have checked the tags, no null reference exception, actually no errors or warnings are being thrown. If i load the scene in the editor and then play it everything works fine. traitPanel.SetActive(true); get called and my panel shows up. However when I load my scene from another scene using   SceneManager.LoadScene(1); the above mentioned line is never reached. Any ideas why this is happening ?


texts: How can I make Enemy follow the player in unity

texts:
I have a 2d platform game where I want the enemy to follow the player for some time
Currently the enemy constantly follows the player -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

 public class Enemy : MonoBehaviour {

    public float speed = 0.5f;
    public Transform Player;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        Vector3 displacement = Player.position -transform.position;
        displacement = displacement.normalized;
        if (Vector2.Distance (Player.position, transform.position) > 1.0f) {
            transform.position += (displacement * speed * Time.deltaTime);

        }

    }

 }

How can I make the enemy only follow in certain areas or for x seconds long?


texts: How do I install the Unity Editor on Linux?

texts:
I have installed Unity trough the Hub but still need the editor. I cannot for the life of me figure out how to do that? I'm running a Ubuntu based Linux system. I already have MonoDevelop installed I just need the darn editor.
I then get greeted with the following popup but nowhere does it give me the chance to install the editor.


texts: Calculating Hit Accuracy score in a game

texts:
I'm currently in the process of making a scoreboard for my game. One of things I would like to display is the players accuracy in the amount of hits they had in game. However, I have never done this before and I've no idea how to go about doing this.

Is there a commonly used algorithm out there that can help me calculate this, or has someone found a way to calculate this fairly easily?

Any help with this would be appreciated.


texts: (LIBGDX) args instead of variables names

texts:
I added Kryonet to my libgdx project like this...

Created a "libs" folder in core project, droped kryonet.jar in there.
In build.gradle of the root project added this line:

project(":core") {
   ...
   dependencies {
    ...
    compile fileTree(dir: 'libs', include: '*.jar')
   }
}

But I keep seeing "arg" instead of the variable names

When I try to see the class this is what it shows:

No button to attach source is being displayed..
Any Ideas?


texts: Removing FMOD from a Unity WebGL project causes an error about not being able to copy fmod_register_static_plugins.cpp

texts:
When I imported the FMOD plugin into a Unity WebGL project, then removed it afterwards, I wasn't able to build it due to errors about trying to copy an FMOD file: fmod_register_static_plugins.cpp
Restarting the editor, reimporting everything, deleting Library/Temp folders did not help. Neither did deleting the FMod folder.


texts: Build a convex hull from a given mesh in Bullet

texts:
According to this tutorial, a convex hull is the most accurate shape one can build from a mesh? I have two questions regarding this:

How do I build a convex hull from a given, complex mesh in Bullet?
Should this be done offline? How do most people do this? (that is, create a collision shape from a mesh in games)


texts:
I'm pretty new in developing videogames. By now I only used SDL with C/C++ to create games. I'm currently learning OpenGL and I realized that to be fluid and easy to maintain the code must be logically separated. Since I want to use OpenGLES on iOS and Android I was wondering how the engine must be imagined in a technical way, some questions came up:

Do I have to separate input/update functions from draw functions in different threads?
Is there only one proper way to think a game engine/loop?
What kind of assets should I use to create a 3D game using openGl ES to get better performance?

EDIT: I figured that I had more questions lacking of answers reading the links DMGregory refered me to. I'll keep reading it till I fully understand it and than ask for the good questions. Thanks a lot.


texts: Effective way to check if an Entity/Player enters a region/trigger

texts:
I was wondering how multiplayer games detect if you enter a special region. Let's assume there is a huge map that is so big that simply checking it would become a huge performance issue.

I've seen bukkit (a modding API for Minecraft servers) firing an Event on every single move. I don't think that larger games do the same because even if you have only a few coordinates you are interested in, you have to loop through a few trigger zone to see if the player is inside your region - for every player. This seems like an extremely CPU-intense operation to me even though I've never developed something like that.

Is there a special algorithm that is used by larger games to accomplish this? The only thing I could imagine is to split up the world into multiple parts and to register the event not on the movement itself but on all the parts that are covered by your area and only check for areas that are registered in the current part.

And another thing I would like to know: How could you detect when someone must have entered a trigger but you never saw him directly in it since his client only sent you an move packet shortly before entering and after leaving the trigger area. Drawing a line and calculate all colliding parts seems rather CPU intensive if you have to perform it every time.


texts: Explain the difference between extrapolation and interpolation

texts:
http://www.unagames.com/blog/daniele/2010/06/fixed-time-step-implementation-box2d here there are two algorithms of smoothing in case of fixed time step physics simulation. I don't understand the formula of interpolation:

state = currentState * alpha + previousState * (1-alpha)

And also I don't understand the comparison figure. Please explaing what is the meaning of multiplying current state with alpha and summing with previous state with 1 - alpha.


texts:
Overview

My game is currently based on a single activity (rather than multiple activities) and I would like to keep it that way.

At the moment, it goes straight into the game at level 1. I will shortly be adding an options menu and another 20 or so levels. (As well as a high-score screen, help screen etc).

The thing I'm not sure about is, how do I tell the app/renderer what screen/part of the game to render?

It's an openGL ES 2.0 app so at the moment, the method I have in my mind is something like this:

Code Snippets

int level = 0;  //0 means menu, 1 means level 1 etc

in onDrawFrame(); have something like this:

@Override
public void onDrawFrame(GL10 gl) {

switch (level){

case 0:renderMenu();break;
case 1:renderLevel1();break
case 2............

And so on.

I would also do the same with the logic updating.

Is this the way to go? I'm just not sure it's very efficient but I can't really see what the alternatives are - another way I was looking into was having a separate GLRenderer for each 'screen / level' but this seems much more over-kill.

Would appreciate some guidance as to how to display the correct screen / level at the right time.

Edit This is the current structure of my code:

Activity class

public class MainActivity extends Activity {

//Various pieces of code here

    class MyGLSurfaceView extends GLSurfaceView {

    //Various pieces of code here

    @Override
    public boolean onTouchEvent(MotionEvent event) {

    //Touch events handles here

}

GL Renderer class

onDrawFrame(){

    render();
    update();
}


texts: How do I fix this "java.lang.ClassNotFoundException" error?

texts:
I received my first crash report via the Google Developer Console, yesterday, and I'm completely lost.

This is my error message:

  java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.UnityPlayerNativeActivity" on path: DexPathList[[zip file "/mnt/asec/com.JamaludineDolley.NinjaBallDash-1/pkg.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib]]

How do I fix this java.lang.ClassNotFoundException error?


texts: Is glxinfo saying that the 980 GTX doesn't support a 32 bit depth buffer?

texts:
I've been using the glxinfo command (glxinfo -v) to explore the supported framebuffer configurations. There are two values relating to depth, "depth" and "depthsize." According the source, it appears that the "depth" value relates to the X config and the "depthsize" value relates to the OpenGL config.

Assuming that is correct, would the lack of a "depthsize=32" entry suggest that 32 bit depth buffers aren't supported? Or is my understanding of the glxinfo output flawed?


texts:
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;

public class SpriteSheet {
    private String path;
    public final int SIZE;
    public int[] pixels;

public static SpriteSheet tiles = new SpriteSheet("/texture/spritesheet.png", 256);

public SpriteSheet(String path, int size) {
    this.path = path;
    this.SIZE = size;
    pixels = new int[SIZE * SIZE];
    load();
}

private void load() {
    try {
        BufferedImage image = ImageIO.read(SpriteSheet.class.getResource(path));
        int w = image.getWidth();
        int h = image.getHeight();
        image.getRGB(0, 0, w, h, pixels, 0, w);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}

So I'm trying to load a SpriteSheet either using slick2d or lwjgl. Was wondering is this faster, than the method above. Also, how do you actually do a spritesheet class for lwjgl.

I'm just confused how you use Sprites in Slick2d. It looks like I need to create an image class and then have SpriteSheet class extend the image class.

http://slick.cokeandcode.com/javadoc/org/newdawn/slick/Image.html


texts: 3D models on 2D tilemap perspective when scrolling

texts:
I am creating a small top-down game, where the player traverses a 2D tilemap, with an illusion of depth provided by 3D models for things like buildings or trees.

Having gotten to the point where I can render models and a basic terrain as a background, I've gotten stuck on the task of joining both together in a way as to seem not too unnatural.

I think an image description of my problem would be best suited for this. For the sake of explanation, the model I am rendering is a transparent cube.

In this position, where the camera has a head-on view, everything looks generally normal. Now, if I shift the model a bit to the right, the following gets displayed:

Not horrible by any means, but it does look a tad bit awkward: the road remains straight while the building seems to be jutting out from the path. The building itself has been panned, but the ground has remained static. Additionally, this has proven rather nausea-inducing during testing, due to the awkward mixing of angles.

The only possible solution that came to me (and hence why I am asking here) would be to render each tile as a model as well. I think that creating a flat rectangle the size of the viewable screen and texturing it with the visible tiles could possible work: that way, since it is a model, it can be rotated and shrunk based on visibility, like the model.

However, I am (very) new to OpenGL, and I fail to see how I could implement this. I know that I can draw a textured rectangle with one, solid texture. I don't know how to draw multiple, smaller textures across a face of the rectangle: is it even possible?

Then, considering that I wish to have other things like cliffs, I wondered if cliff tiles could be rendered as being slanted. My map format has a height map, so the slant could be determined by the direction in which the nearest tile with a smaller height resides.

I fear I'm being rather clumsy at explaining this, which is why, using my most Picasso-esque skills I have put together the next image:

Essentially, though the map itself is made up of 2D tiles, by changing the angle they are being rendered at I reckon it would be possible to simulate a 3D effect: the player camera (smiley in the image) would not be able to see the leftmost side (yellow) if they are positioned towards the right.

Regardless, this is all hypothetical and I have no idea where to even begin. Is it possible to render the background as essentially a model in 3D space? If so, how would this be done: via one large cuboid, or multiple smaller ones? Lastly, would slanting textures based on neighbor height work? More importantly, is there a better way to achieve my goals than what I have proposed?

For all it matters, I am writing this game in Java, utilizing the LWJGL OpenGL wrapper.


texts: How to loop over a part of an ogg vorbis stream?

texts:
I'm successfully streaming ogg vorbis data to openAL with the Java library JOrbis, but now I want to loop over a part of this stream, e.g from 30" to 1'30".

I thought that at the end of the loop, I could redecode from the beginning of the file, skip the unwanted part, and then keep streaming until the end of the loop, and restart again. But I'm not really convinced by this method, as for example, if I want to loop over 4' and 4'30", I'll need to decode each loop 4 minutes of ogg data for nothing.

Another way would be to put all the loop in memory, but it won't be streaming anymore and I want to avoid this.

So is there a way to reach a point in an ogg vorbis stream without decoding the previous data every time ? Does ogg contains a kind of index that can be used, or is it possible to make one by decoding the whole file once before ?

Thanks

(ps: I could't give this question the right tags as I haven't yet 150 rep)


texts: Show Unity Line Renderer as 3d cable or wire

texts:
I am dynamically making a line renderer which is pull by the character to show that a character is pulling a wire. The line renderer working fine but unfortunately its display is not according to my expectation. Like it showing as 2D.

Is there any way available to make it more realistic wire/cable? Maybe any shader will help ?


texts: In XNA, should I use the built-in game component classes?

texts:
I'm just getting started on an XNA game for Window Phone 7. For my Flash games I have my own framework that I was just going to port from AS3, but I have just found the built-in game component stuff in XNA. So should I use this stuff? Should my Entity class extend game component/drawable game component? I'm sure it will be quicker just to port my AS3 code, but I thought this built-in stuff may have some advantages?

UPDATE: I decided not to use them. It doesn't seem that they are meant to be used in the way I described.


texts:
I'm making a simple 2D game for Android using the Unity3D game engine. I created all the levels and everything but I'm stuck at making the game over/retry menu. So far I've been using new scenes as a game over menu. I used this simple script:

#pragma strict

var level = Application.LoadLevel;

function OnCollisionEnter(Collision : Collision)
{
    if(Collision.collider.tag == "Player")
    {
        Application.LoadLevel("GameOver");
    }
}

And this as a 'menu':

#pragma strict

var myGUISkin : GUISkin;

var btnTexture : Texture;

function OnGUI() {
GUI.skin = myGUISkin;

if (GUI.Button(Rect(Screen.width/2-60,Screen.height/2+30,100,40),"Retry"))
    Application.LoadLevel("Easy1");

if (GUI.Button(Rect(Screen.width/2-90,Screen.height/2+100,170,40),"Main Menu"))
    Application.LoadLevel("MainMenu");
}

The problem stands at the part where I have to create over 200 game over scenes, obstacles (the objects that kill the player) and recreate the same script over 200 times for each level. Is there any other way to make this faster and less painful?


texts: Parameter "MoveX" (and "MoveY") does not exist

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

public class PlayerMovement : MonoBehaviour {

    public float moveSpeed;

    public Animator anim;

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

// Update is called once per frame
void Update () {
    if (Input.GetAxisRaw ("Horizontal") > 0.5f ||
        Input.GetAxisRaw("Horizontal") < - 0.5f) {
            transform.Translate (new Vector3
        (Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
        }

        if (Input.GetAxisRaw ("Vertical") > 0.5f || Input.GetAxisRaw ("Vertical") < -0.5f) {
            transform.Translate (new Vector3 (0f, Input.GetAxisRaw ("Vertical") * moveSpeed * Time.deltaTime, 0f));
        }

        anim.SetFloat("MoxeX", Input.GetAxisRaw ("Horizontal"));
        anim.SetFloat("MoxeY", Input.GetAxisRaw ("Vertical"));

        }
    }

I an trying to run this with a basic 2D animation in unity personal and I keep getting Warning! -
Parameter "MoveX" does not exist
and Parameter "MoveY" does not exist
but it is clearly in the animator as a float.


texts:
I'm trying to set up a delay so that the UI element I'm using to darken and obscure the player's buttons doesn't disappear the second the enemy begins their turn.

Any help would be very appreciated, as I'm super-new and probably making a bit of a hash of things.

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

public class TurnController : MonoBehaviour {

static bool playerTurn;
public static GameObject ControlBlocker;

// Use this for initialization
void Start () {
    playerTurn = true;
    ControlBlocker = GameObject.Find("Control Blocker");
    UIController();
}

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

}

public static void TurnChange()
{
    if (playerTurn == true)
    {
        playerTurn = false;
        UIController();
    }
    else if(playerTurn == false)
    {
        playerTurn = true;
        UIController();
    }
}

public static void UIController()
{
    if (playerTurn == true)
    {
        print("PlayerTurn");
        //Delay here/////////////////////////////////////////
        ControlBlocker.SetActive(false);
    }
    else if (playerTurn == false)
    {
        print("EnemyTurn");
        ControlBlocker.SetActive(true);
    }
}

EDIT

So after some Google-fu I've made some changes that allow the code to compile with what looks like a working co-routine;

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

public class TurnController : MonoBehaviour {

public static TurnController instance;
static bool playerTurn = true;
public static GameObject ControlBlocker;

private void Awake()
{
    instance = this;
}

// Use this for initialization
void Start () {
    ControlBlocker = GameObject.Find("Control Blocker");
    ControlBlocker.SetActive(false);
}

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

}

public static void TurnChange()
{
    if (playerTurn == true)
    {
        playerTurn = false;
        print("TCnowFalse");
        instance.StartCoroutine(UIController());
    }
    else if(playerTurn == false)
    {
        playerTurn = true;
        print("TCnowTrue");
        UIController();
    }
}

public static IEnumerator UIController()
{
    if (playerTurn == true)
    {
        print("PlayerTurn");
        //Delay here
        yield return new WaitForSeconds(2);
        ControlBlocker.SetActive(false);
    }
    else if (playerTurn == false)
    {
        print("EnemyTurn");
        ControlBlocker.SetActive(true);
    }
}

BUT - Even with this the functionality still isn't working.

The playerTurn == true section of UIController never fires. PlayerTurn never prints to console and the ControlBlocker stays in place.

playerTurn == false works fine however, and TurnChange is working fine too as it prints both messages to the console when appropriate.

Stuck again!


texts: How can I handle two collisions in the same frame?

texts:
My problem is that I have a player with collisions, and enemy can collide with players collision and execute Hurt function in players script. But the problem is enemies can overlap and can hit the player in the literally same frame. So they both execute Hurt function.

In my Hurt function I change players collision layer for a 2 seconds, and he is no longer be able to seen by enemies. But it doesnt matter because of the same hit by two or more enemies in the same frame.

How can I solve this? I tried bool to check if Hurt function is executed but it doesnt work too...

Here is :

Code on Enemy:

 IEnumerator OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.CompareTag("Player"))
    {
        //burası kediler üst üste bindiginde birden fazla kez calisabiliyor
        charMovementRef.StartCoroutine(charMovementRef.Hurt());

        Debug.Log("hasar yedi");
    }
}

Code on Player:

//Hurt should only works one at the same time
public IEnumerator Hurt()
{
    //layer değiştirerek düşman collisionlarından kaç
    gameObject.layer = 9;
    //canı azalt
    health--;
    HeartUI(); //show the new health on UI
    //karakter görüntüsü yanıp sönsün
    gameObject.GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f);
    //playerı zıplat
    rb2D.velocity = new Vector2(rb2D.velocity.x, 0);
    rb2D.AddForce(new Vector2(0, jumpPower / 1.2f));

    //2 saniyeliğine colliderları kapalı kalsın, sonra eski haline çevir
    yield return new WaitForSeconds(2);
    gameObject.layer = 0;
    gameObject.GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);

}


texts: D3D/OpenGL: Question about shaders in larger projects

texts:
I'm a game dev student and last semester we had a '3D-programming' course, in which we did some basic stuff such as rendering a textured quad spinning around in the "scene". We used quite basic vertex-, geometry-, and fragment-shaders to do this.

My question is, how are shaders "managed" in a larger projects?
For example, I might have a sphere in the scene that uses a shader to generate some effect on it, some VS or FS to generate water ripples or waves on a water 'model', etc.
How would all these different shaders be combined in the same project? Do we just create new shader programs for the different shaders(as you can do in OpenGL)? Do you use some kind of condition-statement in the shader and use only one program? Some other approach?
I've heard you really want to minimize API-calls, especially for realtime apps (Multiple shader programs would need at least 2 calls to set the shader programs, EVERY frame.)
I'm really confused about this part, and our next course involves making a small game so this will be quite important I'd imagine. (also im personally very paranoid when it comes to performance; I want to do things right from the start when possible)

Sorry if the question is poorly formulated, hope it makes some sense. ^^'

An example would be great, HLSL/D3D or GLSL/OpenGL doesnt matter, I've fiddled with both.


texts:
I have noticed lately on the App Store many games have been updated to require a minimum of iOS 4.3 to run thus eliminating support for 2nd gen devices (iPod Touch 2nd gen and iPhone 3G).

It is now 2013, my question is what should be the minimum target iOS version and device platform for games development. If it is 4.3+ why not support older devices?


texts: ios screen design -> how to target multiple devices

texts:
I am writing an IOS Game, landscape only and I am having a conceptual issue with my artwork. The screens are all different sizes. Retina, non-retina as well.

Non Retina ipads + ipad mini is 1024 x 768.

Retina ipads are 2048 x 1536.

So how big do I draw my art? What concept am I messing up? Any screen templates I can download to help me. i.e, learn the boundaries, etc?


texts: Libgdx problem while converting TextureRegion to Pixmap

texts:
I'm developping a Tile base game where I have to generate transition tiles. To do so, I have a method that generate those tiles from 2 existing one and 1 "filter tile". I use this method to make a pixMap from the region I retrieved from my TextureAtlas.

public Pixmap getPixMapFromRegion(TextureRegion region){

    Texture texture = region.getTexture();
    TextureData data = texture.getTextureData();
    if (!data.isPrepared()) {
        data.prepare();
    }
    Pixmap pixmap = data.consumePixmap();
    int width = region.getRegionWidth();
    int height = region.getRegionHeight();
    Pixmap px = new Pixmap(width, height, Format.RGBA4444);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int colorInt = pixmap.getPixel(region.getRegionX() + x, region.getRegionY() + y);

        }
    }
    return px;
}

Them I apply this method

public Pixmap generateMixedTile(TiledMapTileSet tileset, AssetManager assMan,String template, TextureRegion region1, TextureRegion region2) {
    TextureAtlas atlas = assMan.get("../core/assets/tuiles/MergeFilter.atlas")
    AtlasRegion region = atlas.findRegion(template);
    Pixmap templ = getPixMapFromRegion(region);
    Pixmap img1 = getPixMapFromRegion(region1);
    Pixmap img2 = getPixMapFromRegion(region2);
    Pixmap res = newPixmap(region.getRegionWidth(),region.getRegionHeight(),Format.RGBA4444);

    for (int y = 0; y < templ.getHeight(); y++) {
        for (int x = 0; x < templ.getWidth(); x++) {
            if(0xFF000000 == templ.getPixel(x, y))
                res.drawPixel(x, y, img1.getPixel(x, y));
            else
                res.drawPixel(x, y, img2.getPixel(x, y));
        }
    }
    return res;
}

It seems that after asking again and again for the same texture in the AssetManager, I get a Couldn't load file ../core/assets/tuiles/Water3.png  Exception. But this happen after the system success a lot of time to access that same file.

So I don't know how I could handle that because I thought that using assetManager and Atlas was the bests practices

Any Idea of how to fix that or to do it in another way?


texts: 2D animation is not rendered as it supposed to

texts:
I'm working with Melonjs, i have configured everything to update the character movement and still get this "delayed" rendering of the character.

below is the constructor

  // call the constructor
  settings.image='kit.walk';
  settings.spritewidth=56;
  settings.spriteheight=80;

  this.parent(x, y, settings);
  this.alwaysUpdate=true;
  // set the default horizontal & vertical speed (accel vector)
  this.setVelocity(3, 15);
  this.setFriction(0.4,0);
  // set the display to follow our position on both axis
  me.game.viewport.follow(this, me.game.viewport.AXIS.HORIZONTAL);
  this.renderable.addAnimation('walk',[0,1,2])
  this.renderable.setCurrentAnimation('walk');
  this.anchorPoint.set(0.5,1.0);

i'm not very familiar with the engine, but it doesn't seem to be a problem with the engine, i think is a configuration problem somewhere.. i tried to look into examples but nothing helped so far.

could it be a problem with the sprite?


texts:
I'm working on adding billboarded sprites to a game engine, but the engine allows for walking on curved terrain, like spheres. In order to look like the player is walking on the terrain, I want to start with the billboard, then rotate it around its origin (bottom centre) so that its up vector matches the screenspace normal of the terrain.

Here's a diagram of the general idea:

The billboarding works fine - passed the camera's rotation matrix to the sprite, and the poly quad's 0,0,0 is at the bottom centre of the canvas.

How can I get the angle between the normal and screenspace up?

I think it's a matter of projecting the normal with the MVP matrix, to get it as a 2D screenspace vector to calculate the angle from. But I'm not having much luck attempting to implement it.

The sprites take their positioning from the centre of the tiles, along with the normal. I'd also like to move the sprites down in the rotated axis, so that they cover the tile they're standing on.

Any other methods are welcome too.


texts:
After searching "flip card" in google and our stackexchange site, there is no result and I have no ideas about how to flip a card by a corner.
I am developing a ios card game with cocos2d, in this game, i just want to touch the right-bottom corner of back face, and hold on moving towards left-up direction. With moving a little distance, the card can flip to front face.
Any ideas?


texts: Creating animation by script with animation assets

texts:
I'm very new to Unity (not to C# and programming as well) but I managed to achieve some goals very fast. But some concepts I still don't get in their full aspects.

I'm developing a small multiplayer game called skeet. It's about clay pigeon shooting. I have a static 2D scene, with 3 assets: A gun, a bullet and a pigeon. These sprites I'm able to deploy on the scene by an event driven script and I'm able to react on collisions between objects.

I reached the point I have to animate the pigeon and the bullets. First I have to animate the pigeon moving from border to border in a random direction on a random height. Second if a player presses its key to shoot its bullet must be animated from the bottom of the screen straight upwards.

My current idea is to create some animations as assets and to assign them to the sprites I'm creating dynamically. But I don't know what I need in the Unity GUI and in the script.

I'm not looking for a ready to run solution but an ordered list of concepts and advices I have to take a look into.

Edit:

The bullets and pigeons are created dynamically and should be destroyed after the animation finished (by reaching any border of the screen or a collision). So I need to create an animation with assignable position parameters.


texts: What's the best way to store tiles' infos in a 2D table?

texts:
I need to know what's the less time / memory consuming way to store the infos about each tile in a 2D table. The first thing that came to my mind was creating a table holding the infos, and then storing in each tile the string or the number used to access these infos, like:

tilesTable = {
    ["sand"] = {
        walkable = true,
        image = "sand.png",
        --stuff
    },
    ["sea"] = {
        walkable = false,
        image = "sea.png" --...and so on
    }
}

map = {{"sea", "sand", "sand"},
       {"sea", "sea", "sand"},
       {"sea", "sea", "sea"}}

And then accessing their informations like

print(tilesTable[map[x][y]].image)

And the same would be with number indexes.

But then I tought that when trying to access the infos for each tile, I am first accessing the _G table, then the map table, then the map[x] table, then using the result to access again the _G table and the tilesTable, so I tought to store in each position the reference to a global / local table, like

--[[local]] sand = {walkable = true, image = "sand.png"}
--[[local]] sea = {walkable = false, image = "sea.png"}

map = {{sea, sand, sand},
       {sea, sea, sand},
       {sea, sea, sea}}

So that then I just have to call

print(map[x][y].image)

Which i suspect being faster, especially if the table is stored as a local variable.

What should I do? Again, what is the way that is faster and consumes less memory?


texts: Particle Effects move awkwardly as the camera approaches them

texts:
Particle effects seem to move rather awkwardly when partly out of camera bounds. When scaling up particle effects to the point where they fill most of the screen they don't appear static anymore.

Video of the effect

I'm using particles to simulate clouds. Is there a way to fix this without scaling down the individual clouds?


texts: How do I restart an animation that is already playing using SetTrigger?

texts:
I have set up a relatively simple example scene with one enemy.

This enemy is controlled with an animation controller.
In this animation controller, I have set up a trigger named "Hit".

The enemy plays an idle animation, and when my hero character shoots him, I set the trigger "Hit" via script like this:

_animator.SetTrigger("Hit");

This causes the animation controller to react to it, and it transitions from "Idle Animation" to "Hit Animation":

The hit animation is 3 seconds long. After it has completed, the animation controller will automatically transition back to the "Idle Animation".

I would like make it so that the hero character can shoot the enemy even though he is already playing the hit animation. Let's imagine you use a machine gun to shoot him repeatedly quickly.

However, when I call

_animator.SetTrigger("Hit");

while the hit animation is already being played, nothing happens.

As I currently understand it, this makes perfect sense as the Trigger triggers the transition from animation A to animation B, and if we're already at animation B, then there can be no transition.

The transition will only kick in if the animation controller is currently playing the "Idle Animation" as it can then transition to the "Hit animation"

What could I do to "restart" the hit animation?

Thank you.


texts:
I am an indie game developer and I am doing a game similar to guitar hero. I am using tracks composed by musicians and I contacted them to sing a licensing contract. As is my first indie project I have no idea on how I should deal with the royalties aspect of this because each track as an ISRC code and each time a track is played in public there is a fee to pay to the "local" registration authority.

An iPhone game it is downloaded and not played on air (or physically distributed), and hence I think there is a specific legislation for this that specifies how much one should pay. I own some of the tracks composed and for this I think I won't have to pay a royalty (even if the track has an ISRC code) but for other tracks I just have a license "to use".

I wonder how a game like Guitar hero can sell on iPhone for as little as 0,99$ and then have "in app purchases" for packs of 3 songs (for about 2 dollars) and make a profit (I imagine they will have to pay a ISRC royalty).

Does anyone of you have any idea of this can work or if there is a section in this forum where I can ask this question? I understand is not about coding but I think is about development of a game in the broader sense.


texts: Right way to dispose of a WWW IEnumerator after it has completed - Unity

texts: What is the "right" way to dispose of an Ienumerator coroutine after it has completed?


texts: GPU instancing vs combining meshes for performance

texts:
I have a relatively low poly procedurally generated scene in which I reuse a bunch of the same objects (walls, floors, etc). I've been writing some code to combine a room's floor tiles into one mesh, its wall tiles into another mesh, etc. However I came across this tutorial (http://www.habrador.com/tutorials/unity-mesh-combining-tutorial/) in which the author says that GPU instancing is essentially the same as mesh combining, but in fewer lines of code. Is this accurate? I tried GPU instancing and got a massive reduction on the GPU, but the CPU still spends a lot of time drawing. Will mesh combining provide more balanced performance for the CPU? I haven't finished my implementation yet and don't want to bother if it's effectively the same.

Thanks for the help!


texts: PlaySoundAtLocation plays sound after some delay

texts:
I’m developing the Pong game to learn Unreal Engine 4.26 using C++.
I use this code in the class’ constructor to load the sound:
static ConstructorHelpers::FObjectFinder<USoundWave> HitSoundAsset(TEXT("/Game/Effects/pong-paddle.pong-paddle"));
    if (HitSoundAsset.Succeeded())
        HitSound = HitSoundAsset.Object;

And in OnHit event this code:
void APaddle::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
    if ((OtherActor != nullptr) && (OtherActor != this) && (OtherComp != nullptr))
    {
        if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Paddle has been hit by: %s"), *OtherActor->GetName()));

        if (ABall* Ball = Cast<ABall>(OtherActor))
        {
            PlayHitSound();
        }
    }
}

And finally:
void APaddle::PlayHitSound()
{
    if (HitSound != nullptr)
    {
        UGameplayStatics::PlaySoundAtLocation(this, HitSound, GetActorLocation());
    }
}

But it sounds after the ball has bounced.
The sound starts at 0 and it hasn’t any silent.

Is there any way to play it immediately?


texts: Why would I support multiple rendering engines simultaneously?

texts:
I've seen some games from the early 2000s that had a launcher where you could select the rendering engine you wanted to use: DirectX or OpenGL.

Maybe I haven't looked hard enough, but I haven't seen anything like this lately so I have two questions:

Why did they do this before?
Why aren't they still doing it?


texts: Physics-based rotation with an array of pixels

texts: Say I have a simple system, that has a large array of pixels with their own weight, velocity, coordinates etc. (by using classes) if each of those pixels can be connected to 4 other pixels (top, bottom, left, right) how could I let that object rotate, according to physics. An example of this is where I might have an array of pixels that makes a circle, and a slope, if I put the circle at the top of the slope, how would I compute the circle rotating while going down the slope?


texts: Informing objects within a particular state of the world state

texts:
Following the State pattern, every state in my game is a derived object that reflects a particular segment of the game (MenuState, PlayingState, GameOverState, etc.)

Each of those state objects holds a container of objects pertinent to that world state (eg. menuButtonOBject for MenuState, playerObject/enemyObject for PlayingState, etc.)

For each frame, every object from that particular state makes a call to its update() method:

#include "GameState.h"
#include "GameObject.h"

class MenuState : public GameState {

    public:

    // member functions...
    virtual void update() {
        //pseudocode
        foreach (object in objectContainer)
            object->update();
    }

    private:
       std::vector<GameObject*> objectContainer;
}

My question being: what is the most common way to make the GameObject's update() method to have access to every other object in the state?

Eg: my veryBadassEnemyObject needs to know if the playerObject is within a particular x0,y0 -> x1,y1 rectangular area.

The straightest approach I can think of is simply passing the object container to the update function as a parameter, but I have the feeling that there is a much more professional, better way to do it.


texts: Visual Studio draws red underlines ("squiggles") on anything in the UnityEngine namespace

texts:
I work with Unity and Visual Studio 2019 and I have 4 scripts in my project.
I was getting almost every single keyword underlined with the red curvy lines (which shows that it is an error) in all scripts but the game works fine when I start it.
I tried unloading and reloading the solution and also rebuilding and building the solution by following the answers of this question. That solves my problem to some extent. Earlier I had 146 errors and now I have only 42 errors and I noticed that the keywords which are underlined red now (at the time of 42 errors) are a part of the UnityEngine namespace.
I tried restarting Visual Studio and also my computer but that doesn't help.
Even though I am getting those red curvy lines, my game runs well doing all the tasks.
If you didn't understand what am I trying to explain, visit this question. The problem stated in this question is kind of the same as my problem, only the difference is that the answers do not seem to work with the UnityEngine namespace.
Earlier, when I was working on the same project I didn't get those errors without any reason. I am now getting these errors. And I have already installed everything which I needed.


texts:
I'm looking for a networking middleware that may be suitable for a medium-sized MMO.

I don't care in which language it's written, just that it's high-level, stable and has many of the features that can ease my development. I am making a 2D real-time action game.

Come to think of it... I'd be happy with "just" a high-level networking framework that has a few handy features to ease the development of a general networked game.


texts: Distinguish touch gestures for distinct horizontal and vertical commands

texts:
In my script below I'm using horizontal and vertical swipe gesture to move the character but both gestures are called on a single touch.

void Update ()
{
  HorizontalSwipe();
  VerticalSwipe();
}

void HorizontalSwipe()
{
  foreach ( Touch FingerTouchx in Input.touches ) {
    if( FingerTouchx.fingerId < 1 ){  //         FINGERID
      if(FingerTouchx.phase == TouchPhase.Began) {
        FingerInitialPositionx = FingerTouchx.position.x;
      }
      else if(FingerTouchx.phase == TouchPhase.Moved) {
        FingerMovedPositionx = FingerTouchx.position.x;

        if(FingerMovedPositionx > FingerInitialPositionx)
          charcter.transform.Translate(Vector2.right * speed * Time.deltaTime);
        else if(FingerMovedPositionx < FingerInitialPositionx)
          charcter.transform.Translate(-Vector2.right * speed * Time.deltaTime);
      }
      else if(FingerTouchx.phase == TouchPhase.Ended) {
        FingerInitialPositionx = 0f;
        FingerMovedPositionx = 0f;
      }
      else {
        FingerMovedPositionx = FingerTouchx.position.x;

        if(FingerMovedPositionx > FingerInitialPositionx)
          charcter.transform.Translate(Vector2.right * speed * Time.deltaTime);
        else if(FingerMovedPositionx < FingerInitialPositionx)
          charcter.transform.Translate(-Vector2.right * speed * Time.deltaTime);
      }
    }
  }
}

void VerticalSwipe()
{
  foreach (Touch FingerTouchy in Input.touches) {
    if( FingerTouchy.fingerId < 1){      //         FINGERID
      if(FingerTouchy.phase == TouchPhase.Began)
        FingerInitialPositiony = FingerTouchy.position.y;

      if(FingerTouchy.phase == TouchPhase.Moved) {
        FingerMovedPositiony = FingerTouchy.position.y;

        if(FingerMovedPositiony > FingerInitialPositiony)
          charcter.transform.Translate(Vector2.up * speed * Time.deltaTime);

        if(FingerMovedPositiony < FingerInitialPositiony)
          charcter.transform.Translate(-Vector2.down * speed * Time.deltaTime);
      }

      if(FingerTouchy.phase == TouchPhase.Ended) {
        FingerInitialPositiony = 0f;
        FingerMovedPositiony = 0f;
      }
    }
  }
}

Whats wrong here? My game character moves in the swipe direction along with continuous jumps.

What I want to achieve is that the character should move horizontally with one touch gesture and vertically(jump) with another touch gesture.

For example: the gesture made on the lower left corner of the touch screen should only consider horizontal movement and make the character move left or right, while the gesture made on the lower right corner should consider only the vertical movement and make the character jump. I'd like to achieve something similar to what's in Leo's Fortune.


texts: Entity interaction in a component design with events

texts:
My components are 100% isolated. No component knows about anything outside of itself in any way. Components have functions that operate on it's internal state and events to inform what's happening to it's internal state.

I then create a script on my game object called CommHub where I hook up all the component events to component functions. This works really well and I love it. I love having completely decoupled components and 1 central place to see how the communications between them are setup. It gives me a high level, while being functional, view of said game object and some game objects can have a lot of components.

My question is now entity to entity interaction and how to do that while keeping this idea of 100% decoupled components.

Say we have the player game object and a zombie game object. Each are made up of components. The high level idea is the zombie looks in a radius around itself for all entities and if one is the player it'll walk towards it. When in a certain range it'll start a struggle with the player. This is the first interaction between 2 entities. The zombie controller component is the one that checks if it's in range of the player (it's target found from the search component) and if so needs to communicate with the player to tell it to start a struggle with this zombie.

A system for communication between the entities is what I'm interested in talking about while any system still keeping with components not being aware of other components directly (ie. no component knowledge from within another component). I can't think of a good way to do it like I have with inter-entity components.

Any thoughts/ideas?


texts:
I have a problem with a simple game loop. As my rendering and iteration functions together take 10 ms, the time between update and swapBuffers measuers around 140 ms. What is causing this. Is there a straightforward way to fix this.

Could it be related to the fact that each rect() (in a for loop) calls glDrawElements() and it somehow ques the whole process.

void game::startup()
{
    startup();
    glfwSwapInterval(1);
}

void game::render(double currentTime)
{
    static const GLfloat green[] = { 0.0f, 0.25f, 0.0f, 1.0f };
    static const GLfloat one = 1.0f;

    glClearBufferfv(GL_COLOR, 0, green);
    glClearBufferfv(GL_DEPTH, 0, &one);

    auto t1 = std::chrono::high_resolution_clock::now();

    for (size_t y = 0; y < game_board.getWorldHeight(); ++y) {
        for (size_t x = 0; x < golf_board.getWorldWidth(); ++x) {
            rect(x * cell_size, y * cell_size, cell_size, cell_size, game_board.get_state(y * game_board.getWorldWidth() + x));
        }
    }

    auto t2 = std::chrono::high_resolution_clock::now();
    game_board.iterate(1);
    auto t3 = std::chrono::high_resolution_clock::now();

    float rendertime = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count() / 1000.0f;
    float generatetime = std::chrono::duration_cast<std::chrono::microseconds>(t3 - t2).count() / 1000.0f;

    std::chrono::milliseconds ms_perframe(1000 / 60);  // About 60 fps
    auto cur_time = std::chrono::high_resolution_clock::now();
    float sleep_time = std::chrono::duration_cast<std::chrono::microseconds>(t1 + ms_perframe - t2).count() / 1000.0f;

    std::this_thread::sleep_for(t1 + ms_perframe - t3);

    cout << "render time (ms)" << rendertime <<"\n"
         << "generate time (ms)" <<generatetime << "\n"
         << "sleeping time (ms)" << sleep_time << "\n";
}

Output (board size: 256 x 128 = 32768 rectangles drawn per frame):

render time (ms) 8.1
generate time (ms) 1.3
sleeping time (ms) 6.6
SWAP TIME (ms) 146

application run function rendering part:

startup();

do
{
    render(glfwGetTime());

    auto t1 = std::chrono::high_resolution_clock::now();
    glfwSwapBuffers(window);
    auto t2 = std::chrono::high_resolution_clock::now();
    float  swap_time =
    std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count() / 1000.0f;
    std::cout << "SWAP TIME (ms)" << swap_time << "\n";

    glfwPollEvents();

    running &= (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_RELEASE);
    running &= (glfwWindowShouldClose(window) != GL_TRUE);

} while (running);

shutdown();

glfwDestroyWindow(window);
glfwTerminate();

rectangle draw function:

rect(int x, int y, int w, int h, int state) {
// input is top left corner of rectangle, width and height of rectange
and the state of unit

GLfloat fstate = (float)state * 0.5f;
GLfloat vertices[] = {
    x,  y,      fstate,         // Top-left
    x + w,  y,  fstate,         // Top-right
    x + w,  y + h,   fstate,    // Bottom-right
    x, y + h,    fstate          // Bottom-left
};

glBufferSubData(GL_ARRAY_BUFFER,0, sizeof(vertices),vertices);
glUseProgram(shaderProgram);

glUniformMatrix4fv(mvp_location, 1, GL_FALSE, mvp);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
}


texts: How to get a 2D vectorial terrain from an image for Java collision detection?

texts:
I'm trying to make a 2D Java-only game with a terrain like the one shown below. In the previous games I made, I used tile based collsions, but now, I want to use vector based collsions, as an uneven terrain would require minuscule tiles.

What I'd like to know, is how I can get the vectors from the map above, and how I should use them.

For the first part, I could manually measure out each of the coordinates, as shown below, but especially for lager and more detailed maps, that would be a tremendous amount of work.

I was wondering if there is a way to do this easier. I've seen tools that let you draw the vectors over the image, but those export only to engines like Box2D and Unity, which are programmed in different code languages. As I stated before, I only want to use Java.

For the second part, if I have the coordinates of the vectors, what should I do with them? I previously used rectangles, but now I would need to use either lines or polygons that connect each coordinate.

Also, how do I check for collisions between the player's polygon or rectangle, and the polygons or lines that form the terrain? When using rectangles, I could use playerR.Intersects(terrainR), but how can I do this with a terrain?

A link to an easy-to-understand tutorial would be a nice answer too, especially for the last part of my question.

Thanks in advance.


texts:
I am trying to figure out a problem related to CableComponents.

As part of my learning and problem identification I'm trying to place some UE_LOGs/Debug Messages within Pawn.cpp and CableComponent.cpp

These changes are not reflected when the c++ code is compiled within unreal. which is consistent with Unreal only building project code.

So My question is, how can I make these changes to the source code and have them be used?

Alternatively, is there a better way to do what I'm trying to do?

The reason i'm trying to do this

I'm trying to figure out how often the dynamic data of UCableComponent is recalculated compared to the rendering update of APawn.


texts: vertices, better to have more but draw a smaller area or less but expand a larger area

texts:
I have a simple question really. I am creating water for a game and had two different design approaches:

Make a single plane that expands the entire playspace, which would take 6 vertices but cover a much larger area. The idea being the plane would be at a certain height so the sourrong land if higher should cover it.
Check at regular intervals around the created land, ask if the height of that peice of land is below a certain height if so, draw a small square to cover the area and then check the next interval and the next... The idea being you'd have a lot more vertices but much less area will be drawn.

Any help would be appreciated as to which design approach makes more sense.


texts: iPhone, iPad Rendering Ahead of Input (4-5 seconds)

texts:
UPDATE I think I solved this one, though any thoughts or suggestions are always welcome!

This one is truly bizarre...  I'm developing using both an iPhone 3GS and an iPad 2.  This symptom is repeatable on the older iPhone hardware much more readily than on the iPad 2.  Here's what happens:

I start the game and the FPS is ticking at about 47 on the 3GS in OpenGLES2.0.  I have quite a lot on screen right now, so that is reasonable at this stage (I still have a few optimizations I can make too).

If you put a break in touchesBegan, it takes roughly 4-5 seconds before the break occurs and the game halts.  This doesn't happen all of the time, and in fact, if you restart the app several times, it usually goes away.  Moreover, if I let the game sit for a bit, it will eventually "sync."  Like I said, the iPad 2 rarely exhibits the problem (one out of every 15-20 test runs), but it is definitely still present.  If you perform a series of touches and accelerometer events in sequence, they are queued up and rendered just like you did them 4-5 seconds later.  Very reminiscent of 4-5s lag delays back in the day online :)

I've tried a couple things like glFlush, or glFinish at the end of each render loop (doesn't seem to have any effect).  Here's the top game loop:

- (void) drawView: (CADisplayLink*) displayLink
{
double dt = 0.0f; // Time in seconds since last loop
if (displayLink != nil) {
    dt = displayLink.timestamp - m_timestamp;
    m_timestamp = displayLink.timestamp;
}

// Update the game
m_gameEngine->Update(dt);

// Render the game
m_gameEngine->Render();
[m_context presentRenderbuffer:GL_RENDERBUFFER];
}

UPDATE:

The more I think about it...  this could be a loading issue. Right now, I instantiate my main controller class for the game loop in the - (id) initWithFrame: (CGRect) frame
call, which is also where I initialize OpenGL and (finally) call [displayLink addToRunLoop:[NSRunLoop currentRunLoop]
                     forMode:NSDefaultRunLoopMode].  It's almost as if the renderer gets behind or ahead of the game logic and it takes it awhile to get caught back up.

From research, I could also just be throttling the CPU too hard.  But if that were the case, I would imagine it wouldn't catch up...  the FPS stays at a solid 44-46, and the input lag does go away if you let it sit for 10-15 seconds (with or without doing anything, it eventually catches up).  I'm stumped, but I'll keep digging...

UPDATE 2:

Doing some profiling... figured out that the accelerometer being polled 1/60 was a bit taxing.  If I moved it to 1/30, this problem went away.  This is concerning to me, as it likely suggests I do have a CPU overloading issue that will only be solved through some serious optimizations across the board (which is okay, I knew I had to do it anyway).

For anyone with a similar issue, especially if you are using the accelerometer, make sure you disable it if/when you aren't using it.  I only use the accelerometer to allow the player to rotate/move the camera - so when the player has the camera locked, I am now toggling it off.  This has solved my problem for now, but like I said, I probably only solved it temporarily.  A real solution is going to take more work!

Hope this helps.


texts:
With the pending release of MonoDroid we have decided to revisit MonoTouch as a possible alternative to gearing up some Objective-C skills.  I was wondering if anyone had any experience and would share the gotchas before everyone else hits them.  Set to CW, one hurdle per answer please.

MonoTouch allows C# development of iPhone and iPad applications with access to native code libraries.


texts:
I've made a Connect Four game. The first move is made by the player and the second by the computer. Currently, the computer moves randomly; its moves are generated by C++'s random number generator rand(). I'd like to build a basic AI that tries to win or prevent the player from winning.

How can I go about doing this?


texts: Can't get normals to work correctly with lighting in OpenGL

texts:
I'm trying to light up a simple 2d triangle with my cursor as a diffuse light source but can't seem to set the normal correctly for the lighting to look right.  The function that calculates the normal (m3dFindNormal) comes from the OpenGL Superbible (math3d.h) which takes 3 points on a plane and determines the cross product of 2 vectors from those points.  Since this doesn't return a normal of length 1 I then call m3dNormalizeVector3 to get a normal vector of length 1.  I then set the normal for the triangle using glNormal to that vector and draw the triangle.  Using this code the triangle never lights up at all but when I comment out the glNormal call it lights up on the vertices so something must be wrong with the normal.

glShadeModel(GL_SMOOTH);
GLfloat diffuseLight[] = {0.9f, 0.9f, 0.9f, 1.0f};
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
GLfloat lightPos[] = { x, y, 1.0f, 1.0f }; //x and y are the cursor's position
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glColor3f(0.75f, 0.75f, 0.75f);
glBegin(GL_TRIANGLES);
    M3DVector3f vPoints[3] = {{ SCREEN_WIDTH / 2 - 40, SCREEN_HEIGHT / 2 + 40, 0},
                              { SCREEN_WIDTH / 2 + 40, SCREEN_HEIGHT / 2 + 40, 0},
                              { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 0}};
    m3dFindNormal(vNormal, vPoints[0], vPoints[1], vPoints[2]);
    m3dNormalizeVector3( vNormal );
    glNormal3fv(vNormal);
    glVertex3fv( vPoints[0] );
    glVertex3fv( vPoints[1] );
    glVertex3fv( vPoints[2] );
glEnd();

I know the light works because things light up when I move the cursor around but they light up at the wrong times.  Anyone know what I'm doing wrong?


texts: How to make installable .exe file for unity games

texts: I just completed my game but after i built the game from unity to .exe it also has filename_data folder i know it has all the resources for the game. I tried iexpress and innosetup to make the install-able file. I installed the game from the setup then i ran it but the game gives the error "There should be 'HouseFixIt_Data' folder next to the executable", but i added data folder while making install-able file but still i'm getting this error. Please anyone help me...


texts:
I have a model from a package that has existing Blendshapes that work fine.  I'm a bit of a Blender newb, though. I'm trying to add a Blendshape for spikiness to a cube model.  It's early WIP, but it looks roughly the way I expect it to in Blender.  However, when exported and imported into Unity, the mesh with the blendshape applied isn't quite right - the spikes are sort of... plump, as if it isn't quite changing the vertices the same way.  Is there anything specific that needs to be done with this process?  Am I missing something, or is there some tuning I need to do in Blender prior to exporting the FBX?
Blender: http://www.labyrintheer.com/wp-content/uploads/2020/08/spike_bs_blender.mp4
Unity: http://www.labyrintheer.com/wp-content/uploads/2020/08/spike_bs_unity.mp4


texts: OpenGL and 3ds model loading: Path of least resistance?

texts:
Hey guys, im working on a final class project for a graphics class, and me and a teammate are making a simple 3d tower defense game.

We're currently planning on using 3ds models and drawing them with OpenGL.However, niether of us have a lot of practice/experience with loading/drawing models.

What is the fastest and/or easiest (not neccesarily the best or most feature-implemented) way to load a 3ds model and draw it with a OpenGL/glut setup?


texts: Need help solving an acute-triangle to find the distance to the outside of my object

texts:
I recently asked a question here: How would I check the range against the entirety of an enemy object, and not just it's transform.position?
That was accurately answered, and works perfectly fine. However, now I need to find the distance from the center of a non-rectangular object to it's edge as illustrated here:
I have the length of Side A, and the angle between Side A and Side C, as well as the angle between Side A and Side B. I am missing a couple things:

The length of Side B
The length of Side C

My end goal is to get the length of side C. It is important to note that my math skills are barely comparable to first year college algebra. I heavily rely on the methods provided within Unity to calculate dot products, angles, and distances without much understanding of their inner workings.
How would I go about accomplishing this?


texts:
I have a set of numbers I normalize ( so the converted number is between 0 and 1 ) which I want to pass trough a function, which in return gives me a different number between 0 and 1 based on the curve/shape.

For animation the following would do for easeInQuad ( From ):

Math.easeInQuad = function (t, b, c, d) {
    t /= d;
    return c*t*t + b;
};

Where t = current time. b = start value. c = change in value. d = duration

which looks like:

In my case the min is always 0 and max is always 1.
How would I go about creating a function equal to the shape but without all parameters that are required for animation?


texts: How can I fix the "fisheye" distortion in my raycast renderer?

texts:
I've just started making a 'raycast' engine, a pseudo 3D FPS engine similar to Wolfenstein/Doom. I haven't done much reading so my implementation is likely very naive.

My current working prototype has a 'fisheye' distortion [2nd image] which makes sense because the middle of the wall is closer than the far edges, but this is not how Doom looks.

What's the right way to do this? an orthogonal projection seems wrong because you would lose the foreshortening.