Trying to create a fixed time slice system

This commit is contained in:
Kayne Ruse
2013-06-02 04:00:26 +10:00
parent 4c670c3a22
commit 6a16e341ec
9 changed files with 31 additions and 63 deletions
+2 -3
View File
@@ -1,7 +1,7 @@
#include "player.hpp"
#define ANIMATION_SPEED 100
#define WALKING_SPEED 0.14
#define WALKING_SPEED 140
Player::Player(SDL_Surface* s, int w, int h)
: sprite(s, w, h)
@@ -22,10 +22,9 @@ void Player::Update(int delta) {
FaceDirection(Direction::EAST);
}
constexpr double d = 1/sqrt(2);
if (motion.x != 0 && motion.y != 0) {
sprite.SetInterval(ANIMATION_SPEED);
constexpr double d = 1/sqrt(2);
position += motion * d * delta;
}
else if (motion != 0) {
+1 -1
View File
@@ -86,13 +86,13 @@ void SceneManager::LoadScene(SceneList sceneIndex) {
switch(sceneIndex) {
//add scene creation calls here
case SceneList::FIRST:
#ifdef DEBUG
case SceneList::TESTSYSTEMS:
activeScene = new TestSystems(&configUtil, &surfaceMgr, &netUtil);
break;
#endif
case SceneList::FIRST:
case SceneList::SPLASH:
activeScene = new Splash(&configUtil, &surfaceMgr);
break;
+20 -4
View File
@@ -4,6 +4,8 @@
using namespace std;
#include "splash.hpp"
//-------------------------
//Public access members
//-------------------------
@@ -16,6 +18,20 @@ TestSystems::TestSystems(ConfigUtility* cUtil, SurfaceManager* sMgr, UDPNetworkU
surfaceMgr = sMgr;
netUtil = nUtil;
//subscene; load the resources
Splash* splash = new Splash(configUtil, surfaceMgr);
while(splash->GetNextScene() == SceneList::CONTINUE) {
//wipe the screen
SDL_FillRect(splash->GetScreen(), 0, 0);
//call each user defined function
((BaseScene*)(splash))->RunFrame();
//give the computer a break
SDL_Delay(10);
}
delete splash;
SetNextScene(SceneList::CONTINUE);
playerCounter = currentPlayer = 0;
playerMgr.New(playerCounter++, surfaceMgr->Get("elliot"));
@@ -46,8 +62,8 @@ void TestSystems::FrameEnd() {
}
void TestSystems::Update() {
delta.Calculate();
playerMgr.UpdateAll(delta.GetDelta());
// Delta::Calculate();
// playerMgr.UpdateAll(Delta::GetTime());
}
string IToS(int i) {
@@ -81,7 +97,7 @@ void TestSystems::MouseButtonUp(SDL_MouseButtonEvent const& button) {
void TestSystems::KeyDown(SDL_KeyboardEvent const& key) {
switch(key.keysym.sym) {
case SDLK_ESCAPE:
SetNextScene(SceneList::MAINMENU);
QuitEvent();
break;
case SDLK_w:
@@ -164,5 +180,5 @@ void TestSystems::SwitchToPlayer(int index) {
}
void TestSystems::SendMessage(std::string s) {
//
cout << s << endl;
}
-2
View File
@@ -9,7 +9,6 @@
#include "packet_list.hpp"
#include "player_manager.hpp"
#include "delta.hpp"
#include "frame_rate.hpp"
#include "raster_font.hpp"
@@ -47,7 +46,6 @@ protected:
PlayerManager playerMgr;
Delta delta;
FrameRate frameRate;
RasterFont font;