MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
anonymous_namespace{tetris.cpp} Namespace Reference

Classes

struct  ActivePiece
struct  Block
struct  BlockModel
struct  Cell
struct  HighScoreEntry
class  HighScores
struct  LockedBlock
struct  MultiplayerSnapshot
struct  PieceDefinition
struct  PieceQueueEntry
class  TetrisWindow

Enumerations

enum class  AppScreen {
  Intro , Menu , Game , GameOver ,
  NetworkMultiplayer , HighScores , Credits
}
enum class  MultiplayerMode {
  Idle , Hosting , Joining , Connected ,
  Error
}

Functions

std::filesystem::path resolveScoreFilePath ()
std::array< Block, 4 > rotatedBlocks (const ActivePiece &piece)

Variables

const std::array< std::string, 8 > blockTextureFiles
constexpr int boardHeight = 20
constexpr int boardWidth = 10
const std::array< glm::vec3, 8 > colorTints
constexpr float cubeScale = 0.085f
constexpr float cubeSpacing = cubeScale * 1.0f
constexpr std::string_view multiplayerPort = "37373"
constexpr std::size_t nameCharacterCount = sizeof(nameCharacters) - 1
constexpr char nameCharacters [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
constexpr std::size_t nameMaxLength = 10
const std::array< PieceDefinition, 7 > pieceDefinitions
const std::array< std::string, 8 > textureManifests

Enumeration Type Documentation

◆ AppScreen

enum class anonymous_namespace{tetris.cpp}::AppScreen
strong

◆ MultiplayerMode

enum class anonymous_namespace{tetris.cpp}::MultiplayerMode
strong

Function Documentation

◆ resolveScoreFilePath()

std::filesystem::path anonymous_namespace{tetris.cpp}::resolveScoreFilePath ( )
nodiscard

Definition at line 219 of file tetris.cpp.

219 {
220 if (const char *basePath = SDL_GetBasePath(); basePath != nullptr && basePath[0] != '\0') {
221 return std::filesystem::path(basePath) / "scores.dat";
222 }
223
224 std::error_code ec;
225 const std::filesystem::path cwd = std::filesystem::current_path(ec);
226 if (!ec) {
227 return cwd / "scores.dat";
228 }
229
230 return std::filesystem::path("scores.dat");
231 }

◆ rotatedBlocks()

std::array< Block, 4 > anonymous_namespace{tetris.cpp}::rotatedBlocks ( const ActivePiece & piece)
nodiscard

Definition at line 276 of file tetris.cpp.

276 {
277 std::array<Block, 4> rotated = piece.blocks;
278 for (Block &block : rotated) {
279 const int oldX = block.x;
280 block.x = -block.y;
281 block.y = oldX;
282 }
283 return rotated;
284 }

Variable Documentation

◆ blockTextureFiles

const std::array<std::string, 8> anonymous_namespace{tetris.cpp}::blockTextureFiles
Initial value:
{{
"block_ltblue.png",
"block_dblue.png",
"block_orange.png",
"block_yellow.png",
"block_green.png",
"block_purple.png",
"block_red.png",
"block_gray.png",
}}

Definition at line 254 of file tetris.cpp.

254 {{
255 "block_ltblue.png",
256 "block_dblue.png",
257 "block_orange.png",
258 "block_yellow.png",
259 "block_green.png",
260 "block_purple.png",
261 "block_red.png",
262 "block_gray.png",
263 }};

◆ boardHeight

int anonymous_namespace{tetris.cpp}::boardHeight = 20
constexpr

Definition at line 40 of file tetris.cpp.

◆ boardWidth

int anonymous_namespace{tetris.cpp}::boardWidth = 10
constexpr

Definition at line 39 of file tetris.cpp.

◆ colorTints

const std::array<glm::vec3, 8> anonymous_namespace{tetris.cpp}::colorTints
Initial value:
{{
{0.65f, 0.95f, 1.0f},
{0.45f, 0.56f, 1.0f},
{1.0f, 0.63f, 0.25f},
{1.0f, 0.92f, 0.35f},
{0.48f, 1.0f, 0.45f},
{0.82f, 0.48f, 1.0f},
{1.0f, 0.42f, 0.42f},
{0.55f, 0.58f, 0.62f},
}}

Definition at line 265 of file tetris.cpp.

265 {{
266 {0.65f, 0.95f, 1.0f},
267 {0.45f, 0.56f, 1.0f},
268 {1.0f, 0.63f, 0.25f},
269 {1.0f, 0.92f, 0.35f},
270 {0.48f, 1.0f, 0.45f},
271 {0.82f, 0.48f, 1.0f},
272 {1.0f, 0.42f, 0.42f},
273 {0.55f, 0.58f, 0.62f},
274 }};

◆ cubeScale

float anonymous_namespace{tetris.cpp}::cubeScale = 0.085f
constexpr

Definition at line 41 of file tetris.cpp.

◆ cubeSpacing

float anonymous_namespace{tetris.cpp}::cubeSpacing = cubeScale * 1.0f
constexpr

Definition at line 42 of file tetris.cpp.

◆ multiplayerPort

std::string_view anonymous_namespace{tetris.cpp}::multiplayerPort = "37373"
constexpr

Definition at line 46 of file tetris.cpp.

◆ nameCharacterCount

std::size_t anonymous_namespace{tetris.cpp}::nameCharacterCount = sizeof(nameCharacters) - 1
constexpr

Definition at line 45 of file tetris.cpp.

◆ nameCharacters

char anonymous_namespace{tetris.cpp}::nameCharacters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
constexpr

Definition at line 44 of file tetris.cpp.

◆ nameMaxLength

std::size_t anonymous_namespace{tetris.cpp}::nameMaxLength = 10
constexpr

Definition at line 43 of file tetris.cpp.

◆ pieceDefinitions

const std::array<PieceDefinition, 7> anonymous_namespace{tetris.cpp}::pieceDefinitions
Initial value:
{{
{{{{-1, 0}, {0, 0}, {1, 0}, {2, 0}}}, 0},
{{{{-1, 0}, {0, 0}, {1, 0}, {-1, 1}}}, 1},
{{{{-1, 0}, {0, 0}, {1, 0}, {1, 1}}}, 2},
{{{{0, 0}, {1, 0}, {0, 1}, {1, 1}}}, 3},
{{{{-1, 0}, {0, 0}, {0, 1}, {1, 1}}}, 4},
{{{{-1, 0}, {0, 0}, {1, 0}, {0, 1}}}, 5},
{{{{-1, 1}, {0, 1}, {0, 0}, {1, 0}}}, 6},
}}

Definition at line 233 of file tetris.cpp.

233 {{
234 {{{{-1, 0}, {0, 0}, {1, 0}, {2, 0}}}, 0},
235 {{{{-1, 0}, {0, 0}, {1, 0}, {-1, 1}}}, 1},
236 {{{{-1, 0}, {0, 0}, {1, 0}, {1, 1}}}, 2},
237 {{{{0, 0}, {1, 0}, {0, 1}, {1, 1}}}, 3},
238 {{{{-1, 0}, {0, 0}, {0, 1}, {1, 1}}}, 4},
239 {{{{-1, 0}, {0, 0}, {1, 0}, {0, 1}}}, 5},
240 {{{{-1, 1}, {0, 1}, {0, 0}, {1, 0}}}, 6},
241 }};

◆ textureManifests

const std::array<std::string, 8> anonymous_namespace{tetris.cpp}::textureManifests
Initial value:
{{
"manifest_cyan.txt",
"manifest_blue.txt",
"manifest_orange.txt",
"manifest_yellow.txt",
"manifest_green.txt",
"manifest_purple.txt",
"manifest_red.txt",
"manifest_gray.txt",
}}

Definition at line 243 of file tetris.cpp.

243 {{
244 "manifest_cyan.txt",
245 "manifest_blue.txt",
246 "manifest_orange.txt",
247 "manifest_yellow.txt",
248 "manifest_green.txt",
249 "manifest_purple.txt",
250 "manifest_red.txt",
251 "manifest_gray.txt",
252 }};