Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  creating a turn based framework with libgdx  (Read 564 times)
0 Members and 1 Guest are viewing this topic.
Offline forrest10351

Junior Newbie





« Posted 2017-10-04 04:37:04 »

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
Offline forrest10351

Junior Newbie





« Reply #1 - Posted 2017-10-04 15:03:29 »

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!
Offline Riven
Administrator

« JGO Overlord »


Medals: 1313
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2017-10-04 15:27:06 »

1  
if(playerturn = false){

This does not do what you think it does Pointing
It sets playerturn to false, then checks whether it is true.

1  
if(playerturn == false){

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline forrest10351

Junior Newbie





« Reply #3 - Posted 2017-10-04 15:57:01 »

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.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1313
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2017-10-04 16:23:53 »

It's basically the distinction between a comparison
==
, and an assignment:
=


What you basically did was:
1  
2  
3  
4  
playerturn = false;
if(playerturn){
   ...
}
As you assigned 'false' to 'playerturn', before the if-condition was evaluated.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline bmanmcfly
« Reply #5 - Posted 2017-10-04 18:40:30 »

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

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.
Offline rolen

Senior Newbie


Medals: 1



« Reply #6 - Posted 2017-10-06 21:02:27 »

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.
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (52 views)
2017-09-30 02:57:34

theagentd (76 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (182 views)
2017-08-02 12:19:43

cybrmynd (189 views)
2017-08-02 12:18:09

Sralse (197 views)
2017-07-25 17:13:48

Archive (747 views)
2017-04-27 17:45:51

buddyBro (881 views)
2017-04-05 03:38:00

CopyableCougar4 (1429 views)
2017-03-24 15:39:42

theagentd (1319 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!