#include "mxvk/argz.hpp"
#include "mxvk/mxvk.hpp"
#include "mxvk/mxvk_exception.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <format>
#include <iostream>
Go to the source code of this file.
|
| template<typename Func> |
| void | bresenhamLine (int x0, int y0, int x1, int y1, Func plot) |
| int | main (int argc, char **argv) |
◆ asteroids_ASSET_DIR
| #define asteroids_ASSET_DIR "." |
◆ M_PI
| #define M_PI 3.14159265358979323846 |
◆ GameState
| Enumerator |
|---|
| STATE_COUNTDOWN | |
| STATE_LAUNCH | |
| STATE_PLAYING | |
| STATE_GAMEOVER | |
Definition at line 92 of file space.cpp.
◆ bresenhamLine()
template<typename Func>
| void bresenhamLine |
( |
int | x0, |
|
|
int | y0, |
|
|
int | x1, |
|
|
int | y1, |
|
|
Func | plot ) |
Definition at line 100 of file space.cpp.
100 {
101 int dx = abs(x1 - x0);
102 int dy = abs(y1 - y0);
103 int sx = (x0 < x1) ? 1 : -1;
104 int sy = (y0 < y1) ? 1 : -1;
105 int err = dx - dy;
106 while (true) {
107 plot(x0, y0);
108 if (x0 == x1 && y0 == y1)
109 break;
110 int e2 = 2 * err;
111 if (e2 > -dy) {
112 err -= dy;
113 x0 += sx;
114 }
115 if (e2 < dx) {
116 err += dx;
117 y0 += sy;
118 }
119 }
120}
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
Definition at line 1408 of file space.cpp.
1408 {
1410 try {
1412 window.loop();
1414 std::cerr << std::format(
"mxvk: Exception: {}\n", e.
text());
1415 return EXIT_FAILURE;
1417 std::cerr << std::format(
"mxvk: Argument Exception: {}\n", e.
text());
1418 return EXIT_FAILURE;
1419 }
1420 return EXIT_SUCCESS;
1421}
Arguments proc_args(int &argc, char **argv)
Parse standard libmx2 command-line options from main()'s argv.
Exception thrown by Argz::proc() on unrecognised or malformed options.
Plain data structure returned by proc_args() with all common libmx2 CLI options.
bool fullscreen
Whether fullscreen mode was requested.
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
int height
Viewport height in pixels (default: 720).
std::string path
Asset root; proc_args() defaults it to the executable directory.
int width
Viewport width in pixels (default: 1280).
◆ ASTEROID_VERTICES
| int ASTEROID_VERTICES = 8 |
|
constexpr |
◆ EXPLOSION_DURATION
| int EXPLOSION_DURATION = 90 |
|
constexpr |
◆ FIRE_COOLDOWN
◆ FIRE_DELAY
◆ GAME_H
◆ GAME_W
◆ LARGE_ASTEROID_POINTS
| int LARGE_ASTEROID_POINTS = 20 |
|
constexpr |
◆ MAX_ASTEROIDS
◆ MAX_PARTICLES
◆ MAX_PROJECTILES
◆ MEDIUM_ASTEROID_POINTS
| int MEDIUM_ASTEROID_POINTS = 50 |
|
constexpr |
◆ MIN_ASTEROID_RADIUS
| float MIN_ASTEROID_RADIUS = 8.0f |
|
constexpr |
◆ PROJECTILE_LIFETIME
| int PROJECTILE_LIFETIME = 60 |
|
constexpr |
◆ PROJECTILE_SPEED
| float PROJECTILE_SPEED = 5.0f |
|
constexpr |
◆ SHOTS_PER_BURST
◆ SMALL_ASTEROID_POINTS
| int SMALL_ASTEROID_POINTS = 100 |
|
constexpr |
◆ STAR_COUNT