473,732 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turtle Graphics Program

11 New Member
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 5528
horace1
1,510 Recognized Expert Top Contributor
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 New Member
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 MVP
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 New Member
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,d own 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 Recognized Expert Top Contributor
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 MVP
Horace has it then.
Dec 11 '06 #7
JulianP
11 New Member
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 New Member
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...stil l 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 New Member
Nevermind. I figured it out with some help from a friend. Thanks for the first input!
Dec 13 '06 #10

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

Similar topics

1
6727
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 the turtle module but it's not a great solution for me. Is there any known work-around to use turtle with IDLE? If not is there a planned fix for the problem. I find turtle is a convenient way to do simple graphics without having to install...
4
5019
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
3632
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 like it to go faster so it doesn't take to long to see what it is producing. Is there a standard way to speed it up, or am I left with sifting through the source code to fix it myself? Brent
2
10770
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 post the source code for the program???
7
20722
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 of each window just before it is cleared. For example, here are a couple that I've saved by screen capture: <http://www.rcblue.com/Misc/RandomTriangles.jpg> <http://www.rcblue.com/Misc/RandomTriangles2.jpg> They were produced by this script:
5
6652
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
6853
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. Imagine a mechanical turtle that walks around the room under control of c++ program. The turtle holds a pen in one of the two positions, up or down. While the pen is down, the turtle traces out shapes as it moves; while the pen is up, the turtle moves...
1
2490
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
2656
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? Brian Vanderburg II
0
8944
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.