Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (710) Games in Android Showcase (212) games submitted by our members Games in WIP (784) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1] 2
 ignore  |  Print
 Fix "my" method to make an object A move toward X,Y coordinates  (Read 7027 times) 0 Members and 1 Guest are viewing this topic.
alaslipknot
 « Posted 2013-04-20 21:03:18 »

hello,
in order to move my rectangle toward the mouse X & Y coordinate i created this method
and it kinda work but sometimes it gives a strange behavior
so instead of moving like this (O=object, T=target) :
Quote
(O) *
*
*
*
* (T)
it does something similar to this
Quote
(O)*
*
*
*
*  *  * (T)

i hope you understand what i meant

and here is my methode code
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30 `// tx and ty are the target coordinates   public void move(int tx, int ty) {      // calculate distance to cross      int xdistance;      xdistance = tx - x;      // check if the target point is on the right or on the left      // go to it      // decrements/increments the distance so it will reach zero      // and break the condition      if (xdistance > 0) {         x += s;         xdistance -= s;      } else if (xdistance < 0) {         x -= s;         xdistance += s;      }      // same thing      int ydistance;      ydistance = ty - y;      if (ydistance > 0) {         y += s;         ydistance -= s;      } else if (ydistance < 0) {         y -= s;         ydistance += s;      }   }`

thank you

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #1 - Posted 2013-04-20 21:14:34 »

Normalize the direction vector, then multiply it to the speed you want.

alaslipknot
 « Reply #2 - Posted 2013-04-20 21:52:21 »

Normalize the direction vector, then multiply it to the speed you want.

sorry but what do you mean by "normalize"  ??

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Agro
 « Reply #3 - Posted 2013-04-20 21:52:59 »

Get the length of the vector and then get each component of the vector and divide it by the length.

davedes
 « Reply #4 - Posted 2013-04-20 22:24:33 »

Here is some code for that using LWJGL's Vector2f class:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16 `//mouse is point BVector2f mouse = new Vector2f(Mouse.getX(), Mouse.getY());//get directionVector2f dir = new Vector2f(mouse.x - x, mouse.y - y);//normalize itdir.normalise();//scale the vector based on our movement speedfloat speed = 2f;dir.scale(speed);//move the entity with our new direction vectorx += dir.x;y += dir.y;`

If you're a crazy fool and you're using Java2D, it might look like this...

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23 `//mouse is point Bfloat mx = Mouse.getX();float my = Mouse.getY();//get directionfloat dx = mx - x;float dy = my - y;//normalize itfloat len = (float)Math.sqrt(dx * dx + dy * dy);if (len!=0) {   dx /= len;   dy /= len;}//scale the vector based on our movement speedfloat speed = 2f;dx *= speed;dy *= speed;//move the entity with our new direction vectorx += dx;y += dy;`

You might also need a condition to avoid "flickering" when the entity lies under point B (the mouse).

alaslipknot
 « Reply #5 - Posted 2013-04-20 23:37:51 »

If you're a crazy fool and you're using Java2D, it might look like this...

seriously,
i thought it's better to start learning without any external library
well i need to finish this very tiny small game and then maybe i start to learn LWJGL
ps :
can you post a link for a nice explained tutorial  for LWJGL please ?

thank you

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
davedes
 « Reply #6 - Posted 2013-04-21 00:52:09 »

IMHO there is no point in using Java2D for games nowadays, unless you are competing in Java4K.

If you decide to use LWJGL, you need to build everything from the ground up. This can be complicated and daunting for a newbie, for example:
LWJGL ShaderProgram Utility (See my other LWJGL tutorials here)

A better option would be to use a framework like LibGDX. Not only does LibGDX handle all that low-level stuff for you, it also includes utilities like themable GUI, bitmap font generation, integration with Box2D physics, tiled map loading, particle editor tool, texture atlas management, efficient sprite rendering, and much more.

For getting started with LibGDX:

http://www.java-gaming.org/topics/why-are-people-trying-to-use-java2d-to-make-games/28245/msg/256018/view.html#msg256018

HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #7 - Posted 2013-04-21 00:58:14 »

Start here:
http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_1_(The_Display)
http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_2_(Input)

http://www.cokeandcode.com/index.html?page=tutorials

Then you can try making a game with that.
Then forget the rendering methods because immediate mode is useless for performance.

Then this for VBOs (don't worry about 3D. Just stick to 2D):

Then you can try these:
https://github.com/mattdesl/lwjgl-basics/wiki/SpriteBatch
https://github.com/mattdesl/lwjgl-basics/wiki/FrameBufferObjects

Be aware that this will be a long process. It will probably take many months to learn all that.
I recommend to mix up 2D and 3D games while you're at it.
But at least you'll understand OpenGL properly.
If you want to be lazy and don't care about understanding, use LibGDX.

davedes
 « Reply #8 - Posted 2013-04-21 03:40:05 »

Quote
If you want to be lazy and don't care about understanding, use LibGDX.
This isn't really valid.

You can learn the OpenGL pipeline with LibGDX. In many places it wraps it very thinly, e.g.

 1  2  3  4  5  6  7  8  9  10  11  12  13 `Texture tex = new Texture("data/img.png");// -> glTexImage2D(...)tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);// -> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);// -> glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);tex.drawPixmap(pixels, x, y); // -> glTexSubImage2D(x, y, ... pixels);tex.bind(1);// -> glActiveTexture(GL_TEXTURE1);// -> glBindTexture(GL_TEXTURE_2D, texID);`

You don't need to write the verbose OpenGL boilerplate in oder to understand how shaders and textures work.

Same goes for other areas like ShaderProgram, Mesh, etc. Ultimately LibGDX is just another OpenGL wrapper, and you can use it however you choose.

As I explain in my tutorial series, it may be easier to learn shaders and the programmable pipeline by using a high-level API (LibGDX, lwjgl-basics, etc) rather than getting bogged down on OpenGL boilerplate.

HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #9 - Posted 2013-04-21 03:48:49 »

 1 `Texture tex = new Texture("data/img.png");`

There's a bit more going on in there than just glTexImage2D()

SHC
 « Reply #10 - Posted 2013-04-21 03:55:39 »

This is my Java2D method.

 `moveTo()`

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39 `/** * Moves this object to a specified point with a specific speed. Note that * the velocity used is independent of vertical or horizontal velocities of * this object. *  * @param nx The new x-position * @param ny The new y-position * @param speed The speed with which to move * @return True if the new point has been reached */public boolean moveTo(float nx, float ny, float speed){    boolean _x = false;    boolean _y = false;    int distance = (int) Math.sqrt((double) ((x - nx) * (x - nx) + (y - ny) * (y - ny)));    float vel = Math.min(distance, speed);    float newx = x;    float newy = y;    if (x > nx) {        // We should move left        newx -= vel;    } else if (x < nx) {        // We should move right        newx += vel;    } else {        _x = true;    }    if (y > ny) {        // We should move up        newy -= vel;    } else if (y < ny) {        // We should move down        newy += vel;    } else {        _y = true;    }    x = newx;    y = newy;    return (_x && _y);}`

ClickerMonkey

JGO Coder

Medals: 24

Game Engineer

 « Reply #11 - Posted 2013-04-21 04:05:01 »

 1 `Texture tex = new Texture("data/img.png");`

There's a bit more going on in there than just glTexImage2D()

Why reinvent the wheel? It's better for a newbie to use a framework built by people way more talented.

Also, why aren't you writing in machine code? Or better yet, in binary like a boss?

Your personal preference is calling OpenGL directly, don't devolve someone else to your level =P

(having said that, I like writing everything myself, I'm working on changing that... it's hard)

HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #12 - Posted 2013-04-21 04:22:20 »

Why reinvent the wheel? It's better for a newbie to use a framework built by people way more talented.

[analogy]
Because if I know how a wheel works, I can fix the car quicker if something goes wrong. I can also make the wheel better for me. And because I know how it works too, I can make a wheel out of different materials, some which may be better than the current. In the end, it's much better than relying on a one-size-fits-all wheel that goes slow, because despite being on a F1 car, it was also designed with trucks in mind too.
[/analogy]

Also, I want to be one of those "people way more talented". And I'm sure there are lots of others out there too. I know this for certain, because if there weren't, LibGDX or any other library wouldn't exist today. These people should not be told to just go and download loads of libraries to do things for them. Lazy people will always pick the lazy solution, no matter what you tell them. But talented people need some one to say "it will be good for you" before they go into the relatively unknown.

Quote
Your personal preference is calling OpenGL directly, don't devolve someone else to your level =P

FIFY

65K
 « Reply #13 - Posted 2013-04-21 09:51:33 »

[analogy]
Because if I know how a wheel works, I can fix the car quicker if something goes wrong. I can also make the wheel better for me. And because I know how it works too, I can make a wheel out of different materials, some which may be better than the current. In the end, it's much better than relying on a one-size-fits-all wheel that goes slow, because despite being on a F1 car, it was also designed with trucks in mind too.
[/analogy]
The only problem is, that you wouldn't know how to produce a competing high-tech wheel without looking back on the experience of generations of engineers, using it, learning from it, and then, eventually, if it makes sense, creating your own improved thing.
Using a matured library is not the lazy but the professional way.

Lethal Running - a RPG about a deadly game show held in a futuristic dysoptian society.
SHC
 « Reply #14 - Posted 2013-04-21 10:13:05 »

Sorry, I accidentally clicked upon Appreciate.

matheus23

JGO Kernel

Medals: 138
Projects: 3

You think about my Avatar right now!

 « Reply #15 - Posted 2013-04-21 11:06:23 »

[analogy]
Because if I know how a wheel works, I can fix the car quicker if something goes wrong. I can also make the wheel better for me. And because I know how it works too, I can make a wheel out of different materials, some which may be better than the current. In the end, it's much better than relying on a one-size-fits-all wheel that goes slow, because despite being on a F1 car, it was also designed with trucks in mind too.
[/analogy]
The only problem is, that you wouldn't know how to produce a competing high-tech wheel without looking back on the experience of generations of engineers, using it, learning from it, and then, eventually, if it makes sense, creating your own improved thing.
Using a matured library is not the lazy but the professional way.
Sorry, I accidentally clicked upon Appreciate.

I think the appreciation is deserved.

(Blah blah... I really don't like the 90% quote thing...)

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Regenuluz
 « Reply #16 - Posted 2013-04-21 11:42:22 »

The only problem is, that you wouldn't know how to produce a competing high-tech wheel without looking back on the experience of generations of engineers, using it, learning from it, and then, eventually, if it makes sense, creating your own improved thing.
Using a matured library is not the lazy but the professional way.

So uhm.. If you aren't able to create a high tech thing, without looking back at other high tech things, then how did the first high tech things appear? Magic? And yes, using a full fledged library, before learning any basics is surely laziness. And very *few* on this forum can be called professional game developers.

And I really don't get the whole argument that you should just use a library to do everything for you. Do you use a library to wipe your own ass too(Mmm, paper jokes)? I completely agree that a library can be helpful. But there never should be a point where someone say "Oh, instead of learning how to actually do what you want to do, just use X library, it'll do everything for you, even make your coffee."

For simple 2d, for beginners, there's nothing wrong with learning the robes, before taking on a full fledged library. At least encourage people to THINK before telling them that they can achieve world peace, if they use library X. :/

And where's the need to use LWJGL for any of this?

Here is some code for that using LWJGL's Vector2f class:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16 `//mouse is point BVector2f mouse = new Vector2f(Mouse.getX(), Mouse.getY());//get directionVector2f dir = new Vector2f(mouse.x - x, mouse.y - y);//normalize itdir.normalise();//scale the vector based on our movement speedfloat speed = 2f;dir.scale(speed);//move the entity with our new direction vectorx += dir.x;y += dir.y;`

Here's the same code, using javax.vecmath.Vector2d:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16 `//mouse is point BVector2d mouse = new Vector2d(Mouse.getX(), Mouse.getY());//get directionVector2d dir = new Vector2d(mouse.x - x, mouse.y - y);//normalize itdir.normalize(); // This time, spelled with a z, instead of an s.//scale the vector based on our movement speedfloat speed = 2f;dir.scale(speed);//move the entity with our new direction vectorx += dir.x;y += dir.y;`

And Mouse.getX() / Mouse.getY() could be taken from my own MouseController class.

Teach people to learn some basic stuff, before teaching them to use a library, and please for the love of <whatever you think is epic/awesome/holy/etc>, do NOT involve new people in your wars of what library is the most epic. It's just a waste of time.

@alaslipknot
Do a few basic Java2d games, before moving to a big fat library(The joke here is, that most of what's shipped with Java is already libraries, which is why there's the whole throwing around of "why not write machine code then, if you don't want to use a library, blablabla").

Just get a feel for how things work and how to structure your stuff. Once's you've gotten down sprites, etc. etc., then you can start learning OpenGL and one of the many libraries out there(Of which most use LWJGL internally, as far as I've seen...).

Cheers and good luck!
BrassApparatus

Junior Devvie

 « Reply #17 - Posted 2013-04-21 12:03:05 »

http://i.imgur.com/VKaWX.gif
}

Seriously though, OpenGL is not like learning to fingerpaint. It's vector math, and C, and NDC/camera Space/Clip Space/world space...
Methinks that Java2D sounds fun and informative.
alaslipknot
 « Reply #18 - Posted 2013-04-21 15:24:43 »

Quote from: davedes
IMHO there is no point in using Java2D for games nowadays, unless you are competing in Java4K.
yes i agree with that, but, wouldn't be a wrong i started since the 1st game with LWJGL ??
i mean Java2D is the basics no ?

Quote
If you decide to use LWJGL, you need to build everything from the ground up. This can be complicated and daunting for a newbie,
Exactly, that's why i think that the good way to start is Java2D, then start to learn LWJGL step by step, it would be easier no ?

Quote
A better option would be to use a framework like LibGDX. Not only does LibGDX handle all that low-level stuff for you, it also includes utilities like themable GUI, bitmap font generation, integration with Box2D physics, tiled map loading, particle editor tool, texture atlas management, efficient sprite rendering, and much more.
I don't like that, specially if i don't have the minimum knowledge of basics stuffs, i don't know why i feel like this about using FrameWork or Engines but using them make me feel like am not intelligent enough (or lazy) to start with basics and reach that level one day, it's like using a GameMaker but with more advanced script features

Quote from: HeroesGraveDev
Be aware that this will be a long process. It will probably take many months to learn all that.
I recommend to mix up 2D and 3D games while you're at it.
But at least you'll understand OpenGL properly.
If you want to be lazy and don't care about understanding, use LibGDX.
don't worry, i will handle that
and nope, LibGDX is my last option for now

@SHC
thank you

Quote from: ClickerMonkey
Why reinvent the wheel? It's better for a newbie to use a framework built by people way more talented.
then i will be a newbie forever :p
do you want me to be a newbie forever  ??

Quote from: Regenuluz
@alaslipknot
Do a few basic Java2d games, before moving to a big fat library(The joke here is, that most of what's shipped with Java is already libraries, which is why there's the whole throwing around of "why not write machine code then, if you don't want to use a library, blablabla").

Just get a feel for how things work and how to structure your stuff. Once's you've gotten down sprites, etc. etc., then you can start learning OpenGL and one of the many libraries out there(Of which most use LWJGL internally, as far as I've seen...).

Cheers and good luck!
OKAY  !!

@BrassApparatus
xD
and yeees !! i tried to take a look at few openGl examples, and i was " !! "
we'll understand it one day

thank you guys very much for your help, i really appreciate that

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
ClickerMonkey

JGO Coder

Medals: 24

Game Engineer

 « Reply #19 - Posted 2013-04-21 15:28:02 »

I guess it depends what your end goals are... if it's making games for a living.. then it's smart to use libraries. If you are doing it for the learning experience or because you want to make your own library.. then go the LWJGL way!

alaslipknot
 « Reply #20 - Posted 2013-04-21 15:49:06 »

.. if it's making games for a living..

is it possible  ??

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
ClickerMonkey

JGO Coder

Medals: 24

Game Engineer

 « Reply #21 - Posted 2013-04-21 16:02:13 »

Ha not sure if you're being facetious or coy... but if you want to make games for a living you need to build a portfolio of completed games... and the more the merrier. If you're not interested in working for a game company (can't blame you), then indie is a way to go. You can have two strategies for that... work years on a crazy good game... or crank out tons of decent games.

I went a harder route (IMO), which is working 40+ hours a week at a stable programming job and spending all my freetime on game related programming. It's harder to be productive, but the stability is necessary for owning animals, house, and car (and woman?).

alaslipknot
 « Reply #22 - Posted 2013-04-21 17:28:43 »

@ClickerMonkey

the thing is that i don't know that someone can live just with making games, at least you work for a big AAA studio or you have a team with super programmers and awesome artists,
personally  i gain once some money on making "games", but it wasn't like am gonna get payed every month or something like that, there was a guy (artist) who wanted me to help him making his portfolio where you can see the content (drawings) of the website while playing a small little games, i made it with Flash and he gave me 350€
it was 2 years ago, after that i didn't made any incomes
in the beginning i was all excited about making Flash games and how FlashGame Portals are very popular and earning money will not be a hard task, but i never finished any game i start with flash  i always had the feeling that real programmers don't use flash   (ignore that  )
and the reason why i start learning Java is that i really REALLY !! get pissed off after the two 1st months at college, the programming course are all crap multiplied by soo many craps
so i decided to learn a good language and be a freelancer programmer (just to prove to my mom that college sucks   )
i start learning Java in last December, and somehow, i found myself following games tutorials everywhere
it's not my fault
and the final result is that i completely screwed up at college   next year i should "re-do" the 1st semester of this year
and maybe the 2nd too
i spend all my time learning Java, and the rest i spend it with my girlfriend
sorry if i talked too much, but since i said a lot here, i kinda have a little question
does it worth all this time ?? and specially the risks coming with it ??

thank you ^_^

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
ClickerMonkey

JGO Coder

Medals: 24

Game Engineer

 « Reply #23 - Posted 2013-04-21 18:13:05 »

Is it worth it? All depends if you finish something substantial. If you are just doing it as a hobby, then making games are only worthwhile if that's what you enjoy doing the most.

I'm not at the point where I'm ready to quit my full time job (was close many times), so I'm not "there" yet. But one day soon! Also, if you are working towards doing this full time for the rest of your life... be wary of burnout! I'm pretty burned out right now after doing stuff for Haxel, and now I'm overwhelmed with the number of things I need/want to do (stuff for Haxel, other WIP games, blog, etc).

You just need to clearly define what you want, then set goals (and due dates). When you pick a project you're passionate about, develop some way to keep yourself motivated (I use a ToDo-list... I can't stand seeing something on it... that's my driving force behind me finishing things).

alaslipknot
 « Reply #24 - Posted 2013-04-21 19:17:14 »

^
that makes a lot of sense i wish i find the right way someday
and good luck for you

thanx

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
ctomni231

JGO Wizard

Medals: 99
Projects: 1
Exp: 7 years

Not a glitch. Just have a lil' pixelexia...

 « Reply #25 - Posted 2013-04-21 23:04:59 »

There is a huge rift forming in this forum between 2 factions. There are those...

1) Who are in it just to create games as quickly as possible.
2) Who are in it to learn more about the Java (and OpenGL) technologies to write better tools for gaming.

The question is not if it is worth your time. I believe if you had the patience to post, you obviously want to use programming to create games. I think the assumption is that people are making games here solely for the interest of making them as fast and numerous as possible. Everyone who wants to do gaming for the sake of improving their own knowledge of the underlying technologies, (which games are the best way to do this), are wasting time posting in this gaming forum.

Let me be clear and to the point. All of you guys who are doing this to people, are completely wrong.

By this standard, we shouldn't even be trying to create games. There are companies that are made to produce "AAA" titles. They have a lot more money and technology than we are able to fathom. We should just give up programming games and play the games that are tested, true, and are reviewed by people with high merits. What makes our gaming efforts better than any of those tested veterans?

And, yet here we are on a gaming forum for indie gaming, preaching standards. Pathetic.

I know, alaslipknot, that no one is force feeding you to try out new solutions, or the solution that is the most popular at the time. However, Java is much, much more vast than just LibGDX. From a programmer's perspective, using a mainstream library is just as horrible as using a mainstream language.

The best course of action to take is one that will allow you to achieve your goals.

If your goal is to create a game as fast as possible, look into a library like LibGDX that has a lot of tools to help you out.
If your goal is to learn LWJGL inner workings, skip LibGDX and try to write tools for that.
If your goal is to learn Java inner workings, focus on looking through the Java tutorials and looking at code in Graphics2D.

In other words, you have to lay out for people exactly what you are looking for to avoid the generic cut/paste solution. I don't believe there is a cut solution for any problem, especially one as vast as game creation. I just find it sad that people would rather stick to a routine, rather than question why they decided to become an indie game developer in the first place.

Axeman

Senior Devvie

Medals: 7

 « Reply #26 - Posted 2013-04-22 00:30:25 »

alaslipknot, regarding the original post: Learn vector math. It´s gonna help you out a lot and will make your games look and play better. Take a look at Davedes code and you´ll see how elegant the vector solution is to your problem. No more "if (this direction), if (that direction)", it just looks... Nice. Vectors will make your life a whole lot easier.
davedes
 « Reply #27 - Posted 2013-04-22 01:24:08 »

What everybody is missing in this thread is that Java2D is also a framework. You aren't "going down to the wire" by using Java2D. Instead you are "letting it wipe your ass for you", or whatever you want to call it. But, instead of letting it wipe your ass with cashmere (LibGDX), it's wiping your ass with sandpaper. And doing a horrible job at it.

Quote
Exactly, that's why i think that the good way to start is Java2D, then start to learn LWJGL step by step, it would be easier no ?
Learning Java2D won't help you learn LWJGL. If you want to learn something "basic" that lets you transfer your knowledge to LWJGL (which is low-level), then you should learn LibGDX first. It will teach you essential concepts like Textures (GPU), projection matrices, batching, and maybe even shaders, which will transfer to LWJGL well.

If you want to learn graphics programming, this means learning vertices, shaders, vecmath, etc. You can choose to learn these concepts with raw OpenGL calls, or with LibGDX, or with my own lwjgl-basics API. IMHO you will learn the essential concepts faster using LibGDX or another high-level wrapper; and if you want to, you can always learn the boring OpenGL boilerplate later down the road.

To put it another way... LibGDX makes you a more productive graphics programmer, and lets you learn graphics programming faster. If you'd rather spend more timer tinkering and debugging calls to glXXX, then that's your funeral.

The big problem with Java2D is that you might spend a month or two learning how to use it (buffer strategies, volatile images, odd tricks for faster composites and scaling, etc). And at the end of it all, your friend who spent the same amount of time learning LibGDX is already well ahead of you as a graphics programmer for hardware-accelerated devices.

Quote
Here's the same code, using javax.vecmath.Vector2d:
Vecmath is not part of the standard JRE.

ClickerMonkey

JGO Coder

Medals: 24

Game Engineer

 « Reply #28 - Posted 2013-04-22 01:31:23 »

Well said.

I wanted to be a rebel and do it from scratch... writing out to pixels... drawing images, circles, lines, all sorts of fun. Total bad ass. And total waste of time.

Use whatever you want dude.

davedes
 « Reply #29 - Posted 2013-04-22 01:33:32 »

Well said.

I wanted to be a rebel and do it from scratch... writing out to pixels... drawing images, circles, lines, all sorts of fun. Total bad ass. And total waste of time.

Use whatever you want dude.
Sometimes that is fun, too. But that's different from typical Java2D, since you are rendering by hand, and learning lots about bits, bytes, and cool tricks.

My last Java2D project rendered a 3D procedural earth in real-time... I learnt a lot from that, but, of course, barely any of it was using the Java2D APIs. And at the end of it all, it performed like crap on most machines, and would have been many times more efficient as a shader.

Pages: [1] 2
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 theagentd (66 views) 2017-02-18 13:42:33 theagentd (71 views) 2017-02-18 13:35:16 h.pernpeintner (1235 views) 2017-01-24 22:39:11 h.pernpeintner (1223 views) 2017-01-24 22:38:32 Galdo (1775 views) 2017-01-12 13:44:09 Archive (1891 views) 2017-01-02 05:31:41 0AndrewShepherd0 (2427 views) 2016-12-16 03:58:39 0AndrewShepherd0 (2279 views) 2016-12-15 21:50:57 Lunch (2359 views) 2016-12-06 16:01:40 ral0r2 (2152 views) 2016-11-23 16:08:26
 SkyAphid 42x theagentd 28x Spasi 28x philfrei 27x Archive 27x princec 21x misthalu 19x basil_ 19x Coldstream24 16x Aalhex 15x wessles 14x orange451 14x dime26 11x Riven 10x cylab 9x SHC 9x
 List of Learning Resourcesby elect2016-09-09 09:47:55List of Learning Resourcesby elect2016-09-08 09:47:20List of Learning Resourcesby elect2016-09-08 09:46:51List of Learning Resourcesby elect2016-09-08 09:46:27List of Learning Resourcesby elect2016-09-08 09:45:41List of Learning Resourcesby elect2016-09-08 08:39:20List of Learning Resourcesby elect2016-09-08 08:38:19Rendering resourcesby Roquen2016-08-08 05:55:21
 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