Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Basic Java Concepts


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Xeinnex   Members   -  Reputation: 130

Like
0Likes
Like

Posted 02 July 2011 - 09:03 PM

hello, im new in this website, so im not sure im posting in the right forum, i feel like im a beginner in game development so this should be the right place.

anyways, recently, i've been wanting to learn java, lets say i know most algorithm basics, i just need to learn the visual stuff, the input stuff, and the networking stuff.

i concluded that making a game would be a nice way of learning all that, and i've always wanted to make a games so it would be a win win win for me, so if anyone could give me some advices it would be just great.


yes i know that asking for advices might get hard to you because there is too much field to cover, so i came up with some specific questions about it so its easier for you to help me :), here they are:

1- how does the networking stuff works, like if i want to make an online game, that works by turns, lets say like chess, but also played in real time, how would the networking process be?

2- can java work properly with mysql? if yes, is there any basic tutorial or special info i need to know about it? if no, what kind of databases would i have to use?

3- lets say i want my "chess" game to be 2D, because i like 2D better, but i want it to have a 3D effect, lets say like this game: http://armorgames.com/play/2205/light-bot , please notice the way the tiles work in the game, like as if the field had 2-3 or even 4 floors, how would it work?
(im not sure if i can post links, if its against the rules and a mod is reading this please delete number 3, thank you).

4- in case you are wondering, "what about the input stuff", thats what brought me to this website, i found a great java tutorial special for inputs here: http://www.gamedev.net/page/reference/index.html/_/reference/programming/languages/java/java-games-keyboard-and-mouse-r2439, so i will be studying all the code deeply and maybe ask some specific questions when they appear.

just to be clear, im not making a chess game, its just an example that fits all what i want now, and save me all unnecessary explanations.

thank you for reading. and answering :D

and sorry if my english is wrong, my native language is spanish so im trying my best here :). let me know if there is something wrong with this post :)

Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 4222

Like
2Likes
Like

Posted 03 July 2011 - 04:33 AM

1- how does the networking stuff works, like if i want to make an online game, that works by turns, lets say like chess, but also played in real time, how would the networking process be?

Java gives you access to sockets either via the java.net or java.nio packages. If you know about sockets in general, you can work with those with extremely little effort.
There is also Java's remote method invocation (RMI) framework, but that was not designed with games in mind and I would not seriously consider using that for making a game before I made a very serious analysis of my needs and requirements versus what RMI can offer.
In any case, network code is not something I would suggest for a beginner, especially not starting from sockets and building up. Either start with a single player game or search for a networking library which successfully hides the worst from the user.

2- can java work properly with mysql? if yes, is there any basic tutorial or special info i need to know about it? if no, what kind of databases would i have to use?

While I have not worked with mySQL I would be highly surprised if it did not provide a JDBC driver to work with.

3- lets say i want my "chess" game to be 2D, because i like 2D better, but i want it to have a 3D effect, lets say like this game: http://armorgames.com/play/2205/light-bot , please notice the way the tiles work in the game, like as if the field had 2-3 or even 4 floors, how would it work?
(im not sure if i can post links, if its against the rules and a mod is reading this please delete number 3, thank you).

I believe you want to make isometric game if I understand you correctly. Anyway, in the simplest case as shown in the flash game you linked, you can simply draw each tile by drawing the bottom-most <whatever> on the tile and progressing up. Tiles must just be rendered in the right sequence (back to front) so they overdraw each other correctly.

#3 JoeCooper   Members   -  Reputation: 338

Like
1Likes
Like

Posted 03 July 2011 - 04:41 AM

There is JDBC for it, I've used it. Networking is super easy as described above.

I wrote some games in Java here (with source) that shows both input handling and overriding Component classes to do painting. Look at the spinner box for a clean Component example or at "PieBells" for a more complete example.

There's multiple Java programmers here, feel free to ask when you run into trouble spots.

#4 Xeinnex   Members   -  Reputation: 130

Like
0Likes
Like

Posted 03 July 2011 - 10:45 AM

thank you for your responses, i think im going to follow BitMaster's advice and stay away from the networking until i get a more solid knowledge of everything else, anyways i have more questions, im not sure if i should ask in the same thread, or start a new one but here i go:

firstable im going to re-make my last 3rd question, the idea is to have a grid, but the part that confuses me, is that i dont want it to be like a square grid, lets let this quick image talk by itself: http://rookery9.aviary.com.s3.amazonaws.com/8815500/8815715_27d0.jpg so, how would you make that kind of grid like the one at the right?


new questions:

1>> how do you make .exe with java? and how do the folders work, like the bin, data, etc.

2>> is there a special way to make your application go fullscreen? or is it just some java method?

3>> how exactly would a sprite based animation work in java? i've read people uses this kind of spritesheets: http://i25.tinypic.com/vnz136.png and im not sure if its necessary, but i noticed they were all png files.

3.2>> if those "spritesheets" are the way to animate characters in java, how would you use them?

#5 JoeCooper   Members   -  Reputation: 338

Like
1Likes
Like

Posted 03 July 2011 - 11:02 AM

To make an exe, you find a jar bundler. You can produce jar files that are bundled softwares that run like programs if you have Java installed, and you can find software that packs these into exe files.

Caveats: Java software requires a JRE (runtime environment) to be installed. If your bundler doesn't bundle the JRE, you'll have to hand-craft an exe launcher or ask that the user install Java.

I went the complete bundling route with our application because requiring that Java be installed separately was causing way, way too much trouble.

So I wrote a launcher in C with the Windows API. On OS X, I used a launcher that Apple provides.

Regarding your grid, I did this here. It is a basic math problem (Algebra, actually). You have a set of tiles, and each tile has a coordinate, and you iterate through the list, and you have a piece of code that maps a tile's coordinate to a screen position. For each tile, you can either paint a sprite that looks the shape you want as I did in the previous link, or use the java.awt.Graphics API to draw the actual shape or lines as I did in this more primitive shot here.

But that function is the key point; you have a function that's given a Point representing the game board coordinate and it returns a Point representing where to draw it on screen. For the effect you want, you'll want to look at the modulus operator. Some code like "y % 1 == 0 ? true : false" would yield a true or a false value based on whether the row number is odd or even. Alternatively, you could actually have the tiles slant diagonally as you go rightward.

You'll find that programming features a lot of "story problems" such as this where you must craft a math function or algorithm to meet some kind of specification, so, if you're good at those in school, you'll be fine.

An inverse function would be able to map a screen coordinate (for example from a mouse click) to the game grid.

Refer to the Spinner Box code in the link I gave in my previous post to see an example of overriding a JComponent to redo the paint operation. (This is explained in many manual pages, the code I posted is just there because it's a working example.)

Fullscreen? Yes. Just Google it, you're looking for "full screen exclusive" mode.

Sprite sheets; literally the Graphics API has a paint method that lets you choose both the source shape and the destination. So if you have a 4x4 sheet of pictures, you can actually specify which subset of the pixels you want to use for drawing and where to put them. There is one method for this (paint).

The "Pie Bells" example uses a primitive sprite sheet (more of a strip really).

I might be able to send you the code for that board game I linked earlier, with redactions, but that'd eat some of my time so only ask if you plan to read it.

#6 Danny02   Members   -  Reputation: 275

Like
2Likes
Like

Posted 03 July 2011 - 11:35 AM

normaly u won't need to pack your jar into a exe, because if a java runtime(JRE) is installed on a PC u can just start the JAR as any other app.

In the case where u don't know if your user have a valid JRE installed, or corretly configurated, u have to options.
The preferred one should be to use Java Webstart, it allows a user to "install" your application by clicking a link on a website. This approche makes sure that the user has a JRE installed and handle alot of other things too.

In the case that u want to do it a little more oldschool or just want to be able to send someone without internet your app. Wrapping your java app in a Exe Launcher is the best way.
For this case are a lot of free and comercial software out there. I use Launch4J cause its free and has a lot of configuration options.

#7 Xeinnex   Members   -  Reputation: 130

Like
0Likes
Like

Posted 04 July 2011 - 06:43 AM

actually i'd love to see that grid source, even when its not exactly the same, im pretty sure its the same idea.

after reading here and there about my questions, i think the best way would be to start working on small game projects testing all the different stuff im going to need for my big game, the reason being that i dont want to make a big mistake that will cost me lots and lots of time after a while, i need to get dirty with java before i can think of something big, anyways, that source code would be really helpful, i want to start doing a map generator, so the gridding methods are top priority for me right now :), thank you all for your answers, ive been here for 2 days and i can tell already that this is a wonderful community, lets hope i could be the one helping others soon :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS