Pacman Questions in Java

For my university assignment, I have to make a network version of pacman. I thought that the best approach to this problem is to first create a local copy of pacman and then expand it for a network game.

I have to say that I am relatively new to developing the Java GUI and using such functions in java.

I started following the links above regarding developing a game in java and an example pacman game.

I decided to represent the maze as an int array with different values ​​meaning different things. However, when the drawing method is executed inside the main game loop, I redraw the entire maze using this method.

    for (int i : theGame.getMaze())
    {
        if (i == 4)
        {
            g.setColor(mazeWallColour);
            g.fillRect(curX, curY, cellSize, cellSize);
            curX += 25;
        }
        else
        {
            curX += cellSize;
        }

        index++;


        // Move to new row
        if (index == 25)
        {
            index = 0;
            curX = 10;
            curY += cellSize;
        }
    }

1 . , , , , , ( [ BufferStrategy, ]). ?

/ .

.

http://pastebin.com/m25052d5a - .

: - , , .

paintClear (Graphics g)

ocean = sprites.getSprite("oceano.gif");
g.setPaint(new TexturePaint(ocean, new Rectangle(0,t,ocean.getWidth(),ocean.getHeight())));
g.fillRect(10, 10,getWidth() - 20,getHeight() - 110);

- , , ? ?

+5
10

, Thread.sleep , , , . :

Thread.sleep(Math.max(0, startTime - System.currentTimeMillis()));

startTime , System.currentTimeMillis(), startTime - System.currentTimeMillis() , 0 . , , startTime 40 . , , 40 .

, . , , . , , . , System.currentTimeMillis(). , , . ?


. , , , , ? Java GUI, , , , . sleep (0), , . Raymond Chen, , .

+3

-, , . , , , . , "i" , . , cellType - . 2D- , , , .

, , :

setColor() . , , (, , ), , , , , , , .

drawRect() fillRect() , . , , , . Image, . , Graphics . , , .

, Graphics . , paintComponent() (, ). Swing , ; , .

, , - . repaint(Rectangle), Swing , . , (r) . , repaint() ( ), .

Sun tutorial, Swing.

+4

Java, Frogger-esque , , , .

, - . 2- , , .

, , Coke and Code. , , , . - , - .

+4

, , 1fps... , , .

, ?

+3

, .

, , - , (, ) .

BufferedImage, (?, ), . (PacMan, , ..).

, Java2D, , Filthy Rich .

+2

, , Java, Spectrum Analyzer ( o-scope), Java GUI (, , ). , 1 /, , 12-20. .

, . , , .

- The Speed ​​Killer.

. , , , :)

.

+2

, , - Java.

? . - , ? , . , .

. , Java2D API ?

, ?

+1

, , , , .

, , - ( MVC). , , "", , .

+1

Java/Swing . Swing, , .

Allain, 1fps. Java/Swing, , . , .

+1

, . , - 8- , , 8 ^)

, , , , . , . , , , !

+1

All Articles