Skip to content

Commit b103585

Browse files
committed
added the new properties for v1.1
1 parent 7b01d79 commit b103585

File tree

113 files changed

+96
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+96
-33
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/render.experimental.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/firstprojects/catchtheobject/MainActivity.java

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ public class MainActivity extends AppCompatActivity {
2828

2929
private boolean isGameStarted = false;
3030

31-
//private final ArrayList<Integer> backgrounds = new ArrayList<>();
31+
private final ArrayList<Integer> backgrounds = new ArrayList<>();
3232

33-
private final ArrayList<Integer> colors = new ArrayList<>();
3433
private int selectedBackgroundNumber = 0;
3534

3635
private void changeBackground(int index){
37-
binding.backgroundOfActivity.setBackgroundColor(colors.get(index));
38-
// binding.backgroundOfActivity.setBackgroundResource(backgrounds.get(index));
36+
binding.backgroundOfActivity.setBackgroundResource(backgrounds.get(index));
3937
}
4038

4139
private int score = 0;
@@ -59,8 +57,6 @@ private enum Directions{
5957
DOWN_RIGHT,
6058
LEFT,
6159
RIGHT,
62-
CEILING,
63-
BOTTOM
6460
}
6561

6662
private final DisplayMetrics metrics = new DisplayMetrics();
@@ -83,25 +79,25 @@ private int getRandom(int from , int to){
8379
private Directions getCurrentDirection() {
8480

8581
if(velocity > 0 && horizontalVelocity >= 0){
86-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.up_right)); //***
82+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.left_up)); //***
8783
return Directions.UP_RIGHT;
8884
}else if(velocity < 0 && horizontalVelocity >= 0){
89-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.down_right)); //***
85+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.right_down)); //***
9086
return Directions.DOWN_RIGHT;
9187
}else if(velocity < 0 && horizontalVelocity <= 0){
92-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.down_left)); //***
88+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.left_down)); //***
9389
return Directions.DOWN_LEFT;
9490
}else if(velocity > 0 && horizontalVelocity <= 0){
9591
//THIS IS JUST ON THE LEFT DIRECTION.!!
96-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.up_left)); //***
92+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.right_up)); //***
9793
return Directions.UP_LEFT;
9894
}else{
9995
//velocity == 0
10096
if(horizontalVelocity <= 0){
101-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.up_left));
97+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.left));
10298
return Directions.LEFT;
10399
}else{
104-
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.up_right));
100+
binding.movingObject.setImageDrawable( ContextCompat.getDrawable(this,R.drawable.right));
105101
return Directions.RIGHT;
106102
}
107103
}
@@ -143,16 +139,15 @@ public void run() {
143139
}else{
144140
if(targetY > getScreenHeight){
145141

146-
currentDirection = Directions.BOTTOM;
147-
binding.movingObject.setImageDrawable(ContextCompat.getDrawable(MainActivity.this,R.drawable.up_right));
142+
143+
binding.movingObject.setImageDrawable(ContextCompat.getDrawable(MainActivity.this,R.drawable.right_up));
148144

149145
binding.movingObject.setY(getScreenHeight - 1f);
150146
velocity = getRandom(getScreenHeight/50,getScreenHeight/35);
151147

152148
}else if(targetY < 0){
153149

154-
currentDirection = Directions.CEILING;
155-
binding.movingObject.setImageDrawable(ContextCompat.getDrawable(MainActivity.this,R.drawable.up_left));
150+
binding.movingObject.setImageDrawable(ContextCompat.getDrawable(MainActivity.this,R.drawable.left_up));
156151

157152
binding.movingObject.setY(0.1f);
158153
velocity = - getRandom(getScreenHeight/50,getScreenHeight/35);
@@ -181,23 +176,12 @@ private void theWayOfMovement() {
181176
//INITILIZATION PROCESS
182177
private void definition(){
183178

184-
colors.add(ContextCompat.getColor(this,R.color.first_bg_color));
185-
colors.add(ContextCompat.getColor(this,R.color.second_bg_color));
186-
colors.add(ContextCompat.getColor(this,R.color.third_bg_color));
187-
colors.add(ContextCompat.getColor(this,R.color.fourth_bg_color));
188179

189-
/*
190180
backgrounds.add(R.drawable.background1);
191181
backgrounds.add(R.drawable.background2);
192182
backgrounds.add(R.drawable.background3);
193183
backgrounds.add(R.drawable.background4);
194184
backgrounds.add(R.drawable.background5);
195-
backgrounds.add(R.drawable.background6);
196-
backgrounds.add(R.drawable.background7);
197-
backgrounds.add(R.drawable.background8);
198-
backgrounds.add(R.drawable.background9);
199-
*/
200-
201185

202186
getWindowManager().getDefaultDisplay().getMetrics(metrics);
203187

@@ -219,7 +203,7 @@ private void definition(){
219203
binding.startGameButton.setOnClickListener(new View.OnClickListener() {
220204
@Override
221205
public void onClick(View view) {
222-
startGame(30);
206+
startGame(60);
223207
}
224208
});
225209

@@ -236,7 +220,7 @@ public void onClick(View view) {
236220
if(selectedBackgroundNumber > 0){
237221
selectedBackgroundNumber--;
238222
}else{
239-
selectedBackgroundNumber = colors.size() - 1;
223+
selectedBackgroundNumber = backgrounds.size() - 1;
240224
}
241225
changeBackground(selectedBackgroundNumber);
242226
}
@@ -245,7 +229,7 @@ public void onClick(View view) {
245229
binding.arrowRightButton.setOnClickListener(new View.OnClickListener() {
246230
@Override
247231
public void onClick(View view) {
248-
if(selectedBackgroundNumber < colors.size() - 1){
232+
if(selectedBackgroundNumber < backgrounds.size() - 1){
249233
selectedBackgroundNumber++;
250234
}else{
251235
selectedBackgroundNumber = 0;
3.32 MB

0 commit comments

Comments
 (0)