Skip to content

This is a Memory Manager for a game engine written in C++, as a part of my Master's degree in Entertainment Arts and Engineering at the University of Utah

License

Notifications You must be signed in to change notification settings

Vieper1/MemoryManager

Repository files navigation

Custom Game Engine

This is a game engine I built from scratch on C++
It includes the following systems:

  1. A Linear Memory-Pool Allocator
  2. A Fixed Size Allocator
  3. A Custom Smart-Pointer System
  4. A 2D-Physics Engine
  5. A Box-2D Collision Engine
  6. Unreal's Actor Hierarchy System (To build Player & NPC actors from)
  7. Dynamic Component Attachment System (E.g. Keyboard Inputs, Box Collider, Circle Collider)

NOTE: Git doesn't recognize changes to the solution's Default Project. So you'd have to select Pong as the Default Startup Project under the Solution's Properties in Visual Studio


Memory Allocation System

Here's a list of all the unique features the MemoryManager has:

  1. Primary Allocator Unit => Created a Fixed Size Allocator (FSA) & included 3 instances of it to handle allocations of different sizes (100 - 16 byte blocks | 200 - 32 byte blocks | 400 - 96 byte blocks)
    • Header | C++
    • The FSA is able to store anything less than its BLOCK SIZE to be stored in the first free block
    • This one's highly efficient because of the BIT-ARRAY State-Keeper

Fixed Size Allocator


  1. Backup Allocator => Pool Allocator
    • Header | C++
    • The Memory-Pool style allocator allocates blocks linearly regardless of their size
    • There's a ratio of the TOTAL POOL SIZE that stores metadata for each of the allocated blocks

Memory Pool Allocator


  1. The MemorySystem regulates the calls to the 3 FSAs or the Pool Allocator based on the size of the request
    • Header | C++
    • This system receives the allocation calls and invokes the respective allocator



Custom Smart-Pointer System

Features:

  1. Smart Pointer (reference) running a Reference Count book-keeping method to decide underlying pointer lifetime
  2. Weak Pointer running the same book-keeping method, for systems that just want to watch the underlying pointer, or get a Ref to the SmartPtr



2D Physics Engine

Features:

  1. Config: [Mass], [Linear Damping], [Gravity], [Net Force]
  2. Every object has Velocity
  3. Acceleration is imparted based on the Mass, which in turn controls how fast the Velocity changes per frame
  4. Linear Damping controls the acceleration resisting force
  5. If you use the APPLY_FORCE(...) function, you'd change the NetForce value, which is applied each frame and cleared



Box-2D Collision Engine

Features:

  1. Swept-Axis Collision Check formula to deflect off 2-objects with an Impending Collision that's Less Than 1-frame-time
  2. Inter-Frame-Time-Forwarding to resolve more than 2 objects in collison sequentially
  3. Object can register a callback to get notified when it's colliding with anything



Unreal's Actor Hierarchy System

Implemented a World class which handles

  1. Actor Spawning (With and without JSON for prefab)
  2. BeginPlay()
  3. EventTick()
  4. Pause
  5. Quit
  6. Cleanup







GAME FEATURES

How to play the game:

  1. Move the LEFT paddle up/down using W/S
  2. Move the RIGHT paddle up/down using I/K
  3. If the Ball moves past the left paddle, the right player's score increases by 1 (And vice versa)
  4. The first player to reach a score of 3 wins the game
  5. The windows shuts itself down to close the game, printing the win-state in the output log

NOTE: The walls comprise of white square bricks placed close to each other. Each reflect the ball in a random direction to give a sense of randomness to the game (Not really an interesting feature, but I just had in there since it makes it fun)

About

This is a Memory Manager for a game engine written in C++, as a part of my Master's degree in Entertainment Arts and Engineering at the University of Utah

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages