preparatif moteur jeu + patch crash + patch couleur + simplification carte
This commit is contained in:
@@ -2,6 +2,7 @@ package com.iutlaval.myapplication.Video;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -85,6 +86,7 @@ public class Drawable {
|
||||
|
||||
checkPaint();
|
||||
p.setTextSize(textSize*2);
|
||||
p.setColor(Color.BLACK);
|
||||
|
||||
Canvas c = new Canvas(bitmap);
|
||||
|
||||
@@ -118,7 +120,7 @@ public class Drawable {
|
||||
|
||||
rectangle.scaleRectangleToScreen();
|
||||
Bitmap bitmap = Bitmap.createBitmap((int)rectangle.getWidth(),(int)rectangle.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
rectangle.bitmapRectangleBuilder(bitmap,color,p);
|
||||
rectangle.bitmapRectangleBuilder(bitmap,color);
|
||||
|
||||
this.bitmap=bitmap;
|
||||
}
|
||||
@@ -140,7 +142,7 @@ public class Drawable {
|
||||
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0 || bitmap == null)throw new InvalidDataException(name,rectangle);
|
||||
|
||||
rectangle.scaleRectangleToScreen();
|
||||
rectangle.bitmapRectangleBuilder(bitmap,color,p);
|
||||
rectangle.bitmapRectangleBuilder(bitmap,color);
|
||||
this.bitmap = bitmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DrawableCard extends Drawable{
|
||||
|
||||
Paint p = new Paint();
|
||||
|
||||
|
||||
//TODO optimize rectangle by making it only one time
|
||||
//crée les rectangle pour la carte quand elle est sur le terrain
|
||||
Rectangle cardOnBoardFrame = new Rectangle(x,y,CARD_WITH,CARD_HEIGHT/2);
|
||||
cardOnBoardFrame.scaleRectangleToScreen();
|
||||
@@ -86,11 +86,13 @@ public class DrawableCard extends Drawable{
|
||||
Bitmap cardOnBoardBitmap= Bitmap.createBitmap((int)cardOnBoardFrame.getWidth(),(int)cardOnBoardFrame.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
//on dessine nos rectangle sur la bitmap
|
||||
cardOnBoardFrame.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor(removeAlpha(c.getColor())),p);
|
||||
cardOnBoardHp.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor("#FF00FF00"),p);
|
||||
cardOnBoardAtk.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor("#FFFF0000"),p);
|
||||
cardOnBoardFrame.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor(removeAlpha(c.getColor())));
|
||||
cardOnBoardHp.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor("#FF00FF00"));
|
||||
cardOnBoardAtk.bitmapRectangleBuilder(cardOnBoardBitmap,Color.parseColor("#FFFF0000"));
|
||||
|
||||
cardOnBardDrawable = new Drawable(cardOnBoardBitmap,x,y,toString()+"BOARD",CARD_WITH,CARD_HEIGHT*2/3);
|
||||
|
||||
c.setDrawableCard(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.graphics.Paint;
|
||||
import com.iutlaval.myapplication.GameActivity;
|
||||
|
||||
public class Rectangle {
|
||||
|
||||
public static Paint p;
|
||||
float positionX,positionY,width,height;
|
||||
|
||||
/**
|
||||
@@ -72,9 +72,8 @@ public class Rectangle {
|
||||
* retourne la bitmap entre mais avec un rectangle dessiner dedans
|
||||
* @param bitmap la bitmap sur la quelle dessiner
|
||||
* @param color la couleur du carre
|
||||
* @param p le pinceau utiliser pour le canevas
|
||||
*/
|
||||
public void bitmapRectangleBuilder(Bitmap bitmap, int color,Paint p)
|
||||
public void bitmapRectangleBuilder(Bitmap bitmap, int color)
|
||||
{
|
||||
RectangleCanevas c = new RectangleCanevas(bitmap);
|
||||
if(p==null)p = new Paint();
|
||||
|
||||
@@ -76,7 +76,8 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
||||
*/
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
for(Drawable d : toDraw)
|
||||
//le to Array patch les crash
|
||||
for(Drawable d : toDraw.toArray(new Drawable[0]))
|
||||
{
|
||||
d.drawOn(canvas,p);
|
||||
}
|
||||
@@ -121,6 +122,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
||||
* @return retourne faux si l'element existe deja
|
||||
*/
|
||||
public boolean addToDraw(Drawable newElement){
|
||||
if(newElement == null)return false;
|
||||
for(Drawable d : toDraw)
|
||||
{
|
||||
if(d.equals(newElement))
|
||||
|
||||
Reference in New Issue
Block a user