Skip to content

Commit

Permalink
update-parcels
Browse files Browse the repository at this point in the history
  • Loading branch information
CansyLand committed Sep 14, 2023
1 parent 064ac03 commit bd80801
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
23 changes: 11 additions & 12 deletions Party-Time/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export function main() {

// Function to call the API
async function checkTime() {

const response = await fetch('https://worldtimeapi.org/api/timezone/etc/gmt+3') // GMT+3

const worldtime = await response.json()
const timeNow = new Date(worldtime.datetime)

// Debug
console.log('\nParty Start: ', partyStart, '\nTime now: ', timeNow, '\nParty End: ', partyEnd)

Expand All @@ -29,7 +28,9 @@ export function main() {
const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24))
// Calculate the number of hours left after subtracting the days
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
updateSignpost(`Party starts \n in ${days} days \n and ${hours} hours. \n At ${formatAMPM(partyStart.getHours())}`)
updateSignpost(
`Party starts \n in ${days} days \n and ${hours} hours. \n At ${formatAMPM(partyStart.getHours())}`
)
}
// While Party
else if (timeNow >= partyStart && timeNow <= partyEnd) {
Expand All @@ -50,15 +51,13 @@ export function main() {
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))

updateSignpost(`Party ended\n${days} days\nand ${hours} hours ago`)

}

}
checkTime()

// Fetches time API evey 10 seconds
let timer: number = 10
function LoopSystem( dt: number ) {
function LoopSystem(dt: number) {
timer -= dt
if (timer <= 0) {
timer = 10
Expand All @@ -70,18 +69,18 @@ export function main() {
function updateSignpost(text: string) {
// We get signpost by name set in sceneFactory.ts
const signpostEntity = engine.getEntityOrNullByName('signpost')
if(signpostEntity) {
if (signpostEntity) {
const signpost = TextShape.getMutable(signpostEntity)
signpost.text = text
}
}

function formatAMPM(hours: number) {
const ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
const ampm = hours >= 12 ? 'PM' : 'AM'
hours = hours % 12
hours = hours ? hours : 12 // the hour '0' should be '12'

const strTime = hours + ' ' + ampm;
return strTime;
const strTime = hours + ' ' + ampm
return strTime
}
}
1 change: 0 additions & 1 deletion Party-Time/src/sceneFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,4 @@ export function buildScene() {
fontSize: 2
})
Name.create(signpostText, { value: 'signpost' })

}
4 changes: 2 additions & 2 deletions Party-Time/src/startParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function createVideoShapes() {
const floor = engine.addEntity()
MeshRenderer.setPlane(floor)
Transform.create(floor, {
position: { x: 8, y:0.05 , z: 8},
position: { x: 8, y: 0.05, z: 8 },
rotation: Quaternion.fromEulerDegrees(90, 0, 0),
scale: { x: 16, y: 16, z: 16}
scale: { x: 16, y: 16, z: 16 }
})
Material.setPbrMaterial(floor, videoMaterial)

Expand Down

0 comments on commit bd80801

Please sign in to comment.