Разработка игрового развивающего приложения для детей дошкольного возраста на языке Javascript

Анализ примеров компьютерных игр для детей дошкольного возраста. Специфические особенности реализации серверной части программного приложения. Методы проектирования пользовательского интерфейса. Порядок внедрения разработанной информационной системы.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 14.12.2019
Размер файла 6,3 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

Field.fullnessField = [0, 0, 0, 0, 0, 0, 0, 0, 0];

GameState.CurStep++;

if (GameState.CurStep < 6) {

setLockVegetables(GameState.CurStep);

setUnlockVegetables();

if (GameState.CurStep == 1)

Quest_Text.text = "Расставь овощи так, чтобы они не повторялись \n" + "по ВЕРТИКАЛИ";

else if (GameState.CurStep == 2 || GameState == 3)

Quest_Text.text = "Расставь овощи так, чтобы они не повторялись \n" + " по ГОРИЗОНТАЛИ";

else if (GameState.CurStep == 4 || GameState == 5)

Quest_Text.text = "Расставь овощи так, чтобы они не повторялись \n" + "по ВЕРТИКАЛИ и ГОРИЗОНТАЛИ";

} else {

Field.destroy();

Button.destroy();

Quest_Text.alpha = 0;

BackgroundBlack.visible = true;

MainReward.Reward.VisibleToggle();

MainSounds.Sounds.Win.play();

MainParticles.Star0.setYSpeed(100, 300);

MainParticles.Star0.start(false, Math.round(Game.height * 2.5), 0.2, 0);

MainParticles.Star1.start(false, Math.round(Game.height * 1.25), 0, 0);

finishGame(7);

}

}

function update() {

if (Commend_Text.activate) {

if (Commend_Text.alpha < 1) {

Commend_Text.alpha += 0.02;

} else {

Commend_Text.activate = false;

}

}

if (!Commend_Text.activate)

if (Commend_Text.alpha > 0)

Commend_Text.alpha -= 0.02;

MainParticles.Update();

MainReward.Update();

}

Файл: umland\src\Games\game_8

Game = new Phaser.Game(1200, 600, Phaser.AUTO, 'CanvasGame', {preload: preload, create: create, update: update});

Phaser.Game.prototype.showDebugHeader = function () {};

function preload() {

Game.stage.backgroundColor = "#fff";

Game.load.image("spr_background", "../Assets/Images/img_Backgrounds/" + "img_background_" + 4 + ".jpg");

Game.load.image("spr_apple", "../Assets/Images/img_Food/Fruits/" + "x128" + "/img_food_fruits_0.png")

Game.load.image("spr_basket", "../Assets/Images/img_Objects/img_corf.png");

Game.load.image("spr_pack_apples", "../Assets/Images/img_Food/Bunches/Other/" + "x512" + "/img_bunch_3.png");

MainParticles.Preload();

MainReward.Preload(0);

MainButtons.Preload();

MainSounds.Preload();

}

function NextLevelButton_Down(pointer) {

if (MainReward.Reward.Main.DrawUp) {

MainSounds.Sounds.Back.destroy();

MainSounds.Sounds.Win.destroy();

Game.state.start(Game.state.current);

}

}

function create() {

GameState = {};

GameState.CurStep = 0;

GameState.MaxStep = 3;

GameState.won = false;

BackGround = Game.add.image(0, 0, "spr_background");

BackGround.width = Game.width;

BackGround.height = Game.height;

apple = {};

apple = Game.add.image(Game.input.x, Game.input.y, "spr_apple");

apple.anchor.x = 0.5;

apple.anchor.y = 0.5;

apple.angle = 0;

apple.width = Math.round(Game.width * 0.05);

apple.height = 0;

apple.tint = "0xffffff";

apple.alpha = 0.90;

baskets = {};

let distance = 0;

for (let i = 0; i < 3; i++) {

baskets[i] = Game.add.image(0, 0, "spr_basket");

baskets[i].anchor.set(0.5, 0.5);

baskets[i].width = Math.round(Game.width * 0.13);

baskets[i].height = baskets[i].width;

baskets[i].x = Game.width / 6 + baskets[i].width * distance;

baskets[i].y = Game.height / 2;

baskets[i].inputEnabled = true;

baskets[i].isEmpty = true;

distance += 1.7;

}

bars = {};

bars[0] = {}

bars[1] = {}

bars[2] = {}

drawApplesBar(0);

drawApplesBar(1);

drawApplesBar(2);

function drawApplesBar(numBaskets) {

let distance = 0;

bars[numBaskets].fullness = Math.round(Math.random() * 9);

for (let i = 0; i < 9; i++) {

bars[numBaskets][i] = Game.add.image(0, 0, "spr_apple");

bars[numBaskets][i].width = Math.round(Game.width * 0.025);

bars[numBaskets][i].height = bars[numBaskets][i].width;

bars[numBaskets][i].anchor.set(0.5, 0.5);

bars[numBaskets][i].x = (baskets[numBaskets].x - baskets[numBaskets].width / 2 * 1.3) + bars[numBaskets][i].width * distance;

bars[numBaskets][i].y = Game.height / 2 + baskets[0].height / 1.5;

bars[numBaskets][i].angle = 30;

bars[numBaskets][i].alpha = 0.5;

if (i >= bars[numBaskets].fullness)

bars[numBaskets][i].tint = "0x000000";

else

bars[numBaskets][i].tint = "0xffffff"

bars[numBaskets][i].fill = false;

distance += 0.85;

}

}

for (let i = 0; i < 3; i++) {

baskets[i].events.onInputDown.add(function () {

if (bars[i].fullness != 0) {

apple.height = apple.width;

apple.inputEnabled = true;

apple.isDraging = true;

bars[i].fullness--;

bars[i][bars[i].fullness].tint = "0x000000";

bars[i][bars[i].fullness].alpha = 0.5;

}

}, this);

}

applesPack = Game.add.image(0, 0, "spr_pack_apples");

applesPack.width = Math.round(Game.width * 0.2);

applesPack.height = applesPack.width;

applesPack.anchor.set(0.5, 0.5);

applesPack.x = Game.width - Game.width / 8

applesPack.y = Game.height / 2

applesPack.inputEnabled = true;

applesPack.events.onInputDown.add(function () {

apple.height = apple.width;

apple.inputEnabled = true;

apple.isDraging = true;

}, this);

numApplesText = {}

for (let i = 0; i < 3; i++) {

let style = {font: "40px Trebuchet MS", fill: "#ffffff", align: "center"};

numApplesText[i] = Game.add.text(Game.world.centerX, 5, "", style);

numApplesText[i].anchor.set(0.5, 0.0);

numApplesText[i].stroke = "#000000";

numApplesText[i].fontSize = (Game.width * 0.3) * 0.1 + "px";

numApplesText[i].strokeThickness = Math.floor(numApplesText[i].fontSize * 0.15);

numApplesText[i].text = Math.round(Math.random() * 8 + 1);

numApplesText[i].x = (baskets[i].x)

numApplesText[i].y = baskets[i].y - baskets[i].height;

}

var style = {font: "64px Trebuchet MS", fill: "#ffffff", align: "center"};

Quest_Text = Game.add.text(Game.world.centerX, 5, "", style);

Quest_Text.anchor.set(0.5, 0.0);

Quest_Text.text = "";

Quest_Text.font = "Trebuchet MS";

Quest_Text.fontSize = Game.width * 0.03 + "px";

Quest_Text.stroke = "#000000";

Quest_Text.strokeThickness = Math.floor(Quest_Text.fontSize * 0.15);

Quest_Text.alpha = 1;

Quest_Text.inputEnabled = true;

Quest_Text.text = "Распредели яблоки так,\n" + "как написано над корзинами";

var style = {font: "20px Trebuchet MS", fill: "#ffffff", align: "center"};

Commend_Text = Game.add.text(Game.world.centerX / 4, Game.world.centerY, "", style);

Commend_Text.anchor.set(0.5, 0.5);

Commend_Text.goodTexts = ["Молодец!", "Умница!", "Продолжай!"];

Commend_Text.badTexts = ["Неправильно!", "Попробуй ещё раз!", "Ошибка!"];

Commend_Text.text = "Молодец!";

Commend_Text.stroke = "#000000";

Commend_Text.strokeThickness = Math.floor(Commend_Text.fontSize * 0.15);

Commend_Text.activate = false;

Commend_Text.fontSize = Game.width * 0.03 + "px";

Commend_Text.x = Game.width / 2;

Commend_Text.y = Game.height / 1.1;

Commend_Text.alpha = 0;

BackgroundBlack = Game.add.image(0, 0, "spr_background");

BackgroundBlack.width = Game.width;

BackgroundBlack.height = Game.height;

BackgroundBlack.tint = "0x000000";

BackgroundBlack.alpha = 0.25;

BackgroundBlack.inputEnabled = true;

BackgroundBlack.visible = false;

BackgroundBlack.events.onInputDown.add(NextLevelButton_Down, this);

MainParticles.Create();

MainButtons.Create();

MainButtons.MuteToggleButton_Down();

MainReward.Create();

MainSounds.Create();

GameCanvasShow();

}

function update() {

if (Game.input.activePointer.isDown) {

if (apple.isDraging) {

apple.x = Game.input.x;

apple.y = Game.input.y - apple.height * 0.5;

apple.angle += 1;

}

} else {

if (apple.isDraging) {

draggingOfApples(0);

draggingOfApples(1);

draggingOfApples(2);

if (bars[0].fullness == numApplesText[0].text

&& bars[1].fullness == numApplesText[1].text

&& bars[2].fullness == numApplesText[2].text)

GameState.won = true;

}

}

if (GameState.won) {

GameState.CurStep++;

if (GameState.CurStep < GameState.MaxStep) {

MainParticles.Star0.setYSpeed(500, 700);

MainParticles.Star0.start(true, Math.round(Game.height), 0, Math.round(Game.width * 0.025));

MainSounds.Sounds.Clicks[6].play();

if (Commend_Text.activate == false) {

Commend_Text.text = Commend_Text.goodTexts[Math.round(Math.random() * (Commend_Text.goodTexts.length - 1))];

Commend_Text.activate = true;

}

GameState.won = false

for (let i = 0; i < 3; i++)

numApplesText[i].text = Math.round(Math.random() * 8 + 1);

for (let i = 0; i < 3; i++) {

bars[i].fullness = Math.round(Math.random() * 9)

for (let j = 0; j < 9; j++) {

if (j >= bars[i].fullness)

bars[i][j].tint = "0x000000";

else

bars[i][j].tint = "0xffffff"

bars[i][j].fill = false;

}

}

} else {

Commend_Text.text = Commend_Text.goodTexts[Math.round(Math.random() * (Commend_Text.goodTexts.length - 1))];

Quest_Text.alpha = 0;

applesPack.destroy();

for (let i = 0; i < 3; i++)

numApplesText[i].alpha = 0;

for (let i = 0; i < 3; i++)

baskets[i].destroy();

for (let i = 0; i < 3; i++)

for (let j = 0; j < 9; j++)

bars[i][j].destroy();

BackgroundBlack.visible = true;

MainReward.Reward.VisibleToggle();

MainSounds.Sounds.Win.play();

MainParticles.Star0.setYSpeed(100, 300);

MainParticles.Star0.start(false, Math.round(Game.height * 2.5), 0.2, 0);

MainParticles.Star1.start(false, Math.round(Game.height * 1.25), 0, 0);

GameState.won = false;

finishGame(8);

}

}

if (Commend_Text.activate) {

if (Commend_Text.alpha < 1) {

Commend_Text.alpha += 0.02;

} else {

Commend_Text.activate = false;

}

}

if (!Commend_Text.activate)

if (Commend_Text.alpha > 0)

Commend_Text.alpha -= 0.02;

MainParticles.Update();

MainReward.Update();

}

function draggingOfApples(numBasket) {

let dist = Math.sqrt(Math.pow(baskets[numBasket].x - apple.x, 2) + Math.pow(baskets[numBasket].y - apple.y, 2));

apple.height = 0;

apple.isDraging = false;

if (dist < (baskets[numBasket].width * 0.5)) {

if (bars[numBasket].fullness < 9) {

bars[numBasket][bars[numBasket].fullness].tint = "0xffffff"

bars[numBasket].fullness += 1;

baskets[numBasket].isEmpty = false;

}

}

Файл: umland\src\Games\game_9

const Game = new Phaser.Game(1200, 600, Phaser.AUTO, 'CanvasGame',

{preload: preload, create: create, update: update});

Phaser.Game.prototype.showDebugHeader = function () {};

function preload() {

Game.stage.backgroundColor = "#fff";

Game.time.advancedTiming = true;

Game.load.image("spr_background", "../Assets/Images/img_Backgrounds/img_background_4.jpg");

Game.load.image("spr_basket", "../Assets/Images/img_Objects/img_corf.png");

Game.load.image("spr_btn_checkmark", "../Assets/Images/img_Icons/img_btn_checkmark.png");

Game.load.image("spr_btn_cross", "../Assets/Images/img_Icons/" + "img_btn_cross.png");

Game.load.image("spr_apple", "../Assets/Images/img_Food/Fruits/x128/img_food_fruits_0.png");

Game.load.image("spr_banan", "../Assets/Images/img_Food/Fruits/x128/img_food_fruits_1.png");

Game.load.image("spr_orange", "../Assets/Images/img_Food/Fruits/x128/img_food_fruits_2.png");

Game.load.image("spr_char_+", "../Assets/Images/img_ButtonNumbers/x128/img_BtnNumber_plus.png");

Game.load.image("spr_char_-", "../Assets/Images/img_ButtonNumbers/x128/img_BtnNumber_minus.png");

Game.load.image("spr_char_=", "../Assets/Images/img_ButtonNumbers/x128/s-20.png");

Game.load.image("spr_char_?", "../Assets/Images/img_ButtonNumbers/x128/s-24.png");

Game.load.image("spr_char_epmty", "../Assets/Images/img_ButtonNumbers/x128/img_BtnNumber_back.png");

for (var i = 0; i < 10; i++) {

Game.load.image(`spr_btn_number_" + i, "../Assets/Images/img_ButtonNumbers/x128/img_BtnNumber_${i}.png`);

}

MainParticles.Preload();

MainReward.Preload(0);

MainButtons.Preload();

MainSounds.Preload();

}

function NextLevelbutton_Down(pointer) {

if (MainReward.Reward.Main.DrawUp == true) {

MainSounds.Sounds.Back.destroy();

MainSounds.Sounds.Win.destroy();

Game.state.start(Game.state.current);

}

}

function create() {

GameState = {};

GameState.CurStep = 0;

GameState.MaxStep = 4;

BackGround = Game.add.image(0, 0, "spr_background");

BackGround.width = Game.width;

BackGround.height = Game.height;

basket = {};

createBasket();

mathTask = {};

createMathTask();

fruits = {};

fruitSize = Math.round(Game.width * 0.06);

createFruits();

panelFruit = {};

createPanelFruit();

button = {};

createButton();

let styleQuestText = {font: "64px Trebuchet MS", fill: "#ffffff", align: "center"};

Quest_Text = Game.add.text(Game.world.centerX, Game.height * 0.05, "", styleQuestText);

Quest_Text.anchor.set(0.5, 0.0);

Quest_Text.text = "";

Quest_Text.stroke = "#6B3E14";

Quest_Text.fontSize = Math.round((Game.height * 0.05));

Quest_Text.strokeThickness = Math.floor(Quest_Text.fontSize * 0.15);

Quest_Text.alpha = 1;

Quest_Text.text = "Сосчитай и заполни корзину";

BackgroundBlack = Game.add.image(0, 0, "spr_background");

BackgroundBlack.width = Game.width;

BackgroundBlack.height = Game.height;

BackgroundBlack.tint = "0x000000";

BackgroundBlack.alpha = 0.25;

BackgroundBlack.inputEnabled = true;

BackgroundBlack.visible = false;

BackgroundBlack.events.onInputDown.add(NextLevelbutton_Down, this);

MainParticles.Create();

MainButtons.Create();

MainButtons.MuteToggleButton_Down();

MainReward.Create();

MainSounds.Create();

GameCanvasShow();

}

const createBasket = () => {

basket = Game.add.image(0, 0, "spr_basket");

basket.anchor.set(0.5, 0.5);

basket.width = Math.round(Game.width * 0.15);

basket.height = Math.round(Game.width * 0.15);

basket.x = Game.width / 2;

basket.y = Game.height / 2;

basket.amountFruits = 0;

};

const createButton = () => {

button = Game.add.image(0, 0, "spr_btn_checkmark")

button.anchor.set(0.5, 0.5)

button.width = Math.round(Game.width * 0.08);

button.height = button.width;

button.x = Game.width / 2;

button.y = Game.height / 2 + basket.height

button.inputEnabled = true;

button.events.onInputDown.add(continueButton, this);

};

const createMathTask = () => {

mathTask.arrayFruits = ["spr_apple", "spr_banan", "spr_orange"];

mathTask.spriteFruit = mathTask.arrayFruits[Math.round(Math.random() * 2)];

mathTask.firstNum = createFirstNum();

mathTask.plusOrMinus = createPlusOrMinus(mathTask.firstNum.num);

mathTask.secondNum = createSecondNum(mathTask.firstNum.num, mathTask.plusOrMinus.sign);

mathTask.equal = createSignObject("spr_char_=", 6);

mathTask.questionMark = createSignObject("spr_char_?", 7);

mathTask.fruitBack1 = createSignObject("spr_char_epmty", 2);

mathTask.fruit1 = createSignObject(mathTask.spriteFruit, 2, true);

mathTask.fruitBack2 = createSignObject("spr_char_epmty", 5);

mathTask.fruit2 = createSignObject(mathTask.spriteFruit, 5, true);

mathTask.fruitBack3 = createSignObject("spr_char_epmty", 8);

mathTask.fruit3 = createSignObject(mathTask.spriteFruit, 8, true);

mathTask.answer = calculate(mathTask.firstNum.num, mathTask.plusOrMinus.sign, mathTask.secondNum.num);

}

const createFirstNum = () => {

const num = Math.round(Math.random() * 8) + 1;

const firstNum = createSignObject('spr_btn_number_' + num, 1)

firstNum.num = num;

return firstNum;

}

const createPlusOrMinus = (num1) => {

if (num1 === 1)

return createSign('+')

else if (num1 === 9)

return createSign('-')

return (Math.round(Math.random() * 1)) ? createSign('+') : createSign('-')

}

const createSecondNum = (num1, sign) => {

let num2 = Math.round(Math.random() * 7 + 1);

while (!isRightNum(num1, sign, num2))

num2 = Math.round(Math.random() * 7 + 1);

const secondNum = createSignObject('spr_btn_number_' + num2, 4)

secondNum.num = num2;

return secondNum;

}

const createSignObject = (nameSign, position, fruit = false) => {

const sign = Game.add.image(Game.world.centerX, Game.height / 5, nameSign);

sign.anchor.x = 0.5;

sign.anchor.y = 0.5;

sign.width = Math.round(Game.width * 0.05);

sign.height = Math.round(Game.width * 0.05);

sign.x = (Game.world.centerX - sign.width * 9 / 2) + sign.width * position

if (fruit) {

sign.width = Math.round(Game.width * 0.04);

sign.height = Math.round(Game.width * 0.04);

}

return sign;

}

const calculate = (num1, sign, num2) => {

if (sign === '+')

return num1 + num2

else if (sign === '-')

return num1 - num2

}

const createSign = (plusOrMinus) => {

const sign = createSignObject("spr_char_" + plusOrMinus, 3)

sign.sign = plusOrMinus;

return sign

}

const isRightNum = (num1, sign, num2) => {

if (sign === '+')

return (num1 + num2 < 10);

else if (sign === '-')

return (num1 - num2 > 0);

}

const createFruits = () => {

for (let i = 0; i < 27; i++) {

if (i < 9)

fruits[i] = Game.add.image(0, 0, "spr_apple");

else if (i >= 9 && i < 18)

fruits[i] = Game.add.image(0, 0, "spr_banan");

else if (i >= 18)

fruits[i] = Game.add.image(0, 0, "spr_orange");

fruits[i].anchor.set(0.5, 0.5);

fruits[i].width = fruitSize

fruits[i].height = fruitSize;

if (fruits[i].key === "spr_orange") {

fruits[i].width = Math.round(Game.width * 0.05)

fruits[i].height = fruits[i].width

}

fruits[i].angle = Math.round(Math.random() * 180)

randomFruitPosition(fruits[i])

fruits[i].events.onInputDown.add(dragFruit, this);

fruits[i].events.onDragStop.add(dropFruit, this);

fruits[i].inputEnabled = true;

fruits[i].isDraging = false

fruits[i].input.enableDrag(true);

}

Game.world.swap(basket, fruits[26]);

}

const dragFruit = (sprite) => {

sprite.isDraging = true;

const xStart = basket.x - basket.width / 2 + sprite.width / 2

const xEnd = basket.x + basket.width / 2 - sprite.width / 2

const yStart = basket.y - basket.height / 2

const yEnd = basket.y + basket.height / 2

if (sprite.x > xStart && sprite.x < xEnd && sprite.y > yStart && sprite.y < yEnd) {

let count = --basket.amountFruits

panelFruit.amountFruits.destroy()

panelFruit.amountFruits = createPartPanel('spr_btn_number_' + count)

}

}

const dropFruit = (sprite) => {

sprite.isDraging = false;

const xStart = basket.x - basket.width / 2 + sprite.width / 2

const xEnd = basket.x + basket.width / 2 - sprite.width / 2

const yStart = basket.y - basket.height / 2

const yEnd = basket.y + basket.height / 2

if (sprite.x > xStart - sprite.width / 2 && sprite.x < xEnd + sprite.width / 2 && sprite.y > yStart && sprite.y < yEnd)

if (mathTask.spriteFruit === sprite.key) {

sprite.x = Math.round(Math.random() * (xEnd - xStart) + xStart)

sprite.y = basket.y;

let count = ++basket.amountFruits

panelFruit.amountFruits.destroy()

panelFruit.amountFruits = createPartPanel('spr_btn_number_' + count)

} else {

randomFruitPosition(sprite)

}

}

const randomFruitPosition = (sprite) => {

if (Math.round(Math.random() * 1))

sprite.x = Math.round(Math.random() * (Game.width / 2 - basket.width - fruitSize) + fruitSize)

else

sprite.x = Math.round(Math.random() * (Game.width - fruitSize - (Game.width / 2 + basket.width)) + (Game.width / 2 + basket.width))

sprite.y = Math.round(Math.random() * (Game.height / 2 + basket.height / 2 - (basket.height + fruitSize)) + basket.height + fruitSize)

}

const createPanelFruit = () => {

panelFruit.backgroundFruit = createPartPanel('spr_char_epmty')

panelFruit.friut = createPartPanel(mathTask.spriteFruit)

panelFruit.amountFruits = createPartPanel('spr_btn_number_0')

}

const createPartPanel = (texture) => {

const partPanel = Game.add.image(0, 0, texture);

partPanel.anchor.set(0.5, 0.5)

partPanel.width = Math.round(Game.width * 0.025);

partPanel.height = partPanel.width

if (texture !== 'spr_apple' && texture !== 'spr_banan' && texture !== 'spr_orange' && texture !== 'spr_char_epmty')

partPanel.x = basket.x + partPanel.width / 2

else

partPanel.x = basket.x - partPanel.width / 2

partPanel.y = basket.y + fruitSize / 1.5

if (texture === 'spr_orange') {

partPanel.width = Math.round(Game.width * 0.02)

partPanel.height = partPanel.width

}

return partPanel

}

const continueButton = () => {

button.width = Math.round(Game.width * 0.07);

button.height = Math.round(Game.width * 0.07);

setTimeout(() => {

button.width = Math.round(Game.width * 0.08);

button.height = Math.round(Game.width * 0.07);

}, 100);

if (basket.amountFruits === mathTask.answer) {

MainSounds.Sounds.Clicks[6].play();

MainParticles.Star0.setYSpeed(500, 700);

MainParticles.Star0.start(true, Math.round(Game.height), 0, Math.round(Game.width * 0.025));

nextLevel()

} else {

button.loadTexture("spr_btn_cross", 0);

setTimeout(() => button.loadTexture("spr_btn_checkmark", 0), 300);

MainSounds.Sounds.Errors[0].play();

}

};

const nextLevel = () => {

GameState.CurStep++;

destroyMathTask();

destroyFruits();

destroyPanelFruit();

if (GameState.CurStep < GameState.MaxStep) {

basket.amountFruits = 0;

createMathTask();

createFruits();

createPanelFruit()

} else {

basket.destroy();

button.destroy();

Quest_Text.alpha = 0;

BackgroundBlack.visible = true;

MainReward.Reward.VisibleToggle();

MainSounds.Sounds.Win.play();

MainParticles.Star0.setYSpeed(100, 300);

MainParticles.Star0.start(false, Math.round(Game.height * 2.5), 0.2, 0);

MainParticles.Star1.start(false, Math.round(Game.height * 1.25), 0, 0);

finishGame(9);

}

};

const destroyMathTask = () => {

mathTask.firstNum.destroy();

mathTask.plusOrMinus.destroy();

mathTask.secondNum.destroy();

mathTask.equal.destroy();

mathTask.questionMark.destroy();

mathTask.fruitBack1.destroy();

mathTask.fruit1.destroy();

mathTask.fruitBack2.destroy();

mathTask.fruit2.destroy();

mathTask.fruitBack3.destroy();

mathTask.fruit3.destroy();

}

const destroyFruits = () => {

for (let i = 0; i < 27; i++)

fruits[i].destroy();

}

const destroyPanelFruit = () => {

panelFruit.backgroundFruit.destroy()

panelFruit.friut.destroy()

panelFruit.amountFruits.destroy()

}

function update() {

if (Game.input.activePointer.isDown) {

for (let i = 0; i < 27; i++)

if (fruits[i].isDraging) {

fruits[i].angle += 1;

return

}

}

MainParticles.Update();

MainReward.Update();

}

Файл: umland\src\Games\index.html

<html>

<head>

<title id="PageTittleText">Games</title>

<link rel="shortcut icon" type="image/png" href="../favicon.png">

<link rel="stylesheet" type="text/css" href="../Assets/Scripts/scr_GameStyles.css">

<script src="../Assets/Scripts/jquery.min.js"></script>

<script src="../Assets/Scripts/phaser.min.js"></script>

<script src="../commons.js"></script>

<script src="scr_indexGame.js"></script>

<script src="../Assets/Scripts/scr_MainReward.js"></script>

<script src="../Assets/Scripts/scr_MainParticles.js"></script>

<script src="../Assets/Scripts/scr_MainButtons.js"></script>

<script src="../Assets/Scripts/scr_MainSounds.js"></script>

</head>

<body>

<span id="LoadingText">ЗАГРУЗКА</span>

<div id="CanvasGame"></div>

</body>

</html>

Файл: umland\src\Games\scr_indexGame.js

let gameId = location.search.match(/[?&]id=([&]*)/)[1];

let gameURL = "../Games/"+gameId+"/scr_game.js";

$(document).ready(function(){

$("#CanvasGame").hide();

$.ajax( gameURL )

});

function GameCanvasShow(){

$("#"+Game.parent).show(500);

}

Файл: umland\src\scr_index.js

Game = new Phaser.Game("100%", "100%", Phaser.AUTO, 'CanvasGame', { preload: preload, create: create, update: update });

Phaser.Game.prototype.showDebugHeader = function () {

};

let finishedGame = [];

let isLogin = false;

function preload() {

fetch(`${HOST}/finished-games`, {

method: "GET",

headers: {

Accept: 'application/json',

'Content-Type': 'application/json',

},

})

.then(function (response) {

return response.json();

}).then((data) => {

finishedGame = data.gamesId;

isLogin = data.isLogin;

});

Game.stage.backgroundColor = "#fff";

Game.time.advancedTiming = true;

Game.load.image("spr_background", "./Assets/Images/img_MapObjects/img_mainbackground.jpg");

for (let i = 0; i < 13; i++) {

Game.load.image("spr_location_" + i, "./Assets/Images/img_MapObjects/img_location_" + i + ".png");

Game.load.image("spr_login", "./Assets/Images/img_MainButtons/img_login.png");

Game.load.image("spr_logout", "./Assets/Images/img_MainButtons/img_logout.png");

}

}

function create() {

MainLand = {};

MainLand.resizeK = (Game.width / Game.cache.getImage("spr_background").width);

MainLand.Background = Game.add.image(-1, -1, "spr_background");

MainLand.Background.anchor.x = 0.0;

MainLand.Background.anchor.y = 0.0;

MainLand.Background.width = Game.width + 2;

MainLand.Background.height = Math.ceil(Game.cache.getImage(MainLand.Background.key)

.height * MainLand.resizeK) + 2;

MainLand.Location = {};

MainLand.Location[0] = Game.add.image(0, 0, "spr_location_0");

MainLand.Location[0].x = Math.ceil(721 * MainLand.resizeK);

MainLand.Location[0].y = Math.ceil(390 * MainLand.resizeK);

MainLand.Location[0].width = Math.ceil((Game.cache.getImage(MainLand.Location[0].key)

.width * 2) * MainLand.resizeK);

MainLand.Location[0].height = MainLand.Location[0].width;

MainLand.Location[1] = Game.add.image(0, 0, "spr_location_1");

MainLand.Location[1].x = Math.ceil(2536 * MainLand.resizeK);

MainLand.Location[1].y = Math.ceil(47 * MainLand.resizeK);

MainLand.Location[1].width = Math.ceil((Game.cache.getImage(MainLand.Location[1].key)

.width * 2) * MainLand.resizeK);

MainLand.Location[1].height = MainLand.Location[1].width;

MainLand.Location[2] = Game.add.image(0, 0, "spr_location_2");

MainLand.Location[2].x = Math.ceil(1265 * MainLand.resizeK);

MainLand.Location[2].y = Math.ceil((-60) * MainLand.resizeK);

MainLand.Location[2].width = Math.ceil((Game.cache.getImage(MainLand.Location[2]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[2].height = MainLand.Location[2].width;

MainLand.Location[3] = Game.add.image(0, 0, "spr_location_3");

MainLand.Location[3].x = Math.ceil(0 * MainLand.resizeK);

MainLand.Location[3].y = Math.ceil(786 * MainLand.resizeK);

MainLand.Location[3].width = Math.ceil((Game.cache.getImage(MainLand.Location[3]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[3].height = MainLand.Location[3].width;

MainLand.Location[4] = Game.add.image(0, 0, "spr_location_4");

MainLand.Location[4].x = Math.ceil((-90) * MainLand.resizeK);

MainLand.Location[4].y = Math.ceil(1297 * MainLand.resizeK);

MainLand.Location[4].width = Math.ceil((Game.cache.getImage(MainLand.Location[4]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[4].height = MainLand.Location[4].width;

MainLand.Location[5] = Game.add.image(0, 0, "spr_location_5");

MainLand.Location[5].x = Math.ceil((82) * MainLand.resizeK);

MainLand.Location[5].y = Math.ceil((-92) * MainLand.resizeK);

MainLand.Location[5].width = Math.ceil((Game.cache.getImage(MainLand.Location[5]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[5].height = MainLand.Location[5].width;

MainLand.Location[6] = Game.add.image(0, 0, "spr_location_6");

MainLand.Location[6].x = Math.ceil((2995) * MainLand.resizeK);

MainLand.Location[6].y = Math.ceil((80) * MainLand.resizeK);

MainLand.Location[6].width = Math.ceil((Game.cache.getImage(MainLand.Location[6]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[6].height = MainLand.Location[6].width;

MainLand.Location[7] = Game.add.image(0, 0, "spr_location_7");

MainLand.Location[7].x = Math.ceil((2584) * MainLand.resizeK);

MainLand.Location[7].y = Math.ceil((1234) * MainLand.resizeK);

MainLand.Location[7].width = Math.ceil((Game.cache.getImage(MainLand.Location[7]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[7].height = MainLand.Location[7].width;

MainLand.Location[9] = Game.add.image(0, 0, "spr_location_10");

MainLand.Location[9].x = Math.ceil((1542) * MainLand.resizeK);

MainLand.Location[9].y = Math.ceil((403) * MainLand.resizeK);

MainLand.Location[9].width = Math.ceil((Game.cache.getImage(MainLand.Location[9]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[9].height = MainLand.Location[9].width;

MainLand.Location[8] = Game.add.image(0, 0, "spr_location_8");

MainLand.Location[8].x = Math.ceil((1175) * MainLand.resizeK);

MainLand.Location[8].y = Math.ceil((649) * MainLand.resizeK);

MainLand.Location[8].width = Math.ceil((Game.cache.getImage(MainLand.Location[8]

.key).width * 2) * MainLand.resizeK);

MainLand.Location[8].height = MainLand.Location[8].width;

const getTint = (id) => isLogin && finishedGame.includes(id) ? "0Xffffff" : "0x666666";

for (let i = 0; i < 10; i++) {

MainLand.Location[i].anchor.x = 0.0;

MainLand.Location[i].anchor.y = 0.0;

MainLand.Location[i].inputEnabled = true;

MainLand.Location[i].tint = getTint(i);

MainLand.Location[i].events.onInputOver.add(function (sprite) {

if (i == 1) {

sprite.tint = "0xff55ff";

} else {

sprite.tint = "0xffff55";

}

});

MainLand.Location[i].events.onInputOut.add(function (sprite) {

sprite.tint = getTint(i);

});

MainLand.Location[i].input.pixelPerfectOver = true;

MainLand.Location[i].input.pixelPerfectAlpha = 64;

MainLand.Location[i].events.onInputDown.add(function () {

window.location = `${HOST}/Games/?id=game_${i}`;

window.preload()

}, this);

}

var style = { font: "64px Trebuchet MS", fill: "#ffffff", align: "center" };

Quest_Text = Game.add.text(Game.world.centerX, Game.height * 0.05, "", style);

Quest_Text.anchor.set(0.5, 0.0);

Quest_Text.text = isLogin ? "" : 'Авторизирутесь, чтобы сохранять прогресс';

Quest_Text.stroke = "#6B3E14";

Quest_Text.fontSize = Math.round((Game.height * 0.05));

Game.world.setBounds(0, 0, MainLand.Background.width - 2, MainLand.Background.height - 2);

loginButton = isLogin

? Game.add.button(0, 0, "spr_logout", onClickLogout)

: Game.add.button(0, 0, "spr_login", onClickLogin);

function onClickLogout() {

fetch('/logout');

window.location = `${HOST}/sign-in`;

window.preload()

}

function onClickLogin() {

window.location = `${HOST}/sign-in`;

window.preload()

}

}

window.addEventListener('resize', function () {

Game.scale.refresh();

});

function CamerControl() {

if (Game.input.y < Math.floor(Game.height * 0.1)) {

Game.camera.y -= Math.floor(Game.height * 0.02);

}

if (Game.input.y > Math.floor(Game.height * 0.9)) {

Game.camera.y += Math.floor(Game.height * 0.02);

}

}

function update() {

CamerControl();

}

Файл: umland\src\Games\scr_indexGame.js

let gameId = location.search.match(/[?&]id=([&]*)/)[1];

let gameURL = "../Games/"+gameId+"/scr_game.js";

$(document).ready(function(){

$("#CanvasGame").hide();

$.ajax( gameURL )

});

function GameCanvasShow(){

$("#"+Game.parent).show(500);

}

Файл: umland\src\index.html

<html>

<head>

<title id="PageTittleText"></title>

<link rel="shortcut icon" type="image/png" href="./favicon.png">

<script src="./Assets/Scripts/phaser.min.js"></script>

<script src="commons.js"></script>

<script src="scr_index.js"></script>

<link rel="stylesheet" type="text/css" href="indexStyles.css">

</head>

<body>

<div id="CanvasGame"></div>

</body>

</html>

Файл: umland\src\indexStyles.css

body{

margin:0;

}

#CanvasGame {

position: fixed;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

}

Файл: umland\src\sign_up.html

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>umland</title>

<style>

.login-form {

width: 300px;

margin: 0 auto;

font-family: Tahoma, Geneva, sans-serif;

}

.login-form h1 {

text-align: center;

color: #4d4d4d;

font-size: 24px;

padding: 20px 0 20px 0;

}

.login-form input[type="password"],

.login-form input[type="text"],

.login-form input[type="email"] {

width: 100%;

padding: 15px;

border: 1px solid #dddddd;

margin-bottom: 15px;

box-sizing: border-box;

}

.login-form input[type="submit"] {

width: 100%;

padding: 15px;

background-color: #535b63;

border: 0;

box-sizing: border-box;

cursor: pointer;

font-weight: bold;

color: #ffffff;

}

</style>

</head>

<body>

<div class="login-form">

<h1>Созадть акканут</h1>

<form action="sign-up" method="POST">

<input type="text" name="username" placeholder="Имя" required>

<input type="password" name="password" placeholder="Парлоль" required>

<input type="email" name="email" placeholder="Почта" required>

<input type="submit" value="Создать">

<a href='sign_in.html'>Уже есть акканут?</a>

</form>

</div>

</body>

</html>

Файл: umland\src\sign_in.html

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>umland</title>

<style>

.login-form {

width: 300px;

margin: 0 auto;

font-family: Tahoma, Geneva, sans-serif;

}

.login-form h1 {

text-align: center;

color: #4d4d4d;

font-size: 24px;

padding: 20px 0 20px 0;

}

.login-form input[type="password"],

.login-form input[type="text"] {

width: 100%;

padding: 15px;

border: 1px solid #dddddd;

margin-bottom: 15px;

box-sizing: border-box;

}

.login-form input[type="submit"] {

width: 100%;

padding: 15px;

background-color: #535b63;

border: 0;

box-sizing: border-box;

cursor: pointer;

font-weight: bold;

color: #ffffff;

}

</style>

</head>

<body>

<div class="login-form">

<h1>Вход</h1>

<form action="auth" method="POST">

<input type="text" name="username" placeholder="Имя" required>

<input type="password" name="password" placeholder="Парлоль" required>

<input type="submit" value="Войти">

<a href='./sign_up.html'>Создать аккаунт?</a>

</form>

</div>

</body>

</html>

Размещено на Allbest.ru

...

Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.