Path: blob/main/static/src/gs/public/radius-raid/js/definitions.js
1325 views
/*==============================================================================1Definitions2==============================================================================*/3$.definitions = {};45/*==============================================================================6Audio7==============================================================================*/8$.definitions.audio = {9'shoot': {10count: 10,11params: [12[2,,0.2,,0.1753,0.64,,-0.5261,,,,,,0.5522,-0.564,,,,1,,,,,0.25]13]14},15'shootAlt': {16count: 10,17params: [18[0,,0.16,0.18,0.18,0.47,0.0084,-0.26,,,,,,0.74,-1,,-0.76,,1,,,,,0.15]19]20},21'hit': {22count: 10,23params: [24[3,,0.0138,,0.2701,0.4935,,-0.6881,,,,,,,,,,,1,,,,,0.25],25[0,,0.0639,,0.2425,0.7582,,-0.6217,,,,,,0.4039,,,,,1,,,,,0.25],26[3,,0.0948,,0.2116,0.7188,,-0.6372,,,,,,,,,,,1,,,0.2236,,0.25]27]28},29'explosion': {30count: 5,31params: [32[3,,0.1164,0.88,0.37,0.06,,0.1599,,,,-0.0846,0.6485,,,,0.3963,-0.0946,1,,,,,0.25],33[3,,0.2958,0.3173,0.3093,0.0665,,0.1334,,,,,,,,,,,1,,,,,0.25]34]35},36'explosionAlt': {37count: 5,38params: [39[3,,0.15,0.7523,0.398,0.15,,-0.18,,0.39,0.53,-0.3428,0.6918,,,0.5792,0.6,0.56,1,,,,,0.25]40]41},42'takingDamage': {43count: 5,44params: [45[3,,0.1606,0.5988,0.2957,0.1157,,-0.3921,,,,,,,,,0.3225,-0.2522,1,,,,,0.25],46[3,,0.1726,0.2496,0.2116,0.0623,,-0.2096,,,,,,,,,0.2665,-0.1459,1,,,,,0.25],47[3,,0.1645,0.7236,0.3402,0.0317,,,,,,,,,,,,,1,,,,,0.25]48]49},50'death': {51count: 1,52params: [53[3,,0.51,,1,0.1372,,0.02,0.1,,,,0.89,0.7751,,,-0.16,0.32,1,0.3999,0.81,,0.1999,0.15]54]55},56'powerup': {57count: 3,58params: [59[0,,0.01,,0.4384,0.2,,0.12,0.28,1,0.65,,,0.0419,,,,,1,,,,,0.4]60]61},62'levelup': {63count: 2,64params: [65[2,1,0.01,,0.84,0.19,,,,0.62,0.7,,,-0.7248,0.8522,,,,1,,,,,0.45]66]67},68'hover': {69count: 10,70params: [71[0,0.08,0.18,,,0.65,,1,1,,,0.94,1,,,,-0.3,1,1,,,0.3,0.5,0.35]72]73},74'click': {75count: 5,76params: [77[3,,0.18,,,1,,-1,-1,,,,,,,,,,1,,,0.64,,0.35]78]79}80};8182/*==============================================================================83Enemies84==============================================================================*/85$.definitions.enemies = [86{ // Enemy 0 - horizontal / vertical87value: 5,88speed: 1.5,89life: 1,90radius: 15,91hue: 180,92lockBounds: 1,93setup: function() {94if( this.start == 'top' ){95this.direction = $.pi / 2;96} else if( this.start == 'right' ) {97this.direction = -$.pi;98} else if( this.start == 'bottom' ) {99this.direction = -$.pi / 2;100} else {101this.direction = 0;102}103},104behavior: function() {105var speed = this.speed;106if( $.slow ) {107speed = this.speed / $.slowEnemyDivider;108}109110this.vx = Math.cos( this.direction ) * speed;111this.vy = Math.sin( this.direction ) * speed;112}113},114{ // Enemy 1 - diagonal115value: 10,116speed: 1.5,117life: 2,118radius: 15,119hue: 120,120lockBounds: 1,121setup: function() {122var rand = Math.floor( $.util.rand( 0, 2 ) );123if( this.start == 'top' ){124this.direction = ( rand ) ? $.pi / 2 + $.pi / 4: $.pi / 2 - $.pi / 4;125} else if( this.start == 'right' ) {126this.direction = ( rand ) ? -$.pi + $.pi / 4 : -$.pi - $.pi / 4;127} else if( this.start == 'bottom' ) {128this.direction = ( rand ) ? -$.pi / 2 + $.pi / 4 : -$.pi / 2 - $.pi / 4;129} else {130this.direction = ( rand ) ? $.pi / 4 : -$.pi / 4;131}132},133behavior: function() {134var speed = this.speed;135if( $.slow ) {136speed = this.speed / $.slowEnemyDivider;137}138139this.vx = Math.cos( this.direction ) * speed;140this.vy = Math.sin( this.direction ) * speed;141}142},143{ // Enemy 2 - move directly hero144value: 15,145speed: 1.5,146life: 2,147radius: 20,148hue: 330,149behavior: function() {150var speed = this.speed;151if( $.slow ) {152speed = this.speed / $.slowEnemyDivider;153}154155var dx = $.hero.x - this.x,156dy = $.hero.y - this.y,157direction = Math.atan2( dy, dx );158this.vx = Math.cos( direction ) * speed;159this.vy = Math.sin( direction ) * speed;160}161},162{ // Enemy 3 - splitter163value: 20,164speed: 0.5,165life: 3,166radius: 50,167hue: 210,168canSpawn: 1,169behavior: function() {170var speed = this.speed;171if( $.slow ) {172speed = this.speed / $.slowEnemyDivider;173}174175var dx = $.hero.x - this.x,176dy = $.hero.y - this.y,177direction = Math.atan2( dy, dx );178this.vx = Math.cos( direction ) * speed;179this.vy = Math.sin( direction ) * speed;180},181death: function() {182if( this.canSpawn ) {183for( var i = 0; i < 4; i++ ) {184var enemy = $.spawnEnemy( this.type );185enemy.radius = 20;186enemy.canSpawn = 0;187enemy.speed = 1;188enemy.life = 1;189enemy.value = 5;190enemy.x = this.x;191enemy.y = this.y;192if( i == 0 ) {193enemy.x -= 45;194} else if( i == 1 ) {195enemy.x += 45;196} else if( i == 2 ) {197enemy.y -= 45;198} else {199enemy.y += 45;200}201$.enemies.push( enemy );202}203}204}205},206{ // Enemy 4 - wanderer207value: 25,208speed: 2,209life: 4,210radius: 20,211hue: 30,212lockBounds: 1,213setup: function() {214if( this.start == 'top' ){215this.direction = $.pi / 2;216} else if( this.start == 'right' ) {217this.direction = -$.pi;218} else if( this.start == 'bottom' ) {219this.direction = -$.pi / 2;220} else {221this.direction = 0;222}223},224behavior: function() {225var speed = this.speed * $.util.rand( 1, 2 );226if( $.slow ) {227speed = this.speed / $.slowEnemyDivider;228}229230this.direction += $.util.rand( -0.15, 0.15 );231this.vx = Math.cos( this.direction ) * speed;232this.vy = Math.sin( this.direction ) * speed;233}234},235{ // Enemy 5 - stealth, hard to see - move directly hero236value: 30,237speed: 1,238life: 3,239radius: 20,240hue: 0,241saturation: 0,242lightness: 30,243behavior: function() {244var speed = this.speed;245if( $.slow ) {246speed = this.speed / $.slowEnemyDivider;247}248249var dx = $.hero.x - this.x,250dy = $.hero.y - this.y,251direction = Math.atan2( dy, dx );252this.vx = Math.cos( direction ) * speed;253this.vy = Math.sin( direction ) * speed;254}255},256{ // Enemy 6 - big strong slow fatty257value: 35,258speed: 0.25,259life: 8,260radius: 80,261hue: 150,262behavior: function() {263var speed = this.speed;264if( $.slow ) {265speed = this.speed / $.slowEnemyDivider;266}267268var dx = $.hero.x - this.x,269dy = $.hero.y - this.y,270direction = Math.atan2( dy, dx );271this.vx = Math.cos( direction ) * speed;272this.vy = Math.sin( direction ) * speed;273}274},275{ // Enemy 7 - small weak speedy276value: 40,277speed: 2.5,278life: 1,279radius: 15,280hue: 300,281behavior: function() {282var speed = this.speed;283if( $.slow ) {284speed = this.speed / $.slowEnemyDivider;285}286287var dx = $.hero.x - this.x,288dy = $.hero.y - this.y,289direction = Math.atan2( dy, dx );290direction = direction + Math.cos( $.tick / 50 ) * 1;291this.vx = Math.cos( direction ) * speed;292this.vy = Math.sin( direction ) * speed;293}294},295{ // Enemy 8 - strong grower, move to hero296value: 45,297speed: 1.5,298growth: 0.1,299life: 6,300radius: 20,301hue: 0,302saturation: 0,303lightness: 100,304behavior: function() {305var speed = this.speed,306growth = this.growth;307if( $.slow ) {308speed = this.speed / $.slowEnemyDivider;309growth = this.growth / $.slowEnemyDivider;310}311312var dx = $.hero.x - this.x,313dy = $.hero.y - this.y,314direction = Math.atan2( dy, dx );315316if( Math.sqrt(dx * dx + dy * dy ) > 200 ) {317this.vx = Math.cos( direction ) * speed;318this.vy = Math.sin( direction ) * speed;319this.fillStyle ='hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, 0.1)';320this.strokeStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, 1)';321} else {322this.vx += $.util.rand( -0.25, 0.25 );323this.vy += $.util.rand( -0.25, 0.25 );324this.radius += growth * $.dt;325var hue = $.util.rand( 0, 360 );326lightness = $.util.rand( 50, 80 );327this.fillStyle ='hsla(' + hue + ', 100%, ' + lightness + '%, 0.2)';328this.strokeStyle = 'hsla(' + hue + ', 100%, ' + lightness + '%, 1)';329}330}331},332{ // Enemy 9 - circle around hero333value: 50,334speed: 0.5,335angleSpeed: 0.015,336life: 2,337radius: 20,338hue: 60,339setup: function() {340var dx = this.x - $.hero.x,341dy = this.y - $.hero.y;342this.angle = Math.atan2( dy, dx );343this.distance = Math.sqrt( dx * dx + dy * dy );344if( Math.random() > 0.5 ) {345this.angleSpeed = -this.angleSpeed;346}347},348behavior: function() {349var speed = this.speed,350angleSpeed = this.angleSpeed;351if( $.slow) {352speed = this.speed / $.slowEnemyDivider;353angleSpeed = this.angleSpeed / $.slowEnemyDivider;354}355356this.distance -= speed * $.dt;357this.angle += angleSpeed * $.dt;358359this.vx = ( ( $.hero.x + Math.cos( this.angle ) * this.distance ) - this.x ) / 50;360this.vy = ( ( $.hero.y + Math.sin( this.angle ) * this.distance ) - this.y ) / 50;361}362},363{ // Enemy 10 - spawner364value: 55,365speed: 1,366life: 3,367radius: 45,368hue: 0,369canSpawn: 1,370spawnTick: 0,371spawnMax: 250,372behavior: function() {373var speed = this.speed;374if( $.slow ) {375speed = this.speed / $.slowEnemyDivider;376}377378var dx = $.hero.x - this.x,379dy = $.hero.y - this.y,380direction = Math.atan2( dy, dx );381direction = direction + Math.cos( $.tick / 50 ) * 1;382this.vx = Math.cos( direction ) * speed;383this.vy = Math.sin( direction ) * speed;384385if( this.canSpawn ) {386if( this.spawnTick < this.spawnMax ) {387this.spawnTick += $.dt;388} else {389this.spawnTick = 0;390var enemy = $.spawnEnemy( this.type );391enemy.radius = 20;392enemy.canSpawn = 0;393enemy.speed = 3;394enemy.life = 1;395enemy.value = 30;396enemy.x = this.x;397enemy.y = this.y;398$.enemies.push( enemy );399}400}401}402},403{ // Enemy 11 - random location strong tower404value: 60,405speed: 1.5,406life: 10,407radius: 30,408hue: 90,409setup: function(){410this.xTarget = $.util.rand( 50, $.ww - 50 );411this.yTarget = $.util.rand( 50, $.wh - 50 );412},413behavior: function() {414var speed = this.speed;415if( $.slow ) {416speed = this.speed / $.slowEnemyDivider;417}418var dx = this.xTarget - this.x,419dy = this.yTarget - this.y,420direction = Math.atan2( dy, dx );421if( Math.sqrt( dx * dx + dy * dy) > this.speed ) {422this.vx = Math.cos( direction ) * speed;423this.vy = Math.sin( direction ) * speed;424} else {425this.vx = 0;426this.vy = 0;427}428}429},430{ // Enemy 12 - speedy random direction, no homing431value: 65,432speed: 6,433life: 1,434radius: 5,435hue: 0,436lockBounds: 1,437setup: function() {438this.radius = $.util.rand( 15, 35 );439this.speed = $.util.rand( 3, 8 );440if( Math.random() > 0.5 ){441if( this.start == 'top' ){442this.direction = $.pi / 2;443} else if( this.start == 'right' ) {444this.direction = -$.pi;445} else if( this.start == 'bottom' ) {446this.direction = -$.pi / 2;447} else {448this.direction = 0;449}450} else {451var rand = Math.floor( $.util.rand( 0, 2 ) );452if( this.start == 'top' ){453this.direction = ( rand ) ? $.pi / 2 + $.pi / 4: $.pi / 2 - $.pi / 4;454} else if( this.start == 'right' ) {455this.direction = ( rand ) ? -$.pi + $.pi / 4 : -$.pi - $.pi / 4;456} else if( this.start == 'bottom' ) {457this.direction = ( rand ) ? -$.pi / 2 + $.pi / 4 : -$.pi / 2 - $.pi / 4;458} else {459this.direction = ( rand ) ? $.pi / 4 : -$.pi / 4;460}461}462},463behavior: function() {464var speed = this.speed;465if( $.slow ) {466speed = this.speed / $.slowEnemyDivider;467}468this.vx = Math.cos( this.direction ) * speed;469this.vy = Math.sin( this.direction ) * speed;470this.hue += 10;471this.lightness = 50;472this.fillStyle = 'hsla(' + this.hue + ', 100%, ' + this.lightness + '%, 0.2)';473this.strokeStyle = 'hsla(' + this.hue + ', 100%, ' + this.lightness + '%, 1)';474}475}476];477478/*==============================================================================479Levels480==============================================================================*/481$.definitions.levels = [];482var base = 25;483for( var i = 0; i < $.definitions.enemies.length; i++ ){484var distribution = [];485for( var di = 0; di < i + 1; di++ ) {486var value = ( di == i ) ? Math.floor( ( ( i + 1) * base ) * 0.75 ) : ( i + 1) * base;487value = ( i == 0 ) ? base : value;488distribution.push( value );489}490$.definitions.levels.push( {491killsToLevel: 10 + ( i + 1 ) * 7,492distribution: distribution493} );494}495496/*==============================================================================497Powerups498==============================================================================*/499$.definitions.powerups = [500{501title: 'HEALTH PACK',502hue: 0,503saturation: 0,504lightness: 100505},506{507title: 'SLOW ENEMIES',508hue: 200,509saturation: 0,510lightness: 100511},512{513title: 'FAST SHOT',514hue: 100,515saturation: 100,516lightness: 60517},518{519title: 'TRIPLE SHOT',520hue: 200,521saturation: 100,522lightness: 60523},524{525title: 'PIERCE SHOT',526hue: 0,527saturation: 100,528lightness: 60529}530];531532/*==============================================================================533Letters534==============================================================================*/535$.definitions.letters = {536'1': [537[ , , 1, , 0 ],538[ , 1, 1, , 0 ],539[ , , 1, , 0 ],540[ , , 1, , 0 ],541[ 1, 1, 1, 1, 1 ]542],543'2': [544[ 1, 1, 1, 1, 0 ],545[ , , , , 1 ],546[ , 1, 1, 1, 0 ],547[ 1, , , , 0 ],548[ 1, 1, 1, 1, 1 ]549],550'3': [551[ 1, 1, 1, 1, 0 ],552[ , , , , 1 ],553[ , 1, 1, 1, 1 ],554[ , , , , 1 ],555[ 1, 1, 1, 1, 0 ]556],557'4': [558[ 1, , , 1, 0 ],559[ 1, , , 1, 0 ],560[ 1, 1, 1, 1, 1 ],561[ , , , 1, 0 ],562[ , , , 1, 0 ]563],564'5': [565[ 1, 1, 1, 1, 1 ],566[ 1, , , , 0 ],567[ 1, 1, 1, 1, 0 ],568[ , , , , 1 ],569[ 1, 1, 1, 1, 0 ]570],571'6': [572[ , 1, 1, 1, 0 ],573[ 1, , , , 0 ],574[ 1, 1, 1, 1, 0 ],575[ 1, , , , 1 ],576[ , 1, 1, 1, 0 ]577],578'7': [579[ 1, 1, 1, 1, 1 ],580[ , , , , 1 ],581[ , , , 1, 0 ],582[ , , 1, , 0 ],583[ , , 1, , 0 ]584],585'8': [586[ , 1, 1, 1, 0 ],587[ 1, , , , 1 ],588[ , 1, 1, 1, 0 ],589[ 1, , , , 1 ],590[ , 1, 1, 1, 0 ]591],592'9': [593[ , 1, 1, 1, 0 ],594[ 1, , , , 1 ],595[ , 1, 1, 1, 1 ],596[ , , , , 1 ],597[ , 1, 1, 1, 0 ]598],599'0': [600[ , 1, 1, 1, 0 ],601[ 1, , , , 1 ],602[ 1, , , , 1 ],603[ 1, , , , 1 ],604[ , 1, 1, 1, 0 ]605],606'A': [607[ 1, 1, 1, 1, 1 ],608[ 1, , , , 1 ],609[ 1, 1, 1, 1, 1 ],610[ 1, , , , 1 ],611[ 1, , , , 1 ]612],613'B': [614[ 1, 1, 1, 1, 0 ],615[ 1, , , 1, 0 ],616[ 1, 1, 1, 1, 1 ],617[ 1, , , , 1 ],618[ 1, 1, 1, 1, 1 ]619],620'C': [621[ 1, 1, 1, 1, 1 ],622[ 1, , , , 0 ],623[ 1, , , , 0 ],624[ 1, , , , 0 ],625[ 1, 1, 1, 1, 1 ]626],627'D': [628[ 1, 1, 1, , 0 ],629[ 1, , , 1, 0 ],630[ 1, , , , 1 ],631[ 1, , , , 1 ],632[ 1, 1, 1, 1, 1 ]633],634'E': [635[ 1, 1, 1, 1, 1 ],636[ 1, , , , 0 ],637[ 1, 1, 1, , 0 ],638[ 1, , , , 0 ],639[ 1, 1, 1, 1, 1 ]640],641'F': [642[ 1, 1, 1, 1, 1 ],643[ 1, , , , 0 ],644[ 1, 1, 1, , 0 ],645[ 1, , , , 0 ],646[ 1, , , , 0 ]647],648'G': [649[ 1, 1, 1, 1, 1 ],650[ 1, , , , 0 ],651[ 1, , 1, 1, 1 ],652[ 1, , , , 1 ],653[ 1, 1, 1, 1, 1 ]654],655'H': [656[ 1, , , , 1 ],657[ 1, , , , 1 ],658[ 1, 1, 1, 1, 1 ],659[ 1, , , , 1 ],660[ 1, , , , 1 ]661],662'I': [663[ 1, 1, 1, 1, 1 ],664[ , , 1, , 0 ],665[ , , 1, , 0 ],666[ , , 1, , 0 ],667[ 1, 1, 1, 1, 1 ]668],669'J': [670[ , , , , 1 ],671[ , , , , 1 ],672[ , , , , 1 ],673[ 1, , , , 1 ],674[ 1, 1, 1, 1, 1 ]675],676'K': [677[ 1, , , 1, 0 ],678[ 1, , 1, , 0 ],679[ 1, 1, 1, , 0 ],680[ 1, , , 1, 0 ],681[ 1, , , , 1 ]682],683'L': [684[ 1, , , , 0 ],685[ 1, , , , 0 ],686[ 1, , , , 0 ],687[ 1, , , , 0 ],688[ 1, 1, 1, 1, 1 ]689],690'M': [691[ 1, , , , 1 ],692[ 1, 1, , 1, 1 ],693[ 1, , 1, , 1 ],694[ 1, , , , 1 ],695[ 1, , , , 1 ]696],697'N': [698[ 1, , , , 1 ],699[ 1, 1, , , 1 ],700[ 1, , 1, , 1 ],701[ 1, , , 1, 1 ],702[ 1, , , , 1 ]703],704'O': [705[ 1, 1, 1, 1, 1 ],706[ 1, , , , 1 ],707[ 1, , , , 1 ],708[ 1, , , , 1 ],709[ 1, 1, 1, 1, 1 ]710],711'P': [712[ 1, 1, 1, 1, 1 ],713[ 1, , , , 1 ],714[ 1, 1, 1, 1, 1 ],715[ 1, , , , 0 ],716[ 1, , , , 0 ]717],718'Q': [719[ 1, 1, 1, 1, 0 ],720[ 1, , , 1, 0 ],721[ 1, , , 1, 0 ],722[ 1, , , 1, 0 ],723[ 1, 1, 1, 1, 1 ]724],725'R': [726[ 1, 1, 1, 1, 1 ],727[ 1, , , , 1 ],728[ 1, 1, 1, 1, 1 ],729[ 1, , , 1, 0 ],730[ 1, , , , 1 ]731],732'S': [733[ 1, 1, 1, 1, 1 ],734[ 1, , , , 0 ],735[ 1, 1, 1, 1, 1 ],736[ , , , , 1 ],737[ 1, 1, 1, 1, 1 ]738],739'T': [740[ 1, 1, 1, 1, 1 ],741[ , , 1, , 0 ],742[ , , 1, , 0 ],743[ , , 1, , 0 ],744[ , , 1, , 0 ]745],746'U': [747[ 1, , , , 1 ],748[ 1, , , , 1 ],749[ 1, , , , 1 ],750[ 1, , , , 1 ],751[ 1, 1, 1, 1, 1 ]752],753'V': [754[ 1, , , , 1 ],755[ 1, , , , 1 ],756[ 1, , , , 1 ],757[ , 1, , 1, 0 ],758[ , , 1, , 0 ]759],760'W': [761[ 1, , , , 1 ],762[ 1, , , , 1 ],763[ 1, , 1, , 1 ],764[ 1, 1, , 1, 1 ],765[ 1, , , , 1 ]766],767'X': [768[ 1, , , , 1 ],769[ , 1, , 1, 0 ],770[ , , 1, , 0 ],771[ , 1, , 1, 0 ],772[ 1, , , , 1 ]773],774'Y': [775[ 1, , , , 1 ],776[ 1, , , , 1 ],777[ 1, 1, 1, 1, 1 ],778[ , , 1, , 0 ],779[ , , 1, , 0 ]780],781'Z': [782[ 1, 1, 1, 1, 1 ],783[ , , , 1, 0 ],784[ , , 1, , 0 ],785[ , 1, , , 0 ],786[ 1, 1, 1, 1, 1 ]787],788' ': [789[ , , , , 0 ],790[ , , , , 0 ],791[ , , , , 0 ],792[ , , , , 0 ],793[ , , , , 0 ]794],795',': [796[ , , , , 0 ],797[ , , , , 0 ],798[ , , , , 0 ],799[ , , 1, , 0 ],800[ , , 1, , 0 ]801],802'+': [803[ , , , , 0 ],804[ , , 1, , 0 ],805[ , 1, 1, 1, 0 ],806[ , , 1, , 0 ],807[ , , , , 0 ]808],809'/': [810[ , , , , 1 ],811[ , , , 1, 0 ],812[ , , 1, , 0 ],813[ , 1, , , 0 ],814[ 1, , , , 0 ]815],816':': [817[ , , , , 0 ],818[ , , 1, , 0 ],819[ , , , , 0 ],820[ , , 1, , 0 ],821[ , , , , 0 ]822],823'@': [824[ 1, 1, 1, 1, 1 ],825[ , , , , 1 ],826[ 1, 1, 1, , 1 ],827[ 1, , 1, , 1 ],828[ 1, 1, 1, 1, 1 ]829]830};831832