pull/28/head
parent
195756b892
commit
3392dea286
|
@ -198,12 +198,6 @@ import Layout from "../../layouts/Layout.astro";
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
|
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -107,137 +194,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).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);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
submitButton.setInteractive().on('pointerdown', () => {
|
||||
// console.log('Clicked');
|
||||
submitButton.setVisible(false);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : J", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterJ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterJ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedJ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : J', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedJHeight, 'animatedJ').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: J', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : J', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedJHeight, 'animatedJ').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -251,11 +265,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Hook',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Hook',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -283,7 +297,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -300,37 +313,56 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
|
@ -95,6 +160,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -112,137 +199,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : K", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 50, customHeight / 2 + letterHeight, 'letterK').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterK').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedK').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : K', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: K', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : K', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedKHeight, 'animatedK').setDepth(2).setScale(animatedKScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +270,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +283,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -278,7 +293,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
thirdLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const thirdTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '3. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
|
@ -354,7 +369,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -371,35 +385,55 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -90,6 +155,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -114,132 +201,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : L", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 30, customHeight / 2 + letterHeight, 'letterL').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'letterL').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedL').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : L', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: L', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : L', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedLHeight, 'animatedL').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -253,11 +272,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -266,7 +285,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slide',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -279,7 +298,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
|
@ -302,7 +320,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
|
@ -324,7 +341,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -341,30 +357,15 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false); firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -372,4 +373,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer, fourthLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -109,139 +196,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : M", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterM').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterM').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedM').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : M', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: M', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : M', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedMHeight, 'animatedM').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +268,12 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +282,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -278,7 +292,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const thirdTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '3. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
|
@ -289,7 +303,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
fourthLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer4').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const fourthTextLayer = this.add.text(textX, textY, '4. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const fourthTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '4. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioFourthAudio = this.sound.add('audioTwo');
|
||||
fourthTextLayer.setVisible(false);
|
||||
fourthLayer.setDepth(1.1);
|
||||
|
@ -390,7 +404,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -407,30 +420,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
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);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -438,4 +435,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
|
@ -95,6 +160,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -119,131 +206,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : N", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterN').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterN').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedN').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : N', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: N', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : N', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedNHeight, 'animatedN').setDepth(2).setScale(animatedNScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -256,11 +277,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -269,7 +290,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioOne');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -279,7 +300,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const thirdTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '3. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
|
@ -293,8 +314,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -356,7 +375,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -374,34 +392,55 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
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);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -113,133 +200,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : O", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterO').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterO').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedO').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : O', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedOHeight, 'animatedO').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: O', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : O', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedOHeight, 'animatedO').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -253,11 +272,12 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 12 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Close',{ font: '700 35px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around Close',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -291,7 +311,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -308,37 +327,53 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
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);
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
function update() {}
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
</script>
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -115,133 +202,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : P", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 30, customHeight / 2 + letterHeight, 'letterP').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterP').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedP').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : P', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: P', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : P', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedPHeight, 'animatedP').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +273,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +286,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slide Around',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -325,7 +343,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -342,31 +359,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -374,4 +374,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -103,145 +190,72 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('letterQ', '/assets/capital-letter/q.svg');
|
||||
this.load.svg('layer1', '/assets/capital-letter/q_l1.svg');
|
||||
this.load.svg('layer2', '/assets/capital-letter/q_l2.svg');
|
||||
this.load.audio('audioOne', '/assets/audio/tall-down.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slide-around.mp3');
|
||||
this.load.audio('audioOne', '/assets/audio/hook-around-close.mp3');
|
||||
this.load.audio('audioTwo', '/assets/audio/slant.mp3');
|
||||
this.load.image('topLogo', '/assets/top_logo.svg');
|
||||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : Q", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterQ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterQ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedQ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : Q', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2, customHeight / 2 + animatedQHeight, 'animatedQ').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: Q', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : Q', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedQHeight, 'animatedQ').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +269,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Close',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around Close',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +282,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slant',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -281,8 +295,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -325,7 +337,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -342,36 +353,55 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
|
@ -97,6 +162,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -121,131 +208,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : R", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 10, customHeight / 2 + letterHeight, 'letterR').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 10, customHeight / 2 + letterHeight, 'letterR').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedR').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : R', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: R', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : R', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedRHeight, 'animatedR').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -258,11 +278,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 10, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -271,7 +291,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 10, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slide Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slide Around',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -295,8 +315,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -358,7 +376,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -390,21 +407,54 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -107,139 +194,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : S", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterS').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterS').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedS').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : S', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedSHeight, 'animatedS').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: S', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : S', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedSHeight, 'animatedS').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -253,11 +266,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 12 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Snake',{ font: '700 35px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around Snake',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -290,7 +303,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -307,31 +319,15 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
@ -340,5 +336,41 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
function update() {
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -93,6 +158,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -111,140 +198,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : j", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 - 20, customHeight / 2 + letterJeight, 'letterJ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 20 , customHeight / 2 + letterJeight, 'letterJ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterJeight, 'animatedJ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : j', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: j', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : j', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedJHeight, 'animatedJ').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -258,11 +270,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterJeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Down Tail',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Down Tail',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -271,7 +283,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 - 20, customHeight / 2 + letterJeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Dot',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Dot',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -283,8 +295,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -306,7 +316,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
firstLayer.setAlpha(0.5);
|
||||
}
|
||||
});
|
||||
``
|
||||
// Repeat the above code for secondLayer and thirdLayer
|
||||
|
||||
// Add this code for secondLayer
|
||||
|
@ -328,7 +337,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -345,30 +353,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
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);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -376,4 +368,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xeaeae8,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
|
@ -96,6 +161,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -114,137 +201,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : k", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 20, customHeight / 2 + letterHeight, 'letterK').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterK').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedK').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : k', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: k', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : k', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedKHeight, 'animatedK').setDepth(2).setScale(animatedKScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -257,11 +272,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 20, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -270,7 +285,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 20, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Slant In',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Slant In',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -280,7 +295,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
thirdLayer = this.add.image(customWidth / 2 + 20, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Slant Out', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const thirdTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '3. Slant Out',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioThreeAudio = this.sound.add('audioThree');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
|
@ -294,8 +309,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
let thirdDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -357,7 +370,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -375,34 +387,55 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -93,6 +158,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -109,140 +196,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).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);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
submitButton.setInteractive().on('pointerdown', () => {
|
||||
// console.log('Clicked');
|
||||
submitButton.setVisible(false);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : l", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 50, customHeight / 2 + letterHeight, 'letterL').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'letterL').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedL').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : l', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedLHeight, 'animatedL').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: l', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : l', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedLHeight, 'animatedL').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -256,11 +267,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 50, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Tall Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Tall Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -272,8 +283,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -295,7 +304,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -312,31 +320,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
@ -346,4 +337,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xeaeae8,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
// let x = 100;
|
||||
|
||||
// // Use x
|
||||
|
@ -54,14 +119,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 50;
|
||||
letterScale = 1.1;
|
||||
letterScale = 1.7;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
animatedMHeight = 35;
|
||||
animatedMScale = 0.5;
|
||||
animatedMScale = 0.7;
|
||||
helpButtonHeight = customHeight / 1.1;
|
||||
helpButtonWidth = customWidth / 2 + 10;
|
||||
|
||||
|
@ -77,14 +142,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 40;
|
||||
letterScale = 1.3;
|
||||
letterScale = 1.7;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
animatedMHeight = 20;
|
||||
animatedMScale = 0.6;
|
||||
animatedMScale = 0.8;
|
||||
helpButtonHeight = customHeight / 2 + 40;
|
||||
helpButtonWidth = customWidth / 1.32;
|
||||
|
||||
|
@ -95,6 +160,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -112,137 +199,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : m", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterM').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterM').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedM').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : m', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: m', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : m', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedMHeight, 'animatedM').setDepth(2).setScale(animatedMScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +269,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 5 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Small Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Small Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +282,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Roll Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Roll Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -278,7 +292,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
|
||||
const thirdTextLayer = this.add.text(textX, textY, '3. Roll Down', { font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const thirdTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '3. Roll Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioThreeAudio = this.sound.add('audioTwo');
|
||||
thirdTextLayer.setVisible(false);
|
||||
thirdLayer.setDepth(1.1);
|
||||
|
@ -355,7 +369,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -373,34 +386,56 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xeaeae8,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -50,14 +115,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterNeight = 50;
|
||||
letterScale = 1.4;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
|
||||
animatedVideoScale = 0.63;
|
||||
animatedVideoScale = 0.7;
|
||||
animatedNHeight = 32;
|
||||
helpButtonHeight = customHeight / 1.1;
|
||||
helpButtonWidth = customWidth / 2 + 10;
|
||||
|
@ -74,14 +139,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterNeight = 30;
|
||||
letterScale = 1.5;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
|
||||
animatedVideoScale = 0.65;
|
||||
animatedVideoScale = 0.7;
|
||||
animatedNHeight = 20;
|
||||
helpButtonHeight = customHeight / 2 + 40;
|
||||
helpButtonWidth = customWidth / 1.32;
|
||||
|
@ -93,6 +158,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -111,140 +198,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : n", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 60, customHeight / 2 + letterNeight, 'letterN').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 60, customHeight / 2 + letterNeight, 'letterN').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterNeight, 'animatedN').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : n', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: n', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : n', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedNHeight, 'animatedN').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -258,11 +270,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 60, customHeight / 2 + letterNeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 5 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Small Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Small Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -271,7 +283,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 60, customHeight / 2 + letterNeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Roll Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Roll Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -283,8 +295,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -327,7 +337,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -344,30 +353,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -375,4 +368,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -50,7 +115,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterHeight = 40;
|
||||
letterScale = 1.3;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
|
@ -73,7 +138,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterHeight = 30;
|
||||
letterScale = 1.5;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
|
@ -91,6 +156,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -107,141 +194,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : o", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterO').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterO').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedO').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : o', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedOHeight, 'animatedO').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: o', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : o', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedOHeight, 'animatedO').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +266,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Close',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around Close',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -271,8 +282,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
// Add these variables to keep track of start points
|
||||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -294,7 +303,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -311,30 +319,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -342,4 +334,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -21,7 +84,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -39,9 +102,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -90,6 +155,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
}
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -108,140 +195,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : p", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 30, customHeight / 2 + letterPeight, 'letterP').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterPeight, 'letterP').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterPeight, 'animatedP').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : p', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: p', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : p', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedPHeight, 'animatedP').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,11 +267,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterPeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Down Tail',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Down Tail',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -268,7 +280,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 30, customHeight / 2 + letterPeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Roll Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Roll Around',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -322,7 +334,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -339,30 +350,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -370,4 +365,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -21,7 +84,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -39,9 +102,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -92,6 +157,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -116,134 +203,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : q", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 - 45, customHeight / 2 + letterQeight, 'letterQ').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 - 45, customHeight / 2 + letterQeight, 'letterQ').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterQeight, 'animatedQ').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : p', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
const animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedQHeight, 'animatedQ').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: q', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : q', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedQHeight, 'animatedQ').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -257,11 +274,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY; - 35
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 - 45, customHeight / 2 + letterQeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 6.5 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -270,7 +287,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 - 45, customHeight / 2 + letterQeight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Down Hook',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Down Hook',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -282,8 +299,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -325,7 +340,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -342,35 +356,56 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -50,14 +115,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.14
|
||||
canvasHeight = 35;
|
||||
letterReight = 20;
|
||||
letterScale = 1.2;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 0.8;
|
||||
sunScale = 0.1;
|
||||
sunScalePlus = 0.15;
|
||||
sunWidth = 70;
|
||||
sunHeight = 70;
|
||||
|
||||
animatedVideoScale = 0.5;
|
||||
animatedVideoScale = 0.7;
|
||||
animatedRHeight = 32;
|
||||
helpButtonHeight = customHeight / 1.1;
|
||||
helpButtonWidth = customWidth / 2 + 10;
|
||||
|
@ -74,14 +139,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
canvasScale = 0.195;
|
||||
canvasHeight = 20;
|
||||
letterReight = -10;
|
||||
letterScale = 1.2;
|
||||
letterScale = 1.6;
|
||||
backgroundScale = 1;
|
||||
sunScale = 0.2;
|
||||
sunScalePlus = 0.25;
|
||||
sunWidth = 200;
|
||||
sunHeight = 100;
|
||||
|
||||
animatedVideoScale = 0.6;
|
||||
animatedVideoScale = 0.7;
|
||||
animatedRHeight = 20;
|
||||
helpButtonHeight = customHeight / 2 + 40;
|
||||
helpButtonWidth = customWidth / 1.32;
|
||||
|
@ -93,6 +158,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -111,141 +198,64 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.svg('succesImage', '/assets/svg/tick.svg');
|
||||
this.load.svg('hintImage', '/assets/svg/hint.svg');
|
||||
this.load.svg('handPointer', '/assets/svg/hand.svg');
|
||||
this.load.image('backgroundImage', '/assets/bg6.png');
|
||||
this.load.image('cloud', '/assets/cloud.png');
|
||||
this.load.image('canvas', '/assets/canvas4.png');
|
||||
|
||||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : r", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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 + 40, customHeight / 2 + letterReight, 'letterR').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 40, customHeight / 2 + letterReight, 'letterR').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterReight, 'animatedR').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : r', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: r', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : r', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedRHeight, 'animatedR').setDepth(2).setScale(animatedVideoScale);
|
||||
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -259,11 +269,11 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2 + 40, customHeight / 2 + letterReight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 5 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Small Down',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Small Down',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
|
@ -272,7 +282,7 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
secondLayer = this.add.image(customWidth / 2 + 40, customHeight / 2 + letterReight, 'layer2').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 4 : customWidth * 0.75;
|
||||
const secondTextLayer = this.add.text(textX, textY, '2. Roll',{ font: '700 40px quicksand', fill: '#05b3a4'});
|
||||
const secondTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '2. Roll',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioTwoAudio = this.sound.add('audioTwo');
|
||||
secondTextLayer.setVisible(false);
|
||||
secondLayer.setDepth(1);
|
||||
|
@ -284,8 +294,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
let firstDragStartPoint = { x: 0, y: 0 };
|
||||
let secondDragStartPoint = { x: 0, y: 0 };
|
||||
|
||||
// ...
|
||||
|
||||
// Add this code for firstLayer
|
||||
firstLayer.on('dragstart', (pointer) => {
|
||||
firstDragStartPoint.x = pointer.x;
|
||||
|
@ -328,7 +336,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -345,30 +352,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -376,4 +367,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
|
@ -2,15 +2,78 @@
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Guided Letter Tracing Game">
|
||||
<main>
|
||||
<div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
<main>
|
||||
<div id="blurDisplay" class="w-full min-h-screen absolute backdrop-blur-[5px] z-50">
|
||||
<div class="flex justify-center items-center h-screen ">
|
||||
<button id="beforeStartBtn" class="bg-[#0348A8] px-10 py-2 rounded-[4px] text-[#FFFFFF] text-[32px] font-[700]">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="parentMainContainer" class="hidden">
|
||||
<div id="loadingMainContainer" class="w-full h-screen bg-[#00000070] absolute z-10" style="display: none;">
|
||||
<div id="loadingState" style="display: none;" class="bg-white flex text-[#000] absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] items-center space-y-2 w-full px-6 py-16"></div>
|
||||
</div>
|
||||
<div id="scoreBoard" class="z-10 w-full h-screen bg-[#00000070] absolute" style="display: none;">
|
||||
<div class="flex absolute left-1/2 top-1/2 -translate-y-1/2 -translate-x-1/2 max-w-lg flex-col rounded-[8px] bg-white space-y-2 w-full p-6" >
|
||||
<div class="flex flex-row space-x-4 items-center justify-center">
|
||||
<div id="star-container"></div>
|
||||
</div>
|
||||
<div class="flex flex-row" style="margin-top: 15px; margin-bottom: 15px;">
|
||||
<img class="z-10" src="/assets/animate-clipart.gif" alt="" style="width: 90.21px; height: 86.24px;" />
|
||||
<p class="text-[#0348A8] text-[12px] font-[700] p-6 rounded-[10px] -ml-[10px]" style="background: linear-gradient(270.05deg, #FFFFFF 4.67%, #DAEAFF 99.61%);">Well done! <span id="countStar"></span> stars for your effort! <br> Keep pushing, you’ve got this!</p>
|
||||
</div>
|
||||
<div class="flex flex-col w-full max-w-sm items-center justify-center mx-auto gap-3">
|
||||
<button onclick="history.back();" class="rounded-[4px] bg-[#0348A8] text-[#FFF] text-[12px] font-[700] p-2.5 w-full border-[1px] border-[#0348A8]">Wow, Lets Go</button>
|
||||
<button class="border-[1px] border-[#0348A8] p-2.5 rounded-[4px] text-[#0348A8] w-full">Try Again</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clip-art-container absolute bottom-10 right-10" id="bottomAnimateClipart">
|
||||
<div class="flex flex-row z-50 place-items-end clip-art">
|
||||
<img src="/assets/clip-art-with-hand.svg" alt="Clip Art" class="">
|
||||
<div class="relative bg-yellow-500 rounded-[4px] -ml-[10px]" style="background: linear-gradient(74.79deg, #E8EBFF 4.63%, #DDC9F1 97.93%); height: 200px; box-shadow: 0px 4px 8px 3px #CAD1F5;">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Left Star" class="absolute left-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
<img src="/assets/svg/bg-star.svg" alt="Right Star" class="absolute right-0 top-1/4 transform -translate-y-1/2 w-12 h-12">
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex flex-col space-y-3 px-10 py-10 w-[348px] h-[187px] ">
|
||||
<p class="text-center text-[14px] font-[600] text-[#394FC0]">Want to find how much stars you’ve earned?</p>
|
||||
<button class="text-[12px] font-[700] text-white bg-[#394FC0] rounded-[4px] w-full py-2.5" onclick="calculateFromAI();" >Ask to Beanie</button>
|
||||
<a href="" class="text-center text-[12px] font-[600] text-[#394FC0] underline decoration-2 underline-offset-[4px]">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gallerySliderId" class="hidden p-2 z-10 absolute inset-0 bg-black w-full h-screen bg-opacity-50 flex justify-center items-center">
|
||||
<div class="w-full max-w-6xl bg-white rounded-lg">
|
||||
<div class="flex justify-between p-3">
|
||||
<p class="text-[19px] font-[700]">Attempt 2</p>
|
||||
<button onclick="closeGallery();"> <img src="/assets/svg/crossIcon.svg"></button>
|
||||
</div>
|
||||
<div class="relative w-full aspect-video overflow-hidden rounded-b-lg shadow-lg">
|
||||
<img id="slideImage" src="" alt="" class="slide active w-full h-full aspect-video transition-transform duration-500" />
|
||||
|
||||
<button id="prevButton" class="flex justify-center items-center w-[40px] h-[40px] absolute left-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/leftIcon.svg" alt=""></button>
|
||||
<button id="nextButton" class="flex justify-center items-center w-[40px] h-[40px] absolute right-4 top-1/2 transform -translate-y-1/2 bg-[#F4F7FF] text-gray-800 p-2 rounded-full shadow-lg hover:bg-gray-100 transition"><img src="/assets/svg/rightIcon.svg" alt=""></button>
|
||||
|
||||
<div id="slidetInfo" class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-2 text-center text-white">
|
||||
<h2 class="text-lg font-bold" id="imageTitle">Image Title</h2>
|
||||
<p class="text-sm" id="imageDescription">Description goes here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
|
||||
</main>
|
||||
</Layout>
|
||||
<script src="/saveGameData.js" is:inline></script>
|
||||
<script src="/saveGameAI.js" is:inline></script>
|
||||
<script is:inline>
|
||||
function showAnimation() {
|
||||
const clipArt = document.querySelector('.clip-art');
|
||||
clipArt.classList.add('show');
|
||||
}
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
const isTab = window.innerWidth > 768 && window.innerWidth <= 1416;
|
||||
const drawingZone = {
|
||||
x: isMobile ? 0 : window.innerWidth / 4,
|
||||
y: window.innerHeight / 4,
|
||||
|
@ -22,7 +85,7 @@ import Layout from "../../layouts/Layout.astro";
|
|||
type: Phaser.AUTO,
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
backgroundColor: 0xFFFFFF,
|
||||
backgroundColor: 0xebedea,
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||
|
@ -40,9 +103,11 @@ import Layout from "../../layouts/Layout.astro";
|
|||
let firstLayer, secondLayer, thirdLayer;
|
||||
let graphics;
|
||||
let animatedLetter;
|
||||
let scoreTotal = 0; let isDrawing = false;
|
||||
let scoreTotal = 0;
|
||||
let isDrawing = false;
|
||||
let formattedDateTime;
|
||||
let gameStartTime = "start time here";
|
||||
let demoButton;
|
||||
|
||||
if(isMobile){
|
||||
cloudeSize = 200;
|
||||
|
@ -93,6 +158,28 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
noticeWidth = window.innerWidth * 0.5 - 120;
|
||||
noticeHeight = window.innerHeight * 0.32;
|
||||
};
|
||||
if(isMobile){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.65;
|
||||
resetIconWidth = 1.40;
|
||||
tickIconWidth = 1.21;
|
||||
cancelIconWidth = 1.08;
|
||||
galleryIconWidth = 2;
|
||||
}else if(isTab){
|
||||
topLogoWidth = 4.5;
|
||||
muteIconWidth = 1.6;
|
||||
resetIconWidth = 1.43;
|
||||
tickIconWidth = 1.29;
|
||||
cancelIconWidth = 1.18;
|
||||
galleryIconWidth = 1.81;
|
||||
} else{
|
||||
topLogoWidth = 6;
|
||||
muteIconWidth = 1.3;
|
||||
resetIconWidth = 1.26;
|
||||
tickIconWidth = 1.222;
|
||||
cancelIconWidth = 1.185;
|
||||
galleryIconWidth = 1.345;
|
||||
}
|
||||
window.onload = function() {
|
||||
currentDate = new Date();
|
||||
formattedDateTime = currentDate.toLocaleString();
|
||||
|
@ -114,134 +201,65 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
this.load.image('sun', '/assets/sun.png');
|
||||
this.load.image('bgMobile', '/assets/bgMobile.png');
|
||||
this.load.image('canvasStand', '/assets/stand2.png');
|
||||
|
||||
this.load.image("tickIcon", '/assets/svg/tick2.svg');
|
||||
this.load.image("muteIcon", '/assets/svg/mute.svg');
|
||||
this.load.image("cancelIcon", '/assets/svg/cancel.svg');
|
||||
this.load.image("resetIcon", '/assets/svg/reset.svg');
|
||||
this.load.svg('helpIcons', '/assets/svg/help_icon.svg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
this.add.image(customWidth / topLogoWidth, 30, "topLogo");
|
||||
muteIcon = this.add.image(customWidth / muteIconWidth, 30, "muteIcon");
|
||||
retryButton = this.add.image(customWidth / resetIconWidth, 30, "resetIcon");
|
||||
submitButton = this.add.image(customWidth / tickIconWidth, 30, "tickIcon");
|
||||
demoButton = this.add.image(customWidth / galleryIconWidth, 30, "helpIcons");
|
||||
submitNotic = this.add.text(window.innerWidth / 2 - noticeWidth, window.innerHeight / 2 - noticeHeight, 'Submitted Successfully', {font: '600 20px Quicksand', fill: '#FFFFFF', backgroundColor: '#004aad',padding: {left: 20,right: 20,top: 10,bottom: 10}}).setDepth(3).setVisible(false);
|
||||
cancelIcon = this.add.image(customWidth / cancelIconWidth, 30, "cancelIcon");
|
||||
const borderBottom = this.add.graphics();
|
||||
const x = 0; const y = 54;
|
||||
const lineWidth = window.innerWidth;
|
||||
borderBottom.lineStyle(1, 0x0348A8);
|
||||
borderBottom.setAlpha(0.2);
|
||||
borderBottom.beginPath();
|
||||
borderBottom.moveTo(x, y);
|
||||
borderBottom.lineTo(x + lineWidth, y);
|
||||
borderBottom.strokePath();
|
||||
|
||||
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);
|
||||
// windowLoad();
|
||||
submitUserData(this);
|
||||
showAnimation();
|
||||
parentMainContainer.classList.remove('hidden');
|
||||
})
|
||||
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
|
||||
this.add.text(customWidth / 10, 20, "Letter : s", { font: '700 40px quicksand', fill: '#05b3a4', });
|
||||
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
|
||||
|
||||
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud').setAlpha(0.9);
|
||||
cloud.setDepth(-1.8);
|
||||
const scrollSpeed = 0.5;
|
||||
this.time.addEvent({
|
||||
loop: true,
|
||||
callback: () => {
|
||||
cloud.tilePositionX += scrollSpeed;
|
||||
},
|
||||
delay: 16, // Adjust the delay for the desired scrolling speed
|
||||
});
|
||||
|
||||
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
|
||||
|
||||
// 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, 'letterS').setAlpha(0.2).setDepth(0.5).setScale(letterScale);
|
||||
const firstScreen = this.add.image(customWidth / 2 + 90, customHeight / 2 + letterHeight, 'letterS').setDepth(2).setScale(letterScale);
|
||||
// const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'animatedS').setDepth(2); canvasStand
|
||||
firstScreen.setVisible(false);
|
||||
// this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
const canvas = this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
|
||||
// Set up a mask for the drawing area based on the canvas dimensions
|
||||
const maskGraphics = this.make.graphics()
|
||||
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',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
hideButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.stop();
|
||||
isDemoButtonClicked = false;
|
||||
firstScreen.setVisible(false);
|
||||
hideButton.setVisible(false); // Hide the "Hide" button
|
||||
demoButton.setVisible(true); // Show the "Demo" button
|
||||
graphics.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
});
|
||||
hideButton.setVisible(false);
|
||||
let demoButton = this.add.text(helpButtonWidth, helpButtonHeight, "Demo", {
|
||||
font: '900 24px quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor: '#7c4c23',
|
||||
padding: { x: 20, y: 10 },
|
||||
borderRadius: '15px', // Border radius
|
||||
shadow: {
|
||||
offsetX: 2, // X offset for the shadow
|
||||
offsetY: 2, // Y offset for the shadow
|
||||
color: '#000', // Shadow color
|
||||
blur: 5, // Shadow blur
|
||||
fill: true // Apply shadow to fill (background color)
|
||||
}
|
||||
});
|
||||
|
||||
demoButton.setInteractive().on('pointerdown', () => {
|
||||
animatedLetter.setCurrentTime(0);
|
||||
animatedLetter.play(true);
|
||||
graphics.setVisible(false);
|
||||
firstScreen.setVisible(true);
|
||||
demoButton.setVisible(false); // Hide the "Demo" button
|
||||
hideButton.setVisible(true); // Show the "Hide" button
|
||||
animatedLetter.setVisible(true);
|
||||
});
|
||||
|
||||
|
||||
const screenCenterX = this.cameras.main.worldView.x + this.cameras.main.width / 2;
|
||||
const baseFontSize = 24;
|
||||
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
|
||||
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : s', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedSHeight, 'animatedS').setDepth(2).setScale(animatedVideoScale);
|
||||
if(animatedLetter.visible){
|
||||
animatedLetter.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
firstScreen.setVisible(false);
|
||||
} else{
|
||||
graphics.setVisible(false);
|
||||
animatedLetter.setVisible(true);
|
||||
firstScreen.setVisible(true);
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
let responsiveFontSize = isMobile ? 16 : 32;
|
||||
this.add.text(window.innerWidth / 2, 80, 'Letter: s', {fill: '#60C6CB', font: `900 ${responsiveFontSize}px quicksand`}).setOrigin(0.5);
|
||||
const descrptText = this.add.text(window.innerWidth/2, 125, 'Let`s learn how to write letter : s', { font: `900 ${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
|
||||
animatedLetter = this.add.video(customWidth / 2 , customHeight / 2 + animatedSHeight, 'animatedS').setDepth(2).setScale(animatedVideoScale);
|
||||
// Play the video
|
||||
// animatedLetter.play();
|
||||
animatedLetter.setVisible(false);
|
||||
|
@ -255,16 +273,16 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
let textX, textY;
|
||||
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 13 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(textX, textY, '1. Hook Around Snake',{ font: '700 35px quicksand', fill: '#05b3a4'});
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
let stepTextSize = isMobile ? 12 : 16;
|
||||
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1').setScale(letterScale);
|
||||
textX = isMobile ? customWidth / 13 : customWidth * 0.75;
|
||||
textY = isMobile ? customHeight / 5 : customHeight / 2.4;
|
||||
const firstTextLayer = this.add.text(window.innerWidth / 2, window.innerHeight / 1.2, '1. Hook Around Snake',{ font: `600 ${stepTextSize}px quicksand`, fill: '#000000'}).setOrigin(0.5);
|
||||
const audioOneAudio = this.sound.add('audioOne');
|
||||
// audioOneAudio.play();
|
||||
firstLayer.setDepth(1);
|
||||
firstLayer.setAlpha(0.5);
|
||||
firstLayer.setInteractive({ draggable: true });
|
||||
|
||||
|
||||
|
||||
|
@ -290,7 +308,6 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
});
|
||||
|
||||
graphics = this.add.graphics();
|
||||
graphics.setMask(mask);
|
||||
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
|
||||
this.input.on('pointerdown', function (pointer) {
|
||||
isDrawing = true;
|
||||
|
@ -307,30 +324,14 @@ let scoreTotal = 0; let isDrawing = false;
|
|||
graphics.lineTo(pointer.x, pointer.y);
|
||||
graphics.strokePath();
|
||||
});
|
||||
let startButton = this.add.text(startButtonWidth, startButtonHeight, "Start", {
|
||||
font: '900 24px Quicksand',
|
||||
fill: '#05b3a4',
|
||||
backgroundColor : '#7c4c23',
|
||||
padding: {x: 20, y: 10},
|
||||
shadow: {
|
||||
offsetX : 2,
|
||||
offsetY : 2,
|
||||
color: '#000',
|
||||
blur: 5,
|
||||
fill: true
|
||||
}
|
||||
})
|
||||
firstTextLayer.setVisible(false);
|
||||
startButton.setInteractive().on('pointerdown', () => {
|
||||
document.getElementById('beforeStartBtn').addEventListener('click', function() {
|
||||
document.getElementById('blurDisplay').classList.add('hidden');
|
||||
audioOneAudio.play();
|
||||
submitButton.setVisible(true);
|
||||
firstTextLayer.setVisible(true);
|
||||
animatedLetter.setVisible(false);
|
||||
firstScreen.setVisible(false);
|
||||
graphics.setVisible(true);
|
||||
hideButton.setVisible(false);
|
||||
demoButton.setVisible(true);
|
||||
startButton.setVisible(false);
|
||||
})
|
||||
|
||||
|
||||
|
@ -340,4 +341,41 @@ function update() {
|
|||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
.clear-button {
|
||||
background-color: blue;
|
||||
}
|
||||
/* Animation styles */
|
||||
@keyframes slideInUp {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%); /* Start below the viewport */
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0); /* End at its original position */
|
||||
}
|
||||
}
|
||||
|
||||
.clip-art-container {
|
||||
overflow: hidden; /* Prevents overflow during the animation */
|
||||
}
|
||||
|
||||
.clip-art {
|
||||
transform: translateX(100%); /* Initially off-screen to the right */
|
||||
opacity: 0; /* Initially hidden */
|
||||
transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; /* Smooth transition */
|
||||
}
|
||||
|
||||
.clip-art.show {
|
||||
transform: translateX(0); /* Move the image into view */
|
||||
opacity: 1; /* Fade in */
|
||||
}
|
||||
.slide{
|
||||
display: none;
|
||||
}
|
||||
.active{
|
||||
display: block;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue