Although, disjoint else-if statements are actually faster in some programming languages. 
Yes, that's right, and that's why it's absolutely correct to use them.
« previous next » |
Posts: 46
LoggedPosts: 41
LoggedPosts: 41
Loggedpublic void targetExecutionCode() {
/** A.I. targeting execution code!!! */
/** join the if-s
if(Buffer.Player().ai == true && mode == Constant.selectYourTarget) {
if(animationIterator == animationDelay-1) {
contentPane.remove(screen);
*/
if((Buffer.Player().ai == true) && (mode == Constant.selectYourTarget)
&& (animationIterator == animationDelay-1)) {
contentPane.remove(screen);
/**
* a switch replacing the commented if-else structures
*/
switch(attackType) {
case Constant.normalAttack :
if (Buffer.Player().range > 2) {
attackType = Constant.rangedAttack;
}
battleAnimation = new MeleeSequencePanel(Buffer.Player(),Buffer.getEnt(targets[0]));
battleAnimation.setBounds(0,0,maxX,maxY);
/* TODO: Stop local animation loop? */
contentPane.add(battleAnimation);
break;
case Constant.rangedAttack :
rangedAnimation = new RangedSequencePanel(Buffer.Player(),Buffer.getEnt(targets[0]));
rangedAnimation.setBounds(0,0,maxX,maxY);
/* TODO: Stop local animation loop? */
contentPane.add(rangedAnimation);
break;
}// switch
} // combined if
} // end of targetExecutionCode()
/**
* Replaced if-else structure in targetExecutionCode()
*
* case constant.normalAttack
*
* if(Buffer.Player().range > 2 && attackType == Constant.normalAttack) {
attackType = Constant.rangedAttack;
}
if(attackType == Constant.normalAttack) {
battleAnimation = new MeleeSequencePanel(Buffer.Player(),Buffer.getEnt(targets[0]));
battleAnimation.setBounds(0,0,maxX,maxY);
TODO: Stop local animation loop?
contentPane.add(battleAnimation);
}
else if(attackType == Constant.rangedAttack) {
rangedAnimation = new RangedSequencePanel(Buffer.Player(),Buffer.getEnt(targets[0]));
rangedAnimation.setBounds(0,0,maxX,maxY);
TODO: Stop local animation loop?
contentPane.add(rangedAnimation);
}
a complicated way to call repaint()
this.paint(this.getGraphics());
mode = Constant.modeAttack;
changing the sound
JukeBox.PlayBattleTune(); */
Posts: 41
Loggedpublic static final int overlandWalking = 0;
public static final int standardMenuActive = 1;
public static final int selectYourTarget = 2;
public static final int modeAttack = 5;
public static final int statusCheck = 6;
public static final int endOfTurn = 7;
[/code}
etc...
Posts: 837
LoggedPosts: 41
LoggedPosts: 837
LoggedPosts: 1,208
LoggedPosts: 837
LoggedPosts: 41
Loggedprivate int up = 0;
private int down = 0;
private int left = 0;
private int right = 0;
/**equals 1 if particular button was once pressed and not released yet.*/
private int opup = 0;
private int opdown = 0;
private int opleft = 0;
private int opright = 0;
Posts: 41
LoggedPosts: 1,129
LoggedPosts: 41
LoggedPosts: 41
Logged