Merge branch 'master' of github.com:teamteamteam/SpaceScooter
This commit is contained in:
commit
090b7ec5b3
|
@ -1,6 +1,6 @@
|
|||
package de.teamteamteam.spacescooter.background.item;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
import de.teamteamteam.spacescooter.entity.LivingEntity;
|
||||
|
@ -20,7 +20,7 @@ public abstract class Items extends LivingEntity{
|
|||
this.remove();
|
||||
};
|
||||
if(!this.isAlive()){
|
||||
LinkedList<Entity> entities = Screen.currentScreen.getEntities();
|
||||
List<Entity> entities = Screen.currentScreen.getEntities();
|
||||
for (Entity e : entities) {
|
||||
if(e instanceof Player){
|
||||
itemCollected((Player) e);
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.teamteamteam.spacescooter.entity;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.screen.Screen;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class HealthBar extends Entity {
|
|||
}
|
||||
|
||||
public void paint(Graphics2D g) {
|
||||
LinkedList<Entity> entities = Screen.currentScreen.getEntities();
|
||||
List<Entity> entities = Screen.currentScreen.getEntities();
|
||||
for (Entity e : entities) {
|
||||
if(e instanceof Player){
|
||||
this.width = ((Player) e).getHealthPoints();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.teamteamteam.spacescooter.entity;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.background.item.Items;
|
||||
import de.teamteamteam.spacescooter.entity.enemy.Enemy;
|
||||
|
@ -25,7 +25,7 @@ public abstract class LivingEntity extends Entity implements Collidable {
|
|||
|
||||
public void update() {
|
||||
if(!(this instanceof ShootingEntity)) return; //Only check collisions for ShootingEntity.
|
||||
LinkedList<Entity> entities = Screen.currentScreen.getEntities();
|
||||
List<Entity> entities = Screen.currentScreen.getEntities();
|
||||
for (Entity e : entities) {
|
||||
if (e.equals(this)) //Do not collide with myself!
|
||||
continue;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.teamteamteam.spacescooter.entity.enemy;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.teamteamteam.spacescooter.background.item.Items;
|
||||
|
@ -41,7 +41,7 @@ public class EnemyThree extends Enemy{
|
|||
if(random.nextInt(10) < 5) Items.create(getX(), getY());
|
||||
new EnemyThree(0, 0);
|
||||
}
|
||||
LinkedList<Entity> list = Screen.currentScreen.getEntities();
|
||||
List<Entity> list = Screen.currentScreen.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
Entity entity = i.next();
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
|
@ -38,7 +38,7 @@ public class GameOverScreen extends Screen {
|
|||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
g.drawImage(this.img, 0, 0, null);
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().paint(g);
|
||||
|
@ -54,7 +54,7 @@ public class GameOverScreen extends Screen {
|
|||
|
||||
@Override
|
||||
protected void update() {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().update();
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
|
@ -38,7 +38,7 @@ public class GamePausedScreen extends Screen {
|
|||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
g.drawImage(this.img, 0, 0, null);
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().paint(g);
|
||||
|
@ -54,7 +54,7 @@ public class GamePausedScreen extends Screen {
|
|||
|
||||
@Override
|
||||
protected void update() {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().update();
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.awt.Point;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.background.StarBackground;
|
||||
import de.teamteamteam.spacescooter.background.item.ItemChance;
|
||||
|
@ -36,7 +36,7 @@ public class GameScreen extends Screen {
|
|||
|
||||
@Override
|
||||
protected void paint(Graphics2D g) {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().paint(g);
|
||||
|
@ -45,7 +45,7 @@ public class GameScreen extends Screen {
|
|||
|
||||
@Override
|
||||
protected void update() {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().update();
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
|||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.background.StarBackground;
|
||||
import de.teamteamteam.spacescooter.control.Keyboard;
|
||||
|
@ -40,7 +40,7 @@ public class MainMenuScreen extends Screen {
|
|||
|
||||
@Override
|
||||
public void paint(Graphics2D g) {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().paint(g);
|
||||
|
@ -59,7 +59,7 @@ public class MainMenuScreen extends Screen {
|
|||
|
||||
@Override
|
||||
public void update() {
|
||||
LinkedList<Entity> list = this.getEntities();
|
||||
List<Entity> list = this.getEntities();
|
||||
Iterator<Entity> i = list.iterator();
|
||||
while (i.hasNext()) {
|
||||
i.next().update();
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.teamteamteam.spacescooter.screen;
|
|||
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public abstract class Screen {
|
|||
/**
|
||||
* List of entities this screen is taking care of
|
||||
*/
|
||||
protected LinkedList<Entity> entities;
|
||||
protected List<Entity> entities;
|
||||
|
||||
/**
|
||||
* Initialize parent, overlay and the Entity list
|
||||
|
@ -61,7 +62,7 @@ public abstract class Screen {
|
|||
this.entities.remove(e);
|
||||
}
|
||||
|
||||
public LinkedList<Entity> getEntities() {
|
||||
public List<Entity> getEntities() {
|
||||
return new LinkedList<Entity>(this.entities);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,23 +5,33 @@ import java.awt.EventQueue;
|
|||
import de.teamteamteam.spacescooter.gui.GameFrame;
|
||||
|
||||
/**
|
||||
* This thread triggers about 60 redraws per second.
|
||||
* This thread triggers the redrawing on the GameFrame.
|
||||
*/
|
||||
public class PaintThread extends TimedThread {
|
||||
|
||||
private GameFrame gf;
|
||||
|
||||
/**
|
||||
* Runnable that is passed to the EventQueue for later invocation.
|
||||
*/
|
||||
private final Runnable paintRunnable;
|
||||
|
||||
/**
|
||||
* Constructor. Sets the name of the Thread and creates the paintRunnable.
|
||||
*/
|
||||
public PaintThread(GameFrame gf) {
|
||||
this.gf = gf;
|
||||
final GameFrame gameFrame = gf;
|
||||
this.setName("PaintThread");
|
||||
this.paintRunnable = new Runnable() {
|
||||
public void run() {
|
||||
gameFrame.draw();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The work method invoked by the TimingThread.
|
||||
*/
|
||||
public void work() {
|
||||
//Trigger redrawing the things. Important: AWT-Context needed here!
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
gf.draw();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(this.paintRunnable);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue