Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

zigzagger

Name: Anonymous 2008-10-09 17:45

I am taking a programming class outside of school in Java. Right now I am writing a program that has two feet that together are a "Zigzag" that extends a previous class I wrote called pacer. It works well except that while walking the feet seem to shuffle rather than taking steps, and upon the second turn, switch places. I was wondering if anyone could give me some tips. It would be much appreciated.
Thank You.

here is my code for reference.

import java.awt.Image;

public class ZigZag extends Pacer
{
private int stepLengths;
private int stepsCount;
// Constructor
public ZigZag(int x, int y, Image leftPic, Image rightPic)
{
super(x, y, leftPic, rightPic);
stepLengths = PIXELS_PER_INCH * 12;
}



public void firstStep()
{
if (stepsCount == 0)
{
Foot lf = getLeftFoot();
Foot rf = getRightFoot();
lf.turn(45);
rf.turn(45);
stepsCount = 1;
lf.moveForward(stepLengths);
}
}



public void nextStep()
{
Foot lf = getLeftFoot();
Foot rf = getRightFoot();
if (stepsCount % 2 == 0)
{
rf.moveForward(stepLengths);
//rf.moveSideways(stepLengths);
}
else
{
lf.moveForward(stepLengths);
//lf.moveSideways(stepLengths);
}

stepsCount++;
}
public void turn()
{
Foot lf = getLeftFoot();
Foot rf = getRightFoot();
{
rf.turn(-90);
lf.turn(-90);
}
}
}

Name: Anonymous 2008-10-09 17:47

here is my sage for reference.

Name: Anonymous 2008-10-09 18:00

back to /pr/, please

Name: Anonymous 2008-10-09 18:01

what is this filth?  remove it at once.

Name: Anonymous 2008-10-09 18:02

upon the second turn, switch places
Because you have rotated 180°

Name: Anonymous 2008-10-09 18:32

>>5
Don't help him!

Name: Anonymous 2010-11-14 23:59

Name: Anonymous 2011-01-31 20:00

<-- check em dubz

Name: Anonymous 2011-02-03 0:15

Name: Anonymous 2013-01-18 23:35

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List