├── LICENSE ├── README.md └── src └── com └── ozuduru └── shooterGame ├── Alien.java ├── BlueAlien.java ├── Cannon.java ├── Creature.java ├── EnemyGenerator.java ├── Game.java ├── GameBoard.java ├── GreenAlien.java ├── Main.java ├── SpriteSheetLoader.java ├── data └── credits.txt ├── images ├── backgrounds │ ├── background.png │ └── cannonbg.png ├── buttons │ ├── back0.png │ ├── back1.png │ ├── back2.png │ ├── credits0.png │ ├── credits1.png │ ├── credits2.png │ ├── highscore0.png │ ├── highscore1.png │ ├── highscore2.png │ ├── innerbuttons.png │ ├── play0.png │ ├── play1.png │ ├── play2.png │ ├── quit0.png │ ├── quit1.png │ └── quit2.png ├── cannons │ ├── cannon0.png │ └── cannon1.png ├── creatures │ ├── bluealien.png │ └── greenalien.png └── cursors │ ├── default.png │ ├── locked.png │ └── unlocked.png └── sound └── laser.wav /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Onur Ozuduru 2 | 3 | All source codes (all .java files) of this software are licensed under 4 | The MIT License (MIT). 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | For more information about license of the files in 25 | * /src/com/ozuduru/shooterGame/images 26 | * /src/com/ozuduru/shooterGame/sound 27 | 28 | Please see the file /src/com/ozuduru/shooterGame/data/credits.txt 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | java-shooter-game-project 2 | ========================= 3 | 4 | A simple Java game project for programming class. 5 | 6 | It is a very simple 2D shooter game, I tried to explain codes with commands in the source files. 7 | It works but I had very limited time while I was writing that code, so there might be some bugs. 8 | I tested it on Linux and Windows, it works better on Linux than Windows. 9 | I used Inkscape (http://www.inkscape.org) for editing graphics and 10 | also I used some vector and icon sets, for detailed information please see credits.txt or click on Credits button when you run the code. 11 | 12 | I hope that it is helpful for your own homeworks or projects. 13 | Please put a link on somewhere to my github page, if you use the codes with no changes. 14 | 15 | Follow me on, 16 | 17 | * github: [onurozuduru](https://github.com/onurozuduru) 18 | * twitter: [@OnurOzuduru](https://twitter.com/OnurOzuduru) 19 | 20 | 21 | You can see project description which is here, 22 | 23 | 24 | You are expected to implement a simple shooter game with the following scenario: 25 | _Alien creatures from another dimension are attacking people all over the world and you are 26 | the last defender of human race. Your home is your castle and you have to defend this castle. 27 | These creatures came from an inter-dimension portal whose one end is in your house garden. The 28 | creatures appear from the portal. You have a cannon located in your house and you are shooting 29 | those creatures. You can move your cannon up and down. Each creature has got different strength 30 | which reflect on the scores if you destroy them._ 31 | 32 | 33 | __Minimum Criteria:__ 34 | 35 | You are expected to design the game by using java. Below are the minimal criteria: 36 | 37 | * Proper object oriented (OO) hierarchy (E.g. Creatures, cannon types can be implemented 38 | that way. Use concepts of interfaces, abstract classes while designing OO hierarchy) 39 | * Mouse or Key listeners (at least one of them to control your gun) 40 | * Minimal GUI elements ( Minimal a button, a check box and a text field) 41 | * Graphics (Java 2D API usage while designing your graphical elements) 42 | * Animation (Creatures must move or when they die, there can be some animation) 43 | * Create a jar file 44 | * High Score (Keep user high scores for only recent games. Show it in a GUI element, e.g. list 45 | box. You do NOT have to save it on disk and load it.) 46 | 47 | 48 | These are the __minimum__ criteria, you can use more than these. Your application should work 49 | without any errors, so don’t forget to run and check your application. 50 | 51 | 52 | __Limitation:__ 53 | 54 | You __cannot__ use third party libraries in your project. 55 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/Alien.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: Alien.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.Color; 33 | import java.awt.Dimension; 34 | import java.awt.Graphics; 35 | import java.awt.Graphics2D; 36 | import java.awt.event.ActionEvent; 37 | import java.awt.event.ActionListener; 38 | import java.awt.event.MouseEvent; 39 | import java.awt.event.MouseListener; 40 | import java.awt.image.BufferedImage; 41 | import java.io.IOException; 42 | 43 | import javax.swing.JPanel; 44 | import javax.swing.Timer; 45 | 46 | public abstract class Alien extends JPanel implements Creature, MouseListener { 47 | private final int scorePoint = 100; 48 | 49 | protected int deadLine;// game will over when Alien get that position. 50 | protected boolean manIsDown;// if true animation will changed and will disappear. 51 | protected int x, y, width, height; 52 | protected int moveSpeed; 53 | 54 | protected BufferedImage[] frames; 55 | protected int frameLivingLimit, frameDeadLimit, frameCurrent, frameStart; 56 | 57 | protected Timer animationTimer; 58 | 59 | public Alien(BufferedImage[] frames,int frameLivingLimit, int x, int y) { 60 | // Just to be safe, call setters and pass arguments to them. 61 | setFrames(frames, frameLivingLimit); 62 | setX(x); 63 | setY(y); 64 | 65 | // Width and Height values are the same with frames width and height values. 66 | width = frames[0].getWidth(); 67 | height = frames[0].getHeight(); 68 | 69 | manIsDown = false; 70 | 71 | deadLine = 100; 72 | 73 | // Set size and position of the panel. 74 | setPreferredSize(new Dimension(width, height)); 75 | setBounds(x, y, width, height); 76 | 77 | // Set transparent background. 78 | setOpaque(true); 79 | setBackground(new Color(0, 0, 0, 0)); 80 | 81 | // Add listener. 82 | addMouseListener(this); 83 | 84 | // It is the loop for animation. 85 | animationTimer = new Timer(Game.REFRESH_TIME, new ActionListener() { 86 | @Override 87 | public void actionPerformed(ActionEvent e) { 88 | if(!GameBoard.isGameOver) 89 | update(); 90 | }}); 91 | animationTimer.start(); 92 | } 93 | 94 | public Alien(String filePath, int row, int col, int frameLivingLimit, int x, int y) 95 | throws IOException { 96 | this(SpriteSheetLoader.createSprites(filePath, row, col), frameLivingLimit, x, y); 97 | } 98 | 99 | // Sets image frames for animation and frameStart, frameCurrent, frameDeadLimit. 100 | public void setFrames(BufferedImage[] frames, int frameLivingLimit) { 101 | this.frames = frames; 102 | if(frameLivingLimit > 0) 103 | this.frameLivingLimit = frameLivingLimit; 104 | else 105 | throw new IllegalArgumentException("frameLivingLimit CANNOT BE zero or a negative number!"); 106 | this.frameDeadLimit = frames.length; 107 | this.frameStart = 0; 108 | this.frameCurrent = frameStart; 109 | } 110 | 111 | public void setY(int y) { 112 | if(y >= 0) 113 | this.y = y; 114 | else 115 | throw new IllegalArgumentException("y CANNOT BE negative!"); 116 | } 117 | 118 | public void setX(int x) { 119 | if(x >= 0) 120 | this.x = x; 121 | else 122 | throw new IllegalArgumentException("x CANNOT BE negative!"); 123 | } 124 | 125 | public void setMoveSpeed(int moveSpeed) { 126 | if(moveSpeed >= 0) 127 | this.moveSpeed = moveSpeed; 128 | else 129 | throw new IllegalArgumentException("moveSpeed CANNOT BE negative!"); 130 | } 131 | 132 | public int getMoveSpeed() { 133 | return moveSpeed; 134 | } 135 | 136 | // It will decide which frame should be current frame while shooting 137 | // also it will change manIsDown to true according to alien's strength. 138 | public abstract void shooting(); 139 | 140 | @Override 141 | public Timer getAnimationTimer() { 142 | return animationTimer; 143 | } 144 | 145 | @Override 146 | public void move() { 147 | // if not dead, change position. 148 | if(!manIsDown){ 149 | if(x > deadLine) 150 | x -= moveSpeed; 151 | else { 152 | x = deadLine; 153 | GameBoard.isGameOver = true; // game will over when an Alien reaches to deadLine. 154 | animationTimer.stop(); 155 | } 156 | // setLocation of the panel. 157 | setLocation(x, y); 158 | } 159 | } 160 | 161 | @Override 162 | public boolean isAlive() { 163 | return (frameCurrent < frameDeadLimit); 164 | } 165 | 166 | @Override 167 | public void paint(Graphics g) { 168 | super.paint(g); // call super class' paint function to clear. 169 | Graphics2D g2d = (Graphics2D) g; 170 | 171 | // if alive draw current image, otherwise draw transparent color. 172 | if(isAlive()) 173 | g2d.drawImage(frames[frameCurrent], 0, 0, null); 174 | else 175 | setForeground(new Color(0,0,0,0)); 176 | } 177 | 178 | @Override 179 | public void update() { 180 | // call move() to set new location of the panel. 181 | move(); 182 | 183 | // Decide which frame will be current. 184 | if((++frameCurrent == frameLivingLimit) && !manIsDown) 185 | frameCurrent = frameStart; 186 | else if(manIsDown) 187 | frameCurrent = (frameCurrent < frameLivingLimit) ? frameLivingLimit : (frameCurrent + 1); 188 | 189 | // call repaint() to paint current image. 190 | repaint(); 191 | } 192 | 193 | @Override 194 | public int getScorePoint() { 195 | return this.scorePoint; 196 | } 197 | 198 | @Override 199 | public void mouseClicked(MouseEvent e) { 200 | if(GameBoard.isGameOver) 201 | return; 202 | Cannon.setFire(true); 203 | } 204 | 205 | @Override 206 | public void mouseEntered(MouseEvent e) { 207 | setCursor(Game.CURSOR_LOCKED); 208 | } 209 | 210 | @Override 211 | public void mouseExited(MouseEvent e) { 212 | setCursor(Game.CURSOR_UNLOCKED); 213 | } 214 | 215 | @Override 216 | public void mousePressed(MouseEvent e) { 217 | if(GameBoard.isGameOver) 218 | return; 219 | Cannon.setFire(true); 220 | shooting(); 221 | update(); 222 | } 223 | 224 | @Override 225 | public void mouseReleased(MouseEvent e) { 226 | if(GameBoard.isGameOver) 227 | return; 228 | Cannon.setFire(false); 229 | } 230 | 231 | } 232 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/BlueAlien.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: BlueAlien.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.image.BufferedImage; 33 | import java.io.IOException; 34 | 35 | public class BlueAlien extends Alien { 36 | private final int scorePoint = 200; 37 | 38 | protected int strength, shotCount; 39 | private int limit;// will be used as second living limit. 40 | 41 | // Constructor calls Class Alien's constructer with given arguments and 42 | // half of the given frameLivingLimit argument because BlueAlien has 43 | // a strength value which means that after one shot its shape will be changed 44 | // but it will not die untill the shotCount value reaches to strength value. 45 | public BlueAlien(BufferedImage[] frames, int frameLivingLimit, int x, int y) { 46 | super(frames, frameLivingLimit / 2, x, y); 47 | 48 | setMoveSpeed(6); 49 | limit = frameLivingLimit; 50 | shotCount = 0; 51 | 52 | // Die after 3 shots. 53 | setStrength(3); 54 | } 55 | 56 | public BlueAlien(String filePath, int row, int col, int frameLivingLimit, 57 | int x, int y) throws IOException { 58 | this(SpriteSheetLoader.createSprites(filePath, row, col), frameLivingLimit, x, y); 59 | } 60 | 61 | // Strength value may be greater or equal to 0 otherwise it throws an exception. 62 | public void setStrength(int strength) { 63 | if(strength >= 0) 64 | this.strength = strength; 65 | else 66 | throw new IllegalArgumentException("Value of strength CANNOT BE a negative number!"); 67 | } 68 | 69 | @Override 70 | public void shooting() { 71 | // After the first shot the animation will start from 6th frame so 72 | // the shape will be changed. 73 | // When shotCount value equals to strength value the manIsDown will be become to true, 74 | // so it will be dead. 75 | if(++shotCount < strength) { 76 | frameStart = 6; 77 | frameLivingLimit = limit; 78 | } 79 | else 80 | manIsDown = true; 81 | repaint(); 82 | } 83 | 84 | // BlueAlien has own scorePoint value which is different from Alien's default value 100. 85 | @Override 86 | public int getScorePoint() { 87 | return this.scorePoint; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/Cannon.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: Cannon.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.Color; 33 | import java.awt.Graphics; 34 | import java.awt.Graphics2D; 35 | import java.awt.Image; 36 | import java.awt.Toolkit; 37 | import javax.swing.JPanel; 38 | 39 | public class Cannon extends JPanel { 40 | // File paths for cannon and background images. 41 | // File paths are top of the class to be changed easily. 42 | private final String fileCannonImage = "images/cannons/cannon0.png", 43 | fileCannonFireImage = "images/cannons/cannon1.png", 44 | fileBackGround = "images/backgrounds/cannonbg.png"; 45 | 46 | private final int width = 100, height = 150;// Width and Height values of the panel. 47 | 48 | private Image cannonImage, cannonFireImage; 49 | 50 | // positionY: y position of the panel on the window. 51 | // imagePosY: y position of the cannon image on this panel. 52 | private int positionY, imagePosY; 53 | private double angle;// angle of the image. 54 | private static boolean fire; 55 | 56 | public Cannon() { 57 | // Calculate panel's y position on the window. 58 | positionY = (Game.HEIGHT / 2) - (height / 2) + 50; 59 | 60 | // Set position as (0, positionY) and size. 61 | setBounds(0, positionY, width, height); 62 | 63 | setBackground(Color.WHITE); 64 | 65 | setFire(false); 66 | setImages(); 67 | } 68 | 69 | private void setImages() { 70 | // Initialize normal and fired cannon images. 71 | cannonImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileCannonImage)); 72 | cannonFireImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileCannonFireImage)); 73 | 74 | // Wait until the Image's getHeight function returns the height value. 75 | // The getHeight function returns -1 if the image's height is not yet known. 76 | while(cannonImage.getHeight(null) == -1) 77 | System.out.println("class Canon: Waiting for image height..."); 78 | 79 | // Calculate cannon image's y position on the panel. 80 | imagePosY = (height / 2) - (cannonImage.getHeight(null) / 2) - 15; 81 | angle = 0; 82 | } 83 | 84 | public static void setFire(boolean f) { 85 | fire = f; 86 | } 87 | 88 | public void rotate(int x, int y, boolean fire) { 89 | setFire(fire); 90 | // Calculate angle of the image according to given x y arguments. 91 | // angle = arctan( [y - (panel's y position) + (image's y position)] / x) 92 | angle = Math.atan2(y - (positionY + imagePosY), x); 93 | 94 | repaint(); 95 | } 96 | 97 | @Override 98 | public void paint(Graphics g) { 99 | super.paint(g); 100 | 101 | Graphics2D g2d = (Graphics2D) g; 102 | 103 | // rotation angle is angle, rotation origin x is 15, rotation origin y is imagePosY + 60. 104 | // rotation origin positions private final int scorePoint = 200;was found by experiments. 105 | g2d.rotate(angle, 15, imagePosY + 60); 106 | 107 | // If it is firing paint cannon fire image. 108 | if(!fire) 109 | g2d.drawImage(cannonImage, 0, imagePosY, null); 110 | else 111 | g2d.drawImage(cannonFireImage, 0, imagePosY, null); 112 | } 113 | 114 | @Override 115 | protected void paintComponent(Graphics g) { 116 | super.paintComponent(g); 117 | // Draw background of the panel. 118 | g.drawImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileBackGround)), 0, 0, null); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/Creature.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: Creature.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import javax.swing.Timer; 33 | 34 | public interface Creature { 35 | public void move();// Calculates new position of the Creature. 36 | public boolean isAlive(); 37 | public void update();// Decides which frame should be current. 38 | public int getScorePoint(); 39 | Timer getAnimationTimer(); 40 | } 41 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/EnemyGenerator.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: EnemyGenerator.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.image.BufferedImage; 33 | import java.io.IOException; 34 | import java.util.Random; 35 | 36 | public class EnemyGenerator { 37 | private final String fileGreenAlien = "images/creatures/greenalien.png", 38 | fileBlueAlien = "images/creatures/bluealien.png"; 39 | 40 | private BufferedImage[] greenFrames, blueFrames; 41 | 42 | private Random rand; 43 | public EnemyGenerator() throws IOException { 44 | rand = new Random(1000000000); 45 | greenFrames = SpriteSheetLoader.createSprites(fileGreenAlien, 2, 5); 46 | blueFrames = SpriteSheetLoader.createSprites(fileBlueAlien, 3, 6); 47 | } 48 | 49 | public Alien generateNewEnemy() { 50 | // Randomly generates new creatures. 51 | int creatureType = rand.nextInt(2); 52 | 53 | switch (creatureType) { 54 | case 0: 55 | return new GreenAlien(greenFrames, 5, (rand.nextInt(100) + (Game.WIDTH - 100)), rand.nextInt(Game.HEIGHT - 200) + 50); 56 | case 1: 57 | return new BlueAlien(blueFrames, 12, (rand.nextInt(100) + (Game.WIDTH - 100)), rand.nextInt(Game.HEIGHT - 200) + 50); 58 | } 59 | return null; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/Game.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: Game.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.BorderLayout; 33 | import java.awt.Color; 34 | import java.awt.Cursor; 35 | import java.awt.Dimension; 36 | import java.awt.FlowLayout; 37 | import java.awt.Font; 38 | import java.awt.GridLayout; 39 | import java.awt.HeadlessException; 40 | import java.awt.Image; 41 | import java.awt.Point; 42 | import java.awt.Toolkit; 43 | import java.awt.event.ActionEvent; 44 | import java.awt.event.ActionListener; 45 | import java.io.BufferedReader; 46 | import java.io.BufferedWriter; 47 | import java.io.File; 48 | import java.io.FileNotFoundException; 49 | import java.io.FileReader; 50 | import java.io.FileWriter; 51 | import java.io.IOException; 52 | import java.io.InputStreamReader; 53 | import java.net.URLDecoder; 54 | 55 | import javax.swing.ImageIcon; 56 | import javax.swing.JButton; 57 | import javax.swing.JFrame; 58 | import javax.swing.JLabel; 59 | import javax.swing.JOptionPane; 60 | import javax.swing.JPanel; 61 | import javax.swing.JScrollPane; 62 | import javax.swing.JTextField; 63 | import javax.swing.JTextPane; 64 | import javax.swing.text.SimpleAttributeSet; 65 | import javax.swing.text.StyleConstants; 66 | import javax.swing.text.StyledDocument; 67 | 68 | public class Game extends JFrame implements ActionListener{ 69 | // The static cursors will be used in different places in the game (i.e. in Class Alien). 70 | // File paths are top of the class to be changed easily. 71 | protected static Cursor CURSOR_LOCKED, CURSOR_UNLOCKED, CURSOR_DEFAULT; 72 | private final String fileCursorLocked = "images/cursors/locked.png", 73 | fileCursorUnlocked = "images/cursors/unlocked.png", 74 | fileCursorDefault = "images/cursors/default.png"; 75 | 76 | // Set width and height of main window. 77 | // Other classes will use these values that is why they are static. 78 | protected final static int WIDTH = 900, HEIGHT = 500; 79 | 80 | protected final static int REFRESH_TIME = 150; 81 | 82 | protected static int highScore = 0; 83 | 84 | // We will not only read also will write on fileScore, 85 | // so since we cannot write on a file which is in a jar file, we must create a new file 86 | // which is outside of the jar file and we need that ugly line. 87 | // In that notation line: 88 | // getClass().getProtectionDomain().getCodeSource().getLocation().getPath() 89 | // gives the path with the jar file's name to get directory of the jar file 90 | // we create a new File then get its parent with getParent(). 91 | // After that we put a file separator -which is different for Linux/Unix and Windows- 92 | // and the file name __score_data__.txt 93 | private final String fileScore = 94 | new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParent() + 95 | File.separator + "__score_data__.txt"; 96 | 97 | private final String fileCredits = "data/credits.txt"; 98 | 99 | private Font defaultFont; 100 | private JPanel menuPanel, highScorePanel, creditsPanel; 101 | private JButton playButton, quitButton, creditsButton, highScoreButton, 102 | backButton0, backButton1; 103 | private JTextField txtHighScore; 104 | 105 | public enum GameState {NEW, CONTINUE, OVER, HIGHSCORE, CREDITS, WAIT, QUIT}; 106 | public static GameState state; 107 | 108 | public Game() throws HeadlessException, IOException { 109 | this("SHOOTER GAME"); 110 | } 111 | 112 | public Game(String title) throws HeadlessException, IOException { 113 | super(title); 114 | 115 | initCursors(); 116 | loadHighScore(); 117 | setBackButtons(); 118 | 119 | defaultFont = new Font(Font.SERIF, Font.BOLD, 24); 120 | 121 | setMenuPanel(); 122 | setHighScorePanel(); 123 | setCreditsPanel(); 124 | 125 | // Set layout as null since every component's position are declared by setLocation or setBounds functions. 126 | setLayout(null); 127 | setPreferredSize(new Dimension(WIDTH, HEIGHT)); 128 | setBackground(Color.WHITE); 129 | setDefaultCloseOperation(EXIT_ON_CLOSE); 130 | setResizable(false); 131 | setVisible(true); 132 | pack(); 133 | } 134 | 135 | private void setBackButtons() { 136 | backButton0 = createButton(new String[] {"images/buttons/back0.png", 137 | "images/buttons/back1.png", 138 | "images/buttons/back2.png"}); 139 | backButton1 = createButton(new String[] {"images/buttons/back0.png", 140 | "images/buttons/back1.png", 141 | "images/buttons/back2.png"}); 142 | } 143 | 144 | public void initCursors() { 145 | // Get default tookit to create new cursors. 146 | Toolkit toolkit = Toolkit.getDefaultToolkit(); 147 | 148 | // Read images from filepaths. 149 | Image lockedImage = toolkit.getImage(getClass().getResource(fileCursorLocked)); 150 | Image unlockedImage = toolkit.getImage(getClass().getResource(fileCursorUnlocked)); 151 | Image menuImage = toolkit.getImage(getClass().getResource(fileCursorDefault)); 152 | 153 | // Create new cursors with desired parameters. 154 | // Since locked and unlocked cursors 40x40 images, hotspots are (20, 20). 155 | CURSOR_LOCKED = toolkit.createCustomCursor(lockedImage, new Point(20, 20), "cursorLocked"); 156 | CURSOR_UNLOCKED = toolkit.createCustomCursor(unlockedImage, new Point(20, 20), "cursorUnlocked"); 157 | CURSOR_DEFAULT = toolkit.createCustomCursor(menuImage, new Point(16, 16), "cursorDefault"); 158 | } 159 | 160 | public void loadHighScore() throws IOException { 161 | // new File with the file path, it decodes as UTF-8 because there might be some special characters in the file path. 162 | File file = new File(URLDecoder.decode(fileScore, "UTF-8")); 163 | 164 | // If file does not exist create a new file and set highScore as 0. 165 | if(!file.canRead()) { 166 | file.createNewFile(); 167 | setHighScore(0); 168 | } 169 | else { 170 | BufferedReader reader = new BufferedReader(new FileReader(file));//(new InputStreamReader(getClass().getResourceAsStream(fileScore))); 171 | String line = reader.readLine(); 172 | // If file is empty set highScore as 0. 173 | setHighScore( (line != null) ? Integer.parseInt(line) : 0 ); 174 | reader.close(); 175 | } 176 | } 177 | 178 | public static void setState(GameState state) { 179 | Game.state = state; 180 | } 181 | 182 | public static void setHighScore(int score) { 183 | if(score < 0) 184 | throw new IllegalArgumentException("High Score CANNOT BE a negative number!"); 185 | if(score > highScore) 186 | highScore = score; 187 | } 188 | 189 | public static int getHighScore() { 190 | return highScore; 191 | } 192 | 193 | public void saveHighScore() throws IOException, SecurityException { 194 | // new File with the file path, it decodes as UTF-8 because there might be some special characters in the file path. 195 | File file = new File(URLDecoder.decode(fileScore, "UTF-8")); 196 | 197 | if(!file.canWrite()) 198 | file.createNewFile(); 199 | BufferedWriter writer = new BufferedWriter(new FileWriter(file)); 200 | 201 | writer.write(Integer.toString(getHighScore())); 202 | writer.close(); 203 | } 204 | 205 | public void setMenuPanel() { 206 | menuPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); 207 | menuPanel.setBounds(0, 0, WIDTH, HEIGHT); 208 | menuPanel.setBackground(Color.WHITE); 209 | menuPanel.setCursor(Game.CURSOR_DEFAULT); 210 | 211 | JPanel innerPanel = new JPanel(new GridLayout(4, 1, 5, 5)); 212 | innerPanel.setPreferredSize(new Dimension(310, 440)); 213 | innerPanel.setBackground(Color.WHITE); 214 | 215 | playButton = createButton(new String[] {"images/buttons/play0.png", 216 | "images/buttons/play1.png", 217 | "images/buttons/play2.png"}); 218 | 219 | highScoreButton = createButton(new String[] {"images/buttons/highscore0.png", 220 | "images/buttons/highscore1.png", 221 | "images/buttons/highscore2.png"}); 222 | 223 | creditsButton = createButton(new String[] {"images/buttons/credits0.png", 224 | "images/buttons/credits1.png", 225 | "images/buttons/credits2.png"}); 226 | 227 | quitButton = createButton(new String[] {"images/buttons/quit0.png", 228 | "images/buttons/quit1.png", 229 | "images/buttons/quit2.png"}); 230 | innerPanel.add(playButton); 231 | innerPanel.add(highScoreButton); 232 | innerPanel.add(creditsButton); 233 | innerPanel.add(quitButton); 234 | 235 | menuPanel.add(innerPanel); 236 | } 237 | 238 | public void setHighScorePanel() { 239 | highScorePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); 240 | highScorePanel.setBounds(0, 0, WIDTH, HEIGHT); 241 | highScorePanel.setBackground(Color.WHITE); 242 | highScorePanel.setCursor(Game.CURSOR_DEFAULT); 243 | 244 | JPanel innerPanel = new JPanel(new GridLayout(2, 1, 5, 5)); 245 | innerPanel.setPreferredSize(new Dimension(800, 220)); 246 | innerPanel.setBackground(Color.WHITE); 247 | 248 | JLabel lblMessage = new JLabel("High Score", JLabel.CENTER); 249 | lblMessage.setForeground(Color.BLACK); 250 | lblMessage.setFont(defaultFont); 251 | lblMessage.setHorizontalTextPosition(JLabel.CENTER); 252 | 253 | txtHighScore = new JTextField(Integer.toString(highScore), 6); 254 | txtHighScore.setFont(defaultFont); 255 | txtHighScore.setHorizontalAlignment(JTextField.CENTER); 256 | txtHighScore.setEditable(false); 257 | 258 | innerPanel.add(lblMessage, BorderLayout.NORTH); 259 | innerPanel.add(txtHighScore, BorderLayout.CENTER); 260 | 261 | highScorePanel.add(innerPanel); 262 | highScorePanel.add(backButton0); 263 | } 264 | 265 | public void setCreditsPanel() throws IOException { 266 | creditsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); 267 | creditsPanel.setBounds(0, 0, WIDTH, HEIGHT); 268 | creditsPanel.setBackground(Color.WHITE); 269 | creditsPanel.setCursor(Game.CURSOR_DEFAULT); 270 | 271 | String text = "CREDITS"; 272 | 273 | if(getClass().getResourceAsStream(fileCredits) == null) 274 | throw new FileNotFoundException("credits.txt could NOT be found!"); 275 | else { 276 | BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(fileCredits))); 277 | String line = " "; 278 | while(line != null) { 279 | text = text + "\n" + line; 280 | line = reader.readLine(); 281 | } 282 | reader.close(); 283 | } 284 | 285 | JTextPane txtPane = new JTextPane(); 286 | txtPane.setText(text); 287 | txtPane.setEditable(false); 288 | 289 | // StyledDocument for changing font and aligment of the text. 290 | StyledDocument doc = txtPane.getStyledDocument(); 291 | 292 | SimpleAttributeSet body = new SimpleAttributeSet(); 293 | SimpleAttributeSet header = new SimpleAttributeSet(); 294 | 295 | // Font size is 16 for body and aligment is center. 296 | StyleConstants.setAlignment(body, StyleConstants.ALIGN_CENTER); 297 | StyleConstants.setFontSize(body, 16); 298 | 299 | // Font is bold and size is 16 for header and aligment is center. 300 | StyleConstants.setFontSize(header, 24); 301 | StyleConstants.setBold(header, true); 302 | StyleConstants.setAlignment(header, StyleConstants.ALIGN_CENTER); 303 | 304 | doc.setParagraphAttributes(7, doc.getLength(), body, false); 305 | doc.setParagraphAttributes(0, 7, header, false); 306 | 307 | JScrollPane scrollPane = new JScrollPane(txtPane); 308 | scrollPane.setPreferredSize(new Dimension(850, HEIGHT - 200)); 309 | scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 310 | 311 | creditsPanel.add(scrollPane); 312 | creditsPanel.add(backButton1); 313 | } 314 | 315 | // Helper function to create a button. 316 | // Gets 3 file paths to creates 3 icons. 317 | // icon[0]: button icon 318 | // icon[1]: roll over icon. 319 | // icon[2]: pressed icon. 320 | private JButton createButton(String[] iconFiles) { 321 | ImageIcon[] icon = new ImageIcon[iconFiles.length]; 322 | for(int i = 0; i < iconFiles.length; ++i) 323 | icon[i] = new ImageIcon(getClass().getResource(iconFiles[i])); 324 | 325 | JButton button = new JButton(icon[0]); 326 | button.setBorderPainted(false); 327 | button.setFocusable(true); 328 | button.setFocusPainted(false); 329 | button.setRolloverEnabled(true); 330 | button.setRolloverIcon(icon[1]); 331 | button.setPressedIcon(icon[2]); 332 | button.setContentAreaFilled(false); 333 | button.addActionListener(this); 334 | 335 | return button; 336 | } 337 | 338 | public void startGame() throws IOException { 339 | 340 | // Main thread of the program for games states. 341 | Thread t = new Thread(new Runnable() { 342 | @Override 343 | public void run() { 344 | // menu will be shown at the beginning. 345 | setState(GameState.WAIT); 346 | add(menuPanel); 347 | GameBoard board = null; 348 | 349 | // Loop until quit. 350 | while(!state.equals(GameState.QUIT)) { 351 | switch (state) { 352 | // Waits for 200 ms. 353 | case WAIT: 354 | try { 355 | Thread.sleep(200); 356 | } catch (InterruptedException e) { 357 | exceptionOther(e.getMessage()); 358 | } 359 | break; 360 | // Removes menu and creates a new gameBoard. 361 | case NEW: 362 | remove(menuPanel); 363 | repaint(); 364 | try { 365 | board = new GameBoard(); 366 | } catch (IOException e) { 367 | exceptionIO(e.getMessage()); 368 | } 369 | add(board); 370 | pack(); 371 | board.gameLoop(); 372 | setState(GameState.WAIT); 373 | break; 374 | // After game over if user wants to play a new game. 375 | case CONTINUE: 376 | try { 377 | saveHighScore(); 378 | } catch (IOException e) { 379 | exceptionIO(e.getMessage()); 380 | } catch (SecurityException e) { 381 | exceptionSecurity(e.getMessage()); 382 | } 383 | remove(board); 384 | repaint(); 385 | try { 386 | board = new GameBoard(); 387 | } catch (IOException e) { 388 | exceptionIO(e.getMessage()); 389 | } 390 | add(board); 391 | repaint(); 392 | pack(); 393 | board.gameLoop(); 394 | setState(GameState.WAIT); 395 | break; 396 | // If game is over and user do not want to play a new game back to the menu. 397 | case OVER: 398 | try { 399 | saveHighScore(); 400 | } catch (IOException e) { 401 | exceptionIO(e.getMessage()); 402 | } catch (SecurityException e) { 403 | exceptionSecurity(e.getMessage()); 404 | } 405 | remove(board); 406 | repaint(); 407 | add(menuPanel); 408 | repaint(); 409 | pack(); 410 | setState(GameState.WAIT); 411 | break; 412 | // Show high score panel. 413 | case HIGHSCORE: 414 | txtHighScore.setText(Integer.toString(getHighScore())); 415 | remove(menuPanel); 416 | repaint(); 417 | add(highScorePanel); 418 | repaint(); 419 | pack(); 420 | setState(GameState.WAIT); 421 | break; 422 | // Show credits panel. 423 | case CREDITS: 424 | remove(menuPanel); 425 | repaint(); 426 | add(creditsPanel); 427 | repaint(); 428 | pack(); 429 | setState(GameState.WAIT); 430 | break; 431 | case QUIT: 432 | break; 433 | }// End of switch-case 434 | }// End of while 435 | // When loop is done quit the program. 436 | dispose(); 437 | System.exit(0); 438 | }// End of run. 439 | });// End of Thread t. 440 | t.start(); 441 | } 442 | 443 | private void exceptionIO(String e) { 444 | JOptionPane.showMessageDialog(null, 445 | "It seems that there is a problem on your file system!\nError: " + e, 446 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 447 | } 448 | private void exceptionSecurity(String e) { 449 | JOptionPane.showMessageDialog(null, 450 | "It seems that there is a problem about file's permission!\nError: " + e, 451 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 452 | } 453 | private void exceptionOther(String e) { 454 | JOptionPane.showMessageDialog(null, 455 | "We are sorry about that!\nError: " + e, 456 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 457 | } 458 | 459 | @Override 460 | public void actionPerformed(ActionEvent e) { 461 | if(e.getSource().equals(playButton)) 462 | setState(GameState.NEW); 463 | 464 | else if(e.getSource().equals(highScoreButton)) 465 | setState(GameState.HIGHSCORE); 466 | 467 | else if(e.getSource().equals(backButton0) || e.getSource().equals(backButton1)) { 468 | remove(((JButton) e.getSource()).getParent()); 469 | repaint(); 470 | add(menuPanel); 471 | pack(); 472 | setState(GameState.WAIT); 473 | } 474 | 475 | else if(e.getSource().equals(quitButton)) 476 | setState(GameState.QUIT); 477 | 478 | else if(e.getSource().equals(creditsButton)) 479 | setState(GameState.CREDITS); 480 | } 481 | 482 | } 483 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/GameBoard.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: GameBoard.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.applet.Applet; 33 | import java.applet.AudioClip; 34 | import java.awt.Color; 35 | import java.awt.Component; 36 | import java.awt.Dimension; 37 | import java.awt.FlowLayout; 38 | import java.awt.Font; 39 | import java.awt.Graphics; 40 | import java.awt.Toolkit; 41 | import java.awt.event.ActionEvent; 42 | import java.awt.event.ActionListener; 43 | import java.awt.event.MouseAdapter; 44 | import java.awt.event.MouseEvent; 45 | import java.awt.event.MouseMotionListener; 46 | import java.awt.image.BufferedImage; 47 | import java.io.IOException; 48 | import java.net.URL; 49 | 50 | import javax.swing.Icon; 51 | import javax.swing.ImageIcon; 52 | import javax.swing.JButton; 53 | import javax.swing.JCheckBox; 54 | import javax.swing.JLabel; 55 | import javax.swing.JOptionPane; 56 | import javax.swing.JPanel; 57 | import javax.swing.Timer; 58 | 59 | import com.ozuduru.shooterGame.Game.GameState; 60 | 61 | public class GameBoard extends JPanel { 62 | private final String fileBackground = "images/backgrounds/background.png"; 63 | private EnemyGenerator generator; 64 | protected static boolean isGameOver = false; 65 | int score; 66 | 67 | private boolean isStopped; 68 | 69 | private AudioClip bangClip; 70 | private Cannon cannon; 71 | private JLabel lblScore; 72 | private JPanel headerPanel; 73 | private JButton restartButton, stopButton; 74 | private Timer mainTimer; 75 | private Font defaultFont; 76 | private JCheckBox effectOn; 77 | 78 | public GameBoard() throws IOException { 79 | isStopped = false; 80 | 81 | generator = new EnemyGenerator(); 82 | isGameOver = false; // It changes to the true by move function of Class Alien. 83 | score = 0; 84 | defaultFont = new Font(Font.SERIF, Font.BOLD, 24); 85 | 86 | setEffectOn(); 87 | 88 | // If file is missing do not interrupt the program just disable sound option. 89 | URL clipUrl = getClass().getResource("sound/laser.wav"); 90 | if(clipUrl == null) { 91 | effectOn.setSelected(false); 92 | effectOn.setEnabled(false); 93 | } 94 | else 95 | bangClip = Applet.newAudioClip(clipUrl); 96 | 97 | // Set position and size. 98 | setBounds(0, 0, Game.WIDTH, Game.HEIGHT); 99 | 100 | // Set layout as null since every component's position are declared by setLocation or setBounds functions. 101 | setLayout(null); 102 | 103 | setCursor(Game.CURSOR_UNLOCKED); 104 | setHeader(); 105 | setCannon(); 106 | } 107 | 108 | private void setEffectOn() { 109 | effectOn = new JCheckBox("Sound Effects ", true); 110 | effectOn.setBackground(new Color(0, 0, 0, 0)); // Transparent background. 111 | effectOn.setFont(defaultFont); 112 | effectOn.setFocusable(false); 113 | } 114 | 115 | private void setHeader() { 116 | JLabel scoreMsg = new JLabel("Your Score: "); 117 | scoreMsg.setForeground(Color.BLACK); 118 | scoreMsg.setFont(defaultFont); 119 | 120 | lblScore = new JLabel(Integer.toString(score)); 121 | lblScore.setForeground(Color.BLACK); 122 | lblScore.setFont(defaultFont); 123 | 124 | headerPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); 125 | headerPanel.setBounds(0, 0, Game.WIDTH, 50); 126 | headerPanel.setOpaque(true); 127 | headerPanel.setBackground(new Color(0, 0, 0, 0)); 128 | 129 | headerPanel.add(effectOn); 130 | headerPanel.add(scoreMsg); 131 | headerPanel.add(lblScore); 132 | 133 | //Add restart and stop buttons 134 | BufferedImage[] buttonIcons = null; 135 | try { 136 | buttonIcons = SpriteSheetLoader.createSprites("images/buttons/innerbuttons.png", 2, 3); 137 | } catch (IOException e) { 138 | e.printStackTrace(); 139 | } 140 | ImageIcon[] icons = new ImageIcon[buttonIcons.length]; 141 | for(int i = 0; i < buttonIcons.length; ++i) 142 | icons[i] = new ImageIcon(buttonIcons[i]); 143 | 144 | restartButton = createButton(icons[0], icons[1], icons[2]); 145 | stopButton = createButton(icons[3], icons[4], icons[5]); 146 | 147 | headerPanel.add(restartButton); 148 | headerPanel.add(stopButton); 149 | 150 | add(headerPanel); 151 | 152 | headerPanel.setVisible(true); 153 | } 154 | 155 | // Helper function to create a button. 156 | // Gets 3 file paths to creates 3 icons. 157 | // icon[0]: button icon 158 | // icon[1]: roll over icon. 159 | // icon[2]: pressed icon. 160 | private JButton createButton(Icon icon0, Icon icon1, Icon icon2) { 161 | // ImageIcon[] icon = new ImageIcon[iconFiles.length]; 162 | // for(int i = 0; i < iconFiles.length; ++i) 163 | // icon[i] = new ImageIcon(getClass().getResource(iconFiles[i])); 164 | 165 | JButton button = new JButton(icon0); 166 | button.setPreferredSize(new Dimension(icon0.getIconWidth(), icon0.getIconHeight())); 167 | button.setBorderPainted(false); 168 | button.setFocusable(true); 169 | button.setFocusPainted(false); 170 | button.setRolloverEnabled(true); 171 | button.setRolloverIcon(icon1); 172 | button.setPressedIcon(icon2); 173 | button.setContentAreaFilled(false); 174 | button.addActionListener(new InnerButtonListener()); 175 | 176 | return button; 177 | } 178 | 179 | private void setCannon() { 180 | cannon = new Cannon(); 181 | add(cannon); 182 | 183 | // MouseMotionListener calls Cannon's rotate function to follow cursor. 184 | addMouseMotionListener(new MouseMotionListener() { 185 | @Override 186 | public void mouseMoved(MouseEvent e) { 187 | cannon.rotate(e.getX(), e.getY(), false); 188 | } 189 | @Override 190 | public void mouseDragged(MouseEvent arg0) { 191 | } 192 | });// End of addMouseMotionListener. 193 | 194 | // When clicked on blank area cannon will be fired with MouseListener. 195 | // If there is no mouselistener added in the GameBoard, 196 | // cannon be fired only when clicked on Aliens. 197 | addMouseListener(new MouseAdapter() { 198 | @Override 199 | public void mouseClicked(MouseEvent e) { 200 | Cannon.setFire(true); 201 | } 202 | @Override 203 | public void mousePressed(MouseEvent e) { 204 | Cannon.setFire(true); 205 | } 206 | @Override 207 | public void mouseReleased(MouseEvent e) { 208 | Cannon.setFire(false); 209 | } 210 | });// End of addMouseListener. 211 | }// End of setCannon 212 | 213 | public Thread generator() { 214 | // Begin with 4 Aliens; 215 | for(int i = 0; i < 4; ++i) 216 | add(generator.generateNewEnemy()); 217 | 218 | // Generates new aliens until game is over. 219 | // Generation time decreases every second. 220 | return new Thread(new Runnable() { 221 | 222 | @Override 223 | public void run() { 224 | int s = 1000; 225 | while(!isGameOver && !isStopped) { 226 | try { 227 | Thread.sleep(s); 228 | } catch (InterruptedException e) { 229 | JOptionPane.showMessageDialog(null, 230 | "We are sorry about that!\nError: " + e.getMessage(), 231 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 232 | } 233 | if(isStopped) 234 | return; 235 | if(!isGameOver) 236 | add(generator.generateNewEnemy()); 237 | if(s > Game.REFRESH_TIME + 50) 238 | s -= 4; 239 | else 240 | s = Game.REFRESH_TIME + 50; 241 | }// End of while 242 | }});// End of new Thread 243 | }// End of generator() 244 | 245 | public void gameLoop() { 246 | generator().start(); 247 | mainTimer = new Timer(Game.REFRESH_TIME, new ActionListener() { 248 | @Override 249 | public void actionPerformed(ActionEvent arg0) { 250 | repaint(); 251 | if(isGameOver) { 252 | gameOver(); 253 | return; 254 | } 255 | for(Component e : getComponents()) { 256 | if(e instanceof Creature){ 257 | Creature i = (Creature) e; 258 | if(!i.isAlive()) { 259 | if(effectOn.isSelected()) 260 | bangClip.play(); 261 | score += i.getScorePoint(); 262 | lblScore.setText(Integer.toString(score)); 263 | remove(e); 264 | } 265 | } 266 | }// End of for 267 | }// End of ActionPerformed 268 | });// End of mainTimer 269 | mainTimer.start(); 270 | } 271 | 272 | @Override 273 | protected void paintComponent(Graphics g) { 274 | super.paintComponent(g); 275 | // Draw backgroung image. 276 | g.drawImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(fileBackground)), 0, 0, null); 277 | } 278 | 279 | public void gameOver() { 280 | mainTimer.stop(); 281 | for(Component c : getComponents()) { 282 | if(c instanceof Creature) 283 | ((Creature) c).getAnimationTimer().stop(); 284 | remove(c); 285 | } 286 | 287 | int selectedOption = JOptionPane.showConfirmDialog(this, 288 | ("Your Score: " + score + "\nDo you want to play a new Game?"), 289 | "GAME OVER", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 290 | 291 | Game.setHighScore(score); 292 | 293 | switch (selectedOption) { 294 | case JOptionPane.YES_OPTION: 295 | Game.setState(GameState.CONTINUE); 296 | break; 297 | 298 | case JOptionPane.NO_OPTION: 299 | Game.setState(GameState.OVER); 300 | break; 301 | } 302 | } 303 | 304 | private class InnerButtonListener implements ActionListener { 305 | public void gameStop() { 306 | isStopped = true; 307 | mainTimer.stop(); 308 | for(Component c : getComponents()) { 309 | if(c instanceof Creature) 310 | ((Creature) c).getAnimationTimer().stop(); 311 | remove(c); 312 | } 313 | } 314 | 315 | @Override 316 | public void actionPerformed(ActionEvent e) { 317 | if(e.getSource() == restartButton) { 318 | gameStop(); 319 | Game.setState(GameState.CONTINUE); 320 | } 321 | else if(e.getSource() == stopButton) { 322 | gameStop(); 323 | Game.setState(GameState.OVER); 324 | } 325 | } 326 | } 327 | } 328 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/GreenAlien.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: GreenAlien.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.image.BufferedImage; 33 | import java.io.IOException; 34 | 35 | public class GreenAlien extends Alien { 36 | 37 | // Constructor calls Class Alien's constructer with given arguments 38 | // and sets speed to 5. 39 | public GreenAlien(BufferedImage[] frames, int frameLivingLimit, int x, int y) { 40 | super(frames, frameLivingLimit, x, y); 41 | 42 | setMoveSpeed(5); 43 | } 44 | 45 | // Constructor creates a BufferedImage array with given filePath argument 46 | // and calls the constructor GreenAlien(BufferedImage[] frames, int frameLivingLimit, int x, int y) 47 | public GreenAlien(String filePath, int row, int col, int frameLivingLimit, 48 | int x, int y) throws IOException { 49 | this(SpriteSheetLoader.createSprites(filePath, row, col), frameLivingLimit, x, y); 50 | } 51 | 52 | // shooting function only changes manIsDown field to true, 53 | // because the strength of the GreenAlien is 0 which 54 | // means that it will die after one shot. 55 | @Override 56 | public void shooting() { 57 | manIsDown = true; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/Main.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: Main.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.HeadlessException; 33 | import java.io.IOException; 34 | 35 | import javax.swing.JOptionPane; 36 | 37 | public class Main { 38 | 39 | /** 40 | * @param args 41 | */ 42 | public static void main(String[] args) { 43 | // Create a new Game object and call startGame function. 44 | // Catch possible exceptions and show an error message to the user. 45 | try { 46 | new Game().startGame(); 47 | } catch (HeadlessException e) { 48 | JOptionPane.showMessageDialog(null, 49 | "We are sorry about that!\nError: " + e.getMessage(), 50 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 51 | } catch (IOException e) { 52 | JOptionPane.showMessageDialog(null, 53 | "It seems that there is a problem on your file system!\nError: " + e.getMessage(), 54 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 55 | } catch (IllegalArgumentException e) { 56 | JOptionPane.showMessageDialog(null, 57 | "We are sorry about that!\nError: " + e.getMessage(), 58 | "Opps!! Something went wrong!", JOptionPane.ERROR_MESSAGE); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/SpriteSheetLoader.java: -------------------------------------------------------------------------------- 1 | /********************************************************************************* 2 | *File: SpriteSheetLoader.java 3 | *Author: Onur Ozuduru 4 | * e-mail: onur.ozuduru { at } gmail.com 5 | * github: github.com/onurozuduru 6 | * twitter: twitter.com/OnurOzuduru 7 | * 8 | *License: The MIT License (MIT) 9 | * 10 | * Copyright (c) 2014 Onur Ozuduru 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | * SOFTWARE. 28 | *********************************************************************************/ 29 | 30 | package com.ozuduru.shooterGame; 31 | 32 | import java.awt.image.BufferedImage; 33 | import java.io.File; 34 | import java.io.IOException; 35 | import java.io.ObjectInputStream.GetField; 36 | 37 | import javax.imageio.ImageIO; 38 | 39 | public class SpriteSheetLoader { 40 | 41 | public SpriteSheetLoader() { 42 | } 43 | 44 | // It reads the image file from filePath and creates a BufferedImage array 45 | // with dividing the image file into subimages according to given row and col values. 46 | public static BufferedImage[] createSprites(String filePath, int row, int col) 47 | throws IOException { 48 | if(row <= 0 || col <= 0) 49 | throw new IllegalArgumentException("row and col must be positive!"); 50 | 51 | // Size of array will be col * row 52 | BufferedImage[] sprites = new BufferedImage[row * col]; 53 | 54 | // Read the Image 55 | BufferedImage spriteSheet = ImageIO.read(SpriteSheetLoader.class.getResourceAsStream(filePath)); //ImageIO.read(new File(filePath)); 56 | 57 | // Calculate width and height of the each sprite. 58 | // We assume that sprite sheet consists of all same sized sprites. 59 | int width = spriteSheet.getWidth() / col; 60 | int height = spriteSheet.getHeight() / row; 61 | 62 | // Get sprites (sub images) by left to right order from sprite sheet. 63 | for(int i = 0; i < row; ++i) 64 | for(int j = 0; j < col; ++j) 65 | sprites[(i * col) + j] = spriteSheet.getSubimage(j * width, i * height, width, height); 66 | 67 | return sprites; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/data/credits.txt: -------------------------------------------------------------------------------- 1 | Developed by: 2 | 3 | Onur OZUDURU 4 | 5 | Visit my github page: https://github.com/onurozuduru 6 | Follow me on twitter: https://twitter.com/OnurOzuduru 7 | Or send me a mail: onur.ozuduru { at } gmail.com 8 | 9 | Licence: This work is licensed under the Creative Commons Attribution 4.0 International License. 10 | To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 11 | 12 | 13 | Creature Images are created with using the following vector set: 14 | 15 | Name: The Funny Vector Monsters Kit by: designer-daily 16 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 17 | Source: http://www.designer-daily.com/freebie-the-vector-monsters-kit-37053 18 | 19 | 20 | Button Icons are created with using the following icon set: 21 | 22 | Name: Smallicons Icon Set 23 | by: Nick Frost http://dribbble.com/gimpo/ 24 | and 25 | Greg Lapin http://dribbble.com/loonyvoyager 26 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 27 | Source: http://www.smashingmagazine.com/2013/11/29/freebie-smallicons-icon-set/ 28 | 29 | 30 | Button Font is: 31 | 32 | Name: SketchSlab Webfont by: Tony Thomas 33 | License: Free License http://medialoot.com/main/license/ 34 | Source: http://medialoot.com/item/sketchslab-webfont/ 35 | 36 | 37 | Cannon Sound is: 38 | 39 | Name: Laser Cannon by: Mike Koenig 40 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 41 | Source: http://soundbible.com/1771-Laser-Cannon.html 42 | 43 | 44 | Cannon Image Icon is: 45 | 46 | by: Freepik http://www.freepik.com/ 47 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 48 | Source: http://www.flaticon.com/free-icon/cannon_1504 49 | 50 | 51 | Default Target Cursor Icon is from the package: 52 | 53 | Name: Iconic by: P.J. Onori 54 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 55 | Source: http://somerandomdude.com/work/iconic/ 56 | 57 | 58 | Green and Red Target Cursor Icons are from the package: 59 | 60 | Name: Ardentryst-GUICursorsArrowsIconsMarkers 61 | by: Jordan Trudgett http://jordan.trudgett.com/ 62 | License: CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/ 63 | Source: http://opengameart.org/content/cursors-arrows-map-markers-for-ardentryst-by-jordan-trudgett 64 | -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/backgrounds/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/backgrounds/background.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/backgrounds/cannonbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/backgrounds/cannonbg.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/back0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/back0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/back1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/back1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/back2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/back2.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/credits0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/credits0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/credits1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/credits1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/credits2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/credits2.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/highscore0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/highscore0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/highscore1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/highscore1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/highscore2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/highscore2.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/innerbuttons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/innerbuttons.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/play0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/play0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/play1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/play1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/play2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/play2.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/quit0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/quit0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/quit1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/quit1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/buttons/quit2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/buttons/quit2.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/cannons/cannon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/cannons/cannon0.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/cannons/cannon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/cannons/cannon1.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/creatures/bluealien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/creatures/bluealien.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/creatures/greenalien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/creatures/greenalien.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/cursors/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/cursors/default.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/cursors/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/cursors/locked.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/images/cursors/unlocked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/images/cursors/unlocked.png -------------------------------------------------------------------------------- /src/com/ozuduru/shooterGame/sound/laser.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onurozuduru/java-shooter-game-project/7d124bd0127e403e29fb8ec23cb77f51ba3bf401/src/com/ozuduru/shooterGame/sound/laser.wav --------------------------------------------------------------------------------