worked on drag games score calculations
This commit is contained in:
@@ -80,6 +80,7 @@ import Layout from '../../layouts/Layout.astro';
|
||||
let formattedDateTime;
|
||||
let shortUniqueID;
|
||||
let retryButton;
|
||||
let blockMatches;
|
||||
gameResult = [];
|
||||
window.onload = function() {
|
||||
// Get the current date and time
|
||||
@@ -102,7 +103,7 @@ import Layout from '../../layouts/Layout.astro';
|
||||
{
|
||||
x: leftTargetZoneW + 30,
|
||||
y: window.innerHeight / 2.5,
|
||||
name: "leftTarget1",
|
||||
name: "target1",
|
||||
block: null,
|
||||
},
|
||||
// Add more left target zones as needed
|
||||
@@ -112,52 +113,13 @@ import Layout from '../../layouts/Layout.astro';
|
||||
{
|
||||
x: rightTargetZoneW - 30,
|
||||
y: window.innerHeight / 2.5,
|
||||
name: "rightTarget1",
|
||||
name: "target2",
|
||||
block: null,
|
||||
},
|
||||
// Add more right target zones as needed
|
||||
];
|
||||
|
||||
const targetZones = [...leftTargetZones, ...rightTargetZones];
|
||||
|
||||
const blockMatches = [
|
||||
{
|
||||
blockName: "blocks1",
|
||||
targetName: "target1",
|
||||
},
|
||||
{
|
||||
blockName: "blocks2",
|
||||
targetName: "target2",
|
||||
},
|
||||
{
|
||||
blockName: "blocks3",
|
||||
targetName: "target3",
|
||||
},
|
||||
{
|
||||
blockName: "blocks4",
|
||||
targetName: "target4",
|
||||
},
|
||||
{
|
||||
blockName: "blocks5",
|
||||
targetName: "target5",
|
||||
},
|
||||
{
|
||||
blockName: "blocks6",
|
||||
targetName: "target6",
|
||||
},
|
||||
{
|
||||
blockName: "blocks7",
|
||||
targetName: "target7",
|
||||
},
|
||||
{
|
||||
blockName: "blocks8",
|
||||
targetName: "target8",
|
||||
},
|
||||
{
|
||||
blockName: "blocks9",
|
||||
targetName: "target9",
|
||||
},
|
||||
];
|
||||
// console.log(blockMatches.blockName, blockMatches.targetName)
|
||||
var assetsList = {};
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
@@ -327,6 +289,40 @@ import Layout from '../../layouts/Layout.astro';
|
||||
fetch(`https://game-du.teachertrainingkolkata.in/items/game_drag_v4/${encodeURIComponent(paramsID)}?filter[status][_eq]=published`)
|
||||
.then(response => response.json())
|
||||
.then(({ data }) => {
|
||||
blockMatches = [
|
||||
{
|
||||
blockName: "blocks1",
|
||||
targetName: `target${data.match1}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks2",
|
||||
targetName: `target${data.match2}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks3",
|
||||
targetName: `target${data.match3}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks4",
|
||||
targetName: `target${data.match4}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks5",
|
||||
targetName: `target${data.match5}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks6",
|
||||
targetName: `target${data.match6}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks7",
|
||||
targetName: `target${data.match7}`,
|
||||
},
|
||||
{
|
||||
blockName: "blocks8",
|
||||
targetName: `target${data.match8}`,
|
||||
}
|
||||
];
|
||||
// console.log(data)
|
||||
if(isMobile){
|
||||
this.add.text(window.innerWidth / 24, window.innerHeight / 6, data.left_label, {font:`13px`, fill: `#7C4C23`});
|
||||
@@ -403,50 +399,50 @@ import Layout from '../../layouts/Layout.astro';
|
||||
this.add.image(displayW * 0.80-5, 30, "topLogo").setScale();
|
||||
const blocks = [
|
||||
{
|
||||
x: displayW / 2,
|
||||
y: window.innerHeight - 120,
|
||||
x: displayW / 2 - 200,
|
||||
y: window.innerHeight - 250,
|
||||
textureKey: "blocks1",
|
||||
id: "block1",
|
||||
},
|
||||
{
|
||||
x: displayW / 2-100,
|
||||
y: window.innerHeight - 120,
|
||||
y: window.innerHeight - 250,
|
||||
textureKey: "blocks2",
|
||||
id: "block2",
|
||||
},
|
||||
{
|
||||
x: displayW / 2+100,
|
||||
y: window.innerHeight - 120,
|
||||
x: displayW / 2,
|
||||
y: window.innerHeight - 250,
|
||||
textureKey: "blocks3",
|
||||
id: "block3",
|
||||
},
|
||||
{
|
||||
x: displayW / 2-200,
|
||||
y: window.innerHeight - 120,
|
||||
x: displayW / 2+100,
|
||||
y: window.innerHeight - 250,
|
||||
textureKey: "blocks4",
|
||||
id: "block4",
|
||||
},
|
||||
{
|
||||
x: displayW / 2,
|
||||
y: window.innerHeight - 250,
|
||||
x: displayW / 2-200,
|
||||
y: window.innerHeight - 120,
|
||||
textureKey: "blocks5",
|
||||
id: "block5",
|
||||
},
|
||||
{
|
||||
x: displayW / 2-100,
|
||||
y: window.innerHeight - 250,
|
||||
y: window.innerHeight - 120,
|
||||
textureKey: "blocks6",
|
||||
id: "block6",
|
||||
},
|
||||
{
|
||||
x: displayW / 2+100,
|
||||
y: window.innerHeight - 250,
|
||||
x: displayW / 2,
|
||||
y: window.innerHeight - 120,
|
||||
textureKey: "blocks7",
|
||||
id: "block7",
|
||||
},
|
||||
{
|
||||
x: displayW / 2-200,
|
||||
y: window.innerHeight - 250,
|
||||
x: displayW / 2+100,
|
||||
y: window.innerHeight - 120,
|
||||
textureKey: "blocks8",
|
||||
id: "block8",
|
||||
},
|
||||
@@ -528,24 +524,25 @@ import Layout from '../../layouts/Layout.astro';
|
||||
let counter = 0;
|
||||
|
||||
const isMatch = (blockName, targetName) => {
|
||||
if(isMatch){
|
||||
counter++;
|
||||
// console.log(counter)
|
||||
if(isMatch){
|
||||
counter++;
|
||||
console.log(counter)
|
||||
|
||||
if(counter === 8){
|
||||
const overlap = document.getElementById("overlap");
|
||||
overlap.style.display = "block";
|
||||
console.log(counter)
|
||||
submitButton.setVisible(true);
|
||||
retryButton.setVisible(true);
|
||||
if(counter === 8){
|
||||
const overlap = document.getElementById("overlap");
|
||||
overlap.style.display = "block";
|
||||
console.log(counter)
|
||||
submitButton.setVisible(true);
|
||||
retryButton.setVisible(true);
|
||||
}
|
||||
}
|
||||
const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
|
||||
console.log(match)
|
||||
let scoreTotal=0;
|
||||
if(match !== undefined){
|
||||
scoreTotal++;
|
||||
console.log("Score Total", scoreTotal)
|
||||
}
|
||||
}
|
||||
const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
|
||||
let scoreTotal=0;
|
||||
if(match){
|
||||
scoreTotal++;
|
||||
// console.log(scoreTotal)
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user