Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added Laser, Controller, KeyboardInput. This allows the player to move
around, the laser should also be showing up and moving towards the bottom right but it does not even show up for some reason. My battery is dying so I am uploading this but I will fix the laser later
- Loading branch information
Showing
7 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.3 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore | ||
org.eclipse.jdt.core.compiler.source=1.3 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.5 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main; | ||
|
||
import java.awt.Graphics; | ||
import java.util.LinkedList; | ||
|
||
public class Controller { | ||
private LinkedList<Laser> l = new LinkedList<Laser>(); | ||
|
||
Laser tempLaser; | ||
|
||
Game game; | ||
|
||
public Controller(Game game){ | ||
this.game = game; | ||
addLaser(new Laser(100, 300, game)); | ||
} | ||
|
||
public void tick(){ | ||
for(int i = 0; i < l.size(); i++){ | ||
tempLaser = l.get(i); | ||
|
||
tempLaser.tick(); | ||
} | ||
} | ||
public void render(Graphics g){ | ||
for(int i = 0; i < l.size(); i++){ | ||
tempLaser = l.get(i); | ||
|
||
tempLaser.render(g); | ||
} | ||
} | ||
public void addLaser(Laser laser){ | ||
l.add(laser); | ||
} | ||
public void removeLaser(Laser laser){ | ||
l.remove(laser); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main; | ||
|
||
import java.awt.event.KeyAdapter; | ||
import java.awt.event.KeyEvent; | ||
|
||
//whenever a key is pressed this runs | ||
public class KeyboardInput extends KeyAdapter{ | ||
|
||
|
||
Game game; | ||
|
||
public KeyboardInput(Game game){ | ||
this.game = game; | ||
} | ||
@Override | ||
public void keyPressed(KeyEvent e){ | ||
game.keyPressed(e); | ||
|
||
} | ||
@Override | ||
public void keyReleased(KeyEvent e){ | ||
game.keyReleased(e); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.image.BufferedImage; | ||
|
||
public class Laser { | ||
private double x; | ||
private double y; | ||
|
||
BufferedImage laser; | ||
|
||
|
||
|
||
public Laser(double x, double y, Game game){ | ||
this.x = x; | ||
this.y = y; | ||
|
||
SpriteSheet ss = new SpriteSheet(game.getSpriteSheet()); | ||
|
||
laser = ss.grabimage(1, 1, 64, 64); | ||
} | ||
|
||
public void tick(){ | ||
x+=1; | ||
y+=1; | ||
} | ||
public void render(Graphics g){ | ||
g.drawImage(laser, (int)x, (int)y, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters