number 4 complete start from 5 tomorow

This commit is contained in:
dev sp
2023-12-05 15:34:40 +00:00
parent 1253dd5911
commit dfa0499ab0
70 changed files with 1289 additions and 264 deletions

View File

@@ -39,6 +39,8 @@ import Layout from "../../layouts/Layout.astro";
let firstLayer, secondLayer, thirdLayer;
let graphics;
let isDrawing = false;
let formattedDateTime;
let gameStartTime = "stat timr here";
if(isMobile){
cloudeSize = 200;
@@ -59,6 +61,14 @@ import Layout from "../../layouts/Layout.astro";
startButtonHeight = customHeight / 1.1;
startButtonWidth = customWidth / 2 - 100;
submitWidth = customWidth / 2 - 100;
submitHeight = customHeight / 1.1;
noticeWidth = 100;
noticeHeight = 0;
submitWidth = customWidth / 2 - 100;
submitHeight = customHeight / 1.1;
noticeWidth = 100;
noticeHeight = 0;
} else{
cloudeSize = 500;
cloudHeight = 250;
@@ -76,9 +86,27 @@ import Layout from "../../layouts/Layout.astro";
helpButtonHeight = customHeight / 2 + 40;
helpButtonWidth = customWidth / 1.32;
startButtonHeight = customHeight / 2 - 20;
startButtonHeight = customHeight / 2 - 20;
startButtonWidth = customWidth / 1.32;
submitWidth = customWidth / 1.32;
submitHeight = customHeight / 2 - 20;
noticeWidth = 0;
noticeHeight = 0;
submitWidth = customWidth / 1.32;
submitHeight = customHeight / 2 - 20;
noticeWidth = 0;
noticeHeight = 0;
}
window.onload = function() {
currentDate = new Date();
formattedDateTime = currentDate.toLocaleString();
console.log("Page loaded on: " + formattedDateTime);
};
// function gmStartTime() {
// let startTime = new Date();
// let gameStartTime = startTime.toLocaleString();
// console.log("Page loaded on: " + gameStartTime);
// };
// let hideButton;
function preload() {
@@ -97,8 +125,64 @@ import Layout from "../../layouts/Layout.astro";
this.load.image('bgMobile', '/assets/bgMobile.png');
this.load.image('canvasStand', '/assets/stand2.png');
}
function create() {
const URL = window.location.href;
const urlSplit = URL.split('/');
const gameName = urlSplit[3] + '-' + urlSplit[4]
let userData = {
'status' : 'published',
'user_id': 'guided-tracing@beanstalkedu.com',
'game_name': gameName,
'game_open': formattedDateTime,
'game_start' : gameStartTime,
};
function submitUserData() {
console.log(userData)
fetch(`https://management.beanstalkedu.com/items/game_result`, {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
},
body: JSON.stringify(userData)
})
.then(response => {
if(response.ok){
// console.log('Data Saved', response)
} else{
// console.log('Something Wrong', response)
}
})
.catch(error => {
console.error('An error occured', error)
});
};
const submitNotic = this.add.text(window.innerWidth * 0.5 - noticeWidth, window.innerHeight * 0.85 - noticeHeight, 'Submitted Successfully', {
font: '600 20px Quicksand',
fill: 'blue'
}).setDepth(1);
submitNotic.setVisible(false);
submitButton = this.add.text(submitWidth, submitHeight, "Submit", {
font: '900 24px Quicksand',
fill: '#05b3a4',
backgroundColor : '#7c4c23',
padding: {x: 10, y: 10},
shadow: {
offsetX : 2,
offsetY : 2,
color: '#000',
blur: 5,
fill: true
}
});
submitButton.setVisible(false);
submitButton.setInteractive().on('pointerdown', () => {
console.log('Clicked');
submitButton.setVisible(false);
submitNotic.setVisible(true);
// windowLoad();
submitUserData();
})
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
this.add.text(customWidth / 10, 20, "Number : 0", { font: '700 40px quicksand', fill: '#05b3a4', });
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
@@ -116,21 +200,20 @@ import Layout from "../../layouts/Layout.astro";
const sun = this.add.sprite(customWidth - sunWidth, sunHeight, 'sun').setScale(sunScale).setDepth(-1.9);
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
const duration = 3000; // Duration of the animation in milliseconds
const scaleFactor = sunScalePlus; // Scale factor (2 means double the size)
const duration = 3000; // Duration of the animation in milliseconds
// Create a scaling tween
this.tweens.add({
targets: sun,
scaleX: scaleFactor,
scaleY: scaleFactor,
duration: duration,
ease: 'Linear',
yoyo: true, // Makes the animation play in reverse
repeat: -1 // Repeat indefinitely
});
// Create a scaling tween
this.tweens.add({
targets: sun,
scaleX: scaleFactor,
scaleY: scaleFactor,
duration: duration,
ease: 'Linear',
yoyo: true, // Makes the animation play in reverse
repeat: -1 // Repeat indefinitely
});
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'number0').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'number0').setDepth(2).setScale(letterScale);
@@ -143,8 +226,6 @@ import Layout from "../../layouts/Layout.astro";
maskGraphics.fillRect(customWidth / 2 - (canvas.width * canvasScale) / 2, customHeight / 2 + canvasHeight - (canvas.height * canvasScale) / 2, canvas.width * canvasScale, canvas.height * canvasScale);
const mask = maskGraphics.createGeometryMask();
let hideButton = this.add.text(helpButtonWidth, helpButtonHeight, "Let`s Do", {
font: '900 24px quicksand',
fill: '#05b3a4',
@@ -283,13 +364,18 @@ import Layout from "../../layouts/Layout.astro";
firstTextLayer.setVisible(false);
startButton.setInteractive().on('pointerdown', () => {
audioOneAudio.play();
// gmStartTime();
gamestart = new Date();
gameStartTime = gamestart.toLocaleString();
console.log("Page loaded on: " + gameStartTime);
firstTextLayer.setVisible(true);
animatedLetter.setVisible(false); firstScreen.setVisible(false);
animatedLetter.setVisible(false);
firstScreen.setVisible(false);
graphics.setVisible(true);
hideButton.setVisible(false);
demoButton.setVisible(true);
startButton.setVisible(false);
submitButton.setVisible(true);
})