Commit 9bf68a7e authored by Grigoriy Tretyakov's avatar Grigoriy Tretyakov

init

parents
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Dependency directories
node_modules/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Bouncing frags
webpackJsonp([0],{
/***/ 466:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
__webpack_require__(221);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var settings = {
bullet: 'bullet',
frag: 'frag',
fragWidth: 40,
fragHeight: 40,
player: 'player',
playerUp: 'playerUp',
playerDown: 'playerDown',
playerWidth: 40,
playerHeight: 40
};
var Boot = function (_Phaser$Scene) {
_inherits(Boot, _Phaser$Scene);
function Boot() {
_classCallCheck(this, Boot);
return _possibleConstructorReturn(this, (Boot.__proto__ || Object.getPrototypeOf(Boot)).call(this, { key: 'Boot' }));
}
_createClass(Boot, [{
key: 'preload',
value: function preload() {
this.load.image(settings.bullet, 'assets/frag.png');
this.load.spritesheet(settings.frag, 'assets/frag.png', {
frameWidth: settings.fragWidth,
frameHeight: settings.fragHeight
});
this.load.spritesheet(settings.player, 'assets/player.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight
});
this.load.spritesheet(settings.playerUp, 'assets/playerup.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight
});
this.load.spritesheet(settings.playerDown, 'assets/playerdown.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight
});
}
}, {
key: 'create',
value: function create() {
this.scene.start('Game');
}
}]);
return Boot;
}(Phaser.Scene);
var Game = function (_Phaser$Scene2) {
_inherits(Game, _Phaser$Scene2);
function Game() {
_classCallCheck(this, Game);
return _possibleConstructorReturn(this, (Game.__proto__ || Object.getPrototypeOf(Game)).call(this, { key: 'Game' }));
}
_createClass(Game, [{
key: 'create',
value: function create() {
this.add.text(60, 250, 'This is a game!', { font: '20px monospace' });
this.add.sprite(150, 150, settings.frag, 0);
}
}]);
return Game;
}(Phaser.Scene);
var gameConfig = {
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#00212b', //'#0b1728',
scene: [Game]
};
var game = new Phaser.Game(gameConfig);
/***/ })
},[466]);
\ No newline at end of file
webpackJsonp([0],{434:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(210);var c=function(e){function t(){r(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{key:"Game"}));return e.PIC="picture",e}return a(t,e),i(t,[{key:"preload",value:function(){this.load.image(this.PIC,"assets/pic.png")}},{key:"create",value:function(){this.add.text(60,250,"This is a game!",{font:"20px monospace"}),this.add.image(150,150,this.PIC)}}]),t}(Phaser.Scene),u={type:Phaser.AUTO,parent:"game",width:300,height:400,scene:[c]};new Phaser.Game(u)}},[434]);
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>game</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta http-equiv="cleartype" content="on">
<meta name="format-detection" content="telephone=no">
<style>
html, body {
margin: 0;
padding: 0;
image-rendering: optimizeSpeed; /* Older versions of FF */
image-rendering: -moz-crisp-edges; /* FF 6.0+ */
image-rendering: -webkit-optimize-contrast; /* Webkit (non standard naming) */
image-rendering: -o-crisp-edges; /* OS X & Windows Opera (12.02+) */
image-rendering: crisp-edges; /* Possible future browsers. */
-ms-interpolation-mode: nearest-neighbor; /* IE (non standard naming) */
image-rendering: pixelated; /* Chrome 41 */
}
body {
background: #0b1728;
}
canvas {
display: block;
left: 50%;
margin: 0;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div id="game"></div>
<script type="text/javascript" src="vendor-libs.js"></script>
<script type="text/javascript" src="bouncing-frags-game.js"></script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
{
"name": "phaser3-bouncing-frags",
"version": "1.0.0",
"description": "Game",
"main": "src/index.js",
"scripts": {
"start": "./node_modules/.bin/webpack-dev-server",
"build": "./node_modules/.bin/webpack --config webpack.production.config.js",
"build:dev": "./node_modules/.bin/webpack"
},
"author": "gt",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"copy-webpack-plugin": "^4.5.2",
"webpack": "^3.12.0",
"webpack-dev-server": "^2.11.2"
},
"dependencies": {
"phaser": "^3.13.0"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>game</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta http-equiv="cleartype" content="on">
<meta name="format-detection" content="telephone=no">
<style>
html, body {
margin: 0;
padding: 0;
image-rendering: optimizeSpeed; /* Older versions of FF */
image-rendering: -moz-crisp-edges; /* FF 6.0+ */
image-rendering: -webkit-optimize-contrast; /* Webkit (non standard naming) */
image-rendering: -o-crisp-edges; /* OS X & Windows Opera (12.02+) */
image-rendering: crisp-edges; /* Possible future browsers. */
-ms-interpolation-mode: nearest-neighbor; /* IE (non standard naming) */
image-rendering: pixelated; /* Chrome 41 */
}
body {
background: #00212b;
}
canvas {
display: block;
left: 50%;
margin: 0;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div id="game"></div>
<script type="text/javascript" src="vendor-libs.js"></script>
<script type="text/javascript" src="bouncing-frags-game.js"></script>
</body>
</html>
import 'phaser';
let settings = {
wall: 'wall',
wallWidth: 20,
wallHeight: 20,
bullet: 'bullet',
frag: 'frag',
fragWidth: 40,
fragHeight: 40,
player: 'player',
playerUp: 'playerUp',
playerDown: 'playerDown',
playerWidth: 40,
playerHeight: 40,
gameWidth: 800,
gameHeight: 600,
};
class Boot extends Phaser.Scene {
constructor() {
super({key: 'Boot'});
}
preload() {
this.load.image(settings.wall, 'assets/wall.png');
this.load.image(settings.bullet, 'assets/bullet.png');
this.load.spritesheet(settings.frag, 'assets/frag.png', {
frameWidth: settings.fragWidth,
frameHeight: settings.fragHeight,
});
this.load.spritesheet(settings.player, 'assets/player.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight,
});
this.load.spritesheet(settings.playerUp, 'assets/playerup.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight,
});
this.load.spritesheet(settings.playerDown, 'assets/playerdown.png', {
frameWidth: settings.playerWidth,
frameHeight: settings.playerHeight,
});
}
create() {
this.scene.start('Game');
}
}
class Game extends Phaser.Scene {
constructor() {
super({key: 'Game'});
}
create() {
this.createWall();
this.add.sprite(150, 150, settings.frag, 0);
this.add.sprite(400, 350, settings.frag, 1);
}
createWall() {
for (let x = 0; x < settings.gameWidth; x += settings.wallWidth) {
let ceil = this.add.sprite(x, 0, settings.wall);
ceil.setOrigin(0, 0);
let floor = this.add.sprite(x, settings.gameHeight, settings.wall);
floor.setOrigin(0, 1);
}
for (let y = settings.wallHeight; y < settings.gameHeight - settings.wallHeight; y += settings.wallHeight) {
let left = this.add.sprite(0, y, settings.wall);
left.setOrigin(0, 0);
let right = this.add.sprite(settings.gameWidth, y, settings.wall);
right.setOrigin(1, 0);
}
}
}
const gameConfig = {
type: Phaser.AUTO,
width: settings.gameWidth,
height: settings.gameHeight,
backgroundColor: '#00212b', //'#0b1728',
scene: [
Boot,
Game,
]
}
let game = new Phaser.Game(gameConfig);
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: {
app: './src/index.js',
'vendor-libs': ['phaser']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bouncing-frags-game.js'
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src/'),
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
},
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'src', 'index.html'),
to: path.resolve(__dirname, 'dist')
},
{
from: path.resolve(__dirname, 'assets', '**', '*'),
to: path.resolve(__dirname, 'dist')
}
]),
new webpack.DefinePlugin({
'typeof CANVAS_RENDERER': JSON.stringify(true),
'typeof WEBGL_RENDERER': JSON.stringify(true)
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor-libs',
filename: 'vendor-libs.js'
}),
],
}
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: {
app: './src/index.js',
'vendor-libs': ['phaser']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bouncing-frags-game.js'
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src/'),
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
},
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'src', 'index.html'),
to: path.resolve(__dirname, 'dist')
},
{
from: path.resolve(__dirname, 'assets', '**', '*'),
to: path.resolve(__dirname, 'dist')
}
]),
new webpack.optimize.UglifyJsPlugin({
drop_console: true,
minimize: true,
output: {
comments: false
}
}),
new webpack.DefinePlugin({
'typeof CANVAS_RENDERER': JSON.stringify(true),
'typeof WEBGL_RENDERER': JSON.stringify(true)
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor-libs',
filename: 'vendor-libs.js'
}),
],
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment