Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ball.as
- package{
- import flash.display.MovieClip;
- public class Ball extends MovieClip{
- public var xdir = -5;
- public var ydir = 5;
- public function Ball(){
- this.graphics.beginFill(0x000000);
- this.graphics.drawCircle(0,0,10);
- }
- public function update(){
- this.x+=xdir;
- this.y+=ydir;
- }
- }
- }
- //PlayerBat.as
- package{
- import flash.display.MovieClip;
- import flash.events.KeyboardEvent;
- import flash.text.TextField;
- public class PlayerBat extends MovieClip{
- var upkey:Boolean;
- var downkey:Boolean;
- public function PlayerBat(){
- this.graphics.beginFill(0x000000);
- this.graphics.drawRect(0,0,10,50);
- }
- public function init(){
- stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
- stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
- }
- public function update(){
- //trace(upkey);
- if(upkey){
- this.y-=10;
- }
- if(downkey){
- this.y+=10;
- }
- }
- private function keyDown(keyEvent:KeyboardEvent){
- if(keyEvent.keyCode == 38){
- upkey = true;
- }
- if(keyEvent.keyCode == 40){
- downkey = true;
- }
- }
- private function keyUp(keyEvent:KeyboardEvent){
- if(keyEvent.keyCode == 38){
- upkey = false;
- }
- if(keyEvent.keyCode == 40){
- downkey = false;
- }
- }
- }
- }
- //EnemyBat.as
- package{
- import flash.display.MovieClip;
- public class EnemyBat extends MovieClip{
- public var goal:int = 200;
- public function EnemyBat(){
- this.graphics.beginFill(0x000000);
- this.graphics.drawRect(0,0,10,50);
- }
- public function update(){
- if(goal>this.y){
- this.y+=5;
- }
- if(goal<this.y){
- this.y-=5;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment