Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using LibGDX Vector3 for storing non Vector data  (Read 412 times)
0 Members and 1 Guest are viewing this topic.
Offline ImTroyMiller
« Posted 2014-05-08 20:04:29 »

I've been using Vector3 to store X-axis, Y-axis, and the rotation, of items in my game.  I'm not using any of the other methods that this class provides.

Will this cause any performance issues?

Should I just made a small class that stores three floats, has three assessor methods, and three mutator methods?   
Offline pitbuller
« Reply #1 - Posted 2014-05-08 20:31:36 »

How about three floats in your item class. It's seems rather clunky that you use someVector.z as rotation anme instead of just rotation.
Offline saucymeatman
« Reply #2 - Posted 2014-05-08 20:45:39 »

The answer is no. There is no way that it would cause performance issues Smiley
Vector classes are often used to store all kinds of data, and they are not any slower to use than if you just defined a class that had xAxis yAxis and rotation. However, as (I think?) pitbuller was trying to point out, it might be more clear or more readable if you atored the data as members in your class with names that described their purpose.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ImTroyMiller
« Reply #3 - Posted 2014-05-08 20:49:45 »

Well, I've thought about that, but it's not just that one Vector3 holding those three floats, there's another Vector3 and a couple of Vector2, all holding different information.
Offline Slyth2727
« Reply #4 - Posted 2014-05-08 20:55:33 »

Well I'd just create a wrapper class, called Rotation3f or something along those lines. You keep a nice name, but have all the functions like linear interpolation and stuff.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline ImTroyMiller
« Reply #5 - Posted 2014-05-15 07:56:45 »

I made two classes, one stores XYZ positions, and the other stores two X positions and two Y positions.  Both have getters and setters.

I'm making arrays of these two classes  to store the information in, opposed to making a three or four dimensional array and grabbing the information.

The getters and setters make it easier to write my code as oppose to remembering that
  • is X and [1] is Y.

Is this good practice or should I avoid it?
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (39 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (36 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!