Original Post
I was told a while back that declaring global objects/variables,etc was bad programming. That put me in a predicement. I was thinking of different ways to implement weapons into a game, and thought of declaring a global object as an array of 5, then create a function which allows me to simply set the weapon name for each array, giving me 5 weapons with separate names. Would this be considered bad programming or was I just misinformed? an example of what I want to do is: Gameloop.cpp Was I told the correct information, but took it the wrong way? Maybe he meant, declaring variables globally in the main.cpp file? I'm not exactly sure, but would this approach be alright or would I be noobish to do it?
#include "Library.h"
Weapon object[5];
void SetAttrib()
{
object[0].SetName("Sword");
object[1].SetName("Spoon");
object[2].SetName("Axe");
object[3].SetName("Knife");
}
void gameloop()
{
// I would initialize all the items and monsters
// the same way
SetAttrib();
// Done initializing monsters, items, etc
// Gameplay starts
}