NNKL.COM
welcome to my space
X
Search:  
 HOME   Need help with some 'advanced keyboard movement'...
Need help with some 'advanced keyboard movement'...
Published by: smith 2010-03-14
Welcome to:nnkl.com

  • ActionScript 1.0/2.0 [Archive] - Page 87 - kirupaForum::
    AS MX 2004 (On Screen Keyboard) need help, please: infinite menu hiccup Flash XML menu,I need some help. Component Fades Black (getURL() > Advanced) load movie
    http://www.kirupa.com/forum/archive/index.php/f-9-p-87.html
    HOME
    Hi

    I'm starting a new game where the user
    rides a jetski through the water, dodges
    stuff and shoots enemies along the way
    (based around a 007-style theme).

    What I need is some help coding the movement
    of the jetski (left and right). All I can do is
    this:

    onEnterFrame = function() {
    if (Key.isDown(Key.RIGHT)) {
    jetski._x += 10;
    }
    }
    (and do the same for 'left', of course)

    As you can see its very basic and will
    only make very 'linear' movement. What
    I need is to sort-of 'ease' the motion of
    the jetski. Like 'skidding' a little bit.

    I think it's a mathematical thing...
    Quadratics? :puzzle:

    Please help! :beam:

    Thanks in advance.


  • Ah, I see what you're saying - yes, that should work fine, and it sounds like that will give you the naturalistic movement you're looking for.
    Johann Sebastian Bach - Keyboard Concertos 2 (Hyperion Audio CD)::
    Advanced Search. Browse Composers. A B C D E F G H I. J K L M N O P Q. R No 4 in A major, BWV1055 (Bach) CD1 1 Movement 1: Allegro 4:06 Need Help?
    http://www.boosey.com/pages/shop/product_detail.asp?id=939187
    HOME

    Let me know how it works out - post an update here if you can, when you make some progress.

    Steve


  • wow.

    thanks a lot everyone!

    ive got a pre-pre-alpha version up.
    http://www.myvipcard.com.au/yakub/jetski/jetski1.swf


  • what i would do is to increment a speed variable, not the position directly, like when right key is pressed increment speed, when left key is pressed decrease the speed (it should be allowed to go negative values so you can move to either side) and on enterframe add the speed value to x and also when no keys are pressed the speed should decay: like speed *= .9

    hope u get the picture
  • Tabs::
    Use the following key combinations to navigate the help system by keyboard: Storage Manager for Advanced Copy Services. Storage Manager for Copy Services
    http://publib.boulder.ibm.com/infocenter/tivihelp/index.jsp
    HOME
    Active Worlds Help ~ How To Move Around::
    to move with the mouse, you should first select Advanced mode if you In this mode you need to use the keyboards arrow keys or your assigned Move
    http://www.activeworlds.com/help/aw36/move.html
    HOME


  • true, it probably should be bouncing a lil bit at all times, that actually doesn't look bad at the different perspective. heh.. I never claimed to be a good artists.. my jetski was kinda crap.


  • Very cool AP - I added a few elements (the jetskiier is clipart - it's the wrong angle though) just to get the effect. Very neat stuff - though there should probably be a bit of hop/bounce going on all the time, from the effects of the waves, don't you think?

    Steve


  • probably, i tried it again and it worked


  • Hey, i figured I would give this a shot and got WAY more into than I thought I would. Heres what I came up with.


    accelX = jetski._x; // So the jetski starts at the right spot.
    turnSpeed = 1; // the rotation speed of the ski.
    turnThresh = 20; // The max rotation threshold.
    accelSpeed = 5; // The acceleration speed of the jetski
    accelHop = .2; // The acceleration speed of the "bobbing"
    threshY = 5; // The threshold of the "bobbing"
    idleRot = 1; // The "return" speed of the rotation while iddle.
    baseY = jetski._y;

    onEnterFrame = function () {
    if (Key.isDown(Key.RIGHT)) {
    accelX += accelSpeed; // increase X accleration speeed.
    (jetski._y>baseY-threshY) ? accelY += accelHop : accelY -= accelHop; // Bobbing checks
    (jetski._rotation>turnThresh) ? null : rot += turnSpeed; // Turning Checks
    }
    if (Key.isDown(Key.LEFT)) {
    //same as above, but opposite directions.
    accelX -= accelSpeed;
    (jetski._y>baseY-threshY) ? accelY += accelHop : accelY -= accelHop;
    (jetski._rotation<-turnThresh) ? null : rot -= turnSpeed;
    }
    if (!((Key.isDown(Key.RIGHT)) (Key.isDown(Key.LEFT)))) { // Check if there are no keys being pressed
    (jetski._y if (Math.abs(jetski._rotation)<=idleRot) { // ensure there isn't weird "wobbling"
    rot = 0;
    } else {
    (jetski._rotation<0) ? rot += idleRot : null; // rotate right.
    (jetski._rotation>0) ? rot -= idleRot : null; // rotate left.
    }
    }
    jetski._y -= accelY; // bobbing effect.
    jetski._x += (accelX-jetski._x)/14; // accelerate the jetski, divide for sluggish motion.
    jetski._rotation += (rot-jetski._rotation)/4; //rotate the jetski, divide for sluggish motion.
    };
    stop();


    All you need to do is put that on the first frame and make a clip named "jetski." But I would suggest re-writing it and understanding it, and then you can change stuff about it to suit your needs.. for instance you might not want the jetski code on the enterframe of _root.

    Heres the .fla, I added a line to show water level. If anyone has any tips to make the code better, feel free to shout em out. I didn't mess with changing the onEnterFrame from being on the root or the button testing or anything, even though it might be a good idea to do so.


  • Looks like it's working well. The link worked fine for me, F4F - maybe it was temporarily down or something?


  • for the "hoping around" of the waves i got an idea:


    onClipEvent (load) {
    waveIntensity = 10;
    degrees = 0;
    speed=10
    }
    onClipEvent (enterFrame) {
    degrees+=speed;
    _y = Math.sin(degrees*(Math.PI/180))*waveIntensity;
    }


    but u have to experiment around with the values to get a realistic effect, and maybe add to degrees the speed of the jetski, so when its going fast it bounces more and when theres no speed at all it doesnt bounce

    by the way ya3 if u are going to use our code a small credit would be nice...


  • YA3,

    I think the best and easist solution is to think of the X position of the jetski as a destination, so that hitting the left and right arrow keys increases a variable called something like xDest - then, the jetski can constantly be checking its own position to see if it's to the left or right of that target destination, and it can move itself accordingly - and, that way, you can add inertia so it moves slowly.

    I created a similar type of motion for the paddle in this Breakout-style game:

    http://www.plasmicstudio.com/bustthrough

    The paddle has a very small amount of inertia (which you can increase or decrease by adjusting one variable) so that its movement is a little slower than the mouse. If you'd like the .fla for this, let me know and I'll provide it.

    Steve


  • the link didnt work for me!





  • Get Smart About Monitoring Virtual Machines
    Microsoft Gets Ex-Streamly Cozy with U.K.'s MediaWave

    You are looking at:nnkl.com's Need help with some 'advanced keyboard movement'..., click nnkl.com to home
  • latest addition to the kipper household
  • a few from a shoot tonight
  • at the tracks again
  • how do you photograph overweight subjs
  • portrait of erica
  • canon 70 200mm f 2 8l w is and w o is
  • rory and liam
  • self p s
  • i heart music
  • my first
  • those eyes
  • golden age
  • onna beach session
  • a hard decision for me
  •  
  • working with a local musician
  • sort of a storyboard
  • first portraits experimeting
  • second portrait session something is missing
  • inspired by big mike s posting
  • maternity
  • how to do formal shots
  • so in love
  • 18 months
  • which metering mode
  • flower girl
  • latest seniors
  • stressed bride
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 nnkl.com        Site made:CFZ