Skip to content

Commit

Permalink
🔖 Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Sep 24, 2019
2 parents 64acfca + 029cba3 commit de3a743
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 151 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
![](https://raw.githubusercontent.com/ct-js/ct-js/develop/branding/GithubHeader.png)

![](https://img.shields.io/badge/license-MIT-informational?style=flat-square) ![GitHub tag (latest by date)](https://img.shields.io/github/tag-date/ct-js/ct-js?label=version&style=flat-square) ![Travis (.org) branch](https://img.shields.io/travis/ct-js/ct-js/master?style=flat-square) ![Travis (.org) branch](https://img.shields.io/travis/ct-js/ct-js/develop?label=dev%20build&style=flat-square)
[![](https://img.shields.io/badge/license-MIT-informational?style=flat-square)](https://github.com/ct-js/ct-js/blob/develop/LICENSE) [![GitHub tag (latest by date)](https://img.shields.io/github/tag-date/ct-js/ct-js?label=version&style=flat-square)](https://github.com/ct-js/ct-js/releases) [![Travis (.org) master branch](https://img.shields.io/travis/ct-js/ct-js/master?style=flat-square)](https://travis-ci.org/ct-js/ct-js/branches) [![Travis (.org) develop branch](https://img.shields.io/travis/ct-js/ct-js/develop?label=dev%20build&style=flat-square)](https://travis-ci.org/ct-js/ct-js)

[![](https://img.shields.io/discord/490052958310891520?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/CggbPkb) ![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/state:to%20do?style=flat-square&label=todo%20issues) ![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/state:current%20release?style=flat-square&label=current%20release%20issues)
![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/help%20wanted?style=flat-square&label=help%20wanted)
[![](https://img.shields.io/discord/490052958310891520?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/CggbPkb) [![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/state:to%20do?style=flat-square&label=todo%20issues)](https://github.com/ct-js/ct-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22state%3Ato+do%22) [![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/state:current%20release?style=flat-square&label=current%20release%20issues)](https://github.com/ct-js/ct-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22state%3Acurrent+release%22)
[![GitHub issues by-label](https://img.shields.io/github/issues/ct-js/ct-js/help%20wanted?style=flat-square&label=help%20wanted)](https://github.com/ct-js/ct-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)

Ct.js is a 2D game editor that makes its bet on good documentation, visual tools and smooth workflow.

Expand Down
23 changes: 23 additions & 0 deletions app/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## v 1.0.2

*25 September 2019.*

### 🐛 Bug fixes

* Fix broken desktop export, as well as uncatched errors
* Fix textures' "frame count" property not working (#120) by @island205 🎉
* Update parameter names in ct.sprite's readme

### ⚡ General improvements

* Add support for OGG audio files

### Docs

* 🐛 Fix the use of ct.height in Making Shooter tutorial when ct.viewHeight is needed
* ⚡ Change the title of "Troubleshooting: Background splits into squares!" so that it covers tiles as well
* Add a page "Troubleshooting: Sounds don't play at game start!"
* Document `ct.u.degToRad`, `ct.u.radToDeg`
* Document `ct.u.rotate`, `ct.u.rotateRad`


## v 1.0.1

*5 September 2019.*
Expand Down
64 changes: 35 additions & 29 deletions app/data/ct.libs/sound.howler/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global ct Howler Howl */
/* global Howler Howl */
(function () {
ct.sound = {};
ct.sound.howler = Howler;
Expand All @@ -9,32 +9,37 @@
var defaultMaxDistance = [/*%defaultMaxDistance%*/][0] || 2500;
ct.sound.useDepth = [/*%useDepth%*/][0] === void 0? false : [/*%useDepth%*/][0];
ct.sound.manageListenerPosition = [/*%manageListenerPosition%*/][0] === void 0? true : [/*%manageListenerPosition%*/][0];
/**
* Detects if a particular codec is supported in the system

/**
* Detects if a particular codec is supported in the system
* @param {String} type One of: "mp3", "mpeg", "opus", "ogg", "oga", "wav", "aac", "caf", m4a", "mp4", "weba", "webm", "dolby", "flac".
* @returns {Boolean} true/false
*/
ct.sound.detect = Howler.codecs;
/**
* Creates a new Sound object and puts it in resource object
*

/**
* Creates a new Sound object and puts it in resource object
*
* @param {String} name Sound's name
* @param {String} wav Local path to the sound in wav format
* @param {String} mp3 Local path to the sound in mp3 format
* @param {Object} formats A collection of sound files of specified extension, in format `extension: path`
* @param {String} [formats.ogg] Local path to the sound in ogg format
* @param {String} [formats.wav] Local path to the sound in wav format
* @param {String} [formats.mp3] Local path to the sound in mp3 format
* @param {Object} options An options object
*
*
* @returns {Object} Sound's object
*/
ct.sound.init = function (name, wav, mp3, options) {
ct.sound.init = function (name, formats, options) {
options = options || {};
var sounds = [];
if (wav && wav.slice(-4) === '.wav') {
sounds.push(wav);
if (formats.wav && formats.wav.slice(-4) === '.wav') {
sounds.push(formats.wav);
}
if (formats.mp3 && formats.mp3.slice(-4) === '.mp3') {
sounds.push(formats.mp3);
}
if (mp3 && mp3.slice(-4) === '.mp3') {
sounds.push(mp3);
if (formats.ogg && formats.ogg.slice(-4) === '.ogg') {
sounds.push(formats.ogg);
}
var howl = new Howl({
src: sounds,
Expand All @@ -43,7 +48,7 @@
html5: Boolean(options.music),
loop: options.loop,
pool: options.poolSize || 5,

onload: function () {
if (!options.music) {
ct.res.soundsLoaded++;
Expand All @@ -52,15 +57,16 @@
onloaderror: function () {
ct.res.soundsError++;
howl.buggy = true;
console.error('[ct.sound.howler] Oh no! We couldn\'t load ' + (wav || mp3) + '!');
console.error('[ct.sound.howler] Oh no! We couldn\'t load ' +
(formats.wav || formats.mp3 || formats.ogg) + '!');
}
});
if (options.music) {
ct.res.soundsLoaded++;
}
ct.res.sounds[name] = howl;
};

var set3Dparameters = (howl, opts, id) => {
howl.pannerAttr({
coneInnerAngle: opts.coneInnerAngle || 360,
Expand All @@ -75,11 +81,11 @@
};
/**
* Spawns a new sound and plays it.
*
*
* @param {String} name The name of a sound to be played
* @param {Object} [opts] Options object.
* @param {Function} [cb] A callback, which is called when the sound finishes playing
*
*
* @returns {Number} The ID of the created sound. This can be passed to Howler methods.
*/
ct.sound.spawn = function(name, opts, cb) {
Expand Down Expand Up @@ -113,32 +119,32 @@
}
return id;
};

/**
* Stops playback of a sound, resetting its time to 0.
*
*
* @param {String} name The name of a sound
* @param {Number} [id] An optional ID of a particular sound
* @returns {void}
*/
ct.sound.stop = function(name, id) {
ct.res.sounds[name].stop(id);
};

/**
* Pauses playback of a sound or group, saving the seek of playback.
*
*
* @param {String} name The name of a sound
* @param {Number} [id] An optional ID of a particular sound
* @returns {void}
*/
ct.sound.pause = function(name, id) {
ct.res.sounds[name].pause(id);
};

/**
* Resumes a given sound, e.g. after pausing it.
*
*
* @param {String} name The name of a sound
* @param {Number} [id] An optional ID of a particular sound
* @returns {void}
Expand All @@ -149,7 +155,7 @@
/**
* Returns whether a sound is currently playing,
* either an exact sound (found by its ID) or any sound of a given name.
*
*
* @param {String} name The name of a sound
* @param {Number} [id] An optional ID of a particular sound
* @returns {Boolean} `true` if the sound is playing, `false` otherwise.
Expand All @@ -158,7 +164,7 @@
return ct.res.sounds[name].playing(id);
};
/**
* Preloads a sound. This is usually applied to music files before playing,
* Preloads a sound. This is usually applied to music files before playing
* as they are not preloaded by default.
*
* @param {String} name The name of a sound
Expand Down
10 changes: 5 additions & 5 deletions app/data/ct.libs/sprite/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
This module composes new graphic assets out of existing ones. Say, you have a ping-pong animation or multiple animations in one atlas, and instead of managing these animations with code or duplicating frames you could use this module to logically split animations into separate assets and get rid of duplicate frames.
This module composes new textures out of existing ones. Say, you have a ping-pong animation or multiple animations in one atlas, and instead of managing these animations with code or duplicating frames you could use this module to logically split animations into separate assets and get rid of duplicate frames.

## How to

The workflow of this module is simple: you add a one function call, giving an existing graphic asset name, a new one, and a set of frames to play, and you can use this new graphic asset in the way you use it with default ones. You can add these function calls in the "Settings" tab of this mod to make sure that your code is in the right place.
The workflow of this module is simple: you add a one function call, giving an existing texture name, a new one, and a set of frames to play, and you can use this new texture in the way you use it with default ones. You can add these function calls in the "Settings" tab of this mod to make sure that your code is in the right place.

# ![Source strip](./data/ct.libs/sprite/SlimeExample.png)
# +
```js
ct.sprite(
'Slime', 'Slime_Idle',
'Slime', 'Slime_Idle',
[0, 1, 2, 3, 2, 1, 0, 0, 0, 4, 5, 4, 0, 4, 5, 4]
);
/* Later, in your project */
this.graph = 'Slime_Idle';
this.tex = 'Slime_Idle';
```
# =
![Gif result](./data/ct.libs/sprite/SlimeExample_Result.gif)
Expand All @@ -31,7 +31,7 @@ ct.sprite(
[0, 4, 5, 4]
);
/* Later, in project's code */
this.graph = ct.random.dice('Slime_Blink', 'Slime_Wiggle);
this.tex = ct.random.dice('Slime_Blink', 'Slime_Wiggle);
```
# =
# ![Gif result](./data/ct.libs/sprite/SlimeExample_Blink.gif) or ![Gif result](./data/ct.libs/sprite/SlimeExample_Wiggle.gif)
35 changes: 20 additions & 15 deletions app/data/ct.release/sound.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
if (!ct.sound) {
ct.sound = {
/**
* Detects if a particular codec is supported in the system
/**
* Detects if a particular codec is supported in the system
* @param {String} type Codec/MIME-type to look for
* @returns {Boolean} true/false
*/
detect(type) {
var au = document.createElement('audio');
return Boolean(au.canPlayType && au.canPlayType(type).replace(/no/, ''));
},
/**
* Creates a new Sound object and puts it in resource object
*
/**
* Creates a new Sound object and puts it in resource object
*
* @param {String} name Sound's name
* @param {String} wav Local path to the sound in wav format
* @param {String} mp3 Local path to the sound in mp3 format
* @param {Object} formats A collection of sound files of specified extension, in format `extension: path`
* @param {String} [formats.ogg] Local path to the sound in ogg format
* @param {String} [formats.wav] Local path to the sound in wav format
* @param {String} [formats.mp3] Local path to the sound in mp3 format
* @param {Number} [options] An options object
*
*
* @returns {Object} Sound's object
*/
init(name, wav, mp3, options) {
init(name, formats, options) {
var src = '';
if (ct.sound.mp3 && mp3) {
src = mp3;
} else if (ct.sound.wav && wav) {
src = wav;
if (ct.sound.mp3 && formats.mp3) {
src = formats.mp3;
} else if (ct.sound.ogg && formats.ogg) {
src = formats.ogg;
} else if (ct.sound.wav && formats.wav) {
src = formats.wav;
}
options = options || {};
var audio = {
Expand Down Expand Up @@ -53,11 +57,11 @@ if (!ct.sound) {
},
/**
* Spawns a new sound and plays it.
*
*
* @param {String} name The name of sound to be played
* @param {Object} [opts] Options object that is applied to a newly created audio tag
* @param {Function} [cb] A callback, which is called when the sound finishes playing
*
*
* @returns {HTMLTagAudio|Boolean} The created audio or `false` (if a sound wasn't created)
*/
spawn(name, opts, cb) {
Expand Down Expand Up @@ -95,6 +99,7 @@ if (!ct.sound) {
// define sound types we can support
ct.sound.wav = ct.sound.detect('audio/wav; codecs="1"');
ct.sound.mp3 = ct.sound.detect('audio/mpeg;');
ct.sound.ogg = ct.sound.detect('audio/ogg;');
}

/*@sound@*/
2 changes: 1 addition & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"main": "index.html",
"name": "ctjs",
"description": "ctjs",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://ctjs.rocks/",
"license": "MIT",
"user-agent": "ct.js game engine %name/%ver (%osinfo) NW.js/%nwver AppleWebkit/%webkit_ver Chromium/%chromium_ver",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ctjsbuildenvironment",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"directories": {
"doc": "docs"
Expand Down
16 changes: 11 additions & 5 deletions src/node_requires/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ const packImages = () => {
y: g.axis[1] / g.height
}
};
if (yy * g.grid[0] + xx >= g.grid.untill && g.grid.untill > 0) {
if (yy * g.grid[0] + xx >= g.untill && g.untill > 0) {
break;
}
}
registry[g.name] = {
atlas: `./img/a${binInd}.json`,
frames: g.grid.untill > 0? Math.min(g.grid.untill, g.grid[0]*g.grid[1]) : g.grid[0]*g.grid[1],
frames: g.untill > 0? Math.min(g.untill, g.grid[0]*g.grid[1]) : g.grid[0]*g.grid[1],
shape: getTextureShape(g),
anchor: {
x: g.axis[0] / g.width,
Expand Down Expand Up @@ -281,11 +281,17 @@ const stringifySounds = () => {
throw new Error(`The sound asset "${s.name}" does not have an actual sound file attached.`);
}
var wav = s.origname.slice(-4) === '.wav',
mp3 = s.origname.slice(-4) === '.mp3';
sounds += `ct.sound.init('${s.name}', ${wav? `'./snd/${s.uid}.wav'` : 'null'}, ${mp3? `'./snd/${s.uid}.mp3'` : 'null'}, {
mp3 = s.origname.slice(-4) === '.mp3',
ogg = s.origname.slice(-4) === '.ogg';
sounds += `
ct.sound.init('${s.name}', {
wav: ${wav? '\'./snd/'+s.uid+'.wav\'' : false},
mp3: ${mp3? '\'./snd/'+s.uid+'.mp3\'' : false},
ogg: ${ogg? '\'./snd/'+s.uid+'.ogg\'' : false}
}, {
poolSize: ${s.poolSize || 5},
music: ${Boolean(s.isMusic)}
});\n`;
});`;
}
return sounds;
};
Expand Down
Loading

0 comments on commit de3a743

Please sign in to comment.