- #EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 HOW TO#
- #EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 .EXE#
- #EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 CODE#
G.setFont(new Font("Chiller",Font.BOLD,30)) G.setFont(new Font("Chiller",Font.BOLD,72)) G.drawString("Best: " + HelicopterForm.maxDistance,650,500) G.drawString("Best: " + HelicopterForm.distance,650,500) If (HelicopterForm.distance > HelicopterForm.maxDistance) G.drawString("Distance: " + HelicopterForm.distance,30,500) G.setFont(new Font("Arial",Font.BOLD,20)) G.drawImage(copter.getImage(), (int)(copter.getX()), (int)(copter.getY()), null) Paint each image in the foreground where it should go Paint the background with its upper left corner at the upper left corner of the panel It's a method in JPanel that I've overwritten to paint the background and foreground images This is called whenever the computer decides to repaint the window (Various layout managers will try to mess with the size of things to fit everything) Thoroughly make the size of the panel equal to the size of the image Constructs a new ImagePanel with the background image givenĭimension size = new Dimension(img.getWidth(null), img.getHeight(null)) The easiest way to make images from file paths in Swing Constructs a new ImagePanel with the background image specified by the file path given If(upCount top //An array list of foreground images t(1,new MovingImage("rec2.JPG",middlerecs.get(0).getX() + 580,randomMidHeight())) įor(int x = 3 x = bottomrecs.get(x).getY()) If(bottomrecs.get(x).getY() -1 * RECWIDTH) t((NUMRECS - 1),new MovingImage("rec2.JPG",RECWIDTH*(NUMRECS - 1),toprecs.get(26).getY() - moveIncrement)) t((NUMRECS - 1),new MovingImage("rec2.JPG",RECWIDTH*(NUMRECS - 1),toprecs.get(26).getY() + moveIncrement)) īt((NUMRECS - 1),new MovingImage("rec2.JPG",RECWIDTH*(NUMRECS - 1),bottomrecs.get(26).getY() + moveIncrement)) īt((NUMRECS - 1),new MovingImage("rec2.JPG",RECWIDTH*(NUMRECS - 1),bottomrecs.get(26).getY() - moveIncrement)) If (firstUpdates 463) //else if too low, move up If(!paused & !crashed & started & System.currentTimeMillis() - 75 > lastSmoke) If(!paused & !crashed & started & System.currentTimeMillis() - 100 > last) If(!paused & !crashed & started & System.currentTimeMillis() - 10 > lastCopter) * if(!paused & !crashed & started & System.currentTimeMillis() - 1300 > lastSound) LastDistance = System.currentTimeMillis() Helicopter = new MovingImage("helicopter.GIF",XPOS,270) ("Error: "+i.getMessage()) īackground = new JFrame("Helicopter Game") ītDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) //closes the program when the window is closedītResizable(false) //don't allow the user to resize the windowītSize(new Dimension(818,568)) *Floor is 74 and Ceiling is 72 pixels high
private MP3 move = new MP3("HelicopterSound.mp3") Public class HelicopterForm implements MouseListener
#EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 HOW TO#
Hopefully I can figure out how to get an applet version working soon so you don't have to download it, but I had trouble the last time I tried. jar/.exe.Įnjoy :D And I know it's not as good as the flash version, but I'm proud of it so I want to show it off and there aren't too many java snippets on the site so I thought this would be cool to post. For some reason the sounds messed up the. jar file to make it work even in JCreator so I figured it was unnecessary.
#EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 CODE#
The code is pretty messy because we've just been focusing on getting the game working, and also the class files are mashed together below because you can't submit multiple forms on Hawkee for one piece of code.Īll code is by me and my partner except for the MP3 class which we found online and parts of the imagepanel and movingimage classes which were started by a classmate for the rest of us to use, The mp3 class is currently commented out because you need a.
#EXPOSURE JAVA 2013 APCS EDITION TEXTLAB 08 .EXE#
exe file and the images used in the game here: It's currently unfinished, we (my partner and I) still need to add a crash sequence as well as some modifications to make the game more difficult.Īnyway, you can play this by copying the code below and pasting into JCreator or downloading the. This is my final project for APCS (Advanced Placement Computer Science).