MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
tetris.cpp File Reference
#include <SDL3/SDL.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <fstream>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <random>
#include <sstream>
#include <string>
#include <vector>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/glm.hpp>
#include "mxnetwork/socket.hpp"
#include "mxvk/argz.hpp"
#include "mxvk/mxvk.hpp"
#include "mxvk/mxvk_abstract_model.hpp"
#include "mxvk/mxvk_exception.hpp"
#include "mxvk/mxvk_sound.hpp"

Go to the source code of this file.

Classes

struct  anonymous_namespace{tetris.cpp}::ActivePiece
struct  anonymous_namespace{tetris.cpp}::Block
struct  anonymous_namespace{tetris.cpp}::BlockModel
struct  anonymous_namespace{tetris.cpp}::Cell
struct  anonymous_namespace{tetris.cpp}::HighScoreEntry
class  anonymous_namespace{tetris.cpp}::HighScores
struct  anonymous_namespace{tetris.cpp}::LockedBlock
struct  anonymous_namespace{tetris.cpp}::MultiplayerSnapshot
struct  anonymous_namespace{tetris.cpp}::PieceDefinition
struct  anonymous_namespace{tetris.cpp}::PieceQueueEntry
class  anonymous_namespace{tetris.cpp}::TetrisWindow

Namespaces

namespace  anonymous_namespace{tetris.cpp}

Macros

#define tetris_ASSET_DIR   "."

Enumerations

enum class  anonymous_namespace{tetris.cpp}::AppScreen {
  anonymous_namespace{tetris.cpp}::Intro , anonymous_namespace{tetris.cpp}::Menu , anonymous_namespace{tetris.cpp}::Game , anonymous_namespace{tetris.cpp}::GameOver ,
  anonymous_namespace{tetris.cpp}::NetworkMultiplayer , anonymous_namespace{tetris.cpp}::HighScores , anonymous_namespace{tetris.cpp}::Credits
}
enum class  anonymous_namespace{tetris.cpp}::MultiplayerMode {
  anonymous_namespace{tetris.cpp}::Idle , anonymous_namespace{tetris.cpp}::Hosting , anonymous_namespace{tetris.cpp}::Joining , anonymous_namespace{tetris.cpp}::Connected ,
  anonymous_namespace{tetris.cpp}::Error
}

Functions

int main (int argc, char **argv)
std::filesystem::path anonymous_namespace{tetris.cpp}::resolveScoreFilePath ()
std::array< Block, 4 > anonymous_namespace{tetris.cpp}::rotatedBlocks (const ActivePiece &piece)

Variables

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

Macro Definition Documentation

◆ tetris_ASSET_DIR

#define tetris_ASSET_DIR   "."

Definition at line 34 of file tetris.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 2457 of file tetris.cpp.

2457 {
2458 try {
2459 const Arguments args = proc_args(argc, argv);
2460 TetrisWindow window(args.path, args.width, args.height, args.fullscreen, args.enable_vsync);
2461 window.loop();
2462 } catch (const mxnetwork::Exception &e) {
2463 std::cerr << std::format("mxnetwork: Exception: {}\n", e.text());
2464 return EXIT_FAILURE;
2465 } catch (mxvk::Exception &e) {
2466 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
2467 return EXIT_FAILURE;
2468 } catch (ArgException<std::string> &e) {
2469 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
2470 return EXIT_FAILURE;
2471 }
2472
2473 return EXIT_SUCCESS;
2474}
Arguments proc_args(int &argc, char **argv)
Parse standard libmx2 command-line options from main()'s argv.
Definition argz.hpp:872
Exception thrown by Argz::proc() on unrecognised or malformed options.
Definition argz.hpp:178
String text() const
Definition argz.hpp:182
TetrisWindow(const std::string &path, int width, int height, bool fullscreen, bool enable_vsync)
Definition tetris.cpp:298
Lightweight exception wrapper for MXNetwork failures.
Definition exception.hpp:11
std::string text() const
Return the stored error text.
Definition exception.cpp:5
std::string text() const
Plain data structure returned by proc_args() with all common libmx2 CLI options.
Definition argz.hpp:730
bool fullscreen
Whether fullscreen mode was requested.
Definition argz.hpp:736
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
Definition argz.hpp:750
int height
Viewport height in pixels (default: 720).
Definition argz.hpp:733
std::string path
Asset root; proc_args() defaults it to the executable directory.
Definition argz.hpp:735
int width
Viewport width in pixels (default: 1280).
Definition argz.hpp:732