java


How to set Abitrary Units properly?


I'm currently working on a game where you have to avoid asteroids. I started to use arbitrary units.
public final static int WIDTH = 100, HEIGHT = 100;
Additionally, I'm using an OrthographicCamera:
float aspectratio = 16/10;
cam = new OrthographicCamera(100, 100 * aspectratio);
cam.position.set(cam.viewportWidth / 2f, cam.viewportHeight / 2f, 0);
cam.update();
In the game screen, the asteroids look deformed:
That's a problem of your Viewport. Have a look at this page. For example, you can use a FitViewport that scales your game as much as possible to fit the screen, but there may be black bars.
Your aspect is off. Notice your planets aren't round either. Your viewport is 500x400, which is a 5:4 aspect, you want 16:10 aspect.
Try changing
cam = new OrthographicCamera(500, 250 * aspectratio);
to
cam = new OrthographicCamera(500 * aspectratio, 500);
that will give you a viewport of 800x500, or 16:10 aspect

Related Links

Can javascript be used to render web pages
can we use super keyword within the main() class in java? [duplicate]
env.getProperty not working Spring PropertyPlaceholderConfigurer
ExceptionBug in java project?
Android app with onClickListener not working
Trouble with using UNICODE symbols in Java
How to delete in one time few buttons or text fields?
SimpleJDBCCall class parameter passing
Avoid Java compiler optimization of a loop and an if statement
I have a string variable and another string assigned to same variable. Then how to get old string?
I want to compare two versions of data from a table using JAVA and display the differences on a UI.What can be the best way to approach this?
Is there any sense in access modifiers for fields of the private inner class?
SQLite problems in Android, “no such table” error
Spring security protect pointcut using bean profiles duplicate definition
Regex - trouble matching the pattern “(cmd: )”
All possible combinations and subsets of an array in java

Categories

HOME
webpack
isabelle
leon
callback
serverspec
dacpac
windows-azure-storage
n-gram
moonmail
carthage
workload-scheduler
reactcsstransitiongroup
reactive-cocoa
orleans
ehcache
dcevm
cultureinfo
blazemeter
crystal-reports-2010
opentype
windows-server-2000
gsmcomm
frame
http-status-code-503
protovis
uiswipegesturerecognizer
wallpaper
android-ble
space-complexity
xenforo
ansible-playbook
webdriver-manager
ruby-on-rails-3.1
core-plot
glew
botbuilder
executenonquery
user-accounts
rainbowtable
azure-application-gateway
filepicker
qsslsocket
python-cryptography
linode
spring-cache
angular-strap
deadbolt-2
adxstudio-portals
qpid
angstrom-linux
markojs
prettytensor
make-install
sdf
livequery
freedesktop.org
lib.web.mvc
qdialog
spidermonkey
purge
dukescript
android-listview
cakephp-3.1
splash
key-management
clipperlib
e10s
nsbutton
onactivityresult
has-many-through
system.net.webexception
algebraic-data-types
flexmojos
multiprocessor
ccss
ms-project-server-2010
spring-io
quartz-graphics
delphi-6
wsdl-2.0
simba
bitsharp
external-accessory
django-tagging
appendto
floating
cxxtest
yslow
zend-translate
.nettiers
nintendo-ds

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html