diff --git a/sprites/rainbowBorder.png b/sprites/rainbowBorder.png new file mode 100644 index 0000000..b2f571f Binary files /dev/null and b/sprites/rainbowBorder.png differ diff --git a/src/sig/JavaProjectTemplate.java b/src/sig/JavaProjectTemplate.java index d0976f3..84289de 100644 --- a/src/sig/JavaProjectTemplate.java +++ b/src/sig/JavaProjectTemplate.java @@ -26,12 +26,13 @@ class Player{ public class JavaProjectTemplate { public static final String PROGRAM_NAME="Sig's Java Project Template"; - public static int WINDOW_WIDTH=640; - public static int WINDOW_HEIGHT=320; + public static int WINDOW_WIDTH=1280; + public static int WINDOW_HEIGHT=720; public static Panel game; Player pl = new Player(); Sprite bookSpr = new Sprite("book.png"); + Sprite rainbowBorder = new Sprite("rainbowBorder.png"); Sound backgroundMusic = new Sound("battle.wav",true); Sound laserShootSound = new Sound("laserShoot.wav"); @@ -69,6 +70,13 @@ public class JavaProjectTemplate { laserShootSound.play(); } + if (Key.isPressed(KeyEvent.VK_INSERT)) { + game.SetBorderImage(rainbowBorder); + } + if (Key.isPressed(KeyEvent.VK_DELETE)) { + game.SetBorderColor(Color.BRIGHT_BLACK); + } + if (Mouse.isPressed(2)) { //If middle click is pressed, reset the player position. pl.x=pl.y=200; } diff --git a/src/sig/engine/Panel.java b/src/sig/engine/Panel.java index 0c63978..5912f9b 100644 --- a/src/sig/engine/Panel.java +++ b/src/sig/engine/Panel.java @@ -64,6 +64,7 @@ public class Panel extends JPanel implements Runnable,KeyListener { public static long scaleTime; public static Panel p; public static JFrame f; + Sprite backgroundImg; List currentlyPlayingSounds = new ArrayList(); @@ -280,15 +281,24 @@ public class Panel extends JPanel implements Runnable,KeyListener { } public void SetBorderColor(Color col){ + backgroundImg=null; borderCol=new java.awt.Color(col.r,col.g,col.b); } + public void SetBorderImage(Sprite spr){ + backgroundImg=spr; + } + @Override public void paintComponent(Graphics g) { // perform draws on pixels long startTime = System.currentTimeMillis(); g.setColor(borderCol); - g.fillRect(0,0,getWidth(),getHeight()); + if (backgroundImg==null) { + g.fillRect(0,0,getWidth(),getHeight()); + } else { + g.drawImage(backgroundImg.getImg(),0,0,getWidth(),getHeight(),0,0,backgroundImg.width,backgroundImg.height,this); + } g.drawImage(imageBuffer,vViewPos.x,vViewPos.y,vViewSize.x+vViewPos.x,vViewSize.y+vViewPos.y,0,0,ACTUAL_WINDOW_WIDTH,ACTUAL_WINDOW_HEIGHT,this); scaleTime=System.currentTimeMillis()-startTime; }