Skip to main content
edited body
Source Link

Single switch script

  • Everything is in one place, better readability.
  • It will be a lot easier to add cases (powerups) when needed.
  • Centralized ressources = good.

Multiple scripts

  • Can help when the cases have too much lines.
  • Object-oriented, can be easier to call cases.

Looking at your example, the best way to go would be to have one script with a switch case. The example case you gave is simple and I don't really see the need to put it in another file. This would only cause the code to be difficult to maintain, mainly because each case would be in it'Sit's own file of 7 lines. For simple cases, keep them in a switch case.

You can, however, put some of your cases in seperate files if they take too much space and harm readability. The switch case would then call the said script.

Keep this in mind: concise code is ofter better, especially when programming video games. Yes, there are good things about OOP but making a class for one line of code is just absurd. KISS (Keep it stupid simple).

Single switch script

  • Everything is in one place, better readability.
  • It will be a lot easier to add cases (powerups) when needed.
  • Centralized ressources = good.

Multiple scripts

  • Can help when the cases have too much lines.
  • Object-oriented, can be easier to call cases.

Looking at your example, the best way to go would be to have one script with a switch case. The example case you gave is simple and I don't really see the need to put it in another file. This would only cause the code to be difficult to maintain, mainly because each case would be in it'S own file of 7 lines. For simple cases, keep them in a switch case.

You can, however, put some of your cases in seperate files if they take too much space and harm readability. The switch case would then call the said script.

Keep this in mind: concise code is ofter better, especially when programming video games. Yes, there are good things about OOP but making a class for one line of code is just absurd. KISS (Keep it stupid simple).

Single switch script

  • Everything is in one place, better readability.
  • It will be a lot easier to add cases (powerups) when needed.
  • Centralized ressources = good.

Multiple scripts

  • Can help when the cases have too much lines.
  • Object-oriented, can be easier to call cases.

Looking at your example, the best way to go would be to have one script with a switch case. The example case you gave is simple and I don't really see the need to put it in another file. This would only cause the code to be difficult to maintain, mainly because each case would be in it's own file of 7 lines. For simple cases, keep them in a switch case.

You can, however, put some of your cases in seperate files if they take too much space and harm readability. The switch case would then call the said script.

Keep this in mind: concise code is ofter better, especially when programming video games. Yes, there are good things about OOP but making a class for one line of code is just absurd. KISS (Keep it stupid simple).

Source Link

Single switch script

  • Everything is in one place, better readability.
  • It will be a lot easier to add cases (powerups) when needed.
  • Centralized ressources = good.

Multiple scripts

  • Can help when the cases have too much lines.
  • Object-oriented, can be easier to call cases.

Looking at your example, the best way to go would be to have one script with a switch case. The example case you gave is simple and I don't really see the need to put it in another file. This would only cause the code to be difficult to maintain, mainly because each case would be in it'S own file of 7 lines. For simple cases, keep them in a switch case.

You can, however, put some of your cases in seperate files if they take too much space and harm readability. The switch case would then call the said script.

Keep this in mind: concise code is ofter better, especially when programming video games. Yes, there are good things about OOP but making a class for one line of code is just absurd. KISS (Keep it stupid simple).