Coverage Summary for Class: Player (com.mygdx.game.Entitys)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| Player | 100% (1/1) | 100% (6/6) | 100% (15/15) |
1 package com.mygdx.game.Entitys; 2 3 import com.badlogic.gdx.math.Vector2; 4 import com.badlogic.gdx.utils.TimeUtils; 5 import com.mygdx.game.Components.Pirate; 6 import com.mygdx.game.Components.PlayerController; 7 import com.mygdx.game.Faction; 8 import com.mygdx.game.Managers.GameManager; 9 import com.mygdx.game.UI.EndScreen; 10 import com.mygdx.utils.Utilities; 11 12 /** 13 * Player's ship entity. 14 */ 15 public class Player extends Ship { 16 private long lastPointTime; 17 18 /** 19 * Adds ship with PlayerController component and sets its speed. 20 * 21 * @param speed of movement across map 22 */ 23 private Player(float speed) { 24 super(); 25 26 PlayerController pc = new PlayerController(this, speed); 27 addComponent(pc); 28 setName("Player"); 29 30 lastPointTime = TimeUtils.millis() / 1000; 31 } 32 33 /** 34 * Adds ship with PlayerController component, loading its speed from GameManager settings. 35 */ 36 public Player() { 37 this(GameManager.getSettings().get("starting").getFloat("playerSpeed")); 38 } 39 40 /** 41 * Is run once per frame 42 */ 43 @Override 44 public void update(){ 45 super.update(); 46 isAlive(); 47 long current = TimeUtils.millis() / 1000; 48 if (current > lastPointTime) { 49 points(1); 50 } 51 lastPointTime = current; 52 } 53 54 /** 55 * Cleans up hanging data parts 56 */ 57 @Override 58 public void cleanUp() { 59 super.cleanUp(); 60 } 61 62 /** 63 * @return the amount of ammo available to the player 64 */ 65 public int getAmmo() { 66 return getComponent(Pirate.class).getAmmo(); 67 } 68 69 /** 70 * Added for Assessment 2 71 * @return the Faction attached to the pirate component of this object 72 */ 73 public Faction getFaction() { 74 return getComponent(Pirate.class).getFaction(); 75 } 76 77 }