[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
space game
oh yeah, in my last message I forgot to answer one question.
The table of jump gates is probably going to be a list of pointers to port
objects. Each gate would have two port entries. I have yet to do any work on
this code, but I am sending a copy of the Port class that you can reference.
/* GSG, pre-alpha, created and copyright by Darel Finkbeiner.
This code is subject to the GNU Public License.
Warning: this is in no way complete. In fact it doesn't do anything yet except
for altering some memory on your system.
*/
#include <iostream.h>
#include <stdlib.h>
int port; //this holds the current port number, has to be a better way than global var
class Port {
char* Name;
int Minerals, Organics, Fuel; //this is the actual amount of each
int MinAvail, OrgAvail, FuelAvail; //this is the amount that is gained each turn from mining
public:
Port(char* name) {
Name = name;
MinAvail = 5; //set up defaults for testing
OrgAvail = 60;
FuelAvail = 30;
}
void setAmounts(int min, int org, int fuel) { //used to set the starting amounts
Minerals = min;
Organics = org;
Fuel = fuel;
}
void showStats() { //wouldn't a gfx version of this be nice? :-)
cout << Name << endl;
cout << "Minerals: " << Minerals << endl;
cout << "Organics: " << Organics << endl;
cout << "Fuel: " << Fuel << endl;
}
void processTurn() {
Minerals += MinAvail;
Organics += OrgAvail;
Fuel += FuelAvail;
}
};
Port *currPort; //pointer to the current port object, again, I don't like this as a
//global variable
Port* CreatePort(char* name) {
Port* tempPort = new Port(name);
tempPort->setAmounts(10, 10, 20);
return tempPort;
}
struct PortMap { //creates an array of port object pointers and initializes them
Port *portList[5]; //later dev should allow for reading a file to restore a
//previously created galaxy, also be able to read in a list
PortMap() { //of port names
int x;
for(x = 0; x < 5; x++) {//this obviously is where the major changes would be
portList[x] = CreatePort("Unnamed");//They all have the same name, sigh
}
}
};
void MainLoop(PortMap *currMap) { //mainloop
// do stuff here. I change this thing every five minutes to see if something is
// working correctly.
}
void main() {
PortMap *thisMap = new PortMap();
port = 0;
while(true)
MainLoop(thisMap);
}