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

Calendar Event via Intent does not set Start Date and End Date
Combining two accounts [closed]
Casting list of objects to list of maps in java [duplicate]
JComboBox to display multiple lines of text
RotatedRect to Java Ellipse2D or similar - OpenCV
Need to restart Java method up to three times for username & password log-in system
How can I change default elements color android layout?
Guice Request-scoped injection without a servlet (in an RPC server)
RPN Calculator Using Stacks
3D Fourier Transform using JTransforms in Android Studio
Converting RGB byte array to BufferedImage
Creating a term-by-file document matrix from a set of documents
Android POST request with JSON
Headless Selenium test which fills out a form?
How can I extract url from json data with escaped “\” in java
How to make the following sliders for a RGB program

Categories

HOME
client
wso2-am
testng
asp.net-core
debugging
proxy
omnet++
server
hashmap
setup-deployment
analysis
malloc
swagger-ui
multiple-records
adfs
iggrid
u-sql
remote-access
flux
sms-gateway
openedx
crystal-reports-2008
viewport
sox
facebook-access-token
newline
gsoap
nouislider
key-value-observing
http-get
calibre
usbserial
http-referer
force-layout
appfabric
adobe-premiere
qwerty
ssjs
preconditions
jvm-languages
segment
rails-routing
pnotify
nodebb
typed-lambda-calculus
objective-c-swift-bridge
abcpdf9
setuptools
url-pattern
nxt
removechild
slicknav
dstu2-fhir
measures
contact-list
prettytensor
uid
cannon.js
cyclomatic-complexity
libressl
qpainter
xcode-6.2
preferences
document-classification
elliptic-curve
expected-exception
transcoding
didselectrowatindexpath
ember-charts
page-layout
jmapviewer
ora-00911
specification-pattern
gdata-api
dsn
adk
external-accessory
hirefire
xtype
asp.net-mvc-areas
sortable-tables
perfect-hash
spec#
w3wp

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