change code server

pull/5/head
Dev 1 2023-10-03 20:35:21 +05:30
parent d7e64fff32
commit 327df5d313
10 changed files with 90 additions and 42 deletions

BIN
public/assets/backgroundImage.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
public/assets/bg3.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
public/assets/bg5.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 MiB

BIN
public/assets/bg6.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
public/assets/canvas.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

BIN
public/assets/canvas2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
public/assets/cloud.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -32,12 +32,29 @@ import Layout from "../../layouts/Layout.astro";
update: update
}
};
// backgroundImage.png
const game = new Phaser.Game(config);
const customWidth = window.innerWidth;
const customHeight = window.innerHeight;
let firstLayer, secondLayer, thirdLayer;
let graphics;
let isDrawing = false;
if(isMobile){
cloudeSize = 200;
cloudHeight = 340;
canvasScale = 0.23
canvasHeight = 154;
letterHeight = 70;
backgroundScale = 0.8;
} else{
cloudeSize = 500;
cloudHeight = 250;
canvasScale = 0.3;
canvasHeight = 100;
letterHeight = 0;
backgroundScale = 1;
}
// let hideButton;
function preload() {
@ -51,13 +68,33 @@ import Layout from "../../layouts/Layout.astro";
this.load.image('topLogo', '/assets/top_logo.png');
this.load.svg('succesImage', '/assets/svg/tick.svg');
this.load.svg('handPointer', '/assets/svg/hand.svg');
// this.load.image('backgroundImage', '/assets/backgroundImage2.png');
this.load.image('backgroundImage', '/assets/bg6.png');
this.load.image('cloud', '/assets/cloud.png');
this.load.image('canvas', '/assets/canvas2.png');
}
function create() {
this.add.image(customWidth / 2 * 1.6 - 0.5, 50, 'topLogo');
this.add.text(customWidth / 10, 20, "Letter : A", { font: '700 40px quicksand', fill: '#05b3a4', });
const firstScreen = this.add.image(customWidth / 2, customHeight / 2, 'letterA');
// this.add.image(customWidth / 2, 50, 'cloud').setDepth(1.9);
const cloud = this.add.tileSprite(customWidth / 2, customHeight / 2 - cloudHeight, customWidth, cloudeSize, 'cloud');
cloud.setDepth(-1.9);
const scrollSpeed = 0.5;
this.time.addEvent({
loop: true,
callback: () => {
cloud.tilePositionX += scrollSpeed;
},
delay: 16, // Adjust the delay for the desired scrolling speed
});
const backgroundImages = this.add.image(customWidth / 2, customHeight /2, 'backgroundImage').setDepth(-2).setScale(backgroundScale);
this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setAlpha(0.2).setDepth(0.5);
const firstScreen = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'letterA').setDepth(2);
this.add.image(customWidth / 2, customHeight / 2 + canvasHeight, 'canvas').setScale(canvasScale);
firstScreen.setVisible(false);
let hideButton = this.add.text(customWidth / 2, customHeight / 1.1, "Let`s Do", { font: '24px quicksand', fill: '#05b3a4' });
@ -73,7 +110,10 @@ import Layout from "../../layouts/Layout.astro";
});
hideButton.setVisible(false);
let demoButton = this.add.text(customWidth / 2, customHeight / 1.1, "Help", { font: '24px quicksand', fill: '#05b3a4' });
let demoButton = this.add.text(customWidth / 2, customHeight / 1.1, "Help!", { font: '900 24px quicksand', fill: '#05b3a4', backgroundColor: '#7c4c23'}).setPadding(20, 10);
// demoButton.style.borderRadius = "25px";
// demoButton.style.set('borderRadius', '15px');
demoButton.setInteractive().on('pointerdown', () => {
graphics.setVisible(false);
firstScreen.setVisible(true);
@ -90,9 +130,9 @@ import Layout from "../../layouts/Layout.astro";
const responsiveFontSize = (window.innerWidth / 480) * baseFontSize;
const descrptText = this.add.text(screenCenterX, 90, 'Let`s learn how to write letter : A', { font: `${responsiveFontSize}px quicksand`, fill: '#7c4c23', fontWeight : 'bold'}).setOrigin(0.5);
let textX, textY;
let textX = window.innerWidth / 2, textY;
firstLayer = this.add.image(customWidth / 2, customHeight / 2, 'layer1');
firstLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer1');
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
textY = isMobile ? customHeight / 5 : customHeight / 2;
const firstTextLayer = this.add.text(textX, textY, '1. Slant Left', { font: '700 40px quicksand', fill: '#05b3a4'});
@ -102,7 +142,7 @@ import Layout from "../../layouts/Layout.astro";
firstLayer.setAlpha(0.5);
firstLayer.setInteractive({ draggable: true });
secondLayer = this.add.image(customWidth / 2, customHeight / 2, 'layer2');
secondLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer2');
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
const secondTextLayer = this.add.text(textX, textY, '2. Slant Right', { font: '700 40px quicksand', fill: '#05b3a4'});
const slantRightAudio = this.sound.add('slantRight');
@ -112,7 +152,7 @@ import Layout from "../../layouts/Layout.astro";
secondLayer.setInteractive({ draggable: true });
secondLayer.setVisible(false);
thirdLayer = this.add.image(customWidth / 2, customHeight / 2, 'layer3');
thirdLayer = this.add.image(customWidth / 2, customHeight / 2 + letterHeight, 'layer3');
textX = isMobile ? customWidth / 3 : customWidth * 0.75;
const thirdTextLayer = this.add.text(textX, textY, '3. Slide', { font: '700 40px quicksand', fill: '#05b3a4'});
const slideAudio = this.sound.add('slide');
@ -162,7 +202,7 @@ import Layout from "../../layouts/Layout.astro";
}
});
graphics = this.add.graphics();
graphics.lineStyle(15, 0x05b3a4, 2).setDepth(2); // Set line style (width, color, alpha)
graphics.lineStyle(15, 0xFFFFFF, 2).setDepth(2); // Set line style (width, color, alpha)
this.input.on('pointerdown', function (pointer) {
isDrawing = true;
@ -257,11 +297,8 @@ import Layout from "../../layouts/Layout.astro";
// Start Position 626 317
}
// function showLayersWithFadeIn() {
// }
function update() {
// Update any game logic if needed
}
function update() {
}
</script>

View File

@ -3,44 +3,55 @@
<script is:inline>
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
width: window.innerWidth,
height: window.innerHeight,
scene: {
create: create
preload: preload,
create: create,
update: update
}
};
const game = new Phaser.Game(config);
let svgPath = "M100,200 C100,100 400,100 400,200";
let points = parseSvgPath(svgPath);
const game = new Phaser.Game(config);
const customWidth = window.innerWidth;
const customHeight = window.innerHeight;
let ellipseCenter;
let ellipseRadiusX = 74;
let ellipseRadiusY = 100;
let angle = 0;
let rotationSpeed = 0.02; // Adjust rotation speed as needed
let rotatingObject;
function preload(){
this.load.image('handPointer', '/assets/svg/hand.svg');
this.load.image('letterO', '/assets/capital-letter/o.svg')
}
function create() {
// Visualize the SVG path using Phaser graphics (optional)
const graphics = this.add.graphics();
graphics.lineStyle(2, 0xffffff);
for (let i = 0; i < points.length - 1; i++) {
graphics.lineBetween(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y);
}
this.add.image(customWidth / 2, customHeight / 2, 'letterO');
// Create an ellipse (in this case, a visual representation)
// const graphics = this.add.graphics();
// graphics.lineStyle(2, 0xffffff);
// graphics.strokeEllipse(customWidth / 2, customHeight / 2, ellipseRadiusX * 2, ellipseRadiusY * 2);
ellipseCenter = new Phaser.Math.Vector2(customWidth / 2, customHeight / 2); // Center of the ellipse
rotatingObject = this.add.sprite(ellipseCenter.x + ellipseRadiusX, ellipseCenter.y, 'handPointer');
rotatingObject.setScale(0.5).setDepth(2); // Adjust scale as needed
}
function parseSvgPath(path) {
// Parse SVG path data to extract points
// This is a simple example and may not cover all SVG path commands
const commands = path.match(/[a-df-z]|[\-+]?\d+(\.\d+)?/ig);
const points = [];
let currentPoint = { x: 0, y: 0 };
function update() {
// Update the angle for rotation
angle -= rotationSpeed;
commands.forEach((command, index) => {
if (!isNaN(command)) {
const isX = (index % 2 === 0);
currentPoint[isX ? 'x' : 'y'] = parseFloat(command);
points.push({ ...currentPoint });
}
});
// Calculate new position based on the angle and radii
const radius = Math.max(ellipseRadiusX, ellipseRadiusY);
const x = ellipseCenter.x + radius * Math.cos(angle);
const y = ellipseCenter.y + radius * Math.sin(angle);
return points;
rotatingObject.x = x;
rotatingObject.y = y;
// Rotate the object based on the angle (optional)
rotatingObject.rotation = angle;
}
</script>