Skip to content

Commit

Permalink
Optimised the DrawableImage credit to Bairouk Anass
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedSlimani committed Apr 21, 2019
1 parent dce6f03 commit ef50e4c
Show file tree
Hide file tree
Showing 34 changed files with 183 additions and 179 deletions.
Binary file modified .gradle/4.10.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/4.10.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/4.10.1/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/taskHistory/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.10.1/taskHistory/taskHistory.lock
Binary file not shown.
Binary file removed .gradle/4.6/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/4.6/fileContent/fileContent.lock
Binary file not shown.
Binary file removed .gradle/4.6/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/4.6/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/4.6/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file removed .gradle/4.6/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file removed .gradle/4.6/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file removed .gradle/4.6/javaCompile/javaCompile.lock
Binary file not shown.
Binary file removed .gradle/4.6/javaCompile/taskHistory.bin
Binary file not shown.
Binary file removed .gradle/4.6/javaCompile/taskJars.bin
Binary file not shown.
Binary file removed .gradle/4.6/taskHistory/taskHistory.bin
Binary file not shown.
Binary file removed .gradle/4.6/taskHistory/taskHistory.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
326 changes: 159 additions & 167 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/checkDebugClasspath" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/external_libs_dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
Expand Down
2 changes: 2 additions & 0 deletions app2/app2.iml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/checkDebugClasspath" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/external_libs_dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
Expand Down
1 change: 1 addition & 0 deletions emobadaragaminglib/emobadaragaminglib.iml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compile_only_not_namespaced_r_class_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/full_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/intermediate-jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javac" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Screen(Game game) {

/**
* This Method is going to dispose of all the sprites that your screen is using.
*Caaling the garbage collector inside the while loop actually help optimizing the memo.
*Calling the garbage collector inside the while loop actually help optimizing the memo.
*/
public void dispose(){
Iterator<Sprite> e = sprites.iterator();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.emobadaragaminglib.Components;

import com.example.emobadaragaminglib.Base.Game;
import com.example.emobadaragaminglib.Base.Image;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.emobadaragaminglib.Components;


import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
Expand All @@ -9,6 +10,7 @@
import android.graphics.PorterDuff;
import android.util.Log;


import com.example.emobadaragaminglib.Base.Game;
import com.example.emobadaragaminglib.Base.Graphics;
import com.example.emobadaragaminglib.Implementation.AndroidImage;
Expand Down Expand Up @@ -48,15 +50,21 @@ public class DrawableImage {
int colorDots=240;
int colorDrawingArea=201;

public DrawableImage(Bitmap bitmap,DrawFinishListener mdrawFinishListener,int xImage,int yImage) {
this.bitmap = bitmap;
drawFinishListener=mdrawFinishListener;
public DrawableImage(Bitmap bitmap,DrawFinishListener d,int xImage,int yImage,int widthImage,int heightImage) {
//resize image
Bitmap resizedBitmap = Bitmap.createScaledBitmap(bitmap, widthImage, heightImage, true);
bitmap=resizedBitmap;
//
this.bitmap = resizedBitmap;
drawFinishListener=d;
dotedPart(bitmap);

this.xImage=xImage;
this.yImage=yImage;
this.widthImage=bitmap.getWidth();
this.heightImage=bitmap.getHeight();
//this.widthImage=bitmap.getWidth();
//this.heightImage=bitmap.getHeight();
this.widthImage=widthImage;
this.heightImage=heightImage;

mPaint = new Paint();
mPaint.setAntiAlias(true);
Expand Down Expand Up @@ -152,10 +160,10 @@ private void check(int x, int y) {
if (bitmap != null && x >= 0 && x < bitmap.getWidth() && y >= 0 && y < bitmap.getHeight()) {
int pixel = bitmap.getPixel(x, y);
if (Color.red(pixel) == colorDrawingArea && Color.red(pixel) == Color.blue(pixel) && Color.red(pixel) == Color.green(pixel)) {
Log.i("Touch ===", "You're in");
Log.e("Touch ===", "You're in");
canDraw = true;
} else {
Log.i("Touch ===", "You're out");
Log.e("Touch ===", "You're out");
canDraw = false;
}
}
Expand Down Expand Up @@ -252,4 +260,4 @@ public boolean contain(int a,int b){
if(xImage<=a && a<=(xImage+widthImage) && yImage<=b && b<=(yImage+heightImage) ) return true;
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.example.emobadaragaminglib.Base.Game;
import com.example.emobadaragaminglib.Base.Image;
import com.example.emobadaragaminglib.Base.Screen;

/**
* Main component in this library. This is what the user can see and interact with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public void run() {
}
///////////////////////////////:

game.getCurrentScreen().render(deltaTime);
game.getCurrentScreen().drawSprites();
game.getCurrentScreen().render(deltaTime);


Canvas canvas = holder.lockCanvas();
canvas.getClipBounds(dstRect);
Expand Down

0 comments on commit ef50e4c

Please sign in to comment.