├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── js-sfa.iml ├── jsLibraryMappings.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml ├── vcs.xml └── workspace.xml ├── README ├── css └── sfa.css ├── default.htm ├── images └── misc │ ├── akuma │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── akuma2 │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── buttons │ ├── HK.png │ ├── HP.png │ ├── LK.png │ ├── LP.png │ ├── MK.png │ ├── MP.png │ ├── e.png │ ├── hk.png │ ├── hp.png │ ├── lk.png │ ├── lp.png │ ├── mk.png │ ├── mp.png │ ├── n.png │ ├── ne.png │ ├── nw.png │ ├── s.png │ ├── se.png │ ├── sw.png │ └── w.png │ ├── font1 │ ├── cap.png │ ├── credits.png │ ├── insert.png │ └── press-start.png │ ├── ken │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── ken2 │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── mbison │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── mbison2 │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── misc │ ├── announcer-sprites.png │ ├── bars-sprites.png │ ├── blast-sprites.png │ ├── char-select-sprites.png │ ├── char-sprites.png │ ├── dirt-sprites.png │ ├── energy-bar-lvl0.png │ ├── energy-bar-lvl1.png │ ├── energy-bar-lvl2.png │ ├── head-sprites.png │ ├── health-bar-damage.png │ ├── health-bar-life.png │ ├── health-bar.png │ ├── misc-sprites.png │ ├── scf-sprites.png │ ├── shadow-sprites.png │ └── splash.jpg │ ├── ryu │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── ryu2 │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── sagat │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ ├── sagat2 │ ├── misc-sprites.png │ ├── projectiles.png │ ├── sprites.png │ └── trail-sprites.png │ └── stage │ ├── akuma.back.png │ ├── akuma.front.png │ ├── chunli.back.png │ ├── chunli.front.png │ ├── guy.back.png │ ├── guy.front.png │ ├── ken.back.png │ ├── ken.front.png │ ├── mbison.back.png │ ├── mbison.front.png │ ├── rose.back.png │ ├── rose.front.png │ ├── ryu.back.png │ ├── ryu.front.png │ ├── sagat.back.png │ ├── sagat.front.png │ ├── sodom.back.png │ └── sodom.front.png └── script ├── ai-proxy.js ├── akuma-ai.js ├── animation-trial.js ├── animation.js ├── announcer.js ├── audio ├── akuma-theme.ogg.js ├── akuma.ogg.js ├── char-select.ogg.js ├── chunli-theme.ogg.js ├── guy-theme.ogg.js ├── insert-coin.ogg.js ├── ken-theme.ogg.js ├── ken.ogg.js ├── match.ogg.js ├── mbison-theme.ogg.js ├── mbison.ogg.js ├── rose-theme.ogg.js ├── ryu-theme.ogg.js ├── ryu.ogg.js ├── sagat-theme.ogg.js ├── sagat.ogg.js └── sodom-theme.ogg.js ├── base64-binary.js ├── browserDetect.js ├── cdHelper.js ├── char-select.js ├── circle.js ├── debug-modal.js ├── debug.js ├── energy-bar.js ├── faceoff.js ├── flags.js ├── fonts.js ├── fontsystem.js ├── game.js ├── generic-ai.js ├── health-bar.js ├── hitsystem.js ├── init.js ├── insert-coin.js ├── joypad.min.js ├── ken-ai.js ├── load-spritedata.js ├── match.js ├── mbison-ai.js ├── player-akuma-spritedata.js ├── player-akuma.js ├── player-akuma2-spritedata.js ├── player-common.js ├── player-ken-spritedata.js ├── player-ken.js ├── player-ken2-spritedata.js ├── player-mbison-spritedata.js ├── player-mbison.js ├── player-mbison2-spritedata.js ├── player-ryu-spritedata.js ├── player-ryu.js ├── player-ryu2-spritedata.js ├── player-sagat-spritedata.js ├── player-sagat.js ├── player-sagat2-spritedata.js ├── player-utils.js ├── player.ai.js ├── player.animation.js ├── player.combat.js ├── player.debug.js ├── player.input.js ├── player.js ├── player.motion.js ├── player.sound.js ├── ryu-ai.js ├── sagat-ai.js ├── soundmanager.js ├── stage.js ├── stuff-loader.js ├── team.js ├── user.js ├── values.js ├── vcr.js └── webAudioManager.js /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/js-sfa.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 29 | 30 | 31 | 33 | { 34 | "associatedIndex": 8 35 | } 36 | 37 | 38 | 39 | 40 | 41 | 44 | { 45 | "keyToString": { 46 | "RunOnceActivity.OpenProjectViewOnStart": "true", 47 | "RunOnceActivity.ShowReadmeOnStart": "true", 48 | "git-widget-placeholder": "master", 49 | "last_opened_file_path": "/home/dre/projects/js-sfa", 50 | "node.js.detected.package.eslint": "true", 51 | "node.js.selected.package.eslint": "(autodetect)", 52 | "node.js.selected.package.tslint": "(autodetect)", 53 | "nodejs_package_manager_path": "npm", 54 | "vue.rearranger.settings.migration": "true" 55 | } 56 | } 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 1618771075965 67 | 85 | 86 | 87 | 88 | 90 | 91 | 100 | 101 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Street Fighter Alpha 2 | -------------------- 3 | 4 | Try it out here: 5 | https://gamedev8.github.io/js-sfa/default.htm 6 | -------------------- 7 | 8 | 9 | This is more of a "Chrome experiment". I have not really tested it in Firefox, Safari or IE. 10 | 11 | Playable Characters (so far) 12 | -------------------- 13 | Ken 14 | Ryu 15 | Sagat 16 | MBison 17 | Akuma 18 | 19 | Player 1 keys: 20 | -------------------- 21 | Pause (Next frame): O 22 | Resume: P 23 | Coin: Control 24 | Start: Enter 25 | light punch: A 26 | medium punch: S 27 | hard punch: D 28 | light kick: Z 29 | medium kick: X 30 | hard kick: C 31 | turn around: F 32 | walk, crouch, jump: Arrow keys 33 | 34 | Tips 35 | -------------------- 36 | In the browser console, use the debug_.practice() function to quickly start practice matches. 37 | 38 | //Ken vs Ryu 39 | debug_.practice(); 40 | 41 | //Dramatic Battle 42 | debug_.practice([{A:CHARACTERS.KEN}, {A:CHARACTERS.RYU, C:true}], [{A:CHARACTERS.MBISON, C:true}], "dramatic_battle"); 43 | 44 | //start a 1 on 1 match vs Akuma (AI difficulty is maxed out) 45 | debug_.practice([{A:CHARACTERS.KEN}], [{A:CHARACTERS.AKUMA, C:true, D:100}], "guy") 46 | 47 | //start a 2 on 2 match 48 | debug_.practice([{A:CHARACTERS.KEN}, {A:CHARACTERS.RYU, B:true, C:true}], [{A:CHARACTERS.MBISON, C:true}, {A:CHARACTERS.SAGAT, C:true}], "guy") 49 | 50 | //instantly give level 3 energy 51 | debug_.maxOutEnergy(); 52 | 53 | //brings up the projectile editor 54 | debug_.showProjectileEditor(); 55 | 56 | //hides the projectile editor 57 | debug_.hideProjectileEditor(); 58 | 59 | 60 | Join the chat at https://gitter.im/gamedev8/js-sfa 61 | -------------------------------------------------------------------------------- /images/misc/akuma/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/akuma/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma/projectiles.png -------------------------------------------------------------------------------- /images/misc/akuma/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma/sprites.png -------------------------------------------------------------------------------- /images/misc/akuma/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/akuma2/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma2/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/akuma2/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma2/projectiles.png -------------------------------------------------------------------------------- /images/misc/akuma2/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma2/sprites.png -------------------------------------------------------------------------------- /images/misc/akuma2/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/akuma2/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/buttons/HK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/HK.png -------------------------------------------------------------------------------- /images/misc/buttons/HP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/HP.png -------------------------------------------------------------------------------- /images/misc/buttons/LK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/LK.png -------------------------------------------------------------------------------- /images/misc/buttons/LP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/LP.png -------------------------------------------------------------------------------- /images/misc/buttons/MK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/MK.png -------------------------------------------------------------------------------- /images/misc/buttons/MP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/MP.png -------------------------------------------------------------------------------- /images/misc/buttons/e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/e.png -------------------------------------------------------------------------------- /images/misc/buttons/hk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/hk.png -------------------------------------------------------------------------------- /images/misc/buttons/hp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/hp.png -------------------------------------------------------------------------------- /images/misc/buttons/lk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/lk.png -------------------------------------------------------------------------------- /images/misc/buttons/lp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/lp.png -------------------------------------------------------------------------------- /images/misc/buttons/mk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/mk.png -------------------------------------------------------------------------------- /images/misc/buttons/mp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/mp.png -------------------------------------------------------------------------------- /images/misc/buttons/n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/n.png -------------------------------------------------------------------------------- /images/misc/buttons/ne.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/ne.png -------------------------------------------------------------------------------- /images/misc/buttons/nw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/nw.png -------------------------------------------------------------------------------- /images/misc/buttons/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/s.png -------------------------------------------------------------------------------- /images/misc/buttons/se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/se.png -------------------------------------------------------------------------------- /images/misc/buttons/sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/sw.png -------------------------------------------------------------------------------- /images/misc/buttons/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/buttons/w.png -------------------------------------------------------------------------------- /images/misc/font1/cap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/font1/cap.png -------------------------------------------------------------------------------- /images/misc/font1/credits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/font1/credits.png -------------------------------------------------------------------------------- /images/misc/font1/insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/font1/insert.png -------------------------------------------------------------------------------- /images/misc/font1/press-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/font1/press-start.png -------------------------------------------------------------------------------- /images/misc/ken/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/ken/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken/projectiles.png -------------------------------------------------------------------------------- /images/misc/ken/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken/sprites.png -------------------------------------------------------------------------------- /images/misc/ken/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/ken2/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken2/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/ken2/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken2/projectiles.png -------------------------------------------------------------------------------- /images/misc/ken2/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken2/sprites.png -------------------------------------------------------------------------------- /images/misc/ken2/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ken2/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/mbison/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/mbison/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison/projectiles.png -------------------------------------------------------------------------------- /images/misc/mbison/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison/sprites.png -------------------------------------------------------------------------------- /images/misc/mbison/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/mbison2/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison2/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/mbison2/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison2/projectiles.png -------------------------------------------------------------------------------- /images/misc/mbison2/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison2/sprites.png -------------------------------------------------------------------------------- /images/misc/mbison2/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/mbison2/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/announcer-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/announcer-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/bars-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/bars-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/blast-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/blast-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/char-select-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/char-select-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/char-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/char-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/dirt-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/dirt-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/energy-bar-lvl0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/energy-bar-lvl0.png -------------------------------------------------------------------------------- /images/misc/misc/energy-bar-lvl1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/energy-bar-lvl1.png -------------------------------------------------------------------------------- /images/misc/misc/energy-bar-lvl2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/energy-bar-lvl2.png -------------------------------------------------------------------------------- /images/misc/misc/head-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/head-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/health-bar-damage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/health-bar-damage.png -------------------------------------------------------------------------------- /images/misc/misc/health-bar-life.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/health-bar-life.png -------------------------------------------------------------------------------- /images/misc/misc/health-bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/health-bar.png -------------------------------------------------------------------------------- /images/misc/misc/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/scf-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/scf-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/shadow-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/shadow-sprites.png -------------------------------------------------------------------------------- /images/misc/misc/splash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/misc/splash.jpg -------------------------------------------------------------------------------- /images/misc/ryu/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/ryu/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu/projectiles.png -------------------------------------------------------------------------------- /images/misc/ryu/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu/sprites.png -------------------------------------------------------------------------------- /images/misc/ryu/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/ryu2/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu2/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/ryu2/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu2/projectiles.png -------------------------------------------------------------------------------- /images/misc/ryu2/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu2/sprites.png -------------------------------------------------------------------------------- /images/misc/ryu2/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/ryu2/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/sagat/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/sagat/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat/projectiles.png -------------------------------------------------------------------------------- /images/misc/sagat/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat/sprites.png -------------------------------------------------------------------------------- /images/misc/sagat/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/sagat2/misc-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat2/misc-sprites.png -------------------------------------------------------------------------------- /images/misc/sagat2/projectiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat2/projectiles.png -------------------------------------------------------------------------------- /images/misc/sagat2/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat2/sprites.png -------------------------------------------------------------------------------- /images/misc/sagat2/trail-sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/sagat2/trail-sprites.png -------------------------------------------------------------------------------- /images/misc/stage/akuma.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/akuma.back.png -------------------------------------------------------------------------------- /images/misc/stage/akuma.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/akuma.front.png -------------------------------------------------------------------------------- /images/misc/stage/chunli.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/chunli.back.png -------------------------------------------------------------------------------- /images/misc/stage/chunli.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/chunli.front.png -------------------------------------------------------------------------------- /images/misc/stage/guy.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/guy.back.png -------------------------------------------------------------------------------- /images/misc/stage/guy.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/guy.front.png -------------------------------------------------------------------------------- /images/misc/stage/ken.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/ken.back.png -------------------------------------------------------------------------------- /images/misc/stage/ken.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/ken.front.png -------------------------------------------------------------------------------- /images/misc/stage/mbison.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/mbison.back.png -------------------------------------------------------------------------------- /images/misc/stage/mbison.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/mbison.front.png -------------------------------------------------------------------------------- /images/misc/stage/rose.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/rose.back.png -------------------------------------------------------------------------------- /images/misc/stage/rose.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/rose.front.png -------------------------------------------------------------------------------- /images/misc/stage/ryu.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/ryu.back.png -------------------------------------------------------------------------------- /images/misc/stage/ryu.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/ryu.front.png -------------------------------------------------------------------------------- /images/misc/stage/sagat.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/sagat.back.png -------------------------------------------------------------------------------- /images/misc/stage/sagat.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/sagat.front.png -------------------------------------------------------------------------------- /images/misc/stage/sodom.back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/sodom.back.png -------------------------------------------------------------------------------- /images/misc/stage/sodom.front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamedev8/js-sfa/66cf60d2198ef613a84229d4e9d0f07c2347d215/images/misc/stage/sodom.front.png -------------------------------------------------------------------------------- /script/ai-proxy.js: -------------------------------------------------------------------------------- 1 | var CreateAIProxy = function() 2 | { 3 | var player_ = null; 4 | var managed_ = null; 5 | 6 | 7 | var AIProxy = function() 8 | { 9 | } 10 | 11 | AIProxy.prototype.enableAI = function(player,createAiFn) 12 | { 13 | player_ = player_ || player; 14 | managed_ = managed_ || (!!createAiFn ? createAiFn(player_) : null); 15 | } 16 | AIProxy.prototype.release = function() { player_ = null; managed_ = null; } 17 | AIProxy.prototype.reset = function() { managed_.reset(); } 18 | AIProxy.prototype.getManaged = function() { return managed_; } 19 | AIProxy.prototype.isRunning = function() { return !!managed_; } 20 | AIProxy.prototype.onEnemyStartAttack = function(frame, who) { managed_.onEnemyStartAttack(frame,who); } 21 | AIProxy.prototype.onEnemyContinueAttack = function(frame, who) { managed_.onEnemyContinueAttack(frame,who); } 22 | AIProxy.prototype.onEnemyEndAttack = function(frame, who) { managed_.onEnemyEndAttack(frame,who); } 23 | AIProxy.prototype.onEnemyVulnerable = function(frame, who, x, y) { managed_.onEnemyVulnerable(frame,who,x,y); } 24 | AIProxy.prototype.onEnemyFloating = function(frame, who, x, y) { if(!!managed_.onEnemyFloating) { managed_.onEnemyFloating(frame,who,x,y); } } 25 | AIProxy.prototype.onEnemyDizzy = function(frame, who) { managed_.onEnemyDizzy(frame,who); } 26 | AIProxy.prototype.onEnemyAttackPending = function(frame,x,y,player,isSuperMove) { managed_.onEnemyAttackPending(frame,x,y,player,isSuperMove); } 27 | AIProxy.prototype.onEnemyProjectilePending = function(frame,x,y,player,isSuperMove) { managed_.onEnemyProjectilePending(frame,x,y,player,isSuperMove); } 28 | AIProxy.prototype.onEnemyProjectileMoved = function(frame,id,x,y,projectile,isSuperMove) { managed_.onEnemyProjectileMoved(frame,id,x,y,projectile,isSuperMove); } 29 | AIProxy.prototype.onEnemyProjectileGone = function(frame,id) { managed_.onEnemyProjectileGone(id); } 30 | AIProxy.prototype.onTakeHit = function(frame,id) { managed_.onTakeHit(id); } 31 | AIProxy.prototype.onAttackStateChanged = function(who,result) { managed_.onAttackStateChanged(who,result); } 32 | AIProxy.prototype.onBlocked = function() { managed_.onBlocked(); } 33 | AIProxy.prototype.onStartAttack = function(frame,id) { managed_.onStartAttack(id); } 34 | AIProxy.prototype.frameMove = function(frame) { managed_.frameMove(frame); } 35 | AIProxy.prototype.onNewRound = function() { managed_.onNewRound(); } 36 | AIProxy.prototype.onStartAnimation = function(name) { managed_.onStartAnimation(name); } 37 | AIProxy.prototype.onEndAnimation = function(name) { managed_.onEndAnimation(name); } 38 | AIProxy.prototype.execute = function(sequence) { managed_.execute(sequence); } 39 | 40 | return new AIProxy(); 41 | } 42 | -------------------------------------------------------------------------------- /script/animation-trial.js: -------------------------------------------------------------------------------- 1 | var CreateAnimationTrail = function(animations,zIndex,delay) 2 | { 3 | var AnimationTrail = function() 4 | { 5 | this.FollowElement = null; 6 | this.Player = null; 7 | this.Trail = []; 8 | this.Delay = delay || 12; 9 | this.Enabled = false; 10 | this.StageDeltaX = 0; 11 | this.StageDeltaY = 0; 12 | } 13 | 14 | AnimationTrail.prototype.id = 0; 15 | AnimationTrail.prototype.getNextId = function() { return AnimationTrail.prototype.id++; } 16 | 17 | AnimationTrail.prototype.release = function() 18 | { 19 | for(var i = 0, length = this.Trail.length; i < length; ++i) 20 | { 21 | utils_.removeFromDOM(this.Trail[i].Element); 22 | } 23 | utils_.releaseArray(this.Trail); 24 | utils_.removeFromDOM(this.FollowElement); 25 | this.Player = null; 26 | } 27 | 28 | AnimationTrail.prototype.add = function(animation,followElement,folder,player) 29 | { 30 | this.Player = player; 31 | var img = window.document.createElement("div"); 32 | img.className = "player-sprite"; 33 | 34 | var div = window.document.createElement("div"); 35 | div.className = "player"; 36 | /*this.B64Key = "images/misc/" + folder + "/trail-sprites.png";*/ 37 | div.style.backgroundImage = "url(images/misc/" + folder + "/trail-sprites.png)"; 38 | div.appendChild(img); 39 | 40 | this.Trail[this.Trail.length] = {StartFrame:0,Element:div,Animation:animation,FrameIndex:0,LastImageSrc:"",Coords:[],HasB64:false}; 41 | 42 | this.FollowElement = this.FollowElement || followElement; 43 | if(!!this.FollowElement) 44 | { 45 | var container = this.FollowElement.parentNode; 46 | if(container.children.length == 0) 47 | container.appendChild(div); 48 | else 49 | container.insertBefore(div,container.children[0]); 50 | } 51 | } 52 | 53 | 54 | AnimationTrail.prototype.disable = function() 55 | { 56 | if(!!this.Enabled) 57 | { 58 | this.StageDeltaX = 0; 59 | this.StageDeltaY = 0; 60 | 61 | this.Enabled = false; 62 | 63 | for(var i = 0, length = this.Trail.length; i < length; ++i) 64 | { 65 | //this.FollowElement.parentNode.removeChild(this.Trail[i].Element); 66 | this.Trail[i].Element.style.display = "none"; 67 | this.Trail[i].FrameIndex = 0; 68 | } 69 | } 70 | } 71 | 72 | 73 | AnimationTrail.prototype.enable = function(frame,followElement,direction) 74 | { 75 | if(!this.Enabled) 76 | { 77 | this.StageDeltaX = 0; 78 | this.StageDeltaY = 0; 79 | 80 | this.FollowElement = this.FollowElement || followElement; 81 | var container = this.FollowElement.parentNode; 82 | for(var i = 0, length = this.Trail.length; i < length; ++i) 83 | { 84 | AutoApplyFlip(this.Trail[i].Element,direction == -1); 85 | this.Trail[i].Animation.clearAllFrameUserData(); 86 | this.Trail[i].StartFrame = frame + (this.Delay * (i + 1)); 87 | this.Trail[i].FrameIndex = 0; 88 | } 89 | this.Enabled = true; 90 | } 91 | } 92 | 93 | /*returns the current frame for the trail*/ 94 | AnimationTrail.prototype.getCurrentFrame = function(index) 95 | { 96 | return this.Trail[index].Animation.BaseAnimation.Frames[this.Trail[index].FrameIndex]; 97 | } 98 | /**/ 99 | AnimationTrail.prototype.frameMove = function(frame,index,direction,stageX,stageY) 100 | { 101 | if(this.Enabled) 102 | { 103 | this.Direction = direction; 104 | var bottom = parseInt(this.FollowElement.style.bottom); 105 | var left = this.FollowElement.style.left; 106 | var right = this.FollowElement.style.right; 107 | 108 | if(!!this.Player) 109 | { 110 | var rect = this.Player.getImgRect(); 111 | bottom = rect.BottomNoOffset; 112 | if(right == "") 113 | left = rect.Left; 114 | else 115 | right = STAGE.MAX_STAGEX - rect.Right; 116 | } 117 | 118 | if(right === "") 119 | left = left + "px"; 120 | else 121 | right = right + "px"; 122 | 123 | for(var i = 0, length = this.Trail.length; i < length; ++i) 124 | { 125 | this.Trail[i].Animation.addUserDataToFrame(index, 126 | { 127 | Frame:frame 128 | ,Left:left 129 | ,Right:right 130 | /*Must remove the stage offsetY from the cordinate and apply it on the current frame.*/ 131 | /*Remember that recording it here will apply the coordinate after a certain number of frames,*/ 132 | /*and if the screen Y changes then it will mess up the trail - so we must remove the screen offset*/ 133 | ,Bottom:bottom - game_.getMatch().getStage().OffsetY + "px" 134 | ,Top:this.FollowElement.style.top 135 | ,DeltaX:0 136 | ,DeltaY:0 137 | ,Flip:this.Player.IsSpriteReversed 138 | }); 139 | } 140 | } 141 | } 142 | 143 | 144 | /*The trail is applying the exact coords of the player, but the screen may move, which must be applied to all trail coords!*/ 145 | AnimationTrail.prototype.applyStageOffset = function(stageDiffX,stageDiffY) 146 | { 147 | if(!!stageDiffX) 148 | { 149 | for(var trailIndex = 0, nbTrails = this.Trail.length; trailIndex < nbTrails; trailIndex++) 150 | { 151 | for(var frameIndex = 0, nbFrames = this.Trail[trailIndex].Animation.BaseAnimation.Frames.length; frameIndex < nbFrames; ++frameIndex) 152 | { 153 | var frame = this.Trail[trailIndex].Animation.BaseAnimation.Frames[frameIndex]; 154 | var coords = frame.UserData; 155 | for(var coordIndex = 0, nbCoords = coords.length; coordIndex < nbCoords; coordIndex++) 156 | { 157 | coords[coordIndex].DeltaX += stageDiffX; 158 | } 159 | } 160 | } 161 | } 162 | 163 | if(!!stageDiffY) 164 | { 165 | for(var trailIndex = 0, nbTrails = this.Trail.length; trailIndex < nbTrails; trailIndex++) 166 | { 167 | for(var frameIndex = 0, nbFrames = this.Trail[trailIndex].Animation.BaseAnimation.Frames.length; frameIndex < nbFrames; ++frameIndex) 168 | { 169 | var frame = this.Trail[trailIndex].Animation.BaseAnimation.Frames[frameIndex]; 170 | var coords = frame.UserData; 171 | for(var coordIndex = 0, nbCoords = coords.length; coordIndex < nbCoords; coordIndex++) 172 | { 173 | //coords[coordIndex].DeltaY += -stageDiffY; 174 | } 175 | } 176 | } 177 | } 178 | } 179 | 180 | /*returns the first coordinate at the requested frame index*/ 181 | AnimationTrail.prototype.getNextCoord = function(index) 182 | { 183 | /*get the current frame*/ 184 | var retVal = null; 185 | var frameToRender = this.getCurrentFrame(index); 186 | if(!!frameToRender) 187 | { 188 | var tmp = frameToRender.UserData.splice(0,1); 189 | retVal = tmp[0]; 190 | } 191 | return retVal; 192 | } 193 | 194 | AnimationTrail.prototype.render = function(frame,stageDiffX,stageDiffY) 195 | { 196 | if(this.Enabled) 197 | { 198 | /*The trail is applying the exact coords of the player, but the screen may move, which must be applied to all trail coords!*/ 199 | this.applyStageOffset(stageDiffX,stageDiffY); 200 | var stageOffsetY = game_.getMatch().getStage().OffsetY; 201 | 202 | for(var i = 0, length = this.Trail.length; i < length; i++) 203 | { 204 | if(frame > this.Trail[i].StartFrame) 205 | { 206 | var coords = this.getNextCoord(i); 207 | if(!!coords) 208 | { 209 | this.Trail[i].Element.style.left = (!!coords.Left) ? coords.DeltaX + parseInt(coords.Left) + "px" : ""; 210 | this.Trail[i].Element.style.right = (!!coords.Right) ? coords.DeltaX + parseInt(coords.Right) + "px" : ""; 211 | this.Trail[i].Element.style.bottom = (!!coords.Bottom) ? coords.DeltaY + stageOffsetY + parseInt(coords.Bottom) + "px" : ""; 212 | this.Trail[i].Element.style.top = (!!coords.Top) ? coords.DeltaY + parseInt(coords.Top) + "px" : ""; 213 | if(!!coords.Flip) 214 | AutoApplyFlip(this.Trail[i].Element, this.Direction == 1 ? coords.Flip : !coords.Flip); 215 | } 216 | } 217 | if(frame > this.Trail[i].StartFrame) 218 | { 219 | var currentItem = this.Trail[i]; 220 | 221 | if(!currentItem.Animation.hasUserData(currentItem.FrameIndex)) 222 | ++currentItem.FrameIndex; 223 | 224 | var frameToRender = this.getCurrentFrame(i); 225 | if(!!frameToRender) 226 | { 227 | spriteLookup_.set(currentItem.Element,frameToRender.RightSrc); 228 | } 229 | } 230 | } 231 | } 232 | } 233 | 234 | return new AnimationTrail(); 235 | } -------------------------------------------------------------------------------- /script/animation.js: -------------------------------------------------------------------------------- 1 | var BaseAnimation = function(frames,name,isAttack,allowAirBlock) 2 | { 3 | this.Frames = frames || []; 4 | this.FrameSpeed = 4; 5 | this.Name = name; 6 | this.IsAttack = isAttack == undefined ? true : isAttack; 7 | this.AllowAirBlock = allowAirBlock; 8 | this.lastFrameOffset = 0; 9 | this.NbFrames = 0; 10 | this.SetFramesToVulnerable = false; 11 | this.IsThrow = false; 12 | } 13 | 14 | BaseAnimation.prototype.release = function() 15 | { 16 | utils_.releaseArray(this.Frames); 17 | } 18 | 19 | BaseAnimation.prototype.setIsThrow = function(value) 20 | { 21 | this.IsThrow = value; 22 | } 23 | 24 | /*Adds a frame to the move*/ 25 | BaseAnimation.prototype.addFrameWithSound = function(player,volume,soundFilename,shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,chainProjectile,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor) 26 | { 27 | this.addFrame(player,shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,chainProjectile,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor); 28 | var currentFrame = this.Frames[this.Frames.length-1]; 29 | currentFrame.SoundFilename = soundFilename; 30 | currentFrame.SoundVolume = volume; 31 | //soundManager_.load(currentFrame.SoundFilename,3,volume); 32 | } 33 | 34 | /*Adds a frame to the move*/ 35 | BaseAnimation.prototype.addOffsetFrame = function(player,image,nbFrames,x,y) 36 | { 37 | this.addFrame(player,0,null,image,nbFrame,0,0,x,y); 38 | } 39 | 40 | /*Adds a frame to the move*/ 41 | BaseAnimation.prototype.addFrame = function(player,shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,chainProjectile,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor) 42 | { 43 | if(!!this.Frames.length > 0) 44 | this.lastFrameOffset += this.Frames[this.Frames.length - 1].Frames; 45 | var frameOffset = this.lastFrameOffset; 46 | //for(var i = 0; i < this.Frames.length; ++i) 47 | // frameOffset += this.Frames[i].Frames; 48 | 49 | 50 | if(shadowImage == "" && !!player) 51 | shadowImage = player.DefaultShadowImageSrc; 52 | ++player.NbFrames; 53 | this.Frames[this.Frames.length] = new Frame(this.Frames.length,player.getNextFrameID(),shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,frameOffset,chainProjectile,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor); 54 | this.NbFrames += this.Frames[this.Frames.length - 1].Frames; 55 | 56 | var currentFrame = this.Frames[this.Frames.length-1]; 57 | currentFrame.Vulernable = this.SetFramesToVulnerable; 58 | 59 | if(!!this.IsThrow) 60 | { 61 | currentFrame.FlagsToSet.Player = (currentFrame.FlagsToSet.Player || MISC_FLAGS.NONE) | PLAYER_FLAGS.INVULNERABLE; 62 | } 63 | //ensure that isAttack_ is set properly 64 | if(hasFlag(currentFrame.FlagsToSet.Combat,COMBAT_FLAGS.ATTACK)) 65 | { 66 | this.IsAttack = true; 67 | } 68 | 69 | if(hasFlag(currentFrame.FlagsToSet.Combat,COMBAT_FLAGS.PENDING_ATTACK)) 70 | { 71 | currentFrame.IsPendingAttack = true; 72 | } 73 | 74 | if(!!this.IsAttack) 75 | { 76 | if(hasFlag(currentFrame.FlagsToSend, ATTACK_FLAGS.LIGHT)) 77 | currentFrame.HitStop = 8; 78 | else if(hasFlag(currentFrame.FlagsToSend, ATTACK_FLAGS.MEDIUM)) 79 | currentFrame.HitStop = 9; 80 | else if(hasFlag(currentFrame.FlagsToSend, ATTACK_FLAGS.HARD)) 81 | currentFrame.HitStop = 10; 82 | 83 | //Moves that can be air blocked (jump attacks), can ALSO be blocked on the ground, but not in the crouch 84 | var flags = MISC_FLAGS.NONE; 85 | if(!!this.AllowAirBlock) 86 | flags = COMBAT_FLAGS.CAN_BE_AIR_BLOCKED; 87 | else 88 | flags = COMBAT_FLAGS.CAN_BE_BLOCKED; 89 | 90 | 91 | if(!this.SkipFrameBlockCheck) 92 | { 93 | currentFrame.FlagsToSet.Combat = (currentFrame.FlagsToSet.Combat || MISC_FLAGS.NONE) | flags; 94 | //Before StopBlock frame, add pending attack to any non attack frames 95 | if(!hasFlag(currentFrame.FlagsToSet.Combat,COMBAT_FLAGS.ATTACK)) 96 | { 97 | currentFrame.IsPendingAttack = true; 98 | } 99 | 100 | } 101 | else if(!!this.CanAddStopBlock) 102 | { 103 | this.CanAddStopBlock = null; 104 | currentFrame.FlagsToClear.Combat = (currentFrame.FlagsToClear.Combat || MISC_FLAGS.NONE) | flags; 105 | } 106 | } 107 | } 108 | 109 | /*Adds a frame multiple times, and adds the sound effect on the first frame only.*/ 110 | BaseAnimation.prototype.addRepeatingFrameWithSound = function(player,volume,soundFilename,shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor) 111 | { 112 | var imageID = 0; 113 | for(var i = 0; i < nbFrames; ++i) 114 | { 115 | if(i == 0) 116 | { 117 | this.addFrame(player,shadowOffset,shadowImage,image,1,flagsToSet,flagsToClear,x,y,priority,baseDamage,null,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor); 118 | var currentFrame = this.Frames[this.Frames.length-1]; 119 | currentFrame.SoundFilename = soundFilename; 120 | currentFrame.SoundVolume = volume; 121 | imageID = currentFrame.ImageID; 122 | //soundManager_.load(currentFrame.SoundFilename,3,volume); 123 | } 124 | else 125 | { 126 | this.addFrame(player,shadowOffset,shadowImage,image,1,flagsToSet,flagsToClear,x,y,priority,baseDamage,null,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,0,0); 127 | this.Frames[this.Frames.length-1].ImageID = imageID; 128 | } 129 | } 130 | 131 | } 132 | 133 | 134 | /*Adds a frame multiple times*/ 135 | BaseAnimation.prototype.addRepeatingFrame = function(player,shadowOffset,shadowImage,image,nbFrames,flagsToSet,flagsToClear,x,y,priority,baseDamage,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor) 136 | { 137 | for(var i = 0; i < nbFrames; ++i) 138 | { 139 | if(i == 0) 140 | this.addFrame(player,shadowOffset,shadowImage,image,1,flagsToSet,flagsToClear,x,y,priority,baseDamage,null,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,energyToAdd,slideForce,slideFactor); 141 | else 142 | this.addFrame(player,shadowOffset,shadowImage,image,1,flagsToSet,flagsToClear,x,y,priority,baseDamage,null,imageOffsetX,imageOffsetY,hitState,hitPoints,flagsToSend,hitID,hitStop,0,0); 143 | } 144 | } 145 | /*Returns the frame that should be run at a given time*/ 146 | BaseAnimation.prototype.getFrame = function(frameDelta) 147 | { 148 | var count = 0; 149 | for(var i = 0; i < this.Frames.length; ++i) 150 | if((count += this.Frames[i].Frames) >= frameDelta) 151 | return this.Frames[i]; 152 | return null; 153 | } 154 | /*Returns the frame index of a frame*/ 155 | BaseAnimation.prototype.getFrameIndex = function(id) 156 | { 157 | var count = 0; 158 | for(var i = 0; i < this.Frames.length; ++i) 159 | { 160 | if(this.Frames[i].ID == id) 161 | { 162 | return i; 163 | } 164 | } 165 | return -1; 166 | } 167 | /*Returns the first frame with an ID greater than the passed in ID*/ 168 | BaseAnimation.prototype.getNextFrameOffset = function(id) 169 | { 170 | var count = 0; 171 | for(var i = 0; i < this.Frames.length; ++i) 172 | { 173 | count += this.Frames[i].Frames; 174 | if(this.Frames[i].ID == id) 175 | return count; 176 | } 177 | return 0; 178 | } 179 | 180 | /************************************************************************/ 181 | /************************************************************************/ 182 | /************************************************************************/ 183 | 184 | 185 | var BasicBaseAnimation = function(frames,name) 186 | { 187 | this.Frames = frames || []; 188 | this.NbFrames = 0; 189 | this.Name = name; 190 | this.LastFrameOffset = 0; 191 | } 192 | 193 | /*Returns the frame that should be run at a given time*/ 194 | BasicBaseAnimation.prototype.getFrame = function(frameDelta) 195 | { 196 | var count = 0; 197 | for(var i = 0; i < this.Frames.length; ++i) 198 | if((count += this.Frames[i].Frames) >= frameDelta) 199 | return this.Frames[i]; 200 | return null; 201 | } 202 | /*Adds a frame to the move*/ 203 | BasicBaseAnimation.prototype.addEmptyFrame = function(owner,nbFrames) 204 | { 205 | this.addFrame(owner,"",nbFrames,0,0); 206 | } 207 | /*Adds a frame to the move*/ 208 | BasicBaseAnimation.prototype.addFrame = function(owner,image,nbFrames,x,y) 209 | { 210 | if(!!this.Frames.length > 0) 211 | this.LastFrameOffset += this.Frames[this.Frames.length - 1].Frames; 212 | 213 | var frameOffset = this.lastFrameOffset; 214 | 215 | ++owner.NbFrames; 216 | this.Frames[this.Frames.length] = new Frame(this.Frames.length,owner.getNextFrameID(),0,"",image,nbFrames,0,0,x || 0,y || 0,0,0,frameOffset); 217 | this.NbFrames += this.Frames[this.Frames.length - 1].Frames; 218 | } 219 | 220 | -------------------------------------------------------------------------------- /script/base64-binary.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Daniel Guerrero 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL DANIEL GUERRERO BE LIABLE FOR ANY 17 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | */ 24 | 25 | /** 26 | * Uses the new array typed in javascript to binary base64 encode/decode 27 | * at the moment just decodes a binary base64 encoded 28 | * into either an ArrayBuffer (decodeArrayBuffer) 29 | * or into an Uint8Array (decode) 30 | * 31 | * References: 32 | * https://developer.mozilla.org/en/JavaScript_typed_arrays/ArrayBuffer 33 | * https://developer.mozilla.org/en/JavaScript_typed_arrays/Uint8Array 34 | */ 35 | 36 | var Base64Binary = { 37 | _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 38 | 39 | /* will return a Uint8Array type */ 40 | decodeArrayBuffer: function(input) { 41 | var bytes = (input.length/4) * 3; 42 | var ab = new ArrayBuffer(bytes); 43 | this.decode(input, ab); 44 | 45 | return ab; 46 | }, 47 | 48 | decode: function(input, arrayBuffer) { 49 | //get last chars to see if are valid 50 | var lkey1 = this._keyStr.indexOf(input.charAt(input.length-1)); 51 | var lkey2 = this._keyStr.indexOf(input.charAt(input.length-2)); 52 | 53 | var bytes = (input.length/4) * 3; 54 | if (lkey1 == 64) bytes--; //padding chars, so skip 55 | if (lkey2 == 64) bytes--; //padding chars, so skip 56 | 57 | var uarray; 58 | var chr1, chr2, chr3; 59 | var enc1, enc2, enc3, enc4; 60 | var i = 0; 61 | var j = 0; 62 | 63 | if (arrayBuffer) 64 | uarray = new Uint8Array(arrayBuffer); 65 | else 66 | uarray = new Uint8Array(bytes); 67 | 68 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 69 | 70 | for (i=0; i> 4); 78 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 79 | chr3 = ((enc3 & 3) << 6) | enc4; 80 | 81 | uarray[i] = chr1; 82 | if (enc3 != 64) uarray[i+1] = chr2; 83 | if (enc4 != 64) uarray[i+2] = chr3; 84 | } 85 | 86 | return uarray; 87 | } 88 | } -------------------------------------------------------------------------------- /script/browserDetect.js: -------------------------------------------------------------------------------- 1 | var BrowserDetect = { 2 | init: function () { 3 | this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; 4 | this.version = this.searchVersion(navigator.userAgent) 5 | || this.searchVersion(navigator.appVersion) 6 | || "an unknown version"; 7 | this.OS = this.searchString(this.dataOS) || "an unknown OS"; 8 | }, 9 | searchString: function (data) { 10 | for (var i=0;i"; 29 | } 30 | var i = 0; 31 | while(i < this.DebugElement.children.length) 32 | { 33 | if(this.DebugElement.children[i].className == "bDebug") 34 | this.DebugElement.removeChild(this.DebugElement.children[i]); 35 | } 36 | this.DebugElement.innerHTML = html; 37 | } 38 | /*Returns the distance from the passed in circle*/ 39 | Circle.prototype.getDistanceSq = function(otherCircle) 40 | { 41 | var x = otherCircle.RenderX - this.RenderX; 42 | var y = otherCircle.RenderY - this.RenderY; 43 | return x*x + y*y; 44 | } 45 | /*Returns true if the passed in circle intersects this circle instance*/ 46 | Circle.prototype.intersects = function(otherCircle) 47 | { 48 | var dSq = this.getDistanceSq(otherCircle); 49 | return dSq < (this.R+otherCircle.R)*(this.R+otherCircle.R); 50 | } 51 | /*Moves this circle just outside the intersection with the passed in circle, if there is an intersection*/ 52 | Circle.prototype.rejectX = function(otherCircle) 53 | { 54 | var dist = Math.sqrt(this.getDistanceSq(otherCircle)); 55 | var radiiDist = this.R+otherCircle.R; 56 | var delta = 0; 57 | if(dist < (radiiDist) || dist == 0) 58 | { 59 | var dir = (this.RenderX - otherCircle.RenderX) / Math.abs(this.RenderX - otherCircle.RenderX); 60 | if(!dir) 61 | dir = -1; 62 | var val = true; 63 | do 64 | { 65 | this.LocalX += dir; 66 | this.RenderX += dir; 67 | }while(this.intersects(otherCircle) && ++delta < 10000); 68 | /*otherCircle.render()*/ 69 | /*this.render();*/ 70 | } 71 | return delta; 72 | } 73 | -------------------------------------------------------------------------------- /script/debug.js: -------------------------------------------------------------------------------- 1 | function GetDebugInstance(game) 2 | { 3 | /*private member*/ 4 | var game_ = game; 5 | 6 | var setupMatch = function(t1, t2, stage, state) 7 | { 8 | $$init(); 9 | game_.end(); 10 | 11 | t1 = t1 || []; 12 | t2 = t2 || []; 13 | 14 | var teamA = [0]; 15 | var teamB = [1]; 16 | 17 | for(var a = 0; a < t1.length; ++a) 18 | { 19 | t1[a].B = t1[a].B || false; 20 | t1[a].C = t1[a].C || false; 21 | } 22 | 23 | for(var a = 0; a < t2.length; ++a) 24 | { 25 | t2[a].B = t2[a].B || false; 26 | t2[a].C = t2[a].C || false; 27 | } 28 | 29 | 30 | for(var a = 0; a < t1.length; ++a) 31 | { 32 | for(var b = 0; b < t2.length; ++b) 33 | { 34 | if(t1[a].A === t2[b].A) 35 | { 36 | if(!!t1[a].B) 37 | t2[b].B = false; 38 | if(!!t2[b].B) 39 | t1[a].B = false; 40 | if(!t1[a].B && !t2[b].B) 41 | t2[b].B = true; 42 | } 43 | } 44 | } 45 | 46 | /*TEAM 1*/ 47 | if(!!t1[0]) 48 | user1_.resetChar(t1[0].A, t1[0].B, t1[0].C); 49 | else 50 | user1_.resetChar(CHARACTERS.KEN); 51 | 52 | if(!!t1[1]) 53 | { 54 | if(!!t1[1].D) 55 | { 56 | teamB.pop(); 57 | user2_.resetChar(t1[1].A, t1[1].B, t1[1].C); 58 | teamA.push(1); 59 | } 60 | else 61 | { 62 | user3_.resetChar(t1[1].A, t1[1].B, t1[1].C); 63 | teamA.push(2); 64 | } 65 | } 66 | if(!!t1[2]) 67 | { 68 | user4_.resetChar(t1[2].A, t1[2].B, t1[2].C); 69 | teamA.push(3); 70 | } 71 | if(!!t1[3]) 72 | { 73 | user5_.resetChar(t1[3].A, t1[3].B, t1[3].C); 74 | teamA.push(4); 75 | } 76 | 77 | /*TEAM 2*/ 78 | if(!!t1[1] && !!t1[1].D) 79 | { 80 | if(!!t2[0]) 81 | user3_.resetChar(t2[0].A, t2[0].B, t2[0].C); 82 | else 83 | user3_.resetChar(CHARACTERS.RYU); 84 | 85 | teamB.push(2); 86 | } 87 | else 88 | { 89 | if(!!t2[0]) 90 | user2_.resetChar(t2[0].A, t2[0].B, t2[0].C); 91 | else 92 | user2_.resetChar(CHARACTERS.RYU); 93 | } 94 | 95 | if(!!t2[1]) 96 | { 97 | user6_.resetChar(t2[1].A, t2[1].B, t2[1].C); 98 | teamB.push(5); 99 | } 100 | if(!!t2[2]) 101 | { 102 | user7_.resetChar(t2[2].A, t2[2].B, t2[2].C); 103 | teamB.push(6); 104 | } 105 | if(!!t2[3]) 106 | { 107 | user8_.resetChar(t2[3].A, t2[3].B, t2[3].C); 108 | teamB.push(7); 109 | } 110 | game_.startMatch(state === undefined ? MATCH_STATES.PRACTICE : 0, teamA, teamB, stages_[stage || "guy"]); 111 | } 112 | 113 | var Debug = function() 114 | { 115 | 116 | } 117 | 118 | 119 | Debug.prototype.maxOutEnergy = function() 120 | { 121 | game_.getMatch().getTeamA().getEnergybar().change(1000); 122 | game_.getMatch().getTeamB().getEnergybar().change(1000); 123 | } 124 | 125 | //test player battle 126 | Debug.prototype.practice = function (t1, t2, stage) 127 | { 128 | this.setPracticeMode(true); 129 | __noDamage = true; 130 | setupMatch(t1, t2, stage); 131 | } 132 | 133 | //test player battle 134 | Debug.prototype.startMatch = function (t1, t2, stage) 135 | { 136 | this.setPracticeMode(false); 137 | __noDamage = false; 138 | setupMatch(t1, t2, stage, 0); 139 | } 140 | 141 | 142 | Debug.prototype.p1 = function() 143 | { 144 | if(!!game_.getMatch()) 145 | return game_.getMatch().getTeamA().getPlayer(0); 146 | return null; 147 | } 148 | 149 | Debug.prototype.p2 = function() 150 | { 151 | if(!!game_.getMatch()) 152 | return game_.getMatch().getTeamB().getPlayer(0); 153 | return null; 154 | } 155 | 156 | Debug.prototype.t1 = function(index) 157 | { 158 | if(!!game_.getMatch()) 159 | return game_.getMatch().getTeamA().getPlayer(index || 0); 160 | return null; 161 | } 162 | 163 | Debug.prototype.t2 = function(index) 164 | { 165 | if(!!game_.getMatch()) 166 | return game_.getMatch().getTeamB().getPlayer(index || 0); 167 | return null; 168 | } 169 | 170 | Debug.prototype.p1Execute = function(input) 171 | { 172 | if(!!game_.getMatch()) 173 | { 174 | if(!this.p1().Ai.isRunning()) 175 | this.p1().enableAI(); 176 | return this.p1().Ai.getManaged().execute(input); 177 | } 178 | return null; 179 | } 180 | 181 | Debug.prototype.p2Execute = function(input) 182 | { 183 | if(!!game_.getMatch()) 184 | { 185 | if(!this.p2().Ai.isRunning()) 186 | this.p2().enableAI(); 187 | return this.p2().Ai.getManaged().execute(input); 188 | } 189 | return null; 190 | } 191 | 192 | Debug.prototype.p2TestAI = function() 193 | { 194 | if(!!game_.getMatch()) 195 | { 196 | this.p2().enableAI(); 197 | } 198 | return null; 199 | } 200 | 201 | Debug.prototype.p1ReverseFrame = function() 202 | { 203 | debug_.p1().reverseFrame(); 204 | game_.pause(); 205 | } 206 | 207 | Debug.prototype.p1StepFrame = function() 208 | { 209 | game_.pause(); 210 | } 211 | 212 | var spnIndex = window.document.getElementById("spnIndex"); 213 | var txtX = window.document.getElementById("txtX"); 214 | var txtY = window.document.getElementById("txtY"); 215 | var txtShadow = window.document.getElementById("txtShadow"); 216 | var txtShadowOffsetX = window.document.getElementById("txtShadowOffsetX"); 217 | var txtShadowOffsetY = window.document.getElementById("txtShadowOffsetY"); 218 | 219 | 220 | Debug.prototype.readFrameData = function(frame) 221 | { 222 | //.ImageOffsetX,this.CurrentFrame.ImageOffsetY,this.CurrentFrame.ShadowImageSrc 223 | 224 | spnIndex.innerHTML = frame.Index; 225 | txtX.value = +frame.ImageOffsetX; 226 | txtY.value = +frame.ImageOffsetY; 227 | txtShadow.value = frame.ShadowImageSrc.match(/[\d]+/)[0]; 228 | txtShadowOffsetX.value = +frame.ShadowOffset.X; 229 | txtShadowOffsetY.value = +frame.ShadowOffset.Y; 230 | } 231 | 232 | Debug.prototype.setFrameData = function() 233 | { 234 | var x = window.document.getElementById("txtX").value; 235 | var y = window.document.getElementById("txtY").value; 236 | var s = window.document.getElementById("txtShadow").value; 237 | var sx = window.document.getElementById("txtShadowOffsetX").value; 238 | var sy = window.document.getElementById("txtShadowOffsetY").value; 239 | 240 | if(!!+x || x === 0) 241 | debug_.p1().CurrentFrame.ImageOffsetX = +x; 242 | if(!!+y || y === 0) 243 | debug_.p1().CurrentFrame.ImageOffsetY = +y; 244 | if(!!s) 245 | debug_.p1().CurrentFrame.ShadowImageSrc = "images/misc/misc/shadow-" + s + ".png"; 246 | if(!!+sx || sx === 0) 247 | debug_.p1().CurrentFrame.ShadowOffset.X = +sx; 248 | if(!!+sy || sy === 0) 249 | debug_.p1().CurrentFrame.ShadowOffset.Y = +sy; 250 | } 251 | 252 | Debug.prototype.setPracticeMode = function(flag) 253 | { 254 | __noDamage = flag; 255 | } 256 | 257 | Debug.prototype.setFallingDamage = function(flag) 258 | { 259 | __noFallDamage = !flag; 260 | } 261 | 262 | Debug.prototype.setTeamMode = function(flag) 263 | { 264 | game_.setTeamMode(flag); 265 | } 266 | 267 | Debug.prototype.keyCount = 1000; 268 | 269 | Debug.prototype.injectPlayer = function(playerId,team,isAlternate) 270 | { 271 | if(!game_.getMatch() || !game_.getMatch().getTeamA() || !game_.getMatch().getTeamB()) 272 | { 273 | AlertError("You can only inject a player during a match."); 274 | return; 275 | } 276 | 277 | right = Debug.prototype.keyCount++; 278 | up = Debug.prototype.keyCount++; 279 | left = Debug.prototype.keyCount++; 280 | down = Debug.prototype.keyCount++; 281 | p1 = Debug.prototype.keyCount++; 282 | p2 = Debug.prototype.keyCount++; 283 | p3 = Debug.prototype.keyCount++; 284 | k1 = Debug.prototype.keyCount++; 285 | k2 = Debug.prototype.keyCount++; 286 | k3 = Debug.prototype.keyCount++; 287 | turn = Debug.prototype.keyCount++; 288 | var user = new User(right,up,left,down,p1,p2,p3,k1,k2,k3,turn); 289 | user.resetChar(playerId,isAlternate,true); 290 | if(!!user.getName()) 291 | { 292 | var name = user.getName(); 293 | var folder = user.getFolder(); 294 | stuffLoader_.queue("script/player-" + name + ".js",RESOURCE_TYPES.SCRIPT); 295 | stuffLoader_.queue("script/player-" + folder + "-spritedata.js",RESOURCE_TYPES.SCRIPT); 296 | 297 | var onDone = (function(user) 298 | { 299 | return function() 300 | { 301 | var player = user.getPlayer(); 302 | if(team == 1) 303 | game_.getMatch().getTeamA().addPlayer(player,true,true); 304 | else 305 | game_.getMatch().getTeamB().addPlayer(player,true,true); 306 | } 307 | })(user); 308 | stuffLoader_.start(null,onDone,null); 309 | } 310 | else 311 | { 312 | AlertError("user not found"); 313 | 314 | } 315 | 316 | 317 | } 318 | 319 | /*implemented as a singleton*/ 320 | var instance_ = instance_ || new Debug(); 321 | return instance_; 322 | } 323 | -------------------------------------------------------------------------------- /script/energy-bar.js: -------------------------------------------------------------------------------- 1 | /*logic for the energy bar*/ 2 | 3 | var CreateEnergyBar = function(pnlID,team) 4 | { 5 | var amount_ = 0; 6 | var team_ = team; 7 | var parentElement_ = window.document.getElementById(pnlID); 8 | var barElement_ = null; 9 | var level0Element_ = null; 10 | var level1Element_ = null; 11 | var level2Element_ = null; 12 | 13 | var key_ = ENERGYBAR.LEVEL0_KEY; 14 | var startFrame_ = 0; 15 | var animations_ = {}; 16 | var frameCount_ = 0; 17 | var currentSrc_ = ""; 18 | var lastSrc_ = ""; 19 | var isInitialized_ = false; 20 | 21 | var EnergyBar = function(pnlID,team) 22 | { 23 | } 24 | 25 | EnergyBar.prototype.getAmount = function() { return amount_; } 26 | EnergyBar.prototype.setAmount = function(value) { amount_ = value; } 27 | EnergyBar.prototype.getTeam = function() { return team_; } 28 | EnergyBar.prototype.setTeam = function(value) { team_ = value; } 29 | EnergyBar.prototype.getParentElement = function() { return parentElement_; } 30 | EnergyBar.prototype.setParentElement = function(value) { parentElement_ = value; } 31 | EnergyBar.prototype.getBarElement = function() { return barElement_; } 32 | EnergyBar.prototype.setBarElement = function(value) { barElement_ = value; } 33 | EnergyBar.prototype.getLevel0Element = function() { return level0Element_; } 34 | EnergyBar.prototype.setLevel0Element = function(value) { level0Element_ = value; } 35 | EnergyBar.prototype.getLevel1Element = function() { return level1Element_; } 36 | EnergyBar.prototype.setLevel1Element = function(value) { level1Element_ = value; } 37 | EnergyBar.prototype.getLevel2Element = function() { return level2Element_; } 38 | EnergyBar.prototype.setLevel2Element = function(value) { level2Element_ = value; } 39 | EnergyBar.prototype.getKey = function() { return key_; } 40 | EnergyBar.prototype.setKey = function(value) { key_ = value; } 41 | EnergyBar.prototype.getStartFrame = function() { return startFrame_; } 42 | EnergyBar.prototype.setStartFrame = function(value) { startFrame_ = value; } 43 | EnergyBar.prototype.getAnimation = function(value) { return animations_[value]; } 44 | EnergyBar.prototype.setAnimation = function(index, value) { animations_[index] = value; } 45 | EnergyBar.prototype.getAnimations = function() { return animations_; } 46 | EnergyBar.prototype.setAnimations = function(value) { animations_ = value; } 47 | EnergyBar.prototype.getFrameCount = function() { return frameCount_; } 48 | EnergyBar.prototype.setFrameCount = function(value) { frameCount_ = value; } 49 | EnergyBar.prototype.getCurrentSrc = function() { return currentSrc_; } 50 | EnergyBar.prototype.setCurrentSrc = function(value) { currentSrc_ = value; } 51 | EnergyBar.prototype.getLastSrc = function() { return lastSrc_; } 52 | EnergyBar.prototype.setLastSrc = function(value) { lastSrc_ = value; } 53 | EnergyBar.prototype.isInitialized = function() { return isInitialized_; } 54 | EnergyBar.prototype.setInitialized = function(value) { isInitialized_ = value; } 55 | 56 | EnergyBar.prototype.getNextFrameID = function() 57 | { 58 | this.setFrameCount(this.getFrameCount() + 1); 59 | return this.getFrameCount(); 60 | } 61 | EnergyBar.prototype.addAnimation = function(key) 62 | { 63 | /*use default values for the Animation*/ 64 | this.setAnimation(key, new Animation()); 65 | return this.getAnimation(key); 66 | } 67 | 68 | /**/ 69 | EnergyBar.prototype.release = function() 70 | { 71 | utils_.removeChildrenFromDOM(parentElement_, true); 72 | } 73 | 74 | /*initialized the energy bar*/ 75 | EnergyBar.prototype.init = function() 76 | { 77 | /***************************/ 78 | /*initialize the animations*/ 79 | /***************************/ 80 | if(!this.isInitialized()) 81 | { 82 | var nbFrames = 8; 83 | 84 | var level0 = this.addAnimation(ENERGYBAR.LEVEL0_KEY); 85 | level0.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-team-" + team_ + ".png",nbFrames) 86 | 87 | var level0Maxed = this.addAnimation(ENERGYBAR.LEVEL0MAXED_KEY); 88 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-1.png",nbFrames) 89 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-2.png",nbFrames) 90 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-3.png",nbFrames) 91 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-4.png",nbFrames) 92 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-3.png",nbFrames) 93 | level0Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl0-full-team-" + team_ + "-2.png",nbFrames) 94 | 95 | var level1Maxed = this.addAnimation(ENERGYBAR.LEVEL1MAXED_KEY); 96 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-1.png",nbFrames) 97 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-2.png",nbFrames) 98 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-3.png",nbFrames) 99 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-4.png",nbFrames) 100 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-3.png",nbFrames) 101 | level1Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl1-full-team-" + team_ + "-2.png",nbFrames) 102 | 103 | var level2Maxed = this.addAnimation(ENERGYBAR.LEVEL2MAXED_KEY); 104 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-1.png",nbFrames) 105 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-2.png",nbFrames) 106 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-3.png",nbFrames) 107 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-4.png",nbFrames) 108 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-3.png",nbFrames) 109 | level2Maxed.addFrame(this,0,null,"|images/misc/misc/energy-bar-lvl2-full-team-" + team_ + "-2.png",nbFrames) 110 | this.setInitialized(true); 111 | } 112 | /******************************/ 113 | /*initialize the html elements*/ 114 | /******************************/ 115 | barElement_ = window.document.createElement("div"); 116 | barElement_.className = "inner-energy-bar"; 117 | 118 | level0Element_ = window.document.createElement("div"); 119 | level0Element_.className = "level-0-energy"; 120 | level0Element_.style.width = "0px"; 121 | 122 | level1Element_ = window.document.createElement("div"); 123 | level1Element_.style.width = "0px"; 124 | level1Element_.className = "level-1-energy"; 125 | 126 | level2Element_ = window.document.createElement("div"); 127 | level2Element_.style.width = "0px"; 128 | level2Element_.className = "level-2-energy"; 129 | 130 | parentElement_.appendChild(barElement_); 131 | parentElement_.appendChild(level0Element_); 132 | parentElement_.appendChild(level1Element_); 133 | parentElement_.appendChild(level2Element_); 134 | /*set the initial values*/ 135 | 136 | /* 137 | imageLookup_.getBgB64(barElement_,"images/misc/bars-sprites.png"); 138 | imageLookup_.getBgB64(level0Element_,"images/misc/energy-bar-lvl0.png"); 139 | imageLookup_.getBgB64(level1Element_,"images/misc/energy-bar-lvl1.png"); 140 | imageLookup_.getBgB64(level2Element_,"images/misc/energy-bar-lvl2.png"); 141 | */ 142 | this.change(0); 143 | } 144 | /*Resets the energy*/ 145 | EnergyBar.prototype.reset = function() 146 | { 147 | this.setAmount(-amount_); 148 | this.change(0); 149 | } 150 | /**/ 151 | EnergyBar.prototype.setCurrentAnimation = function(key,frame) 152 | { 153 | this.setKey(key) 154 | this.setStartFrame(frame); 155 | } 156 | /*adds to the energy bar*/ 157 | EnergyBar.prototype.change = function(amount,frame) 158 | { 159 | amount = amount || 0; 160 | if((amount_ < ENERGYBAR.MAX_LEVEL2) && (amount_ + amount >= ENERGYBAR.MAX_LEVEL2)) 161 | soundManager_.queueSound("audio/misc/lvl3.zzz"); 162 | 163 | this.setAmount(Math.min(Math.max(amount_ + amount, 0),ENERGYBAR.MAX_LEVEL2)); 164 | this.handleAmountChanged(frame || 0); 165 | } 166 | /*css helper*/ 167 | EnergyBar.prototype.showLevelHelper = function(element,cssDisplay) 168 | { 169 | if(element.style.display != cssDisplay) 170 | element.style.display = cssDisplay; 171 | } 172 | /**/ 173 | EnergyBar.prototype.showEnergyLevelBar = function(level) 174 | { 175 | switch(level) 176 | { 177 | case ENERGYBAR.LEVEL0: { this.showLevelHelper(level0Element_,""); this.showLevelHelper(level1Element_,"none"); this.showLevelHelper(level2Element_,"none"); break;} 178 | case ENERGYBAR.LEVEL1: { this.showLevelHelper(level0Element_,"none"); this.showLevelHelper(level1Element_,""); this.showLevelHelper(level2Element_,"none"); break;} 179 | case ENERGYBAR.LEVEL2: { this.showLevelHelper(level0Element_,"none"); this.showLevelHelper(level1Element_,"none"); this.showLevelHelper(level2Element_,""); break;} 180 | default: { this.showLevelHelper(level0Element_,"none"); this.showLevelHelper(level1Element_,"none"); this.showLevelHelper(level2Element_,"none"); break;} 181 | } 182 | } 183 | 184 | /**/ 185 | EnergyBar.prototype.handleAmountChanged = function(frame) 186 | { 187 | this.showEnergyLevelBar(); 188 | if(amount_ < ENERGYBAR.MAX_LEVEL0) 189 | { 190 | this.showEnergyLevelBar(ENERGYBAR.LEVEL0); 191 | level0Element_.style.width = amount_ + "px"; 192 | this.setCurrentAnimation(ENERGYBAR.LEVEL0_KEY,frame); 193 | } 194 | else if(amount_ < ENERGYBAR.MAX_LEVEL1) 195 | { 196 | this.showEnergyLevelBar(ENERGYBAR.LEVEL1); 197 | level1Element_.style.width = (amount_ - ENERGYBAR.MAX_LEVEL0) + "px"; 198 | this.setCurrentAnimation(ENERGYBAR.LEVEL0MAXED_KEY,frame); 199 | } 200 | else if(amount_ < ENERGYBAR.MAX_LEVEL2) 201 | { 202 | this.showEnergyLevelBar(ENERGYBAR.LEVEL2); 203 | level2Element_.style.width = (amount_ - ENERGYBAR.MAX_LEVEL1) + "px"; 204 | this.setCurrentAnimation(ENERGYBAR.LEVEL1MAXED_KEY,frame); 205 | } 206 | else if(amount_ == ENERGYBAR.MAX_LEVEL2) 207 | { 208 | this.showEnergyLevelBar(ENERGYBAR.LEVELMAXED); 209 | level2Element_.style.width = "0px"; 210 | this.setCurrentAnimation(ENERGYBAR.LEVEL2MAXED_KEY,frame); 211 | } 212 | } 213 | /**/ 214 | EnergyBar.prototype.frameMove = function(frame) 215 | { 216 | var delta = frame - this.getStartFrame(); 217 | var animation = this.getAnimation(this.getKey()); 218 | if(!animation) 219 | return; 220 | 221 | var currentFrame = this.getAnimation(this.getKey()).getFrame(delta); 222 | /*these animations are continuous, so if we go past the end, reset*/ 223 | if(!currentFrame) 224 | { 225 | this.setStartFrame(frame); 226 | delta = frame - this.getStartFrame(); 227 | currentFrame = this.getAnimation(this.getKey()).getFrame(delta); 228 | } 229 | if(!!currentFrame) 230 | { 231 | if(!!currentFrame.LeftSrc) 232 | { 233 | this.setCurrentSrc(currentFrame.LeftSrc); 234 | } 235 | } 236 | } 237 | /**/ 238 | EnergyBar.prototype.render = function(frame) 239 | { 240 | if(this.getLastSrc() != this.getCurrentSrc()) 241 | { 242 | var data = spriteLookup_.get(this.getCurrentSrc()); 243 | if(!!data) 244 | { 245 | barElement_.style.backgroundPosition = data.Left + " " + data.Bottom; 246 | barElement_.style.height = data.Height; 247 | barElement_.style.width = data.Width; 248 | } 249 | } 250 | } 251 | return new EnergyBar(pnlID,team); 252 | } -------------------------------------------------------------------------------- /script/faceoff.js: -------------------------------------------------------------------------------- 1 |  /**********************************************************************************/ 2 | /*This prototype together with the Match prototype handles the announcing of round*/ 3 | /**********************************************************************************/ 4 | var CreateFaceoff = function(match) 5 | { 6 | var match_ = match; 7 | var showedFaceoff_ = false; 8 | var announcedNewRound_ = false; 9 | var startedRound_ = false; 10 | var areNamesHidden_ = true; 11 | var faceoffSound_ = "audio/misc/faceoff.zzz"; 12 | 13 | var Faceoff = function() 14 | { 15 | this.FaceoffElement = null; 16 | this.TeamAFaceoffElement = null; 17 | this.TeamBFaceoffElement = null; 18 | this.TeamANameElement = null; 19 | this.TeamBNameElement = null; 20 | this.VsElement = null; 21 | 22 | this.MaxAngle = 360; 23 | this.MaxScale = 1; 24 | 25 | this.Angle = 0; 26 | this.Scale = 0; 27 | 28 | var nbFrames = 20; 29 | 30 | this.rotateUpFn = (function(max,inc) { return function(t,value) { return Math.min(value + (max/nbFrames), max); } })(this.MaxAngle); 31 | this.rotateDownFn = (function(max,inc) { return function(t,value) { return Math.max(value + (max/nbFrames), 0); } })(this.MaxAngle); 32 | this.scaleUpFn = (function(max,inc) { return function(t,value) { return Math.min(value + (max/nbFrames), max); } })(this.MaxScale); 33 | this.scaleDownFn = (function(max,inc) { return function(t,value) { return Math.max(value - (max/nbFrames), 0); } })(this.MaxScale); 34 | } 35 | 36 | Faceoff.prototype.setTeamA = function(name) 37 | { 38 | spriteLookup_.set(this.TeamAFaceoffElement,"images/misc/misc/p2-select-" + name + ".png"); 39 | spriteLookup_.set(this.TeamANameElement,"images/misc/font3/name-" + name + ".png",false,true); 40 | } 41 | Faceoff.prototype.setTeamB = function(name) 42 | { 43 | spriteLookup_.set(this.TeamBFaceoffElement,"images/misc/misc/p2-select-" + name + ".png"); 44 | spriteLookup_.set(this.TeamBNameElement,"images/misc/font3/name-" + name + ".png",false,true); 45 | } 46 | 47 | Faceoff.prototype.init = function() 48 | { 49 | this.FaceoffElement = window.document.createElement("div"); 50 | this.FaceoffElement.style.display = "none"; 51 | this.FaceoffElement.className = "faceoff"; 52 | 53 | this.TeamAFaceoffElement = window.document.createElement("div"); 54 | this.TeamAFaceoffElement.className = "team1-faceoff"; 55 | 56 | this.TeamBFaceoffElement = window.document.createElement("div"); 57 | this.TeamBFaceoffElement.className = "team2-faceoff"; 58 | 59 | this.FaceoffElement.appendChild(this.TeamAFaceoffElement); 60 | this.FaceoffElement.appendChild(this.TeamBFaceoffElement); 61 | 62 | this.TeamANameElement = window.document.createElement("div"); 63 | this.TeamANameElement.className = "faceoff-name flipped"; 64 | this.TeamAFaceoffElement.appendChild(this.TeamANameElement); 65 | 66 | this.TeamBNameElement = window.document.createElement("div"); 67 | this.TeamBNameElement.className = "faceoff-name"; 68 | this.TeamBFaceoffElement.appendChild(this.TeamBNameElement); 69 | 70 | this.VsElement = window.document.createElement("div"); 71 | this.VsElement.className = "vs"; 72 | spriteLookup_.set(this.VsElement,"images/misc/misc/vs-0.png"); 73 | this.FaceoffElement.appendChild(this.VsElement); 74 | 75 | this.reset(); 76 | 77 | /* 78 | imageLookup_.getBgB64(this.TeamAFaceoffElement,"images/misc/head-sprites.png"); 79 | imageLookup_.getBgB64(this.TeamBFaceoffElement,"images/misc/head-sprites.png"); 80 | imageLookup_.getBgB64(this.TeamANameElement,"images/misc/name-sprites.png"); 81 | imageLookup_.getBgB64(this.TeamBNameElement,"images/misc/name-sprites.png"); 82 | imageLookup_.getBgB64(this.VsElement,"images/misc/head-sprites.png"); 83 | */ 84 | 85 | window.document.getElementById("pnlStage").appendChild(this.FaceoffElement); 86 | } 87 | 88 | Faceoff.prototype.isActive = function() 89 | { 90 | return !startedRound_; 91 | } 92 | 93 | Faceoff.prototype.reset = function() 94 | { 95 | showedFaceoff_ = !!__debugMode; 96 | announcedNewRound_ = !!__debugMode; 97 | startedRound_ = false; 98 | this.Scale = 0; 99 | this.Angle = 0; 100 | 101 | this.rotateScale(); 102 | 103 | this.TeamANameElement.style.display = "none"; 104 | this.TeamBNameElement.style.display = "none"; 105 | this.VsElement.style.display = "none"; 106 | areNamesHidden_ = true; 107 | } 108 | 109 | Faceoff.prototype.pause = function() 110 | { 111 | soundManager_.pause(faceoffSound_); 112 | } 113 | 114 | Faceoff.prototype.resume = function() 115 | { 116 | if(!startedRound_) 117 | soundManager_.resume(faceoffSound_); 118 | } 119 | 120 | Faceoff.prototype.release = function() 121 | { 122 | utils_.removeFromDOM(this.FaceoffElement); 123 | } 124 | 125 | Faceoff.prototype.show = function(frame) 126 | { 127 | showedFaceoff_ = true; 128 | soundManager_.queueSound(faceoffSound_); 129 | this.FaceoffElement.style.display = ""; 130 | } 131 | 132 | 133 | Faceoff.prototype.hide = function(frame) 134 | { 135 | this.FaceoffElement.style.display = "none"; 136 | } 137 | 138 | Faceoff.prototype.startNewRound = function(frame) 139 | { 140 | announcedNewRound_ = true; 141 | match_.startNewRound(frame); 142 | } 143 | 144 | Faceoff.prototype.endNewRound = function(frame) 145 | { 146 | startedRound_ = true; 147 | match_.endNewRound(frame); 148 | } 149 | 150 | Faceoff.prototype.handleRound1 = function(frame) 151 | { 152 | if(!showedFaceoff_ && (frame > CONSTANTS.SHOW_FACEOFF_DELAY)) 153 | this.show(frame); 154 | if(!announcedNewRound_ && (frame > CONSTANTS.ANNOUNCE_FIRST_ROUND_DELAY)) 155 | this.startNewRound(frame); 156 | if(!startedRound_ && (frame > CONSTANTS.START_FIRST_ROUND_DELAY)) 157 | this.endNewRound(frame); 158 | } 159 | 160 | Faceoff.prototype.handleOtherRounds = function(frame) 161 | { 162 | if(!announcedNewRound_ && (frame > CONSTANTS.ANNOUNCE_NEW_ROUND_DELAY)) 163 | this.startNewRound(frame); 164 | if(!startedRound_ && (frame > CONSTANTS.START_NEW_ROUND_DELAY)) 165 | this.endNewRound(frame); 166 | } 167 | 168 | Faceoff.prototype.frameMove = function(frame) 169 | { 170 | if((frame > CONSTANTS.SHOW_FACEOFF_PICS_DELAY) && (frame < CONSTANTS.REMOVE_FACEOFF_PICS_DELAY)) 171 | { 172 | if(this.Scale < this.MaxScale) 173 | { 174 | this.Scale = this.scaleUpFn(frame, this.Scale); 175 | this.Angle = this.rotateUpFn(frame, this.Angle); 176 | this.rotateScale(); 177 | } 178 | else if(!!areNamesHidden_) 179 | { 180 | this.TeamANameElement.style.display = ""; 181 | this.TeamBNameElement.style.display = ""; 182 | this.VsElement.style.display = ""; 183 | areNamesHidden_ = false; 184 | } 185 | } 186 | else if(frame > CONSTANTS.REMOVE_FACEOFF_PICS_DELAY) 187 | { 188 | if(!areNamesHidden_) 189 | { 190 | this.TeamANameElement.style.display = "none"; 191 | this.TeamBNameElement.style.display = "none"; 192 | this.VsElement.style.display = "none"; 193 | areNamesHidden_ = true; 194 | } 195 | if(this.Scale > 0) 196 | { 197 | this.Scale = this.scaleDownFn(frame, this.Scale); 198 | this.Angle = this.rotateDownFn(frame, this.Angle); 199 | this.rotateScale(); 200 | } 201 | } 202 | } 203 | 204 | Faceoff.prototype.rotateScale = function() 205 | { 206 | this.TeamAFaceoffElement.style["-webkit-transform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 207 | this.TeamAFaceoffElement.style["-moz-transform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 208 | this.TeamAFaceoffElement.style["MozTransform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 209 | this.TeamAFaceoffElement.style["-o-transform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotate(" + this.Angle + "deg)"; 210 | this.TeamAFaceoffElement.style["OTransform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotate(" + this.Angle + "deg)"; 211 | this.TeamAFaceoffElement.style["-ms-transform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 212 | 213 | this.TeamBFaceoffElement.style["-webkit-transform"] = "scale(" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 214 | this.TeamBFaceoffElement.style["-moz-transform"] = "scale(" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 215 | this.TeamBFaceoffElement.style["MozTransform"] = "scale(" + this.Scale + "," + this.Scale + ") rotate(" + this.Angle + "deg)"; 216 | this.TeamBFaceoffElement.style["OTransform"] = "scale(" + this.Scale + "," + this.Scale + ") rotate(" + this.Angle + "deg)"; 217 | this.TeamBFaceoffElement.style["-ms-transform"] = "scale(-" + this.Scale + "," + this.Scale + ") rotateZ(" + this.Angle + "deg)"; 218 | } 219 | 220 | Faceoff.prototype.render = function(frame) 221 | { 222 | } 223 | 224 | return new Faceoff(); 225 | } -------------------------------------------------------------------------------- /script/flags.js: -------------------------------------------------------------------------------- 1 | var hasFlag = function(flags,flag) 2 | { 3 | return !!(flags & flag); 4 | } 5 | 6 | var Flags = function(owner, defaultValue) 7 | { 8 | this.IsPlayer = false; 9 | this.Owner = owner || null; 10 | this.DefaultValue = defaultValue || 0; 11 | this.Value = 0; 12 | } 13 | 14 | Flags.prototype.remove = function(value, defaultIfZero) { return this.Value = (this.Value | value) ^ value; } 15 | Flags.prototype.release = function() { this.Owner = null; } 16 | Flags.prototype.clear = function() { this.set(0); } 17 | Flags.prototype.set = function(value) { this.Value = value; return this.Value; } 18 | Flags.prototype.get = function() { return this.Value; } 19 | Flags.prototype.has = function(value) { return hasFlag(this.Value,value); } 20 | Flags.prototype.add = function(value) 21 | { 22 | if(this.IsPlayer && !!this.Owner) 23 | { 24 | //If player is going from immobile to mobile, then stop the combo count on the player. 25 | if(hasFlag(value,PLAYER_FLAGS.MOBILE) && !this.has(PLAYER_FLAGS.MOBILE)) 26 | this.Owner.resetCombo(); 27 | } 28 | return this.Value |= (value || MISC_FLAGS.NONE); 29 | } 30 | 31 | var PlayerFlags = function(owner) 32 | { 33 | this.Owner = owner; 34 | this.Player = new Flags(owner); 35 | this.Player.IsPlayer = true; 36 | this.Pose = new Flags(); 37 | this.Combat = new Flags(); 38 | this.Combo = new Flags(); 39 | this.Spawn = new Flags(); 40 | this.Juggle = new Flags(); 41 | this.SwingSound = new Flags(); 42 | this.HitSound = new Flags(); 43 | this.BlockSound = new Flags(); 44 | this.MotionSound = new Flags(); 45 | this.HitReact = new Flags(); 46 | } 47 | 48 | PlayerFlags.prototype.clear = function() 49 | { 50 | for(var i in this) 51 | if(!!this[i] && !!this[i].clear) 52 | this[i].clear(); 53 | } 54 | PlayerFlags.prototype.release = function() 55 | { 56 | this.Owner = null; 57 | for(var i in this) 58 | if(!!this[i] && !!this[i].release) 59 | this[i].release(); 60 | } 61 | 62 | var FrameFlags = function() 63 | { 64 | this.Player = 0; 65 | this.Pose = 0; 66 | this.Combat = 0; 67 | this.RCombat = 0; 68 | this.Spawn = 0; 69 | this.Combo = 0; 70 | this.Juggle = 0; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /script/fontsystem.js: -------------------------------------------------------------------------------- 1 | var ManagedText = function(elementID,text,x,y,fontSpacing,fontsPath,charWidth,isLeft) 2 | { 3 | this.Text = text || ""; 4 | this.CharWidth = charWidth || 16; 5 | this.Element = window.document.getElementById(elementID); 6 | this.FontsPath = fontsPath || "font1"; 7 | this.FontSpacing = fontSpacing || 0; 8 | this.X = x || 0; 9 | this.Y = y || 0; 10 | 11 | this.dX = 0; 12 | this.dY = 0; 13 | this.TargetX = 0; 14 | this.TargetY = 0; 15 | 16 | this.AnimateCurrent = null; 17 | this.AnimateFunction = null; 18 | this.AnimateEndValue = null; 19 | this.HideFrame = -1; 20 | 21 | this.Width = 0; 22 | this.IsLeft = (isLeft != undefined) ? !!isLeft : true; 23 | this.UpdateRate = 1; 24 | this.init(); 25 | this.Indent = 0; 26 | this.IsVisible = true; 27 | this.change(this.Text); 28 | } 29 | 30 | /*this text element will move toward the passed in X and Y coords*/ 31 | ManagedText.prototype.setTarget = function(x,y) 32 | { 33 | x = Math.ceil(+x); 34 | y = Math.ceil(+y); 35 | 36 | this.TargetX = x; 37 | this.TargetY = y; 38 | 39 | var dx = this.TargetX - this.X; 40 | var dy = this.TargetY - this.Y; 41 | 42 | var dirX = CONSTANTS.TEXT_FADE_SPEED * ((dx)/Math.abs(dx)) || 0; 43 | var dirY = CONSTANTS.TEXT_FADE_SPEED * ((dy)/Math.abs(dy)) || 0; 44 | 45 | this.dX = dirX; 46 | this.dY = dirY; 47 | } 48 | 49 | /*applies the step function to the startValue until end function is true*/ 50 | ManagedText.prototype.animate = function(startValue,endFn,stepFn) 51 | { 52 | this.AnimateCurrent = startValue; 53 | this.AnimateFunction = stepFn; 54 | this.AnimateEndValue = endFn; 55 | 56 | this.change(this.AnimateCurrent); 57 | } 58 | 59 | ManagedText.prototype.animateIncNumber = function(startValue,endValue){this.animate(startValue,function(value){return value < endValue;},function(value){return ++value;});} 60 | ManagedText.prototype.animateDecNumber = function(startValue,endValue){this.animate(startValue,function(value){return value > endValue;},function(value){return --value;});} 61 | 62 | /*initialize the Text*/ 63 | ManagedText.prototype.init = function() 64 | { 65 | this.HideFrame = -1; 66 | } 67 | 68 | /*helper to get the source*/ 69 | ManagedText.prototype.getSrc = function(letter) 70 | { 71 | var value = letter.charCodeAt(0); 72 | switch(this.FontsPath) 73 | { 74 | case "font1": return font1_[value]; 75 | case "font2": return font2_[value]; 76 | case "font3": return font3_[value]; 77 | } 78 | } 79 | 80 | /*Changes the managed text*/ 81 | ManagedText.prototype.change = function(newText,x,hideFrame,showFrame,fadeIn,indent) 82 | { 83 | x = (x == undefined) ? this.X : x; 84 | this.clearTarget(); 85 | this.hideNow(); 86 | this.Text = "" + newText; 87 | this.MustUpdate = true; 88 | this.Indent = indent || 0; 89 | this.ShowFrame = showFrame || 0; 90 | 91 | while(this.Element.children.length > this.Text.length) 92 | this.Element.removeChild(this.Element.children[0]); 93 | while(this.Element.children.length < this.Text.length) 94 | this.Element.appendChild(window.document.createElement("img")); 95 | 96 | this.Width = 0; 97 | for(var i = 0,length = this.Text.length; i < length;++i) 98 | { 99 | this.Width += (!!+this.Text.charAt(i) ? 2*this.CharWidth : this.CharWidth) + this.FontSpacing; 100 | this.Element.children[i].style.marginRight = this.FontSpacing + "px"; 101 | this.Element.children[i].src = this.getSrc(this.Text.charAt(i)); 102 | } 103 | 104 | if(!!hideFrame) 105 | { 106 | if(!fadeIn) 107 | { 108 | this.showNow(x,hideFrame); 109 | } 110 | else 111 | { 112 | this.hideFadeNow(); 113 | this.show(hideFrame); 114 | } 115 | } 116 | else 117 | { 118 | this.showNow(x,hideFrame); 119 | } 120 | } 121 | 122 | /*increments the X*/ 123 | ManagedText.prototype.moveX = function(dx) 124 | { 125 | this.X += dx; 126 | this.MustUpdate = true; 127 | } 128 | 129 | /*increments the Y*/ 130 | ManagedText.prototype.moveY = function(dy) 131 | { 132 | this.Y += dy; 133 | this.MustUpdate = true; 134 | } 135 | ManagedText.prototype.setVisible = function(value) 136 | { 137 | value = (value === undefined) ? false : !!value; 138 | if(this.IsVisible != value) 139 | { 140 | this.IsVisible = value; 141 | this.Element.style.display = !!value ? "" : "none"; 142 | } 143 | } 144 | ManagedText.prototype.hideNow = function() { this.setVisible(false);} 145 | ManagedText.prototype.hide = function() { this.setTarget(-this.Width,this.Y); } 146 | ManagedText.prototype.hideFadeNow = function() 147 | { 148 | this.X = -this.Width; 149 | } 150 | 151 | ManagedText.prototype.clearTarget = function() { this.dX = 0;this.dY = 0;this.HideFrame = -1; } 152 | ManagedText.prototype.showNow = function(x,hideFrame) { this.X = (x != 0 ? x : null) || 0; this.MustUpdate = true; if(!!hideFrame) {this.HideFrame = hideFrame;}} 153 | ManagedText.prototype.show = function(hideFrame) { this.setTarget(this.Indent,this.Y); if(!!hideFrame) {this.HideFrame = hideFrame;}} 154 | 155 | /*toggles between using the left and right css properties for horizontal positioning*/ 156 | ManagedText.prototype.changeDirection = function() 157 | { 158 | this.IsLeft = !this.IsLeft; 159 | this.MustUpdate = true; 160 | } 161 | 162 | ManagedText.prototype.frameMove = function(frame) 163 | { 164 | if(!!this.IsVisible && this.HideFrame != -1 && (frame >= this.HideFrame)) 165 | this.hideNow(); 166 | /* 167 | if(frame % this.UpdateRate == 0) 168 | { 169 | if(!!this.AnimateFunction) 170 | { 171 | if(!this.animateEndValue(this.AnimateCurrent)) 172 | { 173 | this.AnimateFunction = null; 174 | } 175 | else 176 | { 177 | this.AnimateCurrent = this.animateFunction(this.AnimateCurrent); 178 | this.change(this.AnimateCurrent); 179 | } 180 | } 181 | } 182 | */ 183 | if(frame > this.ShowFrame) 184 | { 185 | if(!!this.dX) 186 | { 187 | this.moveX(this.dX); 188 | if(this.X >= this.TargetX) 189 | this.dX = 0; 190 | } 191 | if(!!this.dY) 192 | { 193 | this.moveY(this.dY); 194 | if(this.Y >= this.TargetY) 195 | this.dY = 0; 196 | } 197 | } 198 | } 199 | 200 | 201 | ManagedText.prototype.render = function(frame) 202 | { 203 | if(!!this.MustUpdate && frame > this.ShowFrame) 204 | { 205 | this.MustUpdate = false; 206 | if(this.IsLeft) 207 | { 208 | this.Element.style.right = ""; 209 | this.Element.style.left = this.X + "px"; 210 | this.Element.style.top = this.Y + "px"; 211 | } 212 | else 213 | { 214 | this.Element.style.left = ""; 215 | this.Element.style.right = this.X + "px"; 216 | this.Element.style.top = this.Y + "px"; 217 | } 218 | this.setVisible(true); 219 | } 220 | } 221 | 222 | ManagedText.prototype.release = function() 223 | { 224 | this.init(); 225 | this.change(""); 226 | this.hide(); 227 | } 228 | 229 | var CreateFontSystem = function() 230 | { 231 | var FontSystem = function() 232 | { 233 | this.Text = []; 234 | } 235 | 236 | FontSystem.prototype.preload = function() 237 | { 238 | } 239 | 240 | FontSystem.prototype.reset = function(frame) 241 | { 242 | this.release(frame); 243 | } 244 | 245 | FontSystem.prototype.release = function(frame) 246 | { 247 | //for(var i = 0, length = this.Text.length; i < length; ++i) 248 | // this.Text[i].release(); 249 | utils_.releaseArray(this.Text); 250 | } 251 | 252 | 253 | /*adds some managed text to the system*/ 254 | FontSystem.prototype.addText = function(elementID,text,x,y,fontSpacing,fontsPath,isLeft) 255 | { 256 | var ref = new ManagedText(elementID,text,x,y,fontSpacing,fontsPath,0,isLeft); 257 | ref.init(); 258 | this.Text[this.Text.length] = ref; 259 | return ref; 260 | } 261 | 262 | 263 | FontSystem.prototype.frameMove = function(frame) 264 | { 265 | for(var i = 0, length = this.Text.length; i < length; ++i) 266 | { 267 | this.Text[i].frameMove(frame); 268 | } 269 | } 270 | 271 | FontSystem.prototype.render = function(frame) 272 | { 273 | for(var i = 0, length = this.Text.length; i < length; ++i) 274 | { 275 | this.Text[i].render(frame); 276 | } 277 | } 278 | 279 | return new FontSystem(); 280 | } 281 | -------------------------------------------------------------------------------- /script/health-bar.js: -------------------------------------------------------------------------------- 1 | /*logic for the health bar*/ 2 | 3 | var HEALTHBAR = 4 | { 5 | LIFE_OFFSETX:-292 6 | ,DAMAGE_OFFSETX:-288 7 | ,ANIMATION_RATE:2 8 | ,MAX:288 9 | }; 10 | var CreateHealthBar = function(pnlHealthbarID,team) 11 | { 12 | var damageMultiplier_ = 1; 13 | 14 | var HealthBar = function() 15 | { 16 | this.Max = HEALTHBAR.MAX; 17 | this.Amount = this.Max; 18 | this.CurrentDamage = 0; 19 | this.HealthbarElement = window.document.getElementById(pnlHealthbarID); 20 | this.DamageElement = null; 21 | this.LifeElement = null; 22 | this.Team = team; 23 | this.IsInitialized = false; 24 | } 25 | 26 | HealthBar.prototype.getMax = function() { return this.Max; } 27 | HealthBar.prototype.setMax = function(value) { this.Max = value; } 28 | HealthBar.prototype.getAmount = function() { return this.Amount; } 29 | HealthBar.prototype.setAmount = function(value) { this.Amount = value; } 30 | HealthBar.prototype.getCurrentDamage = function() { return this.CurrentDamage; } 31 | HealthBar.prototype.setCurrentDamage = function(value) { this.CurrentDamage = value; } 32 | HealthBar.prototype.getHealthbarElement = function() { return this.HealthbarElement; } 33 | HealthBar.prototype.setHealthbarElement = function(value) { this.HealthbarElement = value; } 34 | HealthBar.prototype.getDamageElement = function() { return this.DamageElement; } 35 | HealthBar.prototype.setDamageElement = function(value) { this.DamageElement = value; } 36 | HealthBar.prototype.getLifeElement = function() { return this.LifeElement; } 37 | HealthBar.prototype.setLifeElement = function(value) { this.LifeElement = value; } 38 | HealthBar.prototype.getTeam = function() { return this.Team; } 39 | HealthBar.prototype.setTeam = function(value) { this.Team = value; } 40 | HealthBar.prototype.isInitialized = function() { return this.IsInitialized; } 41 | HealthBar.prototype.setInitialized = function(value) { this.IsInitialized = value; } 42 | 43 | 44 | 45 | /**/ 46 | HealthBar.prototype.release = function() 47 | { 48 | utils_.removeChildrenFromDOM(this.HealthbarElement, true); 49 | } 50 | 51 | 52 | HealthBar.prototype.init = function() 53 | { 54 | var img = window.document.createElement("div"); 55 | img.className = "health-bar-item"; 56 | spriteLookup_.set(img,"images/misc/misc/health-bar.png"); 57 | 58 | this.setDamageElement(window.document.createElement("div")); 59 | this.DamageElement.className = "damage"; 60 | this.DamageElement.style.width = "0px"; 61 | this.DamageElement.style.display = "none"; 62 | this.setLifeElement(window.document.createElement("div")); 63 | this.LifeElement.className = "life"; 64 | this.LifeElement.style.width = this.Amount + "px"; 65 | 66 | this.HealthbarElement.appendChild(img); 67 | this.HealthbarElement.appendChild(this.LifeElement); 68 | this.HealthbarElement.appendChild(this.DamageElement); 69 | 70 | /* 71 | imageLookup_.getBgB64(img,"images/misc/bars-sprites.png"); 72 | imageLookup_.getBgB64(this.DamageElement,"images/misc/health-bar-damage.png"); 73 | imageLookup_.getBgB64(this.LifeElement,"images/misc/health-bar-life.png"); 74 | imageLookup_.getBgB64(this.HealthbarElement,"images/misc/bars-sprites.png"); 75 | */ 76 | this.IsInitialized = true; 77 | } 78 | 79 | HealthBar.prototype.reset = function() 80 | { 81 | this.setCurrentDamage(0); 82 | if(this.getTeam() == 1) 83 | this.DamageElement.style.right = ""; 84 | else if(this.getTeam() == 2) 85 | this.DamageElement.style.left = ""; 86 | 87 | this.setAmount(this.Max); 88 | this.DamageElement.style.width = "0px"; 89 | this.LifeElement.style.width = this.Amount + "px"; 90 | } 91 | 92 | HealthBar.prototype.setDamageMultiplier = function(amount) 93 | { 94 | damageMultiplier_ = Math.max(amount,0); 95 | } 96 | 97 | //changes healthbar 98 | HealthBar.prototype.change = function(delta) 99 | { 100 | /*return this.Amount;*/ 101 | 102 | delta *= damageMultiplier_; 103 | 104 | var newAmount = Math.min(Math.max(this.Amount - delta,0), this.Max); 105 | var damage = this.Amount - newAmount; 106 | this.LifeElement.style.width = newAmount + "px"; 107 | if(!!damage) 108 | { 109 | this.setCurrentDamage(this.CurrentDamage + damage); 110 | var offset = HEALTHBAR.LIFE_OFFSETX + newAmount; 111 | if(this.getTeam() == 1) 112 | this.DamageElement.style.right = offset + "px"; 113 | else if(this.getTeam() == 2) 114 | this.DamageElement.style.left = offset + "px"; 115 | this.DamageElement.style.width = this.CurrentDamage + "px"; 116 | this.DamageElement.style.display = ""; 117 | } 118 | 119 | this.setAmount(newAmount); 120 | return this.Amount; 121 | } 122 | 123 | HealthBar.prototype.frameMove = function(frame) 124 | { 125 | } 126 | 127 | HealthBar.prototype.render = function(frame) 128 | { 129 | if(!!this.CurrentDamage && (frame % HEALTHBAR.ANIMATION_RATE == 0)) 130 | { 131 | this.setCurrentDamage(this.CurrentDamage - 1) 132 | this.DamageElement.style.width = this.CurrentDamage + "px"; 133 | } 134 | } 135 | return new HealthBar(pnlHealthbarID,team); 136 | } -------------------------------------------------------------------------------- /script/hitsystem.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var RegisteredHit = function(behavior,hitState,flags,startFrame,frame,damage,energyToAdd,isProjectile,isGrapple,hitX,hitY,attackDirection,who,hitID,attackID,priorityFlags,playerPoseState,playerState,fx,fy,otherPlayer,behaviorFlags,invokedAnimationName) 4 | { 5 | this.BehaviorFlags = behaviorFlags; 6 | this.HitState = hitState; 7 | this.Flags = flags; 8 | this.Frame = frame; 9 | this.StartFrame = 0; 10 | this.Damage = damage; 11 | this.EnergyToAdd = energyToAdd; 12 | this.IsProjectile = isProjectile; 13 | this.IsGrapple = isGrapple; 14 | this.HitX = hitX; 15 | this.HitY = hitY; 16 | this.Who = who; 17 | this.AttackDirection = attackDirection; 18 | this.HitID = hitID; 19 | this.AttackID = attackID; 20 | this.PriorityFlags = priorityFlags; 21 | this.PlayerPoseState = priorityFlags; 22 | this.PlayerState = playerState; 23 | this.AttackForceX = fx; 24 | this.AttackForceY = fy; 25 | this.OtherPlayer = otherPlayer; 26 | this.InvokedAnimationName = invokedAnimationName; 27 | this.NoFrameDelay = false; 28 | } 29 | 30 | 31 | 32 | 33 | //*controls if a move can override another. To allow a double hit, set both the allowOverridgeFlags and overideFlags to OVERRIDE_FLAGS.NONE 34 | var MoveOverrideFlags = function(allowOverrideFlags,overrideFlags) 35 | { 36 | this.AllowOverrideFlags = allowOverrideFlags || OVERRIDE_FLAGS.ALL; 37 | this.OverrideFlags = overrideFlags || OVERRIDE_FLAGS.NULL; 38 | } 39 | 40 | MoveOverrideFlags.prototype.hasAllowOverrideFlag = function(flag) { return !!flag && hasFlag(this.AllowOverrideFlags,flag); } 41 | MoveOverrideFlags.prototype.hasOverrideFlag = function(flag) { return !!flag && hasFlag(this.OverrideFlags,flag); } 42 | 43 | 44 | var ActionDetails = function(registeredHit,overrideFlags,player,otherID,isProjectile,isGrapple,startFrame,frame,otherPlayer) 45 | { 46 | this.MoveOverrideFlags = overrideFlags; 47 | this.Frame = frame || 0; 48 | this.OtherAttackStartFrame = startFrame; 49 | this.RegisteredHit = registeredHit; 50 | this.Key = this.getKey(player.Id,otherID); 51 | this.IsProjectile = isProjectile; 52 | this.IsGrapple = isGrapple; 53 | this.Player = player; 54 | this.OtherPlayer = otherPlayer; 55 | this.PlayerID = player.Id; 56 | } 57 | 58 | 59 | ActionDetails.prototype.getKey = function(playerID,otherID) 60 | { 61 | var retVal = ""; 62 | //ensure that the team 1 is always first 63 | if(playerID.charAt(1) == "1") 64 | retVal = playerID + otherID; 65 | else 66 | retVal = otherID + playerID; 67 | 68 | return retVal; 69 | } 70 | 71 | 72 | var HitSystem = function(actionFrameDelay) 73 | { 74 | this.Actions = {}; 75 | this.HoldFrame = false; 76 | this.ActionFrameDelay = actionFrameDelay || CONSTANTS.DEFAULT_ACTION_FRAME_DELAY; 77 | } 78 | 79 | HitSystem.prototype.pause = function() 80 | { 81 | this.HoldFrame = true; 82 | } 83 | 84 | HitSystem.prototype.resume = function() 85 | { 86 | this.HoldFrame = false; 87 | } 88 | 89 | HitSystem.prototype.checkPendingHits = function(id,overrideFlags) 90 | { 91 | } 92 | 93 | //can the hit on the victimA player be hit 94 | HitSystem.prototype.canHit = function(key,index) 95 | { 96 | var victimA = index == 0 ? this.Actions[key][0] : this.Actions[key][1]; 97 | var victimB = index == 0 ? this.Actions[key][1] : this.Actions[key][0]; 98 | 99 | var retVal = true; 100 | if(!!victimA.OtherPlayer && !!victimA.Player.CurrentAnimation.Animation && !victimA.IsProjectile) 101 | { 102 | if(victimA.Player.isUnhittable()) 103 | return false; 104 | //grapples can not be overriden 105 | if(victimA.Player.isGrappling()) 106 | return false; 107 | if(victimA.IsGrapple || (!!victimB && victimB.IsGrapple)) 108 | return true; 109 | var flags = victimA.Player.CurrentAnimation.Animation.OverrideFlags; 110 | var otherFlags = victimA.OtherPlayer.CurrentAnimation.Animation.OverrideFlags; 111 | 112 | 113 | var imDoingUppercut = victimA.Player.CurrentAnimation.Animation.OverrideFlags.hasAllowOverrideFlag(OVERRIDE_FLAGS.SHORYUKEN); 114 | var youreDoingUppercut = victimA.OtherPlayer.CurrentAnimation.Animation.OverrideFlags.hasAllowOverrideFlag(OVERRIDE_FLAGS.SHORYUKEN); 115 | 116 | var canIOverrideYou = (!flags.hasOverrideFlag(OVERRIDE_FLAGS.NONE) 117 | && flags.hasOverrideFlag(victimA.OtherPlayer.CurrentAnimation.Animation.OverrideFlags.AllowOverrideFlags) /*overrides yours*/ 118 | && !otherFlags.hasOverrideFlag(victimA.Player.CurrentAnimation.Animation.OverrideFlags.AllowOverrideFlags)) /*overrides mine (if both moves override each other, then both should hit)*/ 119 | || imDoingUppercut /*overrides everything*/ 120 | ; 121 | 122 | var canYouOverrideMe = (!otherFlags.hasOverrideFlag(OVERRIDE_FLAGS.NONE) 123 | && otherFlags.hasOverrideFlag(victimA.Player.CurrentAnimation.Animation.OverrideFlags.AllowOverrideFlags) 124 | && !flags.hasOverrideFlag(victimA.OtherPlayer.CurrentAnimation.Animation.OverrideFlags.AllowOverrideFlags)) 125 | || youreDoingUppercut /*overrides everything*/ 126 | 127 | var iDidFirstJumpInAttack = (victimA.Player.CurrentAnimation.Animation.BaseAnimation.IsAttack && victimA.OtherPlayer.CurrentAnimation.Animation.BaseAnimation.IsAttack 128 | && victimA.Player.isAirborne() 129 | && !victimA.OtherPlayer.isAirborne() 130 | && (victimA.Player.CurrentAnimation.StartFrame < victimA.OtherPlayer.CurrentAnimation.StartFrame)) 131 | ; 132 | 133 | var youDidFirstJumpInAttack = (victimA.Player.CurrentAnimation.Animation.BaseAnimation.IsAttack && victimA.OtherPlayer.CurrentAnimation.Animation.BaseAnimation.IsAttack 134 | && victimA.OtherPlayer.isAirborne() 135 | && !victimA.Player.isAirborne() 136 | && (victimA.OtherPlayer.CurrentAnimation.StartFrame < victimA.Player.CurrentAnimation.StartFrame)) 137 | ; 138 | 139 | var canYourHProjectileHit = (otherFlags.hasAllowOverrideFlag(OVERRIDE_FLAGS.HPROJECTILE)) && !victimB; 140 | 141 | //if we aren't facing our victimA, then we can't override 142 | if(!victimA.Player.isFacingPlayer(victimA.OtherPlayer, true)) 143 | return true; 144 | 145 | //after all attack frames in a move are finished - IgnoreOverrides will be set to true 146 | if(!!victimA.Player.IgnoreOverrides) 147 | return true; 148 | 149 | //ken and ryu's uppercut can not be overriden 150 | if(!!imDoingUppercut && !youreDoingUppercut) 151 | return false; 152 | else if(!!youreDoingUppercut) 153 | return true; 154 | 155 | if(!!canYourHProjectileHit) 156 | return true; 157 | 158 | //special overrides 159 | if(!!canYouOverrideMe) 160 | return true; 161 | else if(!!canIOverrideYou) 162 | return false; 163 | 164 | //the first attack on a jump in should hit 165 | if(!!iDidFirstJumpInAttack) 166 | return false; 167 | else if(!!youDidFirstJumpInAttack) 168 | return true; 169 | } 170 | return retVal; 171 | } 172 | 173 | HitSystem.prototype.clearPendingHit = function(id) 174 | { 175 | for(var i in this.Actions) 176 | { 177 | for(var index in this.Actions[i]) 178 | { 179 | if(this.Actions[i][index].PlayerID == id) 180 | { 181 | this.Actions[i][index] = null; 182 | delete this.Actions[i][index]; 183 | } 184 | } 185 | if(!this.Actions[i][0] && !this.Actions[i][1]) 186 | { 187 | delete this.Actions[i]; 188 | } 189 | } 190 | } 191 | 192 | HitSystem.prototype.frameMove = function(frame) 193 | { 194 | for(var i in this.Actions) 195 | { 196 | var item = this.Actions[i]; 197 | 198 | if(!!this.HoldFrame) 199 | { 200 | if(!!item && !!item.ActionFrame) 201 | ++item.ActionFrame; 202 | continue; 203 | } 204 | 205 | if(!!item && !!item.ActionFrame && (item.ActionFrame <= frame)) 206 | { 207 | var canP1Hit = !!item[0] && this.canHit(item[0].Key,0); 208 | var canP2Hit = !!item[1] && this.canHit(item[1].Key,1); 209 | var canDoubleHit = !canP1Hit && !canP2Hit 210 | 211 | if(!!item[0] && canP1Hit) 212 | { 213 | //player 1 registers action 214 | item[0].Player.registerHit(frame,item[0].RegisteredHit); 215 | } 216 | else if(!!item[0]) 217 | { 218 | item[0].Player.didntHit(frame,item[0].OtherPlayer.Id); 219 | } 220 | 221 | if(!!item[1] && canP2Hit) 222 | { 223 | //player 2 registers action 224 | item[1].Player.registerHit(frame,item[1].RegisteredHit); 225 | } 226 | else if(!!item[1]) 227 | { 228 | item[1].Player.didntHit(frame,item[1].OtherPlayer.Id); 229 | } 230 | //clear the action 231 | this.Actions[i] = null; 232 | delete this.Actions[i]; 233 | } 234 | } 235 | } 236 | 237 | HitSystem.prototype.register = function(details) 238 | { 239 | if(details.IsProjectile) 240 | details.Key += "_" + details.Frame.toString(); 241 | if(!this.Actions[details.Key]) 242 | this.Actions[details.Key] = {ActionFrame:details.Frame + (!!details.NoFrameDelay ? 0 : this.ActionFrameDelay)} 243 | if(!this.Actions[details.Key][0] || (this.Actions[details.Key][0].PlayerID == details.PlayerID)) 244 | this.Actions[details.Key][0] = details; 245 | else 246 | this.Actions[details.Key][1] = details; 247 | 248 | if(!!details.NoFrameDelay) 249 | { 250 | this.frameMove(details.Frame); 251 | } 252 | 253 | } 254 | -------------------------------------------------------------------------------- /script/init.js: -------------------------------------------------------------------------------- 1 | Array.prototype.indexOf = Array.prototype.indexOf || function (value) { 2 | for (var i = 0, length = this.length; i < length; ++i) 3 | if (this[i] === value) 4 | return i; 5 | return -1; 6 | }; 7 | 8 | var getRand = function (max) { 9 | if (max === 0) 10 | return 0; 11 | return Math.floor((Math.random() * (max || 100))); 12 | }; 13 | 14 | var rand = function (min, max) { 15 | return min + Math.floor((Math.random() * (max - min))); 16 | }; 17 | 18 | var StageParams = function (key, bg0YOffset, bg1YOffset) { 19 | this.Key = key; 20 | this.Name = key; 21 | this.Bg0YOffset = bg0YOffset || -21; 22 | this.Bg1YOffset = bg1YOffset || -41; 23 | this.Bg0Img = "images/misc/stage/" + this.Key + ".back.png"; 24 | this.Bg1Img = "images/misc/stage/" + this.Key + ".front.png"; 25 | }; 26 | 27 | var stages_ = {}; 28 | var val = STAGE.MAX_STAGEX - 1152; 29 | stages_["ryu"] = new StageParams("ryu"); 30 | stages_["ken"] = new StageParams("ken"); 31 | stages_["guy"] = new StageParams("guy"); 32 | stages_["chunli"] = new StageParams("chunli"); 33 | stages_["dramatic_battle"] = new StageParams("mbison"); 34 | stages_["mbison"] = new StageParams("mbison"); 35 | stages_["akuma"] = new StageParams("akuma"); 36 | stages_["sodom"] = new StageParams("sodom"); 37 | stages_["sagat"] = new StageParams("sagat"); 38 | 39 | function ApplyFlip(element, applied) { 40 | if (applied === undefined) { 41 | //reverse 42 | if ((element.className.indexOf(" flipped") === -1)) { 43 | element.className += " flipped"; 44 | } else { 45 | element.className = element.className.replace(" flipped", ""); 46 | } 47 | } else if (!!applied) { 48 | element.className += " flipped"; 49 | } else { 50 | element.className = element.className.replace(" flipped", ""); 51 | } 52 | } 53 | 54 | function AutoApplyFlip(element, applied) { 55 | if (!!applied && (element.className.indexOf(" flipped") === -1)) { 56 | element.className += " flipped"; 57 | } else if (!applied && (element.className.indexOf(" flipped") !== -1)) { 58 | element.className = element.className.replace(" flipped", ""); 59 | } 60 | } 61 | 62 | function IsFlipped(element) { 63 | return !!element && element.className.indexOf(" flipped") !== -1; 64 | } 65 | 66 | function Alert(text) { 67 | //if(!!console && !!console.log) 68 | //console.log(text); 69 | 70 | } 71 | 72 | function AlertError(text) { 73 | //if(!!console && !!console.error) 74 | // console.error(text); 75 | } 76 | 77 | var announcer_ = CreateAnnouncer(); 78 | var game_ = CreateGame(); 79 | game_.setTeamMode(false); 80 | var fontSystem_ = CreateFontSystem(); 81 | 82 | var runGameLoop_ = (function (thisValue) { 83 | return function () { 84 | thisValue.runGameLoop(thisValue.getCurrentTime()); 85 | } 86 | })(game_); 87 | 88 | var runCharSelectLoop_ = (function (thisValue) { 89 | return function () { 90 | thisValue.runCharSelectLoop(); 91 | } 92 | })(game_); 93 | 94 | var runInsertCoinScreenLoop_ = (function (thisValue) { 95 | return function () { 96 | thisValue.runInsertCoinScreenLoop(); 97 | } 98 | })(game_); 99 | 100 | var btn = function (button, state, min, max) { 101 | return {Button: button, State: state, MinNbFrames: min || undefined, MaxNbFrames: max || undefined}; 102 | }; 103 | 104 | //overriden OnStageImagesLoaded function, just incase the images load too slow 105 | function OnStageImagesLoaded() { 106 | game_.onStageImagesLoaded(); 107 | } 108 | 109 | //Human users 110 | function InitUsers() { 111 | delete window.user1_; 112 | delete window.user2_; 113 | delete window.user3_; 114 | delete window.user4_; 115 | delete window.user5_; 116 | delete window.user6_; 117 | delete window.user7_; 118 | delete window.user8_; 119 | 120 | var val = 10000000; 121 | 122 | window.user1_ = game_.addUser1(KEYS.ARROW_RIGHT, KEYS.ARROW_UP, KEYS.ARROW_LEFT, KEYS.ARROW_DOWN, KEYS.A, KEYS.S, KEYS.D, KEYS.Z, KEYS.X, KEYS.C, KEYS.F, KEYS.CNTRL, KEYS.ENTER); 123 | // window.user1_ = game_.addUser1(GAMEPAD.RIGHT,GAMEPAD.UP,GAMEPAD.LEFT,GAMEPAD.DOWN,GAMEPAD.LS0,GAMEPAD.B3,GAMEPAD.B2,GAMEPAD.RS0,GAMEPAD.B1,GAMEPAD.HK,GAMEPAD.RS1,GAMEPAD.SELECT,GAMEPAD.START,0); 124 | window.user2_ = game_.addUser2(KEYS.NUMPAD_6, KEYS.NUMPAD_8, KEYS.NUMPAD_4, KEYS.NUMPAD_5, KEYS.H, KEYS.J, KEYS.K, KEYS.N, KEYS.M, KEYS.COMMA, KEYS.L, KEYS.NUMPAD_7, KEYS.NUMPAD_9); 125 | 126 | val += 100; 127 | window.user3_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 128 | val += 100; 129 | window.user4_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 130 | val += 100; 131 | window.user5_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 132 | val += 100; 133 | window.user6_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 134 | val += 100; 135 | window.user7_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 136 | val += 100; 137 | window.user8_ = game_.addUser(val + 11, val + 12, val + 13, val + 14, val + 15, val + 16, val + 17, val + 18, val + 19, val + 20, val + 21); 138 | } 139 | 140 | InitUsers(); 141 | 142 | //Goes to the character selection screen 143 | function StartCharacterSelection() { 144 | game_.resume(); 145 | game_.startCharSelect(); 146 | } 147 | 148 | //Goes to the character selection screen 149 | function StartInsertCoin() { 150 | game_.resume(); 151 | game_.startInsertCoinScreen(); 152 | } 153 | 154 | function ResetGame() { 155 | debug_.setPracticeMode(false); 156 | game_.resetPlayers(); 157 | game_.resume(); 158 | StartInsertCoin(); 159 | } 160 | 161 | var debug_ = GetDebugInstance(game_); 162 | /*******************************************************************************************************************************/ 163 | /*******************************************************************************************************************************/ 164 | 165 | //preload a bunch of assets 166 | 167 | //insert coin 168 | stuffLoader_.queue("insert-coin.js", RESOURCE_TYPES.BASE64AUDIO); 169 | stuffLoader_.queue("char-select.js", RESOURCE_TYPES.BASE64AUDIO); 170 | stuffLoader_.queue("match.js", RESOURCE_TYPES.BASE64AUDIO); 171 | 172 | //stuffLoader_.queue("images/misc/misc/insert-coin.png",RESOURCE_TYPES.IMAGE); 173 | stuffLoader_.queue("images/misc/misc/announcer-sprites.png", RESOURCE_TYPES.IMAGE); 174 | stuffLoader_.queue("images/misc/font1/insert.png", RESOURCE_TYPES.IMAGE); 175 | stuffLoader_.queue("images/misc/font1/credits.png", RESOURCE_TYPES.IMAGE); 176 | stuffLoader_.queue("images/misc/font1/cap.png", RESOURCE_TYPES.IMAGE); 177 | 178 | //match 179 | stuffLoader_.queue("images/misc/misc/shadow-sprites.png", RESOURCE_TYPES.IMAGE); 180 | stuffLoader_.queue("images/misc/misc/dirt-sprites.png", RESOURCE_TYPES.IMAGE); 181 | stuffLoader_.queue("images/misc/misc/blast-sprites.png", RESOURCE_TYPES.IMAGE); 182 | stuffLoader_.queue("images/misc/misc/bars-sprites.png", RESOURCE_TYPES.IMAGE); 183 | stuffLoader_.queue("images/misc/misc/misc-sprites.png", RESOURCE_TYPES.IMAGE); 184 | stuffLoader_.queue("images/misc/misc/energy-bar-lvl0.png", RESOURCE_TYPES.IMAGE); 185 | stuffLoader_.queue("images/misc/misc/energy-bar-lvl1.png", RESOURCE_TYPES.IMAGE); 186 | stuffLoader_.queue("images/misc/misc/energy-bar-lvl2.png", RESOURCE_TYPES.IMAGE); 187 | stuffLoader_.queue("images/misc/misc/health-bar-life.png", RESOURCE_TYPES.IMAGE); 188 | stuffLoader_.queue("images/misc/misc/health-bar-damage.png", RESOURCE_TYPES.IMAGE); 189 | stuffLoader_.queue("images/misc/misc/misc-sprites.png", RESOURCE_TYPES.IMAGE); 190 | 191 | //character select 192 | //stuffLoader_.queue("images/misc/misc/player-select.png",RESOURCE_TYPES.IMAGE); 193 | //stuffLoader_.queue("images/misc/font3/name-sprites.png",RESOURCE_TYPES.IMAGE); 194 | //stuffLoader_.queue("images/misc/misc/char-misc-sprites.png",RESOURCE_TYPES.IMAGE); 195 | stuffLoader_.queue("images/misc/misc/head-sprites.png", RESOURCE_TYPES.IMAGE); 196 | //stuffLoader_.queue("images/misc/misc/player-select-back-bg.png",RESOURCE_TYPES.IMAGE); 197 | //stuffLoader_.queue("images/misc/misc/player-select-bg.png",RESOURCE_TYPES.IMAGE); 198 | stuffLoader_.queue("images/misc/misc/char-select-sprites.png", RESOURCE_TYPES.IMAGE); 199 | stuffLoader_.queue("images/misc/misc/char-sprites.png", RESOURCE_TYPES.IMAGE); 200 | 201 | // Needed due to changes in Google Chrome https://goo.gl/7K7WLu 202 | // The user must interact with the page before audio can be played... ugh 203 | var startUpGame = function () { 204 | $$init(); 205 | 206 | if(getRand(100) > 50) 207 | debug_.startMatch([{A:CHARACTERS.RYU, C:true},{A:CHARACTERS.KEN, C:true}], [{A:CHARACTERS.AKUMA, C:true}], "akuma"); 208 | else 209 | debug_.startMatch([{A:CHARACTERS.RYU, C:true},{A:CHARACTERS.KEN, C:true}], [{A:CHARACTERS.MBISON, C:true}], "dramatic_battle"); 210 | } 211 | 212 | $$wasAudioInitialized = false; 213 | var $$init = function() { 214 | if (!$$wasAudioInitialized) { 215 | var container = document.querySelector(".start-game-container"); 216 | if (container) { 217 | container.style.display = "none"; 218 | 219 | $$wasAudioInitialized = true; 220 | soundManager_ = CreateSoundManager(); 221 | 222 | //preload characters 223 | Player.prototype.loadAssets("ryu", "ryu", true); 224 | Player.prototype.loadAssets("ryu", "ryu2", true); 225 | Player.prototype.loadAssets("ken", "ken", true); 226 | Player.prototype.loadAssets("ken", "ken2", true); 227 | Player.prototype.loadAssets("sagat", "sagat", true); 228 | Player.prototype.loadAssets("sagat", "sagat2", true); 229 | Player.prototype.loadAssets("mbison", "mbison", true); 230 | Player.prototype.loadAssets("mbison", "mbison2", true); 231 | Player.prototype.loadAssets("akuma", "akuma", true); 232 | Player.prototype.loadAssets("akuma", "akuma2", true); 233 | } 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /script/insert-coin.js: -------------------------------------------------------------------------------- 1 | var CreateInsertCoinScreen = function(u1,u2) 2 | { 3 | /*private members*/ 4 | var hideInsertCoin_ = false; 5 | var mustUpdate_ = true; 6 | var user1_ = u1; 7 | var user2_ = u2; 8 | var isDone_ = false; 9 | var text1_ = null; 10 | var text1_ = null; 11 | var capElement_ = null; 12 | var insertCoinElement_ = null; 13 | var creditsElement_ = null; 14 | var creditsTextElement_ = null; 15 | var parent_ = window.document.getElementById("pnlStage"); 16 | var nbCredits_ = 0; 17 | 18 | /*public*/ 19 | var InsertCoinScreen = function() 20 | { 21 | } 22 | 23 | 24 | InsertCoinScreen.prototype.resume = function() { } 25 | InsertCoinScreen.prototype.pause = function() { } 26 | InsertCoinScreen.prototype.resetKeys = function() { } 27 | InsertCoinScreen.prototype.init = function() { } 28 | 29 | 30 | InsertCoinScreen.prototype.isDone = function() { return isDone_; } 31 | 32 | InsertCoinScreen.prototype.start = function() 33 | { 34 | game_.showLoading(false); 35 | isDone_ = false; 36 | capElement_ = window.document.createElement("div"); 37 | capElement_.className = "capcom"; 38 | capElement_.id = "pnlCapcom"; 39 | parent_.appendChild(capElement_); 40 | 41 | insertCoinElement_ = window.document.createElement("div"); 42 | insertCoinElement_.className = "insert-coin"; 43 | insertCoinElement_.id = "pnlInsertCoin"; 44 | parent_.appendChild(insertCoinElement_); 45 | centerElement(insertCoinElement_); 46 | 47 | creditsElement_ = window.document.createElement("div"); 48 | creditsElement_.className = "credits"; 49 | creditsElement_.id = "pnlCredits"; 50 | creditsElement_.style.display = "none"; 51 | parent_.appendChild(creditsElement_); 52 | centerElement(creditsElement_); 53 | 54 | creditsTextElement_ = window.document.createElement("div"); 55 | creditsTextElement_.className = "credits-text"; 56 | creditsTextElement_.id = "pnlCredits"; 57 | creditsTextElement_.style.display = "none"; 58 | parent_.appendChild(creditsTextElement_); 59 | 60 | text1_ = fontSystem_.addText("pnlCredits","",432,555,0,"font1"); 61 | //text1_.showNow(432); 62 | var pnlStage = window.document.getElementById("pnlStage"); 63 | spriteLookup_.set(pnlStage, "images/misc/misc/insert-coin.png", true) 64 | 65 | /* 66 | imageLookup_.getBgB64(capElement_,"images/misc/cap.png"); 67 | imageLookup_.getBgB64(insertCoinElement_,"images/misc/insert.png"); 68 | imageLookup_.getBgB64(creditsTextElement_,"images/misc/credits.png"); 69 | imageLookup_.getBgB64(window.document.getElementById("pnlStage"), "images/misc/insert-coin.png"); 70 | */ 71 | } 72 | 73 | 74 | InsertCoinScreen.prototype.release = function() 75 | { 76 | this.IsDone = true; 77 | utils_.removeFromDOM(capElement_); 78 | utils_.removeFromDOM(insertCoinElement_); 79 | utils_.removeFromDOM(creditsTextElement_); 80 | utils_.removeFromDOM(creditsElement_); 81 | window.document.getElementById("pnlStage").style.backgroundImage = ""; 82 | } 83 | 84 | 85 | InsertCoinScreen.prototype.kill = function() 86 | { 87 | this.release(); 88 | } 89 | 90 | InsertCoinScreen.prototype.onAddCredit = function() 91 | { 92 | mustUpdate_ = true; 93 | } 94 | 95 | InsertCoinScreen.prototype.onKeyStateChanged = function(isDown,keyCode,frame) 96 | { 97 | if(!!user1_) 98 | { 99 | if(!!isDown && (keyCode == user1_.Coin)) 100 | this.onAddCredit(); 101 | } 102 | if(!!user2_) 103 | { 104 | if(!!isDown && (keyCode == user2_.Coin)) 105 | this.onAddCredit(); 106 | } 107 | } 108 | 109 | 110 | InsertCoinScreen.prototype.frameMove = function(frame) 111 | { 112 | if((!!user1_ && user1_.IsRequestingCharSelect) || (!!user2_ && user2_.IsRequestingCharSelect)) 113 | { 114 | StartCharacterSelection(); 115 | return; 116 | } 117 | 118 | if((!!u1 && !user1_.hasCredits()) || (!!user2_ && !user2_.hasCredits())) 119 | { 120 | if(!__debugMode && (frame % 1000) == 0) 121 | { 122 | return game_.startRandomMatch(); 123 | } 124 | else if((frame % 80) == 0) 125 | { 126 | hideInsertCoin_ = false; 127 | mustUpdate_ = true; 128 | } 129 | else if((frame % 40) == 0) 130 | { 131 | hideInsertCoin_ = true; 132 | mustUpdate_ = true; 133 | } 134 | } 135 | } 136 | 137 | 138 | InsertCoinScreen.prototype.render = function(frame) 139 | { 140 | if(!!mustUpdate_) 141 | { 142 | mustUpdate_ = false; 143 | if((!!user1_ && user1_.hasCredits()) || (!!user2_ && user2_.hasCredits())) 144 | { 145 | capElement_.style.display = "none"; 146 | insertCoinElement_.style.display = "none"; 147 | creditsElement_.style.display = ""; 148 | creditsTextElement_.style.display = ""; 149 | nbCredits_ = Math.min(9, (!!user1_ ? user1_.getNbCredits() : 0) + (!!user2_ ? user2_.getNbCredits() : 0)) 150 | text1_.change(nbCredits_); 151 | } 152 | else 153 | { 154 | if(!!hideInsertCoin_) 155 | insertCoinElement_.style.display = "none"; 156 | else 157 | insertCoinElement_.style.display = ""; 158 | } 159 | } 160 | } 161 | 162 | return new InsertCoinScreen(); 163 | } -------------------------------------------------------------------------------- /script/joypad.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | joypad.js v2.3.5 3 | Copyright (c) 2019 Arun Michael Dsouza (amdsouza92@gmail.com) 4 | Licence: MIT 5 | */ 6 | var a={events:{},publish:function a(b,c){if(this.events.hasOwnProperty(b))this.events[b].forEach(function(a){return a(c)})},subscribe:function a(b,c){if(!this.events.hasOwnProperty(b))this.events[b]=[];this.events[b].push(c);return{unsubscribe:(function(){var a=this.events[b].indexOf(c);if(-1!==a)this.events[b].splice(a,1)}).bind(this)}}};var a1={CONNECT:{NATIVE:"gamepadconnected",ALIAS:"connect"},DISCONNECT:{NATIVE:"gamepaddisconnected",ALIAS:"disconnect"},BUTTON_PRESS:{NATIVE:null,ALIAS:"button_press"},BUTTON_RELEASE:{NATIVE:null,ALIAS:"button_release"},AXIS_MOVEMENT:{NATIVE:null,ALIAS:"axis_move"}};var b={LEFT:{NAME:"left_stick",AXES:{X:0,Y:1}},RIGHT:{NAME:"right_stick",AXES:{X:2,Y:3}}};var c={LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom"};var d={button_0:0,button_1:1,button_2:2,button_3:3,button_4:4,button_5:5,button_6:6,button_7:7,button_8:8,button_9:9,button_10:10,button_11:11,button_12:12,button_13:13,button_14:14,button_15:15,button_16:16,button_17:17};var e=.8;var a2=function(a){if(console.warn&&"function"==typeof console.warn)console.warn(a);else console.log(a)};var b1=function(a,b){var c=[];Object.keys(b).forEach(function(d){if(b[d]===a)c.push(d);else if(Array.isArray(b[d])&& -1!==b[d].indexOf(a))c.push(d)});return c};var c1=function(a){return!!a&&!!a.type&&!!a.playEffect&&"function"==typeof a.playEffect||false};var d1=function(){return!!window.navigator.getGamepads&&"function"==typeof window.navigator.getGamepads||false};var f={loopStarted:false,instances:{},buttonEvents:{joypad:[]},settings:{axisMovementThreshold:e},remove:function a(b){return delete this.instances[b]},on:function c(d,e){switch(d){case a1.CONNECT.ALIAS:return a.subscribe(a1.CONNECT.ALIAS,e);case a1.DISCONNECT.ALIAS:return a.subscribe(a1.DISCONNECT.ALIAS,e);case a1.BUTTON_PRESS.ALIAS:return a.subscribe(a1.BUTTON_PRESS.ALIAS,e);case a1.BUTTON_RELEASE.ALIAS:return a.subscribe(a1.BUTTON_RELEASE.ALIAS,e);case a1.AXIS_MOVEMENT.ALIAS:return a.subscribe(a1.AXIS_MOVEMENT.ALIAS,e)}},vibrate:function a(b,c){var f=b.vibrationActuator;var g=c||this.settings.vibration;if(c1(f)){var h=f.type;return b.vibrationActuator.playEffect(h,g)}a2("No vibration actuator interface found - https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator")},set:function a(b){var c=b.axisMovementThreshold,d=b.vibration,e=b.customButtonMapping;var f=parseFloat(c);if(!isNaN(f))this.settings.axisMovementThreshold=f;this.settings.vibration=d;this.settings.customButtonMapping=e},trigger:function b(c,d){return a.publish(c,d)}};var j=function(a){a.buttons.forEach(function(c,d1){var e=f.settings.customButtonMapping;var f1=e||d;var i=b1(d1,f1);var j=f.buttonEvents;if(i&&i.length)i.forEach(function(b){if(c.pressed){if(!j.joypad[a.index][b])j.joypad[a.index][b]={pressed:true,hold:false,released:false};j.joypad[a.index][b].button=c;j.joypad[a.index][b].index=d1;j.joypad[a.index][b].gamepad=a}else if(!c.pressed&&j.joypad[a.index][b]){j.joypad[a.index][b].released=true;j.joypad[a.index][b].hold=false}})})};var k=function(a){var c1=function(a){return new CustomEvent(a1.AXIS_MOVEMENT.ALIAS,{detail:a})};var g=f.settings.axisMovementThreshold;var h=a.axes;var i=h.length;var j=i/2;h.forEach(function(b1,d){if(Math.abs(b1)>g){var h=null;var i=null;var k=b1;h=d 0) 27 | { 28 | var points = this.CurrentFrame.HitPoints; 29 | var x = this.getX(); 30 | var i = 0; 31 | for(; (i < maxDebugHits) && (i < points.length); ++i) 32 | { 33 | this.DebugHit[i].style.bottom = (this.getY() + points[i].y) + "px"; 34 | 35 | if(this.Direction < 0) 36 | { 37 | this.DebugHit[i].style.right = ""; 38 | this.DebugHit[i].style.left = (x + points[i].x) + "px"; 39 | } 40 | else 41 | { 42 | this.DebugHit[i].style.left = ""; 43 | this.DebugHit[i].style.right = (x + points[i].x) + "px"; 44 | } 45 | if(this.DebugHit[i].style.display != "") 46 | this.DebugHit[i].style.display = ""; 47 | } 48 | for(; i < 3; ++i) 49 | { 50 | if(this.DebugHit[i].style.display != "none") 51 | this.DebugHit[i].style.display = "none"; 52 | } 53 | } 54 | else 55 | { 56 | for(var i = 0; i < maxDebugHits; ++i) 57 | { 58 | if(this.DebugHit[i].style.display != "none") 59 | this.DebugHit[i].style.display = "none"; 60 | } 61 | } 62 | 63 | 64 | var rect = this.ImgBBox;//this.getRect(); 65 | this.Rect.style.bottom = rect.Bottom + "px"; 66 | 67 | if(this.Direction == -1) 68 | { 69 | this.Rect.style.left = rect.Left + "px"; 70 | this.Rect.style.right = ""; 71 | } 72 | else 73 | { 74 | this.Rect.style.right = (STAGE.MAX_STAGEX - rect.Right) + "px"; 75 | this.Rect.style.left = ""; 76 | } 77 | 78 | this.Rect.style.width = (rect.Right - rect.Left) + "px"; 79 | this.Rect.style.height = (rect.Top - rect.Bottom) + "px"; 80 | 81 | } 82 | 83 | 84 | /**/ 85 | Player.prototype.releaseDebugElements = function() 86 | { 87 | for(var i = 0; i < maxDebugHits; ++i) 88 | { 89 | utils_.removeFromDOM(this.DebugHit[i]); 90 | } 91 | utils_.removeFromDOM(this.Rect); 92 | utils_.removeFromDOM(this.DebKeysElement); 93 | utils_.releaseArray(this.DebugHit); 94 | } 95 | 96 | 97 | /**/ 98 | Player.prototype.createDebugElements = function(parentElement) 99 | { 100 | /* 101 | this.DebugB = window.document.createElement("b"); 102 | this.DebugB.className = "right"; 103 | this.DebugB.innerHTML = "r"; 104 | (parentElement || window.document.getElementById("pnlStage")).appendChild(this.DebugB); 105 | 106 | this.DebugF = window.document.createElement("b"); 107 | this.DebugF.className = "left"; 108 | this.DebugF.innerHTML = "l"; 109 | (parentElement || window.document.getElementById("pnlStage")).appendChild(this.DebugF); 110 | 111 | var d = window.document.createElement("div"); 112 | d.className = "circle-debug"; 113 | this.Circle.DebugElement = d; 114 | this.Circle.render(); 115 | //(parentElement || window.document.getElementById("pnlStage")).appendChild(d); 116 | this.Element.appendChild(d); 117 | */ 118 | this.DebugHit = []; 119 | for(var i = 0; i < maxDebugHits; ++i) 120 | { 121 | this.DebugHit[i] = window.document.createElement("b"); 122 | this.DebugHit[i].style.display = "none"; 123 | this.DebugHit[i].className = "hit"; 124 | this.DebugHit[i].innerHTML = i+1; 125 | (parentElement || window.document.getElementById("pnlStage")).appendChild(this.DebugHit[i]); 126 | } 127 | 128 | this.Rect = window.document.createElement("div"); 129 | this.Rect.className = "player-rect"; 130 | (parentElement || window.document.getElementById("pnlStage")).appendChild(this.Rect); 131 | } 132 | 133 | Player.prototype.createKeysElement = function() 134 | { 135 | this.DebKeysElement = window.document.createElement("div"); 136 | this.DebKeysElement.className = "show-keys"; 137 | if(this.Team == 1) 138 | { 139 | window.document.getElementById("pnlTeam1Keys").appendChild(this.DebKeysElement); 140 | } 141 | else 142 | { 143 | window.document.getElementById("pnlTeam2Keys").appendChild(this.DebKeysElement); 144 | } 145 | this.DebKeysElement.innerHTML = " " 146 | } 147 | 148 | 149 | Player.prototype.debugShowKeysHelper = function(bit) 150 | { 151 | var retVal = ""; 152 | 153 | if(hasFlag(bit,16)) retVal += "+"; 154 | if(hasFlag(bit,32)) retVal += "+"; 155 | if(hasFlag(bit,64)) retVal += "+"; 156 | if(hasFlag(bit,128)) retVal += "+"; 157 | if(hasFlag(bit,256)) retVal += "+"; 158 | if(hasFlag(bit,512)) retVal += "+"; 159 | 160 | return retVal; 161 | } 162 | 163 | 164 | Player.prototype.debugShowDirsHelper = function(bit) 165 | { 166 | var retVal = ""; 167 | if(hasFlag(bit,1) && hasFlag(bit,4)) retVal += this.Direction == 1 ? "" : ""; 168 | if(hasFlag(bit,1) && hasFlag(bit,8)) retVal += this.Direction == 1 ? "" : ""; 169 | if(hasFlag(bit,2) && hasFlag(bit,8)) retVal += this.Direction == 1 ? "" : ""; 170 | if(hasFlag(bit,2) && hasFlag(bit,4)) retVal += this.Direction == 1 ? "" : ""; 171 | 172 | if(!hasFlag(bit,4) && !hasFlag(bit,8) && hasFlag(bit,1)) retVal += this.Direction == 1 ? "" : ""; 173 | if(!hasFlag(bit,4) && !hasFlag(bit,8) && hasFlag(bit,2)) retVal += this.Direction == 1 ? "" : ""; 174 | 175 | if(!hasFlag(bit,1) && !hasFlag(bit,2) && hasFlag(bit,4)) retVal += ""; 176 | if(!hasFlag(bit,1) && !hasFlag(bit,2) && hasFlag(bit,8)) retVal += ""; 177 | 178 | return retVal; 179 | } 180 | 181 | 182 | Player.prototype.debugShowKeys = function() 183 | { 184 | return; 185 | } 186 | 187 | -------------------------------------------------------------------------------- /script/player.input.js: -------------------------------------------------------------------------------- 1 | //returns true if the passed in keys are pressed 2 | Player.prototype.isKeyDown = function(key) 3 | { 4 | return (this.ButtonStates.length > 0) 5 | && (this.ButtonStates[this.ButtonStates.length-1].State[key].Value == BUTTON_STATE.PRESSED); 6 | } 7 | 8 | //returns true if the passed in key state match the current key state 9 | Player.prototype.testButtonState = function(button,state) 10 | { 11 | return (this.ButtonStates.length > 0) 12 | && (this.ButtonStates[this.ButtonStates.length-1].State[key].Value == state); 13 | } 14 | 15 | //returns true if the passed in button state matches the current state 16 | Player.prototype.hasButtonState = function(data) 17 | { 18 | if(!data) 19 | return false; 20 | 21 | var retVal = false; 22 | for(var i = 0; i < data.length; ++i) 23 | { 24 | var moveItem = data[i]; 25 | if(moveItem.State != this.ButtonState[moveItem.Button].Value) 26 | { 27 | return false; 28 | } 29 | } 30 | return true; 31 | } 32 | 33 | 34 | Player.prototype.handleInput = function(frame) 35 | { 36 | if(!this.ForceImmobile) 37 | { 38 | this.checkForAnimation(frame); 39 | } 40 | } 41 | 42 | Player.prototype.clearInput = function(record) 43 | { 44 | for(var i in this.ButtonState) 45 | { 46 | this.ButtonState[i].Value = 0; 47 | this.ButtonState[i].Frame = 0; 48 | } 49 | this.ButtonStates = []; 50 | } 51 | 52 | //Ensures that the buttonStateChange array doesn't get too big 53 | Player.prototype.cleanUpButtonStateChanges = function(frame) 54 | { 55 | if(this.ButtonStates.length > CONSTANTS.MAX_KEYSTATES) 56 | this.ButtonStates = this.ButtonStates.slice(this.ButtonStates.length - CONSTANTS.MAX_KEYSTATES); 57 | 58 | var i = 0; 59 | while(i < this.ButtonStates.length) 60 | { 61 | if(((frame - this.ButtonStates[i].Frame) > CONSTANTS.NBINTERIM_FRAMES) 62 | && this.ButtonStates[i].State[1].Value != BUTTON_STATE.PRESSED 63 | && this.ButtonStates[i].State[2].Value != BUTTON_STATE.PRESSED 64 | && this.ButtonStates[i].State[4].Value != BUTTON_STATE.PRESSED 65 | && this.ButtonStates[i].State[8].Value != BUTTON_STATE.PRESSED 66 | && this.ButtonStates[i].State[16].Value != BUTTON_STATE.PRESSED 67 | && this.ButtonStates[i].State[32].Value != BUTTON_STATE.PRESSED 68 | && this.ButtonStates[i].State[64].Value != BUTTON_STATE.PRESSED 69 | && this.ButtonStates[i].State[128].Value != BUTTON_STATE.PRESSED 70 | && this.ButtonStates[i].State[256].Value != BUTTON_STATE.PRESSED 71 | && this.ButtonStates[i].State[512].Value != BUTTON_STATE.PRESSED 72 | && this.ButtonStates[i].State[1024].Value != BUTTON_STATE.PRESSED) 73 | { 74 | //this.ButtonStates = this.ButtonStates.slice(i+1); 75 | this.ButtonStates.splice(0,i+1); 76 | } 77 | ++i; 78 | } 79 | } 80 | 81 | 82 | 83 | //Simuates pressing keys 84 | Player.prototype.injectInput = function(isDown,bit,frame,funcName) 85 | { 86 | if(bit === null && !!funcName) 87 | { 88 | this[funcName](); 89 | } 90 | else 91 | { 92 | key = null; 93 | for(var a in this.Buttons) 94 | { 95 | if(this.Buttons[a].Bit == bit) 96 | { 97 | key = a; 98 | break; 99 | } 100 | } 101 | 102 | if(!!key) 103 | this.onKeyStateChanged(isDown,key,frame); 104 | } 105 | } 106 | 107 | //Simuates pressing keys 108 | Player.prototype.sendInput = function(input) 109 | { 110 | if(!input || !this.getMatch().getAllowInput()) 111 | return; 112 | 113 | var frame = this.getMatch().getCurrentFrame(); 114 | var key; 115 | for(var i = 0; i < input.length; ++i) 116 | { 117 | key = null; 118 | for(var a in this.Buttons) 119 | { 120 | if(this.Buttons[a].Bit == input[i].Button) 121 | { 122 | key = a; 123 | break; 124 | } 125 | } 126 | 127 | if(!!key) this.onKeyStateChanged(input[i].IsDown,key,frame); 128 | } 129 | } 130 | 131 | //records the current ButtonState 132 | Player.prototype.addCurrentButtonState = function(frame) 133 | { 134 | var state = {}; 135 | for(var i in this.ButtonState) 136 | state[i] = makeButtonState(this.ButtonState[i].Value,this.ButtonState[i].Frame); 137 | 138 | this.ButtonStates.push({State:state,Frame:frame}); 139 | } 140 | 141 | //returns the frame to use for input (used for recording matches) 142 | Player.prototype.getInputFrame = function(frame) 143 | { 144 | return (this.CheckedForAnimationFrame == frame) ? frame + 1 : frame; 145 | } 146 | 147 | //Handles key state changes 148 | Player.prototype.onKeyStateChanged = function(isDown,keyCode,frame) 149 | { 150 | if(!!this.Buttons[keyCode]) 151 | { 152 | var key = this.Buttons[keyCode].Bit; 153 | 154 | if(!!isDown && (this.ButtonState[key].Value == BUTTON_STATE.NONE)) 155 | { 156 | //the button was just pressed 157 | this.ButtonState[key].Value = BUTTON_STATE.PRESSED 158 | this.ButtonState[key].Frame = frame; 159 | } 160 | else if(!isDown && (this.ButtonState[key].Value == BUTTON_STATE.PRESSED)) 161 | { 162 | //the button was released 163 | this.ButtonState[key].Value = BUTTON_STATE.NONE; 164 | this.ButtonState[key].Frame = frame; 165 | } 166 | else 167 | return; 168 | 169 | this.addCurrentButtonState(frame); 170 | 171 | } 172 | //this.User.onKeyStateChanged(isDown,keyCode,frame); 173 | } 174 | 175 | Player.prototype.compareButtonSequence = function(frame,move,input) 176 | { 177 | var mIndex = move.ButtonSequence.length-1; 178 | var iIndex = input.length-1; 179 | var inputItem; 180 | var moveItem; 181 | 182 | 183 | requiredKeys : while((iIndex > -1) && (mIndex > -1)) 184 | { 185 | moveButtons : for(var b = 0; b < move.ButtonSequence[mIndex].length; ++b) 186 | { 187 | var isMatch = false; 188 | 189 | moveItem = move.ButtonSequence[mIndex][b]; 190 | var btn = []; 191 | if(!!moveItem.Button.length) 192 | btn = moveItem.Button; 193 | else 194 | btn.push(moveItem.Button); 195 | 196 | for(var i = 0; i < btn.length; ++i) 197 | { 198 | //inputItem = input[iIndex].State[move.ButtonSequence[mIndex][b].Button]; 199 | inputItem = input[iIndex].State[btn[i]]; 200 | 201 | //is the required button in the proper state? 202 | if(moveItem.State == inputItem.Value) 203 | { 204 | isMatch = true; 205 | //is there a max number of frames 206 | if(!!moveItem.MaxNbFrames && ((frame - inputItem.Frame) > moveItem.MaxNbFrames)) 207 | { 208 | //not ok 209 | return false; 210 | } 211 | //is there a min number of frames 212 | if(!!moveItem.MinNbFrames && ((frame - inputItem.Frame) < moveItem.MinNbFrames)) 213 | { 214 | //not ok 215 | return false; 216 | } 217 | 218 | //if a button matches, then move on to the next button 219 | continue moveButtons; 220 | } 221 | } 222 | //the first time must be a match 223 | if(!isMatch) 224 | { 225 | if(iIndex == input.length-1) 226 | { 227 | return false; 228 | } 229 | //the key is not in the required state, so move to the next element in the user input 230 | --iIndex; 231 | continue requiredKeys; 232 | } 233 | 234 | } 235 | 236 | //all keys at the current location matched, advance in the user input array 237 | --iIndex; 238 | //all keys at the current location matched, advance in the required input array 239 | --mIndex; 240 | 241 | //if we get to the end of the required input, then everything has been ok, so that means we have found a match. 242 | if(mIndex < 0) 243 | { 244 | return true; 245 | } 246 | } 247 | 248 | return false; 249 | } 250 | 251 | 252 | 253 | /*returns true if the player is in a state where the current animation can be interupted with another animation*/ 254 | Player.prototype.allowInterupt = function() 255 | { 256 | return this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_1) 257 | || this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_2) 258 | || this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_3) 259 | || this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_4) 260 | || this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_5) 261 | || this.Flags.Pose.has(POSE_FLAGS.ALLOW_INTERUPT_6) 262 | ; 263 | } 264 | /*Check the current key sequence for a move to execute*/ 265 | Player.prototype.checkForAnimation = function(frame) 266 | { 267 | if(!this.getMatch().getAllowInput()) 268 | return; 269 | if(!!this.CheckedForAnimationFrame == frame) 270 | return; 271 | this.CheckedForAnimationFrame = frame; 272 | 273 | if(this.Flags.Player.has(PLAYER_FLAGS.MOBILE) || (this.allowInterupt() && !this.InteruptAnimation)) 274 | { 275 | for(var i = 0; i < 2; ++i) 276 | { 277 | //copy the original array 278 | var tmpButtons = this.ButtonStates.slice(); 279 | while(tmpButtons.length > 0) 280 | { 281 | var move = i == 0 ? this.findThrow(tmpButtons,frame) : this.findAnimation(tmpButtons,frame); 282 | if(!!move) 283 | { 284 | //was the move chained? 285 | if(move == -1) 286 | return; 287 | 288 | //if IsMisc is set to true, then no animation will be set, but the flags will be read 289 | if(!!move.IsMisc) 290 | { 291 | this.checkFlags(move); 292 | } 293 | //is there no current move, or is the user executing a new move 294 | else if(!this.CurrentAnimation || (this.CurrentAnimation.Animation.BaseAnimation.Name != move.BaseAnimation.Name)) 295 | { 296 | if(!this.setInteruptAnimation(move)) 297 | { 298 | if(move.BaseAnimation.Name == "turn" || move.BaseAnimation.Name == "crouch turn") 299 | this.targetRearEnemy(); 300 | else 301 | this.setCurrentAnimation({Animation:move,StartFrame:frame,Direction:this.Direction}); 302 | } 303 | } 304 | return; 305 | } 306 | 307 | //remove one from the front of the array 308 | tmpButtons.splice(0,1); 309 | } 310 | } 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /script/player.sound.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | Player.prototype.queueDizzy = function() { this.queueSound("audio/misc/dizzy.zzz"); } 4 | Player.prototype.stopDizzyAudio = function() { soundManager_.pause("audio/misc/dizzy.zzz"); } 5 | 6 | Player.prototype.removeQueuedDizzyAudio = function() { soundManager_.stopAny("audio/misc/dizzy.zzz"); } 7 | 8 | 9 | Player.prototype.queueSwingSound = function(value) 10 | { 11 | if(hasFlag(value,SWINGSOUND.HP)) this.queueSound("audio/misc/hp.zzz"); 12 | else if(hasFlag(value,SWINGSOUND.MP)) this.queueSound("audio/misc/mp.zzz"); 13 | else if(hasFlag(value,SWINGSOUND.LP)) this.queueSound("audio/misc/lp.zzz"); 14 | else if(hasFlag(value,SWINGSOUND.HK)) this.queueSound("audio/misc/hk.zzz"); 15 | else if(hasFlag(value,SWINGSOUND.MK)) this.queueSound("audio/misc/mk.zzz"); 16 | else if(hasFlag(value,SWINGSOUND.LK)) this.queueSound("audio/misc/lk.zzz"); 17 | else if(hasFlag(value,SWINGSOUND.SLIDE0)) this.queueSound("audio/misc/slide-0.zzz"); 18 | } 19 | 20 | 21 | 22 | Player.prototype.queueHitSound = function(value) 23 | { 24 | if(!!value.length) 25 | { 26 | for(var i = 0; i < value.length; ++i) 27 | this.queueHitSoundHelper(value[i]); 28 | } 29 | else 30 | { 31 | this.queueHitSoundHelper(value); 32 | } 33 | } 34 | 35 | Player.prototype.queueHitSoundHelper = function(value) 36 | { 37 | if(hasFlag(value,HITSOUND.HP)) this.queueSound("audio/misc/hit-hp.zzz"); 38 | else if(hasFlag(value,HITSOUND.MP)) this.queueSound("audio/misc/hit-mp.zzz"); 39 | else if(hasFlag(value,HITSOUND.LP)) this.queueSound("audio/misc/hit-lp.zzz"); 40 | else if(hasFlag(value,HITSOUND.HP3)) this.queueSound("audio/misc/hit-hp-3.zzz"); 41 | else if(hasFlag(value,HITSOUND.HK)) this.queueSound("audio/misc/hit-hk.zzz"); 42 | else if(hasFlag(value,HITSOUND.MK)) this.queueSound("audio/misc/hit-mk.zzz"); 43 | else if(hasFlag(value,HITSOUND.LK)) this.queueSound("audio/misc/hit-lk.zzz"); 44 | else if(hasFlag(value,HITSOUND.FIRE0)) this.queueSound("audio/misc/fire-0.zzz"); 45 | else if(hasFlag(value,HITSOUND.FIRE1)) this.queueSound("audio/misc/fire-1.zzz"); 46 | } 47 | 48 | 49 | 50 | Player.prototype.queueBlockSound = function() { this.queueSound("audio/misc/block.zzz"); } 51 | Player.prototype.queueBlockProjectileSound = function() { this.queueSound("audio/misc/block-projectile.zzz"); } 52 | Player.prototype.queueGrappleSound = function() { this.queueSound("audio/misc/grapple.zzz"); } 53 | Player.prototype.queueSuperMoveChargeSound = function() { this.queueSound("audio/misc/super-charge.zzz"); } 54 | Player.prototype.queueLightFireSound = function() { this.queueSound("audio/misc/fire-0.zzz"); } 55 | Player.prototype.queueHardFireSound = function() { this.queueSound("audio/misc/fire-1.zzz"); } 56 | 57 | 58 | Player.prototype.queueSound = function(value,volume) 59 | { 60 | soundManager_.queueSound(value,volume); 61 | } 62 | -------------------------------------------------------------------------------- /script/soundmanager.js: -------------------------------------------------------------------------------- 1 | 2 | var CreateSoundManager = function() 3 | { 4 | /*******************************************************/ 5 | /******************* PRIVATE STATE *****************/ 6 | /*******************************************************/ 7 | var items_ = {}; 8 | var sounds_ = []; 9 | var extension_ = ".ogg"; 10 | var id_ = 0; 11 | var sfxManager_ = CreateWebAudioManager(); 12 | var isEnabled_ = BrowserDetect.browser != "Explorer"; 13 | 14 | var GetPath_ = function(path) 15 | { 16 | return path.replace(".zzz",extension_); 17 | } 18 | 19 | var GetElement_ = function(id) 20 | { 21 | return window.document.getElementById(id); 22 | } 23 | 24 | var GetCurrentElement_ = function(path) 25 | { 26 | return GetElement_(items_[path].Elements[items_[path].CurrentChannel]); 27 | } 28 | 29 | 30 | /*******************************************************/ 31 | /******************* PUBLIC STATE *****************/ 32 | /*******************************************************/ 33 | 34 | var SoundManager = function() 35 | { 36 | } 37 | 38 | SoundManager.prototype.getExtension = function() { return extension_; } 39 | SoundManager.prototype.enable = function() { isDisabled_ = false; } 40 | SoundManager.prototype.disable = function() { isDisabled_ = true; } 41 | 42 | /*creates a DOM audio element and loads it with base64 data*/ 43 | SoundManager.prototype.loadBase64 = function(path,nbChannels,defaultVolume,base64Data,loop) 44 | { 45 | if(!!__debugMode || !isEnabled_) return; 46 | 47 | //send all audio to WebAudio by default 48 | if(!!sfxManager_) 49 | { 50 | return sfxManager_.loadBase64(path, nbChannels, defaultVolume, base64Data, loop); 51 | } 52 | 53 | if(!items_[path]) 54 | { 55 | nbChannels = nbChannels || 1; 56 | //nbChannels = 1; 57 | try 58 | { 59 | items_[path] = {Channels:nbChannels,CurrentChannel:0,Elements:[],DefaultVolume:defaultVolume || 1}; 60 | for(var i = 0; i < nbChannels; ++i) 61 | { 62 | var el = new Audio(); 63 | var id = "sound" + id_; 64 | items_[path].Elements[i] = id; 65 | //el.type = "application/ogg"; 66 | el.src = base64Data; 67 | el.load(); 68 | el.id = id; 69 | el.loop = !!loop; 70 | window.document.body.appendChild(el); 71 | 72 | ++id_; 73 | } 74 | 75 | } 76 | catch(err) 77 | { 78 | items_[path] = null; 79 | } 80 | } 81 | 82 | return path; 83 | } 84 | /*creates a DOM audio element and loads it*/ 85 | SoundManager.prototype.load = function(path,nbChannels,defaultVolume) 86 | { 87 | if(!!__debugMode || !isEnabled_) return; 88 | 89 | if(!items_[path]) 90 | { 91 | nbChannels = nbChannels || 1; 92 | //nbChannels = 1; 93 | try 94 | { 95 | items_[path] = {Channels:nbChannels,CurrentChannel:0,Elements:[],DefaultVolume:defaultVolume || 1}; 96 | for(var i = 0; i < nbChannels; ++i) 97 | { 98 | var el = new Audio(); 99 | var id = "sound" + id_; 100 | items_[path].Elements[i] = id; 101 | //el.type = "application/ogg"; 102 | el.src = GetPath_(path) + "?qaz=" + id; 103 | el.load(); 104 | el.id = id; 105 | window.document.body.appendChild(el); 106 | 107 | ++id_; 108 | } 109 | 110 | } 111 | catch(err) 112 | { 113 | items_[path] = null; 114 | } 115 | } 116 | } 117 | 118 | /**/ 119 | SoundManager.prototype.unload = function(path) 120 | { 121 | if(!!items_[path]) 122 | { 123 | for(var i = 0; i < items_[path].Channels; ++i) 124 | { 125 | var element = GetElement_(items_[path].Elements[i]); 126 | element.pause(); 127 | window.document.body.removeChild(element); 128 | } 129 | items_[path] = null; 130 | } 131 | } 132 | 133 | /**/ 134 | SoundManager.prototype.setVolume = function(path, value) 135 | { 136 | if(!isEnabled_) return; 137 | if(!!items_[path]) 138 | { 139 | for(var i = 0; i < items_[path].Channels; ++i) 140 | GetElement_(items_[path].Elements[i]).volume = value; 141 | } 142 | } 143 | 144 | /**/ 145 | SoundManager.prototype.getVolume = function(path) 146 | { 147 | if(!isEnabled_) return; 148 | if(!!items_[path]) 149 | { 150 | return GetCurrentElement_(path).volume; 151 | } 152 | return 0; 153 | } 154 | 155 | /**/ 156 | SoundManager.prototype.isPlaying = function(path) 157 | { 158 | if(!isEnabled_) return; 159 | if(!!items_[path]) 160 | { 161 | return !GetCurrentElement_(path).paused; 162 | } 163 | return 0; 164 | } 165 | 166 | 167 | /**/ 168 | SoundManager.prototype.restart = function(path,loops) 169 | { 170 | if(!isEnabled_) return; 171 | if(!!items_[path]) 172 | { 173 | var el = GetCurrentElement_(path); 174 | if(!!el.duration) 175 | el.currentTime = 0; 176 | el.volume = items_[path].DefaultVolume; 177 | } 178 | else if(!!sfxManager_) 179 | { 180 | sfxManager_.stop(path); 181 | sfxManager_.play(path); 182 | } 183 | } 184 | 185 | /**/ 186 | SoundManager.prototype.play = function(path,loops) 187 | { 188 | if(!isEnabled_) return; 189 | if(!!items_[path]) 190 | { 191 | /*go to the next channel*/ 192 | if(++items_[path].CurrentChannel >= items_[path].Channels) 193 | items_[path].CurrentChannel = 0; 194 | 195 | /*start playing from the time = 0*/ 196 | var el = GetCurrentElement_(path); 197 | if(!!el.duration) el.currentTime = 0; 198 | if(!!loops) el.loop = true; 199 | 200 | el.volume = items_[path].DefaultVolume; 201 | el.play(); 202 | 203 | if(!!el.error) 204 | { 205 | Alert(path); 206 | Alert(el.error); 207 | items_[path] = null; 208 | return; 209 | } 210 | } 211 | else if(!!sfxManager_) 212 | { 213 | sfxManager_.play(path); 214 | } 215 | 216 | } 217 | 218 | /*sets the volume and plays the sound*/ 219 | SoundManager.prototype.playSFX = function(obj,loops) 220 | { 221 | if(!isEnabled_) return; 222 | var path = obj.Value; 223 | if(!!items_[path]) 224 | { 225 | /*go to the next channel*/ 226 | if(++items_[path].CurrentChannel >= items_[path].Channels) 227 | items_[path].CurrentChannel = 0; 228 | /*start playing from time 0*/ 229 | var el = GetCurrentElement_(path); 230 | if(!!el.currentTime) 231 | el.currentTime = 0; 232 | 233 | //el.loop = !!loops; 234 | //el.volume = obj.Volume; 235 | 236 | el.play(); 237 | 238 | if(!!el.error) 239 | { 240 | Alert(path); 241 | Alert(el.error.code); 242 | items_[path] = null; 243 | return; 244 | } 245 | } 246 | else if(!!sfxManager_) 247 | { 248 | sfxManager_.play(obj.Value); 249 | } 250 | } 251 | 252 | 253 | /**/ 254 | SoundManager.prototype.replay = function(path) 255 | { 256 | if(!isEnabled_) return; 257 | if(!!items_[path]) 258 | { 259 | var el = GetCurrentElement_(path); 260 | el.pause(); 261 | el.currentTime = 0; 262 | el.volume = items_[path].DefaultVolume; 263 | el.play(); 264 | } 265 | } 266 | 267 | 268 | /**/ 269 | SoundManager.prototype.pause = function(path) 270 | { 271 | if(!isEnabled_) return; 272 | if(!!items_[path]) 273 | { 274 | var el = GetCurrentElement_(path); 275 | el.pause(); 276 | } 277 | else if(!!sfxManager_) 278 | { 279 | sfxManager_.pause(path); 280 | } 281 | 282 | } 283 | 284 | /**/ 285 | SoundManager.prototype.stop = function(path) 286 | { 287 | if(!isEnabled_) return; 288 | if(!!items_[path]) 289 | { 290 | var el = GetCurrentElement_(path); 291 | el.pause(); 292 | } 293 | if(!!sfxManager_) 294 | { 295 | sfxManager_.stop(path); 296 | } 297 | } 298 | 299 | /**/ 300 | SoundManager.prototype.pauseAll = function() 301 | { 302 | } 303 | 304 | /**/ 305 | SoundManager.prototype.resumeAll = function() 306 | { 307 | } 308 | 309 | /**/ 310 | SoundManager.prototype.resume = function(path) 311 | { 312 | if(!isEnabled_) return; 313 | if(!!items_[path]) 314 | { 315 | var el = GetCurrentElement_(path); 316 | if(!!el.paused) 317 | el.play(); 318 | } 319 | else if(!!sfxManager_) 320 | { 321 | sfxManager_.play(path); 322 | } 323 | 324 | } 325 | /**/ 326 | SoundManager.prototype.playOrResume = function(path,loops) 327 | { 328 | if(!isEnabled_) return; 329 | if(!!items_[path]) 330 | { 331 | var el = GetCurrentElement_(path); 332 | if(!!el.paused) 333 | { 334 | el.loop = !!loops; 335 | el.play(); 336 | } 337 | else 338 | this.play(path,loops); 339 | } 340 | else if(!!sfxManager_) 341 | { 342 | sfxManager_.play(path); 343 | } 344 | 345 | } 346 | 347 | /**/ 348 | SoundManager.prototype.preload = function() 349 | { 350 | } 351 | 352 | 353 | /**/ 354 | SoundManager.prototype.queueSound = function(value,volume,delay) 355 | { 356 | if(!isEnabled_) return; 357 | sounds_[_c3(value, "_", delay)] = {Value:value, Volume:volume||1, Frame:game_.getCurrentFrame() + (delay||0)}; 358 | } 359 | 360 | 361 | /**/ 362 | SoundManager.prototype.stopAny = function(value) 363 | { 364 | if(!isEnabled_) return; 365 | for(var i in sounds_) 366 | if(sounds_[i].Value == value) 367 | delete sounds_[i]; 368 | } 369 | 370 | 371 | /**/ 372 | SoundManager.prototype.reset = function() 373 | { 374 | if(!isEnabled_) 375 | return; 376 | 377 | for(var i in sounds_) 378 | { 379 | this.stop(sounds_[i].Value); 380 | delete sounds_[i]; 381 | } 382 | 383 | if(!!sfxManager_) 384 | { 385 | sfxManager_.stopAll(); 386 | } 387 | } 388 | 389 | 390 | /**/ 391 | SoundManager.prototype.frameMove = function(frame) 392 | { 393 | } 394 | 395 | /**/ 396 | SoundManager.prototype.render = function(frame) 397 | { 398 | if(!isEnabled_) return; 399 | for(var i in sounds_) 400 | { 401 | if(frame >= sounds_[i].Frame) 402 | { 403 | this.playSFX(sounds_[i]); 404 | delete sounds_[i]; 405 | } 406 | } 407 | } 408 | 409 | return new SoundManager(); 410 | } 411 | var soundManager_ = null; 412 | -------------------------------------------------------------------------------- /script/stuff-loader.js: -------------------------------------------------------------------------------- 1 | var CreateUtils = function() 2 | { 3 | var loadingCount_ = 0; 4 | 5 | var Utils = function() 6 | { 7 | } 8 | 9 | Utils.prototype.addBase64Audio = function(src, callbackFn, context) 10 | { 11 | src = "script/audio/" + src.replace(".js",soundManager_.getExtension()) + ".js"; 12 | return this.addScript(src,callbackFn,context); 13 | } 14 | 15 | Utils.prototype.addBase64Image = function(src, callbackFn, context) 16 | { 17 | return this.addScript(src,callbackFn,context); 18 | } 19 | 20 | Utils.prototype.addScript = function(src, callbackFn, context) 21 | { 22 | if(!window.document.getElementById(src)) 23 | { 24 | var script = window.document.createElement("script"); 25 | script.id = src; 26 | script.src = src; 27 | script.type = "text/javascript" 28 | script.onload = (function(startTime,onload,thisValue) 29 | { 30 | return function() 31 | { 32 | var duration = Date.now() - startTime; 33 | if(!!onload) 34 | { 35 | if(!!thisValue) 36 | onload.call(thisValue); 37 | else 38 | onload(); 39 | } 40 | } 41 | })(Date.now(),callbackFn,context); 42 | script.onerror = function() 43 | { 44 | Alert("not found"); 45 | } 46 | window.document.body.appendChild(script); 47 | return true; 48 | } 49 | else 50 | return false; 51 | } 52 | 53 | Utils.prototype.releaseArray = function(arr) 54 | { 55 | while(arr.length > 0) 56 | { 57 | if(!!arr[0].release) 58 | arr[0].release(); 59 | 60 | delete arr[0]; 61 | arr.splice(0,1); 62 | } 63 | } 64 | 65 | Utils.prototype.clearElement = function(element) 66 | { 67 | if(!!element.src) 68 | element.src = ""; 69 | if(!!element.className) 70 | element.className = ""; 71 | if(!!element.style) 72 | element.style.backgroundImage = ""; 73 | } 74 | 75 | Utils.prototype.removeFromDOM = function(element) 76 | { 77 | if(!!element) 78 | { 79 | while(element.children.length > 0) 80 | utils_.removeChildrenFromDOM(element.children[0]); 81 | 82 | var parentNode = element.parentNode; 83 | if(!!parentNode) 84 | { 85 | this.clearElement(element); 86 | parentNode.removeChild(element); 87 | } 88 | else 89 | { 90 | this.clearElement(element); 91 | element = null; 92 | } 93 | } 94 | } 95 | 96 | Utils.prototype.removeChildrenFromDOM = function(element,keepOrginalElement) 97 | { 98 | if(!!element) 99 | { 100 | if(!element.parentNode) 101 | { 102 | if(!keepOrginalElement) 103 | { 104 | this.clearElement(element); 105 | element = null; 106 | } 107 | } 108 | else if(element.children.length == 0) 109 | { 110 | if(!keepOrginalElement) 111 | { 112 | this.clearElement(element); 113 | element.parentNode.removeChild(element); 114 | } 115 | } 116 | else 117 | { 118 | while(element.children.length > 0) 119 | { 120 | utils_.removeChildrenFromDOM(element.children[0]); 121 | } 122 | } 123 | } 124 | } 125 | 126 | return new Utils(); 127 | } 128 | var utils_ = CreateUtils(); 129 | 130 | 131 | 132 | var CreateStuffLoader = function() 133 | { 134 | var stuff_ = {}; 135 | var nbElements_ = 0; 136 | var callback_ = null; 137 | var context_ = null; 138 | var reportProgressCallback_ = null; 139 | 140 | var Report_ = function() 141 | { 142 | if(!!reportProgressCallback_) 143 | { 144 | reportProgressCallback_.call(context_ || window, nbElements_); 145 | } 146 | } 147 | 148 | var OnDone_ = function(loader,index) 149 | { 150 | /*every time something finishes loading, this function will be executed*/ 151 | if(!--nbElements_) 152 | { 153 | if(!!callback_) 154 | { 155 | callback_.call(context_ || window); 156 | } 157 | //stuff_ = {}; 158 | 159 | //callback_ = null; 160 | } 161 | if(!!stuff_[index]) 162 | { 163 | stuff_[index].State = LOADING_STATES.DONE; 164 | } 165 | Report_(); 166 | } 167 | 168 | 169 | var DownloadImage_ = function(index) 170 | { 171 | if(!window.document.images.namedItem(index)) 172 | { 173 | /*add image to the DOM, but off screen*/ 174 | var img = new Image(); 175 | img.onload = CreateOnDoneCallback_(index); 176 | img.id = index; 177 | img.style.position = "absolute"; 178 | img.style.display = "none"; 179 | img.style.top = "10000px"; 180 | img.src = stuff_[index].Src; 181 | //window.document.body.appendChild(img); 182 | } 183 | else 184 | { 185 | CreateOnDoneCallback_(index)(); 186 | } 187 | } 188 | 189 | var DownloadBase64Image_ = function(index) 190 | { 191 | if(!utils_.addBase64Image(stuff_[index].Src, CreateOnDoneCallback_(index))) 192 | OnDone_(null,index); 193 | } 194 | 195 | 196 | var DownloadBase64Audio_ = function(index) 197 | { 198 | if(!utils_.addBase64Audio(stuff_[index].Src, CreateOnDoneCallback_(index))) 199 | OnDone_(null,index); 200 | } 201 | 202 | 203 | var DownloadScript_ = function(index) 204 | { 205 | if(!utils_.addScript(stuff_[index].Src, CreateOnDoneCallback_(index))) 206 | OnDone_(null,index); 207 | } 208 | 209 | /***********************/ 210 | var StuffLoader = function() 211 | { 212 | } 213 | 214 | 215 | StuffLoader.prototype.queue = function(src,type) 216 | { 217 | if(!stuff_[src]) 218 | { 219 | stuff_[src] = {Type:type,State:LOADING_STATES.WAITING,Src:src}; 220 | } 221 | } 222 | 223 | StuffLoader.prototype.start = function(reportProgressCallback, callback, context) 224 | { 225 | for(var i in stuff_) 226 | ++nbElements_; 227 | 228 | if(!nbElements_) 229 | { 230 | callback.call(context || window); 231 | return; 232 | } 233 | 234 | callback_ = callback; 235 | context_ = context; 236 | reportProgressCallback_ = reportProgressCallback; 237 | 238 | 239 | Report_(); 240 | for(var i in stuff_) 241 | { 242 | if(stuff_[i].State == LOADING_STATES.WAITING) 243 | { 244 | switch (stuff_[i].Type) 245 | { 246 | case RESOURCE_TYPES.IMAGE: { DownloadImage_(i); break; } 247 | case RESOURCE_TYPES.BASE64AUDIO: { DownloadBase64Audio_(i); break; } 248 | case RESOURCE_TYPES.BASE64IMAGE: { DownloadBase64Image_(i); break; } 249 | case RESOURCE_TYPES.SCRIPT: { DownloadScript_(i); break; } 250 | }; 251 | } 252 | } 253 | stuff_ = {}; 254 | } 255 | 256 | /***********************/ 257 | var instance = new StuffLoader(); 258 | 259 | var CreateOnDoneCallback_ = (function(thisRef) 260 | { 261 | return function(index) 262 | { 263 | return function() 264 | { 265 | OnDone_(thisRef,index); 266 | } 267 | } 268 | })(instance); 269 | 270 | return instance; 271 | } 272 | var stuffLoader_ = CreateStuffLoader(); -------------------------------------------------------------------------------- /script/team.js: -------------------------------------------------------------------------------- 1 | var Team = function(num) 2 | { 3 | var cursor_ = 0; 4 | var lastCursor_ = -1; 5 | var teamNum_ = num; 6 | var portriatImg_ = window.document.getElementById("portriatTeam" + num); 7 | var nameImg_ = window.document.getElementById("nameTeam" + num); 8 | var healthbar_ = CreateHealthBar("pnlHealthbarTeam" + num,num); 9 | var energybar_ = CreateEnergyBar("pnlEnergyBarTeam" + num + "Container",num); 10 | var comboText_ = null; 11 | var nbHitsText_ = null; 12 | var currentCombo_ = 0; 13 | var currentComboRefCount_ = 0; 14 | var players_ = []; 15 | var wins_ = 0; 16 | var loses_ = 0; 17 | var draws_ = 0; 18 | var isAI_ = true; 19 | 20 | if(!!Team) return new Team(); 21 | 22 | var Team = function(num) 23 | { 24 | players_ = []; 25 | } 26 | 27 | Team.prototype.getGame = function() { return game_; } 28 | Team.prototype.getPlayer = function(value) { return players_[value]; } 29 | Team.prototype.getPlayers = function() { return players_; } 30 | Team.prototype.getNbPlayers = function() { return players_.length; } 31 | Team.prototype.getIsAI = function() { return isAI_; } 32 | Team.prototype.setPlayers = function(value) 33 | { 34 | isAI_ = value.every(function(a) 35 | { 36 | return !!a && a.User.IsAI; 37 | }); 38 | 39 | players_ = value; 40 | this.setPlayerIndexes(); 41 | } 42 | Team.prototype.addPlayer = function(player, doSetup, isAi) 43 | { 44 | if(!!isAi) 45 | { 46 | player.enableAI(); 47 | isAI_ = true; 48 | } 49 | else if(!player.User.IsAI) 50 | isAI_ = false; 51 | 52 | players_.push(player); 53 | this.setPlayerIndexes(); 54 | 55 | if(!!doSetup) 56 | game_.getMatch().setupPlayer(player, teamNum_); 57 | } 58 | Team.prototype.setPlayerIndexes = function() 59 | { 60 | for(var i = 0, length = players_.length; i < length; ++i) 61 | players_[i].setIndex(i); 62 | } 63 | Team.prototype.getCursor = function() { return cursor_; } 64 | Team.prototype.setCursor = function(value) { cursor_ = value; } 65 | Team.prototype.getLastCursor = function() { return lastCursor_; } 66 | Team.prototype.setLastCursor = function(value) { lastCursor_ = value; } 67 | Team.prototype.getTeamNum = function() { return teamNum_; } 68 | Team.prototype.setTeamNum = function(value) { teamNum_ = value; } 69 | Team.prototype.getPortriatImg = function() { return portriatImg_; } 70 | Team.prototype.setPortriatImg = function(value) { portriatImg_ = value; } 71 | Team.prototype.getNameImg = function() { return nameImg_; } 72 | Team.prototype.setNameImg = function(value) { nameImg_ = value; } 73 | Team.prototype.getHealthbar = function() { return healthbar_; } 74 | Team.prototype.setHealthbar = function(value) { healthbar_ = value; } 75 | Team.prototype.getEnergybar = function() { return energybar_; } 76 | Team.prototype.setEnergybar = function(value) { energybar_ = value; } 77 | Team.prototype.getComboText = function() { return comboText_; } 78 | Team.prototype.setComboText = function(value) { comboText_ = value; } 79 | Team.prototype.setNbHitText = function(value) { nbHitsText_ = value; } 80 | Team.prototype.getCurrentCombo = function() { return currentCombo_; } 81 | Team.prototype.setCurrentCombo = function(value) { currentCombo_ = value; } 82 | Team.prototype.incCurrentCombo = function() { ++currentCombo_; } 83 | Team.prototype.getCurrentComboRefCount = function() { return currentComboRefCount_; } 84 | Team.prototype.setCurrentComboRefCount = function(value) { currentComboRefCount_ = value; } 85 | Team.prototype.incCurrentComboRefCount = function() { ++currentComboRefCount_; } 86 | Team.prototype.getWins = function() { return wins_; } 87 | Team.prototype.getLoses = function() { return loses_; } 88 | Team.prototype.getDraws = function() { return draws_; } 89 | 90 | Team.prototype.enableStoryMode = function() 91 | { 92 | for(var i = 0; i < players_.length; ++i) 93 | players_[i].User.enableStoryMode(); 94 | } 95 | 96 | Team.prototype.advanceStoryMode = function() 97 | { 98 | for(var i = 0; i < players_.length; ++i) 99 | players_[i].User.advanceStoryMode(); 100 | } 101 | 102 | Team.prototype.disableStoryMode = function() 103 | { 104 | for(var i = 0; i < players_.length; ++i) 105 | { 106 | players_[i].User.disableStoryMode(); 107 | players_[i].User.reset(); 108 | } 109 | } 110 | 111 | Team.prototype.onDrawRound = function() 112 | { 113 | for(var i = 0; i < players_.length; ++i) 114 | players_[i].User.onDrawRound(); 115 | 116 | ++draws_; 117 | } 118 | 119 | Team.prototype.onWonRound = function(frame) 120 | { 121 | for(var i = 0; i < players_.length; ++i) 122 | { 123 | players_[i].User.onWonRound(); 124 | players_[i].justWon(frame); 125 | } 126 | 127 | ++wins_; 128 | } 129 | 130 | Team.prototype.onLostRound = function() 131 | { 132 | for(var i = 0; i < players_.length; ++i) 133 | players_[i].User.onLostRound(); 134 | 135 | ++loses_; 136 | } 137 | 138 | Team.prototype.forceLose = function(attackDirection) 139 | { 140 | for(var i = 0; i < players_.length; ++i) 141 | players_[i].forceLose(attackDirection); 142 | } 143 | 144 | Team.prototype.init = function() 145 | { 146 | portriatImg_.style.display = ""; 147 | nameImg_.style.display = ""; 148 | healthbar_.init(); 149 | energybar_.init(); 150 | wins_ = 0; 151 | loses_ = 0; 152 | draws_ = 0; 153 | 154 | /* 155 | imageLookup_.getBgB64(portriatImg_,"images/misc/char-sprites.png"); 156 | imageLookup_.getBgB64(nameImg_,"images/misc/char-sprites.png"); 157 | */ 158 | this.hide(); 159 | } 160 | 161 | 162 | 163 | Team.prototype.incComboRefCount = function() 164 | { 165 | this.incCurrentComboRefCount(); 166 | } 167 | 168 | 169 | Team.prototype.decComboRefCount = function() 170 | { 171 | this.setCurrentComboRefCount(Math.max(this.getCurrentComboRefCount() - 1, 0)); 172 | if(!this.getCurrentComboRefCount()) 173 | this.setCurrentCombo(0); 174 | } 175 | 176 | Team.prototype.incCombo = function() 177 | { 178 | this.incCurrentCombo(); 179 | if(this.getCurrentCombo() > 1) 180 | this.writeCombo(this.getCurrentCombo()); 181 | } 182 | 183 | 184 | Team.prototype.initText = function() 185 | { 186 | comboText_ = game_.addManagedText("pnlTeam" + this.getTeamNum() + "ComboText",0,170,"font2", teamNum_ == 2); 187 | nbHitsText_ = game_.addManagedText("pnlTeam" + this.getTeamNum() + "NbHitsText",0,170,"font3", teamNum_ == 2); 188 | } 189 | 190 | 191 | Team.prototype.getNbHitsText = function(nbHits) 192 | { 193 | if(nbHits == 2) return "GOOD !"; 194 | else if(nbHits == 3) return "GOOD !!"; 195 | else if(nbHits == 4) return "GREAT !"; 196 | else if(nbHits == 5) return "GREAT !!"; 197 | else if(nbHits == 6) return "VERY GOOD !"; 198 | else if(nbHits == 7) return "VERY GOOD !!"; 199 | else if(nbHits == 8) return "WONDERFUL !"; 200 | else if(nbHits == 9) return "WONDERFUL !!"; 201 | else if(nbHits == 10) return "FANTASTIC !"; 202 | else if(nbHits == 11) return "FANTASTIC !!"; 203 | else if(nbHits == 12) return "MARVELOUS !"; 204 | else if(nbHits == 13) return "MARVELOUS !!"; 205 | else if(nbHits == 14) return "MARVELOUS !!!"; 206 | //lets add some more 207 | else if(nbHits == 15) return "AWESOME !!"; 208 | else if(nbHits == 16) return "AWESOME !!!"; 209 | else if(nbHits == 17) return "VERY AWESOME!!"; 210 | else if(nbHits == 18) return "VERY AWESOME !!!"; 211 | else if(nbHits == 19) return "OUTSTANDING !!"; 212 | else if(nbHits == 20) return "OUTSTANDING !!!"; 213 | else return "DECENT !!!"; 214 | } 215 | 216 | 217 | Team.prototype.writeCombo = function(nbHits) 218 | { 219 | comboText_.change(nbHits + TEXT.HIT_COMBO,10,game_.getCurrentFrame() + CONSTANTS.COMBO_TEXT_LIFE); 220 | this.writeText(this.getNbHitsText(nbHits)); 221 | } 222 | 223 | 224 | Team.prototype.writeText = function(text) 225 | { 226 | nbHitsText_.change(text,10,game_.getCurrentFrame() + CONSTANTS.TEXT_DELAY + CONSTANTS.TEXT_LIFE,game_.getCurrentFrame() + CONSTANTS.TEXT_DELAY,true,30); 227 | } 228 | 229 | /*remove any DOM element that was added by this instance*/ 230 | Team.prototype.release = function() 231 | { 232 | portriatImg_.style.display = "none"; 233 | nameImg_.style.display = "none"; 234 | if(!!comboText_) 235 | { 236 | comboText_.hideNow(); 237 | comboText_ = null; 238 | } 239 | if(!!nbHitsText_) 240 | { 241 | nbHitsText_.hideNow(); 242 | nbHitsText_ = null; 243 | } 244 | healthbar_.release(); 245 | energybar_.release(); 246 | 247 | utils_.releaseArray(players_); 248 | this.setCursor(0); 249 | } 250 | 251 | Team.prototype.show = function() 252 | { 253 | for(var i = 0; i < players_.length; ++i) 254 | players_[i].show(); 255 | 256 | portriatImg_.parentNode.style.display = ""; 257 | } 258 | 259 | Team.prototype.hide = function() 260 | { 261 | for(var i = 0; i < players_.length; ++i) 262 | players_[i].hide(); 263 | 264 | portriatImg_.parentNode.style.display = "none"; 265 | } 266 | 267 | Team.prototype.pause = function() 268 | { 269 | for(var i = 0; i < players_.length; ++i) 270 | players_[i].pause(); 271 | } 272 | 273 | Team.prototype.resume = function() 274 | { 275 | for(var i = 0; i < players_.length; ++i) 276 | players_[i].resume(); 277 | } 278 | 279 | Team.prototype.preFrameMove = function(frame) 280 | { 281 | for(var i = 0; i < players_.length; ++i) 282 | players_[i].onPreFrameMove(frame); 283 | } 284 | 285 | /**/ 286 | Team.prototype.frameMove = function(frame, x, y, allowInput) 287 | { 288 | if(frame % 100 == 0) 289 | this.setCursor(((cursor_ + 1) < players_.length) ? (cursor_+1) : 0); 290 | 291 | for(var i = 0; i < players_.length; ++i) 292 | { 293 | if(!!allowInput) 294 | { 295 | players_[i].handleAI(frame); 296 | players_[i].handleInput(frame); 297 | } 298 | players_[i].onFrameMove(frame,x,y); 299 | } 300 | 301 | healthbar_.frameMove(frame); 302 | energybar_.frameMove(frame); 303 | } 304 | 305 | Team.prototype.preRender = function(frame) 306 | { 307 | for(var i = 0; i < players_.length; ++i) 308 | players_[i].preRender(frame); 309 | } 310 | 311 | /* Shows details about the players on the team */ 312 | Team.prototype.render = function(frame,deltaX) 313 | { 314 | if(cursor_ != lastCursor_) 315 | { 316 | this.setLastCursor(cursor_); 317 | var player = this.getPlayer(cursor_); 318 | if(!!player) 319 | { 320 | spriteLookup_.set(nameImg_, player.getNameImageSrc()); 321 | spriteLookup_.set(portriatImg_, player.getPortriatImageSrc()); 322 | } 323 | } 324 | for(var i = 0; i < players_.length; ++i) 325 | players_[i].render(frame,deltaX); 326 | 327 | energybar_.render(frame); 328 | healthbar_.render(frame); 329 | } 330 | 331 | return new Team(num); 332 | } -------------------------------------------------------------------------------- /script/vcr.js: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /script/webAudioManager.js: -------------------------------------------------------------------------------- 1 | //a wrapper over the webkit's Web Audio API 2 | 3 | var CreateWebAudioManager = function() 4 | { 5 | if(!window.AudioContext && !window.webkitAudioContext) 6 | return null; 7 | 8 | var getWebAudioContext = function() 9 | { 10 | if(!!window.AudioContext) 11 | return new AudioContext(); 12 | else 13 | return new webkitAudioContext(); 14 | } 15 | 16 | //private 17 | var context_ = getWebAudioContext(); 18 | var items_ = {}; 19 | var sounds_ = []; 20 | var extension_ = ".ogg"; 21 | var id_ = 0; 22 | var nbLoading_ = 0; 23 | var maxNbLoading_ = 0; 24 | var isEnabled_ = BrowserDetect.browser != "Explorer"; 25 | var pnlAudio = window.document.getElementById("pnlAudio"); 26 | 27 | 28 | //public 29 | var WebAudioManager = function() 30 | { 31 | this.init(); 32 | } 33 | 34 | WebAudioManager.prototype.init = function() 35 | { 36 | if(!!context_) 37 | return; 38 | 39 | var createWebAudioContext = (function(context) 40 | { 41 | return function() 42 | { 43 | context = getWebAudioContext(); 44 | } 45 | })(context_); 46 | 47 | if(!!window.attachEvent) 48 | { 49 | window.attachEvent('onload', createWebAudioContext, true); 50 | } 51 | else 52 | { 53 | window.addEventListener('load', createWebAudioContext, true); 54 | } 55 | } 56 | 57 | WebAudioManager.prototype.isLoading = function() { return nbLoading_ != maxNbLoading_; } 58 | 59 | WebAudioManager.prototype.onLoadingChanged = function() 60 | { 61 | if(nbLoading_ != maxNbLoading_) 62 | { 63 | pnlAudio.innerHTML = nbLoading_ + "/" + maxNbLoading_; 64 | pnlAudio.className = "loading"; 65 | } 66 | else 67 | { 68 | pnlAudio.className = "done-loading"; 69 | pnlAudio.innerHTML = "done"; 70 | game_.onAudioDoneLoading(); 71 | } 72 | } 73 | 74 | WebAudioManager.prototype.onStartLoading = function() 75 | { 76 | ++maxNbLoading_; 77 | this.onLoadingChanged(); 78 | game_.onAudioLoading(); 79 | } 80 | 81 | WebAudioManager.prototype.onDoneLoading = function() 82 | { 83 | ++nbLoading_; 84 | this.onLoadingChanged(); 85 | } 86 | 87 | WebAudioManager.prototype.setBuffer = function(key, thisRef) 88 | { 89 | return function(buffer) 90 | { 91 | items_[key].Elements[0] = buffer; 92 | thisRef.onDoneLoading(); 93 | } 94 | } 95 | 96 | WebAudioManager.prototype.onError = function(key, thisRef) 97 | { 98 | return function(err) 99 | { 100 | console.log("Error loaing [" + key + "]. " + err); 101 | thisRef.onDoneLoading(); 102 | } 103 | } 104 | 105 | WebAudioManager.prototype.loadBase64 = function(path,nbChannels,defaultVolume,base64Data,loop) 106 | { 107 | if(!!__debugMode || !isEnabled_) return; 108 | if(!items_[path]) 109 | { 110 | //nbChannels = nbChannels || 1; 111 | nbChannels = 1; 112 | try 113 | { 114 | items_[path] = { 115 | Channels:nbChannels 116 | , CurrentChannel:0 117 | , Elements:[] 118 | , Source: null 119 | , DefaultVolume:defaultVolume || 1 120 | , Loops: loop || false 121 | , PausedAt: 0 122 | , StartedAt: 0 123 | , StartOffset : 0 124 | }; 125 | for(var i = 0; i < nbChannels; ++i) 126 | { 127 | this.onStartLoading(); 128 | var byteArray = Base64Binary.decodeArrayBuffer(base64Data.replace("data:audio/ogg;base64,","")); 129 | context_.decodeAudioData(byteArray, this.setBuffer(path, this), this.onError(path, this)); 130 | } 131 | 132 | } 133 | catch(err) 134 | { 135 | items_[path] = null; 136 | } 137 | } 138 | 139 | return path; 140 | } 141 | 142 | //plays the sound 143 | WebAudioManager.prototype.play = function(path) 144 | { 145 | if(!isEnabled_) 146 | return; 147 | 148 | if(!!items_[path]) 149 | { 150 | var buffer = items_[path].Elements[0]; 151 | if(!!buffer && !items_[path].IsPlaying) 152 | { 153 | var source = context_.createBufferSource(); 154 | source.buffer = buffer; 155 | source.loop = items_[path].Loops 156 | source.connect(context_.destination); 157 | 158 | source.start(0, items_[path].StartOffset % buffer.duration); 159 | items_[path].Source = source; 160 | items_[path].StartedAt = context_.currentTime; 161 | 162 | //enure we can't play looping sounds (theme music) multiple times! 163 | if(items_[path].Loops) 164 | items_[path].IsPlaying = true; 165 | } 166 | } 167 | } 168 | 169 | 170 | // 171 | WebAudioManager.prototype.pause = function(path) 172 | { 173 | if(!!items_[path]) 174 | { 175 | var buffer = items_[path].Elements[0]; 176 | if(!!buffer) 177 | { 178 | var source = items_[path].Source; 179 | if(!!source) 180 | { 181 | items_[path].StartOffset += context_.currentTime - items_[path].StartedAt; 182 | source.disconnect(); 183 | source.stop(); 184 | } 185 | items_[path].Source = null; 186 | items_[path].IsPlaying = false; 187 | } 188 | } 189 | } 190 | 191 | 192 | // 193 | WebAudioManager.prototype.stop = function(path) 194 | { 195 | if(!!items_[path]) 196 | { 197 | this.pause(path); 198 | items_[path].StartOffset = 0; 199 | } 200 | } 201 | 202 | 203 | // 204 | WebAudioManager.prototype.stopAll = function() 205 | { 206 | for(var i in items_) 207 | { 208 | this.stop(i); 209 | } 210 | } 211 | 212 | 213 | return new WebAudioManager(); 214 | } 215 | --------------------------------------------------------------------------------