Next step for basic game or simulation engine.

Hello,

I created a basic object class with some main code. The class allows me to add a object, delete, get settings, settings, move, and test collisions, etc. The program part has a main loop that gets a command prompt then it shows a text grid.

The next step I want to do is have objects able to move. So, I have to create a function like startengine but if I do that I need to setup up. Basic multithreading and a way to get input from the keyboard.

Do anyone have any suggestions?

Vivienne


/// code

#include <iostream>
#include <cstdlib>
#include <string>
#include "include/objects.h"

using namespace std;

const int OBJECTSLIMIT=12;
const int LOCATIONLIMIT=20;

int refreshdisplay(objects & refobjects);

int main()
{
objects object;

// place objects variables
int i,coordx,coordy,choosinglocation=true;
srand(time(NULL));

string commandprompt;
bool continuegame = true;

// loop to init
for(i=0; i<OBJECTSLIMIT; ++i)
{
do
{
coordx=rand()%LOCATIONLIMIT;
coordy=rand()%LOCATIONLIMIT;

if(!object.testcollision(coordx,coordy,0))
{
object.add(1,coordx,coordy);
choosinglocation=false;
}

}
while(choosinglocation);

choosinglocation=true;
}


cout << "World Objects V0.000001preaplhadelta01" << endl;

// refresh display
refreshdisplay(object);

// main loop
do
{
//output prompt
cout << "\r\n\r\nPrompt (/quit to quit):"<<endl;

//cin
cin >> commandprompt;

if(commandprompt=="/quit")
{
continuegame=false;
continue;
}

refreshdisplay(object);

}while(continuegame);

// thank you
cout << "\r\n\r\nThank you for playing" << endl;

return 0;
}

int refreshdisplay( objects & refobjects)
{
int coordx,coordy;
bool a;

cout << "\r\n\r\n";

for(coordy=0; coordy<LOCATIONLIMIT; ++coordy)
{
for(coordx=0; coordx<LOCATIONLIMIT; ++coordx)
{
a=refobjects.testcollision(coordx,coordy,0);

if (a==false)
{
cout << ".";
}
else
{
cout << "X";
}
}

cout << "\r\n";
}

return 1;
}
Last edited on
Topic archived. No new replies allowed.