├── 1行代码实现矩阵相乘 ├── MatrixMluOneLine.scala └── README.md ├── A*算法求解8数码问题 ├── A-Star.scala ├── README.md └── screenShots │ ├── 1.png │ ├── 2.png │ └── 3.png ├── AffineTransformationEx ├── Cpp │ ├── AffiEx.cpp │ ├── CMakeLists.txt │ └── run.sh ├── Python │ ├── affiex.py │ └── run.sh ├── README.md ├── Scala │ ├── .gitignore │ ├── build.sbt │ ├── project │ │ └── plugins.sbt │ ├── run.sh │ └── src │ │ └── main │ │ ├── java │ │ └── visual │ │ │ └── Imshow.java │ │ └── scala │ │ └── Affiex.scala └── datas │ └── timg.jpg ├── AndroidJump ├── DoodleJump │ ├── .classpath │ ├── .project │ ├── AndroidManifest.xml │ ├── bin │ │ ├── AndroidManifest.xml │ │ ├── DoodleJump.apk │ │ ├── classes.dex │ │ ├── classes │ │ │ └── ldp │ │ │ │ └── games │ │ │ │ └── doodlejump │ │ │ │ ├── BuildConfig.class │ │ │ │ ├── Constants.class │ │ │ │ ├── DoodleJumpActivity$1.class │ │ │ │ ├── DoodleJumpActivity$MySensorEventListener.class │ │ │ │ ├── DoodleJumpActivity.class │ │ │ │ ├── GameView$GameThread.class │ │ │ │ ├── GameView.class │ │ │ │ ├── Items │ │ │ │ ├── AbstractItem.class │ │ │ │ ├── ItemBullet.class │ │ │ │ ├── ItemFruit.class │ │ │ │ ├── ItemLife.class │ │ │ │ ├── ItemShit.class │ │ │ │ └── ItemUpgradeBullet.class │ │ │ │ ├── LogicManager$LogicThread.class │ │ │ │ ├── LogicManager.class │ │ │ │ ├── OBjectsManager.class │ │ │ │ ├── R$anim.class │ │ │ │ ├── R$attr.class │ │ │ │ ├── R$drawable.class │ │ │ │ ├── R$layout.class │ │ │ │ ├── R$raw.class │ │ │ │ ├── R$string.class │ │ │ │ ├── R.class │ │ │ │ ├── android │ │ │ │ ├── AbstractAndroid.class │ │ │ │ └── Android.class │ │ │ │ ├── bars │ │ │ │ ├── AbstractBar.class │ │ │ │ ├── InstantShiftBar$ShiftThread.class │ │ │ │ ├── InstantShiftBar.class │ │ │ │ ├── NormalBar.class │ │ │ │ ├── ShiftBar$ShiftThread.class │ │ │ │ ├── ShiftBar.class │ │ │ │ ├── SpringBar.class │ │ │ │ └── ThronBar.class │ │ │ │ ├── bulletandexplode │ │ │ │ ├── Bullet.class │ │ │ │ ├── BulletSet$MoveThread.class │ │ │ │ ├── BulletSet.class │ │ │ │ ├── Explode$ExplodeThread.class │ │ │ │ └── Explode.class │ │ │ │ ├── monsters │ │ │ │ ├── AbstractMonster.class │ │ │ │ ├── BlackStrone$MoveThread.class │ │ │ │ ├── BlackStrone$SplitMonster.class │ │ │ │ ├── BlackStrone.class │ │ │ │ ├── EatingHead$MoveThread.class │ │ │ │ ├── EatingHead.class │ │ │ │ ├── RotateMonster$MoveThread.class │ │ │ │ └── RotateMonster.class │ │ │ │ ├── otherviews │ │ │ │ ├── AboutView$AboutThread.class │ │ │ │ ├── AboutView.class │ │ │ │ ├── ExitView$ExitThread.class │ │ │ │ ├── ExitView.class │ │ │ │ ├── FailView$FailThread.class │ │ │ │ ├── FailView.class │ │ │ │ ├── OptionView$OptionThread.class │ │ │ │ ├── OptionView.class │ │ │ │ ├── ScoreView$Coor.class │ │ │ │ ├── ScoreView$ScoreThread.class │ │ │ │ ├── ScoreView.class │ │ │ │ ├── WelcomeView$WelcomeThread.class │ │ │ │ └── WelcomeView.class │ │ │ │ ├── resource │ │ │ │ ├── BitmapManager.class │ │ │ │ └── SoundPlayer.class │ │ │ │ └── sqlite │ │ │ │ ├── DataBaseOperation.class │ │ │ │ ├── MyString.class │ │ │ │ └── SQLOpenHelper.class │ │ ├── dexedLibs │ │ │ └── annotations-913656a1f0cdeea9c8308bbc2884b960.jar │ │ ├── jarlist.cache │ │ └── resources.ap_ │ ├── gen │ │ └── ldp │ │ │ └── games │ │ │ └── doodlejump │ │ │ ├── BuildConfig.java │ │ │ └── R.java │ ├── proguard.cfg │ ├── project.properties │ ├── res │ │ ├── anim │ │ │ ├── anim_hide_to_show.xml │ │ │ └── anim_show_to_hide.xml │ │ ├── drawable-hdpi │ │ │ ├── android.png │ │ │ ├── android_hurt.png │ │ │ ├── android_hurt_launch.png │ │ │ ├── android_launch.png │ │ │ ├── bar.png │ │ │ ├── blackstone.png │ │ │ ├── blackstone_disappear_1.png │ │ │ ├── blackstone_disappear_2.png │ │ │ ├── blackstone_disappear_3.png │ │ │ ├── bullet.png │ │ │ ├── bullet_item.png │ │ │ ├── dabian_item.png │ │ │ ├── explode1.png │ │ │ ├── explode2.png │ │ │ ├── explode3.png │ │ │ ├── explode4.png │ │ │ ├── explode5.png │ │ │ ├── explode6.png │ │ │ ├── fruit_apple.png │ │ │ ├── fruit_banana.png │ │ │ ├── fruit_mango.png │ │ │ ├── fruit_orange.png │ │ │ ├── fruit_peach.png │ │ │ ├── fruit_pear.png │ │ │ ├── fruit_strawberry.png │ │ │ ├── fruit_tomato.png │ │ │ ├── fruit_watermelon.png │ │ │ ├── ic_launcher.png │ │ │ ├── instantshift.png │ │ │ ├── life_bar_1.png │ │ │ ├── life_item.png │ │ │ ├── monster1_left_close.png │ │ │ ├── monster1_left_open.png │ │ │ ├── monster1_right_close.png │ │ │ ├── monster1_right_open.png │ │ │ ├── next_320.png │ │ │ ├── rotate1.png │ │ │ ├── rotate1_attacked.png │ │ │ ├── rotate2.png │ │ │ ├── rotate2_attacked.png │ │ │ ├── rotate3.png │ │ │ ├── rotate3_attacked.png │ │ │ ├── shift_bar.png │ │ │ ├── spring_bar.png │ │ │ ├── thron_bar.png │ │ │ ├── title.png │ │ │ ├── up_down_bar.png │ │ │ └── upgrade.png │ │ ├── drawable-ldpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ ├── android.png │ │ │ ├── android_hurt.png │ │ │ ├── android_hurt_launch.png │ │ │ ├── android_launch.png │ │ │ ├── bar.png │ │ │ ├── blackstone.png │ │ │ ├── blackstone_disappear_1.png │ │ │ ├── blackstone_disappear_2.png │ │ │ ├── blackstone_disappear_3.png │ │ │ ├── bullet.png │ │ │ ├── bullet_item.png │ │ │ ├── dabian_item.png │ │ │ ├── explode1.png │ │ │ ├── explode2.png │ │ │ ├── explode3.png │ │ │ ├── explode4.png │ │ │ ├── explode5.png │ │ │ ├── explode6.png │ │ │ ├── fruit_apple.png │ │ │ ├── fruit_banana.png │ │ │ ├── fruit_mango.png │ │ │ ├── fruit_orange.png │ │ │ ├── fruit_peach.png │ │ │ ├── fruit_pear.png │ │ │ ├── fruit_strawberry.png │ │ │ ├── fruit_tomato.png │ │ │ ├── fruit_watermelon.png │ │ │ ├── ic_launcher.png │ │ │ ├── instantshift.png │ │ │ ├── life_bar_1.png │ │ │ ├── life_item.png │ │ │ ├── monster1_left_close.png │ │ │ ├── monster1_left_open.png │ │ │ ├── monster1_right_close.png │ │ │ ├── monster1_right_open.png │ │ │ ├── next_320.png │ │ │ ├── rotate1.png │ │ │ ├── rotate1_attacked.png │ │ │ ├── rotate2.png │ │ │ ├── rotate2_attacked.png │ │ │ ├── rotate3.png │ │ │ ├── rotate3_attacked.png │ │ │ ├── shift_bar.png │ │ │ ├── spring_bar.png │ │ │ ├── thron_bar.png │ │ │ ├── title.png │ │ │ ├── up_down_bar.png │ │ │ └── upgrade.png │ │ ├── layout │ │ │ └── main.xml │ │ ├── raw │ │ │ ├── blackstone.mp3 │ │ │ ├── eat_fruit.mp3 │ │ │ ├── explode.mp3 │ │ │ ├── fail.mp3 │ │ │ ├── injure.mp3 │ │ │ ├── launch.mp3 │ │ │ ├── normal_bar.mp3 │ │ │ └── spring_bar.mp3 │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── ldp │ │ └── games │ │ └── doodlejump │ │ ├── Constants.java │ │ ├── DoodleJumpActivity.java │ │ ├── GameView.java │ │ ├── Items │ │ ├── AbstractItem.java │ │ ├── ItemBullet.java │ │ ├── ItemFruit.java │ │ ├── ItemLife.java │ │ ├── ItemShit.java │ │ └── ItemUpgradeBullet.java │ │ ├── LogicManager.java │ │ ├── OBjectsManager.java │ │ ├── android │ │ ├── AbstractAndroid.java │ │ └── Android.java │ │ ├── bars │ │ ├── AbstractBar.java │ │ ├── InstantShiftBar.java │ │ ├── NormalBar.java │ │ ├── ShiftBar.java │ │ ├── SpringBar.java │ │ └── ThronBar.java │ │ ├── bulletandexplode │ │ ├── Bullet.java │ │ ├── BulletSet.java │ │ └── Explode.java │ │ ├── monsters │ │ ├── AbstractMonster.java │ │ ├── BlackStrone.java │ │ ├── EatingHead.java │ │ └── RotateMonster.java │ │ ├── otherviews │ │ ├── AboutView.java │ │ ├── ExitView.java │ │ ├── FailView.java │ │ ├── OptionView.java │ │ ├── ScoreView.java │ │ └── WelcomeView.java │ │ ├── resource │ │ ├── BitmapManager.java │ │ └── SoundPlayer.java │ │ └── sqlite │ │ ├── DataBaseOperation.java │ │ ├── MyString.java │ │ └── SQLOpenHelper.java ├── README.md └── screenshots │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ └── 5.png ├── Jacobi迭代法并行求解线性方程组 ├── Jacobi.scala └── README.md ├── README.md ├── SM3密码杂凑算法 ├── 10161918_wlhi.png ├── README.md └── sm3.scala ├── einsum_ex ├── einsum_cpp_explain.cpp ├── ex10_outer_product.py ├── ex11_batch_matrix_multiply.py ├── ex12_tensor_contraction.py ├── ex13_bilinear_transformation.py ├── ex1_1_matrix_diagonal_extraction.py ├── ex1_2_transpose.py ├── ex1_3_permute.py ├── ex2_reduce_sum.py ├── ex3_column_sum.py ├── ex5_matrix_vector_mul.py ├── ex6_matrix_matrix_mul.py ├── ex7_vector_dot_product.py └── ex8_hadamard_product_and_sum.py ├── 在代码中写WTF ├── README.md └── fk.scala ├── 并行求解n皇后问题 ├── N-Queens-Parallel.scala └── README.md ├── 抓取开源中国的资讯页面的新闻列表 ├── 27204708_LYLK.png ├── README.md └── pachong.scala ├── 算法-----烙饼排序 ├── 29161759_GCMH.png ├── README.md └── laobin.scala ├── 类型通用的归并排序 ├── README.md └── mergeSort.scala └── 遗传算法计算一元函数极值 ├── README.md └── yichuanSuanfa.scala /1行代码实现矩阵相乘/MatrixMluOneLine.scala: -------------------------------------------------------------------------------- 1 | val matrix = List( 2 | List(0.5, 1, 2), 3 | List(1, 0.5, 4)) 4 | 5 | val matrix2 = List( 6 | List(2, 3), 7 | List(3, 2), 8 | List(4, 5)) 9 | 10 | (List[List[Double]]() /: matrix)((acc, row) => acc :+ row.zip(matrix2).map(z => 11 | z._2.map(_ * z._1)).reduceLeft(_.zip(_).map(x => x._1 + x._2))) 12 | -------------------------------------------------------------------------------- /1行代码实现矩阵相乘/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/1行代码实现矩阵相乘/README.md -------------------------------------------------------------------------------- /A*算法求解8数码问题/A-Star.scala: -------------------------------------------------------------------------------- 1 | import scala.collection.mutable.PriorityQueue 2 | import scala.annotation.tailrec 3 | 4 | object Main { 5 | 6 | case class Node(score: Int, depth: Int, map: Array[Array[Int]]){ 7 | override def equals(o: Any): Boolean = o match { 8 | case that: Node => { 9 | for(i <- 0 to 2; j <- 0 to 2) 10 | if(map(i)(j) != that.map(i)(j)) return false 11 | true 12 | } 13 | case _ => false 14 | } 15 | override def hashCode = super.hashCode 16 | } 17 | //隐式Ordering对象,下面的优先级队列需要用到 18 | implicit object NodeOrdering extends Ordering[Node] { 19 | def compare(a: Node, b: Node) = if(a.score > b.score) -1 else 1 20 | } 21 | 22 | val openArray = new PriorityQueue 23 | val closeArray = new PriorityQueue 24 | val table = Array((-1, 0), (1, 0), (0, -1), (0, 1)) 25 | 26 | 27 | def main(args: Array[String]) = { 28 | val (sourceNode, targetNode) = getSourceTarget 29 | openArray enqueue sourceNode 30 | 31 | //辅助函数,a*算法的核心部分, 32 | //节点的深度其实等价于从初始节点进过多少步能到达该节点 33 | @tailrec 34 | def calStep: Int = { 35 | val tempNode = openArray.dequeue 36 | closeArray enqueue tempNode 37 | 38 | if(tempNode.equals(targetNode)) 39 | return tempNode.depth 40 | 41 | val (x, y) = getZeroPosition(tempNode) 42 | for(i <- 0 to 3){ 43 | val tempMap = createNewMap(tempNode.map) 44 | val (newX, newY) = (x + table(i)._1, y + table(i)._2) 45 | //判断扩展的位置是否满足边界条件 46 | if(newX >= 0 && newX <= 2 && newY >=0 && newY <= 2){ 47 | tempMap(x)(y) = tempMap(newX)(newY) 48 | tempMap(newX)(newY) = 0 49 | val tempScore = calScore(tempMap, targetNode.map) + tempNode.depth + 1 50 | val newNode = Node(tempScore, tempNode.depth + 1, tempMap) 51 | if(isNodeNew(newNode)) openArray enqueue newNode 52 | } 53 | } 54 | calStep 55 | } 56 | if(hasSolution(sourceNode, targetNode)){ 57 | val minStep = calStep 58 | println(s"最小步数: $minStep\n") 59 | }else println("8数码问题无解!!") 60 | } 61 | //判断8数码问题有无解 62 | //参考: http://blog.csdn.net/ju136/article/details/6876647 63 | def hasSolution(sourceNode: Node, targetNode: Node) = { 64 | val (source, target) = (sourceNode.map.flatten, targetNode.map.flatten) 65 | var sum1, sum2 = 0; 66 | for(i <- 0 to 8; j <- 0 to i) { 67 | if(source(i) != 0 && source(i) < source(j)) sum1 += 1 68 | if(target(i) != 0 && target(i) < target(j)) sum2 += 1 69 | } 70 | if(sum1 % 2 == sum2 % 2) true 71 | else false 72 | } 73 | 74 | //复制一个新的棋盘 75 | def createNewMap(Map: Array[Array[Int]]) = { 76 | val newMap = Array.ofDim[Int](3, 3) 77 | for(i <- 0 to 2; j <- 0 to 2) newMap(i)(j) = Map(i)(j) 78 | newMap 79 | } 80 | //判断新扩展的节点是否已经遍历过 81 | def isNodeNew(node: Node): Boolean = { 82 | for(n <- openArray) if(n.equals(node)) return false 83 | for(n <- closeArray) if(n.equals(node)) return false 84 | true 85 | } 86 | //计算当前棋盘 Map的得分,也就是和目标棋盘有多少个位置不一样 87 | def calScore(Map: Array[Array[Int]], targetMap: Array[Array[Int]]) = { 88 | (0 /: Map.zip(targetMap)){(result, arrays) => 89 | (result /: arrays._1.zip(arrays._2)){(acc, elems) => 90 | if(elems._1 == elems._2) acc else acc + 1 91 | }} 92 | } 93 | 94 | def printNode(node: Node) = { 95 | for(Array <- node.map){ 96 | Array.foreach(x => print(s"$x ")) 97 | println 98 | } 99 | } 100 | //获取棋盘九个格子中空格子的位置,代码中用0代替空格子,也就是寻找0的位置 101 | def getZeroPosition(node: Node): (Int, Int) = { 102 | for(i <- 0 to 2; j <- 0 to 2) 103 | if(node.map(i)(j) == 0) return (i, j) 104 | (-1, -1) 105 | } 106 | //从终端输入获取初始状态和目标状态 107 | def getSourceTarget = { 108 | println("source node:") 109 | val sourceMap = (for(i <- 1 to 3) yield { 110 | io.Source.stdin.getLines.next.split(" ").map(_.toInt).toArray 111 | }).toArray 112 | 113 | println("\ntarget node:") 114 | val targetMap = (for(i <- 1 to 3) yield { 115 | io.Source.stdin.getLines.next.split(" ").map(_.toInt).toArray 116 | }).toArray 117 | 118 | (Node(0, 0, sourceMap), Node(0, 0, targetMap)) 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /A*算法求解8数码问题/README.md: -------------------------------------------------------------------------------- 1 | 应用A*算法解决8数码问题 2 | 3 | 参考资料:http://blog.csdn.net/ju136/article/details/6876647 4 | 5 | ##截图 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /A*算法求解8数码问题/screenShots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/A*算法求解8数码问题/screenShots/1.png -------------------------------------------------------------------------------- /A*算法求解8数码问题/screenShots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/A*算法求解8数码问题/screenShots/2.png -------------------------------------------------------------------------------- /A*算法求解8数码问题/screenShots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/A*算法求解8数码问题/screenShots/3.png -------------------------------------------------------------------------------- /AffineTransformationEx/Cpp/AffiEx.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : AffiEx.cpp 3 | // Author : Depeng Liang 4 | //============================================================================ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main(int argc, char** argv) { 12 | 13 | if (argc != 11) { 14 | std::cout << "usage: AffiEx IMAGE BBOX_TOP_LEFT_X BBOX_TOP_LEFT_Y BBOX_W BBOX_H ROTATE_ANGLE SHEAR_FACTOER OUT_W OUT_H OUT_PATH" << std::endl; 15 | exit(0); 16 | } 17 | 18 | cv::Mat image; 19 | image = cv::imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file 20 | 21 | cv::namedWindow( "origin image", cv::WINDOW_AUTOSIZE );// Create a window for display. 22 | cv::imshow( "origin image", image ); // Show our image inside it. 23 | 24 | float bbox_top_x = atoi(argv[2]); 25 | float bbox_top_y = atoi(argv[3]); 26 | float bbox_w = atoi(argv[4]); 27 | float bbox_h = atoi(argv[5]); 28 | float bbox_center_x = bbox_top_x + bbox_w / 2; 29 | float bbox_center_y = bbox_top_y + bbox_h / 2; 30 | 31 | float new_width = atoi(argv[8]); 32 | float new_height = atoi(argv[9]); 33 | 34 | // crop mat 35 | cv::Mat crop_mat(3, 3, CV_32F); 36 | // set default value of crop_mat 37 | crop_mat.at(0, 0) = 1; 38 | crop_mat.at(0, 1) = 0; 39 | crop_mat.at(0, 2) = 0; 40 | crop_mat.at(1, 0) = 0; 41 | crop_mat.at(1, 1) = 1; 42 | crop_mat.at(1, 2) = 0; 43 | crop_mat.at(2, 0) = 0; 44 | crop_mat.at(2, 1) = 0; 45 | crop_mat.at(2, 2) = 1; 46 | 47 | crop_mat.at(0, 2) = -bbox_top_x; 48 | crop_mat.at(1, 2) = -bbox_top_y; 49 | 50 | // scale mat 51 | cv::Mat scale_mat(3, 3, CV_32F); 52 | // set default value of scale_mat 53 | scale_mat.at(0, 0) = 1; 54 | scale_mat.at(0, 1) = 0; 55 | scale_mat.at(0, 2) = 0; 56 | scale_mat.at(1, 0) = 0; 57 | scale_mat.at(1, 1) = 1; 58 | scale_mat.at(1, 2) = 0; 59 | scale_mat.at(2, 0) = 0; 60 | scale_mat.at(2, 1) = 0; 61 | scale_mat.at(2, 2) = 1; 62 | 63 | scale_mat.at(0, 0) = new_width / bbox_w; 64 | scale_mat.at(1, 1) = new_height / bbox_h; 65 | 66 | // shift mat 67 | cv::Mat shift_mat1(3, 3, CV_32F); 68 | // set default value of shift_mat1 69 | shift_mat1.at(0, 0) = 1; 70 | shift_mat1.at(0, 1) = 0; 71 | shift_mat1.at(0, 2) = 0; 72 | shift_mat1.at(1, 0) = 0; 73 | shift_mat1.at(1, 1) = 1; 74 | shift_mat1.at(1, 2) = 0; 75 | shift_mat1.at(2, 0) = 0; 76 | shift_mat1.at(2, 1) = 0; 77 | shift_mat1.at(2, 2) = 1; 78 | 79 | shift_mat1.at(0, 2) = -(new_width / 2); 80 | shift_mat1.at(1, 2) = -(new_height / 2); 81 | 82 | // rotate mat 83 | cv::Mat rotate_mat(3, 3, CV_32F); 84 | // set default value of rotate_mat 85 | rotate_mat.at(0, 0) = 1; 86 | rotate_mat.at(0, 1) = 0; 87 | rotate_mat.at(0, 2) = 0; 88 | rotate_mat.at(1, 0) = 0; 89 | rotate_mat.at(1, 1) = 1; 90 | rotate_mat.at(1, 2) = 0; 91 | rotate_mat.at(2, 0) = 0; 92 | rotate_mat.at(2, 1) = 0; 93 | rotate_mat.at(2, 2) = 1; 94 | 95 | float angle = atoi(argv[6]); 96 | angle = angle / 180.0 * 3.14159265358979323846; 97 | const float cos_a = std::cos(angle); 98 | const float sin_a = std::sin(angle); 99 | 100 | rotate_mat.at(0, 0) = cos_a; 101 | rotate_mat.at(0, 1) = sin_a; 102 | rotate_mat.at(1, 0) = -sin_a; 103 | rotate_mat.at(1, 1) = cos_a; 104 | 105 | // shear mat 106 | cv::Mat shear_mat(3, 3, CV_32F); 107 | // set default value of shear_mat 108 | shear_mat.at(0, 0) = 1; 109 | shear_mat.at(0, 1) = 0; 110 | shear_mat.at(0, 2) = 0; 111 | shear_mat.at(1, 0) = 0; 112 | shear_mat.at(1, 1) = 1; 113 | shear_mat.at(1, 2) = 0; 114 | shear_mat.at(2, 0) = 0; 115 | shear_mat.at(2, 1) = 0; 116 | shear_mat.at(2, 2) = 1; 117 | 118 | float shear_factor = atof(argv[7]); 119 | shear_mat.at(0, 1) = shear_factor; 120 | shear_mat.at(1, 0) = shear_factor; 121 | 122 | // shift mat 123 | cv::Mat shift_mat2(2, 3, CV_32F); 124 | // set default value of shift_mat2 125 | shift_mat2.at(0, 0) = 1; 126 | shift_mat2.at(0, 1) = 0; 127 | shift_mat2.at(0, 2) = 0; 128 | shift_mat2.at(1, 0) = 0; 129 | shift_mat2.at(1, 1) = 1; 130 | shift_mat2.at(1, 2) = 0; 131 | 132 | shift_mat2.at(0, 2) = new_width / 2; 133 | shift_mat2.at(1, 2) = new_height / 2; 134 | 135 | cv::Mat out; 136 | cv::Mat tran_mat = shift_mat2 * shear_mat * rotate_mat * shift_mat1 * scale_mat * crop_mat; 137 | 138 | cv::Size new_size(new_width, new_height); 139 | cv::warpAffine(image, out, tran_mat, new_size, CV_INTER_LINEAR, cv::BORDER_CONSTANT, 140 | cv::Scalar(0, 0, 0)); 141 | 142 | cv::imwrite(argv[10], out); 143 | cv::namedWindow( "affi image", cv::WINDOW_AUTOSIZE ); 144 | cv::imshow( "affi image", out); 145 | cv::waitKey(); 146 | 147 | return 0; 148 | } 149 | -------------------------------------------------------------------------------- /AffineTransformationEx/Cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(cmake_AffiEx) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | find_package(OpenCV REQUIRED) 7 | message(STATUS "Found OpenCV (${OpenCV_CONFIG_PATH}), includes: ${OpenCV_INCLUDE_DIRS}, libs: ${OpenCV_LIBRARIES}") 8 | 9 | include_directories(${OpenCV_INCLUDE_DIRS}) 10 | 11 | SET(CMAKE_CXX_FLAGS_DEBUG " $ENV{CXXFLAGS} -DDEBUG -g -w") 12 | SET(CMAKE_CXX_FLAGS_RELEASE " $ENV{CXXFLAGS} -DNDEBUG -O3 -w") 13 | SET(PLATFORM ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) 14 | 15 | add_compile_options(-std=c++11) 16 | INCLUDE_DIRECTORIES(/usr/local/include) 17 | LINK_DIRECTORIES(/usr/local/lib /usr/lib) 18 | 19 | LIST(APPEND LIBS ${OpenCV_LIBRARIES} ) 20 | 21 | add_definitions(-DBUILD_STANDALONE=0) 22 | file(GLOB_RECURSE tools_srcs ${CMAKE_CURRENT_SOURCE_DIR}/AffiEx*.cpp) 23 | 24 | # Build each source file independently 25 | foreach (source ${tools_srcs}) 26 | message(STATUS "${source}") 27 | get_filename_component(name ${source} NAME_WE) 28 | 29 | # target 30 | add_executable(${name} ${source}) 31 | target_link_libraries(${name} ${LIBS}) 32 | endforeach (source) 33 | -------------------------------------------------------------------------------- /AffineTransformationEx/Cpp/run.sh: -------------------------------------------------------------------------------- 1 | IMAGE="../datas/timg.jpg" 2 | OUT_PATH="../datas/cropped.jpg" 3 | 4 | BBOX_TOP_LEFT_X=175 5 | BBOX_TOP_LEFT_Y=30 6 | BBOX_W=250 7 | BBOX_H=270 8 | 9 | OUT_W=125 10 | OUT_H=135 11 | 12 | ROTATE_ANGLE=20 13 | SHEAR_FACTOER=0.2 14 | 15 | ./build/AffiEx \ 16 | $IMAGE $BBOX_TOP_LEFT_X $BBOX_TOP_LEFT_Y $BBOX_W $BBOX_H $ROTATE_ANGLE $SHEAR_FACTOER $OUT_W $OUT_H $OUT_PATH 17 | -------------------------------------------------------------------------------- /AffineTransformationEx/Python/affiex.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import argparse 3 | import math 4 | import numpy as np 5 | 6 | def parse_args(): 7 | parser = argparse.ArgumentParser(description='') 8 | parser.add_argument('--image', type=str, default='../datas/timg.jpg', help='') 9 | parser.add_argument('--out-path', type=str, default='../datas/cropped.jpg', help='') 10 | parser.add_argument('--bbox', type=str, default='175,30,250,270', help='') 11 | parser.add_argument('--rotate-angle', type=float, default=10, help='') 12 | parser.add_argument('--out-wh', type=str, default='250,270', help='') 13 | parser.add_argument('--shear-factor', type=float, default=0.1, help='') 14 | return parser.parse_args() 15 | 16 | if __name__ == '__main__': 17 | args = parse_args() 18 | 19 | img = cv2.imread(args.image, 1) 20 | 21 | bbox = [int(e) for e in args.bbox.split(',')] 22 | out_wh = [int(e) for e in args.out_wh.split(',')] 23 | 24 | # crop matrix, mapping the center of bbox to the center of croped image 25 | crop_mat = np.zeros((3, 3), np.float32) 26 | crop_mat[0][0] = 1 27 | crop_mat[1][1] = 1 28 | crop_mat[2][2] = 1 29 | 30 | crop_mat[0][2] = -bbox[0] 31 | crop_mat[1][2] = -bbox[1] 32 | 33 | # scale matrix 34 | scale_mat = np.zeros((3, 3), np.float32) 35 | scale_mat[2][2] = 1 36 | 37 | scale_x = float(out_wh[0]) / bbox[2] 38 | scale_y = float(out_wh[1]) / bbox[3] 39 | 40 | scale_mat[0][0] = scale_x 41 | scale_mat[1][1] = scale_y 42 | 43 | # shift matrix 44 | shift_mat1 = np.zeros((3, 3), np.float32) 45 | shift_mat1[0][0] = 1 46 | shift_mat1[1][1] = 1 47 | shift_mat1[2][2] = 1 48 | 49 | shift_mat1[0][2] = -(out_wh[0] / 2) 50 | shift_mat1[1][2] = -(out_wh[1] / 2) 51 | 52 | # rotate matrix 53 | rotate_mat = np.zeros((3, 3), np.float32) 54 | rotate_mat[0][0] = 1 55 | rotate_mat[1][1] = 1 56 | rotate_mat[2][2] = 1 57 | 58 | angle = args.rotate_angle / 180.0 * 3.14159265358979323846 59 | cos_a = math.cos(angle) 60 | sin_a = math.sin(angle) 61 | 62 | rotate_mat[0][0] = cos_a 63 | rotate_mat[0][1] = sin_a 64 | rotate_mat[1][0] = -sin_a 65 | rotate_mat[1][1] = cos_a 66 | 67 | # shear matrix 68 | shear_mat = np.zeros((3, 3), np.float32) 69 | shear_mat[0][0] = 1 70 | shear_mat[1][1] = 1 71 | shear_mat[2][2] = 1 72 | 73 | shear_x = args.shear_factor 74 | 75 | shear_mat[0][1] = shear_x 76 | shear_mat[1][0] = shear_x 77 | 78 | # shift matrix 79 | shift_mat2 = np.zeros((2, 3), np.float32) 80 | shift_mat2[0][0] = 1 81 | shift_mat2[1][1] = 1 82 | 83 | shift_mat2[0][2] = out_wh[0] / 2 84 | shift_mat2[1][2] = out_wh[1] / 2 85 | 86 | tran_mat = cv2.gemm(shift_mat2, shear_mat, 1, None, 0) 87 | tran_mat = cv2.gemm(tran_mat, rotate_mat, 1, None, 0) 88 | tran_mat = cv2.gemm(tran_mat, shift_mat1, 1, None, 0) 89 | tran_mat = cv2.gemm(tran_mat, scale_mat, 1, None, 0) 90 | tran_mat = cv2.gemm(tran_mat, crop_mat, 1, None, 0) 91 | 92 | out = cv2.warpAffine(img, tran_mat, (out_wh[0], out_wh[1])) 93 | 94 | cv2.imshow('original image', img) 95 | cv2.imshow('cropped image', out) 96 | cv2.imwrite(args.out_path, out) 97 | cv2.waitKey() 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /AffineTransformationEx/Python/run.sh: -------------------------------------------------------------------------------- 1 | 2 | IMAGE="../datas/timg.jpg" 3 | OUT_PATH="../datas/cropped.jpg" 4 | 5 | 6 | BBOX="175,30,250,270" #top_left_x,top_left_y,width,height 7 | OUT_WH="125,135" # width,height 8 | ROTATE_ANGLE=-10 9 | SHEAR_FACTOR=0.1 10 | 11 | python affiex.py \ 12 | --image $IMAGE \ 13 | --bbox $BBOX \ 14 | --rotate-angle $ROTATE_ANGLE \ 15 | --out-wh $OUT_WH \ 16 | --shear-factor $SHEAR_FACTOR \ 17 | --out-path $OUT_PATH 18 | -------------------------------------------------------------------------------- /AffineTransformationEx/README.md: -------------------------------------------------------------------------------- 1 | # Generate Complicated Affine Transformation Matrix With Simple Matrixs(crop,scale,shift,shear,rotate)). 2 | 3 | ### Cpp Version 4 | 5 | #### Compile & Run 6 | ```bah 7 | cd Cpp && mkdir build && cd build && cmake .. && make -j && cd .. && bash run.sh 8 | ``` 9 | 10 | ### Scala Version 11 | 12 | ```bash 13 | cd Scala 14 | ``` 15 | then run `sbt` and compile the project 16 | 17 | ```bash 18 | bash run.sh 19 | ``` 20 | 21 | ### Python Version 22 | ```bah 23 | cd Python && bash run.sh 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /AffineTransformationEx/Scala/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /AffineTransformationEx/Scala/build.sbt: -------------------------------------------------------------------------------- 1 | lazy val commonSettings = Seq( 2 | version := "1.0.0", 3 | scalaVersion := "2.11.8" 4 | ) 5 | 6 | lazy val root = (project in file(".")). 7 | settings(commonSettings: _*). 8 | settings( 9 | name := "AffiEx" 10 | ) 11 | 12 | libraryDependencies ++= Seq( 13 | "nu.pattern" % "opencv" % "2.4.9-7", 14 | "args4j" % "args4j" % "2.33" 15 | ) 16 | -------------------------------------------------------------------------------- /AffineTransformationEx/Scala/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") 2 | 3 | -------------------------------------------------------------------------------- /AffineTransformationEx/Scala/run.sh: -------------------------------------------------------------------------------- 1 | ROOT=$(cd "$(dirname $0)"; pwd) 2 | 3 | CLASS_PATH=$ROOT/target/scala-2.11/classes/:\ 4 | $HOME/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.8.jar:\ 5 | $HOME/.ivy2/cache/args4j/args4j/bundles/args4j-2.33.jar:\ 6 | $HOME/.ivy2/cache/nu.pattern/opencv/jars/opencv-2.4.9-7.jar 7 | 8 | IMAGE="../datas/timg.jpg" 9 | OUT_PATH="../datas/cropped.jpg" 10 | 11 | BBOX="175,30,250,270" #top_left_x,top_left_y,width,height 12 | OUT_WH="125,135" # width,height 13 | 14 | ROTATE_ANGLE=20 15 | SHEAR_FACTOR=0.2 16 | 17 | java -Xmx4G -cp $CLASS_PATH \ 18 | Affiex \ 19 | --image $IMAGE \ 20 | --bbox $BBOX \ 21 | --rotate-angle $ROTATE_ANGLE \ 22 | --shear-factor $SHEAR_FACTOR \ 23 | --out-wh $OUT_WH \ 24 | --out-path $OUT_PATH 25 | -------------------------------------------------------------------------------- /AffineTransformationEx/Scala/src/main/scala/Affiex.scala: -------------------------------------------------------------------------------- 1 | import org.opencv.highgui.Highgui 2 | import visual.Imshow 3 | import org.opencv.imgproc.Imgproc 4 | import org.opencv.core.Mat 5 | import org.opencv.core.CvType 6 | import org.opencv.core.Size 7 | import org.kohsuke.args4j.Option 8 | import scala.collection.JavaConverters._ 9 | import org.kohsuke.args4j.CmdLineParser 10 | import org.opencv.core.Core 11 | 12 | /** 13 | * @author Depeng Liang 14 | */ 15 | object Affiex { 16 | 17 | nu.pattern.OpenCV.loadShared() 18 | 19 | def main(args: Array[String]): Unit = { 20 | val opt = new Argments() 21 | val parser: CmdLineParser = new CmdLineParser(opt) 22 | try { 23 | parser.parseArgument(args.toList.asJava) 24 | val img = Highgui.imread(opt.image) 25 | 26 | val oriShow = new Imshow("original image") 27 | oriShow.showImage(img) 28 | 29 | val bbox = opt.bbox.split(",").map(_.toInt) 30 | val outWh = opt.outWH.split(",").map(_.toInt) 31 | 32 | // crop mat, mapping the center of bbox to the center of croped image after affine transformation 33 | val cropMat = new Mat(3, 3, CvType.CV_32F) 34 | var tmpArr = Array[Float]( 35 | 1, 0, 0, 36 | 0, 1, 0, 37 | 0, 0, 1 38 | ) 39 | cropMat.put(0, 0, tmpArr) 40 | 41 | tmpArr(2) = -bbox(0) 42 | tmpArr(5) = -bbox(1) 43 | cropMat.put(0, 0, tmpArr) 44 | 45 | // scale mat 46 | val scaleMat = new Mat(3, 3, CvType.CV_32F) 47 | tmpArr = Array[Float]( 48 | 1, 0, 0, 49 | 0, 1, 0, 50 | 0, 0, 1 51 | ) 52 | scaleMat.put(0, 0, tmpArr) 53 | 54 | tmpArr(0) = outWh(0).toFloat / bbox(2) 55 | tmpArr(4) = outWh(1).toFloat / bbox(3) 56 | scaleMat.put(0, 0, tmpArr) 57 | 58 | // shift mat 59 | val shiftMat1 = new Mat(3, 3, CvType.CV_32F) 60 | tmpArr = Array[Float]( 61 | 1, 0, 0, 62 | 0, 1, 0, 63 | 0, 0, 1 64 | ) 65 | shiftMat1.put(0, 0, tmpArr) 66 | 67 | tmpArr(2) = -(outWh(0) / 2) 68 | tmpArr(5) = -(outWh(1) / 2) 69 | 70 | shiftMat1.put(0, 0, tmpArr) 71 | 72 | // rotate mat 73 | val rotateMat = new Mat(3, 3, CvType.CV_32F) 74 | tmpArr = Array[Float]( 75 | 1, 0, 0, 76 | 0, 1, 0, 77 | 0, 0, 1 78 | ) 79 | rotateMat.put(0, 0, tmpArr) 80 | 81 | val angle = opt.rotateAngle / 180.0 * 3.14159265358979323846 82 | val cosA = Math.cos(angle).toFloat 83 | val sinA = Math.sin(angle).toFloat 84 | 85 | tmpArr(0) = cosA 86 | tmpArr(1) = sinA 87 | tmpArr(3) = -sinA 88 | tmpArr(4) = cosA 89 | 90 | rotateMat.put(0, 0, tmpArr) 91 | 92 | // shear mat 93 | val shearMat = new Mat(3, 3, CvType.CV_32F) 94 | tmpArr = Array[Float]( 95 | 1, 0, 0, 96 | 0, 1, 0, 97 | 0, 0, 1 98 | ) 99 | shearMat.put(0, 0, tmpArr) 100 | 101 | tmpArr(1) = opt.shearFactor 102 | tmpArr(3) = opt.shearFactor 103 | 104 | shearMat.put(0, 0, tmpArr) 105 | 106 | // shift mat 107 | val shiftMat2 = new Mat(2, 3, CvType.CV_32F) 108 | tmpArr = Array[Float]( 109 | 1, 0, 0, 110 | 0, 1, 0 111 | ) 112 | shiftMat2.put(0, 0, tmpArr) 113 | 114 | tmpArr(2) = outWh(0) / 2 115 | tmpArr(5) = outWh(1) / 2 116 | 117 | shiftMat2.put(0, 0, tmpArr) 118 | 119 | val out = new Mat() 120 | val tranMat = new Mat() 121 | 122 | Core.gemm(shiftMat2, shearMat, 1, new Mat(), 0, tranMat) 123 | Core.gemm(tranMat, rotateMat, 1, new Mat(), 0, tranMat) 124 | Core.gemm(tranMat, shiftMat1, 1, new Mat(), 0, tranMat) 125 | Core.gemm(tranMat, scaleMat, 1, new Mat(), 0, tranMat) 126 | Core.gemm(tranMat, cropMat, 1, new Mat(), 0, tranMat) 127 | Imgproc.warpAffine(img, out, tranMat, new Size(outWh(0), outWh(1))) 128 | 129 | Highgui.imwrite(opt.outPath, out) 130 | val cropShow = new Imshow("croped image") 131 | cropShow.showImage(out) 132 | 133 | } catch { 134 | case ex: Exception => { 135 | println(ex.getMessage, ex) 136 | parser.printUsage(System.err) 137 | sys.exit(1) 138 | } 139 | } 140 | } 141 | 142 | class Argments { 143 | @Option(name = "--image", usage = "input image") 144 | var image: String = "../datas/timg.jpg" 145 | @Option(name = "--bbox", usage = "") 146 | var bbox: String = "175,30,250,270" // top_left_x,top_left_y,width,height 147 | @Option(name = "--rotate-angle", usage = "") 148 | var rotateAngle: Float = 20 149 | @Option(name = "--shear-factor", usage = "") 150 | var shearFactor: Float = 0.2f 151 | @Option(name = "--out-wh", usage = "") 152 | var outWH: String = "250,270" // output_width,output_height 153 | @Option(name = "--out-path", usage = "") 154 | var outPath: String = "../datas/cropped.jpg" // output_width,output_height 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /AffineTransformationEx/datas/timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AffineTransformationEx/datas/timg.jpg -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DoodleJump 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/DoodleJump.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/DoodleJump.apk -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes.dex -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/BuildConfig.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Constants.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity$1.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity$MySensorEventListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity$MySensorEventListener.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/DoodleJumpActivity.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/GameView$GameThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/GameView$GameThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/GameView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/GameView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/AbstractItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/AbstractItem.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemBullet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemBullet.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemFruit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemFruit.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemLife.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemLife.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemShit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemShit.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemUpgradeBullet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/Items/ItemUpgradeBullet.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/LogicManager$LogicThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/LogicManager$LogicThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/LogicManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/LogicManager.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/OBjectsManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/OBjectsManager.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$anim.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$anim.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$attr.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$drawable.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$layout.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$raw.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$raw.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R$string.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/R.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/android/AbstractAndroid.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/android/AbstractAndroid.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/android/Android.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/android/Android.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/AbstractBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/AbstractBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/InstantShiftBar$ShiftThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/InstantShiftBar$ShiftThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/InstantShiftBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/InstantShiftBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/NormalBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/NormalBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ShiftBar$ShiftThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ShiftBar$ShiftThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ShiftBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ShiftBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/SpringBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/SpringBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ThronBar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bars/ThronBar.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Bullet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Bullet.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/BulletSet$MoveThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/BulletSet$MoveThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/BulletSet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/BulletSet.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Explode$ExplodeThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Explode$ExplodeThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Explode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/bulletandexplode/Explode.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/AbstractMonster.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/AbstractMonster.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone$MoveThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone$MoveThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone$SplitMonster.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone$SplitMonster.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/BlackStrone.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/EatingHead$MoveThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/EatingHead$MoveThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/EatingHead.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/EatingHead.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/RotateMonster$MoveThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/RotateMonster$MoveThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/RotateMonster.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/monsters/RotateMonster.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/AboutView$AboutThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/AboutView$AboutThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/AboutView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/AboutView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ExitView$ExitThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ExitView$ExitThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ExitView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ExitView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/FailView$FailThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/FailView$FailThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/FailView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/FailView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/OptionView$OptionThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/OptionView$OptionThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/OptionView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/OptionView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView$Coor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView$Coor.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView$ScoreThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView$ScoreThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/ScoreView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/WelcomeView$WelcomeThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/WelcomeView$WelcomeThread.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/WelcomeView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/otherviews/WelcomeView.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/resource/BitmapManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/resource/BitmapManager.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/resource/SoundPlayer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/resource/SoundPlayer.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/DataBaseOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/DataBaseOperation.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/MyString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/MyString.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/SQLOpenHelper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/classes/ldp/games/doodlejump/sqlite/SQLOpenHelper.class -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/dexedLibs/annotations-913656a1f0cdeea9c8308bbc2884b960.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/dexedLibs/annotations-913656a1f0cdeea9c8308bbc2884b960.jar -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependecy. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/bin/resources.ap_ -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/gen/ldp/games/doodlejump/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package ldp.games.doodlejump; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/gen/ldp/games/doodlejump/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package ldp.games.doodlejump; 9 | 10 | public final class R { 11 | public static final class anim { 12 | public static final int anim_hide_to_show=0x7f040000; 13 | public static final int anim_show_to_hide=0x7f040001; 14 | } 15 | public static final class attr { 16 | } 17 | public static final class drawable { 18 | public static final int android=0x7f020000; 19 | public static final int android_hurt=0x7f020001; 20 | public static final int android_hurt_launch=0x7f020002; 21 | public static final int android_launch=0x7f020003; 22 | public static final int bar=0x7f020004; 23 | public static final int blackstone=0x7f020005; 24 | public static final int blackstone_disappear_1=0x7f020006; 25 | public static final int blackstone_disappear_2=0x7f020007; 26 | public static final int blackstone_disappear_3=0x7f020008; 27 | public static final int bullet=0x7f020009; 28 | public static final int bullet_item=0x7f02000a; 29 | public static final int dabian_item=0x7f02000b; 30 | public static final int explode1=0x7f02000c; 31 | public static final int explode2=0x7f02000d; 32 | public static final int explode3=0x7f02000e; 33 | public static final int explode4=0x7f02000f; 34 | public static final int explode5=0x7f020010; 35 | public static final int explode6=0x7f020011; 36 | public static final int fruit_apple=0x7f020012; 37 | public static final int fruit_banana=0x7f020013; 38 | public static final int fruit_mango=0x7f020014; 39 | public static final int fruit_orange=0x7f020015; 40 | public static final int fruit_peach=0x7f020016; 41 | public static final int fruit_pear=0x7f020017; 42 | public static final int fruit_strawberry=0x7f020018; 43 | public static final int fruit_tomato=0x7f020019; 44 | public static final int fruit_watermelon=0x7f02001a; 45 | public static final int ic_launcher=0x7f02001b; 46 | public static final int instantshift=0x7f02001c; 47 | public static final int life_bar_1=0x7f02001d; 48 | public static final int life_item=0x7f02001e; 49 | public static final int monster1_left_close=0x7f02001f; 50 | public static final int monster1_left_open=0x7f020020; 51 | public static final int monster1_right_close=0x7f020021; 52 | public static final int monster1_right_open=0x7f020022; 53 | public static final int next_320=0x7f020023; 54 | public static final int rotate1=0x7f020024; 55 | public static final int rotate1_attacked=0x7f020025; 56 | public static final int rotate2=0x7f020026; 57 | public static final int rotate2_attacked=0x7f020027; 58 | public static final int rotate3=0x7f020028; 59 | public static final int rotate3_attacked=0x7f020029; 60 | public static final int shift_bar=0x7f02002a; 61 | public static final int spring_bar=0x7f02002b; 62 | public static final int thron_bar=0x7f02002c; 63 | public static final int title=0x7f02002d; 64 | public static final int up_down_bar=0x7f02002e; 65 | public static final int upgrade=0x7f02002f; 66 | } 67 | public static final class layout { 68 | public static final int main=0x7f030000; 69 | } 70 | public static final class raw { 71 | public static final int blackstone=0x7f050000; 72 | public static final int eat_fruit=0x7f050001; 73 | public static final int explode=0x7f050002; 74 | public static final int fail=0x7f050003; 75 | public static final int injure=0x7f050004; 76 | public static final int launch=0x7f050005; 77 | public static final int normal_bar=0x7f050006; 78 | public static final int spring_bar=0x7f050007; 79 | } 80 | public static final class string { 81 | public static final int app_name=0x7f060001; 82 | public static final int hello=0x7f060000; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-7 12 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/anim/anim_hide_to_show.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/anim/anim_show_to_hide.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/android.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/android_hurt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/android_hurt.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/android_hurt_launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/android_hurt_launch.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/android_launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/android_launch.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/blackstone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/blackstone.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/blackstone_disappear_3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/bullet.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/bullet_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/bullet_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/dabian_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/dabian_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode4.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode5.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/explode6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/explode6.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_apple.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_banana.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_mango.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_mango.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_orange.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_peach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_peach.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_pear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_pear.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_strawberry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_strawberry.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_tomato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_tomato.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/fruit_watermelon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/fruit_watermelon.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/instantshift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/instantshift.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/life_bar_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/life_bar_1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/life_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/life_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/monster1_left_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/monster1_left_close.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/monster1_left_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/monster1_left_open.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/monster1_right_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/monster1_right_close.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/monster1_right_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/monster1_right_open.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/next_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/next_320.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate1_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate1_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate2_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate2_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/rotate3_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/rotate3_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/shift_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/shift_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/spring_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/spring_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/thron_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/thron_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/title.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/up_down_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/up_down_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-hdpi/upgrade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-hdpi/upgrade.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/android.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/android_hurt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/android_hurt.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/android_hurt_launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/android_hurt_launch.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/android_launch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/android_launch.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/blackstone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/blackstone.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/blackstone_disappear_3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/bullet.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/bullet_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/bullet_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/dabian_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/dabian_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode4.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode5.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/explode6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/explode6.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_apple.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_banana.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_mango.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_mango.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_orange.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_peach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_peach.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_pear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_pear.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_strawberry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_strawberry.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_tomato.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_tomato.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/fruit_watermelon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/fruit_watermelon.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/instantshift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/instantshift.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/life_bar_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/life_bar_1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/life_item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/life_item.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/monster1_left_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/monster1_left_close.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/monster1_left_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/monster1_left_open.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/monster1_right_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/monster1_right_close.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/monster1_right_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/monster1_right_open.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/next_320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/next_320.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate1.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate1_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate1_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate2.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate2_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate2_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate3.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/rotate3_attacked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/rotate3_attacked.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/shift_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/shift_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/spring_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/spring_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/thron_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/thron_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/title.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/up_down_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/up_down_bar.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/drawable-mdpi/upgrade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/drawable-mdpi/upgrade.png -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/blackstone.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/blackstone.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/eat_fruit.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/eat_fruit.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/explode.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/explode.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/fail.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/fail.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/injure.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/injure.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/launch.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/launch.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/normal_bar.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/normal_bar.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/raw/spring_bar.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/res/raw/spring_bar.mp3 -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World, DoodleJumpActivity! 5 | AndroidJump 6 | 7 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Constants.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump; 2 | 3 | public class Constants { 4 | public static final int ANIMATION_TIME = 700; 5 | } 6 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/DoodleJumpActivity.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/DoodleJumpActivity.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/GameView.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/GameView.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/AbstractItem.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import ldp.games.doodlejump.android.AbstractAndroid; 4 | import android.graphics.Canvas; 5 | 6 | public abstract class AbstractItem { 7 | public static final int TYPE_NULL = 0; 8 | public static final int TYPE_FRUIT = 1; 9 | public static final int TYPE_SHIT = 2; 10 | public static final int TYPE_LIFE = 3; 11 | public static final int TYPE_BULLET = 4; 12 | 13 | public int type; 14 | 15 | 16 | public abstract void DrawSelf(Canvas canvas, float CoorX, float CoorY); 17 | public abstract void ModifyAndroid(AbstractAndroid android); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/ItemBullet.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.android.AbstractAndroid; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.drawable.BitmapDrawable; 10 | 11 | public class ItemBullet extends AbstractItem { 12 | 13 | Bitmap item_bullet; 14 | 15 | public ItemBullet(DoodleJumpActivity context){ 16 | this.type = TYPE_BULLET; 17 | item_bullet = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.bullet_item)).getBitmap(); 18 | } 19 | 20 | @Override 21 | public void DrawSelf(Canvas canvas, float CoorX, float CoorY) { 22 | canvas.drawBitmap(item_bullet, CoorX, CoorY, null); 23 | 24 | } 25 | 26 | @Override 27 | public void ModifyAndroid(AbstractAndroid android) { 28 | android.bullet_times += 5; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/ItemFruit.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import java.util.Random; 4 | 5 | import ldp.games.doodlejump.DoodleJumpActivity; 6 | import ldp.games.doodlejump.GameView; 7 | import ldp.games.doodlejump.R; 8 | import ldp.games.doodlejump.android.AbstractAndroid; 9 | import ldp.games.doodlejump.resource.SoundPlayer; 10 | 11 | import android.R.plurals; 12 | import android.graphics.Bitmap; 13 | import android.graphics.Canvas; 14 | import android.graphics.drawable.BitmapDrawable; 15 | 16 | public class ItemFruit extends AbstractItem { 17 | 18 | private static final int APPLE = 0; 19 | private static final int BANANA = 1; 20 | private static final int MANGO = 2; 21 | private static final int ORANGE = 3; 22 | private static final int PEACH = 4; 23 | private static final int PEAR = 5; 24 | private static final int STRAWBERRY = 6; 25 | private static final int TOMATO = 7; 26 | private static final int WATERMELON = 8; 27 | 28 | int index; 29 | public Bitmap[] fruits; 30 | 31 | public ItemFruit(DoodleJumpActivity context){ 32 | this.type = TYPE_FRUIT; 33 | index = new Random().nextInt(9); 34 | initBitmap(context); 35 | } 36 | 37 | private void initBitmap(DoodleJumpActivity context) { 38 | fruits = new Bitmap[9]; 39 | fruits[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_apple)).getBitmap(); 40 | fruits[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_banana)).getBitmap(); 41 | fruits[2] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_mango)).getBitmap(); 42 | fruits[3] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_orange)).getBitmap(); 43 | fruits[4] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_peach)).getBitmap(); 44 | fruits[5] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_pear)).getBitmap(); 45 | fruits[6] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_strawberry)).getBitmap(); 46 | fruits[7] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_tomato)).getBitmap(); 47 | fruits[8] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.fruit_watermelon)).getBitmap(); 48 | } 49 | 50 | @Override 51 | public void DrawSelf(Canvas canvas, float CoorX, float CoorY) { 52 | canvas.drawBitmap(fruits[index], CoorX, CoorY, null); 53 | } 54 | 55 | @Override 56 | public void ModifyAndroid(AbstractAndroid android) { 57 | android.AddLifeBar(GetAdd()); 58 | } 59 | 60 | private int GetAdd() { 61 | SoundPlayer.playSound(SoundPlayer.SOUND_EAT_FRUIT); 62 | switch(this.type){ 63 | case APPLE: 64 | case BANANA: 65 | case MANGO: 66 | case ORANGE: 67 | return 20; 68 | case PEACH: 69 | case PEAR: 70 | case STRAWBERRY: 71 | return 30; 72 | case TOMATO: 73 | case WATERMELON: 74 | return 40; 75 | } 76 | return 0; 77 | } 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/ItemLife.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.android.AbstractAndroid; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.drawable.BitmapDrawable; 10 | 11 | public class ItemLife extends AbstractItem { 12 | 13 | Bitmap item_life; 14 | 15 | public ItemLife(DoodleJumpActivity context){ 16 | this.type = TYPE_LIFE; 17 | item_life = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.life_item)).getBitmap(); 18 | } 19 | 20 | @Override 21 | public void DrawSelf(Canvas canvas, float CoorX, float CoorY) { 22 | canvas.drawBitmap(item_life, CoorX, CoorY, null); 23 | 24 | } 25 | 26 | @Override 27 | public void ModifyAndroid(AbstractAndroid android) { 28 | android.life_num ++; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/ItemShit.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.android.AbstractAndroid; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.drawable.BitmapDrawable; 10 | 11 | public class ItemShit extends AbstractItem { 12 | 13 | Bitmap item_shit; 14 | 15 | public ItemShit(DoodleJumpActivity context){ 16 | this.type = TYPE_SHIT; 17 | item_shit = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.dabian_item)).getBitmap(); 18 | } 19 | 20 | @Override 21 | public void DrawSelf(Canvas canvas, float CoorX, float CoorY) { 22 | canvas.drawBitmap(item_shit, CoorX, CoorY, null); 23 | } 24 | 25 | @Override 26 | public void ModifyAndroid(AbstractAndroid android) { 27 | android.MinusLifeBar(10); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/Items/ItemUpgradeBullet.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.Items; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.R; 5 | import ldp.games.doodlejump.android.AbstractAndroid; 6 | import android.graphics.Bitmap; 7 | import android.graphics.Canvas; 8 | import android.graphics.drawable.BitmapDrawable; 9 | 10 | public class ItemUpgradeBullet extends AbstractItem { 11 | 12 | Bitmap Upgrade; 13 | 14 | public ItemUpgradeBullet(DoodleJumpActivity context){ 15 | Upgrade = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.upgrade)).getBitmap(); 16 | } 17 | 18 | @Override 19 | public void DrawSelf(Canvas canvas, float CoorX, float CoorY) { 20 | canvas.drawBitmap(Upgrade, CoorX, CoorY, null); 21 | } 22 | 23 | @Override 24 | public void ModifyAndroid(AbstractAndroid android) { 25 | if(android.bullet_level < 3) 26 | android.bullet_level ++; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/LogicManager.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/LogicManager.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/OBjectsManager.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/OBjectsManager.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/android/AbstractAndroid.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.android; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.OBjectsManager; 5 | import android.graphics.Canvas; 6 | 7 | public abstract class AbstractAndroid { 8 | 9 | 10 | 11 | 12 | public static final float DEFAULT_VERTICAL_ACCELERATE = 1 * DoodleJumpActivity.height_mul; 13 | protected static final float INITIAL_COORX = 145 * DoodleJumpActivity.width_mul; 14 | protected static final float INITIAL_COORY = 380 * DoodleJumpActivity.height_mul; 15 | public static final float INITIAL_VERTICAL_SPEED = -19 * DoodleJumpActivity.height_mul; 16 | public static final float MAX_VERTICAL_SPEED = 19 * DoodleJumpActivity.height_mul; 17 | public static final int STATE_GO_UP = 1; 18 | public static final int STATE_GO_DOWN = 2; 19 | public static final int INITIAL_LIFE_NUM = 10; 20 | public static final int INITIAL_LIFE_BAR = 100; 21 | public static final int INITIAL_LUANCHER_BULLET_TIMES = 100; 22 | public static final int HANDS_UP = 1; 23 | public static final int HANDS_DOWN = 0; 24 | 25 | public float LTCoorX; 26 | public float LTCoorY; 27 | 28 | public float accelerameter; 29 | public float horizonal_speed; 30 | public float vertical_speed; 31 | 32 | public int current_state; 33 | public int life_bar; 34 | public int bullet_times; 35 | public int life_num; 36 | public boolean isfalldown; 37 | public int bitmap_index; 38 | public int bullet_level; 39 | 40 | public abstract void DrawSelf(Canvas canvas); 41 | public abstract void Move(); 42 | public abstract void CheckAndroidCoor(OBjectsManager oBjectsManager); 43 | public abstract void MinusLifeBar(int num); 44 | public abstract void AddLifeBar(int num); 45 | } 46 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/android/Android.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.android; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.LogicManager; 6 | import ldp.games.doodlejump.OBjectsManager; 7 | import ldp.games.doodlejump.R; 8 | import ldp.games.doodlejump.otherviews.OptionView; 9 | import ldp.games.doodlejump.resource.SoundPlayer; 10 | import android.content.SharedPreferences; 11 | import android.graphics.Bitmap; 12 | import android.graphics.Canvas; 13 | import android.graphics.Color; 14 | import android.graphics.Paint; 15 | import android.graphics.drawable.BitmapDrawable; 16 | import android.util.Log; 17 | 18 | public class Android extends AbstractAndroid { 19 | 20 | private boolean ishurt = false; 21 | private int invincible_time = 0; 22 | 23 | public Bitmap[] normal_android; 24 | public Bitmap[] hurt_android; 25 | public Bitmap bullet; 26 | public Bitmap life_littleandroid; 27 | 28 | public Android(DoodleJumpActivity context, int X, int Y){ 29 | this(context); 30 | this.LTCoorX = X; 31 | this.LTCoorY = Y; 32 | 33 | } 34 | 35 | public Android(DoodleJumpActivity context){ 36 | this.LTCoorX = INITIAL_COORX; 37 | this.LTCoorY = INITIAL_COORY; 38 | this.horizonal_speed = 0; 39 | this.vertical_speed = INITIAL_VERTICAL_SPEED + 5 * DoodleJumpActivity.height_mul; 40 | this.current_state = STATE_GO_UP; 41 | accelerameter = DEFAULT_VERTICAL_ACCELERATE; 42 | this.life_bar = INITIAL_LIFE_BAR; 43 | this.life_num = INITIAL_LIFE_NUM; 44 | this.bullet_times = INITIAL_LUANCHER_BULLET_TIMES; 45 | this.bitmap_index = HANDS_DOWN; 46 | this.isfalldown = false; 47 | this.bullet_level = 1; 48 | 49 | getDiffSetting(context); 50 | initBitMap(context); 51 | } 52 | 53 | private void getDiffSetting(DoodleJumpActivity context) { 54 | SharedPreferences sharedPreferences = context.getSharedPreferences(OptionView.PREFS_DIFF, 0); 55 | String diffString = sharedPreferences.getString(OptionView.PREFS_DIFF, "Rookie"); 56 | if(diffString.equalsIgnoreCase(OptionView.DIFFICULTY_ROOKIE)){ 57 | this.bullet_times = INITIAL_LUANCHER_BULLET_TIMES * 2; 58 | } 59 | else if(diffString.equalsIgnoreCase(OptionView.DIFFICULTY_NORMAL)){ 60 | this.life_num = INITIAL_LIFE_NUM - 1; 61 | } 62 | else if(diffString.equalsIgnoreCase(OptionView.DIFFICULTY_MASTER)){ 63 | this.life_num = INITIAL_LIFE_NUM - 3; 64 | this.bullet_times = INITIAL_LUANCHER_BULLET_TIMES - 20; 65 | } 66 | else{ 67 | this.life_num = INITIAL_LIFE_NUM - 5; 68 | this.bullet_times = INITIAL_LUANCHER_BULLET_TIMES - 50; 69 | } 70 | } 71 | 72 | private void initBitMap(DoodleJumpActivity context){ 73 | normal_android = new Bitmap[2]; 74 | normal_android[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.android)).getBitmap(); 75 | normal_android[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.android_launch)).getBitmap(); 76 | 77 | hurt_android = new Bitmap[2]; 78 | hurt_android[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.android_hurt)).getBitmap(); 79 | hurt_android[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.android_hurt_launch)).getBitmap(); 80 | 81 | life_littleandroid = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.life_bar_1)).getBitmap(); 82 | 83 | bullet = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.bullet)).getBitmap(); 84 | } 85 | 86 | @Override 87 | public void DrawSelf(Canvas canvas) { 88 | if(!ishurt) 89 | canvas.drawBitmap(normal_android[bitmap_index], LTCoorX, LTCoorY, null); 90 | else{ 91 | if(invincible_time %2 == 0) 92 | canvas.drawBitmap(normal_android[bitmap_index], LTCoorX, LTCoorY, null); 93 | else 94 | canvas.drawBitmap(hurt_android[bitmap_index], LTCoorX, LTCoorY, null); 95 | invincible_time ++; 96 | if(invincible_time > 20){ 97 | invincible_time = 0; 98 | ishurt = false; 99 | } 100 | } 101 | DrawLifeBar(canvas); 102 | DrawLifeNumandBulletTimes(canvas); 103 | if(bitmap_index == HANDS_UP) 104 | bitmap_index = HANDS_DOWN; 105 | } 106 | 107 | 108 | 109 | 110 | private void DrawLifeNumandBulletTimes(Canvas canvas) { 111 | Paint paint = new Paint(); 112 | paint.setAntiAlias(true); 113 | paint.setTextSize(15* DoodleJumpActivity.height_mul); 114 | canvas.drawText("Life X", DoodleJumpActivity.screen_width/3, 12* DoodleJumpActivity.height_mul, paint); 115 | for(int i=0; i DoodleJumpActivity.screen_height){ 148 | this.MinusLifeBar(LogicManager.FALL_DOWN_DAMAGE); 149 | vertical_speed = Android.INITIAL_VERTICAL_SPEED; 150 | current_state = Android.STATE_GO_UP; 151 | oBjectsManager.isrepeated = false; 152 | } 153 | if(LTCoorX <= -40 * DoodleJumpActivity.width_mul) 154 | LTCoorX = DoodleJumpActivity.screen_width - 40 * DoodleJumpActivity.width_mul; 155 | if(LTCoorX >= DoodleJumpActivity.screen_width) 156 | LTCoorX = 0; 157 | } 158 | 159 | @Override 160 | public void MinusLifeBar(int num) { 161 | if(!ishurt){ 162 | SoundPlayer.playSound(SoundPlayer.SOUND_INJURY); 163 | ishurt = true; 164 | this.life_bar -= num; 165 | if(this.life_bar <= 0){ 166 | this.life_bar = INITIAL_LIFE_BAR; 167 | this.life_num --; 168 | this.bullet_level = 1; 169 | } 170 | } 171 | } 172 | 173 | 174 | @Override 175 | public void AddLifeBar(int num) { 176 | this.life_bar += num; 177 | if(this.life_bar > INITIAL_LIFE_BAR) 178 | this.life_bar = INITIAL_LIFE_BAR; 179 | } 180 | 181 | } 182 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/AbstractBar.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/AbstractBar.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/InstantShiftBar.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/InstantShiftBar.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/NormalBar.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bars; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.Items.AbstractItem; 7 | import ldp.games.doodlejump.resource.SoundPlayer; 8 | import android.graphics.Bitmap; 9 | import android.graphics.Canvas; 10 | import android.graphics.drawable.BitmapDrawable; 11 | 12 | public class NormalBar extends AbstractBar { 13 | 14 | private Bitmap normal_bar; 15 | 16 | public NormalBar(int CoorX, float CoorY, AbstractItem item, DoodleJumpActivity context){ 17 | this.TLCoorX = CoorX; 18 | this.TLCoorY = CoorY; 19 | this.type = TYPE_NORMAL; 20 | this.item = item; 21 | this.isitemeaten = false; 22 | normal_bar = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.bar)).getBitmap(); 23 | } 24 | 25 | @Override 26 | public void drawSelf(Canvas canvas) { 27 | if(this.item != null && !this.isitemeaten) 28 | this.item.DrawSelf(canvas, TLCoorX + 15 * DoodleJumpActivity.height_mul, TLCoorY - 20 * DoodleJumpActivity.height_mul); 29 | canvas.drawBitmap(normal_bar, TLCoorX, TLCoorY, null); 30 | } 31 | 32 | @Override 33 | public boolean IsBeingStep(float CoorX, float CoorY) { 34 | if(CoorX >= TLCoorX - 35 * DoodleJumpActivity.width_mul && CoorX <= TLCoorX + 45 * DoodleJumpActivity.width_mul && CoorY + 45 * DoodleJumpActivity.height_mul <= TLCoorY && TLCoorY - CoorY <= 45 * DoodleJumpActivity.height_mul){ 35 | 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | @Override 42 | public void clear() { 43 | //normal_bar.recycle(); 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/ShiftBar.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bars; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.Items.AbstractItem; 7 | import ldp.games.doodlejump.resource.SoundPlayer; 8 | import android.graphics.Bitmap; 9 | import android.graphics.Canvas; 10 | import android.graphics.drawable.BitmapDrawable; 11 | 12 | public class ShiftBar extends AbstractBar { 13 | 14 | int horizonal_speed = 3; 15 | Bitmap shift_bar; 16 | boolean isrunning = true; 17 | 18 | public ShiftBar(int CoorX, int CoorY, AbstractItem item, DoodleJumpActivity context){ 19 | this.TLCoorX = CoorX; 20 | this.TLCoorY = CoorY; 21 | this.type = TYPE_SHIFT; 22 | this.item = item; 23 | this.isitemeaten = false; 24 | shift_bar = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.shift_bar)).getBitmap(); 25 | new Thread(new ShiftThread()).start(); 26 | } 27 | @Override 28 | public void drawSelf(Canvas canvas) { 29 | if(this.item != null && !this.isitemeaten) 30 | this.item.DrawSelf(canvas, TLCoorX + 15* DoodleJumpActivity.height_mul, TLCoorY - 20* DoodleJumpActivity.height_mul); 31 | canvas.drawBitmap(shift_bar, TLCoorX, TLCoorY, null); 32 | } 33 | 34 | 35 | private class ShiftThread implements Runnable{ 36 | 37 | @Override 38 | public void run() { 39 | while(isrunning){ 40 | try { 41 | Thread.sleep(40); 42 | } catch (Exception e) { 43 | // TODO: handle exception 44 | } 45 | finally{ 46 | if(!GameView.ispause){ 47 | TLCoorX += horizonal_speed; 48 | if(TLCoorX >= 270){ 49 | TLCoorX = 270; 50 | horizonal_speed = -3; 51 | } 52 | if(TLCoorX <= 0){ 53 | TLCoorX = 0; 54 | horizonal_speed = 3; 55 | } 56 | } 57 | } 58 | } 59 | } 60 | 61 | } 62 | 63 | 64 | @Override 65 | public boolean IsBeingStep(float CoorX, float CoorY) { 66 | if(CoorX >= TLCoorX - 35 * DoodleJumpActivity.width_mul && CoorX <= TLCoorX + 45 * DoodleJumpActivity.width_mul && CoorY + 45 * DoodleJumpActivity.height_mul <= TLCoorY && TLCoorY - CoorY <= 45 * DoodleJumpActivity.height_mul){ 67 | // DoodleJumpActivity.soundPlayer.playSound(SoundPlayer.SOUND_NORMAL_BAR); 68 | return true; 69 | } 70 | return false; 71 | } 72 | @Override 73 | public void clear() { 74 | isrunning = false; 75 | //shift_bar.recycle(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/SpringBar.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bars; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import ldp.games.doodlejump.resource.SoundPlayer; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.drawable.BitmapDrawable; 10 | 11 | public class SpringBar extends AbstractBar { 12 | 13 | Bitmap spring_bar; 14 | 15 | 16 | public SpringBar(int CoorX, int CoorY, DoodleJumpActivity context){ 17 | this.TLCoorX = CoorX; 18 | this.TLCoorY = CoorY; 19 | this.type = TYPE_SPRING; 20 | spring_bar = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.spring_bar)).getBitmap(); 21 | } 22 | 23 | 24 | @Override 25 | public void drawSelf(Canvas canvas) { 26 | canvas.drawBitmap(spring_bar, TLCoorX, TLCoorY, null); 27 | 28 | } 29 | 30 | 31 | @Override 32 | public boolean IsBeingStep(float CoorX, float CoorY) { 33 | if(CoorX >= TLCoorX - 35 * DoodleJumpActivity.width_mul && CoorX <= TLCoorX + 45 * DoodleJumpActivity.width_mul && CoorY + 45 * DoodleJumpActivity.height_mul <= TLCoorY && TLCoorY - CoorY <= 45 * DoodleJumpActivity.height_mul){ 34 | SoundPlayer.playSound(SoundPlayer.SOUND_SPRING_BAR); 35 | return true; 36 | } 37 | return false; 38 | } 39 | 40 | 41 | @Override 42 | public void clear() { 43 | // spring_bar.recycle(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bars/ThronBar.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bars; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import android.graphics.Bitmap; 7 | import android.graphics.Canvas; 8 | import android.graphics.drawable.BitmapDrawable; 9 | 10 | public class ThronBar extends AbstractBar { 11 | 12 | public static final int THRON_BAR_DAMAGE = 20; 13 | Bitmap thron_bar; 14 | 15 | public ThronBar(int CoorX, int CoorY, DoodleJumpActivity context){ 16 | this.TLCoorX = CoorX; 17 | this.TLCoorY = CoorY; 18 | this.type = TYPE_THRON; 19 | this.thron_bar = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.thron_bar)).getBitmap(); 20 | } 21 | 22 | @Override 23 | public void drawSelf(Canvas canvas) { 24 | canvas.drawBitmap(thron_bar, TLCoorX, TLCoorY, null); 25 | } 26 | 27 | @Override 28 | public boolean IsBeingStep(float CoorX, float CoorY) { 29 | if(CoorX >= TLCoorX - 35 * DoodleJumpActivity.width_mul && CoorX <= TLCoorX + 45 * DoodleJumpActivity.width_mul && CoorY + 45 * DoodleJumpActivity.height_mul <= TLCoorY && TLCoorY - CoorY <= 45 * DoodleJumpActivity.height_mul) 30 | return true; 31 | return false; 32 | } 33 | 34 | @Override 35 | public void clear() { 36 | // thron_bar.recycle(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bulletandexplode/Bullet.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/bulletandexplode/Bullet.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bulletandexplode/BulletSet.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bulletandexplode; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | 7 | import ldp.games.doodlejump.DoodleJumpActivity; 8 | import ldp.games.doodlejump.android.AbstractAndroid; 9 | import ldp.games.doodlejump.monsters.AbstractMonster; 10 | 11 | import android.graphics.Canvas; 12 | 13 | public class BulletSet { 14 | 15 | HashMap bulletMap = new HashMap(); 16 | 17 | 18 | public BulletSet(AbstractAndroid android, DoodleJumpActivity context){ 19 | if(android.bullet_level == 1) 20 | LevelOne(android, context); 21 | else if(android.bullet_level == 2) 22 | LevelTwo(android, context); 23 | else 24 | LevelTHree(android, context); 25 | new Thread(new MoveThread()).start(); 26 | } 27 | 28 | private void LevelTHree(AbstractAndroid android, DoodleJumpActivity context) { 29 | bulletMap.put(""+1, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 0, context)); 30 | 31 | bulletMap.put(""+2, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -7, context)); 32 | bulletMap.put(""+3, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -10, context)); 33 | bulletMap.put(""+4, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -13, context)); 34 | bulletMap.put(""+5, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -15, context)); 35 | 36 | bulletMap.put(""+6, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 7, context)); 37 | bulletMap.put(""+7, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 10, context)); 38 | bulletMap.put(""+8, new Bullet((int)android.LTCoorX+17,(int)android.LTCoorY-10, 13, context)); 39 | bulletMap.put(""+9, new Bullet((int)android.LTCoorX+17,(int)android.LTCoorY-10, 15, context)); 40 | } 41 | 42 | private void LevelOne(AbstractAndroid android, DoodleJumpActivity context) { 43 | bulletMap.put(""+1, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 0, context)); 44 | bulletMap.put(""+2, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -10, context)); 45 | bulletMap.put(""+3, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -15, context)); 46 | bulletMap.put(""+4, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 10, context)); 47 | bulletMap.put(""+5, new Bullet((int)android.LTCoorX+17,(int)android.LTCoorY-10, 15, context)); 48 | } 49 | 50 | private void LevelTwo(AbstractAndroid android, DoodleJumpActivity context) { 51 | bulletMap.put(""+1, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 0, context)); 52 | 53 | bulletMap.put(""+2, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -7, context)); 54 | bulletMap.put(""+3, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -10, context)); 55 | bulletMap.put(""+4, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, -13, context)); 56 | 57 | bulletMap.put(""+5, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 7, context)); 58 | bulletMap.put(""+6, new Bullet((int)android.LTCoorX+17, (int)android.LTCoorY-10, 10, context)); 59 | bulletMap.put(""+7, new Bullet((int)android.LTCoorX+17,(int)android.LTCoorY-10, 13, context)); 60 | 61 | 62 | } 63 | 64 | public int GetY(){ 65 | for(String key : bulletMap.keySet()){ 66 | return bulletMap.get(key).CoorY; 67 | } 68 | return 0; 69 | } 70 | 71 | public void DrawBullets(Canvas canvas){ 72 | for(String key : bulletMap.keySet()){ 73 | bulletMap.get(key).DrawSelf(canvas); 74 | } 75 | } 76 | 77 | public boolean isTouchBullet(AbstractMonster monster){ 78 | List list = new ArrayList(); 79 | for(String key : bulletMap.keySet()){ 80 | int temp_x = Math.abs(monster.GetX() - bulletMap.get(key).CoorX); 81 | float temp_y = Math.abs(monster.CoorY - bulletMap.get(key).CoorY); 82 | double xiebian = Math.sqrt((double)(temp_x*temp_x) + (double)(temp_y*temp_y)); 83 | if(xiebian <= 30 * DoodleJumpActivity.height_mul){ 84 | monster.BeingAttacked(); 85 | list.add(key); 86 | } 87 | } 88 | for(String key : list){ 89 | bulletMap.remove(key); 90 | } 91 | return monster.IsDestory(); 92 | } 93 | 94 | private class MoveThread implements Runnable{ 95 | 96 | @Override 97 | public void run() { 98 | while(true){ 99 | try { 100 | Thread.sleep(30); 101 | } catch (Exception e) { 102 | // TODO: handle exception 103 | } 104 | for(String key : bulletMap.keySet()){ 105 | bulletMap.get(key).Move(); 106 | } 107 | 108 | } 109 | } 110 | 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/bulletandexplode/Explode.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.bulletandexplode; 2 | 3 | import ldp.games.doodlejump.DoodleJumpActivity; 4 | import ldp.games.doodlejump.GameView; 5 | import ldp.games.doodlejump.R; 6 | import android.graphics.Bitmap; 7 | import android.graphics.Canvas; 8 | import android.graphics.drawable.BitmapDrawable; 9 | 10 | 11 | 12 | public class Explode { 13 | 14 | int index; 15 | boolean isdone; 16 | 17 | int CoorX; 18 | public int CoorY; 19 | public Bitmap[] explodes; 20 | 21 | public Explode(int _CoorX, int _CoorY, DoodleJumpActivity context){ 22 | index = 0; 23 | isdone = false; 24 | this.CoorX = _CoorX; 25 | this.CoorY = _CoorY; 26 | initBitmap(context); 27 | new Thread(new ExplodeThread()).start(); 28 | } 29 | 30 | 31 | 32 | private void initBitmap(DoodleJumpActivity context) { 33 | explodes = new Bitmap[6]; 34 | explodes[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode1)).getBitmap(); 35 | explodes[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode2)).getBitmap(); 36 | explodes[2] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode3)).getBitmap(); 37 | explodes[3] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode4)).getBitmap(); 38 | explodes[4] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode5)).getBitmap(); 39 | explodes[5] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.explode6)).getBitmap(); 40 | } 41 | 42 | 43 | public void DrawSelf(Canvas canvas){ 44 | if(index <= 5) 45 | canvas.drawBitmap(explodes[index], CoorX, CoorY, null); 46 | } 47 | 48 | public boolean isDone(){ 49 | return isdone; 50 | } 51 | 52 | private class ExplodeThread implements Runnable{ 53 | 54 | @Override 55 | public void run() { 56 | while(!isdone){ 57 | try { 58 | Thread.sleep(90); 59 | } catch (Exception e) { 60 | // TODO: handle exception 61 | } 62 | if(!isdone){ 63 | index ++; 64 | if(index > 5) 65 | isdone = true; 66 | } 67 | } 68 | } 69 | 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/AbstractMonster.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/AbstractMonster.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/BlackStrone.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/BlackStrone.java -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/EatingHead.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.monsters; 2 | 3 | import java.util.Random; 4 | 5 | import ldp.games.doodlejump.DoodleJumpActivity; 6 | import ldp.games.doodlejump.GameView; 7 | import ldp.games.doodlejump.R; 8 | import ldp.games.doodlejump.android.AbstractAndroid; 9 | 10 | import android.graphics.Bitmap; 11 | import android.graphics.Canvas; 12 | import android.graphics.drawable.BitmapDrawable; 13 | 14 | public class EatingHead extends AbstractMonster { 15 | 16 | 17 | 18 | public Bitmap[] eatinghead; 19 | 20 | public EatingHead(float f, DoodleJumpActivity context){ 21 | this.CoorX = new Random().nextInt(271) + 25; 22 | this.direction = new Random().nextInt(2) + 1; 23 | bitmap_index = direction == DIRECTION_LEFT ? 0 : 2; 24 | this.CoorY = f; 25 | this.horizontal_speed = direction == DIRECTION_LEFT ? -10 : 10; 26 | intiBitmap(context); 27 | isdestory = false; 28 | isrunning = true; 29 | new Thread(new MoveThread()).start(); 30 | } 31 | 32 | 33 | private void intiBitmap(DoodleJumpActivity context) { 34 | eatinghead = new Bitmap[4]; 35 | eatinghead[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.monster1_left_close)).getBitmap(); 36 | eatinghead[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.monster1_left_open)).getBitmap(); 37 | eatinghead[2] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.monster1_right_close)).getBitmap(); 38 | eatinghead[3] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.monster1_right_open)).getBitmap(); 39 | 40 | } 41 | 42 | 43 | @Override 44 | public void DrawSelf(Canvas canvas) { 45 | canvas.drawBitmap(eatinghead[bitmap_index], CoorX-25* DoodleJumpActivity.height_mul, CoorY-25* DoodleJumpActivity.height_mul, null); 46 | } 47 | 48 | private void Move(){ 49 | this.CoorX += this.horizontal_speed; 50 | if(this.CoorX < 25* DoodleJumpActivity.height_mul){ 51 | this.direction = DIRECTION_RIGHT; 52 | this.horizontal_speed *= -1; 53 | } 54 | if(this.CoorX > DoodleJumpActivity.screen_width - 25* DoodleJumpActivity.height_mul){ 55 | this.direction = DIRECTION_LEFT; 56 | this.horizontal_speed *= -1; 57 | } 58 | } 59 | 60 | private class MoveThread implements Runnable{ 61 | 62 | @Override 63 | public void run() { 64 | while(isrunning){ 65 | try { 66 | Thread.sleep(100); 67 | } catch (Exception e) { 68 | // TODO: handle exception 69 | } 70 | finally{ 71 | if(!GameView.ispause){ 72 | if(direction == DIRECTION_LEFT){ 73 | if(bitmap_index == 0) 74 | bitmap_index = 1; 75 | else 76 | bitmap_index = 0; 77 | } 78 | else{ 79 | if(bitmap_index == 2) 80 | bitmap_index = 3; 81 | else 82 | bitmap_index = 2; 83 | } 84 | Move(); 85 | } 86 | } 87 | } 88 | } 89 | 90 | } 91 | 92 | @Override 93 | public int GetX() { 94 | // TODO Auto-generated method stub 95 | return CoorX; 96 | } 97 | 98 | private int GetDistance(float temp_x, float temp_y, int x, float y) { 99 | double x_length = temp_x - x; 100 | double y_length = temp_y - y; 101 | return (int) Math.sqrt(x_length*x_length + y_length*y_length); 102 | } 103 | 104 | @Override 105 | public void CheckDistance(AbstractAndroid android) { 106 | float temp_x = android.LTCoorX + 22; 107 | float temp_y = android.LTCoorY + 22; 108 | if(GetDistance(temp_x, temp_y, CoorX, CoorY) <= 40 * DoodleJumpActivity.height_mul) 109 | android.MinusLifeBar(10); 110 | } 111 | 112 | 113 | @Override 114 | public boolean IsDestory() { 115 | // TODO Auto-generated method stub 116 | return isdestory; 117 | } 118 | 119 | 120 | @Override 121 | public void BeingAttacked() { 122 | isdestory = true; 123 | } 124 | 125 | 126 | @Override 127 | public boolean IsBeingStep(float CoorX, float CoorY) { 128 | if(CoorX >= this.CoorX - 55 * DoodleJumpActivity.height_mul && CoorX <= this.CoorX + 10 * DoodleJumpActivity.height_mul && CoorY + 70 <= this.CoorY * DoodleJumpActivity.height_mul && this.CoorY - CoorY <= 70 * DoodleJumpActivity.height_mul) 129 | return true; 130 | return false; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/monsters/RotateMonster.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.monsters; 2 | 3 | import java.util.Random; 4 | 5 | import ldp.games.doodlejump.DoodleJumpActivity; 6 | import ldp.games.doodlejump.GameView; 7 | import ldp.games.doodlejump.R; 8 | import ldp.games.doodlejump.android.AbstractAndroid; 9 | import android.graphics.Bitmap; 10 | import android.graphics.Canvas; 11 | import android.graphics.Paint; 12 | import android.graphics.drawable.BitmapDrawable; 13 | 14 | public class RotateMonster extends AbstractMonster { 15 | 16 | private Bitmap[] rotate; 17 | private Bitmap[] rotate_attacked; 18 | private boolean isstop = false; 19 | private int stoptime = 0; 20 | private Paint paint; 21 | private int attacked_times = 0; 22 | private boolean isattacked = false; 23 | 24 | public RotateMonster(float f, DoodleJumpActivity context){ 25 | this.CoorX = new Random().nextInt(271) + 25; 26 | this.direction = new Random().nextInt(2) + 1; 27 | bitmap_index = 0; 28 | this.CoorY = f; 29 | this.horizontal_speed = (int) (direction == DIRECTION_LEFT ? -10 * DoodleJumpActivity.height_mul : 10 * DoodleJumpActivity.height_mul) ; 30 | initBitmap(context); 31 | isrunning = true; 32 | paint = new Paint(); 33 | paint.setAntiAlias(true); 34 | new Thread(new MoveThread()).start(); 35 | } 36 | 37 | private void initBitmap(DoodleJumpActivity context) { 38 | rotate = new Bitmap[3]; 39 | rotate[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate1)).getBitmap(); 40 | rotate[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate2)).getBitmap(); 41 | rotate[2] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate3)).getBitmap(); 42 | 43 | rotate_attacked = new Bitmap[3]; 44 | rotate_attacked[0] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate1_attacked)).getBitmap(); 45 | rotate_attacked[1] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate2_attacked)).getBitmap(); 46 | rotate_attacked[2] = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.rotate3_attacked)).getBitmap(); 47 | } 48 | 49 | @Override 50 | public int GetX() { 51 | return CoorX; 52 | } 53 | 54 | @Override 55 | public void DrawSelf(Canvas canvas) { 56 | if(!isstop){ 57 | if(!isattacked) 58 | canvas.drawBitmap(rotate[bitmap_index], CoorX-25* DoodleJumpActivity.height_mul, CoorY-25* DoodleJumpActivity.height_mul, paint); 59 | else{ 60 | isattacked = false; 61 | canvas.drawBitmap(rotate_attacked[bitmap_index], CoorX-25* DoodleJumpActivity.height_mul, CoorY-25* DoodleJumpActivity.height_mul, paint); 62 | } 63 | } 64 | else{ 65 | if(!isattacked) 66 | canvas.drawBitmap(rotate[0], CoorX-25* DoodleJumpActivity.height_mul, CoorY-25* DoodleJumpActivity.height_mul, paint); 67 | else{ 68 | isattacked = false; 69 | canvas.drawBitmap(rotate_attacked[0], CoorX-25* DoodleJumpActivity.height_mul, CoorY-25* DoodleJumpActivity.height_mul, paint); 70 | } 71 | } 72 | } 73 | 74 | private int GetDistance(float temp_x, float temp_y, int x, float y) { 75 | double x_length = temp_x - x; 76 | double y_length = temp_y - y; 77 | return (int) Math.sqrt(x_length*x_length + y_length*y_length); 78 | } 79 | 80 | @Override 81 | public void CheckDistance(AbstractAndroid android) { 82 | float temp_x = android.LTCoorX + 22* DoodleJumpActivity.height_mul; 83 | float temp_y = android.LTCoorY + 22* DoodleJumpActivity.height_mul; 84 | if(GetDistance(temp_x, temp_y, CoorX, CoorY) <= 40* DoodleJumpActivity.height_mul) 85 | android.MinusLifeBar(20); 86 | 87 | } 88 | 89 | private void Move(){ 90 | this.CoorX += this.horizontal_speed; 91 | if(this.CoorX <= 25* DoodleJumpActivity.height_mul){ 92 | this.direction = DIRECTION_RIGHT; 93 | this.horizontal_speed *= -1; 94 | isstop = true; 95 | } 96 | if(this.CoorX >= DoodleJumpActivity.screen_width - 25* DoodleJumpActivity.height_mul){ 97 | this.direction = DIRECTION_LEFT; 98 | this.horizontal_speed *= -1; 99 | isstop = true; 100 | } 101 | } 102 | 103 | private class MoveThread implements Runnable{ 104 | 105 | @Override 106 | public void run() { 107 | while(isrunning){ 108 | try { 109 | Thread.sleep(50); 110 | } catch (Exception e) { 111 | // TODO: handle exception 112 | } 113 | finally{ 114 | if(!GameView.ispause){ 115 | if(!isstop){ 116 | Move(); 117 | bitmap_index ++; 118 | if(bitmap_index > 2) 119 | bitmap_index = 0; 120 | } 121 | else{ 122 | stoptime ++; 123 | if(stoptime > 20){ 124 | isstop = false; 125 | stoptime = 0; 126 | } 127 | } 128 | 129 | } 130 | } 131 | } 132 | } 133 | 134 | } 135 | 136 | @Override 137 | public boolean IsDestory() { 138 | // TODO Auto-generated method stub 139 | return isdestory; 140 | } 141 | 142 | @Override 143 | public void BeingAttacked() { 144 | if(!isattacked){ 145 | isattacked = true; 146 | attacked_times ++; 147 | if(attacked_times > 1) 148 | isdestory = true; 149 | } 150 | else{ 151 | 152 | } 153 | } 154 | 155 | @Override 156 | public boolean IsBeingStep(float CoorX, float CoorY) { 157 | if(CoorX >= this.CoorX - 55 * DoodleJumpActivity.height_mul && CoorX <= this.CoorX + 10 * DoodleJumpActivity.height_mul&& CoorY + 70 * DoodleJumpActivity.height_mul <= this.CoorY && this.CoorY - CoorY <= 70 * DoodleJumpActivity.height_mul) 158 | return true; 159 | return false; 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/otherviews/AboutView.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.otherviews; 2 | 3 | import ldp.games.doodlejump.Constants; 4 | import ldp.games.doodlejump.DoodleJumpActivity; 5 | import android.content.Context; 6 | import android.graphics.Canvas; 7 | import android.graphics.Color; 8 | import android.graphics.Paint; 9 | import android.view.KeyEvent; 10 | import android.view.MotionEvent; 11 | import android.view.View; 12 | import android.view.animation.AlphaAnimation; 13 | import android.view.animation.Animation; 14 | 15 | public class AboutView extends View { 16 | 17 | DoodleJumpActivity doodleJumpActivity; 18 | boolean isclick = false; 19 | 20 | private Animation alphAnimation; 21 | 22 | public void startEntryAnim(){ 23 | alphAnimation = new AlphaAnimation(0.0f, 1.0f); 24 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 25 | startAnimation(alphAnimation); 26 | } 27 | 28 | public void startExitAnim(){ 29 | alphAnimation = new AlphaAnimation(1.0f, 0.0f); 30 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 31 | startAnimation(alphAnimation); 32 | } 33 | 34 | public AboutView(DoodleJumpActivity context) { 35 | super(context); 36 | doodleJumpActivity = context; 37 | new Thread(new AboutThread()).start(); 38 | startEntryAnim(); 39 | } 40 | 41 | 42 | 43 | 44 | 45 | @Override 46 | protected void onDraw(Canvas canvas) { 47 | canvas.drawColor(Color.parseColor("#faf0cc")); 48 | DrawBackground(canvas); 49 | DrawTitle(canvas); 50 | DrawButton(canvas); 51 | DrawAbout(canvas); 52 | super.onDraw(canvas); 53 | } 54 | 55 | 56 | 57 | 58 | 59 | private void DrawAbout(Canvas canvas) { 60 | Paint paint2 = new Paint(); 61 | paint2.setAntiAlias(true); 62 | paint2.setTextSize(20* DoodleJumpActivity.height_mul); 63 | paint2.setColor(Color.parseColor("#173403")); 64 | int Y = (int) (DoodleJumpActivity.screen_height/8+100 * DoodleJumpActivity.height_mul); 65 | int X = (int) (DoodleJumpActivity.screen_width/2 - 70 * DoodleJumpActivity.height_mul); 66 | canvas.drawText("Android Jump", X, Y, paint2); 67 | canvas.drawText("Version 1.1.1", X, Y+30 * DoodleJumpActivity.height_mul, paint2); 68 | canvas.drawText("Published by Liang Depeng", X-50 * DoodleJumpActivity.height_mul, Y+80 * DoodleJumpActivity.height_mul, paint2); 69 | canvas.drawText("Original concept and game design", X-80 * DoodleJumpActivity.height_mul, Y+110 * DoodleJumpActivity.height_mul, paint2); 70 | canvas.drawText("reference DoodleJump", X-20 * DoodleJumpActivity.height_mul, Y+140 * DoodleJumpActivity.height_mul, paint2); 71 | canvas.drawText("innovated by Liang Depeng", X-50 * DoodleJumpActivity.height_mul, Y+180 * DoodleJumpActivity.height_mul, paint2); 72 | } 73 | 74 | 75 | 76 | 77 | 78 | private void DrawButton(Canvas canvas) { 79 | int y = (int) (DoodleJumpActivity.screen_height-50* DoodleJumpActivity.height_mul); 80 | int x = (int) (DoodleJumpActivity.screen_width/4*3); 81 | Paint paint2 = new Paint(); 82 | paint2.setAntiAlias(true); 83 | paint2.setTextSize(30* DoodleJumpActivity.height_mul); 84 | paint2.setColor(Color.parseColor("#173403")); 85 | canvas.drawText("back", DoodleJumpActivity.screen_width/4*3, DoodleJumpActivity.screen_height-50* DoodleJumpActivity.height_mul, paint2); 86 | paint2.setColor(Color.parseColor("#a0f60b")); 87 | paint2.setAlpha(60); 88 | if(isclick) 89 | canvas.drawRect(x - 20 * DoodleJumpActivity.height_mul, y - 40 * DoodleJumpActivity.height_mul, x + 70 * DoodleJumpActivity.height_mul, y + 20 * DoodleJumpActivity.height_mul, paint2); 90 | } 91 | 92 | 93 | 94 | 95 | 96 | private void DrawTitle(Canvas canvas) { 97 | Paint paint = new Paint(); 98 | paint.setAntiAlias(true); 99 | paint.setTextSize(50* DoodleJumpActivity.height_mul); 100 | paint.setColor(Color.parseColor("#f97f09")); 101 | int y = (int) (DoodleJumpActivity.screen_height / 12); 102 | canvas.drawText("About", DoodleJumpActivity.screen_width/2 - 60 * DoodleJumpActivity.height_mul, y, paint); 103 | } 104 | 105 | 106 | 107 | 108 | 109 | private void DrawBackground(Canvas canvas) { 110 | Paint paint = new Paint(); 111 | paint.setAntiAlias(true); 112 | paint.setColor(Color.parseColor("#c5c5c5")); 113 | for(int i=0; i < DoodleJumpActivity.screen_height; i = (int) (i + 10 * DoodleJumpActivity.height_mul)) 114 | canvas.drawLine(0, i, DoodleJumpActivity.screen_width, i, paint); 115 | for(int i=0; i < DoodleJumpActivity.screen_width; i = (int) (i + 10 * DoodleJumpActivity.height_mul)) 116 | canvas.drawLine(i, 0, i, DoodleJumpActivity.screen_height, paint); 117 | } 118 | 119 | 120 | 121 | @Override 122 | public boolean onTouchEvent(MotionEvent event) { 123 | int y = (int) (DoodleJumpActivity.screen_height-50* DoodleJumpActivity.height_mul); 124 | int x = (int) (DoodleJumpActivity.screen_width/4*3); 125 | if(event.getAction() == MotionEvent.ACTION_DOWN){ 126 | float preX = event.getX(); 127 | float preY = event.getY(); 128 | if(preX > x - 20 * DoodleJumpActivity.height_mul && preX < x+70 * DoodleJumpActivity.height_mul && preY > y - 40 * DoodleJumpActivity.height_mul && preY < y + 20 * DoodleJumpActivity.height_mul) 129 | isclick = true; 130 | } 131 | if(event.getAction() == MotionEvent.ACTION_UP){ 132 | if(isclick){ 133 | startExitAnim(); 134 | doodleJumpActivity.handler.sendEmptyMessage(DoodleJumpActivity.WELCOME); 135 | } 136 | } 137 | return true; 138 | } 139 | 140 | 141 | private class AboutThread implements Runnable{ 142 | 143 | @Override 144 | public void run() { 145 | while(true){ 146 | try { 147 | Thread.sleep(50); 148 | } catch (Exception e) { 149 | // TODO: handle exception 150 | } 151 | postInvalidate(); 152 | } 153 | } 154 | 155 | } 156 | 157 | } 158 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/otherviews/ExitView.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.otherviews; 2 | 3 | //import com.juzi.main.AppConnect; 4 | 5 | import ldp.games.doodlejump.Constants; 6 | import ldp.games.doodlejump.DoodleJumpActivity; 7 | import android.content.Context; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.view.MotionEvent; 12 | import android.view.View; 13 | import android.view.animation.AlphaAnimation; 14 | import android.view.animation.Animation; 15 | 16 | public class ExitView extends View { 17 | 18 | boolean[] isclick = new boolean[2]; 19 | DoodleJumpActivity context; 20 | 21 | private Animation alphAnimation; 22 | 23 | public void startEntryAnim(){ 24 | alphAnimation = new AlphaAnimation(0.0f, 1.0f); 25 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 26 | startAnimation(alphAnimation); 27 | } 28 | 29 | public void startExitAnim(){ 30 | alphAnimation = new AlphaAnimation(1.0f, 0.0f); 31 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 32 | startAnimation(alphAnimation); 33 | } 34 | 35 | public ExitView(DoodleJumpActivity context) { 36 | super(context); 37 | this.context = context; 38 | for(int i=0; i<2; i++) 39 | isclick[i] = false; 40 | new Thread(new ExitThread()).start(); 41 | startEntryAnim(); 42 | } 43 | 44 | @Override 45 | protected void onDraw(Canvas canvas) { 46 | canvas.drawColor(Color.parseColor("#faf0cc")); 47 | DrawBackground(canvas); 48 | DrawTitle(canvas); 49 | DrawButton(canvas); 50 | super.onDraw(canvas); 51 | } 52 | 53 | private void DrawButton(Canvas canvas) { 54 | int X = (int) (DoodleJumpActivity.screen_width / 2 - 70* DoodleJumpActivity.height_mul); 55 | int Y = (int) (DoodleJumpActivity.screen_height / 2); 56 | Paint paint = new Paint(); 57 | paint.setAntiAlias(true); 58 | paint.setColor(Color.parseColor("#a0f60b")); 59 | paint.setAlpha(60); 60 | if(isclick[0]){ 61 | //startExitAnim(); 62 | //AppConnect.getInstance(context).finalize(); 63 | android.os.Process.killProcess(android.os.Process.myPid()); 64 | } 65 | if(isclick[1]){ 66 | //startExitAnim(); 67 | context.handler.sendEmptyMessage(DoodleJumpActivity.WELCOME); 68 | } 69 | Paint paint2 = new Paint(); 70 | paint2.setAntiAlias(true); 71 | paint2.setTextSize(30* DoodleJumpActivity.height_mul); 72 | paint2.setColor(Color.parseColor("#173403")); 73 | canvas.drawText("exit", X, Y, paint2); 74 | canvas.drawText("back", X + 100* DoodleJumpActivity.height_mul, Y, paint2); 75 | } 76 | 77 | private void DrawBackground(Canvas canvas) { 78 | Paint paint = new Paint(); 79 | paint.setAntiAlias(true); 80 | paint.setColor(Color.parseColor("#c5c5c5")); 81 | for(int i=0; i < DoodleJumpActivity.screen_height; i = (int) (i + 10* DoodleJumpActivity.height_mul)) 82 | canvas.drawLine(0, i, DoodleJumpActivity.screen_width, i, paint); 83 | for(int i=0; i < DoodleJumpActivity.screen_width; i = (int) (i + 10* DoodleJumpActivity.height_mul)) 84 | canvas.drawLine(i, 0, i, DoodleJumpActivity.screen_height, paint); 85 | 86 | } 87 | 88 | private void DrawTitle(Canvas canvas) { 89 | Paint paint = new Paint(); 90 | paint.setAntiAlias(true); 91 | paint.setTextSize(50* DoodleJumpActivity.height_mul); 92 | paint.setColor(Color.parseColor("#f97f09")); 93 | int y = (int) (DoodleJumpActivity.screen_height / 12); 94 | canvas.drawText("Exit?", DoodleJumpActivity.screen_width/2 - 40* DoodleJumpActivity.height_mul, y+100* DoodleJumpActivity.height_mul, paint); 95 | } 96 | 97 | @Override 98 | public boolean onTouchEvent(MotionEvent event) { 99 | if(event.getAction() == MotionEvent.ACTION_DOWN){ 100 | int X = (int) (DoodleJumpActivity.screen_width / 2 - 70* DoodleJumpActivity.height_mul); 101 | int Y = (int) (DoodleJumpActivity.screen_height / 2); 102 | int x = (int) event.getX(); 103 | int y = (int) event.getY(); 104 | if(x > X-20 * DoodleJumpActivity.height_mul&& x < X + 50 * DoodleJumpActivity.height_mul&& y > Y - 40* DoodleJumpActivity.height_mul && y < Y + 40* DoodleJumpActivity.height_mul) 105 | isclick[0] = true; 106 | if(x > X+80 * DoodleJumpActivity.height_mul&& x < X + 150 * DoodleJumpActivity.height_mul&& y > Y - 40 * DoodleJumpActivity.height_mul&& y < Y + 40* DoodleJumpActivity.height_mul) 107 | isclick[1] = true; 108 | } 109 | return super.onTouchEvent(event); 110 | } 111 | 112 | 113 | 114 | private class ExitThread implements Runnable{ 115 | 116 | @Override 117 | public void run() { 118 | while(true){ 119 | try { 120 | Thread.sleep(50); 121 | } catch (Exception e) { 122 | // TODO: handle exception 123 | } 124 | postInvalidate(); 125 | } 126 | } 127 | 128 | 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/otherviews/FailView.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.otherviews; 2 | 3 | //import com.juzi.main.AppConnect; 4 | 5 | import ldp.games.doodlejump.Constants; 6 | import ldp.games.doodlejump.DoodleJumpActivity; 7 | import ldp.games.doodlejump.GameView; 8 | import ldp.games.doodlejump.resource.SoundPlayer; 9 | import android.content.Context; 10 | import android.graphics.Canvas; 11 | import android.graphics.Color; 12 | import android.graphics.Paint; 13 | import android.view.MotionEvent; 14 | import android.view.View; 15 | import android.view.animation.AlphaAnimation; 16 | import android.view.animation.Animation; 17 | 18 | public class FailView extends View { 19 | 20 | DoodleJumpActivity doodleJumpActivity; 21 | boolean isrunning = true; 22 | 23 | private Animation alphAnimation; 24 | 25 | public void startEntryAnim(){ 26 | alphAnimation = new AlphaAnimation(0.0f, 1.0f); 27 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 28 | startAnimation(alphAnimation); 29 | } 30 | 31 | public void startExitAnim(){ 32 | alphAnimation = new AlphaAnimation(1.0f, 0.0f); 33 | alphAnimation.setDuration(Constants.ANIMATION_TIME); 34 | startAnimation(alphAnimation); 35 | } 36 | 37 | 38 | public FailView(DoodleJumpActivity context) { 39 | super(context); 40 | doodleJumpActivity = context; 41 | SoundPlayer.playSound(SoundPlayer.SOUND_FAIL); 42 | DoodleJumpActivity.isGame_Running = false; 43 | new Thread(new FailThread()).start(); 44 | startEntryAnim(); 45 | } 46 | 47 | @Override 48 | protected void onDraw(Canvas canvas) { 49 | canvas.drawColor(Color.parseColor("#faf0cc")); 50 | DrawBackground(canvas); 51 | DrawButton(canvas); 52 | super.onDraw(canvas); 53 | } 54 | 55 | private void DrawButton(Canvas canvas) { 56 | Paint paint2 = new Paint(); 57 | paint2.setAntiAlias(true); 58 | paint2.setTextSize(30* DoodleJumpActivity.height_mul); 59 | paint2.setColor(Color.parseColor("#173403")); 60 | canvas.drawText("restart", DoodleJumpActivity.screen_width/2-40* DoodleJumpActivity.height_mul, DoodleJumpActivity.screen_height/10+50* DoodleJumpActivity.height_mul, paint2); 61 | canvas.drawText("exit", DoodleJumpActivity.screen_width/2-20* DoodleJumpActivity.height_mul, DoodleJumpActivity.screen_height/10+150* DoodleJumpActivity.height_mul, paint2); 62 | } 63 | 64 | private void DrawBackground(Canvas canvas) { 65 | Paint paint = new Paint(); 66 | paint.setAntiAlias(true); 67 | paint.setColor(Color.parseColor("#c5c5c5")); 68 | for(int i=0; i < DoodleJumpActivity.screen_height; i = (int) (i + 10* DoodleJumpActivity.height_mul)) 69 | canvas.drawLine(0, i, DoodleJumpActivity.screen_width, i, paint); 70 | for(int i=0; i < DoodleJumpActivity.screen_width; i = (int) (i + 10* DoodleJumpActivity.height_mul)) 71 | canvas.drawLine(i, 0, i, DoodleJumpActivity.screen_height, paint); 72 | } 73 | 74 | @Override 75 | public boolean onTouchEvent(MotionEvent event) { 76 | if(event.getAction() == MotionEvent.ACTION_DOWN){ 77 | float x = event.getX(); 78 | float y = event.getY(); 79 | if(x > DoodleJumpActivity.screen_width/2-60* DoodleJumpActivity.height_mul && x < DoodleJumpActivity.screen_width/2+80* DoodleJumpActivity.height_mul 80 | && y > DoodleJumpActivity.screen_height/10+30* DoodleJumpActivity.height_mul && y DoodleJumpActivity.screen_width/2-40* DoodleJumpActivity.height_mul && x < DoodleJumpActivity.screen_width/2+100* DoodleJumpActivity.height_mul 85 | && y > DoodleJumpActivity.screen_height/10+130* DoodleJumpActivity.height_mul && y 0){ 46 | cursor.moveToFirst(); 47 | // long temp = Long.parseLong(cursor.getString(height_col)); 48 | if(height > temp_h) 49 | SaveToDataBase(height, date); 50 | } 51 | else { 52 | SaveToDataBase(height, date); 53 | } 54 | cursor.close(); 55 | database_read.close(); 56 | } 57 | 58 | private void SaveToDataBase(long height, String date) { 59 | SQLiteDatabase database_write = dbsqlopenhelper.getWritableDatabase(); 60 | ContentValues values = new ContentValues(); 61 | values.put("date", date); 62 | values.put("height", ""+height); 63 | values.put("difficulty", diffString); 64 | database_write.insert(TABLE_NAME, "highid", values); 65 | database_write.close(); 66 | } 67 | 68 | public List GetScoreList(){ 69 | List scoreList = new ArrayList(); 70 | 71 | SQLiteDatabase database_read = dbsqlopenhelper.getReadableDatabase(); 72 | 73 | Cursor cursor = database_read.query(TABLE_NAME, null, null, null, null, null, "highid desc"); 74 | int height_col = cursor.getColumnIndex("height"); 75 | int date_col = cursor.getColumnIndex("date"); 76 | int diff_col = cursor.getColumnIndex("difficulty"); 77 | int num = 0; 78 | if(GetNum() > 0){ 79 | for (cursor.moveToFirst() ; !(cursor.isAfterLast()) ; cursor.moveToNext()){ 80 | num++; 81 | scoreList.add(new MyString(""+num+"."+cursor.getString(date_col)+" "+cursor.getString(height_col), cursor.getString(diff_col))); 82 | } 83 | } 84 | return scoreList; 85 | } 86 | 87 | public long GetNum(){ 88 | 89 | SQLiteDatabase database_read = dbsqlopenhelper.getReadableDatabase(); 90 | 91 | Cursor cursor = database_read.query(TABLE_NAME, null, null, null, null, null, "highid desc"); 92 | int height_col = cursor.getColumnIndex("height"); 93 | int num = 0; 94 | for (cursor.moveToFirst() ; !(cursor.isAfterLast()) ; cursor.moveToNext()){ 95 | num ++; 96 | } 97 | return num; 98 | } 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/sqlite/MyString.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.sqlite; 2 | 3 | public class MyString { 4 | String line_one; 5 | String line_two; 6 | 7 | public String getLine_one() { 8 | return line_one; 9 | } 10 | 11 | public String getLine_two() { 12 | return line_two; 13 | } 14 | 15 | public MyString(String line_one, String line_two){ 16 | this.line_one = line_one; 17 | this.line_two = line_two; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AndroidJump/DoodleJump/src/ldp/games/doodlejump/sqlite/SQLOpenHelper.java: -------------------------------------------------------------------------------- 1 | package ldp.games.doodlejump.sqlite; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | 8 | public class SQLOpenHelper extends SQLiteOpenHelper { 9 | 10 | private static final String DATABASE_NAME = "androidjump.db"; 11 | private static final int DATABASE_VERSION = 1; 12 | 13 | public SQLOpenHelper(Context context){ 14 | this(context, DATABASE_NAME, null, DATABASE_VERSION); 15 | } 16 | 17 | public SQLOpenHelper(Context context, String name, CursorFactory factory, 18 | int version) { 19 | super(context, name, factory, version); 20 | // TODO Auto-generated constructor stub 21 | } 22 | 23 | @Override 24 | public void onCreate(SQLiteDatabase arg0) { 25 | arg0.execSQL("create table androidjump (highid integer primary key autoincrement," 26 | +"date text,"+"height text,"+"difficulty text)"); 27 | } 28 | 29 | @Override 30 | public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) { 31 | // TODO Auto-generated method stub 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /AndroidJump/README.md: -------------------------------------------------------------------------------- 1 | ##仿涂鸦弹跳 2 | 3 | 模仿之前很火的手游涂鸦弹跳,制作比较完整的一个小游戏,之前曾经上传到了机峰等应用网站名字是“安卓弹跳”,不过下载量只有3000多, 4 | 后来就没有时间改进了,现在拿出来分享,还有挺多问题的,屏幕适配就没怎么做。 5 | 6 | 7 | ##展示 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /AndroidJump/screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/screenshots/1.png -------------------------------------------------------------------------------- /AndroidJump/screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/screenshots/2.png -------------------------------------------------------------------------------- /AndroidJump/screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/screenshots/3.png -------------------------------------------------------------------------------- /AndroidJump/screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/screenshots/4.png -------------------------------------------------------------------------------- /AndroidJump/screenshots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/AndroidJump/screenshots/5.png -------------------------------------------------------------------------------- /Jacobi迭代法并行求解线性方程组/README.md: -------------------------------------------------------------------------------- 1 | #用akka来实现并行求解线性方程组 2 | 3 | #输入文件示例 4 | 3 5 | 6 | 7 | 8 -3 2 20 8 | 9 | 10 | 4 11 -1 33 11 | 12 | 13 | 6 3 12 36 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodingForFun 2 | Codes For Sharing 3 | -------------------------------------------------------------------------------- /SM3密码杂凑算法/10161918_wlhi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/SM3密码杂凑算法/10161918_wlhi.png -------------------------------------------------------------------------------- /SM3密码杂凑算法/README.md: -------------------------------------------------------------------------------- 1 | 算法pdf下载:http://www.oscca.gov.cn/News/201012/News_1200.htm 2 | 现在加密的字符只考虑了 ASC 码。 3 | 4 | ###截图 5 | 6 | 7 | -------------------------------------------------------------------------------- /SM3密码杂凑算法/sm3.scala: -------------------------------------------------------------------------------- 1 | object Main { 2 | //每个比特用一个字节来表示 3 | type Bits = List[Byte] 4 | //256比特的初始值 5 | val IV = List("7380166f", "4914b2b9", "172442d7", "da8a0600", "a96f30bc", "163138aa", "e38dee4d", "b0fb0e4e") 6 | val HexTable = List("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f") 7 | //初始值的二进制表示 8 | val IVb = hexStringToBinary(IV) 9 | 10 | val Tj = List("79cc4519", "7a879d8a") 11 | val Tjb = hexStringToBinary(Tj).grouped(32).toList 12 | def getTjb(j: Int) = if(j <= 15) Tjb(0) else Tjb(1) 13 | //获得整数int的二进制表达 14 | def getBinary(int: Int, result: Bits, times: Int): Bits = times match { 15 | case 0 => result 16 | case _ => getBinary(int >> 1, (int & 1).toByte +: result, times - 1) 17 | } 18 | //将16进制的字符串转为二进制表示 19 | def hexStringToBinary(hexString: List[String]) = 20 | (List[Byte]() /: hexString)((acc, elem) => (acc /: elem){ 21 | (a, e) => a ::: getBinary(HexTable.indexOf(e.toString), List[Byte](), 4) 22 | }) 23 | 24 | implicit class MyChar(val c: Char) extends AnyVal{ 25 | def b = getBinary(c.toInt, List[Byte](), 8) 26 | } 27 | 28 | implicit class MyList[T <: Byte](l: List[T]){ 29 | //左循环移位运算 30 | def <<<(n: Int): List[T] = { 31 | def shiftLeft[T](i: Int, list: List[T]) : List[T] = 32 | if(i > 0) { 33 | list match { 34 | case head :: xs => shiftLeft(i-1, xs ::: List(head)) 35 | case Nil => shiftLeft(i-1, Nil) 36 | } 37 | }else list 38 | shiftLeft(n, l) 39 | } 40 | //按位异或运算 41 | def ^(l2: List[T]) = (l zip l2).map{ 42 | case (bit1, bit2) => (bit1 ^ bit2).toByte 43 | } 44 | //按位与操作 45 | def &(l2: List[T]) = (l zip l2).map{ 46 | case (bit1, bit2) => (bit1 & bit2).toByte 47 | } 48 | //按位或操作 49 | def |(l2: List[T]) = (l zip l2).map{ 50 | case (bit1, bit2) => (bit1 | bit2).toByte 51 | } 52 | //按位取反操作 53 | def unary_~ = l.map(~_ & 1).map(_.toByte) 54 | //加运算 55 | def +(l2: List[T]) = { 56 | val addTemp = l.zip(l2).map{case (bit1, bit2) => (bit1 + bit2).toByte} 57 | def carry(ca: Int, result: Bits, num: Int): Bits = 58 | if(num > 0) { 59 | result match { 60 | case head :: tail => 61 | val yushu = (head + ca) % 2 62 | val cane = if(head + ca > 1) 1 else 0 63 | carry(cane, tail ::: List(yushu.toByte), num - 1) 64 | } 65 | } else result 66 | carry(0, addTemp.reverse, addTemp.length).reverse 67 | } 68 | } 69 | 70 | def main(args: Array[String]) = { 71 | val message1 = "abc" 72 | val (padResult, l, k) = padding(stringToBit(message1)) 73 | println(s" message1: $message1\n sm3 encrypt: ${binaryToHexString(iteration(padResult, l, k))}\n") 74 | 75 | val message2 = "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" 76 | val (padResult2, l2, k2) = padding(stringToBit(message2)) 77 | println(s" message2: $message2\n sm3 encrypt: ${binaryToHexString(iteration(padResult2, l2, k2))}") 78 | } 79 | //加密迭代过程 80 | def iteration(message: Bits, l: Int, k: Int) = { 81 | val B = message.grouped(512).toList 82 | val n = (l + k + 65) / 512 83 | def loop(times: Int, V: Bits): Bits = 84 | if(times <= n - 1) loop(times + 1, CF(V, B(times))) 85 | else V 86 | loop(0, IVb) 87 | } 88 | 89 | def FF(X: Bits, Y: Bits, Z: Bits, j: Int) = 90 | if(j <= 15) X ^ Y ^ Z 91 | else (X & Y) | (X & Z) | (Y & Z) 92 | 93 | def GG(X: Bits, Y: Bits, Z: Bits, j: Int) = 94 | if(j <= 15) X ^ Y ^ Z 95 | else (X & Y) | (~ X & Z) 96 | 97 | def CF(V: Bits, B: Bits): Bits = { 98 | val (wj, wjj) = expand(B) 99 | val WordRegister = V.grouped(32).toList 100 | def loop(A: Bits, B: Bits, C: Bits, D: Bits, E: Bits, 101 | F: Bits, G: Bits, H: Bits, num: Int): Bits = num match { 102 | case j if j < 64 => { 103 | val SS1 = ((A <<< 12) + E + (getTjb(j) <<< j)) <<< 7 104 | val SS2 = SS1 ^ (A <<< 12) 105 | val TT1 = FF(A, B, C, j) + D + SS2 + wjj(j) 106 | val TT2 = GG(E, F, G, j) + H + SS1 + wj(j) 107 | loop(TT1, A, B <<< 9, C, P0(TT2), E, F <<< 19, G, j + 1) 108 | } 109 | case 64 => (A ::: B ::: C ::: D ::: E ::: F ::: G ::: H) ^ V 110 | } 111 | loop(WordRegister(0), WordRegister(1), WordRegister(2), WordRegister(3), 112 | WordRegister(4), WordRegister(5), WordRegister(6), WordRegister(7), 0) 113 | } 114 | 115 | def expand(B: Bits) = { 116 | val W16 = B.grouped(32).toList 117 | def loop(W: List[Bits], j: Int): List[Bits] = 118 | if(j >= 16 && j <= 67) 119 | loop(W :+ (P1(W(j - 16) ^ W(j - 9) ^ (W(j - 3) <<< 15)) ^ (W(j - 13) <<< 7) ^ W(j - 6)), j + 1) 120 | else W 121 | val Wj = loop(W16, 16) 122 | val Wjj = for(j <- 0 to 63) yield { Wj(j) ^ Wj(j + 4) } 123 | (Wj, Wjj.toList) 124 | } 125 | 126 | def P0(X: Bits) = X ^ (X <<< 9) ^ (X <<< 17) 127 | 128 | def P1(X: Bits) = X ^ (X <<< 15) ^ (X <<< 23) 129 | 130 | def binaryToHex(binarys: Bits) = (List[String]() /: binarys.grouped(4))((acc, elem) => { 131 | acc :+ s"${HexTable((0 to 3).map(j => Math.pow(2, j) * elem(3 - j)).sum.toInt)}" 132 | }) 133 | 134 | def binaryToHexString(binarys: Bits) = { 135 | val hex = binaryToHex(binarys).grouped(8) 136 | ("" /: hex)((acc, elem) => s"$acc ${("" /: elem)((a, e) => s"$a$e")}") 137 | } 138 | 139 | def stringToBit(string: String) = { 140 | (List[Byte]() /: string.toCharArray)((acc, elem) => acc ::: elem.b) 141 | } 142 | 143 | def padding(message: Bits) = { 144 | val l = message.length 145 | val temp = (l + 1) % 512 146 | val k = if(temp <= 448) 448 - temp else 512 - temp + 448 147 | val addOneZero = (message :+ 1.toByte) ::: getBinary(0, List[Byte](), k) 148 | val padResult = addOneZero ::: getBinary(l, List[Byte](), 64) 149 | (padResult, l, k) 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /einsum_ex/einsum_cpp_explain.cpp: -------------------------------------------------------------------------------- 1 | // 为了方便理解,我简化了大部分代码, 2 | // 并把对于 "..." 省略号的处理去掉了 3 | /** 4 | * 代码实现主要分为3大步: 5 | * 1. 解析 equation,分别得到输入和输出对应的字符串 6 | * 2. 补全输出和输入张量的维度,通过 permute 操作对齐输入和输出的维度 7 | * 3. 将维度对齐之后的输入张量相乘,然后根据求和索引累加 8 | */ 9 | Tensor einsum(std::string equation, TensorList operands) { 10 | // ...... 11 | // 把 equation 按照箭头分割 12 | // 得到箭头左边输入的部分 13 | const auto arrow_pos = equation.find("->"); 14 | const auto lhs = equation.substr(0, arrow_pos); 15 | // 获取输入操作数个数 16 | const auto num_ops = operands.size(); 17 | 18 | // 下面循环主要作用是解析 equation 左边输入部分, 19 | // 按 ',' 号分割得到每个输入张量对应的字符串, 20 | // 并把并把每个 char 字符转成 int, 范围 [0, 25] 21 | // 新建 vector 保存每个输入张量对应的字符数组 22 | std::vector> op_labels(num_ops); 23 | std::size_t curr_op = 0; 24 | for (auto i = decltype(lhs.length()){0}; i < lhs.length(); ++i) { 25 | switch (lhs[i]) { 26 | // ...... 27 | case ',': 28 | // 遇到逗号,接下来解析下一个输入张量的字符串 29 | ++curr_op; 30 | // ...... 31 | break; 32 | default: 33 | // ...... 34 | // 把 char 字符转成 int 35 | op_labels[curr_op].push_back(lhs[i] - 'a'); 36 | } 37 | } 38 | 39 | // TOTAL_LABELS = 26 40 | constexpr int TOTAL_LABELS = 'z' - 'a' + 1; 41 | std::vector label_count(TOTAL_LABELS, 0); 42 | // 遍历所有输入操作数 43 | // 统计 equation 中 'a' - 'z' 每个字符的出现次数 44 | for(const auto i : c10::irange(num_ops)) { 45 | const auto labels = op_labels[i]; 46 | for (const auto& label : labels) { 47 | // ...... 48 | ++label_count[label]; 49 | } 50 | // ...... 51 | } 52 | 53 | // 创建一个 vector 用于保存 equation 54 | // 箭头右边输出的字符到索引的映射 55 | std::vector label_perm_index(TOTAL_LABELS, -1); 56 | 57 | int64_t perm_index = 0; 58 | // ...... 59 | // 接下来解析输出字符串 60 | if (arrow_pos == std::string::npos) { 61 | // 处理用户省略了箭头的情况, 62 | // ...... 63 | } else { 64 | // 一般情况 65 | // 得到箭头右边的输出 66 | const auto rhs = equation.substr(arrow_pos + 2); 67 | // 遍历输出字符串并解析 68 | for (auto i = decltype(rhs.length()){0}; i < rhs.length(); ++i) { 69 | switch (rhs[i]) { 70 | // ...... 71 | default: 72 | // ...... 73 | const auto label = rhs[i] - 'a'; 74 | // ...... 75 | // 建立字符到索引的映射,perm_index从0开始 76 | label_perm_index[label] = perm_index++; 77 | } 78 | } 79 | } 80 | 81 | // 保存原始的输出维度大小 82 | const int64_t out_size = perm_index; 83 | // 对齐输出张量的维度,使得对齐之后的维度等于 84 | // 自由索引加上求和索引的个数 85 | // 对输出补全省略掉的求和索引 86 | // 也就是在输入等式中出现,但是没有在输出等式中出现的字符 87 | for (const auto label : c10::irange(TOTAL_LABELS)) { 88 | if (label_count[label] > 0 && label_perm_index[label] == -1) { 89 | label_perm_index[label] = perm_index++; 90 | } 91 | } 92 | 93 | // 对所有输入张量,同样补齐维度至与输出维度大小相同 94 | // 最后对输入做 permute 操作,使得输入张量的每一维 95 | // 与输出张量的每一维能对上 96 | std::vector permuted_operands; 97 | for (const auto i: c10::irange(num_ops)) { 98 | // 保存输入张量最终做 permute 时候的维度映射 99 | std::vector perm_shape(perm_index, -1); 100 | Tensor operand = operands[i]; 101 | // 取输入张量对应的 equation 102 | const auto labels = op_labels[i]; 103 | std::size_t j = 0; 104 | for (const auto& label : labels) { 105 | // ...... 106 | // 建立当前遍历到的输入张量字符到 107 | // 输出张量的字符到的映射 108 | // label: 当前遍历到的字符 109 | // label_perm_index: 保存了输出字符对应的索引 110 | // 所以 perm_shape 就是建立了输入张量的每一维度 111 | // 与输出张量维度的对应关系 112 | perm_shape[label_perm_index[label]] = j++; 113 | } 114 | // 如果输入张量的维度小于补全后的输出 115 | // 那么 perm_shape 中一定存在值为 -1 的元素 116 | // 那么相当于需要扩充输入张量的维度 117 | // 扩充的维度添加在张量的尾部 118 | for (int64_t& index : perm_shape) { 119 | if (index == -1) { 120 | // 在张量尾部插入维度1 121 | operand = operand.unsqueeze(-1); 122 | // 修改了perm_shape中的index, 123 | // 因为是引用取值 124 | index = j++; 125 | } 126 | } 127 | // 把输入张量的维度按照输出张量的维度重排,采用 permute 操作 128 | permuted_operands.push_back(operand.permute(perm_shape)); 129 | } 130 | // ...... 131 | Tensor result = permuted_operands[0]; 132 | // ..... 133 | // 计算最终结果 134 | for (const auto i: c10::irange(1, num_ops)) { 135 | Tensor operand = permuted_operands[i]; 136 | // 新建 vector 用于保存求和索引 137 | std::vector sum_dims; 138 | // ...... 139 | // 详细的代码可以阅读 Pytorch 源码 140 | // 这里我还没有完全理解 sumproduct_pair 的实现, 141 | // 里面用的是 permute + bmm, 142 | // 不过我觉得可以简单理解为 143 | // 将张量做广播乘法,再根据求和索引做累加 144 | result = sumproduct_pair(result, operand, sum_dims, false); 145 | } 146 | return result; 147 | } 148 | -------------------------------------------------------------------------------- /einsum_ex/ex10_outer_product.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(3) 5 | b = torch.arange(3,7) # -- a vector of length 4 containing [3, 4, 5, 6] 6 | # i = 3, j = 4 7 | torch_ein_out = torch.einsum('i,j->ij', [a, b]).numpy() 8 | torch_ein_out2 = torch.einsum('i,j', [a, b]).numpy() # equal form 9 | torch_org_out = torch.outer(a, b).numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((3, 4), dtype=np.int32) 15 | # outer loop for free indices 16 | for i in range(0, 3): 17 | for j in range(0, 4): 18 | # inner loop for multiplication and summing indices 19 | # for this example, there is no summing indices 20 | sum_result = 0 21 | for inner in range(0, 1): 22 | sum_result += np_a[i] * np_b[j] 23 | np_out[i, j] = sum_result 24 | 25 | print("vector a:\n", np_a) 26 | print("vector b:\n", np_b) 27 | print("torch ein out: \n", torch_ein_out) 28 | print("torch ein out2: \n", torch_ein_out2) 29 | print("torch org out: \n", torch_org_out) 30 | print("numpy out: \n", np_out) 31 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 32 | print("is torch_ein_out2 == torch_ein_out ?", np.allclose(torch_ein_out2, torch_ein_out)) 33 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 34 | 35 | 36 | # vector a: 37 | # [0 1 2] 38 | # vector b: 39 | # [3 4 5 6] 40 | # torch ein out: 41 | # [[ 0 0 0 0] 42 | # [ 3 4 5 6] 43 | # [ 6 8 10 12]] 44 | # torch ein out2: 45 | # [[ 0 0 0 0] 46 | # [ 3 4 5 6] 47 | # [ 6 8 10 12]] 48 | # torch org out: 49 | # [[ 0 0 0 0] 50 | # [ 3 4 5 6] 51 | # [ 6 8 10 12]] 52 | # numpy out: 53 | # [[ 0 0 0 0] 54 | # [ 3 4 5 6] 55 | # [ 6 8 10 12]] 56 | # is np_out == torch_ein_out ? True 57 | # is torch_ein_out2 == torch_ein_out ? True 58 | # is torch_org_out == torch_ein_out ? True 59 | -------------------------------------------------------------------------------- /einsum_ex/ex11_batch_matrix_multiply.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.randn(2,3,5) 5 | b = torch.randn(2,5,4) 6 | # i = 2, j = 3, k = 5, l = 4 7 | torch_ein_out = torch.einsum('ijk,ikl->ijl', [a, b]).numpy() 8 | torch_org_out = torch.bmm(a, b).numpy() 9 | 10 | np_a = a.numpy() 11 | np_b = b.numpy() 12 | # numpy implementation 13 | np_out = np.empty((2, 3, 4), dtype=np.float32) 14 | # outer loop for free indices 15 | for i in range(0, 2): 16 | for j in range(0, 3): 17 | for l in range(0, 4): 18 | # inner loop for multiplication and summing indices 19 | sum_result = 0 20 | for k in range(0, 5): 21 | sum_result += np_a[i, j, k] * np_b[i, k, l] 22 | np_out[i, j, l] = sum_result 23 | 24 | # print("matrix a:\n", np_a) 25 | # print("matrix b:\n", np_b) 26 | # print("torch ein out: \n", torch_ein_out) 27 | # print("torch org out: \n", torch_org_out) 28 | # print("numpy out: \n", np_out) 29 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 30 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_ein_out, torch_org_out)) 31 | 32 | # is np_out == torch_ein_out ? True 33 | # is torch_org_out == torch_ein_out ? True 34 | -------------------------------------------------------------------------------- /einsum_ex/ex12_tensor_contraction.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.randn(2,3,5,7) 5 | b = torch.randn(11,13,3,17,5) 6 | # p = 2, q = 3, r = 5, s = 7 7 | # t = 11, u = 13, v = 17, r = 5 8 | torch_ein_out = torch.einsum('pqrs,tuqvr->pstuv', [a, b]).numpy() 9 | torch_org_out = torch.tensordot(a, b, dims=([1, 2], [2, 4])).numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((2, 7, 11, 13, 17), dtype=np.float32) 15 | # outer loop for free indices 16 | for p in range(0, 2): 17 | for s in range(0, 7): 18 | for t in range(0, 11): 19 | for u in range(0, 13): 20 | for v in range(0, 17): 21 | 22 | # inner loop for multiplication and summing indices 23 | sum_result = 0 24 | for q in range(0, 3): 25 | for r in range(0, 5): 26 | sum_result += np_a[p, q, r, s] * np_b[t, u, q, v, r] 27 | np_out[p, s, t, u, v] = sum_result 28 | 29 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out, atol=1e-6)) 30 | print("is torch_ein_out == torch_org_out ?", np.allclose(torch_ein_out, torch_org_out, atol=1e-6)) 31 | 32 | # is np_out == torch_ein_out ? True 33 | # is torch_ein_out == torch_org_out ? True 34 | -------------------------------------------------------------------------------- /einsum_ex/ex13_bilinear_transformation.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.randn(2,3) 5 | b = torch.randn(5,3,7) 6 | c = torch.randn(2,7) 7 | # i = 2, k = 3, j = 5, l = 7 8 | torch_ein_out = torch.einsum('ik,jkl,il->ij', [a, b, c]).numpy() 9 | m = torch.nn.Bilinear(3, 7, 5, bias=False) 10 | m.weight.data = b 11 | torch_org_out = m(a, c).detach().numpy() 12 | 13 | np_a = a.numpy() 14 | np_b = b.numpy() 15 | np_c = c.numpy() 16 | # numpy implementation 17 | np_out = np.empty((2, 5), dtype=np.float32) 18 | # outer loop for free indices 19 | for i in range(0, 2): 20 | for j in range(0, 5): 21 | # inner loop for multiplication and summing indices 22 | sum_result = 0 23 | for k in range(0, 3): 24 | for l in range(0, 7): 25 | sum_result += np_a[i, k] * np_b[j, k, l] * np_c[i, l] 26 | np_out[i, j] = sum_result 27 | 28 | # print("matrix a:\n", np_a) 29 | # print("matrix b:\n", np_b) 30 | print("torch ein out: \n", torch_ein_out) 31 | print("torch org out: \n", torch_org_out) 32 | print("numpy out: \n", np_out) 33 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 34 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_ein_out, torch_org_out)) 35 | 36 | 37 | # torch ein out: 38 | # [[-2.9185116 0.17024004 -0.43915534 1.5860008 10.016678 ] 39 | # [-0.48688257 -3.5114982 -0.7543343 -0.46790922 1.4816089 ]] 40 | # torch org out: 41 | # [[-2.9185116 0.17024004 -0.43915534 1.5860008 10.016678 ] 42 | # [-0.48688257 -3.5114982 -0.7543343 -0.46790922 1.4816089 ]] 43 | # numpy out: 44 | # [[-2.9185114 0.17023998 -0.4391551 1.5860008 10.016678 ] 45 | # [-0.4868826 -3.5114982 -0.7543342 -0.4679092 1.4816089 ]] 46 | # is np_out == torch_ein_out ? True 47 | # is torch_org_out == torch_ein_out ? True 48 | -------------------------------------------------------------------------------- /einsum_ex/ex1_1_matrix_diagonal_extraction.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(9).reshape(3, 3) 5 | # i = 3 6 | torch_ein_out = torch.einsum('ii->i', [a]).numpy() 7 | torch_org_out = torch.diagonal(a, 0).numpy() 8 | 9 | np_a = a.numpy() 10 | # numpy implementation 11 | np_out = np.empty((3,), dtype=np.int32) 12 | # outer loop for free indices 13 | for i in range(0, 3): 14 | # inner loop for summing indices 15 | # for transpose example there is no inner sum loop 16 | sum_result = 0 17 | for inner in range(0, 1): 18 | sum_result += np_a[i, i] 19 | np_out[i] = sum_result 20 | 21 | print("input:\n", np_a) 22 | print("torch ein out: \n", torch_ein_out) 23 | print("torch org out: \n", torch_org_out) 24 | print("numpy out: \n", np_out) 25 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 26 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_ein_out, torch_org_out)) 27 | -------------------------------------------------------------------------------- /einsum_ex/ex1_2_transpose.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | # i = 2, j = 3 6 | torch_ein_out = torch.einsum('ij->ji', [a]).numpy() 7 | torch_org_out = torch.transpose(a, 0, 1).numpy() 8 | 9 | np_a = a.numpy() 10 | # numpy implementation 11 | np_out = np.empty((3, 2), dtype=np.int32) 12 | # outer loop for free indices 13 | for j in range(0, 3): 14 | for i in range(0, 2): 15 | # inner loop for summing indices 16 | # for transpose example there is no inner sum loop 17 | sum_result = 0 18 | for inner in range(0, 1): 19 | sum_result += np_a[i, j] 20 | np_out[j, i] = sum_result 21 | 22 | print("input:\n", np_a) 23 | print("torch ein out: \n", torch_ein_out) 24 | print("torch org out: \n", torch_org_out) 25 | print("numpy out: \n", np_out) 26 | print("is np_out == torch_org_out ?", np.allclose(torch_ein_out, np_out)) 27 | print("is torch_ein_out == torch_org_out ?", np.allclose(torch_ein_out, torch_org_out)) 28 | 29 | # input: 30 | # [[0 1 2] 31 | # [3 4 5]] 32 | # torch ein out: 33 | # [[0 3] 34 | # [1 4] 35 | # [2 5]] 36 | # torch org out: 37 | # [[0 3] 38 | # [1 4] 39 | # [2 5]] 40 | # numpy out: 41 | # [[0 3] 42 | # [1 4] 43 | # [2 5]] 44 | # is np_out == torch_org_out ? True 45 | # is torch_ein_out == torch_org_out ? True 46 | -------------------------------------------------------------------------------- /einsum_ex/ex1_3_permute.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.randn(2,3,5,7,9) 5 | # i = 7, j = 9 6 | torch_ein_out = torch.einsum('...ij->...ji', [a]).numpy() 7 | torch_org_out = a.permute(0, 1, 2, 4, 3).numpy() 8 | 9 | np_a = a.numpy() 10 | # numpy implementation 11 | np_out = np.empty((2,3,5,9,7), dtype=np.float32) 12 | # outer loop for free indices 13 | for j in range(0, 9): 14 | for i in range(0, 7): 15 | # inner loop for summing indices 16 | # for this example there is no inner sum loop 17 | sum_result = 0 18 | for inner in range(0, 1): 19 | sum_result += np_a[..., i, j] 20 | np_out[..., j, i] = sum_result 21 | 22 | print("is np_out == torch_org_out ?", np.allclose(torch_ein_out, np_out)) 23 | print("is torch_ein_out == torch_org_out ?", np.allclose(torch_ein_out, torch_org_out)) 24 | 25 | # is np_out == torch_org_out ? True 26 | # is torch_ein_out == torch_org_out ? True 27 | -------------------------------------------------------------------------------- /einsum_ex/ex2_reduce_sum.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | # i = 2, j = 3 6 | torch_ein_out = torch.einsum('ij->', [a]).numpy() 7 | torch_org_out = torch.sum(a).numpy() 8 | 9 | np_a = a.numpy() 10 | # numpy implementation 11 | np_out = np.empty((1, ), dtype=np.int32) 12 | # outer loop for free indices 13 | for o in range(0 ,1): 14 | # inner loop for summing indices 15 | sum_result = 0 16 | for i in range(0, 2): 17 | for j in range(0, 3): 18 | sum_result += np_a[i, j] 19 | np_out[o] = sum_result 20 | 21 | print("input:\n", np_a) 22 | print("torch ein out: \n", torch_ein_out) 23 | print("torch org out: \n", torch_org_out) 24 | print("numpy out: \n", np_out) 25 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 26 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_ein_out, torch_org_out)) 27 | 28 | # input: 29 | # [[0 1 2] 30 | # [3 4 5]] 31 | # torch ein out: 32 | # 15 33 | # torch org out: 34 | # 15 35 | # numpy out: 36 | # [15] 37 | # is np_out == torch_ein_out ? True 38 | # is torch_org_out == torch_ein_out ? True 39 | -------------------------------------------------------------------------------- /einsum_ex/ex3_column_sum.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | # i = 2, j = 3 6 | torch_ein_out = torch.einsum('ij->j', [a]).numpy() 7 | torch_org_out = torch.sum(a, dim=0).numpy() 8 | 9 | np_a = a.numpy() 10 | # numpy implementation 11 | np_out = np.empty((3, ), dtype=np.int32) 12 | # outer loop for free indices 13 | for j in range(0, 3): 14 | # inner loop for summing indices 15 | sum_result = 0 16 | for i in range(0, 2): 17 | sum_result += np_a[i, j] 18 | np_out[j] = sum_result 19 | 20 | print("input:\n", np_a) 21 | print("torch ein out: \n", torch_ein_out) 22 | print("torch org out: \n", torch_org_out) 23 | print("numpy out: \n", np_out) 24 | print("is np_out == torch_ein_out ?", np.allclose(torch_org_out, np_out)) 25 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 26 | 27 | # input: 28 | # [[0 1 2] 29 | # [3 4 5]] 30 | # torch ein out: 31 | # [3 5 7] 32 | # torch org out: 33 | # [3 5 7] 34 | # numpy out: 35 | # [3 5 7] 36 | # is np_out == torch_ein_out ? True 37 | # is torch_org_out == torch_ein_out ? True 38 | -------------------------------------------------------------------------------- /einsum_ex/ex5_matrix_vector_mul.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | b = torch.arange(3) 6 | # i = 2, k = 3 7 | torch_ein_out = torch.einsum('ik,k->i', [a, b]).numpy() 8 | torch_ein_out2 = torch.einsum('ik,k', [a, b]).numpy() # equal form 9 | torch_org_out = torch.mv(a, b).numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((2, ), dtype=np.int32) 15 | # outer loop for free indices 16 | for i in range(0, 2): 17 | # inner loop for multiplication and summing indices 18 | sum_result = 0 19 | for k in range(0, 3): 20 | sum_result += np_a[i, k] * np_b[k] 21 | np_out[i] = sum_result 22 | 23 | print("matrix a:\n", np_a) 24 | print("vector b:\n", np_b) 25 | print("torch ein out: \n", torch_ein_out) 26 | print("torch ein out2: \n", torch_ein_out2) 27 | print("torch org out: \n", torch_org_out) 28 | print("numpy out: \n", np_out) 29 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 30 | print("is torch_ein_out2 == torch_ein_out ?", np.allclose(torch_ein_out2, torch_ein_out)) 31 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 32 | 33 | # matrix a: 34 | # [[0 1 2] 35 | # [3 4 5]] 36 | # vector b: 37 | # [0 1 2] 38 | # torch ein out: 39 | # [ 5 14] 40 | # torch ein out2: 41 | # [ 5 14] 42 | # torch org out: 43 | # [ 5 14] 44 | # numpy out: 45 | # [ 5 14] 46 | # is np_out == torch_ein_out ? True 47 | # is torch_ein_out2 == torch_ein_out ? True 48 | # is torch_org_out == torch_ein_out ? True 49 | -------------------------------------------------------------------------------- /einsum_ex/ex6_matrix_matrix_mul.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | b = torch.arange(15).reshape(3, 5) 6 | # i = 2, k = 3, j = 5 7 | torch_ein_out = torch.einsum('ik,kj->ij', [a, b]).numpy() 8 | torch_ein_out2 = torch.einsum('ik,kj', [a, b]).numpy() # equal form 9 | torch_org_out = torch.mm(a, b).numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((2, 5), dtype=np.int32) 15 | # outer loop for free indices 16 | for i in range(0, 2): 17 | for j in range(0, 5): 18 | # inner loop for multiplication and summing indices 19 | sum_result = 0 20 | for k in range(0, 3): 21 | sum_result += np_a[i, k] * np_b[k, j] 22 | np_out[i, j] = sum_result 23 | 24 | print("matrix a:\n", np_a) 25 | print("matrix b:\n", np_b) 26 | print("torch ein out: \n", torch_ein_out) 27 | print("torch ein out2: \n", torch_ein_out2) 28 | print("torch org out: \n", torch_org_out) 29 | print("numpy out: \n", np_out) 30 | print("is numpy == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 31 | print("is torch_ein_out2 == torch_ein_out ?", np.allclose(torch_ein_out2, torch_ein_out)) 32 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 33 | 34 | # matrix a: 35 | # [[0 1 2] 36 | # [3 4 5]] 37 | # matrix b: 38 | # [[ 0 1 2 3 4] 39 | # [ 5 6 7 8 9] 40 | # [10 11 12 13 14]] 41 | # torch ein out: 42 | # [[ 25 28 31 34 37] 43 | # [ 70 82 94 106 118]] 44 | # torch ein out2: 45 | # [[ 25 28 31 34 37] 46 | # [ 70 82 94 106 118]] 47 | # torch org out: 48 | # [[ 25 28 31 34 37] 49 | # [ 70 82 94 106 118]] 50 | # numpy out: 51 | # [[ 25 28 31 34 37] 52 | # [ 70 82 94 106 118]] 53 | # is numpy == torch_ein_out ? True 54 | # is torch_ein_out2 == torch_ein_out ? True 55 | # is torch_org_out == torch_ein_out ? True 56 | -------------------------------------------------------------------------------- /einsum_ex/ex7_vector_dot_product.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(3) 5 | b = torch.arange(3, 6) # vector of length 3 containing [3, 4, 5] 6 | # i = 3 7 | torch_ein_out = torch.einsum('i,i->', [a, b]).numpy() 8 | torch_ein_out2 = torch.einsum('i,i', [a, b]).numpy() # equal form 9 | torch_org_out = torch.dot(a, b).numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((1, ), dtype=np.int32) 15 | # outer loop for free indices 16 | # for this example, there is no free indices 17 | for o in range(0, 1): 18 | # inner loop for multiplication and summing indices 19 | sum_result = 0 20 | for i in range(0, 3): 21 | sum_result += np_a[i] * np_b[i] 22 | np_out[o] = sum_result 23 | 24 | print("vector a:\n", np_a) 25 | print("vector b:\n", np_b) 26 | print("torch ein out: \n", torch_ein_out) 27 | print("torch ein out2: \n", torch_ein_out2) 28 | print("torch org out: \n", torch_org_out) 29 | print("numpy out: \n", np_out) 30 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 31 | print("is torch_ein_out2 == torch_ein_out ?", np.allclose(torch_ein_out2, torch_ein_out)) 32 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 33 | 34 | # vector a: 35 | # [0 1 2] 36 | # vector b: 37 | # [3 4 5] 38 | # torch ein out: 39 | # 14 40 | # torch ein out2: 41 | # 14 42 | # torch org out: 43 | # 14 44 | # numpy out: 45 | # [14] 46 | # is np_out == torch_ein_out ? True 47 | # is torch_ein_out2 == torch_ein_out ? True 48 | # is torch_org_out == torch_ein_out ? True 49 | -------------------------------------------------------------------------------- /einsum_ex/ex8_hadamard_product_and_sum.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | a = torch.arange(6).reshape(2, 3) 5 | b = torch.arange(6,12).reshape(2, 3) 6 | # i = 2, j = 3 7 | torch_ein_out = torch.einsum('ij,ij->', [a, b]).numpy() 8 | torch_ein_out2 = torch.einsum('ij,ij', [a, b]).numpy() # equal form 9 | torch_org_out = (a * b).sum().numpy() 10 | 11 | np_a = a.numpy() 12 | np_b = b.numpy() 13 | # numpy implementation 14 | np_out = np.empty((1, ), dtype=np.int32) 15 | # outer loop for free indices 16 | # for this example, there is no free indices 17 | for o in range(0, 1): 18 | # inner loop for multiplication and summing indices 19 | sum_result = 0 20 | for i in range(0, 2): 21 | for j in range(0, 3): 22 | sum_result += np_a[i,j] * np_b[i,j] 23 | np_out[o] = sum_result 24 | 25 | print("matrix a:\n", np_a) 26 | print("matrix b:\n", np_b) 27 | print("torch ein out: \n", torch_ein_out) 28 | print("torch ein out2: \n", torch_ein_out2) 29 | print("torch org out: \n", torch_org_out) 30 | print("numpy out: \n", np_out) 31 | print("is np_out == torch_ein_out ?", np.allclose(torch_ein_out, np_out)) 32 | print("is torch_ein_out2 == torch_ein_out ?", np.allclose(torch_ein_out2, torch_ein_out)) 33 | print("is torch_org_out == torch_ein_out ?", np.allclose(torch_org_out, torch_ein_out)) 34 | 35 | # matrix a: 36 | # [[0 1 2] 37 | # [3 4 5]] 38 | # matrix b: 39 | # [[ 6 7 8] 40 | # [ 9 10 11]] 41 | # torch ein out: 42 | # 145 43 | # torch ein out2: 44 | # 145 45 | # torch org out: 46 | # 145 47 | # numpy out: 48 | # [145] 49 | # is np_out == torch_ein_out ? True 50 | # is torch_ein_out2 == torch_ein_out ? True 51 | # is torch_org_out == torch_ein_out ? True 52 | -------------------------------------------------------------------------------- /在代码中写WTF/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/在代码中写WTF/README.md -------------------------------------------------------------------------------- /在代码中写WTF/fk.scala: -------------------------------------------------------------------------------- 1 | object What{ 2 | def The(fuck: Any) = Fuck 3 | } 4 | object Fuck { 5 | def !!() = println(s"debug message !!") 6 | def !!!(s: String) = println(s) 7 | } 8 | 9 | What The Fuck !! //这里要最好有个回车,不然可能编译出错 10 | 11 | What The Fuck !!! "debug message !!" 12 | -------------------------------------------------------------------------------- /并行求解n皇后问题/N-Queens-Parallel.scala: -------------------------------------------------------------------------------- 1 | import akka.actor.{Props, ActorRef, Actor, ActorSystem} 2 | import admin._ 3 | 4 | object Pallelnqueens { 5 | 6 | def main(args: Array[String]): Unit = { 7 | val system = ActorSystem("parallelnqueens") 8 | system.actorOf(Props[admin]) ! Start(12) 9 | } 10 | 11 | } 12 | 13 | class admin extends Actor { 14 | import akka.actor.ReceiveTimeout 15 | import scala.concurrent.duration._ 16 | 17 | context.setReceiveTimeout(10 seconds) 18 | 19 | var sum = 0 20 | 21 | def receive = { 22 | case Start(n) => 23 | //n皇后n个actor 24 | for(i <- 0 until n) 25 | context.actorOf(Props[worker], name = s"worker$i") ! Mission(n, List(i)) 26 | case Result(result) => 27 | sum += result.size 28 | println((result map show) mkString "\n") 29 | case ReceiveTimeout => 30 | println(s"sum: $sum") 31 | context.system.shutdown 32 | } 33 | 34 | //把List对应的一个解转换成String表示形式 35 | def show(queens: List[Int]) = { 36 | val lines = 37 | for ( col <- queens.reverse ) 38 | yield Vector.fill(queens.length)("* ").updated(col, "^ ").mkString 39 | s"\n${lines mkString "\n"}" 40 | } 41 | 42 | } 43 | 44 | object admin { 45 | case class Start(n: Int) 46 | case class Result(result: Set[List[Int]]) 47 | case class Mission(n: Int, searchList: List[Int]) 48 | } 49 | 50 | class worker extends Actor { 51 | 52 | def receive = { 53 | case Mission(n, searchList) => 54 | def placeQueens(k: Int): Set[List[Int]] = { 55 | if( k == 1 ) Set(searchList) 56 | else 57 | for{ 58 | queens <- placeQueens(k - 1) 59 | col <- 0 until n 60 | if isSafe(col, queens) 61 | } yield col :: queens 62 | } 63 | context.parent ! Result(placeQueens(n)) 64 | } 65 | 66 | //判断在col该位置能否放一个皇后 67 | def isSafe(col: Int, queens: List[Int]) = { 68 | val row = queens.length 69 | //将每一行和对应的皇后的位置放在一个原组中 70 | val queensWithRow = (row - 1 to 0 by -1) zip queens 71 | queensWithRow forall { 72 | //col不能和存在的列重合,还有行差和列差不能相等,防止对角线重合 73 | case (r,c) => col != c && math.abs(col - c) != row - r 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /并行求解n皇后问题/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/并行求解n皇后问题/README.md -------------------------------------------------------------------------------- /抓取开源中国的资讯页面的新闻列表/27204708_LYLK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/抓取开源中国的资讯页面的新闻列表/27204708_LYLK.png -------------------------------------------------------------------------------- /抓取开源中国的资讯页面的新闻列表/README.md: -------------------------------------------------------------------------------- 1 | 简单的抓取开源中国的新闻,得到新闻标题加网址的列表,可以快速浏览当日新闻或者发微博也可以。 2 | 3 | ###截图 4 | 5 | -------------------------------------------------------------------------------- /抓取开源中国的资讯页面的新闻列表/pachong.scala: -------------------------------------------------------------------------------- 1 | import scala.io.Source 2 | import scala.util.matching.Regex 3 | import scala.io._ 4 | import java.net._ 5 | import java.io._ 6 | 7 | 8 | object OsChinaPaChong { 9 | 10 | //有了这个隐式转换就可以写出 "" | console 类似linux命令 11 | implicit class MyString(val s: String) extends AnyVal{ 12 | def |(f: String => Unit) = f(s) 13 | } 14 | def console(msg: String) = println(msg) 15 | 16 | //用到的正则表达式 17 | val pattern_href = """href\s*=\s*["]?(.+?)["]""".r 18 | val pattern_h2 = """

(.*?)

""".r 19 | val pattern_text = """>(.*?)<""".r 20 | val pattern_href2 = """["](.+?)["]""".r 21 | 22 | val fileprefix = "/home/hadoop/scala/MicroBlog/" 23 | 24 | def main(args: Array[String]): Unit = { 25 | downloadOsChina | console 26 | } 27 | 28 | def downloadOsChina = { 29 | val filepath = downloadPage("http://www.oschina.net/news", 30 | "oschina.txt") 31 | //读取下载好的内容 32 | val lines = Source.fromFile(filepath).mkString 33 | //找出符合pattern_h2的内容 34 | val te = ( pattern_h2 findAllIn lines ) mkString(",") split(",") 35 | //遍历te数组获取新闻列表 36 | ("" /: te)((acc, elem) => { 37 | val h2_url = ( pattern_href findAllIn elem ) mkString(",") split(",") 38 | var CH = getChinese(elem) 39 | var url = getUrl(h2_url(0)) 40 | if(!url.startsWith("http://www.oschina.net")) 41 | url = s"http://www.oschina.net$url" 42 | s"$acc$CH: $url\n\n" 43 | }) 44 | } 45 | 46 | //获取herf中的网址 47 | def getUrl(url: String) = { 48 | var temp = ( pattern_href2 findAllIn url ) mkString; 49 | if(temp.length > 2) 50 | temp substring(1, temp.length() - 1) 51 | else "" 52 | } 53 | 54 | //获取中文内容 55 | def getChinese(origin: String) = { 56 | var temp = ( pattern_text findAllIn origin ) mkString(",") split(",") filter(_.length > 5) 57 | temp(0).substring(1, temp(0).length - 1) 58 | } 59 | 60 | 61 | //根据url下载网页,并保存在文件file中 62 | def downloadPage(urls: String, filename: String) = { 63 | 64 | val localfile = s"$fileprefix/$filename" 65 | val url = new URL(urls) 66 | val connection = 67 | url.openConnection().asInstanceOf[HttpURLConnection] 68 | connection.setRequestMethod("GET") 69 | connection.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0"); 70 | if(connection.getResponseCode == 200) { 71 | val out = new java.io.FileWriter(new File(localfile)) 72 | val in = Source.fromInputStream(connection.getInputStream) 73 | in.getLines.foreach(out.write(_)) 74 | localfile 75 | }else{ 76 | "" 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /算法-----烙饼排序/29161759_GCMH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/算法-----烙饼排序/29161759_GCMH.png -------------------------------------------------------------------------------- /算法-----烙饼排序/README.md: -------------------------------------------------------------------------------- 1 | #用scala实现的类型通用的烙饼排序算法。 2 | 3 | ##烙饼排序问题描述: 4 | 把一摞大小不一的烙饼按顺序排好,大的在下面,小的在上面,要求只能用一只手去翻转烙饼位置,另一只手要端盘子,要求输出最优化的排序过程。 5 | 6 | ##示例: 7 | 3 1 2 8 | 9 | 翻转 1 , 当前烙饼排序 3 2 1 10 | 11 | 完成 12 | 13 | ##解题思想: 14 | 15 | 每次都先找出未排序烙饼中最大的烙饼,然后将其翻转到最上面。然后将它翻转到已排序烙饼的最上层,接着换下一块,如此就可完成排序。 16 | 17 | ##截图 18 | 19 | 20 | -------------------------------------------------------------------------------- /算法-----烙饼排序/laobin.scala: -------------------------------------------------------------------------------- 1 | import scala.reflect.ClassTag 2 | 3 | object sortLaobin { 4 | 5 | def printLaobin[T](strs: String, array: Array[T]) = { 6 | val astr = ("<" /: array){(acc, elem) => s"$acc ${elem.toString}"} 7 | println(s"$strs $astr >") 8 | } 9 | 10 | def sortLaobins[T](array: Array[T])(implicit ordering: Ordering[T], c: ClassTag[T]) = { 11 | var tmp = array 12 | 13 | printLaobin("start: ", tmp) 14 | 15 | var current = 0 16 | val size = array.length 17 | 18 | while(current < size - 1){ 19 | //获取从current开始的最大元素和对应的索引 20 | val (max, max_index) = ((tmp(current), current) /: tmp.drop(current + 1).zip((0 until size).drop(current + 1))){(acc, elem) => 21 | if(ordering.gt(acc._1, elem._1)) acc else elem 22 | } 23 | if(!ordering.equiv(tmp(current), max)){ //若最大的元素就是current所指向的位置则直接进入 24 | if(!ordering.equiv(tmp(size - 1), max)){ //若最大元素在数组末尾则直接翻转current直到数组末尾的元素 25 | println(s" reverse $max to ${tmp(size - 1)}") 26 | tmp = Array.concat(tmp.take(max_index), tmp.drop(max_index).reverse) 27 | } 28 | println(s" reverse ${tmp(current)} to ${tmp(size - 1)}") 29 | tmp = Array.concat(tmp.take(current), tmp.drop(current).reverse) 30 | printLaobin(s" step $current done: ", tmp) 31 | } 32 | current += 1 33 | } 34 | printLaobin("done: ", tmp) 35 | 36 | } 37 | 38 | def main(args: Array[String]) = { 39 | 40 | println("\nexample one : ") 41 | val array1 = Array(3.0, 1.0, 2.0) 42 | sortLaobins(array1) 43 | 44 | println("\nexample two : ") 45 | val array2 = Array(4, 7, 5, 9, 8, 6, 1, 2, 3) 46 | sortLaobins(array2) 47 | 48 | println("\nexample three: ") 49 | val array3 = Array("a", "z", "v", "f", "g", "e", "q", "c", "p") 50 | sortLaobins(array3) 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /类型通用的归并排序/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ldpe2G/CodingForFun/b70bece081c786bc1cc2f9fae8a52a3b7d16b47c/类型通用的归并排序/README.md -------------------------------------------------------------------------------- /类型通用的归并排序/mergeSort.scala: -------------------------------------------------------------------------------- 1 | def msort[T](list: List[T])(fn: (T, T) => Boolean): List[T] = { 2 | //辅助函数,合并两个有序List 3 | def merge(xs: List[T], ys: List[T]): List[T] = (xs, ys) match { 4 | case (Nil, ys) => ys 5 | case (xs, Nil) => xs 6 | case (x :: xs1, y :: ys1) => 7 | if(fn(x, y)) x :: merge(xs1, ys) 8 | else y :: merge(xs, ys1) 9 | } 10 | 11 | val n = list.length / 2 12 | if(n == 0) list 13 | else{ 14 | val (f, s) = list splitAt n 15 | merge(msort(f)(fn), msort(s)(fn)) 16 | } 17 | } 18 | 19 | val list1 = List(2, -4, 5, 7, 1) 20 | val list2 = List("ldp", "fake", "you", "harmonious", "jiong") 21 | println( msort(list1){ (x: Int, y: Int) => x < y } ) 22 | println( msort(list2){ (x: String, y: String) => x.compareTo(y) < 0 }) 23 | -------------------------------------------------------------------------------- /遗传算法计算一元函数极值/README.md: -------------------------------------------------------------------------------- 1 | #用遗传算法计算一元函数的极值,示例函数: 2 | 3 | 4 | 1、(x - 512) * (x - 512) - 10, 极值为 -10; 5 | 6 | 2、(x - 512) * (x - 256) - 10, 极值为 -16394。 7 | 8 | 已经测试通过。 9 | 10 | 定义域为[0, 1024],用二进制表示自变量来模拟基因序列 11 | -------------------------------------------------------------------------------- /遗传算法计算一元函数极值/yichuanSuanfa.scala: -------------------------------------------------------------------------------- 1 | object YiChuan { 2 | 3 | //基因长度 4 | val length = 10 5 | 6 | //迭代次数,最大子代数 7 | val MAX_GENERATION = 600 8 | 9 | //种群大小 10 | val POPULATION_SIZE = 20 11 | 12 | //变异概率 13 | val MUTATION_RATE = 0.01 14 | 15 | /** 16 | * 染色体 17 | * sequence 基因序列,表示一个整数的二进制形式,从最小位开始写 18 | * 比如10的二进制是 00 0000 1010,十位, 19 | * 则sequence表示为 0101 0000 00 20 | * fitness 适应度值 21 | */ 22 | case class Chromosome(sequence: Array[Int], var fitness: Double) 23 | 24 | /** 25 | * 适应度函数,计算 (x-512)*(x-512)-10 的值 26 | */ 27 | def CalFitnessOne(sequence: Array[Int]) = { 28 | //将二进制转为十进制 29 | val x = (0.0 /: (0 until sequence.length)){ 30 | (acc, elem) => acc + sequence(elem) * Math.pow(2.0, elem) 31 | } 32 | //代入函数得出适应度值 33 | (x - 512) * (x - 512) - 10; 34 | } 35 | 36 | /** 37 | * 适应度函数2,计算 (x-512)*(x-256)-10 的值 38 | */ 39 | def CalFitnessTwo(sequence: Array[Int]) = { 40 | //将二进制转为十进制 41 | val x = (0.0 /: (0 until sequence.length)){ 42 | (acc, elem) => acc + sequence(elem) * Math.pow(2.0, elem) 43 | } 44 | //代入函数得出适应度值 45 | (x - 512) * (x - 256) - 10; 46 | } 47 | 48 | import scala.collection.mutable.PriorityQueue 49 | //优先级队列中元素比较的implicit ordering 50 | implicit object ChromosomeOrd extends Ordering[Chromosome] { 51 | def compare(x: Chromosome, y: Chromosome) = y.fitness.compare(x.fitness) 52 | } 53 | 54 | import java.util.Random 55 | val random = new Random 56 | 57 | /** 58 | * 初始化种群 59 | */ 60 | def initPopulation(calFitness: Array[Int] => Double) = { 61 | val population = new PriorityQueue[Chromosome] 62 | for(i <- 0 until POPULATION_SIZE) { 63 | val sequence = Array.fill(length)(0).map(x => x ^ random.nextInt(2)) 64 | population += Chromosome(sequence, calFitness(sequence)) 65 | } 66 | population 67 | } 68 | 69 | /** 70 | * 简单的选择操作,保留优先级队列中前一半的基因 71 | */ 72 | def selectChromosome(population: PriorityQueue[Chromosome]) = { 73 | val minList = (for(i <- 0 until POPULATION_SIZE / 2) 74 | yield population dequeue).toList 75 | (new PriorityQueue[Chromosome] /: minList){ 76 | (acc, elem) => acc += elem 77 | } 78 | } 79 | 80 | /** 81 | * 交叉变异操作 82 | */ 83 | def CrossOver_Mutation(population: PriorityQueue[Chromosome], 84 | calFitness: Array[Int] => Double) = { 85 | //随机获取配偶的位置 86 | //po1为当前染色体的位置 87 | def getSpouse(po1: Int, population_size: Int): Int = { 88 | val spouse = random nextInt population_size 89 | if(spouse == po1) getSpouse(po1, population_size) 90 | else spouse 91 | } 92 | 93 | val populaSize = POPULATION_SIZE / 2 94 | val poList = population.toList 95 | val tempQueue = new PriorityQueue[Chromosome] 96 | for(i <- 0 until populaSize){ 97 | val (seq1, seq2) = CrossOver(poList(i), 98 | poList(getSpouse(i, populaSize)), 99 | calFitness) 100 | tempQueue += seq1 101 | tempQueue += seq2 102 | } 103 | tempQueue map (Mutation(_, calFitness)) 104 | } 105 | 106 | /** 107 | * 交叉两个染色体,产生两个子代 108 | */ 109 | def CrossOver(chromOne: Chromosome, chromTwo: Chromosome, 110 | calFitness: Array[Int] => Double) = { 111 | val position = random nextInt length - 1 112 | val seqOne = 113 | chromOne.sequence.take(position + 1) ++ 114 | chromTwo.sequence.takeRight(length - position) 115 | 116 | val seqTwo = 117 | chromTwo.sequence.take(position) ++ 118 | chromOne.sequence.takeRight(length - position) 119 | 120 | (Chromosome(seqOne, calFitness(seqOne)), 121 | Chromosome(seqTwo, calFitness(seqTwo))) 122 | } 123 | 124 | /** 125 | * 染色体变异 126 | */ 127 | def Mutation(chrom: Chromosome, 128 | calFitness: Array[Int] => Double) = 129 | //首先满足变异概率 130 | if(random.nextDouble > MUTATION_RATE){ 131 | var seq = chrom.sequence 132 | val po = random nextInt length 133 | seq(po) = seq(po) ^ 1 134 | //若变异后适应值比原来大则不变异 135 | if(calFitness(seq) > calFitness(chrom.sequence)) 136 | seq = chrom.sequence 137 | Chromosome(seq, calFitness(seq)) 138 | } else chrom 139 | 140 | 141 | def main(args: Array[String]): Unit = { 142 | var population = initPopulation(CalFitnessTwo) 143 | //var population = initPopulation(CalFitnessOne) 144 | var smallest = population.max.fitness 145 | var temp = 0.0 146 | for(i <- 0 until MAX_GENERATION){ 147 | population = selectChromosome(population) 148 | //population = CrossOver_Mutation(population, CalFitnessOne) 149 | population = CrossOver_Mutation(population, CalFitnessTwo) 150 | temp = population.max.fitness 151 | if(temp < smallest) smallest = temp 152 | } 153 | println(s"函数极值为 $smallest") 154 | } 155 | 156 | } 157 | --------------------------------------------------------------------------------