Skip to main content
gamedev.net
🔒 Locked

Java turn-based game

Started by vincent_cloudy 3 replies 400+ views
Original Post
vincent_cloudy
vincent_cloudy
I am working on the turn-based game, but it is quite strange that the speed is too fast, I mean when the player meet the enemy, it will directly go into the battle mode, the battle mode is use turn-based. But after the player select the action, it immediately does all the thing and return to the player turn, that mean, after you select your action , e.g Attack, then enemy HP is deduced, he choose action and have effect on you. you can see nothing but all the things are already changed. How can I correct it? or what is the structure of turn-based game?
Raghar
Raghar
System.nanoTime()
Or better small sleep after each frame.
vincent_cloudy
vincent_cloudy
Sorry, little confuse.
my structure is something like...

class battle{

battle(){
done=false;
roundForPlayer=false;
}

start(){
roundForPlayer=true;
}

update(){
if(roundForPlayer){
battle(); <-- computer turn to choose action
}
}

draw(Graphics2D){
if(roundForPlayer){
g.drawString("Player Turn");
}else{
g.drawString("Enemy Turn");
}
}

actionPerformed(){
if(button==button1){
roundForPlayer=false;
}

it is looping while done is false;(exit battle mode)
in fact it is a GameState which taught in the Book "Developing game in Java"
start() -> draw()->update()-)draw()......

so my mind is when the player choose attack or defend, the turn will change to "Enemy",after enemy do something, turn will change to Player again.

But I now find that no action when I click button.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.