MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
breakout.cpp File Reference
#include <SDL3/SDL.h>
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <format>
#include <iostream>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/glm.hpp>
#include "mxvk/argz.hpp"
#include "mxvk/mxvk_controller.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{breakout.cpp}::Ball
struct  anonymous_namespace{breakout.cpp}::Block
struct  anonymous_namespace{breakout.cpp}::Box
class  anonymous_namespace{breakout.cpp}::BreakoutWindow

Namespaces

namespace  anonymous_namespace{breakout.cpp}

Macros

#define breakout_ASSET_DIR   "."

Functions

bool anonymous_namespace{breakout.cpp}::check_collision (const Ball &ball, const Box &object)
float anonymous_namespace{breakout.cpp}::clampf (float value, float low, float high)
int main (int argc, char **argv)

Variables

constexpr float anonymous_namespace{breakout.cpp}::BALL_MODEL_SCALE = 0.05f
constexpr float anonymous_namespace{breakout.cpp}::BALL_RADIUS = 0.25f
constexpr float anonymous_namespace{breakout.cpp}::BALL_ROLL_DEGREES_PER_UNIT = 360.0f / (2.0f * PI * BALL_RADIUS)
constexpr float anonymous_namespace{breakout.cpp}::BALL_SPEED = 4.0f
constexpr int anonymous_namespace{breakout.cpp}::BLOCK_COLUMNS = 11
constexpr int anonymous_namespace{breakout.cpp}::BLOCK_ROWS = 5
constexpr float anonymous_namespace{breakout.cpp}::DEFAULT_ZOOM = 0.8f
constexpr float anonymous_namespace{breakout.cpp}::GAME_BOTTOM = -3.75f
constexpr float anonymous_namespace{breakout.cpp}::GAME_LEFT = -5.0f
constexpr float anonymous_namespace{breakout.cpp}::GAME_RIGHT = 5.0f
constexpr float anonymous_namespace{breakout.cpp}::GAME_TOP = 3.75f
constexpr Sint16 anonymous_namespace{breakout.cpp}::GAMEPAD_DEAD_ZONE = 8000
constexpr int anonymous_namespace{breakout.cpp}::MAX_MISSES = 3
constexpr float anonymous_namespace{breakout.cpp}::MAX_ZOOM = 1.6f
constexpr float anonymous_namespace{breakout.cpp}::MIN_ZOOM = 0.45f
constexpr float anonymous_namespace{breakout.cpp}::MODEL_SCALE = 1.0f
constexpr float anonymous_namespace{breakout.cpp}::PADDLE_SPEED = 5.0f
constexpr float anonymous_namespace{breakout.cpp}::PI = 3.14159265358979323846f
constexpr float anonymous_namespace{breakout.cpp}::ROTATION_SPEED = 50.0f
constexpr float anonymous_namespace{breakout.cpp}::ZOOM_SPEED = 0.8f

Macro Definition Documentation

◆ breakout_ASSET_DIR

#define breakout_ASSET_DIR   "."

Definition at line 28 of file breakout.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 733 of file breakout.cpp.

733 {
734 try {
735 Arguments args = proc_args(argc, argv);
736 BreakoutWindow window(args.path, args.width, args.height, args.fullscreen, args.enable_vsync);
737 window.loop();
738 } catch (const mxvk::Exception &e) {
739 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
740 return EXIT_FAILURE;
741 } catch (const ArgException<std::string> &e) {
742 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
743 return EXIT_FAILURE;
744 }
745 return EXIT_SUCCESS;
746}
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
BreakoutWindow(const std::string &path, int width, int height, bool fullscreen, bool enable_vsync)
Definition breakout.cpp:89
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