Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from cs3217-2324/feat/player-interactions
feat: Player Jump
- Loading branch information
Showing
31 changed files
with
278 additions
and
121 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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import CoreGraphics | ||
|
||
public protocol SDSceneDelegate: AnyObject { | ||
|
||
func update(_ scene: SDScene, deltaTime: Double) | ||
func contactOccured(objectA: SDObject, objectB: SDObject) | ||
func contactOccured(objectA: SDObject, objectB: SDObject, contactPoint: CGPoint) | ||
} |
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
24 changes: 24 additions & 0 deletions
24
star-dash/star-dash/Events/ContactEvents/PlayerFloorContactEvent.swift
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,24 @@ | ||
import Foundation | ||
import CoreGraphics | ||
|
||
class PlayerFloorContactEvent: Event { | ||
let timestamp: Date | ||
let entityId: EntityId | ||
let contactPoint: CGPoint | ||
|
||
init(from playerEntityId: EntityId, at contactPoint: CGPoint) { | ||
self.timestamp = Date.now | ||
self.entityId = playerEntityId | ||
self.contactPoint = contactPoint | ||
} | ||
|
||
func execute(on target: EventModifiable) { | ||
guard let positionComponent = target.component(ofType: PositionComponent.self, ofEntity: entityId), | ||
let playerComponent = target.component(ofType: PlayerComponent.self, ofEntity: entityId), | ||
positionComponent.position.y > contactPoint.y else { | ||
return | ||
} | ||
|
||
playerComponent.isJumping = false | ||
} | ||
} |
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
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.