473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Turtle Graphics Program

11
Hi I am working on a Turtle Program and I have put in all the fancy schmancy stuff in I just cant seem to figure out how to print the T, which is my turtle, on the screen. Here is the code for my program so far!

Expand|Select|Wrap|Line Numbers
  1. /* Julian Baranowski
  2. Date:12/7/2006
  3. Revised:
  4. Description: Turtle Graphics Program
  5. */
  6.  
  7.  
  8. import javax.swing.*;
  9. import java.awt.event.*;
  10. import java.awt.*;
  11. import java.io.*;
  12.  
  13. public class P7_21 extends JFrame implements ActionListener
  14. {
  15.     int floor[][];
  16.     JTextArea output, input;
  17.     JButton enter,exit;
  18.     JScrollPane jsp;
  19.     JTextField ent;
  20.     Container container;
  21.     int move[] ={8,6,4,2};
  22.     int moved = 0;
  23.     final int LEFT = 4, RIGHT = 6, UP = 8, DOWN = 2;
  24.     String left,right,up,down;
  25.  
  26.     public P7_21()
  27.     {
  28.         left="";
  29.         right="";
  30.         up="";
  31.         down="";
  32.         container= getContentPane();
  33.         container.setLayout(null);
  34.  
  35.  
  36.         floor = new int [20][20];
  37.         setSize(800,500);
  38.  
  39.         output = new JTextArea(20,50);
  40.         output.setFont(new Font("Monospaced",Font.PLAIN,18));
  41.         //output.setText("TEST");
  42.         output.setBounds(5,5,350,300);
  43.         output.setEditable(false);
  44.         container.add(output);
  45.  
  46.         input = new JTextArea(5,50);
  47.         input.setFont(new Font("Monospaced",Font.PLAIN,12));
  48.         jsp = new JScrollPane(input);
  49.         jsp.setBounds(430,5,360,300);
  50.         //container.add(jsp);
  51.  
  52.         container.add(jsp);
  53.  
  54.         ent = new JTextField();
  55.         ent.setBounds(300,350,200,20);
  56.         ent.setEditable(true);
  57.         ent.addActionListener(this);
  58.         container.add(ent);
  59.  
  60.  
  61.         enter = new JButton("Enter");
  62.         enter.addActionListener(this);
  63.         enter.setBounds(300,400,100,20);
  64.         container.add(enter);
  65.  
  66.         exit = new JButton("Exit");
  67.         exit.addActionListener(this);
  68.         exit.setBounds(400,400,100,20);
  69.         getContentPane().add(exit);
  70.         container.add(exit);
  71.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  72.         this.dispose();
  73.  
  74.         print();
  75.  
  76.         setVisible(true);
  77.  
  78.         //int floor = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; //(Finish next time)
  79.     }
  80.  
  81.     public void actionPerformed(ActionEvent evt)
  82.     {
  83.  
  84.         if(evt.getActionCommand().equals("Exit"))
  85.             {
  86.                 int choice = JOptionPane.showConfirmDialog(null,
  87.                     " You Pressed "+ evt.getActionCommand()+" is this what you want to do? ",
  88.                     " Quit Frame ",
  89.                     JOptionPane.YES_NO_OPTION);
  90.                 if( choice == 0)
  91.                 this.dispose();
  92.             }
  93.  
  94.  
  95.  
  96.         if(evt.getSource()==enter || evt.getSource()==ent)
  97.         {
  98.             if(ent.getText().toLowerCase().compareTo("left")== 0)
  99.             {
  100.                 left ="Key:4 (LEFT)\n";
  101.             System.out.println("Left");
  102.                 input.append(left);
  103.                 ent.setText("");
  104.             }//end left
  105.  
  106.             if(ent.getText().toLowerCase().compareTo("right")==0)
  107.             {
  108.                 right ="Key:6 (RIGHT)\n";
  109.             System.out.println("right");
  110.                 input.append(right);
  111.                 ent.setText("");
  112.             }//end right
  113.  
  114.             if(ent.getText().toLowerCase().compareTo("up")==0)
  115.             {
  116.                 up ="Key:8 (UP)\n";
  117.             System.out.println("Up");
  118.                 input.append(up);
  119.                 ent.setText("");
  120.             }//end up
  121.  
  122.             if(ent.getText().toLowerCase().compareTo("down")==0)
  123.             {
  124.                 down ="Key:2 (DOWN)\n";
  125.             System.out.println("Down");
  126.                 input.append(down);
  127.                 ent.setText("");
  128.             }//end down
  129.  
  130.         }
  131.  
  132.     }
  133.  
  134.     void print()
  135.     {
  136.         for(int x=0;x<floor.length;x++)
  137.         {
  138.             for(int y=0;y<=floor[0].length;y++)
  139.             {
  140.                 if(y==floor[0].length)
  141.                 {
  142.                     output.append("\n");
  143.                     continue;
  144.                 }//end if
  145.                 if(floor[x][y]==0)
  146.                     output.append("0");
  147.                 else
  148.                 if(floor[x][y]==1)
  149.                     output.append("T");
  150.  
  151.             }
  152.         }
  153.     }
  154.  
  155.  
  156.         public static void main(String args[])
  157.         {
  158.             new P7_21();
  159.         }
  160. }
  161.  
Any input is appreciated thanks!

-Julian
Dec 7 '06 #1
10 5491
horace1
1,510 Expert 1GB
made a few modifications to your program - as you type right the T moves across the pattern - is this what you require?
Expand|Select|Wrap|Line Numbers
  1. /* Julian Baranowski
  2. Date:12/7/2006
  3. Revised:
  4. Description: Turtle Graphics Program
  5. */
  6.  
  7.  
  8. import javax.swing.*;
  9. import java.awt.event.*;
  10. import java.awt.*;
  11. import java.io.*;
  12.  
  13. public class P7_21 extends JFrame implements ActionListener
  14. {
  15.         int floor[][];
  16.         JTextArea output, input;
  17.         JButton enter,exit;
  18.         JScrollPane jsp;
  19.         JTextField ent;
  20.         Container container;
  21.         int move[] ={8,6,4,2};
  22.         int moved = 0;
  23.         int xpos=0, ypos=0;    // ** added
  24.         final int LEFT = 4, RIGHT = 6, UP = 8, DOWN = 2;
  25.         String left,right,up,down;
  26.  
  27.         public P7_21()
  28.         {
  29.                 left="";
  30.                 right="";
  31.                 up="";
  32.                 down="";
  33.                 container= getContentPane();
  34.                 container.setLayout(null);
  35.  
  36.  
  37.                 floor = new int [20][20];
  38.                 setSize(800,500);
  39.  
  40.                 output = new JTextArea(20,50);
  41.                 output.setFont(new Font("Monospaced",Font.PLAIN,18));
  42.                 //output.setText("TEST");
  43.                 output.setBounds(5,5,350,300);
  44.                 output.setEditable(false);
  45.                 container.add(output);
  46.  
  47.                 input = new JTextArea(5,50);
  48.                 input.setFont(new Font("Monospaced",Font.PLAIN,12));
  49.                 jsp = new JScrollPane(input);
  50.                 jsp.setBounds(430,5,360,300);
  51.                 //container.add(jsp);
  52.  
  53.                 container.add(jsp);
  54.  
  55.                 ent = new JTextField();
  56.                 ent.setBounds(300,350,200,20);
  57.                 ent.setEditable(true);
  58.                 ent.addActionListener(this);
  59.                 container.add(ent);
  60.  
  61.  
  62.                 enter = new JButton("Enter");
  63.                 enter.addActionListener(this);
  64.                 enter.setBounds(300,400,100,20);
  65.                 container.add(enter);
  66.  
  67.                 exit = new JButton("Exit");
  68.                 exit.addActionListener(this);
  69.                 exit.setBounds(400,400,100,20);
  70.                 getContentPane().add(exit);
  71.                 container.add(exit);
  72.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  73.                 this.dispose();
  74.  
  75.                 print();
  76.  
  77.                 setVisible(true);
  78.  
  79.                 //int floor = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; //(Finish next time)
  80.         }
  81.  
  82.         public void actionPerformed(ActionEvent evt)
  83.         {
  84.  
  85.                 if(evt.getActionCommand().equals("Exit"))
  86.                         {
  87.                                 int choice = JOptionPane.showConfirmDialog(null,
  88.                                         " You Pressed "+ evt.getActionCommand()+" is this what you want to do? ",
  89.                                         " Quit Frame ",
  90.                                         JOptionPane.YES_NO_OPTION);
  91.                                 if( choice == 0)
  92.                                 this.dispose();
  93.                         }
  94.  
  95.  
  96.  
  97.                 if(evt.getSource()==enter || evt.getSource()==ent)
  98.                 {
  99.                          floor[xpos][ypos]=0;    // clear old T ** added
  100.  
  101.                         if(ent.getText().toLowerCase().compareTo("left")== 0)
  102.                         {
  103.                                 left ="Key:4 (LEFT)\n";
  104.                         System.out.println("Left");
  105.                                 input.append(left);
  106.                                 ent.setText("");
  107.                         }//end left
  108.  
  109.                         if(ent.getText().toLowerCase().compareTo("right")==0)
  110.                         {
  111.                                 right ="Key:6 (RIGHT)\n";
  112.                         System.out.println("right");
  113.                                 input.append(right);
  114.                                 ent.setText("");
  115.                                 if(ypos < 10 )ypos++;   // ** addded
  116.                         }//end right
  117.  
  118.                         if(ent.getText().toLowerCase().compareTo("up")==0)
  119.                         {
  120.                                 up ="Key:8 (UP)\n";
  121.                         System.out.println("Up");
  122.                                 input.append(up);
  123.                                 ent.setText("");
  124.                         }//end up
  125.  
  126.                         if(ent.getText().toLowerCase().compareTo("down")==0)
  127.                         {
  128.                                 down ="Key:2 (DOWN)\n";
  129.                         System.out.println("Down");
  130.                                 input.append(down);
  131.                                 ent.setText("");
  132.                         }//end down
  133.                    floor[xpos][ypos]=1;    // move T ** added
  134.                     print();
  135.                 }
  136.  
  137.         }
  138.  
  139.         void print()
  140.         {
  141.                 output.setText("");   // ** added
  142.                 for(int x=0;x<floor.length;x++)
  143.                 {
  144.                         for(int y=0;y<=floor[0].length;y++)
  145.                         {
  146.                                 if(y==floor[0].length)
  147.                                 {
  148.                                         output.append("\n");
  149.                                         continue;
  150.                                 }//end if
  151.                                 if(floor[x][y]==0)
  152.                                         output.append("0");
  153.                                 else
  154.                                 if(floor[x][y]==1)
  155.                                         output.append("T");
  156.  
  157.                         }
  158.                 }
  159.          //  paint();
  160.         }
  161.  
  162.  
  163.                 public static void main(String args[])
  164.                 {
  165.                         new P7_21();
  166.                 }
  167. }
Dec 7 '06 #2
JulianP
11
Thanks,
I was looking for it to print a T when i put in left,right,up, or down.

not sure if what you did actually does something... I can see where your headed but right now it doesn't display a T when I type in right. I am useing Textpad if that helps at all.
Dec 11 '06 #3
r035198x
13,262 8TB
Thanks,
I was looking for it to print a T when i put in left,right,up, or down.

not sure if what you did actually does something... I can see where your headed but right now it doesn't display a T when I type in right. I am useing Textpad if that helps at all.
Sorry for being the dumb one here but could you please repeat again what you want to be printed where when what happens?
Dec 11 '06 #4
JulianP
11
In my program I am setting up a JTextField whith an array of [20][20] and it fills it with 0's. Right now I want it to start in the top left corner and when you type in the command right,left,up,down it will replace the 0 with a T. Here's a Copy of the program agian.

Expand|Select|Wrap|Line Numbers
  1. /* /* Julian Baranowski
  2. Date:12/7/2006
  3. Revised:
  4. Description: Turtle Graphics Program
  5. */
  6.  
  7.  
  8. import javax.swing.*;        // ** import statements
  9. import java.awt.event.*;    // ''
  10. import java.awt.*;            // ''
  11. import java.io.*;            // ''
  12.  
  13.  
  14. public class P7_211 extends JFrame implements ActionListener
  15. {
  16.         int floor[][];
  17.         JTextArea output, input;
  18.         JButton enter,exit;
  19.         JScrollPane jsp;
  20.         JTextField ent;
  21.         Container container;
  22.         int move[] ={8,6,4,2};
  23.         //int moved = 0;
  24.         int xpos=0, ypos=0;    // ** added
  25.         /*final*/ int LEFT = 4, RIGHT = 6, UP = 8, DOWN = 2;
  26.         String left,right,up,down;
  27.  
  28.         public P7_211()
  29.         {
  30.                 left="";
  31.                 right="";
  32.                 up="";
  33.                 down="";
  34.                 container= getContentPane();
  35.                 container.setLayout(null);
  36.  
  37.  
  38.                 floor = new int [20][20];
  39.                 setSize(800,500);
  40.  
  41.                 output = new JTextArea(20,50);
  42.                 output.setFont(new Font("Monospaced",Font.PLAIN,18));
  43.                 //output.setText("TEST");
  44.                 output.setBounds(5,5,350,300);
  45.                 output.setEditable(false);
  46.                 container.add(output);
  47.                 // ** output textfield
  48.  
  49.                 input = new JTextArea(5,50);
  50.                 input.setFont(new Font("Monospaced",Font.PLAIN,12));
  51.                 jsp = new JScrollPane(input);
  52.                 jsp.setBounds(430,5,360,300);
  53.                 //container.add(jsp);
  54.                 // ** input textfield
  55.  
  56.                 container.add(jsp);
  57.  
  58.                 ent = new JTextField();
  59.                 ent.setBounds(300,350,200,20);
  60.                 ent.setEditable(true);
  61.                 ent.addActionListener(this);
  62.                 container.add(ent);
  63.                 // ** enter textfield
  64.  
  65.  
  66.                 enter = new JButton("Enter");
  67.                 enter.addActionListener(this);
  68.                 enter.setBounds(300,400,100,20);
  69.                 container.add(enter);
  70.                 // ** enter button
  71.  
  72.                 exit = new JButton("Exit");
  73.                 exit.addActionListener(this);
  74.                 exit.setBounds(400,400,100,20);
  75.                 getContentPane().add(exit);
  76.                 container.add(exit);
  77.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  78.                 this.dispose();
  79.                 // ** exit button
  80.  
  81.                 print();
  82.  
  83.                 setVisible(true);
  84.  
  85.                 //int floor = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; // ** (not needed)
  86.         }
  87.  
  88.         public void actionPerformed(ActionEvent evt)
  89.         {
  90.  
  91.                 if(evt.getActionCommand().equals("Exit"))
  92.                         {
  93.                                 int choice = JOptionPane.showConfirmDialog(null,
  94.                                         " You Pressed "+ evt.getActionCommand()+" is this what you want to do? ",
  95.                                         " Quit Frame ",
  96.                                         JOptionPane.YES_NO_OPTION);
  97.                                 if( choice == 0)
  98.                                 this.dispose();
  99.                         }// ** end exit panel
  100.  
  101.  
  102.  
  103.                 if(evt.getSource()==enter || evt.getSource()==ent)
  104.                 {
  105.                          floor[xpos][ypos]=0;    // clear old T ** added
  106.  
  107.                         if(ent.getText().toLowerCase().compareTo("left")== 0)
  108.                         {
  109.                                 left ="Key:4 (LEFT)\n";
  110.                         System.out.println("Left");
  111.                                 input.append(left);
  112.                                 ent.setText("");
  113.                         }// ** end left
  114.  
  115.                         if(ent.getText().toLowerCase().compareTo("right")==0)
  116.                         {
  117.                                 right ="Key:6 (RIGHT)\n";
  118.                         System.out.println("right");
  119.                                 input.append(right);
  120.                                 ent.setText("");
  121.                                 if(ypos < 10 )ypos++;   // ** addded
  122.                                 floor[xpos][ypos]=1;
  123.                                 print();
  124.                         }// ** end right
  125.  
  126.                         if(ent.getText().toLowerCase().compareTo("up")==0)
  127.                         {
  128.                                 up ="Key:8 (UP)\n";
  129.                         System.out.println("Up");
  130.                                 input.append(up);
  131.                                 ent.setText("");
  132.                         }// ** end up
  133.  
  134.                         if(ent.getText().toLowerCase().compareTo("down")==0)
  135.                         {
  136.                                 down ="Key:2 (DOWN)\n";
  137.                         System.out.println("Down");
  138.                                 input.append(down);
  139.                                 ent.setText("");
  140.                         }// ** end down
  141.                    floor[xpos][ypos]=1;    // move T ** added
  142.                    print();
  143.                 }// ** end action listener
  144.  
  145.         }// ** end action performed
  146.  
  147.         void print()
  148.         {
  149.                 output.setText("");   // ** added
  150.                 for(int xpos=0;xpos<floor.length;xpos++)
  151.                 {
  152.                         for(int ypos=0;ypos<=floor[0].length;ypos++)
  153.                         {
  154.                                 if(ypos==floor[0].length)
  155.                                 {
  156.                                         output.append("\n");
  157.                                         continue;
  158.                                 }// ** end if
  159.                                 if(floor[xpos][ypos]==0)
  160.                                         output.append("0");
  161.                                 else
  162.                                 if(floor[xpos][ypos]==1)
  163.                                         output.append("T");
  164.  
  165.                         }// ** end inner for
  166.                 }// ** end outer for
  167.                 //floor[xpos][ypos]=1;
  168.                // print();
  169.           //paint();
  170.         }// ** end print()
  171.  
  172.  
  173.                 public static void main(String args[])
  174.                 {
  175.                         new P7_21();
  176.                 }// ** end main()
  177. }
Dec 11 '06 #5
horace1
1,510 Expert 1GB
I have added some code to do LEFT, RIGHT, UP, DOWN
Expand|Select|Wrap|Line Numbers
  1. /* /* Julian Baranowski
  2. Date:12/7/2006
  3. Revised:
  4. Description: Turtle Graphics Program
  5. */
  6.  
  7.  
  8. import javax.swing.*;        // ** import statements
  9. import java.awt.event.*;        // ''
  10. import java.awt.*;              // ''
  11. import java.io.*;               // ''
  12.  
  13.  
  14. public class P7_211 extends JFrame implements ActionListener
  15. {
  16.         int floor[][];
  17.         JTextArea output, input;
  18.         JButton enter,exit;
  19.         JScrollPane jsp;
  20.         JTextField ent;
  21.         Container container;
  22.         int move[] ={8,6,4,2};
  23.         //int moved = 0;
  24.         int xpos=0, ypos=0;    // ** added
  25.         /*final*/ int LEFT = 4, RIGHT = 6, UP = 8, DOWN = 2;
  26.         String left,right,up,down;
  27.  
  28.         public P7_211()
  29.         {
  30.                 left="";
  31.                 right="";
  32.                 up="";
  33.                 down="";
  34.                 container= getContentPane();
  35.                 container.setLayout(null);
  36.  
  37.  
  38.                 floor = new int [20][20];
  39.                 setSize(800,500);
  40.  
  41.                 output = new JTextArea(20,50);
  42.                 output.setFont(new Font("Monospaced",Font.PLAIN,18));
  43.                 //output.setText("TEST");
  44.                 output.setBounds(5,5,350,300);
  45.                 output.setEditable(false);
  46.                 container.add(output);
  47.                 // ** output textfield
  48.  
  49.                 input = new JTextArea(5,50);
  50.                 input.setFont(new Font("Monospaced",Font.PLAIN,12));
  51.                 jsp = new JScrollPane(input);
  52.                 jsp.setBounds(430,5,360,300);
  53.                 //container.add(jsp);
  54.                 // ** input textfield
  55.  
  56.                 container.add(jsp);
  57.  
  58.                 ent = new JTextField();
  59.                 ent.setBounds(300,350,200,20);
  60.                 ent.setEditable(true);
  61.                 ent.addActionListener(this);
  62.                 container.add(ent);
  63.                 // ** enter textfield
  64.  
  65.  
  66.                 enter = new JButton("Enter");
  67.                 enter.addActionListener(this);
  68.                 enter.setBounds(300,400,100,20);
  69.                 container.add(enter);
  70.                 // ** enter button
  71.  
  72.                 exit = new JButton("Exit");
  73.                 exit.addActionListener(this);
  74.                 exit.setBounds(400,400,100,20);
  75.                 getContentPane().add(exit);
  76.                 container.add(exit);
  77.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  78.                 this.dispose();
  79.                 // ** exit button
  80.  
  81.                 print();
  82.  
  83.                 setVisible(true);
  84.  
  85.                 //int floor = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; // ** (not needed)
  86.         }
  87.  
  88.         public void actionPerformed(ActionEvent evt)
  89.         {
  90.  
  91.                 if(evt.getActionCommand().equals("Exit"))
  92.                         {
  93.                                 int choice = JOptionPane.showConfirmDialog(null,
  94.                                         " You Pressed "+ evt.getActionCommand()+" is this what you want to do? ",
  95.                                         " Quit Frame ",
  96.                                         JOptionPane.YES_NO_OPTION);
  97.                                 if( choice == 0)
  98.                                 this.dispose();
  99.                         }// ** end exit panel
  100.  
  101.  
  102.  
  103.                 if(evt.getSource()==enter || evt.getSource()==ent)
  104.                 {
  105.                          floor[xpos][ypos]=0;    // clear old T ** added
  106.  
  107.                         if(ent.getText().toLowerCase().compareTo("left")== 0)
  108.                         {
  109.                                 left ="Key:4 (LEFT)\n";
  110.                         System.out.println("Left");
  111.                                 input.append(left);
  112.                                 ent.setText("");
  113.                                 if(ypos > 0 )ypos--;   // ** addded
  114.                                 floor[xpos][ypos]=1;
  115.                                 print();
  116.                         }// ** end left
  117.  
  118.                         if(ent.getText().toLowerCase().compareTo("right")==0)
  119.                         {
  120.                                 right ="Key:6 (RIGHT)\n";
  121.                         System.out.println("right");
  122.                                 input.append(right);
  123.                                 ent.setText("");
  124.                                 if(ypos < 10 )ypos++;   // ** addded
  125.                                 floor[xpos][ypos]=1;
  126.                                 print();
  127.                         }// ** end right
  128.  
  129.                         if(ent.getText().toLowerCase().compareTo("up")==0)
  130.                         {
  131.                                 up ="Key:8 (UP)\n";
  132.                         System.out.println("Up");
  133.                                 input.append(up);
  134.                                 ent.setText("");
  135.                                 if(xpos > 0 )xpos--;   // ** addded
  136.                                 floor[xpos][ypos]=1;
  137.                                 print();
  138.                         }// ** end up
  139.  
  140.                         if(ent.getText().toLowerCase().compareTo("down")==0)
  141.                         {
  142.                                 down ="Key:2 (DOWN)\n";
  143.                         System.out.println("Down");
  144.                                 input.append(down);
  145.                                 ent.setText("");
  146.                                 if(xpos < 10 )xpos++;   // ** addded
  147.                                 floor[xpos][ypos]=1;
  148.                                 print();
  149.                         }// ** end down
  150.                    floor[xpos][ypos]=1;    // move T ** added
  151.                    print();
  152.                 }// ** end action listener
  153.  
  154.         }// ** end action performed
  155.  
  156.         void print()
  157.         {
  158.                 output.setText("");   // ** added
  159.                 for(int xpos=0;xpos<floor.length;xpos++)
  160.                 {
  161.                         for(int ypos=0;ypos<=floor[0].length;ypos++)
  162.                         {
  163.                                 if(ypos==floor[0].length)
  164.                                 {
  165.                                         output.append("\n");
  166.                                         continue;
  167.                                 }// ** end if
  168.                                 if(floor[xpos][ypos]==0)
  169.                                         output.append("0");
  170.                                 else
  171.                                 if(floor[xpos][ypos]==1)
  172.                                         output.append("T");
  173.  
  174.                         }// ** end inner for
  175.                 }// ** end outer for
  176.                 //floor[xpos][ypos]=1;
  177.                // print();
  178.           //paint();
  179.         }// ** end print()
  180.  
  181.  
  182.                 public static void main(String args[])
  183.                 {
  184.                         new P7_211();
  185.                 }// ** end main()
  186. }
  187.  
Dec 11 '06 #6
r035198x
13,262 8TB
Horace has it then.
Dec 11 '06 #7
JulianP
11
Thank you so much now I just need to integrate a pen up and a pen down. (pen down draws and pen up doesnt) Thanks for your help so much! If I need help with the pen I will ask! Once agian thanks!!

-Julian
Dec 12 '06 #8
JulianP
11
Horace1 thanks for you help so far... i have another question here is the code i have for my pen up and pen down.

Expand|Select|Wrap|Line Numbers
  1.                          if(ent.getText().toLowerCase().compareTo("pen down")==0)
  2.                        {
  3.                                pd ="(PEN DOWN)\n";
  4.                        System.out.println("Pen Down");
  5.                                input.append(pd);
  6.                                ent.setText("");
  7.                                //if(xpos < 10 )xpos++;   // ** addded
  8.                                floor[xpos][ypos]=1;
  9.                                print();
  10.                         }// ** end pd
  11.  
  12.  
  13.                          if(ent.getText().toLowerCase().compareTo("pen up")==0)
  14.                        {
  15.                                pd ="(PEN UP)\n";
  16.                        System.out.println("Pen Up");
  17.                                input.append(pd);
  18.                                ent.setText("");
  19.                                //if(xpos < 10 )xpos++;   // ** addded
  20.                                floor[xpos][ypos]=0;
  21.                                print();
  22.                         }// ** end pu
  23.  
not exactly sure what i need to change for the pen up for it so that i can move without it printing...still looking at it for now if you dont post ill repost if i figure something out. input appreaciated! thanks!
Dec 12 '06 #9
JulianP
11
Nevermind. I figured it out with some help from a friend. Thanks for the first input!
Dec 13 '06 #10
r035198x
13,262 8TB
Nevermind. I figured it out with some help from a friend. Thanks for the first input!
Good work then. Maybe if you could post the solution you got so that some of us slow learners can understand what you were trying to do.
Dec 13 '06 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dbrown2 | last post by:
I typically use IDLE for editing and debug. On Windows at least, IDLE and the standard turtle graphics module do not mix. I think both use Tkinter. For now I use IPython and Jedit when using...
4
by: Brent W. Hughes | last post by:
If the Turtle gets himself into a large (or infinite) loop, is there any way to stop him other than Ctrl-Alt-Del? Brent
1
by: Brent W. Hughes | last post by:
I'm using the turtle graphics module and am trying to teach it to my kids. The slowness of the turtle in drawing things is good at first because it's fun watching it do its thing. But now we'd...
2
by: jevitop | last post by:
Hi, im looking for help on how to make a turtle graphics program. My head will explode trying to figure this out. if anyone can help me please do it, i'll appriciate it!!! Can anyone...
7
by: Dick Moores | last post by:
I accidentally stumbled across the Turtle Graphics module (turtle.py) the other day and have been having some fun with it. Now I'm wondering if there is a way to build into a script the saving...
5
by: tomy | last post by:
Hi All I am a newbie to turtle graphics in python, so sorry if you find this question too easy. How can I get smoother lines in turtle graphics? I am using python on windows. Thanks in advance
4
by: hello123 | last post by:
I saw this program from a website... Any solution ? Turtle Graphics: The Logo language, which is particularly popular among personal computer user, made the concept of turtle graphics famous. ...
1
by: Alexander.Oot | last post by:
I think the speed function may be broken from the turtle graphics package "from turtle import * speed('fastest') forward(50)"
1
by: Allen | last post by:
I'm using the turtle module in Python. Is there a way to save the turle state at any moment for recursive algorithms to easily return the turtle to an earlier point for another branch/etc? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.