#include <iostream>
#include "Musket.hpp"
using std::cout;
void Musket::Start() {} //definition required, even if it's empty
void Musket::FixedUpdate(){}
void Musket::End() {
cout << "end\n";
}
int loop = 5;
void Musket::Update(double dt) {
cout << "update\n";
if (loop <= 1)
Musket::Exit(0);
else
--loop;
}
int main() {
Musket::Init();
return 0;
}
#include <iostream>
namespace Musket{
void Start();
void Update(double dt);
void FixedUpdate();
void End();
namespace { // "anonymous" namespace
class World_Controller {
public:
bool game_running;
void WC_Init() {
game_running = true;
std::cout << "init\n";//testing
}
void WC_Start() {
//
}
void WC_Update() {
//
}
void WC_FixedUpdate() {
//
}
void WC_End() {
//
}
~World_Controller() {
std::cout << "game over\n"; //testing
}
};
World_Controller Musket_Controller;
/*
void Musket_Start() {
}
void Musket_Update(double dt) {
}
void Musket_Fixed_Update() {
}
void Musket_End() {
Musket_Controller.game_running = false;
}
*/
void Musket_Game_Loop() {
Musket_Controller.WC_Start();
Start();
double dt = 0.0; //placeholder
while(Musket_Controller.game_running) {
Musket_Controller.WC_Update();
Update(dt);
//work out fixed update later
}
End();
}
}
void Init() {
Musket_Controller.WC_Init();
Musket_Game_Loop();
}
void Exit(int exit_code) {
Musket_Controller.game_running = false;
}
void Set_FPS(unsigned int fps) {}
};
#ifndef MUSKET_HPP
#define MUSKET_HPP
namespace Musket
{
//defined by user
void Start();
void Update(double dt);
void FixedUpdate();
void End();
//pre-defined, but callable by user
void Init();
void Exit(int exit_code);
void Set_FPS(unsigned int fps);
}
#endif