-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
1,001 additions
and
342 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "pch.h" | ||
#include "Array.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
#pragma once | ||
#include <cstddef> | ||
#include <cassert> | ||
|
||
namespace CM | ||
{ | ||
template<typename Ty, std::size_t N> | ||
class Array | ||
{ | ||
public: | ||
Array() : mSize(0) {} | ||
|
||
void PushBack(const Ty& value) | ||
{ | ||
assert(mSize < N && "Array capacity exceeded"); | ||
mDatas[mSize++] = value; | ||
} | ||
|
||
void PopBack() | ||
{ | ||
assert(mSize > 0 && "Array is empty"); | ||
--mSize; | ||
} | ||
|
||
Ty& operator[](std::size_t index) | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
return mDatas[index]; | ||
} | ||
|
||
const Ty& operator[](std::size_t index) const | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
return mDatas[index]; | ||
} | ||
|
||
std::size_t Size() const noexcept | ||
{ | ||
return mSize; | ||
} | ||
|
||
constexpr std::size_t Capacity() const noexcept | ||
{ | ||
return N; | ||
} | ||
|
||
Ty* begin() noexcept { return mDatas; } | ||
const Ty* begin() const noexcept { return mDatas; } | ||
|
||
Ty* end() noexcept { return mDatas + mSize; } | ||
const Ty* end() const noexcept { return mDatas + mSize; } | ||
|
||
|
||
Ty* Find(const Ty& value) noexcept | ||
{ | ||
for (std::size_t i = 0; i < mSize; ++i) | ||
{ | ||
if (mDatas[i] == value) | ||
{ | ||
return &mDatas[i]; | ||
} | ||
} | ||
return end(); | ||
} | ||
|
||
const Ty* Find(const Ty& value) const noexcept | ||
{ | ||
for (std::size_t i = 0; i < mSize; ++i) | ||
{ | ||
if (mDatas[i] == value) | ||
{ | ||
return &mDatas[i]; | ||
} | ||
} | ||
return end(); | ||
} | ||
|
||
void Erase(std::size_t index) | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
for (std::size_t i = index; i < mSize - 1; ++i) | ||
{ | ||
mDatas[i] = mDatas[i + 1]; | ||
} | ||
--mSize; | ||
} | ||
|
||
private: | ||
Ty mDatas[N]; | ||
std::size_t mSize; | ||
}; | ||
} | ||
|
||
namespace CM | ||
{ | ||
template<typename Ty, std::size_t N> | ||
class Array<Ty*, N> | ||
{ | ||
public: | ||
Array() : mSize(0) | ||
{ | ||
for (std::size_t i = 0; i < N; ++i) | ||
{ | ||
mDatas[i] = nullptr; | ||
} | ||
} | ||
|
||
void PushBack(Ty* value) | ||
{ | ||
assert(mSize < N && "Array capacity exceeded"); | ||
mDatas[mSize++] = value; | ||
} | ||
|
||
void PopBack() | ||
{ | ||
assert(mSize > 0 && "Array is empty"); | ||
--mSize; | ||
mDatas[mSize] = nullptr; | ||
} | ||
|
||
Ty*& operator[](std::size_t index) | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
return mDatas[index]; | ||
} | ||
|
||
const Ty* const& operator[](std::size_t index) const | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
return mDatas[index]; | ||
} | ||
|
||
std::size_t Size() const noexcept | ||
{ | ||
return mSize; | ||
} | ||
|
||
constexpr std::size_t Capacity() const noexcept | ||
{ | ||
return N; | ||
} | ||
|
||
Ty** begin() noexcept { return mDatas; } | ||
Ty* const* begin() const noexcept { return mDatas; } | ||
|
||
Ty** end() noexcept { return mDatas + mSize; } | ||
Ty* const* end() const noexcept { return mDatas + mSize; } | ||
|
||
Ty** Find(Ty* value) noexcept | ||
{ | ||
for (std::size_t i = 0; i < mSize; ++i) | ||
{ | ||
if (mDatas[i] == value) | ||
{ | ||
return &mDatas[i]; | ||
} | ||
} | ||
return end(); | ||
} | ||
|
||
Ty* const* Find(Ty* value) const noexcept | ||
{ | ||
for (std::size_t i = 0; i < mSize; ++i) | ||
{ | ||
if (mDatas[i] == value) | ||
{ | ||
return &mDatas[i]; | ||
} | ||
} | ||
return end(); | ||
} | ||
|
||
void Erase(Ty* value) | ||
{ | ||
size_t idx = 0; | ||
for (; idx < mSize; ++idx) | ||
{ | ||
if (value == mDatas[idx]) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
if (idx != mSize) | ||
{ | ||
for (std::size_t i = idx; i < mSize - 1; ++i) | ||
{ | ||
mDatas[i] = mDatas[i + 1]; | ||
} | ||
--mSize; | ||
mDatas[mSize] = nullptr; | ||
} | ||
} | ||
|
||
void Erase(std::size_t index) | ||
{ | ||
assert(index < mSize && "Index out of bounds"); | ||
for (std::size_t i = index; i < mSize - 1; ++i) | ||
{ | ||
mDatas[i] = mDatas[i + 1]; | ||
} | ||
--mSize; | ||
mDatas[mSize] = nullptr; | ||
} | ||
|
||
private: | ||
Ty* mDatas[N]; | ||
std::size_t mSize; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "pch.h" | ||
#include "CKeyInput.h" | ||
|
||
void CKeyInput::Update() | ||
{ | ||
for (auto& action : m_actionVector) | ||
{ | ||
const ActionKey& key = action->Key; | ||
if (CheckKeyState(key.KeyState, key.KeyCode)) | ||
{ | ||
action->Action(); | ||
} | ||
} | ||
} |
Oops, something went wrong.