This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Map: Codable { | |
let width, height: Int | |
var cells: [Tile] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Conversions | |
// | |
// Created by Maarten Engels on 11/10/2019. | |
// Copyright © 2019 thedreamweb. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// RockPaperScissers | |
// | |
// Created by Maarten Engels on 19/10/2019. | |
// Copyright © 2019 thedreamweb. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Word Scramble | |
// | |
// Created by Maarten Engels on 23/10/2019. | |
// Copyright © 2019 thedreamweb. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Habits | |
// | |
// Created by Maarten Engels on 09/11/2019. | |
// Copyright © 2019 thedreamweb. All rights reserved. | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can set the Swift version to what you need for your app. Versions can be found here: https://hub.docker.com/_/swift | |
FROM swift:5.1 as builder | |
# For local build, add `--build-arg env=docker` | |
# In your application, you can use `Environment.custom(name: "docker")` to check if you're in this env | |
ARG env | |
RUN apt-get -qq update && apt-get install -y \ | |
libssl-dev zlib1g-dev \ | |
&& rm -r /var/lib/apt/lists/* | |
WORKDIR /app | |
COPY . . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple way to get Codable comformance for [Any] and [String: Any] types, | |
// where Any can be any basic type as well as nested arrays and dictionaries. | |
// | |
// Use: | |
// let associativeStorage = [String: Any]() | |
// First wrap it | |
// let wrappedAssociativeStorage = try AnyWrapper.wrapperFor(associativeStorage) | |
// Then encode it using: | |
// let data = try encoder.encode(associativeStorage) | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Shadowcasting | |
/// Based on the explanation and Dart code: https://journal.stuffwithstuff.com/2015/09/07/what-the-hero-sees/ | |
/// Translated to Swift | |
private func transformOctant(row: Int, col: Int, octant: Int) -> Vector { | |
switch octant { | |
case 0: | |
return Vector( x: col, y: -row) | |
case 1: | |
return Vector( x: row, y: -col) | |
case 2: |