Jump to content
  • Advertisement
Sign in to follow this  
CarlosMartinez

Game Programming in Java

This topic is 2632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, about 6 months ago, I asked here for advices to get started on java game developing, and I was kind of naïve, trying to start with an isometric strategy game, which after reading a few articles on the subject, I realized it was too hard to begin, so I spent some more time reading about other stuff, I wasted a lot of time doing stuff not programming related and now I finally got to start working on it again, I’ve been working on it for a while now, and I started an easier project, where I want to make a supermario-like game, with side scrolling and platforms and enemies and all that, but before I start programming the game, I decided to make random mini tests of the different aspects that a side scrolling game like this would involve, and that got me a few questions.

So enough of my boring story, the reason im here again is to ask a couple questions that I have, you don’t have to answer all of them, just feel free to help a future game programmer start his career [font="Wingdings"]J[/font], I know they are a lot of questions but I will put them all here so I don’t make 10 Posts for each one individually.



Questions:

[font="Calibri"]1- [/font]Whats resolution would you recommend for a fullscreen game, I know there are different resolutions like 4:3, 16:9, etc, and I want to know if there is a possibility of that, affecting my game graphics, like stretching the wallpaper or something, do I have to make different versions of the game for each resolution? Is there a universal resolution that works fine for most computers? For example 1024x768 is probably more common than 1600x1200.

[font="Calibri"]2- [/font]Is it good to make a method to catch the actual resolution of the screen and use it for the game?, is it even possible?

[font="Calibri"]3- [/font]When I started animating objects, I had to try some different methods to get it to work, first I had to use lots of different png files, and make a loop so they would repaint one after another, however, that method felt too troublesome, and it required a lot of files so I tried making a .gif, and it worked but it had the problem that I couldn’t play with the framerate, I could just play the gif as it is and that’s it, so I started researching a little bit, and I found out there are some kind of spritesheets, that put all the different frames of the animation in one single file, so my question is: how does it work?, it seems to be the perfect method because it gets rid of all the extra files, and I can play with frame rate [font="Wingdings"]J[/font].

[font="Calibri"]4- [/font]Another question, would be a lot like the last one, I found out about tilesets, which would be pretty much like the spritesheets but for tiles for the maps, and I think the previous answer might answer this one as well, but the difference is that probably not all the tiles will have the same size, so how would it work?

[font="Calibri"]5- [/font]And talking about maps, I would like to know if any of you have a good example for a map editor, I saw some algorithms where the map editor wrote a .txt file which would contain some arrays and stuff pointing to each tile in each position, so I read the best way to do it is with a map editor so you don’t have to make the .txt from scratch, but instead you have a small program to do it for you. So that’s the question how can I make a map editor? Or is there a good tutorial for it?

[font="Calibri"]6- [/font]Im not sure how the copyright works, but is it illegal to use official sprites of an existing game such as metroid, megaman or Mario?, I mean I think it should be fine as long as I don’t make money out of it, but maybe you guys know better about these copyright rules. (in the case that its illegal, is there a good website with an open sprite list database that I could use? I mean I know how to do all that stuff, but I don’t want to waste time on it, I just want to use existing sprites and use them to make a game which wouldn’t be anything more than a test of my skills and practice).

[font="Calibri"]7- [/font]Im not sure how .jar files work, but I need to know if they require the user to have the jvm installer on his computer, in that case my guess is that converting to .exe would be better, but I always read that its not advisable to make such conversion, so how exactly does this .jar work?

[font="Calibri"]8- [/font]Talking about .jar, is there a way to encrypt the game in a way that its harder to copy and its harder or even impossible to access the original code so people cant see it or modify it? Would it still be a .jar after that?

[font="Calibri"]9- [/font]I’ve read some stuff about how the side scrolling would work, but in fact I don’t understand it quite well, I haven’t been able to find a source code that uses side scrolling, so could you please explain how it works, or share a source code that uses it? Thank you [font="Wingdings"]J[/font]

[font="Calibri"]10- [/font]Is there a website where I can post my games and my tests so people can comment and critique them?, or even better, is there a place in this forum to do just that? [font="Wingdings"][font="Wingdings"]J[/font][/font]

Ok I think that’s enough questions, and I hope that it can get me to complete my very first game on java, thank you for your time.

there is a possibility that im missing questions that will come when i advance in the project, so if you have an advice or something i should keep in mind that im probably not aware of, feel free to add it :), any extra info would be great ;D.

Share this post


Link to post
Share on other sites
Advertisement
3- Let your sprites point to individual rectangles of the spritesheet and use that as source area for drawImage(). Also store framerates in your sprite objects to calculate when it is time switch to the next animation frame

5- www.mapeditor.org

8- Obfuscators are doing that - more or less - like yGuard

9- Why dont use a ready-to-use library like Slick for example: its feature list names sprite sheets and tile map support

11- I think you should start with something more simple as a very first game

Share this post


Link to post
Share on other sites
well im trying to avoid overusing outside libraries, i want to try to make my own so i can fully understand whats going on, i might end up starting with an easier game actually, but this is my goal so any other game i make before this one would be to "test" something that might be useful here however i think your answer for #3 wasnt clear enough for me :), i mean by looking at character spritesheets, they are always like very symmetric, and all frames have the very same size, so if i make a program that uses a size, it wouldnt work for bigger spritesheets, so it would be great to have an example, actually i think having access to a library of examples is just what i need to understand most of this stuff, i find it really surprising that its so hard to find source codes for java games.

Share this post


Link to post
Share on other sites

well im trying to avoid overusing outside libraries, i want to try to make my own so i can fully understand whats going on, i might end up starting with an easier game actually, but this is my goal so any other game i make before this one would be to "test" something that might be useful here however i think your answer for #3 wasnt clear enough for me :), i mean by looking at character spritesheets, they are always like very symmetric, and all frames have the very same size, so if i make a program that uses a size, it wouldnt work for bigger spritesheets, so it would be great to have an example, actually i think having access to a library of examples is just what i need to understand most of this stuff, i find it really surprising that its so hard to find source codes for java games.


Those free libraries are most likely open source, so you can still see whats going on and how functionality was implemented.
Sorry, I dont get your spritesheet sizing problem or what you are trying to do.
By the way, Slick has "SpriteSheet handling" :wink:

Share this post


Link to post
Share on other sites
I'm new myself but this basically what I understand on how to use spritesheet.

3. You 'divide' the spritesheet into grids. Lets say you create a 256x256 pixel spritesheet, and decided to use a 64x64 for a frame of the animation. So you gonna have about 16 grids/frames. You need to specify with frame take which grid by specifying the coordinates of the grids on the spritesheet. 1st frame may take the 1st grid, 2nd frame the second, etc... I hope you understand what I'm trying to say.

Other members who can explain this better than me surely is appreciated.

Share this post


Link to post
Share on other sites
[font="Calibri"]1- [/font]Depends on your audience. For mainstream/casual audience, 1366x768 accounts for just about half of all windows PCs currently -- primarily due to the popularity of this resolution on laptop displays. However, if you're targeting a more hardcore audience, Steam's hardware surveys are a good place to look.

[font="Calibri"]2- [/font]Its possible, but it depends. Not everyone has the GPU power to run games at the same resolution they run their desktop at. It would be better to detect their GPU, CPU and RAM, (you can get the vendor/model strings pretty easily) then select appropriate detail and resolution settings by default, and let them tweak them later.

[font="Calibri"]3- [/font]Sprite sheets are the typical approach. There's plenty of info on how they work if you look around.

[font="Calibri"]4- [/font]Same -- Tiles probably should have the same size -- if a "tile" is larger, build it out of several smaller tiles. Older game consoles only had one strict tile size at a time, if they can make due, so can you.

[font="Calibri"]5- [/font]Mappy is one solution, I think a program called "Tiled" or something has one built in as well that's decent. Its likely that you'll have to eventually write your own editor or other tools to complete your maps though. Some support trigger regions or collision segments, but for anything more exotic than that you're usually on your own. The good news is that writing a simple map editor isn't too difficult once you've got the basis of your game engine in place.

[font="Calibri"]6- [/font]Whether you make money is of no bearing, you've either been given permission or not, or you're willing to fight it out over parody/fair use. As your own personal placeholders its fine, but once you distribute you need original art if you want to completely insulate yourself from any potential legal trouble. If you like the art of a particular game, find an artist who can do things in a similar style.

[font="Calibri"]7- AFAIK, a JAR is Java's equivalent of an EXE with resources packaged inside. If you're going to write the game in Java, you may as well embrace the platform lock, stock and barrel. Minecraft and its's JAR are doing just fine.[/font]

[font="Calibri"]8- [/font]I wouldn't worry about it for a non-commercial, non-AAA release. The best defense from Piracy is to make a game that people are happy to pay for. Time spent on innefectual copy protection mechanisms is time *not* spent improving your game.

[font="Calibri"]9- A camera (or view-port) looks into the world -- the camera moves and only draw's the part of the world that is in view. Its basic algebra, nothing too difficult.[/font]

[font="Calibri"]10- I'm sure there are. Though with programs that need to be installed, testers are sometimes wary of viruses, etc. For a Java game, it might be better to host embed it in a webpage (minecraft does this too) which, I think, imposes some additional sandboxing around the Java run-time (but I'm not sure).[/font]


Share this post


Link to post
Share on other sites
thank you Ravyne, it was very clear, i didnt thought about that time *not* spent improving my game, and of course im not expecting any of my games to be worthy of piracy anytime soon, i was just curious about it.

while waiting for answers here, i've made a lot of research on sprite handling, and well im starting to get the hang of it, but still, i havent been able to find info about how the .txt map files works, i dont even know how to get whats inside of it on my game, so i think its a great idea to get a premade map editor, and use it until i feel the need of making my own, but even if i had the perfect map editor, i wouldnt be able to use it on my games since i cant find a way to import data from a .txt

i decided to forget about the fullscreen for now and focus on regular windowed games so i dont have to worry too much about the players machine.

i was wondering about the copyright issues because i see games get a lot of fan-art and there doesnt seem to be any problem with it, so i thought maybe fan-games were allowed too.

about the side-scrolling algorithm, i think its one of those things you have to figure out on the way, nothing will work until i have maps, sidescrolling, and i can handle spritesheets, but when all of them are done, then developing the game will be A LOT easier (at least i hope so).

anyways thank you a lot, it was really helpful, i think im going to make more research on these subjects.

some more questions:

also im not sure what minecraft does, but well i dont exactly want my games to be focused on website, but i've realized switching from a window game to a java applet isnt that hard, so would it be better to make a simple website to host my games and make them playable from the website and also downloadable?, actually, what question that has been on my head for a while is: how does the saving works? i mean i assume i would need to write on the user's PC and i guess i would need to request permission, so i have no clue how to look for it around the net, i mean this could easily be divided in 2 questions:
how do i request permission to write on the user's pc?, do i need to?
how would the save file be?, its a really scary theme for me, i think about it and i cant really come up with a way to save all parameters and all stuff, maybe its not as complex as i think, maybe its even worse.
also i dont want my game to include any online feature yet, so i think i shouldnt host the saving database, i think it should be written on the user's computer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!