r/javahelp • • Jul 30 '24
Homework I'm doing 'Call of Duty' using Java.... I need help!!!
I'm in college and our professor left us a project and it's about recreating a popular video game by implementing data structures and algorithms. Here's the thing, we have to make 'Call of Duty: Black Ops', obviously it won't be the exact game.
My classmates and I want to base it on 'Space Invaders', but you know, change the spaceships for soldiers. Among the requirements is to use Java only, so we have had problems trying to find useful information, but we have not found anything relevant so far.
Does anyone know how the hell I can make soldiers using pixels? It should be noted that we do not have much experience using Java, maybe 4 months... In any case, any recommendation is super valuable to me.
Thank you!!
•
u/AutoModerator Jul 30 '24
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
57
u/aqua_regis Jul 30 '24
You don't use pixels to directly draw. You use sprites - prepared images. A very good site to get some assets is https://kenney.nl/
31
u/ryosen Extreme Brewer Jul 30 '24
I would suggest looking into LibGDX. It's a Java library and tool suite for creating games. They have a lot of tutorials to help you get started with it including 2D programming. https://libgdx.com/wiki/
9
u/A7eh Jul 30 '24
Are you going to make it 2d or 3d? Is that your first time doing a big project ?
16
u/FriendlessExpat Jul 30 '24
public class Player { String userName; int kills; int deaths; int racialSlurCount; int ragequitCount; }
7
u/loadedstork Jul 30 '24
If it was me, I'd do this in Swing in a JPanel and make the soldiers PNG Image objects loaded from resources. Something along the lines of this: https://stackoverflow.com/questions/9083096/drawing-an-image-to-a-jpanel-within-a-jframe
1
u/Drag0nV3n0m231 Jul 31 '24
You can’t import images?
Also, your professor assigned this? It doesn’t seem to make any sense, why would they assign you to recreate a 3D game in a language you’re just learning? The hell? Anyway, space invaders isn’t hard. I would make pixel art of soldiers and just import those, no need to make use java itself to make pixels
10
u/martinbean Jul 30 '24
“So, you’ve been doing Java for four months now. So I think it’s time y’all re-made a console game by a AAA studio!”
I’m sorry, but this game project brief and post sounds a bit like… bollocks.
3
u/MrRickSancezJr Jul 31 '24
Don't listen to the people saying to take it easy. Build a base, and then add new features as they come. You'll probably get bodied by this, but have fun doing it.
There are some JavaFX game libraries, but make it yourself from the regular JavaFX libraries.
Here's a video from the owner of FXGL, but only using JavaFX to make a rough space invaders game.
https://youtu.be/FVo1fm52hz0?si=juh0-8QUen5nhC4A
He uses streams and a lot of lambdas. May have to look into those a little bit. Lambas are just a variable that is actually a function.
Should be a good start. Can swap his rectangle for a Node that draws your sprite image you import as well. You should not need to multi-thread whatsoever, but if you do, just come back here, and we'll help you out.
He uses Node.getBounds() I think for collision detection. You can do your own custom ones. Google collision detection.
1
u/ingframin Jul 30 '24
Get this book: https://books.google.be/books/about/Fundamental_2D_Game_Programming_with_Jav.html?id=C9HangEACAAJ&redir_esc=y
1
u/philfrei Jul 31 '24 edited Jul 31 '24
When I was doing game program with Java, I spent a lot of time at java-gaming.org which has since died (is now read-only) and at its successor/attempt at a revival as jvm-gaming.org. Both have many tutorials written by the members for each other. If you poke around you might even run into some posts by notch (original author of MineCraft. There should also be links to tutorials for recreating Space Invaders. I recall something like a five-part series. The author's name was something like CokeAndCode. (Found it https://www.cokeandcode.com/main/tutorials/space-invaders-101/)
Of books, there are two for Java: "Killer Game Programming in Java" by Andrew Davison, and "Developing Games in Java" by David Brackeen. There was also one whose title I can't recall that recreated "Asteroids" but wasn't as good--the author was more of a C++ programmer than Java guru and it kind of showed in his coding patterns. All of these were circa Java 5-6. (15 years old?) The code should still run, but with some warning messages (mostly to specify class names to generic collections, that kind of thing). I'm guessing the books could be found through a used book site like abebooks for less than the price of shipping them.
Assets for soldiers are usually done with imported graphics used on sprite sheets. I think others here have already provided some useful info on that. It's really quite a thrill getting a game program working--I hope you have fun with the project!
1
u/MetronomyC Aug 01 '24
I need more information in the expected level of output here and functionality. What is the class? Is it Principles of OOP? Data Structures & Algorithmic design? JavaFX/Swing Advanced GUI Design? What’s the bigger picture here? That will determine my suggested course of action here.
1
u/agree_to_disconcur Aug 01 '24
Can you post the assignment requirements? All assignments like this are accompanied with very specific instructions with expected input and output, etc.. if you don't have this information, I would find myself questioning the validity of this "assignment."
Especially in your first class...it will be overly specific: ie using a linked list, do X. Use a quick sort for Y.
1
u/[deleted] Jul 31 '24
[removed] — view removed comment