3rd person camera shooter game in C++DirectX need guidance

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

3rd person camera shooter game in C++DirectX need guidance

Postby grimreaper2017 on Thu Dec 28, 2017 6:14 am

Hi people, developing a 3rd Person shooter (under the water game) in C++ and Direct X. I've got the firing mechanism to work - perfect.

But I want to advance my own skills, I have been toying with the idea of using Homing Missile (been struggling over the idea for a few months now), any ideas on resources in C++ in this field? I can create one in Unity & Unreal (blue prints). but trying to do one in C++ is driving me nuts. Even if it is in 2D, and I can reverse engineer the code

or something it would be a start. :(
grimreaper2017
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 1
Joined: Wed Dec 27, 2017 7:45 am

Re: 3rd person camera shooter game in C++DirectX need guidan

Postby dandymcgee on Tue Jan 02, 2018 5:53 pm

The logic would be the same as any "follow" mechanism. Essentially, just set the follower's acceleration in the direction of the target each frame.

Untested pseudocode (this is C, feel free to replace C idioms with C++ idioms, e.g. std::vector<Entity>):
const float ENTITY_ACC = 1.0f;

typedef struct vec2
{
float x, y;
} vec2;

typedef struct entity
{
vec2 pos;
vec2 vel;
vec2 acc;
entity *target;
} entity;

void update_entities(int count, entity *entities)
{
for (int i = 0; i < count; ++i)
{
if (entities[i].target != NULL)
{
float delta_x = entities[i].target.pos.x - entities[i].pos.x;
float delta_y = entities[i].target.pos.y - entities[i].pos.y;
entities[i].acc.x = (delta_x > 0.0f) ? ENTITY_ACC : -ENTITY_ACC;
entities[i].acc.y = (delta_y > 0.0f) ? ENTITY_ACC : -ENTITY_ACC;
}

// TODO: Check if entities[i].type == HOMING_MISSILE && are_colliding(entities[i], entities[i].target)
// If so, damage target, delete missile, etc.
}
}
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4707
Joined: Tue Apr 29, 2008 4:24 pm
Location: San Francisco

Re: 3rd person camera shooter game in C++DirectX need guidan

Postby dandymcgee on Wed Jan 03, 2018 8:28 pm

Also, while this is not directly related to your question, I just found this great resource for 2D games that you might like to read: http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4707
Joined: Tue Apr 29, 2008 4:24 pm
Location: San Francisco


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron