- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
vb.net qr code generator source code USING NETWORK COMMUNICATIONS in Font
CHAPTER 6 USING NETWORK COMMUNICATIONS Data Matrix ECC200 Generation In None Using Barcode creation for Font Control to generate, create Data Matrix image in Font applications. www.OnBarcode.comDrawing Code 128A In None Using Barcode encoder for Font Control to generate, create Code128 image in Font applications. www.OnBarcode.comif(piece > 1) { g.drawImage(myBlackCrown, (2*i + offset)*mySquareSize + mySquareSize/2, j*mySquareSize + 1 + mySquareSize/2, Graphics.VCENTER|Graphics.HCENTER); } } } } // now the blank squares: // actually, this part is probably not necessary... g.setColor(WHITE); for(int i = 0; i < 4; i++) { for(int j = 0; j < 8; j++) { if(j % 2 == 0) { offset = 1; } else { offset = 0; } g.fillRect((2*i + offset)*mySquareSize, j*mySquareSize, mySquareSize, mySquareSize); } } // if the player has reached the end of the game, // you display the end message. if(myGame.getGameOver()) { //System.out.println("paint-->gameOver"); // perform some calculations to place the text correctly: Font font = g.getFont(); int fontHeight = font.getHeight(); int fontWidth = font.stringWidth("Game Over"); g.setColor(WHITE); g.fillRect((width - fontWidth)/2, (height - fontHeight)/2, fontWidth + 2, fontHeight); // write in black g.setColor(BLACK); g.setFont(font); g.drawString("Game Over", (width - fontWidth)/2, (height - fontHeight)/2, g.TOP|g.LEFT); } } //------------------------------------------------------// handle keystrokes /** Code 39 Extended Drawer In None Using Barcode creation for Font Control to generate, create Code 3/9 image in Font applications. www.OnBarcode.comData Matrix Drawer In None Using Barcode printer for Font Control to generate, create DataMatrix image in Font applications. www.OnBarcode.comCHAPTER 6 USING NETWORK COMMUNICATIONS
EAN 13 Printer In None Using Barcode drawer for Font Control to generate, create EAN-13 Supplement 5 image in Font applications. www.OnBarcode.comPrint Barcode In None Using Barcode generator for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.com* Move the player. */ public void keyPressed(int keyCode) { if(myGame.isMyTurn()) { int action = getGameAction(keyCode); switch (action) { case LEFT: myGame.leftPressed(); break; case RIGHT: myGame.rightPressed(); break; case FIRE: case UP: myGame.upPressed(); break; case DOWN: myGame.deselect(); break; } repaint(); serviceRepaints(); } } } The CheckersCanvas class is a standard application of the Canvas class (see the Using the Graphics and Canvas Classes section in 2 for details about how you use the Canvas class). For this game, I didn t even bother to use GameCanvas since the graphics are simple, and I don t need to synchronize the keystroke queries with any game animations. The part that s unique to the checkers game is in the paint() method. You can see that there are two possibilities: either it just writes a message and returns or it paints the whole checkerboard. To make it a little easier on the eyes, I made the checkerboard gray and white, rather than red and black, and then made the pieces themselves red and black. (I made a point to verify that the color scheme looks OK on a grayscale screen.) Then whichever square is currently selected is painted a slightly lighter shade of gray than the other dark squares and put a red outline around it. The only point that may require some explanation is the use of the local variable offset. This variable keeps track of the fact that in every other row of the grid the set of dark squares shifts over one square. So, when painting the grid, you first determine whether you re in an even row or an odd row and (keeping track of it in offset) to determine which four squares should be colored of the eight squares in the row. Also notice that I always have the local player be the red pieces that start on the bottom half of the screen. So when you re playing, it ll look to you like you moved a red piece, but on your opponent s cell phone it ll appear that you moved one of the black pieces (see Figure 6-8). I can get away with this since the board is symmetric. GTIN - 128 Creation In None Using Barcode encoder for Font Control to generate, create USS-128 image in Font applications. www.OnBarcode.comMake UPC E In None Using Barcode generator for Font Control to generate, create UPC E image in Font applications. www.OnBarcode.comCHAPTER 6 USING NETWORK COMMUNICATIONS
DataMatrix Maker In VB.NET Using Barcode generation for VS .NET Control to generate, create ECC200 image in .NET applications. www.OnBarcode.comData Matrix Encoder In VS .NET Using Barcode printer for Reporting Service Control to generate, create Data Matrix ECC200 image in Reporting Service applications. www.OnBarcode.comFigure 6-8. The two players checkerboards are displayed in such a way that the local player s pieces always start at the bottom of the screen. The logic of the game itself is in the CheckersGame class (Listing 6-9). Listing 6-9. CheckersGame.java package net.frog_parrot.checkers; import java.util.Vector; /** * This class takes care of the underlying logic and data of * the checkers game being played. That includes where * all of the pieces are on the board and where it is OK * for them to move to. * * @author Carol Hamer Code 39 Extended Generation In VS .NET Using Barcode printer for ASP.NET Control to generate, create Code39 image in ASP.NET applications. www.OnBarcode.comPaint EAN13 In Java Using Barcode creator for Java Control to generate, create EAN13 image in Java applications. www.OnBarcode.comPrinting Barcode In None Using Barcode maker for Software Control to generate, create Barcode image in Software applications. www.OnBarcode.comCode 39 Extended Encoder In C#.NET Using Barcode generator for VS .NET Control to generate, create Code 3 of 9 image in .NET applications. www.OnBarcode.comRecognizing PDF417 In C# Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comPaint PDF417 In .NET Framework Using Barcode creator for Reporting Service Control to generate, create PDF 417 image in Reporting Service applications. www.OnBarcode.comEAN 13 Encoder In Objective-C Using Barcode creator for iPhone Control to generate, create EAN 13 image in iPhone applications. www.OnBarcode.com2D Creation In .NET Framework Using Barcode encoder for ASP.NET Control to generate, create Matrix Barcode image in ASP.NET applications. www.OnBarcode.comBarcode Decoder In None Using Barcode scanner for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comEncode EAN 128 In None Using Barcode maker for Office Word Control to generate, create EAN / UCC - 13 image in Microsoft Word applications. www.OnBarcode.com |
|