I’m somewhat new to programming and newer still to libgdx. I am working on a turn based, tactical, rpg similar to fire emblem or final fantasy tactics, after having worked through some tutorials. So far I have been able to render an enemy, a player, and let the player move in a turn based fashion. Now I want to set up some basic “AI” for the enemy. basically I want it to move along the X axis until it is 1 tile away from the player, but for some reason it is not working. here is the relevant code. if anyone has any help for a newb it is appreciated.
https://pastebin.com/MpkU8BBn
https://pastebin.com/dwHPhRiK
https://pastebin.com/5juT8jez
so I have been playing around with the code and I think i have figured out the fundamental issue im having. any help is greatly appreciated.
at the end of the (player) move method i have a condition.
if(energy==0){
playerturn=false;
}
basically once the player has used all of their energy, the boolean that controls if the player move or enemy move method is active, is set so that the enemy has their turn. however the enemy move method doesnt seem to recognize the change in the boolean’s state. it starts off as such:
public void enemyMove(EnemyCharacter activeEnemy){
if(playerturn = false){
System.out.print("test");
but it never prints out test in the console.
however if I change the enemy move method to:
public void enemyMove(EnemyCharacter activeEnemy){
if(energy==0){
System.out.print("test");
it starts to work. I dont understand why using energy to change a boolean value doesnt work but relying on the energy value itself does. Once again thank you for any help you can give!
if(playerturn = false){
This does not do what you think it does :point:
It sets playerturn to false, then checks whether it is true.
if(playerturn == false){
Thank you very much, I’ve gone through at least a few java tutorials and either never learned or forgot about that distinction! felt like I was going crazy haha.
It’s basically the distinction between a comparison [icode]==[/icode], and an assignment: [icode]=[/icode]
What you basically did was:
playerturn = false;
if(playerturn){
...
}
As you assigned ‘false’ to ‘playerturn’, before the if-condition was evaluated.
First off, I think you should scale down your project considerably. Since you are new to programming, and particularly graphical programming. (I suspect you got into it because you wanted to make games, right?) You’ll get alot more out of making a graphical tic-tac-toe game as a beginning.
To answer your question though, if you want a turn based system you would have to split the logic between “player turn” and “process entities” for that turn once the turn is complete, for every turn.
Just to give an idea of just how much you’ll need to work out :
- player controls
- leveling
- map loading
- camera controls
- NPC’s
- enemies
- probably going to need pathfinding
- collision detection (with enemies for fighting, NPC’s for talking, etc)
- a quest system (because there needs to be a reason to go into the dungeon)
- HUD
- Inventory system
- save / load
- sound / music
- transitions
- finally, getting into the finishing touches of special effects, transitions, etc.
- almost forgot, then the balancing… because you don’t want your level 3 mage to be able to take down the last boss
Another factor, because you are going to wind up with hundreds of classes and sub-classes and dealing with alot of similar but slightly different code (a rat will use similar logic to a warlock, but the warlock might be able to cast spells), so, before you get into making an RPG, you will probably want to get into an entity based system (like ashley). That involves it’s own learning curve thinking in terms of components and systems that process those components.
So, you’ll be much better off if you only need to concern yourself with:
- defining the map (3x3)
- determine whose turn, whether player or AI
- determine a winner
Then, after 2-3 weeks working on that and getting it solid, you’ll be much better prepared for something a bit more complex…
After working on increasingly larger projects your confidence and skills will improve and you will have a better sense (and a code base).
I can tell you from experience, when you start on a too large of project you will not consider things that may not seem important but will ultimately break your code as you add to it. That frustration leads many to just give up. Better to start by debugging a project with 5-10 classes than when your project is 20% done and you’ve got to sort through 50+ files to determine which interaction is causing some obscure bug.
There’s a reason why a game like final fantasy tactics took a team of around 200 people several years to complete.
i have a turn based prototype in the making. its tile based, it has movement attack and turn based system with simple ui.
it wasn’t that hard to make and i simplified alot of process.
contact me and next week i will be able to walk you trough all of it personaly.
im planing on turning it to a tutorial because i haven’t seen any on that subject. so i wouldn’t mind testing my tut material on somone before i publish it.
turn based tactics isnt easy to implement as you might think.