Yes, you absolutely can make your own game engine. However, it's important to understand that creating a game engine from scratch is a complex task. It requires strong knowledge in areas such as programming (often C++ for performance-critical applications), mathematics (particularly linear algebra for graphics and physics calculations), computer graphics (including knowledge of APIs like OpenGL or DirectX), physics, and possibly even sound processing.
Here's a very simplified example of what a basic game engine might start to look like, written in pseudo-code:
Remember, this is an oversimplification. Real-world game engines are immensely more complex, catering to things like networking, physics simulation, handling various file types, memory management, multi-threading, and much more.
While it is an enormous task to undertake, making your own game engine can be a great way to learn about all the aspects of game development and computer science in general. However, if your primary goal is to make a game (especially if you're working alone or with a small team), it might be more practical to use an existing engine like Unity, Unreal Engine, or Godot. These engines handle most of the heavy lifting for you, allowing you to focus on the unique aspects of your game.