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

Spring sql-error-codes.xml does not show correct exception on timeout
Approaches to Android MediaPlayer state mismatch error on isPlaying()?
Issue with Android SQLite cursor while reading table having blob content
Is there a non-jdk implementation for a concurrent weak hash map?
how to immplement dynamic parameter on Jmeter with java
What to do when catching e(rror) in Java
apache.servicemix.bundles.quickfix - Attempting to create standalone NewOrderSingle object throws exception
Printing a message if a char has more than one symbol(using char, not String)
Stop Eclipse to show documents when mouse is hover over words in double quotation
What exactly does Android's #hide annotation do?
Java - Server listens on many ports
Should I use one SQLiteHelper for all SQLiteDatabases in my app or one for each one of them?
no connection between postgresql DB and eclipse
How to change Android status bar color in all activities together
Writing sql query in hibernate
How to initialize all threads of a fixed thread pool before submitting any tasks? (JAVA)

Categories

HOME
amazon-ec2
minimum-spanning-tree
azure-data-factory
react-virtualized
view
iterator
lodash
twitter-bootstrap-4
acquia
cross-validation
add
vb.net-2010
messages
workload-scheduler
telephony
reactcsstransitiongroup
emulator
conemu
orleans
graphicsmagick
sylius
sox
xpages-ssjs
pepper
libuv
junit5
google-cloud-endpoints-v2
pdb
fog
form-data
cloud-code
devextreme
scaffold
x11-forwarding
lto
vapor
unobtrusive-validation
document.write
lumberjack
elmah
jvm-languages
long-polling
osx-mavericks
network-flow
hls.js
return-value
media-player
capacity
pillow
specrun
pycaffe
abcpdf9
angular-cache
heidisql
phishing
multi-level
mikroc
login-control
skobbler-maps
skype4py
oauth2client
netmq
separator
computer-algebra-systems
generic-programming
jsapi
gadt
winddk
document-classification
onactivityresult
google-reader
sgen
yorick
marmalade
dealloc
bundles
datagridviewcolumn
dir
dotnetnuke-5
android-screen-support
robotics-studio
angularjs-controller
ohm
pendrive
spyware
invite
datareader
cxxtest
asp.net-mvc-areas
routedevent
noscript
gacutil

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
Mobile App
Mobile App
Mobile App