• Breaking News

    Following enemy CSFML Hi, So basically I'm developing a 2d RPG type game, in the old pokemon style. One of the parts of the game is an enemy that starts following you once you get in a certain range. I was able to implement the detection part (quite easy, just basic vector math), now I need to make him move according to a clock (not the hard part), but I don't know how I would make him follow a vector (enemy position to player position). The code below is a function that returns distance between two points (mouse cursor and sprite position). Any sort of help would be hugely appreciated. Cheers // GETTING DISTANCE BETWEEN TWO POINTS IN 2D // RESULT IS USED IN A CONDITION ALONGSIDE A CLOCK int vector_dist(sfVector2i mouse, sfVector2f pos) { int dist = 0; int x = mouse.x - pos.x; int y = mouse.y - pos.y; dist = sqrt(x * x + y * y); return (dist); } https://ift.tt/eA8V8J

    Hi, So basically I'm developing a 2d RPG type game, in the old pokemon style. One of the parts of the game is an enemy that starts following you once you get in a certain range. I was able to implement the detection part (quite easy, just basic vector math), now I need to make him move according to a clock (not the hard part), but I don't know how I would make him follow a vector (enemy position to player position). The code below is a function that returns distance between two points (mouse cursor and sprite position). Any sort of help would be hugely appreciated. Cheers // GETTING DISTANCE BETWEEN TWO POINTS IN 2D // RESULT IS USED IN A CONDITION ALONGSIDE A CLOCK int vector_dist(sfVector2i mouse, sfVector2f pos) { int dist = 0; int x = mouse.x - pos.x; int y = mouse.y - pos.y; dist = sqrt(x * x + y * y); return (dist); }

    from GameDev.net https://ift.tt/2YK0RbC

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728