// draw all the shapes on the list public void paint(Graphics g) { super.paint(g); // is no super.paint(), then lines stay on screen for (int i = 0; i < allTheShapesCount; i++) { allTheShapes[i].drawMe(g); } }
public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.draw( new Ellipse2D.Double( centerx - (centery - 500), centery - (centery - 500), 2 * (centery - 500), 2 * (centery - 500))); try { g2d.draw( new Ellipse2D.Double( player.x - player.size / 2, player.y - player.size / 2, player.size, player.size)); } catch (NullPointerException e) { } k = 1; while (k <= ballCount) { g2d.draw( new Ellipse2D.Double( ball[k].x - ball[k].size / 2, ball[k].y - ball[k].size / 2, ball[k].size, ball[k].size)); k++; } }
public void paint(Graphics g) { super.paint(g); g.setFont(fotn); Random generator1 = new Random(); height = bird.getBirdy(); g.drawImage(Backgroundtop, 0, 0, 450, 644, null); g.drawImage(Bird, 100, height, 40, 30, null); if (firstrun == true) { // intiate threads pipethread[currentthreads].start(); birdthread.start(); firstrun = false; } for (int index = 0; index <= currentthreads; index++) { g.drawImage(Pipes, pipeob[index].getpipex(), pipeob[index].getpipey(), null); } g.drawImage(Backgroundbottom, 0, 644, 450, 156, null); g.setColor(Color.black); if (pipeob[currentthreads].getpipex() <= 550) { currentthreads++; pipethread[currentthreads].start(); score++; } g.drawString("Score: " + score + "", 50, 50); for (int index = 0; index < currentthreads; index++) { if (((height < pipeob[index].getpipey() + 730) || (height > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100)) || ((height < pipeob[index].getpipey() + 730) || (height > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140)) || ((height + 30 < pipeob[index].getpipey() + 730) || (height + 30 > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100)) || ((height + 30 < pipeob[index].getpipey() + 730) || (height + 30 > pipeob[index].getpipey() + 870)) && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140)) || ((height + 30 >= 644))) { g.drawImage(gameover, 125, 200, null); JOptionPane.showMessageDialog( null, "You Dead. \n you scored " + score, "Oh no!", JOptionPane.INFORMATION_MESSAGE); } } for (int counter = 0; counter <= 50000000; counter++) { counter++; counter--; } do { repaint(); } while (replay = true); }
public void paint(Graphics g) { super.paint(g); if (screen.equalsIgnoreCase("title")) { MyPanel.score = 0; hs = new Highscore(); c.removeAll(); c.add(ts); panel = null; ts.revalidate(); } else if (screen.equalsIgnoreCase("instructions")) { c.removeAll(); c.add(instructions); instructions.revalidate(); } else if (screen.equalsIgnoreCase("mode")) { c.removeAll(); c.add(mode); mode.revalidate(); } else if (screen.equalsIgnoreCase("difficulty")) { c.removeAll(); c.add(dif); dif.revalidate(); } else if (screen.equalsIgnoreCase("highscore")) { if (hs.returnCount() == 0) { c.removeAll(); c.add(hs); c.validate(); } } else if (screen.equalsIgnoreCase("gameover")) { if (!once) { c.removeAll(); c.add(gg); once = true; c.validate(); } } else { if (once) { c.removeAll(); panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff); c.setLayout(new BorderLayout()); c.add(panel.returnNs(), BorderLayout.WEST); c.add(panel, BorderLayout.CENTER); c.add(btns, BorderLayout.SOUTH); c.add(panel.returnAmmo(), BorderLayout.EAST); c.validate(); once = false; } } repaint(); }