-
Notifications
You must be signed in to change notification settings - Fork 4
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 #3 from Vanessamae23/main
Fix hasComponent and added more components
- Loading branch information
Showing
32 changed files
with
538 additions
and
93 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
Binary file modified
BIN
+80.2 KB
(250%)
...proj/project.xcworkspace/xcuserdata/macbookpro.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
Binary file added
BIN
+2.74 KB
...Forge/TowerForge/Assets.xcassets/Sprites.spriteatlas/Bullet.imageset/Bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
TowerForge/TowerForge/Assets.xcassets/Sprites.spriteatlas/Bullet.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" : "Bullet.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...rForge/TowerForge/Assets.xcassets/Sprites.spriteatlas/LightHouse-1.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" : "LightHouse-1.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+22.4 KB
...orge/Assets.xcassets/Sprites.spriteatlas/LightHouse-1.imageset/LightHouse-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
TowerForge/TowerForge/Assets.xcassets/Sprites.spriteatlas/Shooter-1.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" : "Shooter-1.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+22.4 KB
...TowerForge/Assets.xcassets/Sprites.spriteatlas/Shooter-1.imageset/Shooter-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
TowerForge/TowerForge/Assets.xcassets/Sprites.spriteatlas/Shooter-2.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" : "Shooter-2.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+22.6 KB
...TowerForge/Assets.xcassets/Sprites.spriteatlas/Shooter-2.imageset/Shooter-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
TowerForge/TowerForge/Assets.xcassets/Sprites.spriteatlas/road-tile.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" : "road-tile.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+3.47 KB
...TowerForge/Assets.xcassets/Sprites.spriteatlas/road-tile.imageset/road-tile.png
Loading
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
33 changes: 33 additions & 0 deletions
33
TowerForge/TowerForge/LevelManager/Components/BaseComponents/MovableComponent.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,33 @@ | ||
// | ||
// MovableComponent.swift | ||
// TowerForge | ||
// | ||
// Created by Vanessa Mae on 15/03/24. | ||
// | ||
|
||
import Foundation | ||
import CoreGraphics | ||
|
||
class MovableComponent: TFComponent { | ||
public var velocity: CGVector | ||
public var position: CGPoint | ||
|
||
init(position: CGPoint, velocity: CGVector = .zero) { | ||
self.velocity = velocity | ||
self.position = position | ||
super.init() | ||
} | ||
|
||
override func update(deltaTime: TimeInterval) { | ||
guard let entity = entity, | ||
let positionComponent = entity.component(ofType: PositionComponent.self), | ||
let spriteComponent = entity.component(ofType: SpriteComponent.self) else { | ||
return | ||
} | ||
|
||
let finalX = positionComponent.position.x + velocity.dx * CGFloat(deltaTime) | ||
let finalY = positionComponent.position.y + velocity.dy * CGFloat(deltaTime) | ||
positionComponent.changeTo(to: CGPoint(x: finalX, y: finalY)) | ||
spriteComponent.node.position = positionComponent.position | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
TowerForge/TowerForge/LevelManager/Components/BaseComponents/PositionComponent.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,25 @@ | ||
// | ||
// PositionComponent.swift | ||
// TowerForge | ||
// | ||
// Created by MacBook Pro on 17/03/24. | ||
// | ||
|
||
import Foundation | ||
import CoreGraphics | ||
|
||
class PositionComponent: TFComponent { | ||
var position: CGPoint | ||
|
||
init(position: CGPoint) { | ||
self.position = position | ||
super.init() | ||
} | ||
|
||
func changeTo(to position: CGPoint) { | ||
guard let entity = entity, let spriteComponent = entity.component(ofType: SpriteComponent.self) else { | ||
return | ||
} | ||
self.position = position | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.