hi guys.. i need help.. can you give me a simple program of games in java except for tic-tac toe? i need it at the end of july.. i want to pass this subject and i want to master this programming language... please do grant my request... thank you very much

Do your own homework. You have a month, do it. God, asking for someone to do your work for you, then saying, in the same breath no less, that you want to master the language. Well, buddy, those two statements just do not go together.

hi guys.. i need help.. can you give me a simple program of games in java except for tic-tac toe? i need it at the end of july.. i want to pass this subject and i want to master this programming language... please do grant my request... thank you very much

If somebody writes the game for you, it is going to work adversly towards your mastering of the language. Google would be a good place to start, and not just the first results page.

since you are taking the subject, you'll propably have examples in your textbook or a course. try to understand what they do, create alternative sollutions, ...
this is a better (and faster) way to learn java than asking someone you don't know and who'll propably use code you don't understand to make it for you.

just choose for yourself what kind of program you want, decide on the classes, make them and use them. even if the program isn't completed at the end of the month, at least your teacher will see you've given it some effort.

How about a simple card game like blackjack!

Make a class called card and initialize each one putting them into a container like a list. You could then implement an algorithm to shuffle the cards too.

I wrote a tic-tac-toe program in about an hour for AP Computer Science. In a week we wrote a fully functional monopoly. (just to give you an idea of what a month can do)

Suggestion for implementation of a tic-tac-toe program:

Make a grid of buttons with transparent .gifs via loop(using gridbag or something to make the 3x3 grid) and place them into a two dimensional array (or populate a two dimensional array with a small class representing the buttons). The buttonclick method could then replace the button being clicked with either an x or an o .gif, then call a method to check for 3 of the same .gifs (or flag variables in the classes) in a row in the various directions. Once one of the players wins, display a win message and disable the buttons.

The one that I wrote was 3 classes and totaled only 340 lines including the gui. A tic-tac-toe program shouldn't take you very long at all to write, so knock it out early and enjoy your month :p

Whoops, missed the part with "except" on the tic tac toe idea. :p

Connect 4 is an easy game that can be done with an expanded version of the "Suggestion for implementation of a tic-tac-toe program:" above with the addition of a timer and using only a single row of actual buttons.


Monopoly is an easy game to write if you keep it basic, though requires lots of gui code, which can take time to work through if you get something wrong.

If you don't like guis and prefer algorithms, you can try Tetris (friend of mine wrote one in about a week and a half) or simple card games as stated above.

I think he already left once he found out we wouldn't just hand him a completed assignment to turn in.

I think he already left once he found out we wouldn't just hand him a completed assignment to turn in.

He still has 26 days before he realizes no-one else will give him a completed assignment either. :p

I think the connect 4 idea was good anyways. I hope he comes back and tries it.

I think the connect 4 idea was good anyways. I hope he comes back and tries it.

I agree :)

but I seriously doubt he will (unless it is under another pseudonym trying to trick people into doing his homework some other way).

hello... since you cant help me in my PROJECT, i downloaded a game in java... it is called "blocks".. im not so sure if it is running correctly. can i ask a favor again? will you please correct if its not complete or if there is wrong in the program...? please help me i beg you... thank you..

here's the program:

import java.util.Random;
import java.awt.Graphics;
import java.awt.*; //setColor is somewhere in java.awt and it is needed

public class Block implements Paintable, Variables {
    public int xPos;
    public int yPos;
    private int rotations;
    int blockGrid[][];
    int type;

    Block (int xPosition, int yPosition, int blockType) {
        //Make a new block
        xPos = xPosition;
        yPos = yPosition;
        type = blockType;
            this.blockGrid = new int[4][4];
            switch (blockType) {
                case 1:
                    // make a cube piece
                    blockGrid[1][2]=2;
                    blockGrid[1][3]=2;
                    blockGrid[2][2]=2;
                    blockGrid[2][3]=2;
                    rotations=1;
                    break;
                case 2:
                    // make a line piece
                    blockGrid[2][0]=3;
                    blockGrid[2][1]=3;
                    blockGrid[2][2]=3;
                    blockGrid[2][3]=3;
                    rotations=2;
                    break;
                case 3:
                    // make a middle finger piece
                    blockGrid[1][2]=4;
                    blockGrid[2][2]=4;
                    blockGrid[3][2]=4;
                    blockGrid[2][3]=4;
                    rotations=4;
                    break;
                case 4:
                    // make an L piece
                    blockGrid[2][1]=5;
                    blockGrid[2][2]=5;
                    blockGrid[2][3]=5;
                    blockGrid[3][3]=5;
                    rotations=4;
                    break;
                case 5:
                    // make a J piece
                    blockGrid[2][1]=6;
                    blockGrid[2][2]=6;
                    blockGrid[2][3]=6;
                    blockGrid[1][3]=6;
                    rotations=4;
                    break;
                case 6:
                    // make a S piece
                    blockGrid[1][1]=1;
                    blockGrid[1][2]=1;
                    blockGrid[2][2]=1;
                    blockGrid[2][3]=1;
                    rotations=6;
                    break;
                default:
                    // make a slash piece
                    blockGrid[3][1]=7;
                    blockGrid[3][2]=7;
                    blockGrid[2][2]=7;
                    blockGrid[2][3]=7;
                    rotations=6;
                    break;
            }
        } //end of Block constructor

    public void rotate () {

        int[][] temp = new int[4][4];

        switch(rotations) {
            case 1:
                break;
            case 6:
                //rotate 180 along 2, 2 (or 3, 3 in Cartesian)

                if (blockGrid[1][3] != 0) {
                    for (int x=1; x < 4; x++) {
                        for (int y=1; y < 4; y++) {
                            temp[x][y] = blockGrid[y][4-x];
                        }
                    }

                    for (int x=1; x < 4; x++) {
                        for (int y=1; y < 4; y++) {
                            blockGrid[x][y] = temp[y][4-x];
                        }
                    }
                }

            case 4:
                //rotate CW   center of rotation is 2, 2
                //            or (3, 3) in non-array grid

                for (int x=1; x < 4; x++) {
                    for (int y=1; y < 4; y++) {
                        temp[x][y] = blockGrid[y][4-x];
                    }
                }

                for (int y=0; y < 4; y++) {
                    for (int x=0; x < 4; x++) {
                        blockGrid[x][y] = temp[x][y];
                    }
                }
                break;

            case 2:
                //reflection along diagonal

                for (int y=0; y < 4; y++) {
                    for (int x=0; x < 4; x++) {
                        temp[x][y] = blockGrid[y][x];
                    }
                }

                for (int y=0; y < 4; y++) {
                    for (int x=0; x < 4; x++) {
                        blockGrid[x][y] = temp[x][y];
                    }
                }
                break;
        } //end of switch
    } //end of rotate

    public void paint(Graphics screen, int a, int b) {
        for (int x=0; x<4; x++) {
            for (int y=0; y<4; y++) {
                if ( (blockGrid[x][y] != 0) && (y + yPos >= 0) ) {

                    int key = blockGrid[x][y];
                    int cornerX = (x + xPos) * (blockSize + blockSpacing) + a;
                    int cornerY = (y + yPos) * (blockSize + blockSpacing) + b;

                    //draw a rectangle
                    screen.setColor(BlocksGame.changeColor(key));
                    screen.fillRect
                        (cornerX + 1, cornerY + 1, blockSize - 2, blockSize - 2);

                    //draw highlights
                    screen.setColor(BlocksGame.changeColor(key, 0));
                    screen.drawLine
                        (cornerX, cornerY, cornerX + blockSize - 1, cornerY);
                    screen.drawLine
                        (cornerX, cornerY, cornerX, cornerY + blockSize - 1);

                    //draw shadow
                    screen.setColor(BlocksGame.changeColor(key, 1));
                    screen.drawLine
                        (cornerX + blockSize - 1, cornerY + 1,
                        cornerX + blockSize - 1, cornerY + blockSize - 1);
                    screen.drawLine
                        (cornerX + 1, cornerY + blockSize - 1,
                        cornerX + blockSize - 1, cornerY + blockSize - 1);

                    if (BlocksGame.helper && (cornerX < 330)) {
                        //draw helper lines
                        screen.setColor(Color.lightGray);
                        screen.drawLine
                            (cornerX - 1, cornerY + blockSize,
                            cornerX - 1, 321);
                        screen.drawLine
                            (cornerX + blockSize, cornerY + blockSize,
                            cornerX + blockSize, 321);
                    }
                }
            }
        }
    } //end of paint

} //end of class


import java.awt.event.*;
import java.awt.*;
import java.util.Random;

public class BlocksGame extends java.applet.Applet
    implements Variables, Runnable {

    Block currentBlock;
    Block previewBlock;
    Field gameField;
    Score scoreBox;
    GameOver gameOverWindow;

    Thread runner;
    Frame window;

    Image offscreenImage; // these are for double buffering
    Graphics offscreen;

    public static boolean helper=true; // those grey lines
    int gameSpeed; //see levelUp; game begins with level up
    private boolean gameOver;
    private int gameLevel;
    int gameScore;
    private int wheelHue; //holding a value for method changeColor
    private boolean hardDrop=false; //holding a value for spacebar / hard drop

    Image blocksPicture;

    public void init() {
        gameOver = true;

        gameField = new Field();
        scoreBox = new Score();


        requestFocus(); //need that to get keypresses of course

        blocksPicture = getImage(getCodeBase(), "blocks.gif");
        offscreenImage = createImage(size().width, size().height);
        offscreen = offscreenImage.getGraphics();

        repaint();

        newPreview();

    }

    public void startGame() {

        gameLevel = -1;
        levelUp(); //sets the gamespeed
        gameScore = 0;

        //clear the gamefield
        for (int x = 0; x < fieldWidth; x++) {
            for (int y = 0; y < fieldHeight; y++) {
                gameField.addToField(x, y, 0);
            }
        }

        repaint();
        repaint();
        repaint();
        shiftBlocks();
        newPreview();
                        // the random is time-based so a delay
                        // helps ensure that the preview and current
                        // block are not the same.
        gameOver=false;
    }

    public void shiftBlocks() {
        //Makes the current block what preview block is.
        currentBlock = new Block(
            (fieldWidth / 2) - 2, -3, previewBlock.type
            );

        // checks if the block overlaps when it is placed
        if (blockHitTest(0)) {
            gameOver();
        }
    }

    public void newPreview() {
        //Makes a new preview block
        Random r = new Random();
        int previewBlockType = (int)(r.nextDouble() * 7) + 1;
        previewBlock = new Block(10, 0, previewBlockType);
    }

    public void update(Graphics g) {
        paint(g);
    }

    public void paint(Graphics screen) {

        //Clear offscreen
        offscreen.setColor(Color.white);
        offscreen.fillRect(0, 0, size().width, size().height);
        offscreen.setColor(Color.black);

        offscreen.drawImage(blocksPicture, 0, 0, this);

        //display the field
        gameField.paint(offscreen, shiftX + 1, shiftY + 1);

        //display the current block
        if ((currentBlock != null) && !gameOver) {
            currentBlock.paint(offscreen, shiftX + 1, shiftY + 1);
        }

        //display the preview block
        previewBlock.paint(offscreen, shiftX + 1, shiftY + 1);

        //display the score
        scoreBox.paint(offscreen, 329, 259,
            gameLevel * linesPerLevel + gameScore, gameLevel);

        //move contents of offscreen buffer onto the real screen
        screen.drawImage(offscreenImage, 0, 0, this);

        if (window != null) {
            window.repaint();
        }

    }//end of override of paint

    public void destroy() {
        offscreen.dispose();
    }

    //thread code
    public void start() {
        if (runner == null) {
            runner = new Thread(this);
            runner.start();
        }
    }

    public void run() {
        Thread thisThread = Thread.currentThread();

        while ((runner == thisThread)) {
        if (!gameOver) {

            // putting collision check after block is shifted down
            // disables trick placement!  I like trick placement.


            if (!blockHitTest(1)) {
                currentBlock.yPos++;
                // argument of 1 in blockHitTest tests for blocks
                // 1 BELOW the piece, instead of checking overlapping.
            } else {
                addBlock();
            }   // end of if loop, which moves current block down one
                // among other things.

            repaint();

            try {
                Thread.sleep(gameSpeed);
            } catch (InterruptedException e) { }
        }
        }
    }

    public void addBlock() {

        int[] checkLines = new int[4];  // holds y values to check
        int counter = 0;                // for line breaks.

        addingToFieldLoop:
        for (int y=3; y >= 0; y--) {
            for (int x = 0; x < 4; x++) {

            // nested for loops reads in rows, from bottom to top

                if ((currentBlock.blockGrid[x][y] != 0)) {

                    //checks if game is over
                    if ((y + currentBlock.yPos) < 0) {
                        gameOver=true;
                        break addingToFieldLoop;
                    }

                    gameField.addToField(
                    x + currentBlock.xPos,
                    y + currentBlock.yPos,
                    currentBlock.blockGrid[x][y]);

                    checkLines[counter] = y + currentBlock.yPos;
                    counter++;
                    // Holds y values to check for line breaks later
                }
            }
        }

                //Checks four times if a complete line was created,
                //*all at once*.  If lines were deleted while the
                //current block was being added to the field,
                //there would be wierd things happening!
                //I think.

        int linesBroken = 0;

        for (int counter2=3; counter2 >= 0; counter2--) {
            linesBroken += gameField.checkLines(checkLines[counter2]);
            // checkLines checks for line breaks
            // starting with higher lines (important!)
        }

        gameScore += linesBroken;
        while(linesBroken >= 3) {
            gameScore++;
            linesBroken--;
        }
        // gives 1 bonus point for breaking 3 lines at once,
        // and 2 bonus points for 4 lines.

        if (!gameOver) {
            shiftBlocks();
            newPreview();
        }

        // checks if we've leveled
        if (gameScore >= linesPerLevel) {
            levelUp();
        }

        if (gameOver) {
            gameOver();
        }
    }

    public void stop() {
        if (runner != null) {
            runner = null;
        }
    }
    // end of thread code

    //input handling for keyboard presses
    public boolean keyDown(Event evt, int key) {
        switch (key) {
            case Event.F1:
            case Event.F10:
                if (helper) {
                    helper = false;
                    } else {
                    helper = true;
                }
                break;
            case 82:
            case Event.F2:
                // starts a new game
                if (gameOver) {
                    startGame();
                }
                break;
        }

        if (!gameOver) {
            switch (key) {
                //case 27:
                    //for cheating only
                    //gameScore += linesPerLevel;
                    //levelUp();
                    //break;
                case 44:
                    // 44 is < or ,
                case Event.LEFT:
                    currentBlock.xPos--;
                    if (blockHitTest(0) && !gameOver) {
                        currentBlock.xPos++;
                    }
                    break;
                case 46:
                    // 46 is > or .
                case Event.RIGHT:
                    currentBlock.xPos++;
                    if (blockHitTest(0)) {
                        currentBlock.xPos--;
                    }
                    break;
                case Event.DOWN:
                    // soft drop
                    currentBlock.yPos++;
                    if (blockHitTest(0)) {
                        currentBlock.yPos--;
                    }
                    break;
                case 32:
                    // Hard drop: space bar
                    while (!blockHitTest(1) && !hardDrop) {
                        currentBlock.yPos++;
                    }
                    hardDrop = true;

                    //if (blockHitTest(1)) {
                    //    addBlock();
                    //}
                    //if I try to implement this wierd things happen.
                    //I am not going to bother.

                    break;
                case 122:
                    // CCW rotation: z
                    currentBlock.rotate();
                    currentBlock.rotate();
                    currentBlock.rotate();
                    if (blockHitTest(0)) {
                        currentBlock.rotate();
                    }
                    break;
                case 120:
                    // CW rotation: x
                case Event.UP:
                    currentBlock.rotate();
                    if (blockHitTest(0)) {
                        currentBlock.rotate();
                        currentBlock.rotate();
                        currentBlock.rotate();
                    }
                    //hahahahaha.  I just undo illegal moves. :)    
                    break;
            }
        }
        repaint();
        return true;
    }

    public boolean keyUp(Event evt, int key) {
        // Handles key up, of only one which we care about- spacebar
        // This is so that multiple blocks don't come down because you
        // accidentally held spacebar too long.
        switch(key) {
            case 32:
                hardDrop = false;
                break;
        }
        return true;
    }

    public boolean blockHitTest(int n) {
        for (int x=0; x<4; x++) {
            for (int y=0; y<4; y++) {
                if ( currentBlock.blockGrid[x][y] != 0 ) {
                    if ( gameField.hitTest
                        (x + currentBlock.xPos, y + currentBlock.yPos + n)
                        ) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public void gameOver() {
        gameOver = true;
        gameField.gameOver();

        gameOverWindow = new GameOver("GAME OVER.",
            (gameLevel * linesPerLevel + gameScore));
        WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                gameOverWindow.hide();
            }
        };
        gameOverWindow.addWindowListener(l);

        gameOverWindow.resize(250,400);
        if(!gameOverWindow.isShowing()) {
            gameOverWindow.show();
        }
    }

    public void levelUp() {
        int constant = 90;
        gameScore -= linesPerLevel;
        gameLevel++;
        double n;
        n = 1000 / (gameLevel + 3); // if changing this make sure division
                                    // by 0 doesn't occur!
        gameSpeed = constant + (int)(3 * n) - gameLevel;
            // if you graph y = 1 / x, there is a curve where x diminishes
            // by less and less as y increases.  It looks like a slide.
            // Adding the constant makes the game less fast at higher levels
            // At level 100 1/x would be 10 miliseconds!!!

        // for testing only
        System.out.println("Game delay is: " + gameSpeed);
    }

    public static Color changeColor
        (int key) {

        // Check for white
        if (key == 0) {
            return Color.white;
        }

        // key gets translated into a hue

        float hue = (selectColor(key) / 360F);

        return Color.getHSBColor(hue, blockSat, blockBright);
    }

    public static Color changeColor(int key, int highlight) {
        float hue = (selectColor(key) / 360F);
        switch (highlight) {
            case 0:
                return Color.getHSBColor(hue, highlightSat, highlightBright);
            default:
                return Color.getHSBColor(hue, shadowSat, shadowBright);
        }
    }

    public static int selectColor(int key) {
        switch (key) {
            case 0:
                // White (which has no hue...)
                return 0;
            case 1:
                // Red
                return 0;
            case 2:
                // Orange
                return 30;
            case 3:
                // Yellow
                return 60;
            case 4:
                // Green
                return 120;
            case 5:
                // Light Blue/Cyan/Sky
                return 180;
            case 6:
                // Dark Blue
                return 240;
            case 7:
                // Magenta / Purple / Violet
                return 290;
        } //end of switch that determines hue
        System.out.println("select Color out of range");
        return 0;
    }        
}

import java.awt.Graphics;
import java.awt.*;

public class Field implements Paintable, Variables {

    int[][] field = new int[10][20];
    boolean fullLine = false; //need this variable to hold info from loop

    //constructor
    Field() {

        // G    color: Red
        int g = 1;
        field[3][0]=g;
        field[2][0]=g;
        field[1][0]=g;
        field[0][0]=g;
        field[0][1]=g;
        field[0][2]=g;
        field[0][3]=g;
        field[0][4]=g;
        field[1][4]=g;
        field[2][4]=g;
        field[3][4]=g;
        field[3][3]=g;
        field[3][2]=g;
        field[2][2]=g;

        // o (first)    color: Yellow
        int o = 3;
        field[4][3]=o;
        field[5][3]=o;
        field[5][4]=o;
        field[5][5]=o;
        field[4][5]=o;
        field[3][5]=o;

        // o (second)   color: Sky Blue
        o = 5;
        field[6][4]=o;
        field[7][4]=o;
        field[7][5]=o;
        field[7][6]=o;
        field[6][6]=o;
        field[5][6]=o;

        // d    color: Dark Blue
        int d = 6;
        field[8][6]=d;
        field[9][4]=d;
        field[9][5]=d;
        field[9][6]=d;
        field[9][7]=d;
        field[9][8]=d;
        field[8][8]=d;
        field[7][8]=d;
        field[7][7]=d;

        // L    color: Green
        int L = 4;
        field[0][7]=L;
        field[0][8]=L;
        field[0][9]=L;
        field[0][10]=L;
        field[1][10]=L;
        field[2][10]=L;

        // u    color: Orange
        int u = 2;
        field[2][9]=u;
        field[2][11]=u;
        field[3][11]=u;
        field[4][11]=u;
        field[4][10]=u;
        field[4][9]=u;

        // c    color: Violet/Purple
        int c = 7;
        field[6][11]=c;
        field[5][11]=c;
        field[4][12]=c;
        field[4][13]=c;
        field[5][13]=c;
        field[6][13]=c;

        //k     color: Red
        int k = 1;
        field[7][10]=k;
        field[7][11]=k;
        field[7][12]=k;
        field[7][13]=k;
        field[7][14]=k;
        field[9][12]=k;
        field[8][13]=k;
        field[9][14]=k;

        //!Exclamations color: Green
        int e = 4;
        field[0][16]=e;
        field[0][17]=e;
        field[0][19]=e;

        field[2][16]=e;
        field[2][17]=e;
        field[2][19]=e;

        field[4][16]=e;
        field[4][17]=e;
        field[4][19]=e;

        field[6][16]=e;
        field[6][17]=e;
        field[6][19]=e;

        field[8][16]=e;
        field[8][17]=e;
        field[8][19]=e;
        //end of my pretty 'picture'
    }

    public void paint(Graphics screen, int x, int y) {

        for (int i=0; i<fieldWidth; i++) {
            for (int n=0; n<fieldHeight; n++) {
                if (field[i][n] == 0) {
                    //draw white
                    screen.setColor(Color.white);
                    screen.fillRect(
                    i * (blockSize + blockSpacing) + x,
                    n * (blockSize + blockSpacing) + y,
                    blockSize,
                    blockSize);
                } else {

                    // Modified code from Block class
                    int key = field[i][n];
                    int cornerX = (i) * (blockSize + blockSpacing) + x;
                    int cornerY = (n) * (blockSize + blockSpacing) + y;

                    //draw a rectangle
                    screen.setColor(BlocksGame.changeColor(key));
                    screen.fillRect
                        (cornerX + 1, cornerY + 1, blockSize - 2, blockSize - 2);

                    //draw highlights
                    screen.setColor(BlocksGame.changeColor(key, 0));
                    screen.drawLine
                        (cornerX, cornerY, cornerX + blockSize - 1, cornerY);
                    screen.drawLine
                        (cornerX, cornerY, cornerX, cornerY + blockSize - 1);

                    //draw shadow
                    screen.setColor(BlocksGame.changeColor(key, 1));
                    screen.drawLine
                        (cornerX + blockSize - 1, cornerY + 1,
                        cornerX + blockSize - 1, cornerY + blockSize - 1);
                    screen.drawLine
                        (cornerX + 1, cornerY + blockSize - 1,
                        cornerX + blockSize - 1, cornerY + blockSize - 1);
                }
            }
        }
    } //end of paint

    public void addToField(int x, int y, int value) {
         field[x][y] = value;
    }

    public int checkLines(int y) {
        this.fullLine = true;

        for (int i = 0; i < fieldWidth; i++) {
            if (field[i][y] == 0) {
                this.fullLine = false;
            }
        }

        if (this.fullLine == true) {

            //pull top lines down
            for (int x = 0; x < fieldWidth; x++) {
                for (int lineY = y; lineY > 0; lineY--) {
                    field[x][lineY] = field[x][lineY-1];
                }
                field[x][0]=0;
            }
            return 1;
        } else {
        return 0;
        }
    }

    public boolean hitTest (int x, int y) {
        //checks if it bumps the sides or bottom
        //19 is the last array index
        if ( x < 0 || x > 9 || y > 19 ) {
            return true;
        }

        //when currentBlock is at the top, checks if it hits the sides
        if ( y < 0 ) {
            if ( x < 0 || x > 9 ) {
                return true;
            }
            return false;
        }

        //checks for collision with the field, duh
        if ( field[x][y] != 0 ) {
            return true;
            } else {
            return false;

        }
    }

    public void gameOver() {
        //fill field with red
        for (int x = 0; x < fieldWidth; x ++) {
            for (int y = 0; y < fieldHeight; y++) {
                field[x][y]=1;
            }
        }

        // Spell GAME OVER in white letters

        //G
        field[2][1]=0;
        field[1][1]=0;
        field[0][1]=0;
        field[0][2]=0;
        field[0][3]=0;
        field[0][4]=0;
        field[1][4]=0;
        field[2][4]=0;
        field[2][3]=0;

        //A
        field[0][9]=0;
        field[0][8]=0;
        field[0][7]=0;
        field[0][6]=0;
        field[1][6]=0;
        field[2][6]=0;
        field[2][7]=0;
        field[2][8]=0;
        field[2][9]=0;
        field[1][8]=0;

        //M
        field[0][13]=0;
        field[0][12]=0;
        field[0][11]=0;
        field[1][11]=0;
        field[2][11]=0;
        field[3][11]=0;
        field[4][12]=0;
        field[4][13]=0;
        field[2][12]=0;
        field[2][13]=0;

        //E
        field[2][15]=0;
        field[1][15]=0;
        field[0][15]=0;
        field[0][16]=0;
        field[0][17]=0;
        field[0][18]=0;
        field[1][18]=0;
        field[2][18]=0;
        field[3][18]=0;
        field[2][17]=0;
        field[1][17]=0;

        //O
        field[6][1]=0;
        field[7][1]=0;
        field[8][1]=0;
        field[8][2]=0;
        field[8][3]=0;
        field[8][4]=0;
        field[7][4]=0;
        field[6][4]=0;
        field[6][3]=0;
        field[6][2]=0;

        //V
        field[6][6]=0;
        field[6][7]=0;
        field[6][8]=0;
        field[7][9]=0;
        field[8][8]=0;
        field[8][7]=0;
        field[8][6]=0;

        //E
        field[8][11]=0;
        field[7][11]=0;
        field[6][11]=0;
        field[6][12]=0;
        field[6][13]=0;
        field[6][14]=0;
        field[7][14]=0;
        field[8][14]=0;
        field[9][14]=0;
        field[8][13]=0;
        field[7][13]=0;

        //R
        field[6][19]=0;
        field[6][18]=0;
        field[6][17]=0;
        field[6][16]=0;
        field[7][16]=0;
        field[8][16]=0;
        field[8][17]=0;
        field[7][17]=0;
        field[9][18]=0;
        field[9][19]=0;
        // end of 'GAME OVER'
    }


} //end of class

import java.awt.*;

class GameOver extends Frame implements Variables {

int score=0;

    GameOver(String title, int i) {
        super(title);
        score = i;

        Button close = new Button ("Good Game.");
        setLayout(new FlowLayout(FlowLayout.CENTER, 10, 315));
        add(close);
    }

    public void update(Graphics g) {
        // Kills the flickering
        paint(g);
    }

    public void paint (Graphics g) {
        String mess="Your rank is: ";
        String rank[] = { "Addict", "Damn Nerd",
            "1337 5<R1P7 |<1DD13", "Alexey Pazhitnov's Grandma",
            "New kid on the block", "Utter blockhead", "Block sucker" };

        FontMetrics fm;
        Font plain = new Font("Helvetica", Font.PLAIN, 14);
        Font bold = new Font("Helvetica", Font.BOLD, 14);

        fm= g.getFontMetrics();
        int y = 25;

        if (score > 42 * linesPerLevel)
            mess += rank[0];
            else if (score>37*linesPerLevel) 
                mess += rank[1];
            else if (score>31*linesPerLevel) 
                mess += rank[2];
            else if (score>22*linesPerLevel) 
                mess += rank[3];
            else if (score>12*linesPerLevel) 
                mess += rank[4];
            else if (score>3*linesPerLevel)
                mess += rank[5];
            else if (score <= 3*linesPerLevel)
                mess += rank[6];
        g.setFont(bold);
        g.drawString(mess, 15, y + 20);
        g.drawString(" [Score= " + score + " ]", 15, y + 40);

        g.setFont(plain);
        for (int i = 1; i < 8; i++) {
            g.setColor( BlocksGame.changeColor(i, 1));
            g.drawString(rank[i - 1], 15, (i * y) + 80);
        }
    }

    public boolean action(Event evt, Object arg) {
        if (evt.target instanceof Button ) {
            hide();
            return true;
        } else {
            return false;
        }
    }

}

import java.awt.Graphics;

public interface Paintable {
    public void paint(Graphics screen, int x, int y);
}

//import java.awt.Graphics;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.*;

public class Score {

    public void paint(Graphics screen, int x, int y, int score, int level) {

        int textX = 4;
        int textY = 16;
        String text = "Lines: " + score;
        String text2 = "Level: " + level;

        Font f = new Font("Helvetica", Font.PLAIN, 10);
        screen.setFont(f);
        screen.setColor(Color.black);

        //Draw the box around the score; rounded corners of 3X3 pixels

        screen.drawRoundRect(
            x, y, 59, 61, 3, 3);

        screen.drawString(text, x + textX, y + textY);
        screen.drawString(text2, x + textX, 2 * textY + y + 15);

        // for testing purposes
        // System.out.println("Width of text: " + fm.stringWidth(text2));
        // System.out.println("Width of text: " + fm.stringWidth(text));
    }                                     
}

public interface Variables {
    public int shiftX=208;
    public int shiftY=81;
    public int blockSize=11;
    public int blockSpacing=1;
    public int fieldWidth = 10;
    public int fieldHeight = 20;
    public int linesPerLevel = 6; // Change this to 10 - 20

    public float blockSat=0.6F;
    public float blockBright=0.9F;
    public float shadowSat=1F;
    public float shadowBright=0.3F;
    public float highlightSat=0.35F;
    public float highlightBright=1.0F;
}
commented: Bad attitude, not willing to learn -1
commented: Name is offensive and post indicates no effort to understand anything about the question. +0

I thought you wanted to write a game (at least that is what the first post said) not simply scrape one (although the first post said this, too).

You also said you wanted to master the language (once again according to your first post), but now you are not even willing to attempt to debug the code you scraped from somewhere else.

I don't think anything else needs to be said.

I thought you wanted to write a game (at least that is what the first post said) not simply scrape one (although the first post said this, too).

You also said you wanted to master the language (once again according to your first post), but now you are not even willing to attempt to debug the code you scraped from somewhere else.

Seconded.

Seconded.

And "thirded" even.

genocide (I hate to even address someone who chose that as a name), you have shown no effort whatsoever. The only way to learn a language is to use it, which includes debugging. You have not even stated what you think is not working correctly. No one here is going to pick through this for you and attempt to fix it for you. You've made it quite clear you want a "project" done for you and you do not have any interest in learning anything about Java.

Also, some unsolicited advice: have a bit of common sense and decency in choosing a name by which to post.

and he fails to even bother to use code tags to make the thousand or so lines of terrible (how can it be otherwise) code he wants us to correct for him so he can pass it off as his own easier to read.

Incompetent liar, lazy, and inconsiderate as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.