Flash RPG: Wall Detection (Corrected)

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
8,438
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on May 29, 2009

CODE:
MC_dude.onEnterFrame=function(){
radius=8;
if(Key.isDown(Key.UP)){
this._y-=10;
this._rotation =180;
}
if(Key.isDown(Key.DOWN)){
this._y +=10;
this._rotation = 0;
}
if(Key.isDown(Key.LEFT)){
this._x-=10;
this._rotation = 90;
}
if(Key.isDown(Key.RIGHT)){
this._x+=10;
this._rotation = -90;
}
while (MC_wall.hitTest(this._x, this._y+radius, true)){
this._y--;
}
while (MC_wall.hitTest(this._x, this._y-radius, true)){
this._y++;
}
while (MC_wall.hitTest(this._y, this._x-radius, true)){
this._x++;
}
while (MC_wall.hitTest(this._y, this._x+radius, true)){
this._x--;
}
}

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 9 dislikes

Link to this comment:

Share to:

Uploader Comments (PivotyPivoty)

  • I assure you, you understand none of that code you just wrote. Looks like you recorded half your screen and had the code pre-made.

  • @CrazehGamer 1st line: call upon the movie clip for a function 2nd line: distance from touching the wall 3rd line: if up arrow key is pressed 4th line: move the player up the Y axis by 10 5th line: rotate the player 180 degrees (facing up) 6th line: close function 1 //Repeats for other 3 keys 7th line: if player is hitting the wall with specified distance going down: 8th line: send the player in opposite direction //Repeats for up Don't you dare test my 6 years of scripting knowledge
  • @CrazehGamer And yes, I did use notes, take a good look at the timing of the video and the date of when it was made. Back in that day, i had to make the videos quick, so I paced through the coding because i simply did not have time. Hope this helped by the way

  • @CrazehGamer I mean really, I have coded so many things 10x more complex than this.

see all

All Comments (53)

Sign In or Sign Up now to post a comment!
  • Seriously ! You Helped Lot of people including me. THank you very much! We are developing a game right now but of course its an amateur RPG game. Your videos helped us alot ! :) Thank you u posted these videos :)

  • i'm using an animated character who is not a circle. I have all of the movement down but how am i supposed to make it so he stops at walls

  • diagonal walls?

  • @kdizzletotheshizzle did you try to add a other } to it? because that happens to me alot and I found out a solution by adding a other bracket

  • OMFG mine keeps saying

    "**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler MC_dude.onEnterFrame=function(­){

    Total ActionScript Errors: 1 Reported Errors: 1"

  • I think the code is wrong. :L

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more