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.
3rd person camera shooter game in C++DirectX need guidance
Moderator: PC Supremacists
-
- Chaos Rift Newbie
- Posts: 1
- Joined: Wed Dec 27, 2017 5:45 am
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: 3rd person camera shooter game in C++DirectX need guidan
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>):
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.target != NULL) { float delta_x = entities.target.pos.x - entities.pos.x; float delta_y = entities.target.pos.y - entities.pos.y; entities.acc.x = (delta_x > 0.0f) ? ENTITY_ACC : -ENTITY_ACC; entities.acc.y = (delta_y > 0.0f) ? ENTITY_ACC : -ENTITY_ACC; } // TODO: Check if entities.type == HOMING_MISSILE && are_colliding(entities, entities.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!
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: 3rd person camera shooter game in C++DirectX need guidan
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/ ... atformers/
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!