-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
111,710 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="ru"> | ||
|
||
<head> | ||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0" /> | ||
<style media='screen' type='text/css'> | ||
@font-face { | ||
font-family: "Silkscreen"; | ||
src: url('assets/fonts/Silkscreen.ttf'); | ||
} | ||
|
||
body { | ||
padding: 0px; | ||
margin: 0px; | ||
height: 100svh; | ||
max-height: 100svh; | ||
overflow: hidden; | ||
} | ||
|
||
#game { | ||
margin: 0px; | ||
padding: 0px; | ||
height: 100svh; | ||
width: 100vw; | ||
} | ||
</style> | ||
<script src="lib/phaser.min.js"></script> | ||
<script src="lib/config.js"></script> | ||
<script src="lib/missionsConfig.js"></script> | ||
<script src="lib/sameGame.js"></script> | ||
<script src="lib/gameManager.js"></script> | ||
<script src="lib/missionManager.js"></script> | ||
<script src="lib/components/character.js"></script> | ||
<script src="lib/components/button.js"></script> | ||
<script src="lib/components/iconButton.js"></script> | ||
<script src="lib/scenes/menuScene.js"></script> | ||
<script src="lib/scenes/gameScene.js"></script> | ||
<script src="lib/app.js?version=0.168"></script> | ||
<title>Приключения Тотошки</title> | ||
</head> | ||
|
||
<body> | ||
<div class="font_preload hidden"> | ||
<span style="font-family: Silkscreen;"></span> | ||
</div> | ||
<div id="game"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
String.prototype.format = function () { | ||
let args = arguments | ||
// args is strings | ||
if (args.length === 1 && args[0] !== null && typeof args[0] === 'object') { | ||
args = args[0]; | ||
} | ||
|
||
let string = this | ||
for (let key in args) { | ||
string = string.replace("%{" + key + "}", args[key]) | ||
} | ||
|
||
return string | ||
} | ||
Math.getRandomIntWithStep = function (min, max, step) { | ||
return Math.floor(Math.random() * ((max - min) / step) + min / step) * step; | ||
} | ||
|
||
const SCREEN_WIDHT = 720 | ||
const SCREEN_HEIGHT = 1280 | ||
|
||
const config = { | ||
type: Phaser.AUTO, | ||
scale: { | ||
mode: Phaser.Scale.FIT, | ||
autoCenter: Phaser.Scale.CENTER_BOTH, | ||
width: SCREEN_WIDHT, | ||
height: SCREEN_HEIGHT, | ||
parent: 'game', | ||
}, | ||
scene: [GameScene], | ||
scene: [MenuScene, GameScene], | ||
backgroundColor: '#4b4b4b', | ||
roundPixels: true, | ||
// pixelArt: true, | ||
}; | ||
|
||
const game = new Phaser.Game(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Button extends Phaser.GameObjects.GameObject { | ||
/** | ||
* @param {Phaser.Scene} scene | ||
*/ | ||
constructor(scene, x, y, width, height) { | ||
super(scene) | ||
|
||
this.scene = scene | ||
this.width = width | ||
this.height = height | ||
this.x = x | ||
this.y = y | ||
// this.initContainer() | ||
} | ||
|
||
get centerOffset() { | ||
return [0, -1] | ||
} | ||
|
||
onPointerDown(callback, context = this) { | ||
this.container.on("pointerdown", callback, context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class Character extends Phaser.GameObjects.Sprite { | ||
/** | ||
* @param {Phaser.Scene} scene | ||
*/ | ||
constructor(scene, x, y, texture, frame) { | ||
super(scene, x, y, texture, frame) | ||
scene.add.existing(this) | ||
|
||
this.setScale(3) | ||
this.setFlipX(true) | ||
this.texture.setFilter(Phaser.Textures.FilterMode.NEAREST) | ||
|
||
this.walkAround() | ||
} | ||
|
||
walkAround() { | ||
this.tweenMove = this.scene.tweens.add({ | ||
targets: this, | ||
props: { | ||
x: { value: 120, duration: 10000, flipX: true }, | ||
}, | ||
ease: Phaser.Math.Easing.Linear | ||
, | ||
yoyo: true, | ||
repeat: -1, | ||
}); | ||
|
||
this.tweenStep = this.scene.tweens.add({ | ||
targets: this, | ||
angle: { start: -2, to: 2 }, | ||
yoyo: true, | ||
repeat: -1, | ||
duration: 500 | ||
}); | ||
} | ||
|
||
stopWalking(){ | ||
this.tweenMove.pause() | ||
this.tweenStep.pause() | ||
} | ||
|
||
onPointerDown(callback, context = this) { | ||
this.container.on("pointerdown", callback, context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
class IconButton extends Button { | ||
/** | ||
* @param {Phaser.Scene} scene | ||
*/ | ||
constructor(scene, x, y, width, height, texture, text=null, options={ fontSize: null, shadow: true }) { | ||
super(scene, x, y, width, height) | ||
|
||
this.texture = texture | ||
this.text = text | ||
this.fontSize = options.fontSize | ||
this.shadow = options.shadow | ||
this.fontOptions = { fontFamily: 'Silkscreen', fontSize: this.fontSize || 60 } | ||
this.initContainer() | ||
} | ||
|
||
static loadAssets(scene) { | ||
const path = 'assets/ui/' | ||
const extension = '.png' | ||
const frameConfig = { frameWidth: 359, frameHeight: 162 } | ||
const spriteNames = ['greenRectNormal'] | ||
const spriteCodes = [54, 55] | ||
|
||
spriteNames.forEach((value, index) => { | ||
scene.load.spritesheet(spriteNames[index], `${path}${value}${extension}`, frameConfig) | ||
}) | ||
} | ||
|
||
get centerOffset() { | ||
return [0, -3] | ||
} | ||
|
||
initContainer() { | ||
this.shape = this.scene.add.rectangle(0, 0, this.width, this.height) | ||
this.sprite = this.scene.add.sprite( | ||
0, 0, | ||
this.texture | ||
) | ||
|
||
const scale = this.width / this.sprite.width | ||
this.sprite.setScale(scale) | ||
this.sprite.setDisplaySize(this.width, this.height) | ||
if (this.shadow) this.sprite.preFX.addShadow(-3, -3, 0.006, 1, 0x333333, 10) | ||
|
||
Phaser.Display.Align.In.Center(this.sprite, this.shape, ...this.centerOffset); | ||
|
||
let content = [this.shape, this.sprite] | ||
|
||
if (this.text) { | ||
|
||
this.buttonText = this.scene.add.text(0, 0, this.text, { ...this.fontOptions }); | ||
|
||
content.push(this.buttonText) | ||
|
||
if (!this.fontSize) { | ||
const textScale = (this.width / 1.2) / this.buttonText.width | ||
this.buttonText.setFontSize(this.fontOptions.fontSize * textScale) | ||
} | ||
|
||
Phaser.Display.Align.In.Center(this.buttonText, this.sprite, ...this.centerOffset); | ||
} | ||
|
||
|
||
this.container = this.scene.add.container(this.x, this.y, content) | ||
this.container.setSize(this.width, this.height) | ||
.setInteractive() | ||
} | ||
|
||
onPointerDown(callback, context = this) { | ||
this.container.input.cursor = 'pointer' | ||
this.container.on("pointerdown", callback, context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const VERSION = 'v0.168' | ||
const TIME_LIMIT = 120 | ||
const MOVES_LIMIT = 50 | ||
const GAME_MODES = Object.freeze({ | ||
CLASSIC: 'classic', | ||
TIME_ATTACK: 'timeAttack', | ||
MOVES_ATTACK: 'movesAttack' | ||
}) | ||
const END_GAME_TEXT = "\n\n\n\n\n\nВаш Результат\n🏅%{score}\n\nЛучший результат: \n🏆%{totalScore}\n\nМакс. комбо: %{maxCombo}\n\nНажмите на экран, \nчтобы перезапустить\nуровень"; | ||
const TIME_ATTACK_END_GAME_TEXT = `Время вышло.${END_GAME_TEXT}`; | ||
const MOVES_ATTACK_END_GAME_TEXT = `Ходы закончились.${END_GAME_TEXT}`; | ||
const CLEAR_FIELD_END_GAME_TEXT = `Вы очистили всё поле!${END_GAME_TEXT}`; | ||
const TIME_TEXT = "⏱ %{time}" | ||
const MOVES_TEXT = "Ходы: %{moves}" | ||
const MISSIONS_COUNT = 3 | ||
|
||
const GAME_OPTIONS = { | ||
gemSpriteSize: 256, | ||
gemSize: 74, | ||
baseSize: 74, | ||
boardOffset: { x: 60, y: 210 }, | ||
destroySpeed: 200, | ||
fallSpeed: 100, | ||
slideSpeed: 300, | ||
rows: 11, | ||
columns: 8, | ||
maxRows: 11, | ||
maxColumns: 8, | ||
items: 4, | ||
minimumMatches: 2, | ||
}; |
Oops, something went wrong.