Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////here is my code
- package {
- import flash.display.MovieClip;
- import flash.events.KeyboardEvent;
- import flash.events.Event;
- public class marioV2Code extends MovieClip {
- public function marioV2Code() {
- //variables
- var dir:String = "stop";
- var wCheck :Boolean = false;
- //putting the map on the stage
- var w:map = new map();
- addChild(w);
- //putting the tube on the stage
- var t:tube = new tube();
- w.addChild(t);
- //putting mario at the bottom
- var m:mario = new mario();
- addChild(m);
- m.gotoAndStop(1);
- m.x = 20;
- m.y = 307;
- stage.addEventListener(KeyboardEvent.KEY_DOWN, dFun);
- function dFun(evt:KeyboardEvent):void {
- if (evt.keyCode == 39 && wCheck == false) {
- dir = "right";
- m.gotoAndPlay(2);
- wCheck = true;
- }
- if (evt.keyCode == 37 && wCheck == false) {
- dir = "left";
- m.gotoAndPlay(14);
- wCheck = true;
- }
- if (evt.keyCode == 32) {
- m.y -=6;
- }
- }
- stage.addEventListener(KeyboardEvent.KEY_UP, uFun);
- function uFun(evt:KeyboardEvent):void {
- if (evt.keyCode == 39) {
- dir = "stop";
- m.gotoAndStop(2);
- wCheck = false;
- }
- if (evt.keyCode == 37) {
- dir = "stop";
- m.gotoAndStop(14);
- wCheck = false;
- }
- }
- addEventListener(Event.ENTER_FRAME, mainFun);
- function mainFun(evt:Event):void {
- moveMario();
- if ( m.hitTestObject(t) ) {
- if (dir == "right") {
- m.x -=1;
- w.x +=3;
- }
- }
- }
- //functions......
- function moveMario():void {
- if (dir == "right" && wCheck == true && m.x < 535) {
- m.x += 1;
- w.x -=3;
- if (m.currentFrame == 13) m.gotoAndPlay(3);
- } else if (dir == "left" && wCheck == true && m.x > 15) {
- m.x -= 1;
- w.x += 3;
- if (m.currentFrame == 27) m.gotoAndPlay(15);
- }
- if (m.y < 307) m.y += .6;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment