slooksterpsv
February 27th, 2014, 08:08 AM
I've found a few bugs in my game as I've been working on it, and something is hammering into my mind that it's my camera class causing the corruption (and it may not be in any shape or form).
Here's what I'm doing:
I have a bunch of classes and a few select ones depend on my camera interface for things such as:
Player
Collision
Enemy
Objects
Weapons
etc.
Now here's what I'm doing:
Each of those classes have a pointer called:
Camera* cam;
Each of those functions when initialized take a pointer to camera via:
OnInit(Camera* camera)
Each of those classes assign cam the following way:
cam = camera;
Each of those classes are invoked via:
Player* player = new Player();
player->OnInit(&cam);
Weapon* weapon = new Weapon();
weapon->OnInit(&cam);
etc.
Is that the best way? Should I make it a global variable? Could it be something else causing memory corruption? Now when my game first loads, the map is skewed. The last things I did were:
Fixed bug where I was storing strings like so (from a file):
Changed the following from:
char tset[80];
fscanf(map, "%s", &tset);
To:
char tset[80];
fscanf(map, "%s", tset);
I'm about to upload my entire project just to seek help finding these issues, but it's very very undocumented code.
Here's what I'm doing:
I have a bunch of classes and a few select ones depend on my camera interface for things such as:
Player
Collision
Enemy
Objects
Weapons
etc.
Now here's what I'm doing:
Each of those classes have a pointer called:
Camera* cam;
Each of those functions when initialized take a pointer to camera via:
OnInit(Camera* camera)
Each of those classes assign cam the following way:
cam = camera;
Each of those classes are invoked via:
Player* player = new Player();
player->OnInit(&cam);
Weapon* weapon = new Weapon();
weapon->OnInit(&cam);
etc.
Is that the best way? Should I make it a global variable? Could it be something else causing memory corruption? Now when my game first loads, the map is skewed. The last things I did were:
Fixed bug where I was storing strings like so (from a file):
Changed the following from:
char tset[80];
fscanf(map, "%s", &tset);
To:
char tset[80];
fscanf(map, "%s", tset);
I'm about to upload my entire project just to seek help finding these issues, but it's very very undocumented code.