-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d96a5d
commit 5e6d652
Showing
27 changed files
with
383 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Pickup.swift | ||
// Engine | ||
// | ||
// Created by Nick Lockwood on 27/01/2020. | ||
// Copyright © 2020 Nick Lockwood. All rights reserved. | ||
// | ||
|
||
public enum PickupType { | ||
case medkit | ||
case shotgun | ||
} | ||
|
||
public struct Pickup: Actor { | ||
public let type: PickupType | ||
public var radius: Double = 0.5 | ||
public var position: Vector | ||
|
||
public init(type: PickupType, position: Vector) { | ||
self.type = type | ||
self.position = position | ||
} | ||
} | ||
|
||
public extension Pickup { | ||
var isDead: Bool { return false } | ||
|
||
var texture: Texture { | ||
switch type { | ||
case .medkit: | ||
return .medkit | ||
case .shotgun: | ||
return .shotgunPickup | ||
} | ||
} | ||
|
||
func billboard(for ray: Ray) -> Billboard { | ||
let plane = ray.direction.orthogonal | ||
return Billboard( | ||
start: position - plane / 2, | ||
direction: plane, | ||
length: 1, | ||
texture: texture | ||
) | ||
} | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,6 @@ public enum Thing: Int, Decodable { | |
case door | ||
case pushwall | ||
case `switch` | ||
case medkit | ||
case shotgun | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// Weapon.swift | ||
// Engine | ||
// | ||
// Created by Nick Lockwood on 07/02/2020. | ||
// Copyright © 2020 Nick Lockwood. All rights reserved. | ||
// | ||
|
||
public enum Weapon: Int { | ||
case pistol | ||
case shotgun | ||
} | ||
|
||
public extension Weapon { | ||
struct Attributes { | ||
let idleAnimation: Animation | ||
let fireAnimation: Animation | ||
let fireSound: SoundName | ||
let damage: Double | ||
let cooldown: Double | ||
let projectiles: Int | ||
let spread: Double | ||
let defaultAmmo: Double | ||
} | ||
|
||
var attributes: Attributes { | ||
switch self { | ||
case .pistol: | ||
return Attributes( | ||
idleAnimation: .pistolIdle, | ||
fireAnimation: .pistolFire, | ||
fireSound: .pistolFire, | ||
damage: 10, | ||
cooldown: 0.25, | ||
projectiles: 1, | ||
spread: 0, | ||
defaultAmmo: .infinity | ||
) | ||
case .shotgun: | ||
return Attributes( | ||
idleAnimation: .shotgunIdle, | ||
fireAnimation: .shotgunFire, | ||
fireSound: .shotgunFire, | ||
damage: 50, | ||
cooldown: 0.5, | ||
projectiles: 5, | ||
spread: 0.4, | ||
defaultAmmo: 5 | ||
) | ||
} | ||
} | ||
} | ||
|
||
public extension Animation { | ||
static let pistolIdle = Animation(frames: [ | ||
.pistol | ||
], duration: 0) | ||
static let pistolFire = Animation(frames: [ | ||
.pistolFire1, | ||
.pistolFire2, | ||
.pistolFire3, | ||
.pistolFire4, | ||
.pistol | ||
], duration: 0.5) | ||
static let shotgunIdle = Animation(frames: [ | ||
.shotgun | ||
], duration: 0) | ||
static let shotgunFire = Animation(frames: [ | ||
.shotgunFire1, | ||
.shotgunFire2, | ||
.shotgunFire3, | ||
.shotgunFire4, | ||
.shotgun | ||
], duration: 0.5) | ||
} |
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
Oops, something went wrong.