Next_Work_on_Responsevness
parent
d882f2db00
commit
28dd7ab327
|
@ -1,14 +1,19 @@
|
||||||
---
|
---
|
||||||
import Layout from '../../layouts/Layout.astro';
|
import Layout from '../../layouts/Layout.astro';
|
||||||
// const planResp = await fetch('https://api8.siliconpin.com/items/hosting?filter[status][_eq]=published');
|
const data = await fetch('https://management.beanstalkedu.com/items/game_drag');
|
||||||
// const planRespJson = await planResp.json();
|
const dataJson = await data.json();
|
||||||
// const planRespData = planRespJson.data;
|
const description = dataJson.data[2].description;
|
||||||
|
console.log(description)
|
||||||
---
|
---
|
||||||
<Layout title="Drag Game">
|
<Layout title="Drag Game">
|
||||||
<main>
|
<main>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<img style="width: 100%; height: 150px;" src="/assets/topbar1.jpg" alt="">
|
<!-- <img style="width: 100%; height: 150px;" src="/assets/topbar1.jpg" alt=""> -->
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<!-- <h2>{description}</h2> -->
|
||||||
|
<!-- <h2 class="text-center text-4xl font-bold text-[#7c4c23] xl:w-2/3">Match the words on the left side with their rhyming words on the right by drawing lines</h2> -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="overlap">
|
<div id="overlap">
|
||||||
<div id="result"></div>
|
<div id="result"></div>
|
||||||
|
@ -85,14 +90,40 @@ const blockMatches = [
|
||||||
targetName: "target4",
|
targetName: "target4",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
//let counter = 0; // Counter variable
|
|
||||||
class MyGame extends Phaser.Scene {
|
class MyGame extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
preload() {
|
preload() {
|
||||||
// this.load.image("wrong", "https://management.beanstalkedu.com/assets/1320eec6-3029-41e5-8aad-904e590cb420");
|
fetch(`https://management.beanstalkedu.com/items/game_drag`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data.data);
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const paramsID = params.get('id');
|
||||||
|
console.log(paramsID);
|
||||||
|
fetch(`https://management.beanstalkedu.com/items/game_drag/${encodeURIComponent(paramsID)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(dataWithParamsID => {
|
||||||
|
const description = dataWithParamsID.data.description;
|
||||||
|
console.log(description);
|
||||||
|
const text = this.add.text(900, 20, description, {
|
||||||
|
fontSize: '32px',
|
||||||
|
color: '#ffffff',
|
||||||
|
});
|
||||||
|
|
||||||
|
text.setOrigin(0.5);
|
||||||
|
// let description_txt = this.add.text(0, 0, description, {font: '40px Ariel', fill: '#7c4c23' });
|
||||||
|
Phaser.Display.Align.In.Center(description_txt);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching data using paramsID:', error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching initial data:', error);
|
||||||
|
});
|
||||||
|
|
||||||
this.load.image("tick", '/assets/tick.png');
|
this.load.image("tick", '/assets/tick.png');
|
||||||
this.load.image("bg", '/assets/background.jpg');
|
this.load.image("bg", '/assets/background.jpg');
|
||||||
this.load.image("target1", '/assets/yam.png');
|
this.load.image("target1", '/assets/yam.png');
|
||||||
|
@ -118,9 +149,26 @@ class MyGame extends Phaser.Scene {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
create() {
|
create() {
|
||||||
|
fetch(`https://management.beanstalkedu.com/items/game_drag`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
// console.log(data.data);
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const paramsID = params.get('id');
|
||||||
|
console.log(paramsID);
|
||||||
|
fetch(`https://management.beanstalkedu.com/items/game_drag/${encodeURIComponent(paramsID)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(dataWithParamsID => {
|
||||||
|
const leftImage1 = dataWithParamsID.data.left_image1
|
||||||
|
console.log(leftImage1);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching data using paramsID:', error);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching initial data:', error);
|
||||||
|
});
|
||||||
// fetch(`https://management.beanstalkedu.com/items/game_drag`)
|
// fetch(`https://management.beanstalkedu.com/items/game_drag`)
|
||||||
// .then(response => response.json())
|
// .then(response => response.json())
|
||||||
// .then(data => {
|
// .then(data => {
|
||||||
|
@ -281,43 +329,17 @@ const isMatch = (blockName, targetName) => {
|
||||||
// console.log("Result", result)
|
// console.log("Result", result)
|
||||||
return match !== undefined;
|
return match !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Example usage
|
|
||||||
|
|
||||||
|
|
||||||
// Calculate the sum total points
|
|
||||||
// for (const match of blockMatches) {
|
|
||||||
// isMatch(match.blockName, match.targetName);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("Sum Total Points:", counter);
|
|
||||||
|
|
||||||
|
|
||||||
// let counter = 0;
|
|
||||||
|
|
||||||
// const isMatch = (blockName, targetName) => {
|
|
||||||
// const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
|
|
||||||
|
|
||||||
// if (match) {
|
|
||||||
// counter++;
|
|
||||||
// }
|
|
||||||
// if (counter <= 4) {
|
|
||||||
// console.log("Points:", counter);
|
|
||||||
// } else {
|
|
||||||
// console.log("Matchggg:", counter);
|
|
||||||
// }
|
|
||||||
// return match !== undefined;
|
|
||||||
// };
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
type: Phaser.AUTO,
|
type: Phaser.AUTO,
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
|
|
||||||
parent: "phaser-example",
|
parent: "phaser-example",
|
||||||
scale: {
|
scale: {
|
||||||
mode: Phaser.Scale.FIT,
|
mode: Phaser.Scale.FIT,
|
||||||
autoCenter: Phaser.Scale.CENTER_BOTH,
|
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
|
||||||
},
|
},
|
||||||
|
|
||||||
scene: MyGame,
|
scene: MyGame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue