Commit ee4c082a authored by Rominho15's avatar Rominho15
Browse files

Version 3.1 :

- Modification des fonctions du groupe de briques
- Meilleure gestion des collisions
parent db21cc28
Pipeline #787 skipped
......@@ -57,24 +57,40 @@ public class GameController {
// créé les briques du groupe
BrickGroup brickGroup = gameModel.getBrickGroup();
int largeur = 60;
int hauteur = 20;
int distL = largeur + 20;
int distH = hauteur + 10;
int y = 0;
int x = 0;
for(int i=0 ; i<150 ; i++) {
brickGroup.createBrick(x,y,largeur,hauteur);
x += distL;
if(x+largeur > size.x) {
x = 0;
y += distH;
int nbBricksX = 10;
int ratioX = 4;
Point Px = calculTailleBriqueSpace(size.x,nbBricksX,nbBricksX+1,ratioX);
int largeur = Px.x;
int distL = Px.y;
int nbBricksY = 7;
int RatioY = 1;
Px = calculTailleBriqueSpace(size.y/3,nbBricksX,nbBricksX+1,RatioY);
int hauteur = Px.x;
int distH = Px.y;
int x = distL;
int y = distH;
for(int i=0 ; i<nbBricksY ; i++) {
for(int j=0 ; j<nbBricksX ; j++) {
brickGroup.createBrick(x,y,largeur,hauteur);
x += largeur + distL;
}
x = distL;
y += hauteur + distH;
}
gameView.invalidate();
}
public Point calculTailleBriqueSpace(int tailleTotale,int nbBriques,int nbSpaces,int ratio) {
int tailleSpaces = tailleTotale/(nbBriques*ratio+nbSpaces);
int tailleBriques = ratio * tailleSpaces;
Point p = new Point(tailleBriques,tailleSpaces);
return p;
}
public void startGame() {
gameThread=new GameThread(this,gameModel,gameView);
gameThread.start();
......
......@@ -56,7 +56,6 @@ public class GameView extends View {
paintBall.setARGB(255, 200, 200, 200);
paintBrick=new Paint();
paintBrick.setStrokeWidth(5);
paintBrick.setStyle(Paint.Style.FILL_AND_STROKE);
paintBrick.setARGB(255, 255, 0, 0);
......@@ -92,16 +91,16 @@ public class GameView extends View {
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("View : ", "onTouchEvent");
//Log.d("View : ", "onTouchEvent");
switch(event.getAction()) {
case (MotionEvent.ACTION_MOVE) :
Log.d("View : ", "move " + event.getX() + " " +event.getY());
//Log.d("View : ", "move " + event.getX() + " " +event.getY());
int x=(int)event.getX();
int y=(int)event.getY();
gameControlleur.moveBat(x);
break;
case (MotionEvent.ACTION_DOWN) :
Log.d("View : ", "move " + event.getX() + " " +event.getY());
//Log.d("View : ", "move " + event.getX() + " " +event.getY());
x=(int)event.getX();
y=(int)event.getY();
gameControlleur.moveBat(x);
......@@ -110,6 +109,7 @@ public class GameView extends View {
return true;
}
/*
private SensorManager sensorManager;
private Sensor accelerometer;
......@@ -132,4 +132,5 @@ public class GameView extends View {
{
sensorManager.unregisterListener(eventListener);
}
*/
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment