Browse files

Merge branch 'devlukas' of github.com:GADCPrague/Project-Manhattan in…

…to devlukas
  • Loading branch information...
2 parents 105b6d8 + f7ac71b commit bf4eb866911ea6bda1594b0652b89a60f4d899f3 Jan Zalsky committed Feb 19, 2012
Showing with 148 additions and 15 deletions.
  1. BIN res/drawable-hdpi/badback1.png
  2. BIN res/drawable-hdpi/badbody1.png
  3. BIN res/drawable-hdpi/badhead1.png
  4. BIN res/drawable-hdpi/badleaf1.png
  5. BIN res/drawable-hdpi/badleaf2.png
  6. BIN res/drawable-hdpi/goodback1.png
  7. BIN res/drawable-hdpi/goodbody1.png
  8. BIN res/drawable-hdpi/goodhead1.png
  9. BIN res/drawable-hdpi/goodleaf1.png
  10. BIN res/drawable-hdpi/goodleaf2.png
  11. BIN res/drawable-ldpi/badback1.png
  12. BIN res/drawable-ldpi/badbody1.png
  13. BIN res/drawable-ldpi/badhead1.png
  14. BIN res/drawable-ldpi/badleaf1.png
  15. BIN res/drawable-ldpi/badleaf2.png
  16. BIN res/drawable-ldpi/goodback1.png
  17. BIN res/drawable-ldpi/goodbody1.png
  18. BIN res/drawable-ldpi/goodhead1.png
  19. BIN res/drawable-ldpi/goodleaf1.png
  20. BIN res/drawable-ldpi/goodleaf2.png
  21. BIN res/drawable-mdpi/badback1.png
  22. BIN res/drawable-mdpi/badbody1.png
  23. BIN res/drawable-mdpi/badhead1.png
  24. BIN res/drawable-mdpi/badleaf1.png
  25. BIN res/drawable-mdpi/badleaf2.png
  26. BIN res/drawable-mdpi/goodback1.png
  27. BIN res/drawable-mdpi/goodbody1.png
  28. BIN res/drawable-mdpi/goodhead1.png
  29. BIN res/drawable-mdpi/goodleaf1.png
  30. BIN res/drawable-mdpi/goodleaf2.png
  31. BIN res/drawable-xhdpi/badback1.png
  32. BIN res/drawable-xhdpi/badbody1.png
  33. BIN res/drawable-xhdpi/badhead1.png
  34. BIN res/drawable-xhdpi/badleaf1.png
  35. BIN res/drawable-xhdpi/badleaf2.png
  36. BIN res/drawable-xhdpi/goodback1.png
  37. BIN res/drawable-xhdpi/goodbody1.png
  38. BIN res/drawable-xhdpi/goodhead1.png
  39. BIN res/drawable-xhdpi/goodleaf1.png
  40. BIN res/drawable-xhdpi/goodleaf2.png
  41. +90 −0 src/cz/gug/hackaton/manhattan/actors/BitmapFlower.java
  42. +11 −6 src/cz/gug/hackaton/manhattan/actors/Flower.java
  43. +43 −9 src/cz/gug/hackaton/manhattan/actors/Garden.java
  44. +4 −0 src/cz/gug/hackaton/manhattan/actors/PlantHolder.java
View
BIN res/drawable-hdpi/badback1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/badbody1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/badhead1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/badleaf1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/badleaf2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/goodback1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/goodbody1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/goodhead1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/goodleaf1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/goodleaf2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/badback1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/badbody1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/badhead1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/badleaf1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/badleaf2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/goodback1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/goodbody1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/goodhead1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/goodleaf1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/goodleaf2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/badback1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/badbody1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/badhead1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/badleaf1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/badleaf2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/goodback1.png
Diff not rendered.
View
BIN res/drawable-mdpi/goodbody1.png
Diff not rendered.
View
BIN res/drawable-mdpi/goodhead1.png
Diff not rendered.
View
BIN res/drawable-mdpi/goodleaf1.png
Diff not rendered.
View
BIN res/drawable-mdpi/goodleaf2.png
Diff not rendered.
View
BIN res/drawable-xhdpi/badback1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/badbody1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/badhead1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/badleaf1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/badleaf2.png
Diff not rendered.
View
BIN res/drawable-xhdpi/goodback1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/goodbody1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/goodhead1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/goodleaf1.png
Diff not rendered.
View
BIN res/drawable-xhdpi/goodleaf2.png
Diff not rendered.
View
90 src/cz/gug/hackaton/manhattan/actors/BitmapFlower.java
@@ -0,0 +1,90 @@
+package cz.gug.hackaton.manhattan.actors;
+
+import cz.gug.hackathon.mantattan.R;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Picture;
+import android.graphics.Rect;
+
+public class BitmapFlower extends Flower {
+
+
+ private int flowerHeadId;
+ private int flowerBodyId;
+ private int flowerLeaf1Id;
+ private int flowerLeaf2Id;
+ private int backgroundId;
+
+
+ Bitmap flowerHeadBitmap,flowerBodyBitmap,flowerLeaf1Bitmap,flowerLeaf2Bitmap,flowerBackgroundBitmap;
+ Rect flowerHeadDim,flowerBodyDim,flowerLeaf1Dim,flowerLeaf2Dim,flowerBackgroundDim;
+
+ //Bitmap back = BitmapFactory.decodeResource(getResources(), R.drawable.background);
+ //Rect backDim = new Rect(0,0,back.getWidth(),back.getHeight());
+ //Rect viewDim;
+ //Paint backPaint = new Paint();
+
+ public BitmapFlower(float xpos, float ypos, float holder_width,
+ float holder_height, int flowerHeadId, int flowerBodyId,
+ int flowerLeaf1Id, int flowerLeaf2Id, int backgroundId,Context context) {
+ super();
+
+ this.xpos = xpos;
+ this.ypos = ypos;
+ this.holder_width = holder_width;
+ this.holder_height = holder_height;
+
+ this.flowerHeadId = flowerHeadId;
+ this.flowerBodyId = flowerBodyId;
+ this.flowerLeaf1Id = flowerLeaf1Id;
+ this.flowerLeaf2Id = flowerLeaf2Id;
+ this.backgroundId = backgroundId;
+
+ flowerHeadBitmap = BitmapFactory.decodeResource(context.getResources(), this.flowerHeadId);
+ flowerHeadDim = new Rect(0,0,flowerHeadBitmap.getWidth(),flowerHeadBitmap.getHeight());
+
+ flowerBodyBitmap = BitmapFactory.decodeResource(context.getResources(), this.flowerBodyId);
+ flowerBodyDim = new Rect(0,0,flowerBodyBitmap.getWidth(),flowerBodyBitmap.getHeight());
+
+ flowerLeaf1Bitmap = BitmapFactory.decodeResource(context.getResources(), this.flowerLeaf1Id);
+ flowerLeaf1Dim = new Rect(0,0,flowerLeaf1Bitmap.getWidth(),flowerLeaf1Bitmap.getHeight());
+
+ flowerLeaf2Bitmap = BitmapFactory.decodeResource(context.getResources(), this.flowerLeaf2Id);
+ flowerLeaf2Dim = new Rect(0,0,flowerLeaf2Bitmap.getWidth(),flowerLeaf2Bitmap.getHeight());
+
+ flowerBackgroundBitmap = BitmapFactory.decodeResource(context.getResources(), this.backgroundId);
+ flowerBackgroundDim = new Rect(0,0,flowerBackgroundBitmap.getWidth(),flowerBackgroundBitmap.getHeight());
+
+ Canvas c;
+ Paint p = new Paint();
+
+ c = flowerHead.beginRecording(flowerHeadBitmap.getWidth(), flowerHeadBitmap.getHeight());
+ c.drawBitmap(flowerHeadBitmap, flowerHeadDim, flowerHeadDim, p);
+ flowerHead.endRecording();
+
+ c = flowerBody.beginRecording(flowerBodyBitmap.getWidth(), flowerBodyBitmap.getHeight());
+ c.drawBitmap(flowerBodyBitmap, flowerBodyDim, flowerBodyDim, p);
+ flowerBody.endRecording();
+
+ c = flowerLeaf1.beginRecording(flowerLeaf1Bitmap.getWidth(), flowerLeaf1Bitmap.getHeight());
+ c.drawBitmap(flowerLeaf1Bitmap, flowerLeaf1Dim, flowerLeaf1Dim, p);
+ flowerLeaf1.endRecording();
+
+ c = flowerLeaf2.beginRecording(flowerLeaf2Bitmap.getWidth(), flowerLeaf2Bitmap.getHeight());
+ c.drawBitmap(flowerLeaf2Bitmap, flowerLeaf2Dim, flowerLeaf2Dim, p);
+ flowerLeaf2.endRecording();
+
+ c = background.beginRecording(flowerBackgroundBitmap.getWidth(), flowerBackgroundBitmap.getHeight());
+ c.drawBitmap(flowerBackgroundBitmap, flowerBackgroundDim, flowerBackgroundDim, p);
+ background.endRecording();
+
+
+
+ }
+
+
+
+}
View
17 src/cz/gug/hackaton/manhattan/actors/Flower.java
@@ -16,12 +16,17 @@
protected Picture cursor = new Picture();
protected Picture background = new Picture();
+
protected float idleFactor;
protected float alphaFactor;
protected float crushFactor=0;
protected float growFactor;
protected float cursorAlphaFactor;
protected float cursorIdleFactor;
+
+ public Flower() {
+ super();
+ }
public Flower(float xpos, float ypos, float holder_width,float holder_height,
Picture flowerHead,Picture flowerBody,Picture flowerLeaf1,
@@ -103,7 +108,7 @@ public void render(Canvas canvas) {
canvas.translate(this.xpos, this.ypos);
canvas.save();
- canvas.translate(holder_width/2-15, holder_height-30);
+ canvas.translate(holder_width/2-background.getHeight()/2, holder_height-background.getHeight()/2);
canvas.drawPicture(background);
canvas.restore();
@@ -115,12 +120,12 @@ public void render(Canvas canvas) {
canvas.restore();
canvas.save();
- canvas.translate(holder_width/2-2, holder_height-30);
+ canvas.translate(holder_width/2-flowerBody.getWidth()/2, holder_height-flowerBody.getHeight());
canvas.drawPicture(flowerBody);
canvas.restore();
canvas.save();
- canvas.translate(holder_width/2-17-10*crushFactor, holder_height-35);
+ canvas.translate(holder_width/2-(flowerLeaf1.getWidth()+2)-10*crushFactor, holder_height-35);
canvas.drawPicture(flowerLeaf1);
canvas.restore();
@@ -130,10 +135,10 @@ public void render(Canvas canvas) {
canvas.restore();
canvas.save();
- canvas.translate(holder_width/2-30, holder_height-80+30*crushFactor);
+ canvas.translate(holder_width/2-flowerHead.getWidth()/2, holder_height-80+30*crushFactor);
- canvas.rotate(180*crushFactor, 30, 30);
- canvas.scale(1,1-crushFactor/3, 30, 30);
+ canvas.rotate(180*crushFactor, flowerHead.getWidth()/2, flowerHead.getHeight()/2);
+ canvas.scale(1,1-crushFactor/3, flowerHead.getWidth()/2, flowerHead.getHeight()/2);
canvas.drawPicture(flowerHead);
canvas.restore();
View
52 src/cz/gug/hackaton/manhattan/actors/Garden.java
@@ -6,7 +6,12 @@
import cz.gug.hackathon.mantattan.R;
import cz.gug.hackaton.manhattan.actors.accessors.PlantHolderAccessor;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.media.MediaPlayer;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -48,6 +53,19 @@
private int[][] stateImage = new int[ROWS][COLS];
+ Bitmap back = BitmapFactory.decodeResource(getResources(), R.drawable.background);
+ Rect backDim = new Rect(0,0,back.getWidth(),back.getHeight());
+ Rect viewDim;
+ Paint backPaint = new Paint();
+
+ private MediaPlayer mp;
+
+ private void initPlayer() {
+ mp = MediaPlayer.create(this.getContext(), R.raw.grow);
+ }
+
+
+
Runnable mUpdate = new Runnable() {
private long lastMillis = System.currentTimeMillis();
@@ -92,6 +110,11 @@ private void checkTap(float x,float y) {
if (garden[r][c][0].wasCrushed(x, y)) {
System.out.println("tapped u:" + c + ", v:" + r);
handleTap(r, c);
+
+ if (!mp.isPlaying()) {
+ mp.start();
+ }
+
}
}
}
@@ -182,13 +205,7 @@ public void onEvent(EventType arg0, BaseTween arg1) {
manager.killTarget(garden[tr][tc][newState[tr][tc]]);
garden[tr][tc][newState[tr][tc]].setCrush(1f);
-
- // Tween.to(garden[tr][tc][newState[tr][tc]], PlantHolderAccessor.CRUSH, 500)
- // .target(0)
- // .ease(Bounce.OUT)
- // .delay(500)
- // .start(manager);
-
+
}
}
));
@@ -228,6 +245,10 @@ public void onEvent(EventType arg0, BaseTween arg1) {
private void initFlowers() {
+ initPlayer();
+
+
+
Tween.registerAccessor(Flower.class, new PlantHolderAccessor());
final View touchView = findViewById(R.id.ingame_main);
@@ -271,22 +292,35 @@ private void initGarden() {
table.shuffle(5);
}
+ this.viewDim = new Rect(0,0,(int)viewWidth,(int)viewHeight);
+
float xwidth = viewWidth/COLS;
float xheight = xwidth;
float yOffset = viewHeight - xheight*ROWS;
for (int c = 0; c < COLS; c++) {
for (int r = 0; r < ROWS; r++) {
- garden[r][c][0] = new NicePlant(c*xwidth, r*xheight+yOffset, xwidth, xheight, null, null, null, null, null, null);
- garden[r][c][1] = new NastyPlant(c*xwidth, r*xheight+yOffset, xwidth, xheight, null, null, null, null, null, null);
+ // garden[r][c][0] = new NicePlant(c*xwidth, r*xheight+yOffset, xwidth, xheight, null, null, null, null, null, null);
+ // garden[r][c][1] = new NastyPlant(c*xwidth, r*xheight+yOffset, xwidth, xheight, null, null, null, null, null, null);
+
+ garden[r][c][0] = new BitmapFlower(c*xwidth, r*xheight+yOffset, xwidth, xheight,R.drawable.goodhead1,R.drawable.goodbody1,R.drawable.goodleaf1,R.drawable.goodleaf2,R.drawable.goodback1, this.getContext());
+ garden[r][c][1] = new BitmapFlower(c*xwidth, r*xheight+yOffset, xwidth, xheight,R.drawable.badhead1,R.drawable.badbody1,R.drawable.badleaf1,R.drawable.badleaf2,R.drawable.badback1, this.getContext());
+
+
stateImage[r][c] = table.getValues(r, c);
}
}
}
protected void onDraw(Canvas canvas) {
+
+ if (viewDim != null) {
+ canvas.save();
+ canvas.drawBitmap(back, backDim, viewDim, backPaint);
+ canvas.restore();
+ }
if (garden != null && table != null ) {
for (int c = 0; c < COLS; c++) {
View
4 src/cz/gug/hackaton/manhattan/actors/PlantHolder.java
@@ -7,6 +7,10 @@
protected float holder_width,holder_height;
+ public PlantHolder() {
+
+ }
+
public PlantHolder(float xpos, float ypos, float holder_width,
float holder_height) {
super();

0 comments on commit bf4eb86

Please sign in to comment.