Initial Commmit:

Gulp Tasks for
* Copy libs to public folder
* Source Uglyfy + Copy
* Zip
This commit is contained in:
Indrajith K L
2018-08-12 02:37:22 +05:30
commit ddbf11efa3
7 changed files with 5919 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
/node_modules
/dist
/temp
/.cache
/libs
/public

16
README.md Normal file
View File

@@ -0,0 +1,16 @@
# js13kgames-template
A barebone template aimed for [js13kgames](js13kgames.com)
## This template includes
* [Kontra](https://github.com/straker/kontra)
* [TinyMusic](https://github.com/kevincennis/TinyMusic)
## Features
Integrated gulp build process for :
* Copying libs under node_modules folder to an distributable folder.
* Minification
* Final Zip file Compression
* Shows final zip file size.
## Support me
[<img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' />](https://ko-fi.com/R6R36EBQ)

56
gulpfile.js Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var uglify = require('gulp-uglify');
const zip = require('gulp-vinyl-zip').zip;
var size = require('gulp-size');
var libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js'];
var libFolder = 'libs/';
var outputTemp = 'temp/';
gulp.task('serve', ['copylibs'], function () {
browserSync.init({
server: './'
});
gulp.watch("./**/*.js", { cwd: './' },function(){
gulp.run('uglyfy_copy')
}).on('change', browserSync.reload);;
gulp.watch("./**/*.html", { cwd: './' }).on('change', browserSync.reload);
browserSync.watch()
});
gulp.task('uglyfy_copy', function () {
return gulp.src('src/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('public/js'));
});
gulp.task('copylibs', function () {
return gulp
.src(libs)
.pipe(gulp.dest(libFolder))
});
gulp.task('zipFiles',['prepare_dist_folder'], function () {
return gulp.src('temp/**/*.*')
.pipe(zip('archive.zip'))
.pipe(gulp.dest('dist'))
.pipe(size({
title: '### Final Archive Size => '
}))
});
gulp.task('prepare_dist_folder', function () {
return gulp
.src(['libs/*','public/**/*.*','index.html'],{base: './'})
.pipe(gulp.dest(outputTemp))
});

15
index.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="./libs/kontra.min.js"></script>
<script src="./libs/TinyMusic.min.js"></script>
<title>Document</title>
</head>
<body onload="Game()">
<canvas></canvas>
<script src="public/js/main.js"></script>
</body>
</html>

5773
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "js13kgames-template",
"version": "1.0.0",
"description": "A barebone template aimed for js13kgames",
"scripts": {
"start": "./node_modules/.bin/gulp serve",
"release": "./node_modules/.bin/gulp zipFiles"
},
"author": "Indrajith K L",
"license": "MIT",
"dependencies": {
"kontra": "^4.0.0",
"tinymusic": "^1.0.0"
},
"devDependencies": {
"browser-sync": "^2.24.6",
"gulp": "^3.9.1",
"gulp-size": "^3.0.0",
"gulp-uglify": "^3.0.1",
"gulp-vinyl-zip": "^2.1.0"
}
}

30
src/js/main.js Normal file
View File

@@ -0,0 +1,30 @@
function Game(){
kontra.init();
var sprite = kontra.sprite({
x: 100, // starting x,y position of the sprite
y: 80,
color: 'blue', // fill color of the sprite rectangle
width: 20, // width and height of the sprite rectangle
height: 40,
dx: 2 // move the sprite 2px to the right every frame
});
var loop = kontra.gameLoop({ // create the main game loop
update: function() { // update the game state
sprite.update();
// wrap the sprites position when it reaches
// the edge of the screen
if (sprite.x > kontra.canvas.width) {
sprite.x = -sprite.width;
}
},
render: function() { // render the game state
sprite.render();
}
});
loop.start(); // start the game
}
window.Game = Game;