Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (736)
Games in Android Showcase (223)
games submitted by our members
Games in WIP (813)
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  
  Turn based combat turn order  (Read 714 times)
0 Members and 1 Guest are viewing this topic.
Offline PotatoBytes

Junior Newbie




We are a group of three students


« Posted 2014-05-06 22:22:19 »

I'm working on a project for my class at a tech center, and am making a turn-based rpg in Java. Currently I'm looking at using either a priority queue or a linked list to store the order of the characters in battle each round. Which should I be using? Or is there a better way I could be doing it?
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #1 - Posted 2014-05-06 22:26:17 »

You could do that, but unless you need some advanced properties that I didn't get a whiff of, you could more simply use a ArrayList and sort it via Collections.sort().
99% of the time you don't need a data structure more complicated than a List/array type.
Offline PotatoBytes

Junior Newbie




We are a group of three students


« Reply #2 - Posted 2014-05-06 22:28:00 »

Well, we plan to add features after getting a basic system working, including things such as the ability to cast a haste or slow spell in order to change a character's speed.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #3 - Posted 2014-05-06 22:34:59 »

I'm assuming your system works something like each character has a "cooldown" or a count down till next action?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
// in BattleHandler or something

updateAllEntities(); // decrements Entity.cooldown for each, plus whatever logic

for(Entity character : yourParty) {
    if(character.cooldown <= 0) {
        character.performAction();
        character.resetCooldown();
    }
}

// then to "slow down" an opponent, all you do is add to their cooldown:

public void stun(Entity target, int timeToSlow) {
    target.cooldown += timeToSlow;
}


This is just a simple method I came up with, and is based off of game ticks, but you could also use actual time if game-tick based logic is undesirable (despite it's nice determinism).

You could also store priorities in the entities and just sort the list every frame, and unless you have hundreds of entities, it won't really matter.
Offline PotatoBytes

Junior Newbie




We are a group of three students


« Reply #4 - Posted 2014-05-07 01:56:47 »

Awesome, thanks! We've been thinking about storing the priorities for each character, but doing it with ticks is also a pretty good idea. Thanks for the help!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

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

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

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

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

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

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

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

theagentd (1235 views)
2017-03-24 15:32:08

Rule (1213 views)
2017-03-19 12:43:22

Rule (1264 views)
2017-03-19 12:42:17
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!