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

Go to the source code of this file.

Classes

struct  anonymous_namespace{puzzle_drop.cpp}::Block
struct  anonymous_namespace{puzzle_drop.cpp}::Cell
struct  anonymous_namespace{puzzle_drop.cpp}::Piece
class  anonymous_namespace{puzzle_drop.cpp}::PuzzleDropWindow

Namespaces

namespace  anonymous_namespace{puzzle_drop.cpp}

Macros

#define puzzle_drop_ASSET_DIR   "."

Enumerations

enum class  anonymous_namespace{puzzle_drop.cpp}::BlockType {
  anonymous_namespace{puzzle_drop.cpp}::Null = 0 , anonymous_namespace{puzzle_drop.cpp}::Clear , anonymous_namespace{puzzle_drop.cpp}::Red1 , anonymous_namespace{puzzle_drop.cpp}::Red2 ,
  anonymous_namespace{puzzle_drop.cpp}::Red3 , anonymous_namespace{puzzle_drop.cpp}::Green1 , anonymous_namespace{puzzle_drop.cpp}::Green2 , anonymous_namespace{puzzle_drop.cpp}::Green3 ,
  anonymous_namespace{puzzle_drop.cpp}::Blue1 , anonymous_namespace{puzzle_drop.cpp}::Blue2 , anonymous_namespace{puzzle_drop.cpp}::Blue3 , anonymous_namespace{puzzle_drop.cpp}::Match
}
enum class  anonymous_namespace{puzzle_drop.cpp}::ShiftDirection { anonymous_namespace{puzzle_drop.cpp}::Down , anonymous_namespace{puzzle_drop.cpp}::Up }

Functions

bool anonymous_namespace{puzzle_drop.cpp}::is_play_block (BlockType type)
int main (int argc, char **argv)
bool anonymous_namespace{puzzle_drop.cpp}::same_or_match (BlockType actual, BlockType expected)
int anonymous_namespace{puzzle_drop.cpp}::texture_index (BlockType type)

Variables

const std::array< glm::vec3, 10 > anonymous_namespace{puzzle_drop.cpp}::BLOCK_TINTS
constexpr int anonymous_namespace{puzzle_drop.cpp}::BOARD_HEIGHT = 22
constexpr int anonymous_namespace{puzzle_drop.cpp}::BOARD_WIDTH = 20
constexpr float anonymous_namespace{puzzle_drop.cpp}::CUBE_SCALE = 0.048f
constexpr float anonymous_namespace{puzzle_drop.cpp}::CUBE_SPACING = CUBE_SCALE * 1.12f
constexpr std::array< float, 3 > anonymous_namespace{puzzle_drop.cpp}::FALL_SECONDS {0.86f, 0.68f, 0.50f}
constexpr size_t anonymous_namespace{puzzle_drop.cpp}::FRAME_TEXTURE_INDEX = 10
constexpr Uint32 anonymous_namespace{puzzle_drop.cpp}::INTRO_FADE_INTERVAL_MS = 35U
constexpr float anonymous_namespace{puzzle_drop.cpp}::INTRO_FADE_STEP = 0.01f
constexpr float anonymous_namespace{puzzle_drop.cpp}::INTRO_START_FADE = 1.0f
constexpr size_t anonymous_namespace{puzzle_drop.cpp}::LEVEL_GRAPHIC_COUNT = 8
constexpr int anonymous_namespace{puzzle_drop.cpp}::MATRIX_RAIN_TEXTURE_HEIGHT = 720
constexpr int anonymous_namespace{puzzle_drop.cpp}::MATRIX_RAIN_TEXTURE_WIDTH = 1280
constexpr size_t anonymous_namespace{puzzle_drop.cpp}::PREVIEW_BLOCK_TEXTURE_COUNT = 10
const std::array< std::string, PREVIEW_BLOCK_TEXTURE_COUNTanonymous_namespace{puzzle_drop.cpp}::PREVIEW_BLOCK_TEXTURE_FILES

Macro Definition Documentation

◆ puzzle_drop_ASSET_DIR

#define puzzle_drop_ASSET_DIR   "."

Definition at line 25 of file puzzle_drop.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1252 of file puzzle_drop.cpp.

1252 {
1253 try {
1254 Arguments args = proc_args(argc, argv);
1255 PuzzleDropWindow window(args.path, args.width, args.height, args.fullscreen, args.enable_vsync);
1256 window.loop();
1257 } catch (const mxvk::Exception &e) {
1258 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
1259 return EXIT_FAILURE;
1260 } catch (const ArgException<std::string> &e) {
1261 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
1262 return EXIT_FAILURE;
1263 } catch (const std::exception &e) {
1264 std::cerr << std::format("puzzle_drop: Exception: {}\n", e.what());
1265 return EXIT_FAILURE;
1266 }
1267 return EXIT_SUCCESS;
1268}
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
PuzzleDropWindow(const std::string &path, int width, int height, bool fullscreen, bool enable_vsync)
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