Simple Wolfenstein 3D clone written in Swift

Overview

Travis Swift 4.2 License Twitter

Screenshot

Mein Leben!

Swiftenstein is a partial reimplementation of ID Software's 1992 classic FPS Wolfenstein 3D in Swift for iOS. It is not a complete game, just a single-level tech demo.

It's also not a completely faithful recreation of the original game engine - I've deliberately removed some features and added others that weren't in the original, but it should be close enough for nostalgia purposes.

For copyright reasons, I've redrawn (badly) the Wolfenstein wall textures and sprites, but if you would prefer to use Adrian Carmack's original graphics, a web search for "Wolfenstein sprites" should provide a good starting point.

This code is not particularly polished or well-structured. I wrote it as a learning exercise and am releasing it for educational purposes. I may improve it in future, or I may not. If you feel like improving it yourself, please open a PR.

How to Play

The game can be played one-handed in either portrait or landscape orientation. The entire screen acts as a virtual thumbstick for turning left/right and moving forwards/backwards (there's no strafing support as yet). Tap anywhere to fire.

If you have a phone with 3D Touch support you can force-touch to autofire. Otherwise you'll need to tap repeatedly.

Enemies are placed randomly, so if you're unlucky you may be shot in the back immediately when the game starts. You have limited health and ammo, but if you turn right at the start you'll see a submachine gun that should help your chances of survival.

There are a couple of secret sliding pushwalls - see if you can find them. Be careful not to accidentally crush yourself to death!

Find the elevator switch to complete the level. Once you flip the switch, the level will reset.

How it Works

In 1992 there were no 3D graphics cards, and no standard 3D graphics APIs like OpenGL or DirectX. Wolfenstein's engine had to draw every pixel to the screen manually using a technique called ray casting.

Swiftenstein replicates this technique. All drawing is done by manipulating an array of ARGB pixel values, which is then finally turned into a UIImage and displayed in a UIImageView.

On a modern system, this is absolutely not the right way to implement 3D graphics. From a performance and battery-life point of view, this is a terrible way to put pixels on the screen, and you should instead take advantage of dedicated 3D rendering hardware in the GPU (using SceneKit or Metal).

But ray casting is a pretty cool technique to learn all the same, with applications beyond graphics rendering. For example, Swiftenstein re-uses the same ray casting logic for bullet hit detection, hidden object culling and line-of-sight tests between enemies and player, and this would still be applicable even if the game used a modern GPU-based renderer.

If you want to learn more about ray casting, I recommend Fabian Sanglard's excellent Wolfenstein 3D Game Engine Black Book and also Lode Vandevenne's amazing Raycasting tutorial series.

You might also like...
Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it.
Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it.

WishList Tracking: An exploration with SwiftUI Simple iOS app written with SwiftUI (and, of course, Swift) to begin exploring it. Goal: Get used to Vi

Todo-list - Simple todo list app written in Swift

About TodoApp TodoApp is sinmple todo list app that I created in my free time, i

Simple RSS reader app written in Swift

Feeds4U Simple RSS reader app written in Swift. Contributions All PRs should be directed to 'develop' branch. Important Note Use code as you wish. Don

Stopwatches - Simple multiple stopwatch app written in SwiftUI
Stopwatches - Simple multiple stopwatch app written in SwiftUI

Stopwatches ⏱️ ⏱️ ⏱️ Log the time you take to do something. Use it for studying,

Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.
Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

Nudge is application for enforcing macOS updates, written in Swift
Nudge is application for enforcing macOS updates, written in Swift

Nudge (macadmin's Slack #nudge) Nudge is application for enforcing macOS updates, written in Swift 5.5 and SwiftUI 5.2. In order to use the newest fea

A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

NES - NES emulator, written in Swift

Swift NES NES emulator, written in Swift. NESKit: Emulator core. License GPL v3.

A open source Swift app for iOS 13 that allows you to check your NFC transit card information. Written with SwiftUI.
A open source Swift app for iOS 13 that allows you to check your NFC transit card information. Written with SwiftUI.

ABANDONED Metrodroid, which TransitPal was heavily inspired by, now has its own fully functional iOS app! It should be in the App Store "soon". I stro

Owner
Nick Lockwood
Nick Lockwood
Instagram clone with firebase and swift

Instagram clone with firebase and swift

Murat Çiçek 1 Nov 20, 2021
Twitter Clone With Swift

Project 3 - Twitter App Part 1 *Twitter Clone is a basic twitter app to read your tweets. Time spent: 3 hours spent in total User Stories The followin

null 0 Dec 20, 2021
CloneNetflix - A Netflix Clone application with swift

CloneNetflix - A Netflix Clone application with swift

유정모 1 Mar 16, 2022
🎬 Netflix Clone 🔥 Made using UIKit with Swift language.

Made using UIKit with Swift language. Core Data was used as the local database. Tmdb and youtube api were used for the API.

Ferhat İltaş 17 Sep 16, 2022
Kinopoisk clone iOS app using Swift, TMDb API, Youtube API and SDWebImage.

?? Kinopoisk clone iOS app using Swift, TMDb API, Youtube API and SDWebImage. App mainly developed to learn about Swift(UIKit), working with JSON, using MVVM architectural pattern.

ofigensky 1 Aug 20, 2022
A shameless clone of iOS stock calculator app.

CalClone A shameless clone of iOS stock calculator app. Starting Requirements Xcode 13 Runing Not requires any specific steps, clone and run. git clon

Kemal Sanlı 1 Jun 3, 2022
Trello Clone iOS App build with SwiftUI

Trello Clone iOS App - SwiftUI A Trello Clone App for iOS built with SwiftUI. Features The app has several main features: Card, BoardList CRUD. Drag a

Alfian Losari 72 Oct 28, 2022
A detailed clone of the Instagram app built with Firebase

[This repository is no longer being maintained] InstagramClone A detailed clone

null 0 Dec 26, 2021
The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app.

The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app. It has Messages-like bubble and screen effects, reactions, and animations, all created with SwiftUI.

Stream 20 Dec 24, 2022
CultureCenter Netflix Clone Coding Dodo-Jayden

Netflix_CloneCoding CultureCenter Netflix Clone Coding Dodo-Jayden Git Commit Message 제목 50자이내 단어 형태로 종결 [작업태그] 작업사항 본문 80자 이내 단어 형태로 종결 작업 사항 설명 ex)

null 2 Jul 2, 2022