Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-04-2010, 02:31 AM   #1
benw36
Registered User
 
Join Date: Apr 2010
Posts: 3
Default [AS2] Mario Game

hello everyone
i am coding a mario game and i have my code worked out so i can jump and move and whatnot. but now it comes to the part where i need to hit the blocks and i cannot figure out a hittest that will work.
please help by making a hittest!

the level is in a movieclip (such as the clouds in the background and the blocks i am trying to contact) that movieclip is called "level_mc" and the block movieclip inside the level is called "block1_mc".

ps: i am pretty sure the hittest should be located in that position, if not please specify where it should be.

ActionScript Code:
//variable declarations onClipEvent(load){     right = true;     left = false;     rduck = false;     lduck = false;     rmoving = false;     lmoving = false;     ducking = true;     jumping = false;     falling = false;     resetpos = false;     jump = 15; //play themesong     themesong = new Sound(this);     themesong.attachSound("theme.mp3");     themesong.start(0,99);     } onClipEvent(enterFrame){     //walking config     if(Key.isDown(Key.RIGHT)){         this._xscale = 100;         this._x = 200;         right = true;         left = false;         rmoving = true;         _root.level_mc._x -= 8;         }else{         rmoving = false;         }     if(Key.isDown(Key.LEFT)){         this._xscale = -100;         this._x = 224;         left = true;         right = false;         lmoving = true;         if(_root.level_mc._x <= 200){             _root.level_mc._x += 8;         }         }else{         lmoving = false;         }     if(right && !rmoving||left && !lmoving){         this.gotoAndPlay(1);         }     //duck config     if(Key.isDown(Key.DOWN) && ducking){         this._visible = false;         _root.duck_mc._x = 200;         _root.duck_mc._y = 324;         }else{         this._visible = true;         _root.duck_mc._x = -100;         }     if(right){         _root.duck_mc._xscale = 100;         }     if(left){         _root.duck_mc._xscale = -100;         _root.duck_mc._x += 22;         }     //jump config     if (Key.isDown(Key.UP) && !jumping){         jumping = true;         ducking = false;         jumpsound = new Sound(this);         jumpsound.attachSound("jump.wav");         jumpsound.start(0,1);     }     if (jumping){         this.gotoAndStop(4);         this._y -= jump;         jump -= 1;         if(jump<0){             falling = true;         }         if(jump<-15){             jump = -15;         }         HITTEST SHOULD BE HERE !!!!!!!     }     //ground hit test     if (_root.ground_mc.hitTest(this._x+this._width, this._y+this._height, true) && falling){         jump = 15;         jumping = false;         falling = false;         ducking = true;         resetpos = true;     }     if(resetpos){         this.gotoAndPlay(1);         resetpos = false;         } }
benw36 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:37 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.