├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── empty.png
│ │ │ │ ├── red.png
│ │ │ │ ├── yellow.png
│ │ │ │ ├── board_bg.png
│ │ │ │ ├── cell_frame.png
│ │ │ │ ├── chess_icon.png
│ │ │ │ ├── chess_wall.jpg
│ │ │ │ ├── connect4_icon.png
│ │ │ │ ├── chess_background.jpg
│ │ │ │ ├── chess_black_king.png
│ │ │ │ ├── chess_black_pawn.png
│ │ │ │ ├── chess_black_queen.png
│ │ │ │ ├── chess_black_rook.png
│ │ │ │ ├── chess_white_king.png
│ │ │ │ ├── chess_white_pawn.png
│ │ │ │ ├── chess_white_queen.png
│ │ │ │ ├── chess_white_rook.png
│ │ │ │ ├── chess_black_bishop.png
│ │ │ │ ├── chess_black_knight.png
│ │ │ │ ├── chess_white_bishop.png
│ │ │ │ ├── chess_white_knight.png
│ │ │ │ ├── gravity_balls_ball.png
│ │ │ │ ├── gravity_balls_icon.png
│ │ │ │ ├── snake_and_ladder_board.jpg
│ │ │ │ ├── snake_and_ladder_dice.png
│ │ │ │ ├── snake_and_ladder_icon.png
│ │ │ │ ├── snake_and_ladder_image.png
│ │ │ │ ├── snake_and_ladder_wall.jpg
│ │ │ │ ├── gravity_balls_background.jpg
│ │ │ │ ├── snake_and_ladder_player1.png
│ │ │ │ ├── snake_and_ladder_player2.png
│ │ │ │ ├── snake_and_ladder_players.png
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── anim
│ │ │ │ └── falling.xml
│ │ │ ├── menu
│ │ │ │ └── game.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_snake_and_ladder_last_page.xml
│ │ │ │ ├── activity_snake_and_ladder_main.xml
│ │ │ │ ├── board_row.xml
│ │ │ │ ├── front_board_row.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_main_connect4.xml
│ │ │ │ ├── activity_snake_and_ladder_board.xml
│ │ │ │ └── activity_chess_main.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── dipansh
│ │ │ │ └── asobimasu
│ │ │ │ ├── connect4
│ │ │ │ ├── Cell.java
│ │ │ │ ├── Board.java
│ │ │ │ └── MainActivityConnect4.java
│ │ │ │ ├── chess
│ │ │ │ ├── pieces
│ │ │ │ │ ├── Movable.java
│ │ │ │ │ ├── Piece.java
│ │ │ │ │ ├── Rook.java
│ │ │ │ │ ├── Bishop.java
│ │ │ │ │ ├── Pawn.java
│ │ │ │ │ ├── King.java
│ │ │ │ │ ├── Knight.java
│ │ │ │ │ └── Queen.java
│ │ │ │ └── data
│ │ │ │ │ ├── Position.java
│ │ │ │ │ └── Coordinates.java
│ │ │ │ ├── snakeAndLadder
│ │ │ │ ├── SnakeAndLadderLastPage.java
│ │ │ │ ├── Block.java
│ │ │ │ ├── Players.java
│ │ │ │ ├── SnakeAndLadderMainActivity.java
│ │ │ │ ├── Board.java
│ │ │ │ ├── GamePlay.java
│ │ │ │ └── SnakeAndLadderBoard.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── gravityBalls
│ │ │ │ └── GravityBallsMainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── dipansh
│ │ │ └── asobimasu
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── dipansh
│ │ └── asobimasu
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshots
├── Chess.png
├── gravityballs_1.png
├── gravityballs_2.png
└── connect4_screenshot.jpeg
├── .idea
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── .travis.yml
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshots/Chess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/screenshots/Chess.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/screenshots/gravityballs_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/screenshots/gravityballs_1.png
--------------------------------------------------------------------------------
/screenshots/gravityballs_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/screenshots/gravityballs_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/empty.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/red.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/yellow.png
--------------------------------------------------------------------------------
/screenshots/connect4_screenshot.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/screenshots/connect4_screenshot.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/board_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/board_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cell_frame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/cell_frame.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_wall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_wall.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/connect4_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/connect4_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_background.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_king.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_king.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_pawn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_pawn.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_queen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_queen.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_rook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_rook.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_king.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_king.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_pawn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_pawn.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_queen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_queen.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_rook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_rook.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_bishop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_bishop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_black_knight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_black_knight.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_bishop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_bishop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/chess_white_knight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/chess_white_knight.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gravity_balls_ball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/gravity_balls_ball.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gravity_balls_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/gravity_balls_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_board.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_board.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_dice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_dice.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_image.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_wall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_wall.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gravity_balls_background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/gravity_balls_background.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_player1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_player1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_player2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_player2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snake_and_ladder_players.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/drawable/snake_and_ladder_players.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DipanshKhandelwal/Asobimasu/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | language: android
3 | android:
4 | components:
5 | - platform-tools
6 | - tools
7 | - build-tools-26.0.2
8 | - android-26
9 | before_script:
10 | - chmod +x gradlew
11 | script:
12 | - ./gradlew assembleDebug
13 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Dec 01 10:05:14 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/falling.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/game.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/connect4/Cell.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.connect4;
2 |
3 | /**
4 | * Created by rachana on 12/12/2017.
5 | */
6 |
7 | public class Cell {
8 | public boolean empty;
9 | public Board.Turn player;
10 |
11 | public Cell() {
12 | empty = true;
13 | }
14 |
15 | public void setPlayer(Board.Turn player) {
16 | this.player = player;
17 | empty = false;
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Movable.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import java.util.ArrayList;
4 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
5 | import com.example.dipansh.asobimasu.chess.data.Position;
6 |
7 | /**
8 | * Created by dipansh on 1/12/17.
9 | */
10 |
11 | public interface Movable {
12 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/dipansh/asobimasu/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Asobimasu
3 |
4 |
5 | UNDO
6 | Queen
7 | Bishop
8 | Rook
9 | Knight
10 | Game Over !!
11 |
12 |
13 |
14 | Settings
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/data/Position.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.data;
2 |
3 | import com.example.dipansh.asobimasu.chess.pieces.Piece;
4 |
5 | /**
6 | * Created by DIPANSH KHANDELWAL on 03-06-2017
7 | */
8 |
9 | public class Position {
10 | private Piece piece;
11 |
12 |
13 | public Position(Piece piece ) {
14 | this.piece = piece;
15 | }
16 |
17 | public Piece getPiece() {
18 | return piece;
19 |
20 | }
21 |
22 | public void setPiece(Piece piece) {
23 | this.piece = piece;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/data/Coordinates.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.data;
2 |
3 | /**
4 | * Created by DIPANSH KHANDELWAL on 03-06-2017
5 | */
6 |
7 | public class Coordinates {
8 | private int x;
9 | private int y;
10 |
11 | public Coordinates(int x, int y) {
12 | this.x = x;
13 | this.y = y;
14 | }
15 |
16 | public void setX(int x) {
17 | this.x = x;
18 | }
19 |
20 | public int getX() {
21 | return x;
22 | }
23 |
24 | public int getY() {
25 | return y;
26 | }
27 |
28 | public void setY(int y) {
29 | this.y = y;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/SnakeAndLadderLastPage.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | import com.example.dipansh.asobimasu.R;
4 | import android.content.Intent;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 |
9 | public class SnakeAndLadderLastPage extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_snake_and_ladder_last_page);
15 | }
16 |
17 | public void onClickReplay(View view){
18 | Intent replay = new Intent(SnakeAndLadderLastPage.this,SnakeAndLadderBoard.class);
19 | startActivity(replay);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/Block.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | /**
4 | * Created by lenovo on 09-12-2017.
5 | */
6 |
7 | public class Block {
8 | public Block(){
9 | block_id=0;
10 | block_value=0;
11 | jump_pos=0;
12 | }
13 | void setBlock_id(Block b,int i){
14 | b.block_id=i;
15 | }
16 | void setValue(Block b,int i){
17 | b.block_value=i;
18 | }
19 | void setJumpPos(Block b,int i){
20 | b.jump_pos=i;
21 | }
22 | int getValue(){
23 | return this.block_value;
24 | }
25 | int getJump(){
26 | return this.jump_pos;
27 | }
28 | int get_id(){
29 | return this.block_id;
30 | }
31 | private int block_id;
32 | private int block_value;
33 | private int jump_pos;
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/Players.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | /**
4 | * Created by lenovo on 09-12-2017.
5 | */
6 |
7 | public class Players {
8 |
9 | private int player_pos;
10 | private boolean win_stat;
11 | private int rank;
12 | public Players(){
13 | player_pos=0;
14 | win_stat=false;
15 | rank=0;
16 | }
17 | public int get_pos(){
18 | return this.player_pos;
19 | }
20 | public void update_pos(int pos){
21 | this.player_pos=pos;
22 | }
23 | public boolean IsWinner(){
24 | return this.win_stat;
25 | }
26 | public int getRank(){
27 | return this.rank;
28 | }
29 | public void setRank(int i){
30 | this.rank=i;
31 | }
32 | public void set_win_stat(boolean ws){
33 | this.win_stat=ws;
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/dipansh/asobimasu/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.dipansh.asobimasu", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
8 | #f0ba8c29
9 | #f0f0d157
10 | #a2ce2a7c
11 | #795e45e6
12 | #969b1be1
13 | #8dff0004
14 | #d9732b
15 | #898989
16 |
17 |
18 |
19 | #4A90E2
20 | #FFD918
21 | #FF000B
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Piece.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class Piece implements Movable{
13 |
14 | private boolean white;
15 |
16 | public Piece(boolean white) {
17 | this.white = white;
18 | }
19 |
20 |
21 |
22 | public boolean isWhite() {
23 | return white;
24 | }
25 |
26 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
27 | ArrayList allowedMoves = new ArrayList<>();
28 | Coordinates c;
29 | for(int i=0;i<8;i++){
30 | for(int j=0;j<8;j++){
31 | c = new Coordinates(i,j);
32 | allowedMoves.add(c);
33 | }
34 | }
35 | return allowedMoves;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.example.dipansh.asobimasu"
7 | minSdkVersion 21
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
28 | implementation 'com.android.support:design:26.1.0'
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/SnakeAndLadderMainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | import com.example.dipansh.asobimasu.R;
4 | import android.content.Intent;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.RelativeLayout;
9 |
10 | import com.example.dipansh.asobimasu.R;
11 |
12 | public class SnakeAndLadderMainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_snake_and_ladder_main);
18 | RelativeLayout image = (RelativeLayout) findViewById(R.id.start_page);
19 |
20 | image.setOnClickListener(new View.OnClickListener() {
21 | @Override
22 | public void onClick(View view) {
23 | Intent board = new Intent(SnakeAndLadderMainActivity.this, SnakeAndLadderBoard.class);
24 | startActivity(board);
25 | }
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_snake_and_ladder_last_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
25 |
26 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_snake_and_ladder_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
15 |
22 |
23 |
35 |
36 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/board_row.xml:
--------------------------------------------------------------------------------
1 |
7 |
13 |
19 |
25 |
31 |
37 |
43 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/front_board_row.xml:
--------------------------------------------------------------------------------
1 |
7 |
13 |
19 |
25 |
31 |
37 |
43 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/Board.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | /**
4 | * Created by lenovo on 09-12-2017.
5 | */
6 |
7 | public class Board {
8 | public Board(){}
9 | Block b_obj=new Block();
10 | Block[] SL_board=new Block[101];
11 | public void createBoard(){
12 | for(int i=0;i<101;i++){
13 | SL_board[i]=new Block();
14 | }
15 | for(int i=0;i<=100;i++){
16 | b_obj.setBlock_id(SL_board[i],i);
17 | b_obj.setJumpPos(SL_board[i],i);
18 | }
19 | // Setting jump positions for those blocks which have ladders climbing up.
20 | b_obj.setValue(SL_board[5],1);
21 | b_obj.setJumpPos(SL_board[5],25);
22 | b_obj.setValue(SL_board[10],1);
23 | b_obj.setJumpPos(SL_board[10],29);
24 | b_obj.setValue(SL_board[22],1);
25 | b_obj.setJumpPos(SL_board[22],41);
26 | b_obj.setValue(SL_board[28],1);
27 | b_obj.setJumpPos(SL_board[28],55);
28 | b_obj.setValue(SL_board[44],1);
29 | b_obj.setJumpPos(SL_board[44],95);
30 | b_obj.setValue(SL_board[70],1);
31 | b_obj.setJumpPos(SL_board[70],89);
32 | b_obj.setValue(SL_board[79],1);
33 | b_obj.setJumpPos(SL_board[79],81);
34 |
35 | // Setting jump positions for blocks having snake faces.
36 | b_obj.setValue(SL_board[31],-1);
37 | b_obj.setJumpPos(SL_board[31],14);
38 | b_obj.setValue(SL_board[37],-1);
39 | b_obj.setJumpPos(SL_board[37],17);
40 | b_obj.setValue(SL_board[73],-1);
41 | b_obj.setJumpPos(SL_board[73],53);
42 | b_obj.setValue(SL_board[78],-1);
43 | b_obj.setJumpPos(SL_board[78],29);
44 | b_obj.setValue(SL_board[92],-1);
45 | b_obj.setJumpPos(SL_board[92],35);
46 | b_obj.setValue(SL_board[99],-1);
47 | b_obj.setJumpPos(SL_board[99],7);
48 | }
49 | Block[] getMyBlocks(Board b1){
50 | return b1.SL_board;
51 | }
52 | Block getBlock(Board b,int pos){
53 | return b.SL_board[pos];
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Asobimasu [](https://travis-ci.org/DipanshKhandelwal/Asobimasu)
2 |
3 | Games for android
4 | ## Screenshots
5 |
6 | ### Chess
7 |
8 |
9 |  |
10 |
11 |
12 |
13 | ### Gravity Balls
14 |
15 |
16 |  |
17 |  |
18 |
19 |
20 |
21 | ### Connect4
22 |
23 |
24 |  |
25 |
26 |
27 |
28 | ## How to launch the project locally
29 | 1. Download **[Android Studio](https://developer.android.com/studio/index.html)** from the Google Developers site or using this [link](https://developer.android.com/studio/index.html).
30 | 2. Install the file to your pc.
31 | 3. Download the required **SDK(Standard Development Kit) Tools** .
32 | 4. **[Clone the repository](https://github.com/DipanshKhandelwal/Asobimasu.git)** from : "https://github.com/DipanshKhandelwal/Asobimasu.git" .
33 |
34 | `bash
35 | git clone --recursive https://github.com/DipanshKhandelwal/Asobimasu.git
36 | `
37 | 5. Open the project in Android Studio.
38 | 6. For launching the project you can either :
39 | 1. **Install emulator**
40 | * For this you must have **HAMX (Hardware Accelerated Execution Manager)** installed in Android Studio IDE.
41 | * To install **[HAMX (Hardware Accelerated Execution Manager)](https://stackoverflow.com/questions/29136173/emulator-error-x86-emulation-currently-requires-hardware-acceleration)** refer here.
42 | * You can download it at the time of installation of the Android Studio or install it afterwards in the **SDK manager**.
43 | * Use your **AVD manager** for launching the app.
44 | 2. **Use your Android Phone**
45 | * For using your phone, firstly connect your Android Phone with the pc using a data cable.
46 | * Go to the Settings > Developers Setting.
47 | * **Allow USB debugging**.
48 | * **Run** the project from the Android Studio IDE.
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu;
2 |
3 | import android.content.Intent;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 |
9 | import com.example.dipansh.asobimasu.chess.ChessMainActivity;
10 | import com.example.dipansh.asobimasu.connect4.MainActivityConnect4;
11 | import com.example.dipansh.asobimasu.gravityBalls.GravityBallsMainActivity;
12 | import com.example.dipansh.asobimasu.snakeAndLadder.SnakeAndLadderMainActivity;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | FloatingActionButton chess, snake_and_ladder, gravity_balls, connect4;
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 |
22 | chess = (FloatingActionButton) findViewById(R.id.button_chess);
23 | snake_and_ladder = (FloatingActionButton) findViewById(R.id.button_snake_and_ladder);
24 | gravity_balls = (FloatingActionButton) findViewById(R.id.button_gravity_balls);
25 | connect4 = (FloatingActionButton) findViewById(R.id.button_connect4);
26 |
27 | chess.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 | Intent chess = new Intent(MainActivity.this, ChessMainActivity.class);
31 | MainActivity.this.startActivity(chess);
32 | }
33 | });
34 |
35 | snake_and_ladder.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent chess = new Intent(MainActivity.this, SnakeAndLadderMainActivity.class);
39 | MainActivity.this.startActivity(chess);
40 | }
41 | });
42 |
43 | gravity_balls.setOnClickListener(new View.OnClickListener() {
44 | @Override
45 | public void onClick(View v) {
46 | Intent chess = new Intent(MainActivity.this, GravityBallsMainActivity.class);
47 | MainActivity.this.startActivity(chess);
48 | }
49 | });
50 |
51 | connect4.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | Intent chess = new Intent(MainActivity.this, MainActivityConnect4.class);
55 | MainActivity.this.startActivity(chess);
56 | }
57 | });
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
33 |
34 |
46 |
47 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/connect4/Board.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.connect4;
2 |
3 | /**
4 | * Created by rachana on 12/12/2017.
5 | */
6 |
7 | public class Board {
8 |
9 | public com.example.dipansh.asobimasu.connect4.Board.Turn turn;
10 |
11 | private int numCols;
12 | private int numRows;
13 | public boolean hasWinner;
14 | public Cell[][] cells;
15 |
16 | public enum Turn {
17 | FIRST, SECOND
18 | }
19 |
20 | public Board(int cols, int rows) {
21 | numCols = cols;
22 | numRows = rows;
23 | cells = new Cell[numCols][numRows];
24 | reset();
25 | }
26 |
27 | public void reset() {
28 | hasWinner = false;
29 | turn = Turn.FIRST;
30 | for (int col = 0; col < numCols; col++) {
31 | for (int row = 0; row < numRows; row++) {
32 | cells [col][row] = new Cell();
33 | }
34 | }
35 | }
36 |
37 | public int lastAvailableRow(int col) {
38 | for (int row = numRows - 1; row >= 0; row--) {
39 | if (cells[col][row].empty) {
40 | return row;
41 | }
42 | }
43 | return -1;
44 | }
45 |
46 | public void occupyCell(int col, int row) {
47 | cells[col][row].setPlayer(turn);
48 | }
49 |
50 | public void toggleTurn() {
51 | if (turn == Turn.FIRST) {
52 | turn = Turn.SECOND;
53 | } else {
54 | turn = Turn.FIRST;
55 | }
56 | }
57 |
58 | public boolean checkForWin(int c, int r) {
59 | for (int col = 0; col < numCols; col++) {
60 | if (isContiguous(turn, 0, 1, col, 0, 0) || isContiguous(turn, 1, 1, col, 0, 0) || isContiguous(turn, -1, 1, col, 0, 0)) {
61 | hasWinner = true;
62 | return true;
63 | }
64 | }
65 | for (int row = 0; row < numRows; row++) {
66 | if (isContiguous(turn, 1, 0, 0, row, 0) || isContiguous(turn, 1, 1, 0, row, 0) || isContiguous(turn, -1, 1, numCols - 1, row, 0)) {
67 | hasWinner = true;
68 | return true;
69 | }
70 | }
71 | return false;
72 | }
73 |
74 | private boolean isContiguous(Turn player, int dirX, int dirY, int col, int row, int count) {
75 | if (count >= 4) {
76 | return true;
77 | }
78 | if (col < 0 || col >= numCols || row < 0 || row >= numRows) {
79 | return false;
80 | }
81 | Cell cell = cells[col][row];
82 | if (cell.player == player) {
83 | return isContiguous(player, dirX, dirY, col + dirX, row + dirY, count + 1);
84 | } else {
85 | return isContiguous(player, dirX, dirY, col + dirX, row + dirY, 0);
86 | }
87 | }
88 |
89 | }
90 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Rook.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class Rook extends Piece{
13 |
14 | public Rook(boolean white) {
15 | super(white);
16 | }
17 |
18 | @Override
19 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
20 |
21 | ArrayList allowedMoves = new ArrayList<>();
22 | allowedMoves.clear();
23 | Coordinates c ;
24 |
25 | for(int i=(coordinates.getX()+1) ; i<8 ;i++){
26 | if(board[i][coordinates.getY()].getPiece() == null){
27 | c = new Coordinates(i , coordinates.getY());
28 | allowedMoves.add(c);
29 | }else{
30 | if(board[i][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
31 | c = new Coordinates(i , coordinates.getY());
32 | allowedMoves.add(c);
33 | }
34 | break;
35 | }
36 | }
37 |
38 | for(int i=(coordinates.getX()-1) ; i>=0 ; i--){
39 | if(board[i][coordinates.getY()].getPiece() == null){
40 | c = new Coordinates(i , coordinates.getY());
41 | allowedMoves.add(c);
42 | }else{
43 | if(board[i][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
44 | c = new Coordinates(i , coordinates.getY());
45 | allowedMoves.add(c);
46 | }
47 | break;
48 | }
49 | }
50 |
51 | for(int i=(coordinates.getY()-1) ; i>=0 ; i--){
52 | if(board[coordinates.getX()][i].getPiece() == null){
53 | c = new Coordinates( coordinates.getX() , i);
54 | allowedMoves.add(c);
55 | }else{
56 | if(board[coordinates.getX()][i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
57 | c = new Coordinates( coordinates.getX() , i);
58 | allowedMoves.add(c);
59 | }
60 | break;
61 | }
62 | }
63 |
64 | for(int i=(coordinates.getY()+1) ; i<8 ;i++){
65 | if(board[coordinates.getX()][i].getPiece() == null){
66 | c = new Coordinates(coordinates.getX() , i);
67 | allowedMoves.add(c);
68 | }else{
69 | if(board[coordinates.getX()][i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
70 | c = new Coordinates(coordinates.getX() , i);
71 | allowedMoves.add(c);
72 | }
73 | break;
74 | }
75 | }
76 | //check locations at board
77 | //work on the coordinates and return the allowed moves
78 | return allowedMoves;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/GamePlay.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | import java.util.Random;
4 |
5 | /**
6 | * This File has the main logic if you wanna see how the process is going just run this java file
7 | * This File is just for understanding Its important methods are reconstucted in SnakeAndLadderBoard.java
8 | * @author Rohit.
9 | */
10 |
11 | public class GamePlay {
12 | Block[] board=new Block[101];
13 | Board gameBoard=new Board();
14 | public GamePlay(){
15 | }
16 | public int throwDice(){
17 | int count=0;
18 | int dice_no=0;
19 | Random r=new Random();
20 | dice_no=r.nextInt(5)+1;
21 | if(dice_no==6){
22 | count++;
23 | while(count<3){
24 | dice_no+=r.nextInt(5)+1;
25 | if(dice_no%6==0)
26 | count++;
27 | else
28 | break;
29 | }
30 | if(count==3){
31 | dice_no=0;
32 | }
33 | }
34 | return dice_no;
35 | }
36 |
37 | public void Play(int nop,int value){ // nop= num of players.
38 | gameBoard.createBoard();
39 | int position=0;
40 | Block z=new Block();
41 | z=gameBoard.getBlock(gameBoard,10);
42 | System.out.println("@@@@");
43 | System.out.println(z.getValue());
44 | int complete_num=0; // it will store the number of players who have completed playing.
45 | Players[] plyr=new Players[nop];
46 | for(int i=0;i AllowedMoves(Coordinates coordinates , Position[][] board){
20 | ArrayList allowedMoves = new ArrayList<>();
21 | Coordinates c;
22 |
23 | for(int i=1 ; i<8 ; i++){
24 | if((coordinates.getX()+i)<8 && (coordinates.getY()+i)<8){
25 | if(board[coordinates.getX()+i][coordinates.getY()+i].getPiece() == null){
26 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()+i);
27 | allowedMoves.add(c);
28 | }else{
29 | if(board[coordinates.getX()+i][coordinates.getY()+i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
30 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()+i);
31 | allowedMoves.add(c);
32 | }
33 | break;
34 | }
35 | }
36 | }
37 |
38 | for(int i=1 ; i<8 ; i++){
39 | if((coordinates.getX()-i)>=0 && (coordinates.getY()+i)<8){
40 | if(board[coordinates.getX()-i][coordinates.getY()+i].getPiece() == null){
41 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()+i);
42 | allowedMoves.add(c);
43 | }else{
44 | if(board[coordinates.getX()-i][coordinates.getY()+i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
45 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()+i);
46 | allowedMoves.add(c);
47 | }
48 | break;
49 | }
50 |
51 | }
52 | }
53 |
54 | for(int i=1 ; i<8 ; i++){
55 | if((coordinates.getX()-i)>=0 && (coordinates.getY()-i)>=0){
56 | if(board[coordinates.getX()-i][coordinates.getY()-i].getPiece() == null){
57 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()-i);
58 | allowedMoves.add(c);
59 | }else{
60 | if(board[coordinates.getX()-i][coordinates.getY()-i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
61 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()-i);
62 | allowedMoves.add(c);
63 | }
64 | break;
65 | }
66 |
67 | }
68 | }
69 |
70 | for(int i=1 ; i<8 ; i++){
71 | if((coordinates.getX()+i)<8 && (coordinates.getY()-i)>=0){
72 | if(board[coordinates.getX()+i][coordinates.getY()-i].getPiece() == null){
73 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()-i);
74 | allowedMoves.add(c);
75 | }else{
76 | if(board[coordinates.getX()+i][coordinates.getY()-i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
77 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()-i);
78 | allowedMoves.add(c);
79 | }
80 | break;
81 | }
82 |
83 | }
84 | }
85 | return allowedMoves;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main_connect4.xml:
--------------------------------------------------------------------------------
1 |
6 |
12 |
21 |
28 |
33 |
34 |
47 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Pawn.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class Pawn extends Piece{
13 |
14 | public Pawn(boolean white) {
15 | super(white);
16 | }
17 |
18 | @Override
19 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
20 |
21 | ArrayList allowedMoves = new ArrayList<>();
22 | allowedMoves.clear();
23 | Coordinates c;
24 |
25 | if(board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
26 |
27 | if(coordinates.getX()<8 && coordinates.getX()>=0 && (coordinates.getY()-1)<8 && (coordinates.getY()-1)>=0){
28 | if(board[coordinates.getX()][coordinates.getY()-1].getPiece()==null){
29 | c=new Coordinates(coordinates.getX() , coordinates.getY() - 1);
30 | allowedMoves.add(c);
31 |
32 | if((coordinates.getY() == 6) && (board[coordinates.getX()][coordinates.getY() - 2].getPiece() == null)){
33 | c = new Coordinates(coordinates.getX(), coordinates.getY() - 2);
34 | allowedMoves.add(c);
35 | }
36 | }
37 | }
38 |
39 | if((coordinates.getX()+1)<8 && (coordinates.getX()+1)>=0 && (coordinates.getY()-1)<8 && (coordinates.getY()-1)>=0) {
40 | if (board[coordinates.getX() + 1][coordinates.getY() - 1].getPiece() != null) {
41 | if(board[coordinates.getX() + 1][coordinates.getY() - 1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
42 | c = new Coordinates(coordinates.getX() + 1, coordinates.getY() - 1);
43 | allowedMoves.add(c);
44 | }
45 | }
46 |
47 | }
48 |
49 | if((coordinates.getX()-1)<8 && (coordinates.getX()-1)>=0 && (coordinates.getY()-1)<8 && (coordinates.getY()-1)>=0) {
50 | if (board[coordinates.getX() - 1][coordinates.getY() - 1].getPiece() != null) {
51 | if(board[coordinates.getX() - 1][coordinates.getY() - 1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
52 | c = new Coordinates(coordinates.getX() - 1, coordinates.getY() - 1);
53 | allowedMoves.add(c);
54 | }
55 | }
56 | }
57 |
58 | }else{
59 |
60 | if((coordinates.getX())<8 && (coordinates.getX())>=0 && (coordinates.getY()+1)<8 && (coordinates.getY()+1)>=0) {
61 | if (board[coordinates.getX()][coordinates.getY() + 1].getPiece() == null) {
62 | c = new Coordinates(coordinates.getX(), coordinates.getY() + 1);
63 | allowedMoves.add(c);
64 |
65 | if(coordinates.getY() == 1 && (board[coordinates.getX()][coordinates.getY() + 2].getPiece() == null)){
66 | c = new Coordinates(coordinates.getX(), coordinates.getY() + 2);
67 | allowedMoves.add(c);
68 | }
69 | }
70 | }
71 |
72 | if((coordinates.getX()+1)<8 && (coordinates.getX()+1)>=0 && (coordinates.getY()+1)<8 && (coordinates.getY()+1)>=0) {
73 | if (board[coordinates.getX() + 1][coordinates.getY() + 1].getPiece() != null) {
74 | if(board[coordinates.getX() + 1][coordinates.getY() + 1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
75 | c = new Coordinates(coordinates.getX() + 1, coordinates.getY() + 1);
76 | allowedMoves.add(c);
77 | }
78 | }
79 | }
80 |
81 | if((coordinates.getX()-1)<8 && (coordinates.getX()-1)>=0 && (coordinates.getY()+1)<8 && (coordinates.getY()+1)>=0) {
82 | if (board[coordinates.getX() - 1][coordinates.getY() + 1].getPiece() != null) {
83 | if(board[coordinates.getX() - 1][coordinates.getY() + 1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
84 | c = new Coordinates(coordinates.getX() - 1, coordinates.getY() + 1);
85 | allowedMoves.add(c);
86 | }
87 | }
88 | }
89 |
90 | }
91 | //check locations at board
92 | //work on the coordinates and return the allowed moves
93 | return allowedMoves;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/King.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class King extends Piece {
13 |
14 | public King(boolean white) {
15 | super( white);
16 | }
17 |
18 | @Override
19 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
20 | ArrayList allowedMoves = new ArrayList<>();
21 | allowedMoves.clear();
22 | Coordinates c;
23 |
24 | if((coordinates.getX()+1) <8 && (coordinates.getY()+1)<8){
25 | if(board[coordinates.getX()+1][coordinates.getY()+1].getPiece() == null){
26 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()+1);
27 | allowedMoves.add(c);
28 | }else{
29 | if(board[coordinates.getX()+1][coordinates.getY()+1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
30 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()+1);
31 | allowedMoves.add(c);
32 | }
33 | }
34 | }
35 |
36 | if((coordinates.getY()+1)<8){
37 | if(board[coordinates.getX()][coordinates.getY()+1].getPiece() == null){
38 | c = new Coordinates(coordinates.getX() , coordinates.getY()+1);
39 | allowedMoves.add(c);
40 | }else{
41 | if(board[coordinates.getX()][coordinates.getY()+1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
42 | c = new Coordinates(coordinates.getX() , coordinates.getY()+1);
43 | allowedMoves.add(c);
44 | }
45 | }
46 | }
47 |
48 | if((coordinates.getX()-1) >=0 && (coordinates.getY()+1)<8){
49 | if(board[coordinates.getX()-1][coordinates.getY()+1].getPiece() == null){
50 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()+1);
51 | allowedMoves.add(c);
52 | }else{
53 | if(board[coordinates.getX()-1][coordinates.getY()+1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
54 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()+1);
55 | allowedMoves.add(c);
56 | }
57 | }
58 | }
59 |
60 | if((coordinates.getX()+1) <8 ){
61 | if(board[coordinates.getX()+1][coordinates.getY()].getPiece() == null){
62 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY());
63 | allowedMoves.add(c);
64 | }else{
65 | if(board[coordinates.getX()+1][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
66 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY());
67 | allowedMoves.add(c);
68 | }
69 | }
70 | }
71 |
72 | if((coordinates.getX()-1) <8 ){
73 | if(board[coordinates.getX()-1][coordinates.getY()].getPiece() == null){
74 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY());
75 | allowedMoves.add(c);
76 | }else{
77 | if(board[coordinates.getX()-1][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
78 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY());
79 | allowedMoves.add(c);
80 | }
81 | }
82 | }
83 |
84 | if((coordinates.getX()+1) <8 && (coordinates.getY()-1)>=0){
85 | if(board[coordinates.getX()+1][coordinates.getY()-1].getPiece() == null){
86 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()-1);
87 | allowedMoves.add(c);
88 | }else{
89 | if(board[coordinates.getX()+1][coordinates.getY()-1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
90 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()-1);
91 | allowedMoves.add(c);
92 | }
93 | }
94 | }
95 |
96 | if((coordinates.getY()-1)>=0){
97 | if(board[coordinates.getX()][coordinates.getY()-1].getPiece() == null){
98 | c = new Coordinates(coordinates.getX() , coordinates.getY()-1);
99 | allowedMoves.add(c);
100 | }else{
101 | if(board[coordinates.getX()][coordinates.getY()-1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
102 | c = new Coordinates(coordinates.getX() , coordinates.getY()-1);
103 | allowedMoves.add(c);
104 | }
105 | }
106 | }
107 |
108 | if((coordinates.getX()-1) <8 && (coordinates.getY()-1)>=0){
109 | if(board[coordinates.getX()-1][coordinates.getY()-1].getPiece() == null){
110 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()-1);
111 | allowedMoves.add(c);
112 | }else{
113 | if(board[coordinates.getX()-1][coordinates.getY()-1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
114 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()-1);
115 | allowedMoves.add(c);
116 | }
117 | }
118 | }
119 |
120 |
121 |
122 | return allowedMoves;
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Knight.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class Knight extends Piece{
13 |
14 | public Knight(boolean white) {
15 | super(white);
16 | }
17 |
18 | @Override
19 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
20 | ArrayList allowedMoves = new ArrayList<>();
21 | allowedMoves.clear();
22 | Coordinates c;
23 |
24 | if (coordinates.getX()+2 <8 && coordinates.getY()-1 >=0){
25 | if(board[coordinates.getX()+2][coordinates.getY()-1].getPiece() ==null){
26 | c = new Coordinates(coordinates.getX()+2 , coordinates.getY()-1);
27 | allowedMoves.add(c);
28 | }else{
29 | if(board[coordinates.getX()+2][coordinates.getY()-1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
30 | c = new Coordinates(coordinates.getX()+2 , coordinates.getY()-1);
31 | allowedMoves.add(c);
32 | }
33 | }
34 | }
35 |
36 | if (coordinates.getX()+1 <8 && coordinates.getY()-2 >=0){
37 | if(board[coordinates.getX()+1][coordinates.getY()-2].getPiece() ==null){
38 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()-2);
39 | allowedMoves.add(c);
40 | }else{
41 | if(board[coordinates.getX()+1][coordinates.getY()-2].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
42 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()-2);
43 | allowedMoves.add(c);
44 | }
45 | }
46 | }
47 |
48 | if (coordinates.getX()-2 >= 0 && coordinates.getY()-1 >=0){
49 | if(board[coordinates.getX()-2][coordinates.getY()-1].getPiece() ==null){
50 | c = new Coordinates(coordinates.getX()-2 , coordinates.getY()-1);
51 | allowedMoves.add(c);
52 | }else{
53 | if(board[coordinates.getX()-2][coordinates.getY()-1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
54 | c = new Coordinates(coordinates.getX()-2 , coordinates.getY()-1);
55 | allowedMoves.add(c);
56 | }
57 | }
58 | }
59 |
60 | if (coordinates.getX()-1 >=0 && coordinates.getY()-2 >=0){
61 | if(board[coordinates.getX()-1][coordinates.getY()-2].getPiece() ==null){
62 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()-2);
63 | allowedMoves.add(c);
64 | }else{
65 | if(board[coordinates.getX()-1][coordinates.getY()-2].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
66 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()-2);
67 | allowedMoves.add(c);
68 | }
69 | }
70 | }
71 |
72 | if (coordinates.getX()+2 <8 && coordinates.getY()+1 <8){
73 | if(board[coordinates.getX()+2][coordinates.getY()+1].getPiece() ==null){
74 | c = new Coordinates(coordinates.getX()+2 , coordinates.getY()+1);
75 | allowedMoves.add(c);
76 | }else{
77 | if(board[coordinates.getX()+2][coordinates.getY()+1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
78 | c = new Coordinates(coordinates.getX()+2 , coordinates.getY()+1);
79 | allowedMoves.add(c);
80 | }
81 | }
82 | }
83 |
84 | if (coordinates.getX()+1 <8 && coordinates.getY()+2 <8){
85 | if(board[coordinates.getX()+1][coordinates.getY()+2].getPiece() ==null){
86 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()+2);
87 | allowedMoves.add(c);
88 | }else{
89 | if(board[coordinates.getX()+1][coordinates.getY()+2].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
90 | c = new Coordinates(coordinates.getX()+1 , coordinates.getY()+2);
91 | allowedMoves.add(c);
92 | }
93 | }
94 | }
95 |
96 | if (coordinates.getX()-2 >=0 && coordinates.getY()+1 <8){
97 | if(board[coordinates.getX()-2][coordinates.getY()+1].getPiece() ==null){
98 | c = new Coordinates(coordinates.getX()-2 , coordinates.getY()+1);
99 | allowedMoves.add(c);
100 | }else{
101 | if(board[coordinates.getX()-2][coordinates.getY()+1].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
102 | c = new Coordinates(coordinates.getX()-2 , coordinates.getY()+1);
103 | allowedMoves.add(c);
104 | }
105 | }
106 | }
107 |
108 | if (coordinates.getX()-1 >=0 && coordinates.getY()+2 <8){
109 | if(board[coordinates.getX()-1][coordinates.getY()+2].getPiece() ==null){
110 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()+2);
111 | allowedMoves.add(c);
112 | }else{
113 | if(board[coordinates.getX()-1][coordinates.getY()+2].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
114 | c = new Coordinates(coordinates.getX()-1 , coordinates.getY()+2);
115 | allowedMoves.add(c);
116 | }
117 | }
118 | }
119 |
120 | return allowedMoves;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/connect4/MainActivityConnect4.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.connect4;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Point;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.Display;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.animation.Animation;
14 | import android.view.animation.AnimationUtils;
15 | import android.view.animation.TranslateAnimation;
16 | import android.widget.Button;
17 | import android.widget.ImageView;
18 | import android.widget.TextView;
19 |
20 | import com.example.dipansh.asobimasu.R;
21 |
22 |
23 | public class MainActivityConnect4 extends Activity {
24 | private ImageView[][] cells;
25 | private View boardView;
26 | private Board board;
27 | private ViewHolder viewHolder;
28 | private static int NUM_ROWS = 6;
29 | private static int NUM_COLS = 7;
30 |
31 | private class ViewHolder {
32 | public TextView winnerText;
33 | public ImageView turnIndicatorImageView;
34 | }
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_main_connect4);
40 | board = new Board(NUM_COLS, NUM_ROWS);
41 | boardView = findViewById(R.id.game_board);
42 | buildCells();
43 | boardView.setOnTouchListener(new View.OnTouchListener() {
44 | @Override
45 | public boolean onTouch(View view, MotionEvent motionEvent) {
46 | switch (motionEvent.getAction()) {
47 | case MotionEvent.ACTION_POINTER_UP:
48 | case MotionEvent.ACTION_UP: {
49 | int col = colAtX(motionEvent.getX());
50 | if (col != -1)
51 | drop(col);
52 | }
53 | }
54 | return true;
55 | }
56 | });
57 | Button resetButton = (Button) findViewById(R.id.reset_button);
58 | resetButton.setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View view) {
61 | reset();
62 | }
63 | });
64 | viewHolder = new ViewHolder();
65 | viewHolder.turnIndicatorImageView = (ImageView) findViewById(R.id.turn_indicator_image_view);
66 | viewHolder.turnIndicatorImageView.setImageResource(resourceForTurn());
67 | viewHolder.winnerText = (TextView) findViewById(R.id.winner_text);
68 | viewHolder.winnerText.setVisibility(View.GONE);
69 | }
70 |
71 |
72 | @Override
73 | public boolean onCreateOptionsMenu(Menu menu) {
74 | // Inflate the menu; this adds items to the action bar if it is present.
75 | getMenuInflater().inflate(R.menu.game, menu);
76 | return true;
77 | }
78 |
79 | @Override
80 | public boolean onOptionsItemSelected(MenuItem item) {
81 | // Handle action bar item clicks here. The action bar will
82 | // automatically handle clicks on the Home/Up button, so long
83 | // as you specify a parent activity in AndroidManifest.xml.
84 | int id = item.getItemId();
85 | if (id == R.id.action_settings) {
86 | return true;
87 | }
88 | return super.onOptionsItemSelected(item);
89 | }
90 |
91 | private void buildCells() {
92 | cells = new ImageView[NUM_ROWS][NUM_COLS];
93 | for (int r=0; r 6)
141 | return -1;
142 | return col;
143 | }
144 |
145 | private int resourceForTurn() {
146 | switch (board.turn) {
147 | case FIRST:
148 | return R.drawable.red;
149 | case SECOND:
150 | return R.drawable.yellow;
151 | }
152 | return R.drawable.red;
153 | }
154 |
155 | private void reset() {
156 | board.reset();
157 | viewHolder.winnerText.setVisibility(View.GONE);
158 | viewHolder.turnIndicatorImageView.setImageResource(resourceForTurn());
159 | for (int r=0; r
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/chess/pieces/Queen.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.chess.pieces;
2 |
3 | import com.example.dipansh.asobimasu.chess.data.Coordinates;
4 | import com.example.dipansh.asobimasu.chess.data.Position;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Created by DIPANSH KHANDELWAL on 03-06-2017
10 | */
11 |
12 | public class Queen extends Piece implements Movable{
13 |
14 | public Queen(boolean white) {
15 | super(white);
16 | }
17 |
18 | @Override
19 | public ArrayList AllowedMoves(Coordinates coordinates , Position[][] board){
20 | ArrayList allowedMoves = new ArrayList<>();
21 | Coordinates c;
22 | allowedMoves.clear();
23 |
24 | for(int i=(coordinates.getX()+1) ; i<8 ;i++){
25 | if(board[i][coordinates.getY()].getPiece() == null){
26 | c = new Coordinates(i , coordinates.getY());
27 | allowedMoves.add(c);
28 | }else{
29 | if(board[i][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
30 | c = new Coordinates(i , coordinates.getY());
31 | allowedMoves.add(c);
32 | }
33 | break;
34 | }
35 | }
36 |
37 | for(int i=(coordinates.getX()-1) ; i>=0 ; i--){
38 | if(board[i][coordinates.getY()].getPiece() == null){
39 | c = new Coordinates(i , coordinates.getY());
40 | allowedMoves.add(c);
41 | }else{
42 | if(board[i][coordinates.getY()].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
43 | c = new Coordinates(i , coordinates.getY());
44 | allowedMoves.add(c);
45 | }
46 | break;
47 | }
48 | }
49 |
50 | for(int i=(coordinates.getY()-1) ; i>=0 ; i--){
51 | if(board[coordinates.getX()][i].getPiece() == null){
52 | c = new Coordinates( coordinates.getX() , i);
53 | allowedMoves.add(c);
54 | }else{
55 | if(board[coordinates.getX()][i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
56 | c = new Coordinates( coordinates.getX() , i);
57 | allowedMoves.add(c);
58 | }
59 | break;
60 | }
61 | }
62 |
63 | for(int i=(coordinates.getY()+1) ; i<8 ;i++){
64 | if(board[coordinates.getX()][i].getPiece() == null){
65 | c = new Coordinates(coordinates.getX() , i);
66 | allowedMoves.add(c);
67 | }else{
68 | if(board[coordinates.getX()][i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
69 | c = new Coordinates(coordinates.getX() , i);
70 | allowedMoves.add(c);
71 | }
72 | break;
73 | }
74 | }
75 |
76 | /*............................*/
77 | for(int i=1 ; i<8 ; i++){
78 | if((coordinates.getX()+i)<8 && (coordinates.getY()+i)<8){
79 | if(board[coordinates.getX()+i][coordinates.getY()+i].getPiece() == null){
80 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()+i);
81 | allowedMoves.add(c);
82 | }else{
83 | if(board[coordinates.getX()+i][coordinates.getY()+i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
84 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()+i);
85 | allowedMoves.add(c);
86 | }
87 | break;
88 | }
89 | }
90 | }
91 |
92 | for(int i=1 ; i<8 ; i++){
93 | if((coordinates.getX()-i)>=0 && (coordinates.getY()+i)<8){
94 | if(board[coordinates.getX()-i][coordinates.getY()+i].getPiece() == null){
95 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()+i);
96 | allowedMoves.add(c);
97 | }else{
98 | if(board[coordinates.getX()-i][coordinates.getY()+i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
99 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()+i);
100 | allowedMoves.add(c);
101 | }
102 | break;
103 | }
104 |
105 | }
106 | }
107 |
108 | for(int i=1 ; i<8 ; i++){
109 | if((coordinates.getX()-i)>=0 && (coordinates.getY()-i)>=0){
110 | if(board[coordinates.getX()-i][coordinates.getY()-i].getPiece() == null){
111 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()-i);
112 | allowedMoves.add(c);
113 | }else{
114 | if(board[coordinates.getX()-i][coordinates.getY()-i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
115 | c = new Coordinates(coordinates.getX()-i , coordinates.getY()-i);
116 | allowedMoves.add(c);
117 | }
118 | break;
119 | }
120 |
121 | }
122 | }
123 |
124 | for(int i=1 ; i<8 ; i++){
125 | if((coordinates.getX()+i)<8 && (coordinates.getY()-i)>=0){
126 | if(board[coordinates.getX()+i][coordinates.getY()-i].getPiece() == null){
127 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()-i);
128 | allowedMoves.add(c);
129 | }else{
130 | if(board[coordinates.getX()+i][coordinates.getY()-i].getPiece().isWhite() != board[coordinates.getX()][coordinates.getY()].getPiece().isWhite()){
131 | c = new Coordinates(coordinates.getX()+i , coordinates.getY()-i);
132 | allowedMoves.add(c);
133 | }
134 | break;
135 | }
136 |
137 | }
138 | }
139 |
140 | //check locations at board
141 | //work on the coordinates and return the allowed moves
142 | return allowedMoves;
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dipansh/asobimasu/snakeAndLadder/SnakeAndLadderBoard.java:
--------------------------------------------------------------------------------
1 | package com.example.dipansh.asobimasu.snakeAndLadder;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.TextView;
8 | import com.example.dipansh.asobimasu.R;
9 |
10 | import java.util.Random;
11 |
12 | public class SnakeAndLadderBoard extends AppCompatActivity {
13 |
14 | int count = 0;
15 | int countP1 = 0;
16 | int countP2 = 0;
17 | int posP1 = 0;
18 | int posP2 = 0;
19 | int numberOfPlayers = 2;
20 | int complete_num = 0; // it will store the number of players who have completed playing.
21 | boolean startPlayer1 = false;
22 | boolean startPlayer2 = false;
23 |
24 | Players[] plyr = new Players[numberOfPlayers];
25 |
26 | Block[] board = new Block[101];
27 | Board gameBoard = new Board();
28 |
29 | public TextView[][] DisplayBoard;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_snake_and_ladder_board);
35 |
36 | gameBoard.createBoard();
37 | for(int i=0;i 10 && position % 10 != 0){
246 | i = position/10;
247 | j = (position%10) -1;
248 | }
249 | else if(position==0){
250 | i=0;
251 | j=0;
252 | }
253 | else if(position % 10 == 0){
254 | i = (position/10) - 1;
255 | j = 9;
256 | }
257 | else if(position < 10){
258 | i = 0;
259 | j = position-1;
260 | }
261 |
262 | //For removing image of player1 from previous position
263 | if(positionOfPlayer1 < 0){
264 | x=0;
265 | y=0;
266 | }
267 | else if(positionOfPlayer1 > 10 && positionOfPlayer1 % 10 != 0){
268 | x = positionOfPlayer1/10;
269 | y = (positionOfPlayer1%10) -1;
270 | }
271 | else if(positionOfPlayer1 == 0){
272 | x=0;
273 | y=0;
274 | }
275 | else if(positionOfPlayer1 % 10 == 0){
276 | x = (positionOfPlayer1/10) - 1;
277 | y = 9;
278 | }
279 | else if(positionOfPlayer1 < 10){
280 | x = 0;
281 | y = positionOfPlayer1 - 1;
282 | }
283 |
284 | //Removing player1's Image from previous position
285 | DisplayBoard[x][y].setBackgroundResource(0);
286 |
287 | //displaying player1 in new position
288 | if(position != posP2)
289 | DisplayBoard[i][j].setBackgroundResource(R.drawable.snake_and_ladder_player1);
290 | else
291 | DisplayBoard[i][j].setBackgroundResource(R.drawable.snake_and_ladder_players);
292 |
293 | }
294 |
295 | private void movePlayer2(int position, int positionOfPlayer2){
296 |
297 | int i = 0, j = 0;
298 | int x = 0, y = 0;
299 |
300 | //For moving player2 to new position
301 | if(position > 10 && position % 10 != 0){
302 | i = position/10;
303 | j = (position%10) -1;
304 | }
305 | else if(position==0){
306 | i = 0;
307 | j = 0;
308 | }
309 | else if(position % 10 == 0){
310 | i = (position/10) - 1;
311 | j=9;
312 | }
313 | else if(position < 10){
314 | i=0;
315 | j=position-1;
316 | }
317 |
318 | //For removing image of player2 from previous position
319 | if(positionOfPlayer2 < 0){
320 | x=0;
321 | y=0;
322 | }
323 | else if(positionOfPlayer2 > 10 && positionOfPlayer2 % 10 != 0){
324 | x = positionOfPlayer2/10;
325 | y = (positionOfPlayer2%10) -1;
326 | }
327 | else if(positionOfPlayer2 == 0){
328 | x=0;
329 | y=0;
330 | }
331 | else if(positionOfPlayer2 % 10 == 0){
332 | x = (positionOfPlayer2/10) - 1;
333 | y = 9;
334 | }
335 | else if(positionOfPlayer2 < 10){
336 | x = 0;
337 | y = positionOfPlayer2 - 1;
338 | }
339 |
340 | //Removing player2's Image from previous position
341 | DisplayBoard[x][y].setBackgroundResource(0);
342 |
343 | //displaying player2 in new position
344 | if(posP1!=position)
345 | DisplayBoard[i][j].setBackgroundResource(R.drawable.snake_and_ladder_player2);
346 |
347 | else
348 | DisplayBoard[i][j].setBackgroundResource(R.drawable.snake_and_ladder_players);
349 | }
350 |
351 |
352 |
353 | /**
354 | * This method finds the Posion of player after a single dice roll
355 | * @param nop is player number
356 | * @param value is the value of the dice roll
357 | * @return posision after a single roll
358 | */
359 | public int Play(int nop,int value){
360 |
361 | int positionAfterRoll=0; //Position of specific player after 1 roll
362 | int j=1; // Player Number
363 | if(complete_num xmax) {
165 | mPosX = xmax;
166 | mVelX = 0;
167 | } else if (x < -xmax) {
168 | mPosX = -xmax;
169 | mVelX = 0;
170 | }
171 | if (y > ymax) {
172 | mPosY = ymax;
173 | mVelY = 0;
174 | } else if (y < -ymax) {
175 | mPosY = -ymax;
176 | mVelY = 0;
177 | }
178 | }
179 | }
180 |
181 | /*
182 | * A particle system is just a collection of particles
183 | */
184 | class ParticleSystem {
185 | static final int NUM_PARTICLES = 5;
186 | private Particle mBalls[] = new Particle[NUM_PARTICLES];
187 |
188 | ParticleSystem() {
189 | /*
190 | * Initially our particles have no speed or acceleration
191 | */
192 | for (int i = 0; i < mBalls.length; i++) {
193 | mBalls[i] = new Particle(getContext());
194 | mBalls[i].setBackgroundResource(R.drawable.gravity_balls_ball);
195 | mBalls[i].setLayerType(LAYER_TYPE_HARDWARE, null);
196 | addView(mBalls[i], new ViewGroup.LayoutParams(mDstWidth, mDstHeight));
197 | }
198 | }
199 |
200 | /*
201 | * Update the position of each particle in the system using the
202 | * Verlet integrator.
203 | */
204 | private void updatePositions(float sx, float sy, long timestamp) {
205 | final long t = timestamp;
206 | if (mLastT != 0) {
207 | final float dT = (float) (t - mLastT) / 1000.f /** (1.0f / 1000000000.0f)*/;
208 | final int count = mBalls.length;
209 | for (int i = 0; i < count; i++) {
210 | Particle ball = mBalls[i];
211 | ball.computePhysics(sx, sy, dT);
212 | }
213 | }
214 | mLastT = t;
215 | }
216 |
217 | /*
218 | * Performs one iteration of the simulation. First updating the
219 | * position of all the particles and resolving the constraints and
220 | * collisions.
221 | */
222 | public void update(float sx, float sy, long now) {
223 | // update the system's positions
224 | updatePositions(sx, sy, now);
225 |
226 | // We do no more than a limited number of iterations
227 | final int NUM_MAX_ITERATIONS = 10;
228 |
229 | /*
230 | * Resolve collisions, each particle is tested against every
231 | * other particle for collision. If a collision is detected the
232 | * particle is moved away using a virtual spring of infinite
233 | * stiffness.
234 | */
235 | boolean more = true;
236 | final int count = mBalls.length;
237 | for (int k = 0; k < NUM_MAX_ITERATIONS && more; k++) {
238 | more = false;
239 | for (int i = 0; i < count; i++) {
240 | Particle curr = mBalls[i];
241 | for (int j = i + 1; j < count; j++) {
242 | Particle ball = mBalls[j];
243 | float dx = ball.mPosX - curr.mPosX;
244 | float dy = ball.mPosY - curr.mPosY;
245 | float dd = dx * dx + dy * dy;
246 | // Check for collisions
247 | if (dd <= sBallDiameter2) {
248 | /*
249 | * add a little bit of entropy, after nothing is
250 | * perfect in the universe.
251 | */
252 | dx += ((float) Math.random() - 0.5f) * 0.0001f;
253 | dy += ((float) Math.random() - 0.5f) * 0.0001f;
254 | dd = dx * dx + dy * dy;
255 | // simulate the spring
256 | final float d = (float) Math.sqrt(dd);
257 | final float c = (0.5f * (sBallDiameter - d)) / d;
258 | final float effectX = dx * c;
259 | final float effectY = dy * c;
260 | curr.mPosX -= effectX;
261 | curr.mPosY -= effectY;
262 | ball.mPosX += effectX;
263 | ball.mPosY += effectY;
264 | more = true;
265 | }
266 | }
267 | curr.resolveCollisionWithBounds();
268 | }
269 | }
270 | }
271 |
272 | public int getParticleCount() {
273 | return mBalls.length;
274 | }
275 |
276 | public float getPosX(int i) {
277 | return mBalls[i].mPosX;
278 | }
279 |
280 | public float getPosY(int i) {
281 | return mBalls[i].mPosY;
282 | }
283 | }
284 |
285 | public void startSimulation() {
286 | /*
287 | * It is not necessary to get accelerometer events at a very high
288 | * rate, by using a slower rate (SENSOR_DELAY_UI), we get an
289 | * automatic low-pass filter, which "extracts" the gravity component
290 | * of the acceleration. As an added benefit, we use less power and
291 | * CPU resources.
292 | */
293 | mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
294 | }
295 |
296 | public void stopSimulation() {
297 | mSensorManager.unregisterListener(this);
298 | }
299 |
300 | public SimulationView(Context context) {
301 | super(context);
302 | mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
303 |
304 | DisplayMetrics metrics = new DisplayMetrics();
305 | getWindowManager().getDefaultDisplay().getMetrics(metrics);
306 | mXDpi = metrics.xdpi;
307 | mYDpi = metrics.ydpi;
308 | mMetersToPixelsX = mXDpi / 0.0254f;
309 | mMetersToPixelsY = mYDpi / 0.0254f;
310 |
311 | // rescale the ball so it's about 0.5 cm on screen
312 | mDstWidth = (int) (sBallDiameter * mMetersToPixelsX + 0.5f);
313 | mDstHeight = (int) (sBallDiameter * mMetersToPixelsY + 0.5f);
314 | mParticleSystem = new ParticleSystem();
315 |
316 | Options opts = new Options();
317 | opts.inDither = true;
318 | opts.inPreferredConfig = Bitmap.Config.RGB_565;
319 | }
320 |
321 | @Override
322 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
323 | // compute the origin of the screen relative to the origin of
324 | // the bitmap
325 | mXOrigin = (w - mDstWidth) * 0.5f;
326 | mYOrigin = (h - mDstHeight) * 0.5f;
327 | mHorizontalBound = ((w / mMetersToPixelsX - sBallDiameter) * 0.5f);
328 | mVerticalBound = ((h / mMetersToPixelsY - sBallDiameter) * 0.5f);
329 | }
330 |
331 | @Override
332 | public void onSensorChanged(SensorEvent event) {
333 | if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
334 | return;
335 | /*
336 | * record the accelerometer data, the event's timestamp as well as
337 | * the current time. The latter is needed so we can calculate the
338 | * "present" time during rendering. In this application, we need to
339 | * take into account how the screen is rotated with respect to the
340 | * sensors (which always return data in a coordinate space aligned
341 | * to with the screen in its native orientation).
342 | */
343 |
344 | switch (mDisplay.getRotation()) {
345 | case Surface.ROTATION_0:
346 | mSensorX = event.values[0];
347 | mSensorY = event.values[1];
348 | break;
349 | case Surface.ROTATION_90:
350 | mSensorX = -event.values[1];
351 | mSensorY = event.values[0];
352 | break;
353 | case Surface.ROTATION_180:
354 | mSensorX = -event.values[0];
355 | mSensorY = -event.values[1];
356 | break;
357 | case Surface.ROTATION_270:
358 | mSensorX = event.values[1];
359 | mSensorY = -event.values[0];
360 | break;
361 | }
362 | }
363 |
364 | @Override
365 | protected void onDraw(Canvas canvas) {
366 | /*
367 | * Compute the new position of our object, based on accelerometer
368 | * data and present time.
369 | */
370 | final ParticleSystem particleSystem = mParticleSystem;
371 | final long now = System.currentTimeMillis();
372 | final float sx = mSensorX;
373 | final float sy = mSensorY;
374 |
375 | particleSystem.update(sx, sy, now);
376 |
377 | final float xc = mXOrigin;
378 | final float yc = mYOrigin;
379 | final float xs = mMetersToPixelsX;
380 | final float ys = mMetersToPixelsY;
381 | final int count = particleSystem.getParticleCount();
382 | for (int i = 0; i < count; i++) {
383 | /*
384 | * We transform the canvas so that the coordinate system matches
385 | * the sensors coordinate system with the origin in the center
386 | * of the screen and the unit is the meter.
387 | */
388 | final float x = xc + particleSystem.getPosX(i) * xs;
389 | final float y = yc - particleSystem.getPosY(i) * ys;
390 | particleSystem.mBalls[i].setTranslationX(x);
391 | particleSystem.mBalls[i].setTranslationY(y);
392 | }
393 |
394 | // and make sure to redraw asap
395 | invalidate();
396 | }
397 |
398 | @Override
399 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
400 | }
401 | }
402 | }
403 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_snake_and_ladder_board.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
37 |
38 |
42 |
43 |
47 |
48 |
52 |
53 |
57 |
58 |
62 |
63 |
67 |
68 |
72 |
73 |
77 |
78 |
82 |
83 |
87 |
88 |
92 |
93 |
97 |
98 |
102 |
103 |
107 |
108 |
112 |
113 |
117 |
118 |
122 |
123 |
127 |
128 |
132 |
133 |
137 |
138 |
142 |
143 |
147 |
148 |
152 |
153 |
157 |
158 |
162 |
163 |
167 |
168 |
172 |
173 |
177 |
178 |
182 |
183 |
187 |
188 |
189 |
193 |
194 |
198 |
199 |
203 |
204 |
208 |
209 |
213 |
214 |
218 |
219 |
223 |
224 |
228 |
229 |
233 |
234 |
238 |
239 |
243 |
244 |
248 |
249 |
253 |
254 |
258 |
259 |
263 |
264 |
268 |
269 |
273 |
274 |
278 |
279 |
283 |
284 |
288 |
289 |
293 |
294 |
298 |
299 |
303 |
304 |
308 |
309 |
313 |
314 |
318 |
319 |
323 |
324 |
328 |
329 |
333 |
334 |
338 |
339 |
343 |
344 |
348 |
349 |
353 |
354 |
358 |
359 |
363 |
364 |
368 |
369 |
373 |
374 |
378 |
379 |
383 |
384 |
388 |
389 |
393 |
394 |
398 |
399 |
403 |
404 |
408 |
409 |
413 |
414 |
418 |
419 |
423 |
424 |
428 |
429 |
433 |
434 |
438 |
439 |
443 |
444 |
448 |
449 |
453 |
454 |
458 |
459 |
463 |
464 |
468 |
469 |
473 |
474 |
478 |
479 |
483 |
484 |
488 |
489 |
493 |
494 |
498 |
499 |
503 |
504 |
508 |
509 |
513 |
514 |
518 |
519 |
523 |
524 |
528 |
529 |
533 |
534 |
538 |
539 |
540 |
541 |
542 |
549 |
550 |
559 |
560 |
570 |
571 |
581 |
582 |
589 |
590 |
600 |
601 |
611 |
612 |
621 |
622 |
623 |
624 |
625 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_chess_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
32 |
33 |
38 |
39 |
44 |
45 |
50 |
51 |
56 |
57 |
62 |
63 |
68 |
69 |
75 |
76 |
81 |
82 |
88 |
89 |
94 |
99 |
100 |
105 |
110 |
111 |
116 |
117 |
122 |
123 |
128 |
129 |
134 |
135 |
140 |
141 |
146 |
147 |
152 |
153 |
158 |
159 |
164 |
165 |
170 |
171 |
176 |
177 |
182 |
183 |
188 |
189 |
194 |
195 |
200 |
201 |
206 |
207 |
212 |
217 |
218 |
223 |
224 |
229 |
230 |
235 |
236 |
241 |
242 |
247 |
248 |
253 |
254 |
259 |
260 |
265 |
266 |
271 |
272 |
277 |
278 |
283 |
284 |
289 |
290 |
295 |
300 |
301 |
306 |
307 |
312 |
313 |
318 |
323 |
324 |
329 |
330 |
335 |
336 |
341 |
342 |
347 |
348 |
353 |
354 |
359 |
360 |
365 |
366 |
371 |
372 |
377 |
378 |
383 |
384 |
389 |
390 |
395 |
396 |
401 |
402 |
407 |
408 |
413 |
414 |
415 |
425 |
426 |
434 |
435 |
443 |
444 |
452 |
453 |
461 |
462 |
470 |
471 |
479 |
480 |
488 |
489 |
497 |
498 |
506 |
507 |
515 |
516 |
524 |
525 |
533 |
534 |
542 |
543 |
551 |
552 |
560 |
561 |
569 |
570 |
578 |
579 |
587 |
588 |
596 |
597 |
605 |
606 |
614 |
615 |
623 |
624 |
632 |
633 |
641 |
642 |
650 |
651 |
659 |
660 |
668 |
669 |
677 |
678 |
686 |
687 |
695 |
696 |
704 |
705 |
713 |
714 |
722 |
723 |
731 |
732 |
740 |
741 |
749 |
750 |
758 |
759 |
767 |
768 |
776 |
777 |
785 |
786 |
794 |
795 |
803 |
804 |
812 |
813 |
821 |
822 |
830 |
831 |
839 |
840 |
848 |
849 |
857 |
858 |
866 |
867 |
875 |
876 |
884 |
885 |
893 |
894 |
902 |
903 |
911 |
912 |
920 |
921 |
929 |
930 |
938 |
939 |
947 |
948 |
956 |
957 |
965 |
966 |
974 |
975 |
983 |
984 |
992 |
993 |
1001 |
1002 |
1003 |
1013 |
1014 |
1026 |
1027 |
1042 |
1043 |
1058 |
1059 |
1074 |
1075 |
1090 |
1091 |
1092 |
1093 |
1108 |
1109 |
1110 |
--------------------------------------------------------------------------------