So, I want to be a game developer, and I know that Java isn’t necessarily used for making games that much anymore, but I’m going to be retaking a class for Java soon, so I want to see what I can do with it since (assuming the class goes the exact same way as last time) we do not make any games in this class. Since I’m working with a tutor who knows my learning style (typically more hands on), she suggested that I look up a simple tutorial for making a simple game in Java. Unfortunately, said tutorials for Java are surprisingly lacking when compared to languages like Python and C++. I also would like to mention that I do use IntelliJ, but lately have been using the good ol’ Notepad/Command Line way of coding, mostly for fun, but also because so far it’s actually helped me focus a little better on what I’m doing (though I’m not really sure why). If anyone can provide any resources for beginner projects that involve coding games in Java, I’d greatly appreciate it. Thanks in advance
#Beginner Games you can code in Java?
1 messages · Page 1 of 1 (latest)
<@&987246964494204979> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
I want to practice my skills by creating some simple games. What are some beginner games that I can code in Java?
Here are a few ideas for simple games you can code in Java:
-
Tic Tac Toe: A classic two-player game where players take turns placing X's and O's on a 3x3 grid.
-
Hangman: A word guessing game where players try to guess a hidden word one letter at a time.
-
Guess the Number: A game where the computer generates a random number and the player has to guess it within a certain number of tries.
-
Blackjack: A card game where players try to get as close to 21 as possible without going over.
-
Snake: A classic arcade game where players control a snake that grows longer as it eats food, while avoiding running into walls or itself.
These games are relatively simple to code and can help you practice fundamental programming concepts in Java such as loops, conditionals, and user input. Once you feel comfortable with these games, you can start exploring more advanced game development concepts and tools in other languages like Unity or Unreal Engine.
i recommend using LibGDX (a simple library for game development in java)
I suppose I should’ve mentioned that I am coding illiterate lol (I do not know what that means)
oh so you do not know java yet?
"LibGDX" is just the name of the library if you were confused by that, or do you not know what a library is?
Simple console games are an excellent first step.
but honestly as a beginner you would first code like console games, and a graphical game when you know at least the basics (but better be more advanced than just the basics)
Java tutorials are lacking compared to C++? Idk about java, but I know that in the C++ world there is a grand total of one good tutorial...
Do you know what object oriented programming is? If not, i'd suggest starting far more basic than any game...
I can’t help feeling a little hurt by that. I know what object oriented programming is. I may say I’m coding illiterate but I’m not that incapable… I said that about C++ because C based languages are used quite commonly in game development, so it would make sense that they had to start somewhere
you should describe a little bit more what you want and on which level you are. So do you want to make a graphical game like a pong or do you want to make a console game and learn the basics of java with that?
I'm sorry I wasn't asking that to hurt your feelings, I was asking to understand what to recommend better
And hearing that I'd follow the others' recommendation starting with a console app
try to make a terminal tictactoe app
try to make it have an AI which will play against you
an "ai" you can easily have the full search tree of a tic tac to game in memory and let the computer make the optimal move
simple alpha beta search
Something really basic (pun not intended). Like, I’m only wanting to code a game at this point because as I showed, I’m a hands on learner. A textbook alone isn’t going to teach me anything, and most of the exercises in said textbooks felt like they weren’t teaching me that much (it just felt like copy and pasting…). I don’t know how else to describe it really. The only thing I know for sure is that I ideally don’t want the game to be text based, since that feels like I’d be coding literally any other application where you have to have user input
do you already know coding? e.g. do you know C++?
I was told C++ was really hard so I haven’t touched it yet (though I do want to eventually). I have some experience in Python, but I don’t really know if said experience would be helpful in this case
Also it’s all good. Sorry for the late reply
yea c++ is really fucking hard
its not. its just that people prefer to teach c++. from the 90s - often bc they dont know better
thats like showing someone java 4. thats "hard" as well
i want to know C++ from the 90s, i like it. all the modern things i can use later, but i do want the raw memory and not abstract everything nice away with smart pointers and RAII
modern c++ isnt much harder than modern java or python. it just has a focus on topics that people might not find relevant, especially as beginner.
most notably lifetime and ownership of objects
c++, like many languages that arent java or python, suffers from good and free learning material being available. so the road can be bumpy
i would recommend something more easy first than, but if you really want to throw yourself into the cold water: look for a "LibGDX" tutorial, and code something simple like a pong there
So is LibGDX something you have to import or smth?
yes it is a library for game development
like pygame in python
but libgdx sets up the project for you
when you download it
Is it something you can get in the same way as JOptionPane where you can just kinda implement it with the import statement or do I have to get it separately (I remember having to do the latter for pygame)
there is a setup jar
i mean ok i might be much less smart than you are but like
auto switch_to_new_thread(std::jthread& out)
{
struct awaitable
{
std::jthread* p_out;
bool await_ready() { return false; }
void await_suspend(std::coroutine_handle<> h)
{
std::jthread& out = *p_out;
if (out.joinable())
throw std::runtime_error("Output jthread parameter not empty");
out = std::jthread([h] { h.resume(); });
std::cout << "New thread ID: " << p_out->get_id() << '\n';
}
void await_resume() {}
};
return awaitable{&out};
}
struct task
{
struct promise_type
{
task get_return_object() { return {}; }
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
};
task resuming_on_new_thread(std::jthread& out)
{
std::cout << "Coroutine started on thread: " << std::this_thread::get_id() << '\n';
co_await switch_to_new_thread(out);
// awaiter destroyed here
std::cout << "Coroutine resumed on thread: " << std::this_thread::get_id() << '\n';
}
int main()
{
std::jthread out;
resuming_on_new_thread(out);
}
Can you point out the undefined behavior here? (this is an example from the reference)
Detected code, here are some useful tools:
lol
Here's a tip: It's a use-after-free
you are invading a help thread
anyways TL;DR my point is java is great choice to start to learn programming, and c++ is much harder
i understand that you may be interested to do GUI but that comes with a whole heap of issues, foremost those caused by multithreading: e.g. race conditions
Which brings me back to the tic-tac-toe suggestion as a warmup to get more familiar with the language
and the AI idea to get more familiar with implementing slightly more complex logic
I can’t help feeling like my comment got a bit lost in the shuffle…
i like C++, and just because things like UB, and direct memory access and getting segmentation faults because you made a mistake can be a little harder that is no point against it, there is nothing bad in learning a non trivial language
it is an external library
you download it
and execute the setup jar
this sets up a project for you
Sooo… not like JOptionPane (I’m sorry for being stupid I don’t remember learning about libraries last time I took Java…)
swing is in the standard library that is why you can just directly import it
other libraries you have to install first, e.g. via a package manager like Maven or Gradle, or include a jar in the build path
but the libgdx setup jar does that for you
Where would one find the downloads? Like, is there an official site for them? I don’t want to get a virus
libgdx has a official site there you find the download
and for maven and gradle projects there is "maven repository"
but i agree with this too be honest. i think that may be too hard to start with, i would learn the language first to a certain level
i dont really think this snippet is representative for anything a beginner will face when learning programming with c++. and thats kinda what i was aiming at. especially since ull find difficult quirks like that in any language in mkre advanced scenarios
im more thinking of pointer arithmetic, raw c-arrays and all the stuff around rule-of-5, virtual and whatnot that is the main focus of any c++ beginner course, giving everyone a headache and thinking programming is more complex than it has to be, while essentially not being at a focus in modern day programming with c++ at all
its focused on the internals and how the language works rather than teaching people how to program first
but thats also bc most learning material available for c++ has that as target audience and not programming beginners. but is then being used to teach those
ur right. im sorry. lets continue in #geek-speak