nicklockwood / retrorampage Goto Github PK
View Code? Open in Web Editor NEWTutorial series demonstrating how to build a retro first-person shooter from scratch in Swift
License: Other
Tutorial series demonstrating how to build a retro first-person shooter from scratch in Swift
License: Other
Hi and thanks for this awesome tutorial! It's a great project and I really like how you're presenting it.
I've run into a problem a bunch of times though that i really dont get. I'm somewhere in the beginning of part 3 now and i'm told to enter
player.direction = input.velocity / length in world.update.
byt that gives me the error
Operator argument #2 must precede operator argument #1
I've gotten this a few times before and then i've been able to flip it around since it's been multiplication. This time however it's division so i can't flip it.
I've googled the error without finding anything but I'm pretty new to coding so maybe it's just me...
Weird thing happened:
I finished part 2 of this (awesome!) tutorial & had a weird feeling about how fast my "character" (blue box) was moving.
So I downloaded the source code for part 2 & just ran it on my iPhone.
And for some weird reason, the "character" in the game built from github source moves almost half the speed...
I checked the code and ignoring some added whitespace, my code & github source are identical. Same constants, same functions, same everything - I followed the tutorial step by step & copy/pasted everything as instructed.
Here are the screen recordings comparing my "version" & the source:
Archive.zip
P.S.: I'm not sure this is really an issue in the github sense - sorry if it isn't ๐
P.P.S.: I'll compare all the files again first thing in the morning - there is a chance I missed something, but I'm pretty sure I didn't (I wouldn't be opening an issue otherwise)
Hello Nick,
in Part 1 - Ready Player One - you say you should create a new Player.swift file.
You didn't specify the location. I put it inside Engine after looking at the provided source code.
Just a tiny thing I stumbled upon ๐. I am really enjoying your tutorial so far - thank you very much!
BR Denise
I'm absolutely loving this series! Thanks so much. ๐๐ป
I stumbled through this part of the update [line 495], and just wanted to let you know.
Now, in the Monster.update()
method, modify the state machine again to swap the animations:
switch monster.state {
case .idle:
if monster.canSeePlayer(in: self) {
state = .chasing
animation = .monsterWalk
}
case .chasing:
guard monster.canSeePlayer(in: self) else {
state = .idle
animation = .monsterIdle
break
}
...
}
I changed it so it would compile (leaving the velocity intact for now) :
mutating func update(in world: World) {
switch state {
/// all the monster needs to do is wait until it sees the player.
/// That means we need a method to detect if the monster can see the player
/// since they always face the player, just check if there is a wall between them
case .idle:
if canSeePlayer(in: world) {
state = .chasing
animation = .monsterWalk
}
velocity = Vector(x: 0, y: 0)
case .chasing:
guard canSeePlayer(in: world) else {
state = .idle
animation = .monsterIdle
break
}
let direction = world.player.position - position
velocity = direction * (speed / direction.length)
}
}
Thanks for the tutorial, really enjoying it.
One correction/note on part 5. According to footnote 1:
Long before modern GPU technology, consoles such as the SNES included built-in support for scaling and rotating sprites instead of just moving them around.
The SNES Mode 7 could only scale/rotate backgrounds - specifically not sprites. See the linked https://en.wikipedia.org/wiki/Mode_7#Limits:
Mode 7 can only work on backgrounds, not sprites; therefore, any object that does not rotate or scale with the background must be a sprite, even items that would normally be thought of as part of the background, such as fixed platforms.
While mode 7 is still relevant/interesting, sprites were used in the same way you describe them for enemies and items in Wolf3D. For example, Super Mario Kart uses Mode 7 to scale/rotate the course as a background, but the characters in their karts are sprites pre-drawn at different sizes/angles. Later games that included specialized DSP chips were able to sprite scaling/rotation, but that's not Mode 7 and not built in to the console :).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.