The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Adventurer
Posted by: Anton | February 10, 2010 @ 1:32pm
ActionScript Code
[
Download
]
package { import flash.display.*; import flash.events.*; import flash.utils.Timer; import flash.text.TextField; public class Adventurer extends MovieClip { private var player:Player; private var enemy:Enemy; public var leftArrow, rightArrow:Boolean; private var score:int; public var livesLeft:int = 3; public function startAdventurer() { // initalize score score = 0; showGameScore(); // create player player = new Player(); addChild(player); setChildIndex(player, 2); // create enemy enemy = new Enemy(); addChild(enemy); setChildIndex(enemy, 2); // listen for keyboard stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction); stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction); // listen for player hitting stuff addEventListener(Event.ENTER_FRAME, checkForHits); } // check for collisions public function checkForHits(event:Event) { if (player.hitTestObject(enemy)) { _root.removeChild(this); showGameScore(); endGame(); livesLeft--; } } // key pressed public function keyDownFunction(event:KeyboardEvent) { if (event.keyCode == 37) { leftArrow = true; } else if (event.keyCode == 39) { rightArrow = true; } } // key lifted public function keyUpFunction(event:KeyboardEvent) { if (event.keyCode == 37) { leftArrow = false; } else if (event.keyCode == 39) { rightArrow = false; } } public function showGameScore() { showScore.text = String("Score: "+score); //showShots.text = String("Shots Left: "+shotsLeft); } // game is over, clear movie clips public function endGame() { enemy.deleteEnemy(); enemy = null; player.deletePlayer(); player = null; stage.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction); stage.removeEventListener(KeyboardEvent.KEY_UP,keyUpFunction); gotoAndStop("end"); } } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.54 / 8
68 Votes
http://codebin.yi.org/497
page generated in 0.01 seconds