Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
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 2702 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.
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  

Riven (439 views)
2019-09-04 15:33:17

hadezbladez (5297 views)
2018-11-16 13:46:03

hadezbladez (2213 views)
2018-11-16 13:41:33

hadezbladez (5565 views)
2018-11-16 13:35:35

hadezbladez (1156 views)
2018-11-16 13:32:03

EgonOlsen (4592 views)
2018-06-10 19:43:48

EgonOlsen (5467 views)
2018-06-10 19:43:44

EgonOlsen (3128 views)
2018-06-10 19:43:20

DesertCoockie (4023 views)
2018-05-13 18:23:11

nelsongames (4741 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 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‑
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!