• iozzz
    了解作者
  • HTML
    开发工具
  • 3.4MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2020-09-02 14:59
    上传日期
飞机大战 html5 canvas源码 可供研究及游戏体验
html5-fly.zip
  • html5-fly
  • enemy_small_4.png
    1.1KB
  • Sound.js
    3.4KB
  • sky.jpg
    40KB
  • enemy_artifact_2.png
    3.7KB
  • ship_down_3.png
    4.5KB
  • ship_death_7.png
    1.7KB
  • splode_1.png
    1.5KB
  • Collision.js
    1.1KB
  • Keyboard.js
    1.3KB
  • splode_2.png
    2.5KB
  • starfield.jpg
    82.4KB
  • ship_up_1.png
    6.4KB
  • ship_up_3.png
    5KB
  • ship_death_3.png
    6.9KB
  • level_1_loop.ogg
    686.8KB
  • enemy_small_2.png
    1.1KB
  • enemy_small.png
    1005B
  • play.html
    21.3KB
  • gun_image.png
    2.2KB
  • ship_death_6.png
    8.7KB
  • splode_6.png
    1.5KB
  • speed_image.png
    1.9KB
  • artifact_skull.png
    3.7KB
  • loading_music.ogg
    122.3KB
  • Laser.js
    1.8KB
  • splode_4.png
    3.7KB
  • FloatyText.js
    934B
  • EnemyShot.js
    2.2KB
  • ship_death_5.png
    8.3KB
  • shot_image.png
    663B
  • gem_image.png
    2.4KB
  • Background.js
    1.3KB
  • boss_loop.ogg
    620.2KB
  • AfterEffect.js
    2.3KB
  • splode_7.png
    998B
  • ship_death_1.png
    6.8KB
  • splash_screen.jpg
    46.9KB
  • LevelDirector.js
    19.2KB
  • enemy_small_special.png
    1KB
  • artifact_chard.png
    6.8KB
  • foreground.png
    159.4KB
  • enemy_small_4_special.png
    1KB
  • command_ship.png
    2.6KB
  • Ship.js
    9.9KB
  • Loader.js
    3.9KB
  • foreground_light.png
    170.1KB
  • Sortie.js
    831B
  • Enemy.js
    6.3KB
  • splode_3.png
    3.3KB
  • ship_death_2.png
    6.8KB
  • Shot.js
    1.6KB
  • level_1_preloop.ogg
    266.8KB
  • enemy_small_2_special.png
    1.1KB
  • enemy_small_3.png
    1.1KB
  • splode_5.png
    3.5KB
  • Powerup.js
    4.5KB
  • double_image.png
    1.8KB
  • level_passed.ogg
    181.3KB
  • level_2_loop.ogg
    1MB
  • ship_down_1.png
    6KB
  • ship_up_2.png
    5.8KB
  • Mouse.js
    8.2KB
  • ship_icon.png
    2.2KB
  • loading.png
    10.7KB
  • ship_down_2.png
    5.3KB
  • PeaShooter.js
    1.8KB
  • ship_center.png
    6.5KB
  • enemy_artifact.png
    1.4KB
  • title.png
    12.7KB
  • ship_death_4.png
    7.5KB
内容介绍
<!DOCTYPE HTML> <html> <head> <style type="text/css"> #dbg { font-family: "Helvetica", cursive, sans-serif; border: 1px solid black; width: 600; } body { background:#000; color:white; font-family: Arial,Helvetica,Sans-serif; } a { color: #009de9; outline: none; } a:hover { text-decoration: none; } </style> <link rel="shortcut icon" href="http://www.dougx.net/favicon.ico"> <title>HTML5战机游戏</title> <!---- javascript includes ---> <!---- open license with citation to dougx.net---> <script type="text/javascript" src="Sound.js"> </script> <script type="text/javascript" src="Background.js"> </script> <script type="text/javascript" src="Mouse.js"> </script> <script type="text/javascript" src="Loader.js"> </script> <script type="text/javascript" src="FloatyText.js"> </script> <script type="text/javascript" src="Keyboard.js"> </script> <script type="text/javascript" src="Collision.js"> </script> <script type="text/javascript" src="AfterEffect.js"> </script> <script type="text/javascript" src="PeaShooter.js"> </script> <script type="text/javascript" src="Laser.js"> </script> <script type="text/javascript" src="LevelDirector.js"> </script> <script type="text/javascript" src="Sortie.js"> </script> <script type="text/javascript" src="Enemy.js"> </script> <script type="text/javascript" src="Powerup.js"> </script> <script type="text/javascript" src="Shot.js"> </script> <script type="text/javascript" src="EnemyShot.js"> </script> <script type="text/javascript" src="Ship.js"> </script> <script type="text/javascript"> // // thanks for viewing the code, feel free to reuse. // if you do, please link to my site! thanks! // var g_canvas; var g_context; var g_soundsLoaded; var g_isChr; var g_onscreenControls; var g_paused; var g_renderInterval; var g_clockInterval; var g_totalItems; var g_itemsLoaded; var g_background; var g_foreground; var g_ship; var g_gameState; var g_highScore; var g_powerups; var g_floatyText; var g_projectiles; var g_enemyProjectiles; var g_enemies; var g_afterEffects; var g_rainbow; var g_basicShotSound; var g_laserShotSound; var g_dinkSound; var g_smallExplodeSound; var g_bonusSound; var g_explodeSound; var g_artifact_chard_sound; var g_double_sound; var g_gem_sound; var g_gun_sound; var g_shot_sound; var g_speed_sound; var g_levelDirector; var g_shotsFired; var g_shotsRequired; var g_accuracy; var g_showAccuracy; var g_enemiesDestroyed; // // main() is called once the game has loaded and the user has clicked // on the "new game" button on the splash screen. This is a clean slate // with no registered timers or event listeners. // function main() { var level_1_loop = document.getElementById("level_1_loop"); var bossLoop = document.getElementById("boss_loop"); //dbg("engine = " + navigator.userAgent, false); g_rainbow = new Array("yellow", "orange", "white", "red"); document.addEventListener('keydown', keyDown, false); document.addEventListener('keyup', keyUp, false); if ( g_basicShotSound == null ) { g_basicShotSound = new Sound("basic_shot",5); g_laserShotSound = new Sound("laser",5); g_smallExplodeSound = new Sound("small_explode",5); g_bonusSound = new Sound("bonus_sound",4); g_explodeSound = new Sound("explode", 3); g_artifact_chard_sound = new Sound("artifact_chard_sound", 2); g_double_sound = new Sound("double_sound", 2); g_gem_sound = new Sound("gem_sound", 4); g_gun_sound = new Sound("gun_sound", 2); g_shot_sound = new Sound("shot_sound", 3); g_speed_sound = new Sound("speed_sound", 3); } g_highScore = 0; g_gameState = "setup"; g_levelDirector = new LevelDirector(); // // telling the level director to start will put the clock and // render loops on interval timers // g_levelDirector.startLevel(); } // // map a sound name to a global audio object // function lookupSound(name) { if ( name == "double_sound" ) return g_double_sound; else if ( name == "gem_sound" ) return g_gem_sound; else if ( name == "gun_sound" ) return g_gun_sound; else if ( name == "shot_sound" ) return g_shot_sound; else if ( name == "speed_sound" ) return g_speed_sound; dbg("Failed sound lookup: " + name, false); return null; } // // the level director will kick off an interval that calls // this function every 100ms // function clockLoop() { if ( g_paused ) return; g_levelDirector.myClock += 100; //dbg("Clock = " + g_levelDirector.myClock, false); g_levelDirector.launchSorties(); g_levelDirector.gameEvents(); } // // the LevelDirector will kick off an interval that calls this function // which redraws the entire screen. that interval determines the game's // fps. // function renderLoop() { if ( g_paused ) return; g_background.render(); g_ship.render(); var remainingPowerups = new Array(); for (var i = 0; i < g_powerups.length; ++i) { if (g_powerups[i].render()) { remainingPowerups.push(g_powerups[i]); } else delete g_powerups[i]; } delete g_powerups; g_powerups = remainingPowerups; var remainingText = new Array(); for (var i = 0; i < g_floatyText.length; ++i) { if (g_floatyText[i].render()) { remainingText.push(g_floatyText[i]); } else delete g_floatyText[i]; } delete g_floatyText; g_floatyText = remainingText; var remainingEnemies = new Array(); for (var i = 0; i < g_enemies.length; ++i) { if (g_enemies[i].render()) { remainingEnemies.push(g_enemies[i]); } else delete g_enemies[i]; } delete g_enemies; g_enemies = remainingEnemies; var remainingProjectiles = new Array(); for (var i = 0; i < g_projectiles.length; ++i) { if (g_projectiles[i].render()) { remainingProjectiles.push(g_projectiles[i]); } else delete g_projectiles[i]; } delete g_projectiles; g_projectiles = remainingProjectiles; var remainingEnemyProjectiles = new Array(); for (var i = 0; i < g_enemyProjectiles.length; ++i) { if (g_enemyProjectiles[i].render()) { remainingEnemyProjectiles.push(g_enemyProjectiles[i]); } else delete g_enemyProjectiles[i]; } delete g_enemyProjectiles; g_enemyProjectiles = remainingEnemyProjectiles; var remainingAfterEffects = new Array(); for (var i = 0; i < g_afterEffects.length; ++i) {
评论
    相关推荐