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

How to run CPU intensive parallel tasks with Vert.X in Java
How to pass ArrayList of different types to method?
Finding the last two digits before the decimal point for the number (4+sqrt(11))^n
Printing JTextArea [closed]
Number stored as text warning in excel using POI
How to atomically check TWO AtomicBooleans in Java in one safe operation without a synchronized block (i.e. low cost locks)?
Change default charset to UTF-8
Spring Javamail properties from Database
Reverse the rows of a 2d array
switching between multiple JPanels in CardLayout
Pattern Matching Algorithm for Serial Numbers
Call different methods depending on input parameters
Convert Multiset to a Map
Maven: Using a project folder as a repository for lib
java.lang.ClassNotFoundException: org.elasticsearch.common.transport.TransportAddress
Call a method before destroySession in Java?

Categories

HOME
date
gerrit
keras
isabelle
server
kde
comparison
smarty
session
syntax
rsyslog
react-redux
jpeg
fingerprint
serverspec
esper
ssl-client-authentication
node-pdfkit
here-api
handsontable
decimal
nhibernate-envers
nas
zapier
paging
css-animations
cultureinfo
autosys
java-7
tdd
cas
maxmind
elasticsearch-ruby
msys2
windows-server-2000
gitignore
quote
gsoap
ioio
titanium-mobile
google-sites-2016
hexo
vxworks
dosbox
adobe-premiere
twitch
hp-ux
sql-server-agent
texmaker
node-gyp
firebase-admin
fakeiteasy
keydown
scorm
long-polling
xml-documentation
jquery-validate
return-value
togetherjs
csound
snmptrapd
qtwebview
jspdf-autotable
dwscript
crosswalk-runtime
google-feed-api
ado.net-entity-data-model
home-directory
mikroc
pcf
firebaseui
gstreamer-0.10
simplewebrtc
make-install
livequery
pagerank
ipconfig
separator
ruby-2.2
django-unittest
myo
mmc
composite
tablelayout
android-nested-fragment
nsbutton
app42
typo3-neos
intentservice
terminal-services
mysqltuner
opcache
gwt-rpc
hungarian-algorithm
delphi-6
referrer
broken-links
cascalog
tridion-worldserver
wse3.0
buildr
boost-filesystem
servicehost
sortable-tables
gamequery
rescale
exchange-server-2003
nerddinner
3gp

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