Hello all, i tried to make the title as much informative as possible.
Anyhow, i’ll try to be brief - I’m fairly new to java programming and programming altogether,
after learning the basics and some advanced concepts i made a console version of a custom version of a turns-based card game (essentially the goal is to have the lowest hand “value” based on your cards ranks), with the player playing against a single computer “player”.
Now to make the console version i created the classes i needed (Card,Deck,Player Hand and Pile), and then in my Main class i created the game itself by using nested while loops:
while (!roundOver){
while (playersTurn) {
...
playersTurn = false;
}
while (!playersTurn) {
computer's decision making based on his hand, the card in pile etc;
playersTurn = true;
}
}
}
the decisions made by either the player or the computer were handled by methods in the player hand class,
where if either the computer or the player wins the round, roundOver is changed to true and the player is able to start another round.
Now for what i’m here for - I wanted to make a Gui to play the game,and for that i chose to experiment with JavaFX because of it’s built in effects, animations etc. that fit nicely into my game “vision”.
I tried reading some online articles and watching youTube videos but neither helped me understand - how do i implement this event-driven game loop similar to the one i made in the console version, as in how should my program look like for making it “turn based” where each time it’s either the player’s or the computer’s turn…
I’m using JavaFX Scene Builder so currently my program is made of the GUI FXML file, the FXML Controller class, the the main class and the game component classes (card, deck etc.).
After creating and customizing the game window with JavaFX scene builder and creating fields that enables to start a new game, I’m lost. I don’t really have the grasp of how my program should look like in terms of where do i insert event handling, and essentially how to make a turn-based event-triggered Javafx program.
I’ll just clarify that i’m not looking for someone to write code for me, what i’m after is a general explanation that will clarify the concept of event-triggered actions in JavaFX Guis, and perhaps Guis in general.
Thanks in advance!