mirror of
https://github.com/Cpt-Adok/SNAKE.git
synced 2026-01-25 10:34:06 +00:00
changement de player et Effects
This commit is contained in:
@@ -25,5 +25,10 @@ public enum Effects {
|
|||||||
/**
|
/**
|
||||||
* <p> impossible à passer à travers.
|
* <p> impossible à passer à travers.
|
||||||
*/
|
*/
|
||||||
IMPASSABLE;
|
IMPASSABLE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> le corps du serpent "disparait d'une case".
|
||||||
|
*/
|
||||||
|
DISPARITON;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ package Item;
|
|||||||
*/
|
*/
|
||||||
public enum Items {
|
public enum Items {
|
||||||
Mur("mur", Effects.IMPASSABLE),
|
Mur("mur", Effects.IMPASSABLE),
|
||||||
|
Body("corps", Effects.IMPASSABLE),
|
||||||
|
|
||||||
FRAISE("fraise", Effects.INVINCIBILITY),
|
ABRICOT("fraise", Effects.INVINCIBILITY),
|
||||||
ORANGE("orange", Effects.POWER),
|
ORANGE("orange", Effects.POWER),
|
||||||
BANANE("banane", Effects.BOOST);
|
BANANE("banane", Effects.BOOST);
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public enum Items {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * <p> type de variable pour recuperer le nom :
|
* <p> type de variable pour recuperer le nom :
|
||||||
* <pre><code>String name = Item.FRAISE.getName()</code></pre>
|
* <pre><code>String name = Item.FRAISE.getName()</code></pre>
|
||||||
* @return Avoir le nom de l'item
|
* @return Avoir le nom de l'item
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import Personnages.*;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String value = Items.FRAISE.getName();
|
System.out.println((byte)'A');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
package Personnages;
|
package Personnages;
|
||||||
|
|
||||||
public class Personnage {
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import Item.Effects;
|
||||||
|
|
||||||
|
public class Personnage {
|
||||||
|
private int size;
|
||||||
|
protected int[] coordinate;
|
||||||
|
|
||||||
|
private ArrayList<Effects> effectsList;
|
||||||
|
|
||||||
|
protected Personnage(int size, int[] coordinate) {
|
||||||
|
this.coordinate = coordinate;
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementSize(long size) {
|
||||||
|
this.size += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEffects(Effects effect) {
|
||||||
|
this.effectsList.add(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Effects> getEffects() {
|
||||||
|
return this.effectsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean haveEffect(Effects effect) {
|
||||||
|
return effectsList.contains(effect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
package Personnages;
|
package Personnages;
|
||||||
|
|
||||||
public class Player extends Personnage {
|
public class Player extends Personnage {
|
||||||
|
public Player(int size, int[] coordinate) {
|
||||||
|
super(size, coordinate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveCoordinate(int keys) {
|
||||||
|
switch (keys) {
|
||||||
|
case 77: // w
|
||||||
|
this.coordinate[1]++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 73: // s
|
||||||
|
this.coordinate[1]--;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 61: // a
|
||||||
|
this.coordinate[0]--;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 64: // d
|
||||||
|
this.coordinate[0]++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // autre
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package Personnages;
|
package Personnages;
|
||||||
|
|
||||||
public class Robot extends Personnage {
|
public class Robot extends Personnage {
|
||||||
|
public Robot(int size, int[] coordinate) {
|
||||||
|
super(size, coordinate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user