Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Nov 2011
Offline Last Active Aug 12 2012 05:32 PM

Posts I've Made

In Topic: Finding which Block Clicked

29 November 2011 - 02:51 PM

How are you drawing the blocks? Use the same positioning you use to draw the blocks to get their physical location in the game world, and calculate the location of the mouse in the game world.

Block = (MousePos + CameraPos) / BlockSize;

Block is the cell that a block may or may not be in. You can usually use this to get the index into your array of blocks, if you have one, with something like this:
Index = (Block.y * NumBlocksWide) + Block.x;
(If your blocks are stored that way in memory).

CameraPos is the location of the camera (usually the upper-left corner of the screen) in the game world, in pixels. MousePos is the location, in pixels, relative to the upper-left of the screen (which is why MousePos + CameraPos equals the position of the mouse in the game world). BlockSize is the constant size of the grid cells of your world.l

This is assuming you are using a grid-based system for blocks. If not, you can partition your game world into chunks, and have a list of objects in each chunk, and then only check if the mouse is in the bounding box of any object in that chunk.

Yeah, I can't believe how simple this solution is. I completely forgot.

In Topic: Why not Java?

28 November 2011 - 06:13 AM

The only way to sample a new language or a new tech potential is to try it first hand. I started playing with C# while sitting in airports waiting for flights.. now I use it whenever I can.
There isn't one single thing that makes C# awesome.. there are thousands of them, ranging from tools quality (ie. Visual Studio), .NET interopability , library, language features and the fact that is a very "evolving" language.

The problem is when idealism and fixations that resembles religions more than technology start to cloud people's mind.. and the OP is a spot on example of this kind of damage done by close mindedness.

So being close minded is having an opinion? I don't know much about c#, but I don't have any problem with Java right now. The Nintendo 64 might be years behind an Xbox 360, but some people like the 64 better. I learned Java because I wanted to make mods for Minecraft. I really like the language, and feel comfortable with it. No religion-like idealism here.

In Topic: Why not Java?

28 November 2011 - 12:01 AM

XNA is pretty cool, but I will not use it. I am a big supporter of cross platform. I like lwjgl and slick for Java. Can someone point me to some nice c# game libraries?

In Topic: Why not Java?

27 November 2011 - 12:08 PM

Thanks guys. I think I will stick with Java until I have a need for another language.

In Topic: Why not Java?

27 November 2011 - 11:10 AM

I understand many people use Java and love it, so do I. I love eclipse and it's syntax. But I'm hearing c# is now better than Java in many ways. Many c# game devs use XNA, which I won't use because of its lack of cross platform support. What are my other c# options? Besides Unity, I don't know any. I also hear c++ is great for games, but advanced memory management scares me.

First, Java is quite nice. I wouldn't say it is perfect, but what is. Pound for pound, Java and C# are very similar (ignore the howls of the indignant) and are pretty interoperable as far as basic libraries and language structure go.

That said, Java's largest drawback is lack of gaming platform support (and libraries: there's no XNA for Java). While vanilla C# (pure .Net) is limited to Microsoft controlled devices, those devices (read: platforms) range from the PC to the XBox to the Windows Phone and, as of this month, to the Playstation. Java just doesn't have that. It does have a toehold in the mobile market via Android, but with Google and Oracle going at it (Android SDK support for 1.7 = ???) the future is somewhat dubious. Rumors abound of injecting a JVM on iOS but that's not been confirmed as practical (read: Apple hasn't said "No!" just yet). Oracle is pushing JavaFX as something that can be used for "gaming consoles" but it remains to be seen whether that will take off (or be practical).

If you were looking for "cross-PC C# platform" options then you might consider Mono. With careful structuring, you can pull off a Mono/C# compatible application reasonably well. There's supposedly an XNA library for Mono tho' I've not used it myself.

Other C# options include various engines and components, such as Axiom or OpenTK, to do the heavy lifting for you.

C++ is pretty stock as far as games go, but as the years wear on its acceptance wanes in favor of "safer" languages (such as C#), to the point where it is actively discouraged (and/or forbidden) on certain platforms. If you don't have a use for what C++ can offer you (such as memory management) then don't worry about it.

Also, minor nit-pick but Eclipse isn't a language. It is a reasonable IDE tho'.

Frankly, if you're not making anything "serious" I don't see a reason to fret. If you're just making PC/Android games then stick with Java. Switch when you run into a valid limitation.

When I said "eclipse and its syntax", I was still talking about Java. I was saying two things I love about Java is its syntax, and eclipse.