javadoc update
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
package com.iutlaval.myapplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pour obtenir le code erreur faite ERROR_CODE.****.ordinal();
|
||||||
|
*/
|
||||||
|
public enum ERROR_CODE {
|
||||||
|
ERROR_SUCCESS,ERROR_UNKNOwN, ERROR_INVALID_CARD_DIMENSIONS, ERROR_TEXTURE_DIMENSIONS_INVALID
|
||||||
|
}
|
||||||
@@ -2,40 +2,35 @@ package com.iutlaval.myapplication.Game;
|
|||||||
|
|
||||||
import com.iutlaval.myapplication.Game.Cards.Card;
|
import com.iutlaval.myapplication.Game.Cards.Card;
|
||||||
import com.iutlaval.myapplication.Game.Player.Player;
|
import com.iutlaval.myapplication.Game.Player.Player;
|
||||||
import com.iutlaval.myapplication.Game.Player.PlayerBot;
|
|
||||||
import com.iutlaval.myapplication.Game.Player.PlayerOnlineAdversary;
|
|
||||||
import com.iutlaval.myapplication.Game.Player.PlayerLocal;
|
import com.iutlaval.myapplication.Game.Player.PlayerLocal;
|
||||||
import com.iutlaval.myapplication.GameActivity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Board {
|
public class Board {
|
||||||
private static final int MAX_CARD_ON_BOARD=10;
|
private static final int MAX_CARD_ON_BOARD=10;
|
||||||
private List<Card> AdvCardsOnBoard;
|
private List<Card> advCardsOnBoard;
|
||||||
private List<Card> PlayerCardsOnBoard;
|
private List<Card> playerCardsOnBoard;
|
||||||
private PlayerLocal player1;
|
|
||||||
private Player player2;
|
|
||||||
|
|
||||||
public Board()
|
public Board()
|
||||||
{
|
{
|
||||||
AdvCardsOnBoard = new ArrayList<>();
|
advCardsOnBoard = new ArrayList<>();
|
||||||
PlayerCardsOnBoard = new ArrayList<>();
|
playerCardsOnBoard = new ArrayList<>();
|
||||||
player1 = new PlayerLocal();
|
}
|
||||||
|
|
||||||
if(GameActivity.isMultiplayer())
|
/**
|
||||||
|
* joue une carte et l'ajoute au terrain du joueur correspondant
|
||||||
|
* @param card
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public void playCard(Card card,Player player)
|
||||||
{
|
{
|
||||||
player2 = new PlayerOnlineAdversary();
|
if(player instanceof PlayerLocal)
|
||||||
}else{
|
|
||||||
player2 = new PlayerBot();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO fill decks
|
|
||||||
if(GameActivity.isHosting())
|
|
||||||
{
|
{
|
||||||
|
playerCardsOnBoard.add(card);
|
||||||
}else{
|
}else{
|
||||||
|
advCardsOnBoard.add(card);
|
||||||
}
|
}
|
||||||
|
card.onCardPlayed(this,player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,35 @@ import android.graphics.Color;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.iutlaval.myapplication.Game.Board;
|
import com.iutlaval.myapplication.Game.Board;
|
||||||
|
import com.iutlaval.myapplication.Game.Player.Player;
|
||||||
import com.iutlaval.myapplication.R;
|
import com.iutlaval.myapplication.R;
|
||||||
|
|
||||||
public abstract class Card {
|
public abstract class Card {
|
||||||
private static Bitmap frameBitmap = null;
|
private static Bitmap frameBitmap = null;
|
||||||
|
|
||||||
public void onCardAttack(Board board){}
|
/**
|
||||||
|
* *cette methode est appeler a chaque fois que la carte attaque
|
||||||
|
* @param board
|
||||||
|
*/
|
||||||
|
public void onCardAttack(Board board,Card enemy){}
|
||||||
|
|
||||||
public void onCardPlayed(Board board){}
|
/**
|
||||||
|
* cette methode est appeler quand la carte est jouer
|
||||||
|
* elle se fait appler par board.java
|
||||||
|
* @param board
|
||||||
|
*/
|
||||||
|
public void onCardPlayed(Board board, Player p){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cette methode est appeler quand la carte est detruite
|
||||||
|
* @param board
|
||||||
|
*/
|
||||||
public void onCardDeath(Board board){}
|
public void onCardDeath(Board board){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cette methode est appeler quand le tour commance
|
||||||
|
* @param board
|
||||||
|
*/
|
||||||
public void onTurnBegin(Board board){}
|
public void onTurnBegin(Board board){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,12 +60,23 @@ public abstract class Card {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne l'indice de la texture du cadre
|
||||||
|
* par defaut cette methode possede un cadre donc vous n'avez pas a l'utilser
|
||||||
|
* DE PLUS ne pas l'importer ameliore les performance car la ram n'est solicier qu'une fois pour l'integralite des cartes
|
||||||
|
* vous pouvez la trouver a R.drawable.NOMDELATEXTURE
|
||||||
|
* @return entier id texture
|
||||||
|
*/
|
||||||
public int getFrameTexture()
|
public int getFrameTexture()
|
||||||
{
|
{
|
||||||
return R.drawable.cadre_carte;
|
return R.drawable.cadre_carte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne l'indice de la texture de la photo de la carte
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract int getCardPicture();
|
public abstract int getCardPicture();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,12 +92,24 @@ public abstract class Card {
|
|||||||
return "#00000000";
|
return "#00000000";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourn le texte de la description de la carte
|
||||||
|
* @return la description
|
||||||
|
*/
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne un entier coresspondant a l'attaque de la carte
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract int getAttack();
|
public abstract int getAttack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne la santé de la carte
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract int getHealth();
|
public abstract int getHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public class GameActivity extends Activity {
|
|||||||
setContentView(v);
|
setContentView(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO a supprime quand le moteur de jeu pour être utliser a des fin de teste
|
||||||
private class MainThread extends Thread
|
private class MainThread extends Thread
|
||||||
{
|
{
|
||||||
Renderer view;
|
Renderer view;
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ public class InvalidDataException extends Throwable {
|
|||||||
y = rectangle.getHeight();
|
y = rectangle.getHeight();
|
||||||
this.name=name;
|
this.name=name;
|
||||||
}
|
}
|
||||||
public InvalidDataException(String name,float x,float y)
|
|
||||||
{
|
|
||||||
this.y=y;
|
|
||||||
this.x=x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne un string detaillant l'erreur
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getDetail() {
|
public String getDetail() {
|
||||||
return "name " + name + " x:" + x +" y:"+ y;
|
return "name " + name + " x:" + x +" y:"+ y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.iutlaval.myapplication.ERROR_CODE;
|
||||||
import com.iutlaval.myapplication.GameActivity;
|
import com.iutlaval.myapplication.GameActivity;
|
||||||
import com.iutlaval.myapplication.InvalidDataException;
|
import com.iutlaval.myapplication.InvalidDataException;
|
||||||
|
|
||||||
@@ -33,32 +34,17 @@ public class Drawable {
|
|||||||
this.name=name;
|
this.name=name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* cree un drawable depuis une bitmap est des coordonnés
|
|
||||||
* @param bitmap bitmap
|
|
||||||
* @param x coordoné x compris entre 0 et 100
|
|
||||||
* @param y coordoné y comrpis entre 0 et 100
|
|
||||||
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
|
||||||
*
|
|
||||||
* deprecier car non adapter a la resolution de l'ecran
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Drawable(Bitmap bitmap,float x,float y,String name){
|
|
||||||
this(x,y,name);
|
|
||||||
this.bitmap=bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cree un drawable depuis une bitmap est des coordonnés
|
* @param bitmap a dessiner
|
||||||
* @param bitmap bitmap
|
* @param x_pos position en x du texte
|
||||||
* @param x_pos coordoné x compris entre 0 et 100
|
* @param y_pos position en y du texte
|
||||||
* @param y_pos coordoné y comrpis entre 0 et 100
|
* @param name nom du Drawable
|
||||||
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
* @param x_size taille du drawable entre 0 et 100
|
||||||
* deprecier car non adapter a la resolution de l'ecran
|
* @param y_size taille du drawable entre 0 et 100
|
||||||
*
|
* @throws InvalidDataException
|
||||||
* TODO : echelle dynamique avec l'ecran
|
|
||||||
*/
|
*/
|
||||||
public Drawable(@NonNull Bitmap bitmap, float x_pos, float y_pos, String name, float x_size, float y_size) throws InvalidDataException {
|
public Drawable(@NonNull Bitmap bitmap, float x_pos, float y_pos, String name, float x_size, float y_size){
|
||||||
this(x_pos,y_pos,name);
|
this(x_pos,y_pos,name);
|
||||||
|
|
||||||
float x_scaled_size = x_size* GameActivity.screenWidth/100;
|
float x_scaled_size = x_size* GameActivity.screenWidth/100;
|
||||||
@@ -70,13 +56,14 @@ public class Drawable {
|
|||||||
|
|
||||||
if(x_scaled_size <=0 || y_scaled_size <=0)
|
if(x_scaled_size <=0 || y_scaled_size <=0)
|
||||||
{
|
{
|
||||||
throw new InvalidDataException(name,x_scaled_size,y_scaled_size);
|
Log.e("TEXTURE :","ERREUR DE MISE A L'ECHELLE");
|
||||||
|
System.exit(ERROR_CODE.ERROR_TEXTURE_DIMENSIONS_INVALID.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bitmap = Bitmap.createScaledBitmap(bitmap, (int)x_scaled_size, (int)y_scaled_size, GameActivity.bilinearFiltering);
|
this.bitmap = Bitmap.createScaledBitmap(bitmap, (int)x_scaled_size, (int)y_scaled_size, GameActivity.bilinearFiltering);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**TODO : limiter la longeur des lignes et implementer le retour a la ligne
|
/**TODO : corriger les deformation due au changement de ratio (x_size,y_size)
|
||||||
* ce constructeur permet de rendre du texte
|
* ce constructeur permet de rendre du texte
|
||||||
* @param text le texte a rendre
|
* @param text le texte a rendre
|
||||||
* @param x_pos position en x du texte
|
* @param x_pos position en x du texte
|
||||||
@@ -119,14 +106,14 @@ public class Drawable {
|
|||||||
* ce constructeur n'est pas rapide essayer de l'utiliser le moin possible
|
* ce constructeur n'est pas rapide essayer de l'utiliser le moin possible
|
||||||
* TODO : optimize it and remove the deprecated flag
|
* TODO : optimize it and remove the deprecated flag
|
||||||
*
|
*
|
||||||
* this contructor create a Drawable object from a rectangle and a color
|
* ce constructeur dessine un rectangle avec la texture donner en argument
|
||||||
* @param rectangle recange cooresspondant a la surface a dessiner
|
* @param rectangle recange cooresspondant a la surface a dessiner
|
||||||
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
||||||
* @param color couleur du rectangle
|
* @param color couleur du rectangle
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Drawable(Rectangle rectangle, String name, int color) throws InvalidDataException {
|
public Drawable(Rectangle rectangle, String name, int color) throws InvalidDataException {
|
||||||
this(null,rectangle.getPositionX(),rectangle.getPositionY(),name);
|
this(rectangle.getPositionX(),rectangle.getPositionY(),name);
|
||||||
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0)throw new InvalidDataException(name,rectangle);
|
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0)throw new InvalidDataException(name,rectangle);
|
||||||
|
|
||||||
rectangle.scaleRectangleToScreen();
|
rectangle.scaleRectangleToScreen();
|
||||||
@@ -136,25 +123,33 @@ public class Drawable {
|
|||||||
this.bitmap=bitmap;
|
this.bitmap=bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ce constructeur n'est pas rapide essayer de l'utiliser le moin possible
|
* ce constructeur n'est pas tres rapide donc a eviter il utilse pas mal de ram mais sava encore le gc de java s'en ocupe vite
|
||||||
* TODO : optimize it and remove the deprecated flag
|
* ce constructeur dessine un rectangle avec la texture donner en argument
|
||||||
*TODO update javadoc
|
* @param bitmap
|
||||||
*
|
|
||||||
* this contructor create a Drawable object from a rectangle and a color
|
|
||||||
* @param rectangle recange cooresspondant a la surface a dessiner
|
* @param rectangle recange cooresspondant a la surface a dessiner
|
||||||
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
||||||
* @param color couleur du rectangle
|
* @param color couleur du rectangle
|
||||||
|
* @throws InvalidDataException
|
||||||
*/
|
*/
|
||||||
|
//TODO verifier l'utiliter de ce constructeur
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Drawable(Bitmap bitmap,Rectangle rectangle, String name, int color) throws InvalidDataException {
|
public Drawable(Bitmap bitmap,Rectangle rectangle, String name, int color) throws InvalidDataException {
|
||||||
this(bitmap,rectangle.getPositionX(),rectangle.getPositionY(),name);
|
this(rectangle.getPositionX(),rectangle.getPositionY(),name);
|
||||||
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0 || bitmap == null)throw new InvalidDataException(name,rectangle);
|
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0 || bitmap == null)throw new InvalidDataException(name,rectangle);
|
||||||
|
|
||||||
rectangle.scaleRectangleToScreen();
|
rectangle.scaleRectangleToScreen();
|
||||||
rectangle.bitmapRectangleBuilder(bitmap,color,p);
|
rectangle.bitmapRectangleBuilder(bitmap,color,p);
|
||||||
|
this.bitmap = bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NE PAS UTLISER CETTE FONCTION EST RESERVER AU FONCTIONNEMENT DU MOTEUR GRAPHIQUE
|
||||||
|
* SI VOUS EN AVEZ BESOIN ENTRE EN CONTACT AVEC MARC POUR AJOUTER AU MOTEUR LA FONCTIONNALITER QUE VOUS AVEZ BESOIN
|
||||||
|
* @param c canevas sur le quel dessiner
|
||||||
|
* @param p pinceau
|
||||||
|
*/
|
||||||
public void drawOn(Canvas c, Paint p)
|
public void drawOn(Canvas c, Paint p)
|
||||||
{
|
{
|
||||||
//drawings
|
//drawings
|
||||||
@@ -177,6 +172,11 @@ public class Drawable {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourne vrai si l'objet passer en argument est un drawble qui a le meme nom
|
||||||
|
* @param o l'objet passer en argument
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if(o instanceof Drawable)
|
if(o instanceof Drawable)
|
||||||
@@ -186,6 +186,13 @@ public class Drawable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet de changer les coordonnés sur l'ecran de l'objet
|
||||||
|
* TOUT LES OBJET SONT DESSINER DEPUIS LE COIN HAUT GAUCHE LES COODONNE DESIGNE DONC CE COIN
|
||||||
|
* ET NON PAS LE CENTRE DE LA CARTE
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
*/
|
||||||
public void setCoordinates(float x, float y) {
|
public void setCoordinates(float x, float y) {
|
||||||
this.x=x;
|
this.x=x;
|
||||||
this.y=y;
|
this.y=y;
|
||||||
@@ -204,6 +211,12 @@ public class Drawable {
|
|||||||
*/
|
*/
|
||||||
public void onDeletion(Renderer r){}
|
public void onDeletion(Renderer r){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* coupe le texte a une certaine longeur
|
||||||
|
* @param charPerLines nombre de caractére par lignes
|
||||||
|
* @param text texte a afficher
|
||||||
|
* @return liste de lignes de texte
|
||||||
|
*/
|
||||||
private List<String> cutText(int charPerLines,String text)
|
private List<String> cutText(int charPerLines,String text)
|
||||||
{
|
{
|
||||||
List<String> output = new ArrayList<>();
|
List<String> output = new ArrayList<>();
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.iutlaval.myapplication.ERROR_CODE;
|
||||||
import com.iutlaval.myapplication.Game.Cards.Card;
|
import com.iutlaval.myapplication.Game.Cards.Card;
|
||||||
import com.iutlaval.myapplication.InvalidDataException;
|
import com.iutlaval.myapplication.InvalidDataException;
|
||||||
|
|
||||||
@@ -29,8 +31,23 @@ public class DrawableCard extends Drawable{
|
|||||||
private Drawable cardHpDrawable;
|
private Drawable cardHpDrawable;
|
||||||
private Drawable cardAtkDrawable;
|
private Drawable cardAtkDrawable;
|
||||||
|
|
||||||
|
/**
|
||||||
public DrawableCard(Card c, float x, float y, String name, Context context) throws InvalidDataException {
|
* ce constructeur permet de crée un drawable simplifier pour les carte qui integre :
|
||||||
|
* _le supoort de la description
|
||||||
|
* _le changement d'etat entre grand et terrain
|
||||||
|
* _les point de vie
|
||||||
|
* _l'image
|
||||||
|
* _les deplacement du tout
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param c carte a dessiner
|
||||||
|
* @param x position de la carte sur l'axe x
|
||||||
|
* @param y position de la carte sur l'axe y
|
||||||
|
* @param name nom du drawable
|
||||||
|
* @param context le contexte est simplement l'instance de GameActivity qui est utiliser pas le moteur de jeu
|
||||||
|
* @throws InvalidDataException
|
||||||
|
*/
|
||||||
|
public DrawableCard(Card c, float x, float y, String name, Context context){
|
||||||
super(c.getFrameBitmap(context),x,y,name,CARD_WITH,CARD_HEIGHT);
|
super(c.getFrameBitmap(context),x,y,name,CARD_WITH,CARD_HEIGHT);
|
||||||
|
|
||||||
onBoard=false;
|
onBoard=false;
|
||||||
@@ -40,10 +57,16 @@ public class DrawableCard extends Drawable{
|
|||||||
|
|
||||||
color = c.getColor();//CARD_WITH+x
|
color = c.getColor();//CARD_WITH+x
|
||||||
Rectangle cardRect = new Rectangle(x,y,(float)(CARD_WITH+x),(float)(CARD_HEIGHT+x));
|
Rectangle cardRect = new Rectangle(x,y,(float)(CARD_WITH+x),(float)(CARD_HEIGHT+x));
|
||||||
OpacityRectangleDrawable = new Drawable(cardRect,toString()+"Opacity", Color.parseColor(c.getColor()));
|
|
||||||
|
|
||||||
Bitmap pictureBitmap = BitmapFactory.decodeResource(context.getResources(),c.getCardPicture());
|
Bitmap pictureBitmap = BitmapFactory.decodeResource(context.getResources(),c.getCardPicture());
|
||||||
|
|
||||||
|
try {
|
||||||
|
OpacityRectangleDrawable = new Drawable(cardRect,toString()+"Opacity", Color.parseColor(c.getColor()));
|
||||||
PictureDrawable = new Drawable(pictureBitmap,getX()+1.1F,getY()+2.5F,toString()+"Picture",CARD_WITH-2.4F,CARD_HEIGHT/2 - 4);
|
PictureDrawable = new Drawable(pictureBitmap,getX()+1.1F,getY()+2.5F,toString()+"Picture",CARD_WITH-2.4F,CARD_HEIGHT/2 - 4);
|
||||||
|
} catch (InvalidDataException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e("CARTE :","forme de la carte invalide !");
|
||||||
|
System.exit(ERROR_CODE.ERROR_INVALID_CARD_DIMENSIONS.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Paint p = new Paint();
|
Paint p = new Paint();
|
||||||
@@ -91,6 +114,12 @@ public class DrawableCard extends Drawable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* supprime la couche alpha numerique d'une carte
|
||||||
|
* MAIS si la carte est completement transparente ALORS la texture devien blanche
|
||||||
|
* @param color le code #AARRGGBB de la carte
|
||||||
|
* @return la texture modifier
|
||||||
|
*/
|
||||||
private String removeAlpha(String color) {
|
private String removeAlpha(String color) {
|
||||||
char[] colorArray = color.toCharArray();
|
char[] colorArray = color.toCharArray();
|
||||||
if(colorArray[1]=='0' && colorArray[2]=='0')return "#FFFFFFFF";
|
if(colorArray[1]=='0' && colorArray[2]=='0')return "#FFFFFFFF";
|
||||||
@@ -141,6 +170,10 @@ public class DrawableCard extends Drawable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defini si la carte doit s'afficher en format plein ecran ou en format terrain (avec ou sans description)
|
||||||
|
* @param onBoard
|
||||||
|
*/
|
||||||
public void setOnBoard(Boolean onBoard)
|
public void setOnBoard(Boolean onBoard)
|
||||||
{
|
{
|
||||||
this.onBoard = onBoard;
|
this.onBoard = onBoard;
|
||||||
|
|||||||
@@ -5,12 +5,19 @@ import android.view.Display;
|
|||||||
public class FpsTime {
|
public class FpsTime {
|
||||||
private static long frametime;
|
private static long frametime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialise le frame time pour pouvoir utliser le delais
|
||||||
|
* @param d ecran
|
||||||
|
*/
|
||||||
public static void init(Display d)
|
public static void init(Display d)
|
||||||
{
|
{
|
||||||
float fps = d.getRefreshRate();
|
float fps = d.getRefreshRate();
|
||||||
frametime = (long)(1.0F/fps*1000);
|
frametime = (long)(1.0F/fps*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* atten exactement la durée d'une image a l'ecran a la vitesse optimal de l'ecran
|
||||||
|
*/
|
||||||
public static void waitFrameTime(){
|
public static void waitFrameTime(){
|
||||||
try {
|
try {
|
||||||
Thread.sleep((frametime));
|
Thread.sleep((frametime));
|
||||||
|
|||||||
@@ -8,11 +8,28 @@ import com.iutlaval.myapplication.GameActivity;
|
|||||||
public class Rectangle {
|
public class Rectangle {
|
||||||
|
|
||||||
float positionX,positionY,width,height;
|
float positionX,positionY,width,height;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialiser un rectangle avec
|
||||||
|
* @param positionX une postion en x
|
||||||
|
* @param positionY une position en y
|
||||||
|
* @param width une largeur
|
||||||
|
* @param height une hauteur
|
||||||
|
*/
|
||||||
public Rectangle(float positionX,float positionY,float width,float height)
|
public Rectangle(float positionX,float positionY,float width,float height)
|
||||||
{
|
{
|
||||||
set(positionX,positionY,width,height);
|
set(positionX,positionY,width,height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet de redefinir toutes le information du rectange
|
||||||
|
*
|
||||||
|
* /!\ si vous modifier un rectange du moteur de rendu il faut prendre en compte la resolution/!\
|
||||||
|
* @param positionX une postion en x
|
||||||
|
* @param positionY une position en y
|
||||||
|
* @param width une largeur
|
||||||
|
* @param height une hauteur
|
||||||
|
*/
|
||||||
public void set(float positionX,float positionY,float width,float height)
|
public void set(float positionX,float positionY,float width,float height)
|
||||||
{
|
{
|
||||||
this.positionX=positionX;
|
this.positionX=positionX;
|
||||||
@@ -37,6 +54,11 @@ public class Rectangle {
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* met automatiquement le rectangle a la taille de l'ecran
|
||||||
|
* /!\ ne pas le lancer plus d'une fois sinon les mesures devienderons n'importequoi /!\
|
||||||
|
* /!\ toutes les dimention du rectangle doivent être comprise entre 0 et 100 sinon elle sortiron de l'ecran/!\
|
||||||
|
*/
|
||||||
protected void scaleRectangleToScreen()
|
protected void scaleRectangleToScreen()
|
||||||
{
|
{
|
||||||
set(getPositionX()* GameActivity.screenWidth/100,
|
set(getPositionX()* GameActivity.screenWidth/100,
|
||||||
|
|||||||
Reference in New Issue
Block a user