Java 2D game programming - Newbie questions - java

We're a team of a programmer and a designer and we want to make a medium-sized java game which will be played as an applet in the web browser. Me (the programmer) has 3 years of general development experience, but I haven't done any game programming before.
We're assuming that:
We'll decide on a plot, storyline of the game, etc.
We'll create a list of assets (images) that we need, i.e player images, monster images, towns, buildings, trees, objects, etc. (We're not adding any music/sound efffects for now)
The designer will get started on creating those images while I finish reading some of the game programming books i've bought. The designer will create the first town/level of the game, then pass on those images to me, I will begin coding that first level and he would start on the next level, and after 4-5 levels we'll release v.1 of the game.
Question 1: Is this the correct methodology to use for this project?
Question 2: What format should the designer create those images in. Should they be .bmp, .jpeg, or .gif files? And, would he put all those images in one file, or put each monster/object/building in its own file? Note; We are sticking to 2D for now and not doing 3D.
Question 3: I've seen some game artware where there would be a file for a monster, and in that file there'd be about 3-4 images of a monster from different directions, all put in one file, i think because they're part of an animation. Here's an illustraton:
[Monster looking to right] ... [Monster looking in the front] ... [Monster looking to right[
And all of them are in one file. Is this how he'll have to supply me with those animations?
What i'm trying to find out is, what is the format he'll have to supply me the designed images in, for me to be able to access/manipulate them easily in the Java code.
All answers appreciated :)

I have some comments for each question.
Question 1: You say that you will begin coding level 1, 2, .. one by one. I recommend you to create a reusable framework instead or see it in the big picture instead. For the information you provide I think you are going to make some kind of RPG game. There are lots of things that can be shared between levels such as the Shop, the dialog system, for example. So focus for extensibility.
Why wait for designers to pass on the image? You can begin your coding by starting with pseudo graphics file you created yourself. You can then work with designer in parallel this way. And you can replace your pseudo graphics file with ones provided by designer later.
Question 2: JPG is not suitable for pixel-art style image, that appears a lot in most 2D game. And the GIF support only 256 color. The best choice to me seems to be PNG.
The designer should always keep the original artworks in editable format as well. It's likely that you want to change the graphics in the future.
Question 3: It depends. The format mentioned, where character's animations are kept in single file, is called Sprite. If you kept your resource in this sprite format than you will have some works reading each of the sub-image by specifying coordinates. However, sprite helps you keep things organized. All the 2D graphics related to "Zombie" character is kept in one place. It is therefore easy to maintain.

About the image format: don't let the designer deliver anything as jpg, because you'll lose quality.
Let him send it as png instead, and convert it to your preferred format as needed.
Also, remember to have him send the source files (photoshop/illustrator/3dsmax/whatever) in case you'll ever need tiny changes that you can make yourself without hiring the graphics dude. Who knows if he'll still be available in the future anyway.

I want to suggest to you that, before you make any decisions about your workflows, you and your colleague go have a look at JavaFX and see if maybe that's the toolkit that best meets your needs.
http://java.sun.com/javafx/

The [Monster looking to right] ... [Monster looking in the front] ... [Monster looking to left] style of animation demarcation has been around for as long as I've been peeking into game data, so I would suggest going with that path.

I was about to make the same remark as Wouter: use PNG, modern format which is highly compressed (as opposed to BMP), lossless (as opposed to Jpeg) and full color and with several level of transparency (as opposed to Gif).
Why people put several sprites in the same image? Actually, for Java, I am not sure, if the images are part of a jar... I know it is interesting in CSS, for example, because it reduces the number of images to download, so the number of hits on the server, which is a well known Web optimization. For games on hard disk, reducing the number of small files can be interesting too.
The designer can appreciate this too. At least in times where sprites used a color palette: you had only one image, using the same palette: easier to edit, and slightly reduce the overall size (in times were memory was costly!).
I can't answer on the methodology, I never did a game in team... If it fits your needs, it is probably the right methodology...
duncan points to JavaFX, I will point to pulpcore which seems to be a promising library. Of course, there are plenty others, like JGame and such.

Bunch of pros here: http://www.javagaming.org/

This is not answering any of the questions. But for game develop/Simulation Engines learning if u need a reference:
http://www.cs.chalmers.se/idc/ituniv/kurser/08/simul/
It's a link for the class lectures of Simulation Engines at Chalmers Univ in Gotembourg. The teacher as a game company and gave quite good lectures. Check the slides we had in the classes, maybe they'll help you a bit.

Related

How to expand the StdDraw library without using AWT or SWING

So in the beginner coding classes I teach, they've (the district) moved us away from the Graphics library with java.awt.* and java.swing.* to the simplified standard graphics library, StdDraw -- not necessarily a bad thing as it has most of the bells and whistles that my students need and we only really use it for one chapter and then its an option for a later project if they feel more artsy that analytical. It also more closely mirrors the coordinate system they're using in math classes and logically makes more sense to them defining center pionts to draw instead of corners.
One of the things I really wish it had was the ability to draw sectors/wedges/slices of circles. It does arcs (the portions of a circumference), but especially for the graphical [pie] charts, it's quite essential. For the moment they're just coloring the arcs and we're going on with the lessons. But for NEXT year, I'm hoping I can edit something into the library ahead of time and let them use it traditionally without going against the other teachers across the (large) district and utilizing two graphical libraries "StdDraw" and "g" or being the lone one who uses g entirely.
Most results online suggest migrating to the g-library, my only hesitation was the explicit move away from that for the younger students. More advanced, older may still use it, but I don't teach them. A decent Google, reddit and stackoverflow search didn't return anything that I could just plug into the StdDraw library so wondering if you have any suggestions or work-arounds?

detecting changes between two images (detecting appearances of new objects)

This is my first question on Stackoverflow, so at first - hi everyone :)
I'm a newbie in image processing, but I have to write an app (in Java) to detect changes between images from a camera (or rather to detect new objects on images).
A camera is taking a picture every minute, all day, so as an input I have a sequence of color images in JPG.
The important things are:
the camera isn't moving, so a background doesn't change. I'm interested only in
detecting objects (e.g. people, animals, cars, ..) between lens and a background
it should be impervious to image noise from a camera or weather (e.g. rain, snow, sun moving - shades)
the only thing I need as an output is an information that sth has changed between two images
I'm interested in as simple solution as possible, but it has to be a working solution.
It doesn't need to be infallible, but it should work correctly in most normal cases.
Of course, I don't expect someone give me a ready to use snippet of a code
(although that would be great! ;) ), but if someone, who knows the topic, gives me some guidelines (steps to do, algorithms or articles to read), I'll be really gratefull. I haven't found nothing appropriate on google and unfortunately I don't have a year to read few books and do a PhD to find a solution :)
you can parse md5 of the image and compare parts of it, and check if they are similar or not, you can refer to this
You can use Keypoint Matching which is almost the same method as 1 you can read about this.
Read about Histogram method
As a simple solution, just subtract one image from the other and look at the differences. Ignore small changes and try to build area of movement and just accept bigger areas.

Images as game levels

I have been searching the past few days but can't seem to find anything on how to read .png files and then build levels off of that. I already know how to load images and files, but how does one go about pulling data out of them in order to build game levels. Anyone care to enlighten me? By the way I use Java.
You are thinking too high-level. The programming language doesn't know what a "game" is, or a "level." You can load an image file, that's great -- now you have a set of binary data in memory. There is no meaning attached to those bits. What you need is a model representing your level; perhaps, for example, you could simply have two images, one of which is the 'background' and one of which is an occlusion map. For example, black areas on the second image are impassable/blocking, while the first image is simply the level as it is displayed.
When you're writing in a "real" programming language, and not a game-building toolkit, the building of a model to represent your problem is your responsibility.

How to make a custom video player W/ embed options! Rare [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
First question: What would be the best language to create a video player in? / Anyone point me in the direction of a tut that can help me write said script?
Second Question: How can I code such player to echo a embed code for each video: Ala youtube/break/viemo.
^ whats amazing to me, is the fact I searched google for a day and a half and haven't even come close to someone explaining how to build a video player, let alone have a option for it to spit out a embed code or any other sharing options.
Usage info: Once the player is finished it will be imported into wordpress, so I can have total control of each video and manage them accordingly. Not asking for help for importing to WP but any tips would be great.
{Please don't point me to VideoJS or any other video service, as I will make my own and not pay for a license.}
In general, a video player is a picture gallery, where twenty four (or more) pictures are displayed in order every second during the entire duration of the film. Twenty four is the lowest limit for a person to visually confuse static pictures with motion, for better effects I would recommend thirty or more.
The second component of a video player is typically a music player, which displays many "frames" of music per second, which blend through the digital to analog playback system into something resembling continuous sound.
Getting these two subsystems to operate without letting one get ahead of the other is generally required for a "video playback" system. There are many "already done" systems, but it sounds like you envision building your own (to add in unique "features").
Keep in mind that there are very large volumes of data moving around in "video playback". This means that if it is possible, compressing the data is vital for reasonable performance. Compression routines are not as simple as they seem, and the major video codecs are those that do a good job of balancing CPU cycles to decompress, file size, and resulting image quality.
Assuming you really don't want to write a video player, but just want to use someone else's video player "with enhancements", you will be at the mercy of how well built the existing video player is, whether or not it supports any kind of customization, and if it does, how well it supports the customization you have in mind.
Since speed is such a consideration, even though more advanced languages exist, traditionally these things are done in C, assembly, or even hardware acceleration chips.
These are my thought, although you should try to search a little better... Tutorials are very easy to find ...
You could use Flash / ActionScript to create a custom video player. It's still common on the net, although more and more non-flash players are rising (HTML5). I still prefer Flash because of the performance, but keep in mind that iPhone / iPad doesn't support Flash...
If you are going to script your own videoplayer in Flash, this tutorial will set you off to create your own implementation...
For your second question:
Just create a database with a unique ID for every video URL your player will have. When you create the embed code you can include this unique ID as a URL var to the main video player.
From there on you can call your player page with URL vars (example: http://www.yourlink.com?videoid=ID).
When you embed your SWF object you can then pass the videoid along with a FlashVar, or prefetch the matching video URL and send that URL with a FlashVar to your SWF. It's not so complicated, more info can be found here.
try osmf.org. You can either use the strobe media playback with it or build your own player around it. OSMF is pretty robust

Java: How exactly are character models and the like created in LWJGL?

Think about the games like Spiral Knights and Minecraft(Which I believe both use LWJGL) - How are the characters created? Does, at least Spiral Knights, use some other outside program to make them, then import them somehow? Does Minecraft handle their mob / character creation all in Java or LWJGL(That would make sense to me, since the models are more simple)? I'm confused as to how and where they're made, and the different ways you go about making them. I'm not talking about textures, but the things that the textures are applied to.
Does making the models even use LWJGL?
Please tell me if I misunderstood something, or said something incorrectly that didn't make sense.
It's pretty hard to say without knowing what each individual team's art pipeline looks like. As such I won't try to speculate except to say that as long as you can render 3d geometry, you can surely find or build a routine to import just about any 3d file format: collada, max, maya (mb, ma), .x, ms3d, blend, etc.
The need to consider just 3 things:
Does the 3d tool you're considering support the kind of art you want to create?
Do you or your artist have experience in that tool?
Can you write or find the code to load the 3d file format?
If you can answer those 3 questions positively, then you have a good candidate for the tool to use for this project :-)

Categories

Resources