23 Commits

Author SHA1 Message Date
hans 7d3f394dcf Added c resize window function
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-09-02 13:26:14 +02:00
hans 9462c58727 Remove Material dependency
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-31 17:26:07 +02:00
hans c36f151585 Somewhat improved map rays
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 23:37:07 +02:00
hans a35dbeddf0 Renamed color -> paintColor
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 23:21:00 +02:00
hans 394b9acf3f Cleaned up data classes
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 23:20:17 +02:00
hans 63c2a1bfa2 More space for the 3d view
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 21:40:16 +02:00
hans 277903ace8 Abstract out math logic and reuse in multiple painters
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 21:10:25 +02:00
hans c83e343dcf Implement ray casting
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 19:59:28 +02:00
hans bdb8b1c67f Added TODO
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 18:49:47 +02:00
hans ce0b2432c6 Fix noisy OS sounds on key presses
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 18:46:28 +02:00
hans 024d60d25a Fix player movement and rotation
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 18:44:46 +02:00
hans 3fee462c35 Draw player position line a bit better
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 17:39:45 +02:00
hans a6911411f9 Draw player dot
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 17:34:28 +02:00
hans d1b99c2af2 Paint the map
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 17:21:48 +02:00
hans 93ba2b8486 Add layout placeholder
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 16:27:41 +02:00
hans 889a3e5c34 Draw background
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 16:20:34 +02:00
hans 6c1b7fac76 Update launch config and use a custom painter
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 15:47:17 +02:00
hans 4b176986b1 Add placeholder Flutter project
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 15:37:29 +02:00
hans 9569c08384 Improved game size rendering
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 15:32:23 +02:00
hans 7402f9da3c Draw floors and ceilings
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 15:10:56 +02:00
hans 7ab8a867fc Allow for more dynamic game sizes
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 14:34:42 +02:00
hans 5520d1e41b Rename some variables for clarity; add variables for game size.
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 14:12:28 +02:00
hans c9d02b3818 Allow changing color of wall based on map value
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2026-08-30 13:53:06 +02:00
36 changed files with 2640 additions and 143 deletions
+52
View File
@@ -1,3 +1,55 @@
!.vscode
**/*.dSYM
raycaster
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/
/android/build/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
# Generated code
*.mapper.dart
*.g.dart
not_translated.txt
+45
View File
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: "6655482ec06e547f90abf8ae7590466f4415978d"
channel: "stable"
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: android
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: ios
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: linux
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: macos
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: web
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
- platform: windows
create_revision: 6655482ec06e547f90abf8ae7590466f4415978d
base_revision: 6655482ec06e547f90abf8ae7590466f4415978d
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
+24 -4
View File
@@ -1,18 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang - Build and debug active file",
"name": "Flutter",
"request": "launch",
"type": "dart"
},
{
"name": "Flutter (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "Flutter (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "Raycaster (C)",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"program": "${workspaceFolder}/raycaster",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang build active file"
"preLaunchTask": "Build raycaster"
}
]
}
+24
View File
@@ -1,6 +1,30 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "Build raycaster",
"command": "/usr/bin/clang",
"args": [
"-g",
"${workspaceFolder}/raycaster.c",
"-o",
"${workspaceFolder}/raycaster",
"-framework",
"OpenGL",
"-framework",
"GLUT",
"-Wno-deprecated-declarations"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Builds raycaster.c explicitly"
},
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
+11
View File
@@ -0,0 +1,11 @@
include: package:arcane_analysis/analysis_options.yaml
analyzer:
exclude:
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**
+791
View File
@@ -0,0 +1,791 @@
import "dart:math" as math;
import "package:flutter/services.dart";
import "package:flutter/widgets.dart";
// dart format off
const List<int> map = [
1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,0,0,0,0,0,1,
1,0,0,0,0,2,0,1,
1,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,
];
// dart format on
const int mapX = 8;
const int mapY = 8;
const int mapSize = 32;
const double gameWidth = 320;
const double gameHeight = 256;
void main() {
runApp(const MainApp());
}
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
RayData rayData = const RayData(
playerAngle: 0,
playerPosition: Offset.zero,
rays: [],
);
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.ltr,
child: LayoutBuilder(
builder: (context, constraints) => Row(
spacing: mapSize / 1,
textDirection: TextDirection.ltr,
children: [
Flexible(
child: Transform.translate(
offset: const Offset(16, 0),
child: Center(
child: FittedBox(
fit: BoxFit.contain,
child: Stack(
children: [
Map(rayData),
Player(
onAngleUpdated: (angle) {
setState(() {
rayData = rayData.copyWith(
playerAngle: angle,
);
});
},
onPositionUpdated: (position) {
setState(() {
rayData = rayData.copyWith(
playerPosition: position,
);
});
},
onRaysUpdated: (rays) {
setState(() {
rayData = rayData.copyWith(
rays: rays,
);
});
},
),
],
),
),
),
),
),
Flexible(
flex: 3,
child: Stack(
children: [
const Background(),
Walls(rayData),
],
),
),
],
),
),
);
}
}
// * Player
class Player extends StatefulWidget {
const new({
required this.onRaysUpdated,
required this.onAngleUpdated,
required this.onPositionUpdated,
super.key,
});
final ValueChanged<List<Ray>> onRaysUpdated;
final ValueChanged<double> onAngleUpdated;
final ValueChanged<Offset> onPositionUpdated;
@override
State<Player> createState() => _PlayerState();
}
class _PlayerState extends State<Player> {
late final FocusNode _focusNode;
double playerAngle = 0;
double get playerDeltaX => math.cos(playerAngle) * 5;
double get playerDeltaY => math.sin(playerAngle) * 5;
Offset get playerDelta => Offset(playerDeltaX, playerDeltaY);
Offset playerPosition = const Offset(1.5 * mapSize, 1.5 * mapSize);
@override
void initState() {
super.initState();
_focusNode = FocusNode()..requestFocus();
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.onRaysUpdated(calculateRays(playerPosition, playerDelta));
widget.onAngleUpdated(playerAngle);
widget.onPositionUpdated(playerPosition);
});
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
List<Ray> calculateRays(Offset offset, Offset delta) {
const double dr = math.pi / 180;
final List<Ray> rays = [];
int dof;
int mx;
int my;
int mapPoint;
double yo = 1;
double xo = 1;
final Offset playerCenter = offset + const Offset(4, 4);
double rayX = 0;
double rayY = 0;
double disT = 0;
double rayAngle = delta.direction - (dr * 30);
if (rayAngle < 0) {
rayAngle += 2 * math.pi;
}
if (rayAngle > 2 * math.pi) {
rayAngle -= 2 * math.pi;
}
int r;
for (r = 0; r < 60; r++) {
// * --- Check Horizontal Lines ---
dof = 0;
double distanceHor = 1000000;
double hx = playerCenter.dx;
double hy = playerCenter.dy;
// Negative inverse of tangent
final double aTan = -1.0 / math.tan(rayAngle);
// ? Looking up (ray angle > π)
if (rayAngle > math.pi) {
rayY = ((playerCenter.dy / mapSize).floorToDouble() * mapSize) - 0.0001;
rayX = (playerCenter.dy - rayY) * aTan + playerCenter.dx;
yo = -mapSize / 1;
xo = -yo * aTan;
}
// ? Looking down
if (rayAngle < math.pi) {
rayY =
((playerCenter.dy / mapSize).floorToDouble() * mapSize) + mapSize;
rayX = (playerCenter.dy - rayY) * aTan + playerCenter.dx;
yo = mapSize / 1;
xo = -yo * aTan;
}
// ? Looking straight left or right
if (rayAngle == 0.0 || rayAngle == math.pi) {
// It's impossible to ever hit a horizontal line
rayX = playerCenter.dx;
rayY = playerCenter.dy;
dof = 8;
}
int mv = 0;
int mh = 0;
while (dof < 8) {
mx = rayX ~/ mapSize;
my = rayY ~/ mapSize;
mapPoint = my * mapX + mx;
if (mapPoint > 0 && mapPoint < mapX * mapY && map[mapPoint] > 0) {
// We hit a wall!
mh = map[mapPoint];
hx = rayX;
hy = rayY;
distanceHor = dist(
playerCenter.dx,
playerCenter.dy,
hx,
hy,
rayAngle,
);
dof = 8;
} else {
rayX += xo;
rayY += yo;
dof += 1;
}
}
// * --- Check Vertical Lines ---
dof = 0;
double distanceVert = 1000000;
double vx = playerCenter.dx;
double vy = playerCenter.dy;
// Negative of tangent
final double nTan = -math.tan(rayAngle);
const double pi2 = math.pi / 2;
const double pi3 = 3 * math.pi / 2;
// ? Looking left
if (rayAngle > pi2 && rayAngle < pi3) {
rayX = ((playerCenter.dx / mapSize).floorToDouble() * mapSize) - 0.0001;
rayY = (playerCenter.dx - rayX) * nTan + playerCenter.dy;
xo = -mapSize / 1;
yo = -xo * nTan;
}
// ? Looking right
if (rayAngle < pi2 || rayAngle > pi3) {
rayX =
((playerCenter.dx / mapSize).floorToDouble() * mapSize) + mapSize;
rayY = (playerCenter.dx - rayX) * nTan + playerCenter.dy;
xo = mapSize / 1;
yo = -xo * nTan;
}
// ? Looking straight up or down
if (rayAngle == pi2 || rayAngle == pi3) {
rayX = playerCenter.dx;
rayY = playerCenter.dy;
dof = 8;
}
while (dof < 8) {
mx = rayX ~/ mapSize;
my = rayY ~/ mapSize;
mapPoint = my * mapX + mx;
if (mapPoint > 0 && mapPoint < mapX * mapY && map[mapPoint] > 0) {
// We hit a wall!
mv = map[mapPoint];
// Save the values and calculate the distance from the player
vx = rayX;
vy = rayY;
distanceVert = dist(
playerCenter.dx,
playerCenter.dy,
vx,
vy,
rayAngle,
);
dof = 8; // Break the loop - no need to calculate more.
} else {
// If we didn't hit a wall, we check the next horizontal line by adding
// the x and y offset.
rayX += xo;
rayY += yo;
dof += 1;
}
}
Color wallColor = const Color.fromRGBO(0, 0, 0, 0);
if (distanceVert < distanceHor) {
rayX = vx;
rayY = vy;
disT = distanceVert;
// Vertical walls are drawn a little brighter than horizontal walls
wallColor = const Color.fromRGBO(230, 0, 0, 1);
if (mv == 2) {
wallColor = const Color.fromRGBO(0, 179, 0, 1);
}
rays.add(Ray(Offset(rayX, rayY), disT, wallColor));
}
if (distanceHor < distanceVert) {
rayX = hx;
rayY = hy;
disT = distanceHor;
// Horizontal walls are drawn a little darker than vertical walls
wallColor = const Color.fromRGBO(179, 0, 0, 1);
if (mh == 2) {
wallColor = const Color.fromRGBO(0, 102, 0, 1);
}
rays.add(Ray(Offset(rayX, rayY), disT, wallColor));
}
// * Increase the ray angle to draw the next ray
rayAngle += dr;
if (rayAngle < 0) {
rayAngle += 2 * math.pi;
}
if (rayAngle > 2 * math.pi) {
rayAngle -= 2 * math.pi;
}
}
return rays;
}
double dist(double ax, double ay, double bx, double by, double ang) {
return math.sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
}
@override
Widget build(BuildContext context) {
// TODO: Use HardwareKeyboard
return Focus(
focusNode: _focusNode,
onKeyEvent: (FocusNode node, value) {
if (value is! KeyDownEvent && value is! KeyRepeatEvent) {
return KeyEventResult.ignored;
}
final LogicalKeyboardKey key = value.logicalKey;
bool handled = false;
if (key == LogicalKeyboardKey.keyA) {
// Move left
playerAngle -= 0.1;
if (playerAngle < 0) {
playerAngle += 2 * math.pi;
}
handled = true;
} else if (key == LogicalKeyboardKey.keyD) {
// Move right
playerAngle += 0.1;
if (playerAngle > 2 * math.pi) {
playerAngle -= 2 * math.pi;
}
handled = true;
} else if (key == LogicalKeyboardKey.keyW) {
// Move forward
playerPosition += playerDelta;
handled = true;
} else if (key == LogicalKeyboardKey.keyS) {
// Move backwwards
playerPosition -= playerDelta;
handled = true;
}
if (handled) {
widget.onRaysUpdated(calculateRays(playerPosition, playerDelta));
widget.onAngleUpdated(playerAngle);
widget.onPositionUpdated(playerPosition);
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},
child: CustomPaint(
painter: PlayerPainter(
offset: playerPosition,
delta: playerDelta,
),
),
);
}
}
class PlayerPainter extends CustomPainter {
final Offset offset;
final Offset delta;
const new({
required this.offset,
required this.delta,
});
@override
void paint(Canvas canvas, Size size) {
// Player dot
canvas.drawRect(
Rect.fromLTWH(offset.dx, offset.dy, 8, 8),
Paint()..color = const Color.fromRGBO(255, 255, 0, 1),
);
// Player direction line
canvas.drawLine(
offset + const Offset(4, 4),
offset + const Offset(4, 4) + (delta * 5),
Paint()
..color = const Color.fromRGBO(255, 255, 0, 1)
..strokeWidth = 2,
);
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
// * Walls
class Walls extends StatelessWidget {
const new(this.rayData, {super.key});
final RayData rayData;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) => ClipRect(
child: CustomPaint(
size: constraints.biggest,
painter: WallPainter(
playerAngle: rayData.playerAngle,
rayData: rayData.rays,
),
),
),
);
}
}
class WallPainter extends CustomPainter {
final double playerAngle;
final List<Ray> rayData;
const new({
required this.playerAngle,
required this.rayData,
});
@override
void paint(Canvas canvas, Size size) {
final double scale = math.max(
size.width / gameWidth,
size.height / gameHeight,
);
final double offsetX = (size.width - gameWidth * scale) / 2;
final double offsetY = (size.height - gameHeight * scale) / 2;
canvas
..save()
..translate(offsetX, offsetY)
..scale(scale);
for (int i = 0; i < rayData.length; i++) {
final Ray ray = rayData[i];
// * --- Draw 3D Walls ---
// Correct the fish-eye effect
const double dr = math.pi / 180;
final double rayAngle = playerAngle - (dr * 30) + (i * dr);
double correctedAngle = playerAngle - rayAngle;
if (correctedAngle < 0) {
correctedAngle += 2 * math.pi;
}
if (correctedAngle > 2 * math.pi) {
correctedAngle -= 2 * math.pi;
}
final double disT = ray.distance * math.cos(correctedAngle);
double lineHeight = (mapSize * gameHeight) / disT;
if (lineHeight > gameHeight) {
lineHeight = gameHeight;
}
if (lineHeight > gameWidth) {
lineHeight = gameWidth;
}
final double lineOffset = (gameHeight / 2.0) - (lineHeight / 2.0);
final double rayWidth = gameWidth / rayData.length;
final double rayX3D = i * rayWidth;
canvas.drawRect(
Rect.fromLTWH(rayX3D, lineOffset, rayWidth, lineHeight),
Paint()
..color = ray.paintColor
..isAntiAlias = false
..strokeWidth = 1.5,
);
}
canvas.restore();
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
// * Map
class Map extends StatelessWidget {
const new(
this.rayData, {
super.key,
});
final RayData rayData;
@override
Widget build(BuildContext context) {
const double width = mapX * mapSize / 1;
const double height = mapY * mapSize / 1;
return Stack(
children: [
const CustomPaint(
size: Size(width, height),
painter: MapPainter(
mapData: map,
mapX: mapX,
mapY: mapY,
tileSize: mapSize / 1,
),
),
CustomPaint(
painter: MapRayPainter(
rayData: rayData,
),
),
],
);
}
}
class MapPainter extends CustomPainter {
final List<int> mapData;
final int mapX;
final int mapY;
final double tileSize;
const new({
required this.mapData,
required this.mapX,
required this.mapY,
required this.tileSize,
});
@override
void paint(Canvas canvas, Size size) {
final paintWhite = Paint()..color = const Color.fromRGBO(255, 255, 255, 1);
final paintBlack = Paint()..color = const Color.fromRGBO(0, 0, 0, 1);
final paintGrey = Paint()..color = const Color.fromRGBO(84, 84, 84, 1);
canvas.drawRect(
Rect.fromLTWH(0, 0, tileSize * mapX, tileSize * mapY),
paintGrey,
);
for (int i = 0; i < mapData.length; i++) {
final double x = (i % mapX) * tileSize;
final double y = (i ~/ mapX) * tileSize;
canvas.drawRect(
Rect.fromLTWH(x, y, tileSize - 1, tileSize - 1),
mapData[i] == 0 ? paintBlack : paintWhite,
);
}
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
class MapRayPainter extends CustomPainter {
final RayData rayData;
const new({
required this.rayData,
});
@override
void paint(Canvas canvas, Size size) {
final Offset playerCenter = rayData.playerPosition + const Offset(4, 4);
for (final Ray ray in rayData.rays) {
canvas.drawLine(
playerCenter,
ray.hitPosition - const Offset(1, 1),
Paint()
..color = const Color.fromRGBO(0, 255, 255, 1)
..strokeWidth = 1,
);
}
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
// * Background
class Background extends StatelessWidget {
const new({
super.key,
});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) => Stack(
textDirection: TextDirection.ltr,
children: [
CustomPaint(
size: constraints.biggest,
painter: Ceiling(),
),
CustomPaint(
size: constraints.biggest,
painter: Floor(),
),
],
),
);
}
}
class Ceiling extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Rect rect = Offset.zero & size;
final double halfHeight = rect.height / 2;
final Rect topHalf = Rect.fromLTWH(
rect.left,
rect.top,
rect.width,
halfHeight,
);
const LinearGradient gradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(32, 32, 32, 1.0),
Color.fromRGBO(96, 96, 96, 1.0),
],
stops: [0.0, 1.0],
);
canvas.drawRect(
topHalf,
Paint()..shader = gradient.createShader(topHalf),
);
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
class Floor extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Rect rect = Offset.zero & size;
final double halfHeight = rect.height / 2;
final Rect bottomHalf = Rect.fromLTWH(
rect.left,
halfHeight,
rect.width,
rect.bottom,
);
const LinearGradient gradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(32, 32, 0, 1.0),
Color.fromRGBO(96, 96, 0, 1.0),
],
stops: [0.0, 1.0],
);
canvas.drawRect(
bottomHalf,
Paint()..shader = gradient.createShader(bottomHalf),
);
}
@override
bool shouldRepaint(covariant oldDelegate) => false;
@override
bool shouldRebuildSemantics(covariant oldDelegate) => false;
}
// * Ray Data
class Ray(
/// Where it hit on the 2D map
var Offset hitPosition,
/// Corrected 3D distance
var double distance,
/// Wall color
var Color paintColor,
);
class RayData {
/// The direction the player is facing
final double playerAngle;
/// The player's position
final Offset playerPosition;
/// The rays cast from the player
final List<Ray> rays;
const RayData({
required this.playerAngle,
required this.playerPosition,
required this.rays,
});
RayData copyWith({
double? playerAngle,
Offset? playerPosition,
List<Ray>? rays,
}) {
return RayData(
playerAngle: playerAngle ?? this.playerAngle,
playerPosition: playerPosition ?? this.playerPosition,
rays: rays ?? this.rays,
);
}
}
+7
View File
@@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/
# Xcode-related
**/dgph
**/xcuserdata/
+1
View File
@@ -0,0 +1 @@
#include "ephemeral/Flutter-Generated.xcconfig"
+1
View File
@@ -0,0 +1 @@
#include "ephemeral/Flutter-Generated.xcconfig"
@@ -0,0 +1,10 @@
//
// Generated file. Do not edit.
//
import FlutterMacOS
import Foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
}
+729
View File
@@ -0,0 +1,729 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objects = {
/* Begin PBXAggregateTarget section */
33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
isa = PBXAggregateTarget;
buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
buildPhases = (
33CC111E2044C6BF0003C045 /* ShellScript */,
);
dependencies = (
);
name = "Flutter Assemble";
productName = FLX;
};
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; };
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 33CC10EC2044A3C60003C045;
remoteInfo = Runner;
};
33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 33CC111A2044C6BA0003C045;
remoteInfo = FLX;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
33CC110E2044A8840003C045 /* Bundle Framework */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Bundle Framework";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* raycaster.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "raycaster.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = "<group>"; };
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = "<group>"; };
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
331C80D2294CF70F00263BE5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10EA2044A3C60003C045 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
331C80D6294CF71000263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
331C80D7294CF71000263BE5 /* RunnerTests.swift */,
);
path = RunnerTests;
sourceTree = "<group>";
};
33BA886A226E78AF003329D5 /* Configs */ = {
isa = PBXGroup;
children = (
33E5194F232828860026EE4D /* AppInfo.xcconfig */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
);
path = Configs;
sourceTree = "<group>";
};
33CC10E42044A3C60003C045 = {
isa = PBXGroup;
children = (
33FAB671232836740065AC1E /* Runner */,
33CEB47122A05771004F2AC0 /* Flutter */,
331C80D6294CF71000263BE5 /* RunnerTests */,
33CC10EE2044A3C60003C045 /* Products */,
D73912EC22F37F3D000D13A0 /* Frameworks */,
);
sourceTree = "<group>";
};
33CC10EE2044A3C60003C045 /* Products */ = {
isa = PBXGroup;
children = (
33CC10ED2044A3C60003C045 /* raycaster.app */,
331C80D5294CF71000263BE5 /* RunnerTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
33CC11242044D66E0003C045 /* Resources */ = {
isa = PBXGroup;
children = (
33CC10F22044A3C60003C045 /* Assets.xcassets */,
33CC10F42044A3C60003C045 /* MainMenu.xib */,
33CC10F72044A3C60003C045 /* Info.plist */,
);
name = Resources;
path = ..;
sourceTree = "<group>";
};
33CEB47122A05771004F2AC0 /* Flutter */ = {
isa = PBXGroup;
children = (
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */,
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
);
path = Flutter;
sourceTree = "<group>";
};
33FAB671232836740065AC1E /* Runner */ = {
isa = PBXGroup;
children = (
33CC10F02044A3C60003C045 /* AppDelegate.swift */,
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
33E51913231747F40026EE4D /* DebugProfile.entitlements */,
33E51914231749380026EE4D /* Release.entitlements */,
33CC11242044D66E0003C045 /* Resources */,
33BA886A226E78AF003329D5 /* Configs */,
);
path = Runner;
sourceTree = "<group>";
};
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
331C80D4294CF70F00263BE5 /* RunnerTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
331C80D1294CF70F00263BE5 /* Sources */,
331C80D2294CF70F00263BE5 /* Frameworks */,
331C80D3294CF70F00263BE5 /* Resources */,
);
buildRules = (
);
dependencies = (
331C80DA294CF71000263BE5 /* PBXTargetDependency */,
);
name = RunnerTests;
productName = RunnerTests;
productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
33CC10EC2044A3C60003C045 /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
33CC10E92044A3C60003C045 /* Sources */,
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
);
buildRules = (
);
dependencies = (
33CC11202044C79F0003C045 /* PBXTargetDependency */,
);
name = Runner;
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
productName = Runner;
productReference = 33CC10ED2044A3C60003C045 /* raycaster.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
33CC10E52044A3C60003C045 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
CreatedOnToolsVersion = 14.0;
TestTargetID = 33CC10EC2044A3C60003C045;
};
33CC10EC2044A3C60003C045 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 1;
};
};
};
33CC111A2044C6BA0003C045 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 33CC10E42044A3C60003C045;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
33CC10EC2044A3C60003C045 /* Runner */,
331C80D4294CF70F00263BE5 /* RunnerTests */,
33CC111A2044C6BA0003C045 /* Flutter Assemble */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
331C80D3294CF70F00263BE5 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10EB2044A3C60003C045 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
};
33CC111E2044C6BF0003C045 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
Flutter/ephemeral/FlutterInputs.xcfilelist,
);
inputPaths = (
Flutter/ephemeral/tripwire,
);
outputFileListPaths = (
Flutter/ephemeral/FlutterOutputs.xcfilelist,
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
331C80D1294CF70F00263BE5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
33CC10E92044A3C60003C045 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
331C80DA294CF71000263BE5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 33CC10EC2044A3C60003C045 /* Runner */;
targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */;
};
33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
33CC10F52044A3C60003C045 /* Base */,
);
name = MainMenu.xib;
path = Runner;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
331C80DB294CF71000263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.raycaster.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/raycaster.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/raycaster";
};
name = Debug;
};
331C80DC294CF71000263BE5 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.raycaster.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/raycaster.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/raycaster";
};
name = Release;
};
331C80DD294CF71000263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.raycaster.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/raycaster.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/raycaster";
};
name = Profile;
};
338D0CE9231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Profile;
};
338D0CEA231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Profile;
};
338D0CEB231458BD00FA5F75 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Manual;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Profile;
};
33CC10F92044A3C60003C045 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
33CC10FA2044A3C60003C045 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
};
33CC10FC2044A3C60003C045 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
33CC10FD2044A3C60003C045 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Release;
};
33CC111C2044C6BA0003C045 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Manual;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
33CC111D2044C6BA0003C045 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
331C80DB294CF71000263BE5 /* Debug */,
331C80DC294CF71000263BE5 /* Release */,
331C80DD294CF71000263BE5 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC10F92044A3C60003C045 /* Debug */,
33CC10FA2044A3C60003C045 /* Release */,
338D0CE9231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC10FC2044A3C60003C045 /* Debug */,
33CC10FD2044A3C60003C045 /* Release */,
338D0CEA231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33CC111C2044C6BA0003C045 /* Debug */,
33CC111D2044C6BA0003C045 /* Release */,
338D0CEB231458BD00FA5F75 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Prepare Flutter Framework Script"
scriptText = "&quot;$FLUTTER_ROOT&quot;/packages/flutter_tools/bin/macos_assemble.sh prepare&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "raycaster.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "raycaster.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "raycaster.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "331C80D4294CF70F00263BE5"
BuildableName = "RunnerTests.xctest"
BlueprintName = "RunnerTests"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "raycaster.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "raycaster.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+13
View File
@@ -0,0 +1,13 @@
import Cocoa
import FlutterMacOS
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
@@ -0,0 +1,68 @@
{
"images" : [
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "app_icon_16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "app_icon_32.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "app_icon_32.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "app_icon_64.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "app_icon_128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "app_icon_256.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "app_icon_256.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "app_icon_512.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "app_icon_512.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "app_icon_1024.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

+343
View File
@@ -0,0 +1,343 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Runner" customModuleProvider="target">
<connections>
<outlet property="applicationMenu" destination="uQy-DD-JDr" id="XBo-yE-nKs"/>
<outlet property="mainFlutterWindow" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="APP_NAME" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="APP_NAME" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About APP_NAME" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide APP_NAME" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit APP_NAME" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="5QF-Oa-p0T">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
<items>
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
<connections>
<action selector="undo:" target="-1" id="M6e-cu-g7V"/>
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
<connections>
<action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
<connections>
<action selector="cut:" target="-1" id="YJe-68-I9s"/>
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
<connections>
<action selector="copy:" target="-1" id="G1f-GL-Joy"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
<connections>
<action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
</connections>
</menuItem>
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
</connections>
</menuItem>
<menuItem title="Delete" id="pa3-QI-u2k">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
<connections>
<action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
<menuItem title="Find" id="4EN-yA-p0u">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Find" id="1b7-l0-nxx">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
<action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
<action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
<action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
<action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<connections>
<action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
<items>
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
<connections>
<action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
</connections>
</menuItem>
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
<connections>
<action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
</connections>
</menuItem>
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="9ic-FL-obx">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
<items>
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
</connections>
</menuItem>
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
</connections>
</menuItem>
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
</connections>
</menuItem>
<menuItem title="Smart Links" id="cwL-P1-jid">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
</connections>
</menuItem>
<menuItem title="Data Detectors" id="tRr-pd-1PS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
</connections>
</menuItem>
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Transformations" id="2oI-Rn-ZJC">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
<items>
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
</connections>
</menuItem>
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
</connections>
</menuItem>
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
<items>
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="-1" id="dU3-MA-1Rq"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="EPT-qC-fAb">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="rJ0-wn-3NY"/>
</menuItem>
</items>
<point key="canvasLocation" x="142" y="-258"/>
</menu>
<window title="APP_NAME" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="MainFlutterWindow" customModule="Runner" customModuleProvider="target">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</window>
</objects>
</document>
+14
View File
@@ -0,0 +1,14 @@
// Application-level settings for the Runner target.
//
// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
// future. If not, the values below would default to using the project name when this becomes a
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = raycaster
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.example.raycaster
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2026 com.example. All rights reserved.
+2
View File
@@ -0,0 +1,2 @@
#include "../../Flutter/Flutter-Debug.xcconfig"
#include "Warnings.xcconfig"
+2
View File
@@ -0,0 +1,2 @@
#include "../../Flutter/Flutter-Release.xcconfig"
#include "Warnings.xcconfig"
+13
View File
@@ -0,0 +1,13 @@
WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
GCC_WARN_UNDECLARED_SELECTOR = YES
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_PRAGMA_PACK = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_COMMA = YES
GCC_WARN_STRICT_SELECTOR_MATCH = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_UNREACHABLE_CODE = YES
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>$(PRODUCT_COPYRIGHT)</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
+15
View File
@@ -0,0 +1,15 @@
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
super.awakeFromNib()
}
}
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
+12
View File
@@ -0,0 +1,12 @@
import Cocoa
import FlutterMacOS
import XCTest
class RunnerTests: XCTestCase {
func testExample() {
// If you add code to the Runner application, consider adding tests here.
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
}
}
+19
View File
@@ -0,0 +1,19 @@
name: raycaster
description: "A new Flutter project."
publish_to: "none"
version: 0.1.0+1
environment:
sdk: ^3.13.1
dependencies:
flutter:
sdk: flutter
dev_dependencies:
arcane_analysis: ^1.0.5
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
+251 -138
View File
@@ -7,14 +7,47 @@
#define PI3 3 * PI / 2
#define DR 0.0174533f // One degree in radians
#define gameWidth 320
#define gameHeight 256
#define GAP 20
#define MAP_WIDTH (mapX * mapSize)
#define MAP_HEIGHT (mapY * mapSize)
#define TOTAL_WIDTH (MAP_WIDTH + GAP + gameWidth)
#define TOTAL_HEIGHT (MAP_HEIGHT > gameHeight ? MAP_HEIGHT : gameHeight)
// 0° => 0 radians (RIGHT)
// 90° => π/2 radians (TOP)
// 180° => π radians (LEFT)
// 270° => 3π/2 radians (BOTTOM)
// 360° => 2π radians (RIGHT)
// * Player position (px, py), delta (pdx, pdy), and angle (pa)
float px, py, pdx, pdy, pa;
// * Define the world
int mapX = 8, mapY = 8, mapSize = 32;
// clang-format off
int map[] =
{
1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,0,0,0,0,0,1,
1,0,0,0,0,2,0,1,
1,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,
};
// clang-format on
// Function to check if a number is a power of 2
int isPowerOfTwo(int n)
{
return (n > 0) && ((n & (n - 1)) == 0);
}
// * Player position (playerX, playerY), delta (playerDeltaX, playerDeltaY), and angle (pa)
float playerX, playerY, playerDeltaX, playerDeltaY, playerAngle;
// * Draw the player on the screen
void drawPlayer()
@@ -23,44 +56,28 @@ void drawPlayer()
glColor3f(1, 1, 0);
glPointSize(8);
glBegin(GL_POINTS);
glVertex2i(px, py);
glVertex2i(playerX, playerY);
glEnd();
// Draws the player direction
glLineWidth(3);
glBegin(GL_LINES);
glVertex2i(px, py);
glVertex2i(px + pdx * 5, py + pdy * 5);
glVertex2i(playerX, playerY);
glVertex2i(playerX + playerDeltaX * 5, playerY + playerDeltaY * 5);
glEnd();
}
// * Define the world
int mapX = 8, mapY = 8, mapS = 64;
// clang-format off
int map[] =
{
1,1,1,1,1,1,1,1,
1,0,1,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,1,0,0,0,0,1,
1,0,0,0,0,0,0,1,
1,0,0,0,0,1,0,1,
1,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,
};
// clang-format on
// * Draws the top-down map with white alls and black floors
void drawMap2D()
{
int gridMapSize = mapSize;
int x, y, xo, yo;
for (y = 0; y < mapY; y++)
{
for (x = 0; x < mapX; x++)
{
// Check if it's a wall (e.g., 1)
if (map[y * mapX + x] == 1)
// Check if it's a wall
if (map[y * mapX + x] > 0)
{
// Color walls (white)
glColor3f(1, 1, 1);
@@ -71,15 +88,15 @@ void drawMap2D()
glColor3f(0, 0, 0);
}
xo = x * mapS;
yo = y * mapS;
xo = x * gridMapSize;
yo = y * gridMapSize;
glBegin(GL_QUADS);
// Draw each block; the +-1 creates the outline
glVertex2i(xo + 1, yo + 1);
glVertex2i(xo + 1, yo + mapS - 1);
glVertex2i(xo + mapS - 1, yo + mapS - 1);
glVertex2i(xo + mapS - 1, yo + 1);
glVertex2i(xo + 1, yo + gridMapSize - 1);
glVertex2i(xo + gridMapSize - 1, yo + gridMapSize - 1);
glVertex2i(xo + gridMapSize - 1, yo + 1);
glEnd();
}
}
@@ -96,10 +113,20 @@ float dist(float ax, float ay, float bx, float by, float ang)
// * The actual raycaster
void drawRays3D()
{
int r, mx, my, mp, dof;
int r, mx, my, mapPoint, dof;
int gridMapSize = mapSize;
// Ensure mapSize is a power of 2, otherwise default or handle error
if (!isPowerOfTwo(mapSize))
{
fprintf(stderr, "Error: mapSize must be a power of 2 (e.g., 16, 32, 64, 128).\n");
exit(1);
}
int shiftSize = (int)(log2f((float)mapSize));
// Ray x, y, angle
float rx, ry, ra;
float rayX, rayY, rayAngle;
float xo, yo;
@@ -108,16 +135,16 @@ void drawRays3D()
// Let's initialize the ray angle n degrees from the player's facing position
// ra = ray angle; pa = player angle; DR = degree radian; n = degrees to use
ra = pa - DR * 30;
rayAngle = playerAngle - DR * 30;
// Make sure to limit the next angle
if (ra < 0)
if (rayAngle < 0)
{
ra += 2 * PI;
rayAngle += 2 * PI;
}
if (ra > 2 * PI)
if (rayAngle > 2 * PI)
{
ra -= 2 * PI;
rayAngle -= 2 * PI;
}
// * Cast n rays
@@ -129,55 +156,57 @@ void drawRays3D()
// We need to get the shortest ray cast in either the vertical or horizontal
// distance. So, we'll set a default that's way higher than we'll ever
// calculate, and save the horizontal ray's X and Y position.
float disH = 1000000, hx = px, hy = py;
float distanceHor = 1000000, hx = playerX, hy = playerY;
// Negative inverse of tangent
float aTan = -1.0f / tanf(ra);
float aTan = -1.0f / tanf(rayAngle);
// Check if the ray is looking up or down.
// If it's less than π (e.g., 180°), we're looking down.
// ? Looking up (ray angle > π)
if (ra > PI)
if (rayAngle > PI)
{
// Round the ray's Y position to the nearest 64th value.
// We can do this by bit-shifting down by 6, then bit-shifting back up by
// 6. Then, we subtract a small amount for accuracy.
ry = (((int)py >> 6) << 6) - 0.0001f;
// We can do this by bit-shifting down by `shiftSize`, then bit-shifting back up by
// `shiftSize`. Then, we subtract a small amount for accuracy.
rayY = (((int)playerY >> shiftSize) << shiftSize) - 0.0001f;
// The ray's X value is the distance between the player and the ray's Y
// position, times the inverse of tangent, plus the player's X position.
rx = (py - ry) * aTan + px;
rayX = (playerY - rayY) * aTan + playerX;
// Now that we have the ray's first grid intersection position, we need
// the next X and Y offset for the second grid intersection point.
yo = -64;
yo = -gridMapSize;
xo = -yo * aTan;
}
// ? Looking down
if (ra < PI)
if (rayAngle < PI)
{
// This is almost exactly the same as looking up, but we add one grid
// unit, instead of subtracting a tiny amount.
ry = (((int)py >> 6) << 6) + 64;
rayY = (((int)playerY >> shiftSize) << shiftSize) + gridMapSize;
rx = (py - ry) * aTan + px;
rayX = (playerY - rayY) * aTan + playerX;
// This is almost exactly the same as looking up, but we add instead of
// subtract.
yo = 64;
yo = gridMapSize;
xo = -yo * aTan;
}
// ? Looking straight left or right
if (ra == 0.0f || ra == PI)
if (rayAngle == 0.0f || rayAngle == PI)
{
// It's impossible to ever hit a horizontal line
rx = px;
ry = py;
rayX = playerX;
rayY = playerY;
}
int mv = 0, mh = 0;
// ? We don't want to get caught in an infinite loop, so use the
// depth-of-field to limit our check to a max of 8.
while (dof < 8)
@@ -186,21 +215,23 @@ void drawRays3D()
// to know where that is in the map array.
// Let's take the ray hit position (rx,ry) and divide it by 64 (bit-shift
// 6 places), and use that to find the position in the map's array.
mx = (int)(rx) >> 6;
my = (int)(ry) >> 6;
mp = my * mapX + mx;
mx = (int)(rayX) >> shiftSize;
my = (int)(rayY) >> shiftSize;
mapPoint = my * mapX + mx;
// If the map position is less than the array's size, then we can check it
// inside the map. If the value is 1, there's a wall. If we hit a wall,
// we're done!
if (mp > 0 && mp < mapX * mapY && map[mp] == 1)
if (mapPoint > 0 && mapPoint < mapX * mapY && map[mapPoint] > 0)
{
// We hit a wall!
mh = map[mapPoint];
// Save the values and calculate the distance from the player
hx = rx;
hy = ry;
disH = dist(px, py, hx, hy, ra);
hx = rayX;
hy = rayY;
distanceHor = dist(playerX, playerY, hx, hy, rayAngle);
dof = 8; // Break the loop - no need to calculate more.
}
@@ -208,42 +239,42 @@ void drawRays3D()
{
// If we didn't hit a wall, we check the next horizontal line by adding
// the x and y offset.
rx += xo;
ry += yo;
rayX += xo;
rayY += yo;
dof += 1;
}
}
// * --- Check Vertical Lines ---
dof = 0;
float disV = 1000000, vx = px, vy = py;
float distanceVert = 1000000, vx = playerX, vy = playerY;
// Negative of tangent
float nTan = -tanf(ra);
float nTan = -tanf(rayAngle);
// ? Looking left
if (ra > PI2 && ra < PI3)
if (rayAngle > PI2 && rayAngle < PI3)
{
rx = (((int)px >> 6) << 6) - 0.0001f;
ry = (px - rx) * nTan + py;
xo = -64;
rayX = (((int)playerX >> shiftSize) << shiftSize) - 0.0001f;
rayY = (playerX - rayX) * nTan + playerY;
xo = -gridMapSize;
yo = -xo * nTan;
}
// ? Looking right
if (ra < PI2 || ra > PI3)
if (rayAngle < PI2 || rayAngle > PI3)
{
rx = (((int)px >> 6) << 6) + 64;
ry = (px - rx) * nTan + py;
xo = 64;
rayX = (((int)playerX >> shiftSize) << shiftSize) + gridMapSize;
rayY = (playerX - rayX) * nTan + playerY;
xo = gridMapSize;
yo = -xo * nTan;
}
// ? Looking straight up or down
if (ra == 0.0f || ra == PI)
if (rayAngle == 0.0f || rayAngle == PI)
{
rx = px;
ry = py;
rayX = playerX;
rayY = playerY;
}
while (dof < 8)
@@ -252,21 +283,23 @@ void drawRays3D()
// to know where that is in the map array.
// Let's take the ray hit position (rx,ry) and divide it by 64 (bit-shift
// 6 places), and use that to find the position in the map's array.
mx = (int)(rx) >> 6;
my = (int)(ry) >> 6;
mp = my * mapX + mx;
mx = (int)(rayX) >> shiftSize;
my = (int)(rayY) >> shiftSize;
mapPoint = my * mapX + mx;
// If the map position is less than the array's size, then we can check it
// inside the map. If the value is 1, there's a wall. If we hit a wall,
// we're done!
if (mp > 0 && mp < mapX * mapY && map[mp] == 1)
if (mapPoint > 0 && mapPoint < mapX * mapY && map[mapPoint] > 0)
{
// We hit a wall!
mv = map[mapPoint];
// Save the values and calculate the distance from the player
vx = rx;
vy = ry;
disV = dist(px, py, vx, vy, ra);
vx = rayX;
vy = rayY;
distanceVert = dist(playerX, playerY, vx, vy, rayAngle);
dof = 8; // Break the loop - no need to calculate more.
}
@@ -274,8 +307,8 @@ void drawRays3D()
{
// If we didn't hit a wall, we check the next horizontal line by adding
// the x and y offset.
rx += xo;
ry += yo;
rayX += xo;
rayY += yo;
dof += 1;
}
}
@@ -284,95 +317,163 @@ void drawRays3D()
// This is what actually determines our ray that hits a wall!
// Vertical wall hit
if (disV < disH)
if (distanceVert < distanceHor)
{
rx = vx;
ry = vy;
disT = disV;
rayX = vx;
rayY = vy;
disT = distanceVert;
// Vertical walls are drawn a little brighter than horizontal walls
glColor3f(0.9, 0, 0);
if (mv == 2)
{
glColor3f(0, 0, 0.7);
}
}
// Horizontal wall hit
if (disH < disV)
if (distanceHor < distanceVert)
{
rx = hx;
ry = hy;
disT = disH;
rayX = hx;
rayY = hy;
disT = distanceHor;
// Horizontal walls are drawn a little darker than vertical walls
glColor3f(0.7, 0, 0);
if (mh == 2)
{
glColor3f(0, 0, 0.4);
}
}
// * Draw the ray
glLineWidth(3);
glBegin(GL_LINES);
glVertex2i(px, py);
glVertex2i(rx, ry);
glVertex2i(playerX, playerY);
glVertex2i(rayX, rayY);
glEnd();
// * --- Draw 3D Walls ---
// Correct the fish-eye effect
float ca = pa - ra;
if (ra < 0)
float correctedAngle = playerAngle - rayAngle;
if (correctedAngle < 0)
{
ra += 2 * PI;
correctedAngle += 2 * PI;
}
if (ra > 2 * PI)
if (correctedAngle > 2 * PI)
{
ra -= 2 * PI;
correctedAngle -= 2 * PI;
}
disT = disT * cos(ca);
disT = disT * cos(correctedAngle);
// The window will be 320x160 px
// The formula for each line height will be the cube size (64) times our
// screen height (320), divided by the ray distance (disT).
// screen height, divided by the ray distance (disT).
// The further away, the larger the distance and the shorter the final line
// height will be.
float lineH = (mapS * 320) / disT;
float lineHeight = (mapSize * gameHeight) / disT;
if (lineHeight > gameHeight)
{
lineHeight = gameHeight;
}
// Let's make sure the line doesn't exceed our vertical space, so we cap it
if (lineHeight > gameWidth)
{
lineHeight = gameWidth;
}
// We need to offset the line to the middle of the screen
// That's the full window height, minus half the line height
float lineO = 160 - lineH / 2;
float lineOffset = (gameHeight / 2.0f) - (lineHeight / 2.0f);
// Let's make sure the line doesn't exceed our vertical space, so we cap it
if (lineH > 320)
{
lineH = 320;
}
// Calculate dynamic column width and horizontal starting offset
float rayWidth = (float)gameWidth / 60.0f;
float rayX3D = MAP_WIDTH + GAP + (r * rayWidth);
// * Draw the "wall" line
glLineWidth(8);
glBegin(GL_LINES);
// Draw the line every 8th pixel, and shift the viewport to the right by 530
glVertex2i(r * 8 + 530, lineO);
glVertex2i(r * 8 + 530, lineH + lineO);
// Draw solid wall column using QUADS instead of GL_LINES
glBegin(GL_QUADS);
glVertex2f(rayX3D, lineOffset);
glVertex2f(rayX3D + rayWidth, lineOffset);
glVertex2f(rayX3D + rayWidth, lineOffset + lineHeight);
glVertex2f(rayX3D, lineOffset + lineHeight);
glEnd();
// * Increase the ray angle to draw the next ray
ra += DR;
if (ra < 0)
rayAngle += DR;
if (rayAngle < 0)
{
ra += 2 * PI;
rayAngle += 2 * PI;
}
if (ra > 2 * PI)
if (rayAngle > 2 * PI)
{
ra -= 2 * PI;
rayAngle -= 2 * PI;
}
}
}
// * Draw ceiling
void drawCeiling()
{
float halfHeight = (float)(gameHeight / 2);
glBegin(GL_QUADS);
for (float distance = 0; distance < halfHeight; distance += 1.0f)
{
// Normalize color from 0.0 to 1.0 based on distance, multiplied by relative intensity
float colorIntensity = 0.5f + (distance / halfHeight);
glColor3f(0.25 * colorIntensity, 0.25 * colorIntensity, 0.25 * colorIntensity);
// Draw a horizontal strip at the current distance
glVertex2f(MAP_WIDTH + GAP, distance);
glVertex2f(MAP_WIDTH + GAP, distance + 1.0f);
glVertex2f(TOTAL_WIDTH, distance + 1.0f);
glVertex2f(TOTAL_WIDTH, distance);
}
glEnd();
}
// * Draw floor
void drawFloor()
{
float halfHeight = (float)(gameHeight / 2);
glBegin(GL_QUADS);
for (float distance = 0; distance < halfHeight; distance += 1.0f)
{
float colorIntensity = 0.5f + (distance / halfHeight);
glColor3f(0.25 * colorIntensity, 0.25 * colorIntensity, 0.0f);
float y = halfHeight + distance;
glVertex2f(MAP_WIDTH + GAP, y);
glVertex2f(MAP_WIDTH + GAP, y + 1.0f);
glVertex2f(TOTAL_WIDTH, y + 1.0f);
glVertex2f(TOTAL_WIDTH, y);
}
glEnd();
}
// * Main rendering
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawCeiling();
drawFloor();
drawMap2D();
drawRays3D();
drawPlayer();
glutSwapBuffers();
}
void resize(int w, int h)
{
glutReshapeWindow(1024, 512);
}
// * Check for key presses and move the "player" accordingly
void buttons(unsigned char key, int x, int y)
{
@@ -385,32 +486,32 @@ void buttons(unsigned char key, int x, int y)
// 0° -> 360° ≈ 0 -> ~6.28
// Change player angle slightly (using radians)
pa -= 0.1;
playerAngle -= 0.1;
// If player angle drops below 0, let's reset back to 2π
if (pa < 0)
if (playerAngle < 0)
{
pa += 2 * PI;
playerAngle += 2 * PI;
}
// The values returned from sin() and cos() are very small, so we'll just
// artificialy inflate them by multilying by 5. This is our actual movement.
pdx = cos(pa) * 5.0f;
pdy = sin(pa) * 5.0f;
playerDeltaX = cos(playerAngle) * 5.0f;
playerDeltaY = sin(playerAngle) * 5.0f;
}
// ? Move right
if (key == 'd')
{
pa += 0.1;
playerAngle += 0.1;
if (pa > 2 * PI)
if (playerAngle > 2 * PI)
{
pa -= 2 * PI;
playerAngle -= 2 * PI;
}
pdx = cos(pa) * 5.0f;
pdy = sin(pa) * 5.0f;
playerDeltaX = cos(playerAngle) * 5.0f;
playerDeltaY = sin(playerAngle) * 5.0f;
}
// ? Move forward
@@ -418,41 +519,50 @@ void buttons(unsigned char key, int x, int y)
{
// We change the X and Y values based on our delta, which is calculated
// during our rotation.
px += pdx;
py += pdy;
playerX += playerDeltaX;
playerY += playerDeltaY;
}
// ? Move backwards
if (key == 's')
{
px -= pdx;
py -= pdy;
playerX -= playerDeltaX;
playerY -= playerDeltaY;
}
glutPostRedisplay();
}
void init()
{
// Sets the screen to the given color (grey)
glClearColor(0.3, 0.3, 0.3, 0);
// Sets the window to be 2D at a given size
gluOrtho2D(0, 1024, 512, 0);
// gluOrtho2D(0, 1024, 512, 0);
gluOrtho2D(0, TOTAL_WIDTH, TOTAL_HEIGHT, 0);
// Set the initial player location
px = 300;
py = 300;
// Spawn player centered in grid tile (1, 1)
playerX = 1.5f * mapSize;
playerY = 1.5f * mapSize;
playerAngle = 0;
// Calculate the initial player deltaX and deltaY
pdx = cos(pa) * 5.0f;
pdy = sin(pa) * 5.0f;
playerDeltaX = cos(playerAngle) * 5.0f;
playerDeltaY = sin(playerAngle) * 5.0f;
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(1024, 512);
// glutInitWindowSize(TOTAL_WIDTH, TOTAL_HEIGHT);
glutInitWindowSize(1024, 510);
// Initialize the window to the center of the screen
glutInitWindowPosition(200, 200);
glutCreateWindow("Raycaster");
init();
@@ -460,6 +570,9 @@ int main(int argc, char *argv[])
// Send display parameters to the display function
glutDisplayFunc(display);
// Handle window resizes
glutReshapeFunc(resize);
// Send key presses to the keyboard function
glutKeyboardFunc(buttons);