Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  2D Drawing  (Read 3704 times)
0 Members and 1 Guest are viewing this topic.
Offline Dane

Senior Newbie





« Posted 2013-02-19 02:14:14 »

I'm trying to figure out what the best way to draw a 2d game is, and I'm pretty much stumped.

I use a StrategyBuffer in a canvas at the moment, and this is basically what I'm doing right now:

Updating method: http://pastebin.com/zrmmTGEg
Drawing method: http://pastebin.com/924nhQkp
Image2D.java: http://pastebin.com/T16CrRq2

Educate me.  Grin

Doing it wrong since 0x7CC.
Offline davedes
« Reply #1 - Posted 2013-02-19 05:49:37 »

LibGDX

It's a game-centric library, includes tons of tools and documentation, distributes to many platforms, and is built on OpenGL as to ensure high rendering performance.

Offline Dane

Senior Newbie





« Reply #2 - Posted 2013-02-19 06:52:15 »

Thanks, but I was looking for more of an alternative that wouldn't include using libraries that weren't made by myself.
Although- It does look interesting so I will definitely check it out and give it a go! Smiley

The reason why I'm looking for an alternative that doesn't use a library; is because I've got this thing where I don't feel as accomplished if I didn't make 100% of it.

Doing it wrong since 0x7CC.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StumpyStrust
« Reply #3 - Posted 2013-02-19 07:07:35 »

Then try lwjgl. I am sure davedes will post his great tutorials on it.  Wink

If you don't like the idea of using libs then why are you using any of the built in java libs?

Offline Dane

Senior Newbie





« Reply #4 - Posted 2013-02-19 07:40:41 »

Then try lwjgl. I am sure davedes will post his great tutorials on it.  Wink

If you don't like the idea of using libs then why are you using any of the built in java libs?

Haha you got me there, what I meant specifically were libraries other than the stock ones. Tongue

Doing it wrong since 0x7CC.
Offline StumpyStrust
« Reply #5 - Posted 2013-02-19 07:50:31 »

If you are ok with inconstant performance and many missing features that really are very nice to have for game dev then you can use java2d but I strongly recommend opengl.

Basically, fastest way of rendering an image in java2d is simply graphics.drawImage(image stuff);

Use bufferedimages. Don't worry about the whole volatile image thing as it does very little for you unless you are trying some hacks.

1  
2  
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) (fade)));
        g2d.setTransform(AffineTransform.getRotateInstance(rotation.x, loc.x, loc.y));


That is the fastest way I found for rotating and changing alpha for images.

Offline davedes
« Reply #6 - Posted 2013-02-19 16:51:12 »

Sounds like you have a case of NIH... (Not Invented Here).

Honestly, you'd be foolish not to use LibGDX. Just because it's a third-party library doesn't mean you should shy away from it (Java2D and LWJGL are also third-party libraries). If you want to avoid third-party code at all costs, you should be writing your own rasterizer in C and assembly. Roll Eyes

For example, here are three scenarios, and in all cases LibGDX is the best choice:

1. You want to make a game. Without LibGDX, you have a lot of boilerplate to write (game loop, texture handlers, shader compilation, tiled map loader, etc). LibGDX makes development smoother and allows you to focus on programming the game itself.

2. You want to learn general graphics programming. LibGDX gives you a high-level platform for manipulating GL, textures, shaders, and so forth without wasting time tinkering with hundreds of lines of OpenGL boilerplate. It's an easier way to learn the pipeline.

3. You want to learn OpenGL from the lowest level. At this point some people may suggest LWJGL, but really LibGDX is just another OpenGL wrapper at its core. So you can get down to the nitty-gritty and write your own texture loaders, if you really want to reinvent the wheel. The difference is, you're working with a cross-platform solution (LibGDX ports to iOS, WebGL, Android, and Desktop) as opposed to LWJGL, a desktop-only solution. And, with LibGDX, you have the option to use its utilities (shaders, asset management, image decoders, 3D model loaders, JNI-accelerated matrix math) whenever you want.

If I still haven't convinced you... and you refuse to use LibGDX, start poking around my tutorials and code here (which is just "straight LWJGL").

Offline Dane

Senior Newbie





« Reply #7 - Posted 2013-02-19 17:38:12 »

After checking LibGDX's Wiki, I've decided to move on from tinkering with my 'while (running)' statement and spamming draw().
I'm comfortable and confident with saying I think this is going to go well. Smiley

You've all helped convinced me, I really appreciate it.  Grin

Doing it wrong since 0x7CC.
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #8 - Posted 2013-02-19 18:22:06 »

I wonder how many people you've converted to libgdx over the years...
Offline davedes
« Reply #9 - Posted 2013-02-19 18:51:00 »

Not enough. Grin

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Oskuro

JGO Knight


Medals: 39
Exp: 6 years


Coding in Style


« Reply #10 - Posted 2013-02-20 19:05:07 »

Being a sufferer of NIH all I can say is... Check the Java4k games, study their code, some have pretty neat tricks you can learn from.


Still, making stuff on your own without third-party is justifiable. A couple reasons off the top of my head:

  • Educational purposes: If you want to know how pure Java ticks and what its limitations are.
  • Platform Limitations: Maybe you're developing a Java4k game, maybe for a mobile device with pure java exclusively, or maybe for a platform where alternative libraries don't work correctly.


Or, maybe, you're just a masochist like I am...  Roll Eyes

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #11 - Posted 2013-02-21 04:03:10 »

Sounds like you have a case of NIH... (Not Invented Here).

Honestly, you'd be foolish not to use LibGDX. Just because it's a third-party library doesn't mean you should shy away from it (Java2D and LWJGL are also third-party libraries). If you want to avoid third-party code at all costs, you should be writing your own rasterizer in C and assembly. Roll Eyes

Assembly and C involve 3rd party code. Type the .bin files out by hand. Wink

Anyway, NIH is not neccessarily a bad thing. You have to realise your limits and not go about creating a new operating system just to make a game.

There is also a good reason for NIH:

The more "easy-to-use libraries" out there, the more n00bs you get asking stupid questions about things that would be obvious had they learnt how things really work.

Offline Dane

Senior Newbie





« Reply #12 - Posted 2013-02-21 07:04:07 »

The main reason why I don't like using third party libraries is because I like to know how everything works.

For example; I've always wanted to create my own really basic 3D rendering. Similar to what RuneScape used back in 2003-2006. (Software Rendering)
But their client's rendering is so obfuscated that I couldn't learn from it.

Doing it wrong since 0x7CC.
Offline relminator
« Reply #13 - Posted 2013-02-22 16:40:08 »

The main reason why I don't like using third party libraries is because I like to know how everything works.

For example; I've always wanted to create my own really basic 3D rendering. Similar to what RuneScape used back in 2003-2006. (Software Rendering)
But their client's rendering is so obfuscated that I couldn't learn from it.

It's not actually hard to make your own software 3D rasterizers.  I've made quite a few about 10 years ago.  I hope you can read quickbasic...(Scroll down for the 3D series.)

http://rel.phatcode.net/index.php?action=contents&item=Tutorials

I also have an x86(fixed point integer) assembly version of the rasterizer if you want.

But really, in this day and age, you'd better be learning OpenGL.

Offline Dane

Senior Newbie





« Reply #14 - Posted 2013-02-25 02:42:30 »

After using libGDX, I've determined that it just isn't for me, instead I'll be checking out Relminator's link and just learning to create my own 3D rasterizer.

Thanks everybody for your input! Smiley

Doing it wrong since 0x7CC.
Offline davedes
« Reply #15 - Posted 2013-02-25 03:30:02 »

Huh

When I said writing your own rasterizer, I meant it as a joke. It will lead to pretty terrible performance compared to LibGDX and you will be nowhere closer to making a 2D game. Can I ask why you didn't like the library and/or how you feel it could be improved? 

Just curious. Wink

Offline Dane

Senior Newbie





« Reply #16 - Posted 2013-02-25 04:05:29 »

Huh

When I said writing your own rasterizer, I meant it as a joke. It will lead to pretty terrible performance compared to LibGDX and you will be nowhere closer to making a 2D game. Can I ask why you didn't like the library and/or how you feel it could be improved? 

Just curious. Wink

LibGDX may have an upper hand on performance, but that doesn't necessarily mean the rasterizer would be bad. Smiley

I didn't enjoy using the library because I feel like I should be learning how to create my own tools and use those tools to make my own content.

I've got a severe case of NIH and so far nothing has cured me of it. Sad


Edit: Actually, I'm thinking of using either LWJGL or some basic wrapper for OpenGL.

I know LibGDX is derived from LWJGL but it's just the way LibGDX is setup that I don't like very much.

Doing it wrong since 0x7CC.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (23 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (54 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!