I created a I do not get to loop in main (like 1 nanosec runtime?) but anyway. You need a proper game loop for the first time after you change the position of the player and you have to re-submit the frame. Search for writing gamloops, my suggestion and maybe even double buffer strategies can be searched so that you get a liquid rendering. JFrame and created backgrounds and players but I Can help players please help me! This is my source: they have 3 clauses in 1 package, is the main square true? This is my Uni Project and I am confused ........
Package Sporthead; Import javax.swing *; Import java.awt. *; Import java.awt.image.ImageObserver; Import java.awt.image.ImageProducer; Public Class Screen JFrame {Personal Image Back; Private Image Player 1; Private Image Player 2; Private image goal1; Private Image Goal 2; Private image ball; Player 1p = new player 1 (); Public screen () {setTitle ("title"); Set size (1500, 800); SetLocation (0,0); SetDefaultCloseOperation (EXIT_ON_CLOSE); SetVisible (true); } Public Zero LoadPix () {player1 = New Imagen ("C: \\ Test \\ Player 1 Page"). IIMAG (); Player 2 = new image ("C: \\ Test \\ player 2.png"). IIMAG (); Goal 1 = New Imagen ("C: \\ Test \\ Target 1.png"). IIMAG (); Goal2 = New Imagen ("C: \\ Test \\ Target 2.png"). IIMAG (); Ball = new image ("C: \\ test \\ ball page"). GetImage (); Back = new image ("C: \\ test \\ background .jpg"). GetImage (); Repaint (); } Public zero color (graphics g) {g.drawImage (back, 0, 0, empty); P.paint (g); G.drawImage (player 2, -400, 200, empty); G.drawImage (goal 1, 400, 145, empty); G.drawImage (target 2, -500, 140, faucet); G.drawImage (ball, -20, -200, blank); G.setColor (Color.BLACK); G Drline (0, 603, 1400, 603); }} Package Sporthead; Import java.awt. *; Import java.awt.event. *; Import javax.swing *; Import sun.java2d.pipe.DrawImage; Public Category Player1 JFrame {Personal Image Image; Private int x = 0; Private int y = 0; Public int yMove = 200; Public int xMove = 200; Public player 1 () {image = new image icon ("C: \\ test \\ player 1 page"). IIMAG (); AddKeyListener (New KeyList ()); } Public Zero Color (Graphics G) {g.drawImage (Image, xMove, yMove, this); } Public Zero Step Left () {x = xMove--; } Public Zero Step Write () {y = xMove ++; } Public Zero Step Reset (int value) {xMove = value; } // Internal class Private class keylist key adapter {Public Zero Key is pressed (keyweight) (if (KAJKK.Code) == KeyEvent.VK_LEft} {step left; } If (k.getKeyCode () == KeyEvent.VK_RIGHT) {moveRight (); }}}} Package sportshead; Import javax.swing *; Import java.awt. *; Import java.awt.event.KeyEvent; Import java.awt.image.ImageObserver; Import java.awt.image.ImageProducer; Public class Main Jeffrera {public static expands zero main (string [] args {int i = 0; Screen s = new screen (); S.loadPics (); Player 1p = new player 1 (); For (i = 0; i <50; i + = 5) {p.xMove + = i; P.yMove + = I; P.repaint (); S.loadPics (); }}
No comments:
Post a Comment