• Create Account

### #Actualwarnexus

Posted 18 May 2013 - 11:03 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

What is a violation of DRY? What dictates a simulation logic?

### #7warnexus

Posted 18 May 2013 - 10:17 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

What is a violation of DRY? What dictates a simulation logic?

I do not think of a loop is right for my draw method because the draw method of every game object is called if these game objects are added to an Arraylist that stores these game objects.

### #6warnexus

Posted 18 May 2013 - 10:14 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

What is a violation of DRY? What dictates a simulation logic?

### #5warnexus

Posted 18 May 2013 - 10:13 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

What is a violation of DRY? What is a simulation logic?

### #4warnexus

Posted 18 May 2013 - 10:12 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

What is a violation of DRY?

### #3warnexus

Posted 18 May 2013 - 10:12 PM

I still don't know about slowdown because I don't know what determines how often your draw code is called. I do know now that you have simulation logic in your draw code, which is a no-no. Also, that function is a significant violation of DRY.

//put the position limits in an array

public void draw(Graphics g) {
int xpos = position.getX();
for(int i = 0; i < 5; ++i) {
if(xpos < positionLimits[i]) {
g.drawImage(alienMovementAnimation.get(i), xpos, (int)position.getY(), null);
break;
}
}

//Game.setGameWon(true); //do this in the logic, not in the drawing!

}


Game objects are added to an Arraylist. A for each loop goes through each element in the array list and draws these game objects to the screen for every iteration of the game loop.

PARTNERS