-
Notifications
You must be signed in to change notification settings - Fork 1
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 #40 from cs3217-2324/minimap
Feat/Minimap
- Loading branch information
Showing
21 changed files
with
188 additions
and
20 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
21 changes: 21 additions & 0 deletions
21
star-dash/star-dash/Assets.xcassets/MiniMap.imageset/Contents.json
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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Star dash-15.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+12.4 KB
star-dash/star-dash/Assets.xcassets/MiniMap.imageset/Star dash-15.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
star-dash/star-dash/Assets.xcassets/PlayerIcons/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
star-dash/star-dash/Assets.xcassets/PlayerIcons/RedNoseIcon.imageset/Contents.json
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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Idle (10) copy.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+45.8 KB
...h/star-dash/Assets.xcassets/PlayerIcons/RedNoseIcon.imageset/Idle (10) copy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
struct GameInfo { | ||
let playerScore: Int | ||
let playersInfo: [PlayerInfo] | ||
} |
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,13 @@ | ||
// | ||
// PlayerInfo.swift | ||
// star-dash | ||
// | ||
// Created by Lau Rui han on 28/3/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct PlayerInfo { | ||
let position: CGPoint | ||
let player: PlayerSprite | ||
} |
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
62 changes: 62 additions & 0 deletions
62
star-dash/star-dash/Rendering/MTKRenderer/MiniMapView.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,62 @@ | ||
// | ||
// MiniMapView.swift | ||
// star-dash | ||
// | ||
// Created by Lau Rui han on 28/3/24. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
class MiniMapView: UIView { | ||
// Player number label | ||
private var mapImageView: UIImageView! | ||
private var playerIcons: [UIImageView] = [] | ||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
} | ||
|
||
func setupSubviews() { | ||
mapImageView = UIImageView(image: UIImage(named: "MiniMap")) | ||
mapImageView.contentMode = .scaleAspectFit | ||
mapImageView.translatesAutoresizingMaskIntoConstraints = false | ||
addSubview(mapImageView) | ||
|
||
NSLayoutConstraint.activate([ | ||
mapImageView.topAnchor.constraint(equalTo: topAnchor, constant: 50), | ||
mapImageView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 30), | ||
mapImageView.widthAnchor.constraint(equalToConstant: 300), | ||
mapImageView.heightAnchor.constraint(equalToConstant: 50) | ||
]) | ||
} | ||
// TODO: Pass in actual map size | ||
func update(playersInfo: [PlayerInfo], mapSize: CGSize = CGSize(width: 4_500, height: 0)) { | ||
removeAllPlayerIcons() | ||
|
||
for playerData in playersInfo { | ||
let playerIcon = UIImageView(image: UIImage(named: "RedNoseIcon")) | ||
playerIcon.contentMode = .scaleAspectFit | ||
playerIcon.translatesAutoresizingMaskIntoConstraints = false | ||
addSubview(playerIcon) | ||
playerIcons.append(playerIcon) | ||
|
||
let miniMapX = (playerData.position.x / mapSize.width) * mapImageView.frame.width | ||
|
||
playerIcon.widthAnchor.constraint(equalToConstant: 30).isActive = true | ||
playerIcon.centerXAnchor.constraint(equalTo: mapImageView.leadingAnchor, constant: miniMapX).isActive = true | ||
playerIcon.centerYAnchor.constraint(equalTo: mapImageView.bottomAnchor, constant: -20).isActive = true | ||
} | ||
} | ||
|
||
private func removeAllPlayerIcons() { | ||
for playerIcon in playerIcons { | ||
playerIcon.removeFromSuperview() | ||
} | ||
playerIcons.removeAll() | ||
} | ||
|
||
} |
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,3 +1,4 @@ | ||
struct OverlayInfo { | ||
let score: Int | ||
let playersInfo: [PlayerInfo] | ||
} |
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