C++ Game Dev 33: Shared Context
This is part of an ongoing series where we write a complete 2D game engine in C++ and SFML. A […]
This is part of an ongoing series where we write a complete 2D game engine in C++ and SFML. A […]
This is part of an ongoing series where we write a complete 2D game engine in C++ and SFML. A […]
This is part of an ongoing series where we write a complete 2D game engine in C++ and SFML. A […]
This is part of an ongoing series where we write a complete 2D game engine in C++ and SFML. A […]
This week we will start work on a collision communication system. Currently, when two objects collide the only action they can take is to prevent the collision by moving apart, however what if we want more complicated behaviour? Such as causing damage to an enemy when the projectile collides with them or making the arrows disappear when they collide with a tile.
This week we are continuing where we left off by editing the collision system to call the OnCollisionEnter, OnCollisionStay, and OnCollisionExit functions that we wrote last week. This will lay the groundwork for many future features that require interaction between colliding objects.
Last week we wrote the code that will enable communication between objects when they collide. This communication can happen at three stages of a collision: when the collision occurs, every frame the collision is maintained, and when the collision ends. This week we are going to write a new component for our projectile that will remove it from the game when it collides with another object (so when collision first happens). It will be a simple component but will hopefully show you how to respond to collision events.
This week we are going to add a friend for the player. We’ll refractor the player creation code to reuse as much of it as possible and we’ll also create a new collision layer for the character and setup collisions between the player and his new friend.
In this series, we will write an AI that can teach itself to follow a set of rules. In an ideal world, I could write one AI character that could adapt to any environment within the game and provide an engaging experience for the player. While we are a long way from that ideal, this experiment may be a small stepping stone towards it.
In this part, we write the brains of our agents: a simple feed forward artificial neural network.