Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cs3217-2324/group-project-star-dash…
Browse files Browse the repository at this point in the history
… into entity
  • Loading branch information
jasonqiu212 committed Mar 12, 2024
2 parents 043991b + 784abe5 commit 1ae863a
Show file tree
Hide file tree
Showing 27 changed files with 461 additions and 0 deletions.
60 changes: 60 additions & 0 deletions star-dash/star-dash.xcodeproj/project.pbxproj
Expand Up @@ -16,6 +16,15 @@
4E630F0D2B9F7E090008F887 /* star_dashTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F0C2B9F7E090008F887 /* star_dashTests.swift */; };
4E630F172B9F7E090008F887 /* star_dashUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F162B9F7E090008F887 /* star_dashUITests.swift */; };
4E630F192B9F7E090008F887 /* star_dashUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F182B9F7E090008F887 /* star_dashUITestsLaunchTests.swift */; };
4E630F272B9F7E770008F887 /* Entity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F262B9F7E770008F887 /* Entity.swift */; };
4E630F2A2B9F7EF60008F887 /* PositionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F292B9F7EF60008F887 /* PositionComponent.swift */; };
4E630F2C2B9F7F460008F887 /* Component.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F2B2B9F7F460008F887 /* Component.swift */; };
4E630F2E2B9F81850008F887 /* HealthComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F2D2B9F81850008F887 /* HealthComponent.swift */; };
4E630F302B9F83DE0008F887 /* SpriteComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F2F2B9F83DE0008F887 /* SpriteComponent.swift */; };
4E630F322B9F887C0008F887 /* PhysicsComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F312B9F887C0008F887 /* PhysicsComponent.swift */; };
4E630F342B9F8FC00008F887 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F332B9F8FC00008F887 /* Player.swift */; };
4E630F372B9F91DE0008F887 /* PlayerSprite.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F362B9F91DE0008F887 /* PlayerSprite.swift */; };
4E630F392B9F943B0008F887 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E630F382B9F943B0008F887 /* EntityManager.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -49,6 +58,15 @@
4E630F122B9F7E090008F887 /* star-dashUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "star-dashUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
4E630F162B9F7E090008F887 /* star_dashUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = star_dashUITests.swift; sourceTree = "<group>"; };
4E630F182B9F7E090008F887 /* star_dashUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = star_dashUITestsLaunchTests.swift; sourceTree = "<group>"; };
4E630F262B9F7E770008F887 /* Entity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Entity.swift; sourceTree = "<group>"; };
4E630F292B9F7EF60008F887 /* PositionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PositionComponent.swift; sourceTree = "<group>"; };
4E630F2B2B9F7F460008F887 /* Component.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Component.swift; sourceTree = "<group>"; };
4E630F2D2B9F81850008F887 /* HealthComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthComponent.swift; sourceTree = "<group>"; };
4E630F2F2B9F83DE0008F887 /* SpriteComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteComponent.swift; sourceTree = "<group>"; };
4E630F312B9F887C0008F887 /* PhysicsComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhysicsComponent.swift; sourceTree = "<group>"; };
4E630F332B9F8FC00008F887 /* Player.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
4E630F362B9F91DE0008F887 /* PlayerSprite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerSprite.swift; sourceTree = "<group>"; };
4E630F382B9F943B0008F887 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -99,6 +117,8 @@
4E630EF42B9F7E070008F887 /* star-dash */ = {
isa = PBXGroup;
children = (
4E630F352B9F91C20008F887 /* Enums */,
4E630F252B9F7E500008F887 /* Entities */,
4E630EF52B9F7E070008F887 /* AppDelegate.swift */,
4E630EF72B9F7E070008F887 /* SceneDelegate.swift */,
4E630EF92B9F7E070008F887 /* ViewController.swift */,
Expand Down Expand Up @@ -127,6 +147,37 @@
path = "star-dashUITests";
sourceTree = "<group>";
};
4E630F252B9F7E500008F887 /* Entities */ = {
isa = PBXGroup;
children = (
4E630F282B9F7EC20008F887 /* Components */,
4E630F262B9F7E770008F887 /* Entity.swift */,
4E630F332B9F8FC00008F887 /* Player.swift */,
4E630F382B9F943B0008F887 /* EntityManager.swift */,
);
path = Entities;
sourceTree = "<group>";
};
4E630F282B9F7EC20008F887 /* Components */ = {
isa = PBXGroup;
children = (
4E630F292B9F7EF60008F887 /* PositionComponent.swift */,
4E630F2B2B9F7F460008F887 /* Component.swift */,
4E630F2D2B9F81850008F887 /* HealthComponent.swift */,
4E630F2F2B9F83DE0008F887 /* SpriteComponent.swift */,
4E630F312B9F887C0008F887 /* PhysicsComponent.swift */,
);
path = Components;
sourceTree = "<group>";
};
4E630F352B9F91C20008F887 /* Enums */ = {
isa = PBXGroup;
children = (
4E630F362B9F91DE0008F887 /* PlayerSprite.swift */,
);
path = Enums;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -258,9 +309,18 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4E630F272B9F7E770008F887 /* Entity.swift in Sources */,
4E630F2C2B9F7F460008F887 /* Component.swift in Sources */,
4E630F392B9F943B0008F887 /* EntityManager.swift in Sources */,
4E630F302B9F83DE0008F887 /* SpriteComponent.swift in Sources */,
4E630EFA2B9F7E070008F887 /* ViewController.swift in Sources */,
4E630F322B9F887C0008F887 /* PhysicsComponent.swift in Sources */,
4E630EF62B9F7E070008F887 /* AppDelegate.swift in Sources */,
4E630F2A2B9F7EF60008F887 /* PositionComponent.swift in Sources */,
4E630EF82B9F7E070008F887 /* SceneDelegate.swift in Sources */,
4E630F342B9F8FC00008F887 /* Player.swift in Sources */,
4E630F372B9F91DE0008F887 /* PlayerSprite.swift in Sources */,
4E630F2E2B9F81850008F887 /* HealthComponent.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (1).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (2).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (3).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (4).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (5).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (6).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (7).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Run (8).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions star-dash/star-dash/Entities/Components/Component.swift
@@ -0,0 +1,20 @@
//
// Component.swift
// star-dash
//
// Created by Lau Rui han on 12/3/24.
//

import Foundation
typealias ComponentId = UUID
class Component {
var entityId: UUID
var id: UUID

init(id: UUID, entityId: UUID) {
self.id = id
self.entityId = entityId

}

}
21 changes: 21 additions & 0 deletions star-dash/star-dash/Entities/Components/HealthComponent.swift
@@ -0,0 +1,21 @@
//
// HealthComponent.swift
// star-dash
//
// Created by Lau Rui han on 12/3/24.
//

import Foundation

class HealthComponent: Component {
var health: Int

init(id: UUID, entityId: UUID, health: Int) {
self.health = health
super.init(id: id, entityId: entityId)
}

convenience init(entityId: UUID, health: Int) {
self.init(id: UUID(), entityId: entityId, health: health)
}
}
29 changes: 29 additions & 0 deletions star-dash/star-dash/Entities/Components/PhysicsComponent.swift
@@ -0,0 +1,29 @@
//
// PhysicsComponent.swift
// star-dash
//
// Created by Lau Rui han on 12/3/24.
//

import Foundation

class PhysicsComponent: Component {
var mass: CGFloat
var velocity: CGVector
var force: CGVector
var collisionMask: UInt32
var affectedByGravity: Bool

init(id: UUID, entityId: UUID, mass: CGFloat, velocity: CGVector, force: CGVector, collisionMask: UInt32, affectedByGravity: Bool) {
self.mass = mass
self.velocity = velocity
self.force = force
self.collisionMask = collisionMask
self.affectedByGravity = affectedByGravity
super.init(id: id, entityId: entityId)
}

convenience init(entityId: UUID, mass: CGFloat, velocity: CGVector, force: CGVector, collisionMask: UInt32, affectedByGravity: Bool) {
self.init(id: UUID(), entityId: entityId, mass: mass, velocity: velocity, force: force, collisionMask: collisionMask, affectedByGravity: affectedByGravity)
}
}
33 changes: 33 additions & 0 deletions star-dash/star-dash/Entities/Components/PositionComponent.swift
@@ -0,0 +1,33 @@
//
// PositionComponent.swift
// star-dash
//
// Created by Lau Rui han on 12/3/24.
//

import Foundation


class PositionComponent: Component {
var position: CGPoint
var rotation: Float

init(id: UUID, entityId: UUID, position: CGPoint, rotation: Float) {
self.position = position
self.rotation = rotation
super.init(id: id, entityId: entityId)
}

convenience init(entityId: UUID, position: CGPoint, rotation: Float) {
self.init(id: UUID(), entityId: entityId, position: position, rotation: rotation)
}

func setPosition(position: CGPoint) {
self.position = position
}

func setRotation(rotation: Float) {
self.rotation = rotation
}

}

0 comments on commit 1ae863a

Please sign in to comment.