Commit 94d886d8 by Oriol Gómez

meeeowwwwww!

parent d4c24e61
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";
import {randomInt} from 'util'
import {utils} from 'utilities'
import {panner} from 'sono/effects';
import {Insect} from 'insect'
export var ins=null;
import {Timer} from 'timer'
......@@ -79,7 +80,7 @@ break;
}
}
reset() {
this.btime=randomInt(8000,20000);
this.btime=utils.randomInt(8000,20000);
this.musicVolume=1;
this.shields=0;
this.kills=0;
......@@ -110,7 +111,7 @@ insect.destroy()
looper() {
if (this.spawner.elapsed>=this.spawn) {
this.spawner.reset();
this.spawn=randomInt(2000-(this.level*200),3000-(this.level*100));
this.spawn=utils.randomInt(2000-(this.level*200),3000-(this.level*100));
var ins=new Insect();
this.enemies.push(ins);
}
......
import {soundObject} from 'soundObject'
import sono from 'sono'
import {game} from 'main'
import {randomInt} from 'util'
import {soundObject} from 'soundObject';
import {speech} from 'tts'
import {Timer} from 'timer';
import sono from 'sono';
import {panner} from 'sono/effects';
import {game} from 'main';
import {utils} from 'utilities';
class Insect {
constructor() {
this.vol=0.1
this.position=null;
this.snd=soundObject.create(game.mode+"/l_"+randomInt(1,game.numberOfEnemies[game.mode]));
this.snd=soundObject.create(game.mode+"/l_"+utils.randomInt(1,game.numberOfEnemies[game.mode]));
this.panner=this.snd.effects.add(sono.panner());
this.move=new Timer()
this.move.reset();
this.snd.loop=true;
this.snd.playbackRate=getRandomArbitrary(68,122)/100
this.snd.playbackRate=utils.getRandomArbitrary(68,122)/100
this.snd.volume=this.vol;
this.snd.play()
this.alive=true;
this.speed=null;
this.pos=randomInt(1,3);
this.pos=utils.randomInt(1,3);
speech.speak(this.pos)
//set pan
if (this.pos==1)
......@@ -56,8 +58,8 @@ startGame()
}//function
die() {
this.snd.destroy()
this.deathSound=soundObject.create(game.mode+"/d_"+randomInt(1,8))
this.slapSound=soundObject.create(game.mode+"/slap"+randomInt(1,4))
this.deathSound=soundObject.create(game.mode+"/d_"+utils.randomInt(1,8))
this.slapSound=soundObject.create(game.mode+"/slap"+utils.randomInt(1,4))
var panner1=this.deathSound.effects.add(sono.panner())
var panner2=this.slapSound.effects.add(sono.panner())
if (this.pos==1)
......
"use strict";
import {getRandomArbitrary,getRandomInt} from 'util'
import {utils} from 'utilities'
import {TTS,useWebTTS} from 'tts'
if (typeof speech == "undefined") var speech = new TTS();
import $ from 'jquery'
......@@ -50,8 +50,6 @@ function playIntro() {
}
function startGame() {
console.log(getRandomArbitrary(12,20));
//console.log(randomInt(12,20));
if (game!=null & game.music!=null) {
game.music.stop();
......
......@@ -29,4 +29,5 @@ class TTS {
}
} // end class
export {useWebTTS,TTS}
\ No newline at end of file
if (typeof speech == "undefined") var speech = new TTS();
export {useWebTTS,TTS,speech}
\ No newline at end of file
'use strict';
export function distance3D(x1, y1, z1, x2, y2, z2) {
class GameUtils {
distance3D(x1, y1, z1, x2, y2, z2) {
return Math.sqrt((x2-x1)*(x2-x1) +
(y2-y1)*(y2-y1) +
(z2-z1)*(z2-z1));
}
export function distance(jx, jy, kx, ky) {
distance(jx, jy, kx, ky) {
//return Math.hypot(jx-kx, jy-ky)
return Math.sqrt(((jx - kx) * (jx - kx)) + ((jy - ky)) * (jy - ky))
}
export function calculateAngle(x1, y1, x2, y2) {
calculateAngle(x1, y1, x2, y2) {
var angle = Math.atan2((y2-y1), (x2-x1));
angle = (angle >= 0) ? 0 : (2*Math.PI) + angle;
return angle;
// return Math.atan2((y2 - y1),(x2 - x1));
}
export function isCollide3D(a, b)
isCollide3D(a, b)
{
return(a.x <= (b.x+b.width) && (a.x+a.width) >= b.x)&&(a.y <= (b.y+b.height) && (a.y+a.height) >= b.y)&&(a.z <= (b.z+b.depth) && (a.z+a.depth) >= b.z);
}
export function randomInt(min, max) {
randomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
export function getRandomArbitrary(min, max) {
getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
\ No newline at end of file
}
}
export var utils=new GameUtils();
\ No newline at end of file
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