Messing with the Joystick Demo

2»

Comments

  • THRSTNTHRSTN Member Posts: 178
    That worked GREAT! thanks mark. I wonder how i would add animation to the angle movement instead of just rotation?
  • QbAnYtOQbAnYtO Member Posts: 523
    Attribute? Movement detection? If play is moving (and rotating in any case) then animate???
  • dazzlemedazzleme Member Posts: 152
    I'm using a joystick in a side shooter game; the joystick logic comes from CodeMonkey's joystick project. In CodeMonkey's project, the actor that is being controlled by the joystick can be moved off the screen in any direction. In my game, I am trying to prevent the actor from being able to be moved off the screen.

    I've set up four rules and applied them to the movable actor, and am wondering if there is a better way to do this or not. Here's the logic behind my movable actor:

    -------------------------
    *MOVE*
    Direction: game.Angle
    Speed: 300*game.DistanceFromCenter/game.BaseRadius

    *RULE 1: Stop moving RIGHT at 440 pixels*
    When Attribute self.Position.X < 440
    Move: Direction 0. Speed: 300

    *RULE 2: Stop moving LEFT at 40 pixels*
    When Attribute self.PositionX > 40
    Move: Direction: 180. Speed: 300

    *RULE 3: Stop moving UP at 290 pixels*
    When Attribute self.Position.Y < 290
    Move: Direction: 90. Speed: 300

    *RULE 4: Stop moving DWON at 30 pixels*
    When Attribute self.Position.Y > 30
    Move: Direction: 270. Speed: 300

    *CONSTRAIN ATTRIBUTE*
    Constrain Attribute: self.Rotation To: game.Angle2

    *RULE*
    Rule for firing

    *CONTROL CAMERA*
    -------------------------

    To the many experts on the forums, does this look like good code, or is there a better way? Sometimes in my fiddling around with different things (using the above code) my actor will slip beyond the boundaries or it will bounce back and forth madly against them if the joystick isn't at just the right angle.

    Any feedback / suggestions are greatly appreciated.
  • simo103simo103 Member, PRO Posts: 1,331
    not sure if it will help but I tried to set self.linear.velocity.x and y to zero to get a dead stop
  • dazzlemedazzleme Member Posts: 152
    Thanks for the suggestion simo103, I'll give it a shot.
Sign In or Register to comment.