Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I hope I help with the problem, though my solution might not answer exactly what you ask. I am not familiar with Swing, and usually my android development is done with Adobe Air. But by the powers of Google and my experience I shall try to help.

How to get the screen resolution using Java and Swing: http://stackoverflow.com/questions/3680221/screen-resolution-javahttps://stackoverflow.com/questions/3680221/screen-resolution-java

As for the number of tiles you need, that is a game design decision. For simplicity you can decide that all your levels will require a fixed tile size. Based on that you can then divide the screen width and height by the fixed number of tiles you require. So if the screen is 600 X 600 pixels and you require a 10 X 10 grid; each tile would be 60 X 60 pixels.

For added simplicity you could create the tiles at some arbitrary size and add them to the canvas and then scale the canvas to meet your screen size requirements.

Additionally you will want to take into account any UI elements you will have. Using the example above, if you decided to save 50 pixels around the border for UI elements, you would have 500 X 500 to work with making the tiles 50 X 50 pixels.

I hope I help with the problem, though my solution might not answer exactly what you ask. I am not familiar with Swing, and usually my android development is done with Adobe Air. But by the powers of Google and my experience I shall try to help.

How to get the screen resolution using Java and Swing: http://stackoverflow.com/questions/3680221/screen-resolution-java

As for the number of tiles you need, that is a game design decision. For simplicity you can decide that all your levels will require a fixed tile size. Based on that you can then divide the screen width and height by the fixed number of tiles you require. So if the screen is 600 X 600 pixels and you require a 10 X 10 grid; each tile would be 60 X 60 pixels.

For added simplicity you could create the tiles at some arbitrary size and add them to the canvas and then scale the canvas to meet your screen size requirements.

Additionally you will want to take into account any UI elements you will have. Using the example above, if you decided to save 50 pixels around the border for UI elements, you would have 500 X 500 to work with making the tiles 50 X 50 pixels.

I hope I help with the problem, though my solution might not answer exactly what you ask. I am not familiar with Swing, and usually my android development is done with Adobe Air. But by the powers of Google and my experience I shall try to help.

How to get the screen resolution using Java and Swing: https://stackoverflow.com/questions/3680221/screen-resolution-java

As for the number of tiles you need, that is a game design decision. For simplicity you can decide that all your levels will require a fixed tile size. Based on that you can then divide the screen width and height by the fixed number of tiles you require. So if the screen is 600 X 600 pixels and you require a 10 X 10 grid; each tile would be 60 X 60 pixels.

For added simplicity you could create the tiles at some arbitrary size and add them to the canvas and then scale the canvas to meet your screen size requirements.

Additionally you will want to take into account any UI elements you will have. Using the example above, if you decided to save 50 pixels around the border for UI elements, you would have 500 X 500 to work with making the tiles 50 X 50 pixels.

Source Link

I hope I help with the problem, though my solution might not answer exactly what you ask. I am not familiar with Swing, and usually my android development is done with Adobe Air. But by the powers of Google and my experience I shall try to help.

How to get the screen resolution using Java and Swing: http://stackoverflow.com/questions/3680221/screen-resolution-java

As for the number of tiles you need, that is a game design decision. For simplicity you can decide that all your levels will require a fixed tile size. Based on that you can then divide the screen width and height by the fixed number of tiles you require. So if the screen is 600 X 600 pixels and you require a 10 X 10 grid; each tile would be 60 X 60 pixels.

For added simplicity you could create the tiles at some arbitrary size and add them to the canvas and then scale the canvas to meet your screen size requirements.

Additionally you will want to take into account any UI elements you will have. Using the example above, if you decided to save 50 pixels around the border for UI elements, you would have 500 X 500 to work with making the tiles 50 X 50 pixels.