Hello and welcome to our community! Is this your first visit?
Register
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Enthusiast Fyrren's Avatar

    Join Date
    Oct 2007
    Location
    Norway
    Posts
    1,595

    Waw... Two Player Movement, Crashing, And Winning Help-.-

    I Am Making A Game right now... but i need help with two player movement, and some other stuff... in flash 8!

    Here is the code i use for one player movement:
    Code:
    onClipEvent(enterFrame){
         if(Key.isDown(Key.RIGHT)){
           this._x += 20;
    }
        if(Key.isDown(Key.LEFT)){
           this._x -= 20;
    }
        if(Key.isDown(Key.UP)){
           this._y -= 20;
    }
        if(Key.isDown(Key.DOWN)){
           this._y += 20;
    }
    if(_root.playerhp < 1){
    	this.unloadMovie();
    	_root.playerhp = 0;
    }
    }
    (That playerhp thing is just something later for the game.)
    So how do i make another player move with WASD?
    I have tried to change the actions a little, and it didn't work...

    Next problem: How do i add a wall that player 1 cannot go through, but player two can?

    Last problem i think: How do i add a thing that player 1 can go onto and then it goes to the next frame?

    Please help! You will be credited in the game!
    Sway bought me VIP a few years back. Respect.

  2. #2
    Fanatic Enthusiast Niall's Avatar

    Join Date
    Aug 2007
    Posts
    3,298

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    You need to be more specific about things, like, what happens if you go through the wall, does anything happen to either player?
    Is the game sidescrolling, headview, what?

    Oh, and as to the WASD thing, I believe that if you change the keyisDown.(key.DOWN) or whatever to keyisDown(.key.W) and so on.

    If that doesn't work it may be using the numbered keys thing, like each keyboard key has a number assigned to it, like whatever key would be (example) keyisDown.(key.45) or something, you'd have to find a list.

    Maybe you could provide us with the SWF so far?

  3. #3
    Enthusiast Fyrren's Avatar

    Join Date
    Oct 2007
    Location
    Norway
    Posts
    1,595

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    Its birds eye view. And keyisdown(key.W) Dont Work. I tried. When player one goes ona a wall he stops, and cannot go though it. player two can go through the wall so no wall actions needed for that guy, only the WASD movements.
    Sway bought me VIP a few years back. Respect.

  4. #4
    Fanatic Enthusiast Niall's Avatar

    Join Date
    Aug 2007
    Posts
    3,298

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    Hmm, I'll look into it for you.

    EDIT

    Solutuion I believe.

    Change DOW, UP, LEFT and RIGHT to 65, 68, 87 and 83, I hope that works?

    If not I'll keep trying.

  5. #5
    Enthusiast Fyrren's Avatar

    Join Date
    Oct 2007
    Location
    Norway
    Posts
    1,595

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    This is what i got:

    "**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: ')' or ',' expected
    if(Key.isDown(Key.65)){// If right control key is pressed

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: ')' or ',' expected
    if(Key.isDown(Key.68)){// If left control key is pressed

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 6: Statement must appear within on/onClipEvent handler
    this._x -= 20;// then left speed is 20

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 7: Unexpected '}' encountered
    }

    Total ActionScript Errors: 4 Reported Errors: 4"

    Not the actual thing i wanted :P
    Sway bought me VIP a few years back. Respect.

  6. #6
    Fanatic Enthusiast Niall's Avatar

    Join Date
    Aug 2007
    Posts
    3,298

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    Oh poop.

    I'll keep on googling then

  7. #7
    Nev
    Nev is offline
    Veteran Enthusiast

    Join Date
    Feb 2006
    Posts
    8,835

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    For player two's movements:
    Code:
    if (Key.isDown(68)) { this._x += speed; }
    if (Key.isDown(65)) { this._x -= speed; }
    if (Key.isDown(87)) { this._y -= speed; }
    if (Key.isDown(83)) { this._y += speed; }
    For the wall thing, put the collision detection in for player 1, but not player 2:
    Code:
    while (_root.walls.hitTest(this._x, this._y+radius, true)) { this._y--; }
    while (_root.walls.hitTest(this._x, this._y-radius, true)) { this._y++; }
    while (_root.walls.hitTest(this._x+radius, this._y, true)) { this._x--; }
    while (_root.walls.hitTest(this._x-radius, this._y, true)) { this._x++; }
    ** Make sure walls have the instance of walls

    For the nextFrame thing, put:
    Code:
    if (this.hitTest(_root.user._x - _root.user.radius, _root.user._y, true)) { _root.gotoAndStop(frameNumber); }
    if (this.hitTest(_root.user._x + _root.user.radius, _root.user._y, true)) { _root.gotoAndStop(frameNumber); }
    if (this.hitTest(_root.user._x, _root.user._y - _root.user.radius, true)) { _root.gotoAndStop(frameNumber); } 
    if (this.hitTest(_root.user._x, _root.user._y + _root.user.radius, true)) { _root.gotoAndStop(frameNumber); }
    ** Make sure to change frameNumber to the actual number, or set that variable.

    Make sure you set a radius value for these as well (half of the characters width).
    Wish I could go and post my RPG tutorial already, so you guys can stop asking questions, but I still have to wait for Fraz to announce the winners.

  8. #8
    Enthusiast Fyrren's Avatar

    Join Date
    Oct 2007
    Location
    Norway
    Posts
    1,595

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    WAW!!! SUPER THANX NEV! I Finally can continue my game! Again GREAT thanx! You will be credited!
    Sway bought me VIP a few years back. Respect.

  9. #9
    Fanatic Enthusiast Niall's Avatar

    Join Date
    Aug 2007
    Posts
    3,298

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    Quote Originally Posted by fyrren
    WAW!!! SUPER THANX NEV! I Finally can continue my game! Again GREAT thanx! You will be credited!
    I was close with the numbers, and tried....CREDIT ME! Heh, nah, good luck with the game.

  10. #10
    Enthusiast Fyrren's Avatar

    Join Date
    Oct 2007
    Location
    Norway
    Posts
    1,595

    Re: Waw... Two Player Movement, Crashing, And Winning Help-.-

    Where to put in the radius? Im getting up this when im inserting the actions:

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 19: Statement must appear within on/onClipEvent handler
    while (_root.walls.hitTest(this._x, this._y+radius, true))

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 21: Statement must appear within on/onClipEvent handler
    while (_root.walls.hitTest(this._x, this._y-radius, true))

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 23: Statement must appear within on/onClipEvent handler
    while (_root.walls.hitTest(this._x+radius, this._y, true))

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 25: Statement must appear within on/onClipEvent handler
    while (_root.walls.hitTest(this._x-radius, this._y, true))

    Total ActionScript Errors: 4 Reported Errors: 4

    Help?
    Sway bought me VIP a few years back. Respect.


 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •