Darkstar Showdown (NEXT 2024)

Darkstar Showdown Darkstar Showdown is a 3D turn-based strategy game developed in C++ as an individual submission for the Ubisoft NEXT 2024 competition in the programming category, where it won third place. The game was created in just 3 days using a provided graphics API, and it centered around this year’s theme of “firing projectiles.” C++ opengl Game Features You and another player, pilot a spaceship separated by a dying darkstar with the goal of destroying the other player before the star implodes....

January 10, 2024

C++ Test Review

Just some scattered notes for test review. Object Composition Object memory is stored contiguously. If an object has pointers, those pointers are still stored contiguously but point to wherever the data is. Object Ownership One simple approach is to say that whatever creates the object becomes the owner of the object Thus, it becomes responsible for deleting it Inheritance Polymorphism Zombie* bob = new Zombie("Bob"); Zombie* sally = new ZombieSoldier("Sally", 100); bob->attack(); // prints "Bob throws a punch" sally->attack(); // prints "Sally throws a punch" // wait....

October 16, 2023

C++ A Personal Guide

A compilation of various features and gotchas I’ve encountered while studying C++. Instantiating Object Member Variables When to Use Initializer Lists Intializer lists offer a secondary method of initializer member variables for a class. A question comes up of why would we use this method as opposed to initializing the variables on declaration of just in the constructor. Below are a few core purposes. Initialize Const Members You could initialize these on declaration but what if you we want to pass in their values as arguments to the constructor....

October 4, 2023

Stack and Heap

Declaring Data Structures on the Heap https://stackoverflow.com/questions/8036474/when-vectors-are-allocated-do-they-use-memory-on-the-heap-or-the-stack vector<Type> vect; will allocate the vector, i.e. the header info, on the stack, but the elements on the free store (“heap”). vector<Type> *vect = new vector<Type>; allocates everything on the free store (except vect pointer, which is on the stack). vector<Type*> vect; will allocate the vector on the stack and a bunch of pointers on the free store, but where these point is determined by how you use them (you could point element 0 to the free store and element 1 to the stack, say)....

September 27, 2023

Signed Ints and Two's Complement

Two’s Complement Representation Why We Use It In c++, signed integers are represented in two’s complement notation. Before I get to how that notation works, I want to explain why we use it. Comparing both representations, -1 would look like this // Decimal 4294967295 // Binary Signed Int 10000000000000000000000000000001 // Two's Complement Signed Int 11111111111111111111111111111111 The normal signed binary representation is pretty easily understood if you know what a sign bit is....

September 12, 2023