# How to make my Android Game compatible with all screen sizes

**URL:** https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004
**Category:** Processing for Android
**Created:** [January 31, 2019, 8:30pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004 "2019-01-31T20:30:28Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Alexander](https://discourse.processing.org/u/Alexander)
#### Post date: [January 31, 2019, 8:30pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/1 "2019-01-31T20:30:28Z")

</div>

Hello guys, i have a big problem. I am almost ready to publish my first game in google play, but i cannot figure out how to make the app compatible with all the different sizes of screens (1280x720, 1920x1080 etc.) . Here is a simple examble of what i am trying to do:

fullScreen(P2D);

if(mousePressed && mouseX \> width - 89/100 \* width && mouseX \< width - 70/100 \* width && mouseY \> height - 26/100 \* height && mouseY \< height - 12/100 \* height){

```
                               background(0);

```

So, the “if” represents a red button that is going to start the game. I started the game with a 1280x720 scren, but i remembered that i want to make the app compatible with all devices, so:

The first “if” was this:

```
if(mousePressed && mouseX > 140 && mouseX < 390 && mouseY > 530 && mouseY < 630){
   
                                background(0);

```

So i found how many % of 1280 is 140 and replaced it with “if(…&& mouseX \> width - 89/100 \* width…” and i did the same thing (with different percentages of course) with all the mouseY and mouseX’s, but it didn’t work… I really don’t know what to do, please help me! Thanks!

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [January 31, 2019, 8:39pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/2 "2019-01-31T20:39:39Z")

</div>

Can you please try to be more specific? What do you mean when you say it didn’t work?

Can you post a small example program that demonstrates the problem?

---

<div class="post-metadata">

### Author: ![Alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Alexander](https://discourse.processing.org/u/Alexander)
#### Post date: [January 31, 2019, 8:43pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/3 "2019-01-31T20:43:07Z")

</div>

void setup(){  
fullScreen(P2D);  
}

void draw(){  
if(mousePressed && mouseX \> width - 89/100 \* width && mouseX \< width - 70/100 \* width && mouseY \> height - 26/100 \* height && mouseY \< height - 12/100 \* height){

background(0);

The idea is when i press that part of the screen, to set the background to 0.

There’s too much code to post it all here

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [January 31, 2019, 8:47pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/4 "2019-01-31T20:47:56Z")

</div>

Sounds like you need to [debug your code](https://happycoding.io/tutorials/processing/debugging). Try splitting that line up into multiple steps and printing out the values of each step.

Specifically, I’m guessing that your division is not working how you expect.

---

<div class="post-metadata">

### Author: ![Alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Alexander](https://discourse.processing.org/u/Alexander)
#### Post date: [January 31, 2019, 8:59pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/5 "2019-01-31T20:59:21Z")

</div>

So, when i do that, it tells me my value for mouseX is 1920, but when i post the same calculation in google, it tells me that its 140. I don’t know why.

---

<div class="post-metadata">

### Author: ![Alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Alexander](https://discourse.processing.org/u/Alexander)
#### Post date: [January 31, 2019, 9:14pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/6 "2019-01-31T21:14:18Z")

</div>

uh, i used 0.89 instead of 89/100 and it worked. Strange. Thanks for the answer!

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [January 31, 2019, 9:26pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/7 "2019-01-31T21:26:35Z")

</div>

Look into **integer division**. Basically, an `int` value can only hold whole numbers, without any decimal places. Since `70` and `100` are both `int` values, the result is an `int` as well. And since it can’t hold a decimal place, it ends up being `0` instead of `0.7`.

Try it out with a simpler example:

```auto
int x = 70;
int y = 100;
int z = x / y;
println(z);

```

---

<div class="post-metadata">

### Author: ![Alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Alexander](https://discourse.processing.org/u/Alexander)
#### Post date: [January 31, 2019, 9:49pm UTC](https://discourse.processing.org/t/how-to-make-my-android-game-compatible-with-all-screen-sizes/8004/8 "2019-01-31T21:49:53Z")

</div>

I figured it out, thanks alot!
