Results 1 to 3 of 3
  1. #1
    Nouman is offline Member
    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Default Connect 4 Programming Project Help!

    Hey guyz, so i am a reaaly beginner programmer that only knows the basics, and i need to use an array to keep track of the pieces on the grid already.
    My program is below

    Java Code:
    // The "ConnecT4" class.
    import java.awt.*;
    import hsa.LASSConsole;
    
    public class ConnecT4
    {
        static LASSConsole c;           // The output console
    
        public static void main (String[] args) throws java.lang.InterruptedException
        {
            c = new LASSConsole ();
    
            // Place your program here.  'c' is the output console
            //Draw Te Grid
            DrawGrid (215, 70, 425, 425);
       
            while (true)
            {
    
                //Clear the screen
          
    
    
                //Show the current position of the mouse
            
                int x = c.GetMouseX ();
                int y = c.GetMouseY ();
    
              
    
                //Show the status of the three buttons
                c.println ("Buttons = " + c.GetMouseButtons ());
    
                DrawGrid (215, 70, 425, 425);
                if (c.GetMouseButtons () == 100 && x >= 220 && x <= 260)
                {
                 DrawGrid (215, 70, 425, 425);
                c.setColor (Color.blue);
                c.fillOval (218, 420, 425/ 7, 425/6);
                 
                }
                
                //Wait 100ms (1/10 of a second) before repeating
                Thread.sleep (500);
      
              
            }
    
    
    
        }
    
    
        public static void DrawGrid (int x, int y, int width, int length)
        {
         
            //Setting the basic yellow grid in the back
    
            c.setColor (Color.black);
            c.fillRect (x, y, width, length);
            //Drawing the set gird circles
            c.setColor (Color.white);
            int Ovals = 0;
            
            for (int i = 0 ; i <= 41 ; i++)
            {
                //Draw the blue outline for each oval
    
                c.setColor (Color.blue);
                c.drawOval (x + 3, y, width / 7, length / 6);
                //Start drawing the circles
                c.setColor (Color.white);
                c.fillOval (x + 3, y, width / 7, length / 6);
                //Update the x count to draw circles beside eachother
                x = x + 60;
                //Update ovals so maximum number isnt exceeded
                Ovals = Ovals + 1;
                //If Ovals = 7 then start drawing the Ovals on the next line
                if (Ovals == 7)
                {
                    x = x - 420;
                    y = y + 70;
    
                }
                //If Ovals = 14 then start drawing ovals on the next line
                if (Ovals == 14)
                {
    
                    x = x - 420;
                    y = y + 70;
                }
                //If Ovals = 21 then draw the ovals on the next row
                if (Ovals == 21)
                {
                    x = x - 420;
                    y = y + 70;
    
                }
                //If ovals = 28 then start drawing them on the next row
                if (Ovals == 28)
                {
                    x = x - 420;
                    y = y + 70;
                }
                //If ovals = 35, then start drawing it on the last row
                if (Ovals == 35)
                {
                    x = x - 420;
                    y = y + 70;
                }
            }
    
    
    
    
        }
    
    
        // ConnecT4 class
    
    
    
    } // main method

    So all i need help with is how to add an array to keep track of my 42 pieces on the board
    Last edited by JavaForums; 05-31-2011 at 06:45 PM. Reason: [code] tag added.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    For the record: I deleted your other identical thread.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Programming Project trouble..
    By hockey9999 in forum New To Java
    Replies: 1
    Last Post: 12-20-2010, 08:07 PM
  2. Fairly Simple (I think) programming project
    By Glyph in forum Jobs Offered
    Replies: 0
    Last Post: 10-22-2010, 12:16 AM
  3. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 10:15 AM
  4. Replies: 2
    Last Post: 04-12-2010, 05:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •