Quellcode durchsuchen

core: tick methods now use seconds, like any sane system.

legacy
Sam Hocevar sam vor 12 Jahren
Ursprung
Commit
90bfc79b22
42 geänderte Dateien mit 172 neuen und 172 gelöschten Zeilen
  1. +4
    -4
      src/camera.cpp
  2. +3
    -3
      src/camera.h
  3. +3
    -3
      src/debug/fps.cpp
  4. +2
    -2
      src/debug/fps.h
  5. +12
    -12
      src/debug/quad.cpp
  6. +3
    -3
      src/debug/quad.h
  7. +5
    -5
      src/debug/record.cpp
  8. +3
    -3
      src/debug/record.h
  9. +5
    -5
      src/debug/sphere.cpp
  10. +3
    -3
      src/debug/sphere.h
  11. +3
    -3
      src/debug/stats.cpp
  12. +2
    -2
      src/debug/stats.h
  13. +6
    -6
      src/emitter.cpp
  14. +3
    -3
      src/emitter.h
  15. +3
    -3
      src/entity.cpp
  16. +3
    -3
      src/entity.h
  17. +2
    -2
      src/font.cpp
  18. +1
    -1
      src/font.h
  19. +4
    -4
      src/gradient.cpp
  20. +3
    -3
      src/gradient.h
  21. +2
    -2
      src/input.h
  22. +6
    -6
      src/platform/ps3/ps3input.cpp
  23. +2
    -2
      src/platform/ps3/ps3input.h
  24. +11
    -11
      src/platform/sdl/sdlinput.cpp
  25. +3
    -3
      src/platform/sdl/sdlinput.h
  26. +3
    -3
      src/sample.cpp
  27. +2
    -2
      src/sample.h
  28. +4
    -4
      src/sprite.cpp
  29. +3
    -3
      src/sprite.h
  30. +3
    -3
      src/text.cpp
  31. +2
    -2
      src/text.h
  32. +15
    -15
      src/ticker.cpp
  33. +2
    -2
      src/tileset.cpp
  34. +1
    -1
      src/tileset.h
  35. +5
    -5
      src/world.cpp
  36. +3
    -3
      src/world.h
  37. +5
    -5
      src/worldentity.cpp
  38. +3
    -3
      src/worldentity.h
  39. +2
    -2
      test/tutorial/01_triangle.cpp
  40. +6
    -6
      test/tutorial/02_cube.cpp
  41. +13
    -13
      test/tutorial/03_fractal.cpp
  42. +3
    -3
      test/xolotl/xolotl.cpp

+ 4
- 4
src/camera.cpp Datei anzeigen

@@ -52,18 +52,18 @@ mat4 const &Camera::GetProjMatrix()
return m_proj_matrix;
}

void Camera::TickGame(float deltams)
void Camera::TickGame(float seconds)
{
WorldEntity::TickGame(deltams);
WorldEntity::TickGame(seconds);

m_view_matrix = mat4::lookat(m_position, m_target, m_up);
m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 1000.0f);
//m_proj_matrix = mat4::ortho(-160, 160, -120, 120, .1f, 2000.0f);
}

void Camera::TickDraw(float deltams)
void Camera::TickDraw(float seconds)
{
WorldEntity::TickDraw(deltams);
WorldEntity::TickDraw(seconds);
}

} /* namespace lol */


+ 3
- 3
src/camera.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -35,8 +35,8 @@ public:
mat4 const &GetProjMatrix();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
mat4 m_view_matrix, m_proj_matrix;


+ 3
- 3
src/debug/fps.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -55,9 +55,9 @@ DebugFps::DebugFps(int x, int y)
#endif
}

void DebugFps::TickGame(float deltams)
void DebugFps::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

char buf[1024];



+ 2
- 2
src/debug/fps.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,7 +30,7 @@ public:
virtual ~DebugFps();

protected:
virtual void TickGame(float deltams);
virtual void TickGame(float seconds);

private:
DebugFpsData *data;


+ 12
- 12
src/debug/quad.cpp Datei anzeigen

@@ -96,11 +96,11 @@ private:
float x = 0.0f;
for (npoints = 0; npoints < SINE_SIZE && x <= 1.0f; npoints++)
{
float y = 0.5f + 0.5f * lol_sin(x * 2.0f * M_PI + time * 5e-3f);
float y = 0.5f + 0.5f * lol_sin(x * 2.0f * M_PI + time * 5.f);
points[npoints * 2] = aa.x + (bb.x - aa.x) * x;
points[npoints * 2 + 1] = aa.y + (bb.y - aa.y) * y;

float dy = M_PI * lol_cos(x * 2.0f * M_PI + time * 5e-3f);
float dy = M_PI * lol_cos(x * 2.0f * M_PI + time * 5.f);
float dx = SINE_SPACE / sqrtf(1.0f + dy * dy);
x += dx;
}
@@ -119,7 +119,7 @@ DebugQuad::DebugQuad()
: data(new DebugQuadData())
{
data->initialised = 0;
data->time = RandF(10000.0f);
data->time = RandF(10.0f);

m_drawgroup = DRAWGROUP_HUD;
}
@@ -142,16 +142,16 @@ void DebugQuad::Advance()
}
}

void DebugQuad::TickGame(float deltams)
void DebugQuad::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

data->time += deltams;
data->time += seconds;
}

void DebugQuad::TickDraw(float deltams)
void DebugQuad::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

if (!data->initialised && !IsDestroying())
{
@@ -213,7 +213,7 @@ void DebugQuad::TickDraw(float deltams)

GLfloat texcoords[12];
mat4 t1 = mat4::translate(0.5f, 0.5f, 0.0f)
* mat4::rotate(0.0254f * data->time, 0.0f, 0.0f, 1.0f)
* mat4::rotate(25.4f * data->time, 0.0f, 0.0f, 1.0f)
* mat4::translate(-0.5f, -0.5f, 0.0f);
for (int i = 0; i < 6; i++)
{
@@ -224,9 +224,9 @@ void DebugQuad::TickDraw(float deltams)

GLfloat colors[18];
mat4 t2 = mat4::translate(0.5f, 0.5f, 0.5f)
* mat4::rotate(0.0154f * data->time, 0.0f, 0.0f, 1.0f)
* mat4::rotate(0.0211f * data->time, 0.0f, 1.0f, 0.0f)
* mat4::rotate(0.0267f * data->time, 1.0f, 0.0f, 0.0f)
* mat4::rotate(15.4f * data->time, 0.0f, 0.0f, 1.0f)
* mat4::rotate(21.1f * data->time, 0.0f, 1.0f, 0.0f)
* mat4::rotate(26.7f * data->time, 1.0f, 0.0f, 0.0f)
* mat4::translate(-0.5f, -0.5f, 0.0f);
for (int i = 0; i < 6; i++)
{


+ 3
- 3
src/debug/quad.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,8 +30,8 @@ public:
virtual ~DebugQuad();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
void ResetState();


+ 5
- 5
src/debug/record.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -62,14 +62,14 @@ DebugRecord::DebugRecord(char const *path, float fps)
m_drawgroup = DRAWGROUP_CAPTURE;
}

void DebugRecord::TickGame(float deltams)
void DebugRecord::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void DebugRecord::TickDraw(float deltams)
void DebugRecord::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

ivec2 size = Video::GetSize();



+ 3
- 3
src/debug/record.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,8 +30,8 @@ public:
virtual ~DebugRecord();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
DebugRecordData *data;


+ 5
- 5
src/debug/sphere.cpp Datei anzeigen

@@ -121,18 +121,18 @@ DebugSphere::DebugSphere()
data->initialised = 0;
}

void DebugSphere::TickGame(float deltams)
void DebugSphere::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

data->time += 0.003f * deltams;
data->time += 3.f * seconds;
while (data->time > 6.0 * M_PI)
data->time -= 6.0 * M_PI;
}

void DebugSphere::TickDraw(float deltams)
void DebugSphere::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

if (IsDestroying())
{


+ 3
- 3
src/debug/sphere.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,8 +30,8 @@ public:
virtual ~DebugSphere();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
DebugSphereData *data;


+ 3
- 3
src/debug/stats.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -46,9 +46,9 @@ DebugStats::DebugStats(char const *path)
m_gamegroup = GAMEGROUP_AFTER;
}

void DebugStats::TickGame(float deltams)
void DebugStats::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

fprintf(data->fp, "%i %f %f %f %f\n",
Ticker::GetFrameNum(),


+ 2
- 2
src/debug/stats.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,7 +30,7 @@ public:
virtual ~DebugStats();

protected:
virtual void TickGame(float deltams);
virtual void TickGame(float seconds);

private:
DebugStatsData *data;


+ 6
- 6
src/emitter.cpp Datei anzeigen

@@ -50,13 +50,13 @@ Emitter::Emitter(TileSet *tileset, vec3 gravity)
data->nparticles = 0;
}

void Emitter::TickGame(float deltams)
void Emitter::TickGame(float seconds)
{
for (int i = 0; i < data->nparticles; i++)
{
vec3 oldvelocity = data->velocities[i];
data->velocities[i] += deltams * data->gravity;
data->positions[i] += deltams * 0.5f
data->velocities[i] += seconds * data->gravity;
data->positions[i] += seconds * 0.5f
* (oldvelocity + data->velocities[i]);
if (data->positions[i].y < -100)
{
@@ -67,12 +67,12 @@ void Emitter::TickGame(float deltams)
}
}

Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void Emitter::TickDraw(float deltams)
void Emitter::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

for (int i = 0; i < data->nparticles; i++)
Scene::GetDefault()->AddTile(data->tileset, data->particles[i],


+ 3
- 3
src/emitter.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -33,8 +33,8 @@ public:
void AddParticle(int id, vec3 pos, vec3 vel);

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
EmitterData *data;


+ 3
- 3
src/entity.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -50,7 +50,7 @@ char const *Entity::GetName()
return "<entity>";
}

void Entity::TickGame(float deltams)
void Entity::TickGame(float seconds)
{
#if !LOL_RELEASE
if (m_tickstate != STATE_PRETICK_GAME)
@@ -59,7 +59,7 @@ void Entity::TickGame(float deltams)
#endif
}

void Entity::TickDraw(float deltams)
void Entity::TickDraw(float seconds)
{
#if !LOL_RELEASE
if (m_tickstate != STATE_PRETICK_DRAW)


+ 3
- 3
src/entity.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -38,8 +38,8 @@ protected:
virtual char const *GetName();
inline int IsDestroying() { return m_destroy; }

virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

enum
{


+ 2
- 2
src/font.cpp Datei anzeigen

@@ -59,9 +59,9 @@ Font::~Font()
delete data;
}

void Font::TickDraw(float deltams)
void Font::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);
}

char const *Font::GetName()


+ 1
- 1
src/font.h Datei anzeigen

@@ -32,7 +32,7 @@ public:
protected:
/* Inherited from Entity */
virtual char const *GetName();
virtual void TickDraw(float deltams);
virtual void TickDraw(float seconds);

public:
/* New methods */


+ 4
- 4
src/gradient.cpp Datei anzeigen

@@ -51,14 +51,14 @@ Gradient::Gradient(vec3 aa, vec3 bb)
data->shader = NULL;
}

void Gradient::TickGame(float deltams)
void Gradient::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void Gradient::TickDraw(float deltams)
void Gradient::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

float const vertex[] = { 0.0f, 0.0f, 0.0f,
640.0f, 0.0f, 0.0f,


+ 3
- 3
src/gradient.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -32,8 +32,8 @@ public:
char const *GetName() { return "<gradient>"; }

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
GradientData *data;


+ 2
- 2
src/input.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,7 +30,7 @@ public:
static vec2 GetAxis(int axis);
static ivec2 GetMousePos();
static ivec3 GetMouseButtons();
//BH : Added this, is a v0.1 Alpha version.
//BH : Added this, is a v0.1 Alpha version.
static int GetButtonState(int button);

/* Entities can subscribe to events */


+ 6
- 6
src/platform/ps3/ps3input.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -81,9 +81,9 @@ Ps3Input::Ps3Input()
#endif
}

void Ps3Input::TickGame(float deltams)
void Ps3Input::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

#if defined __CELLOS_LV2__
CellPadInfo2 pad_info2;
@@ -107,9 +107,9 @@ void Ps3Input::TickGame(float deltams)
{
int x = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X];
int y = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1];
vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127),
-4e-3f * (abs(y - 127) < 16 ? 0 : y - 127));
data->mousepos += delta * deltams;
vec2 delta(4.f * (abs(x - 127) < 16 ? 0 : x - 127),
-4.f * (abs(y - 127) < 16 ? 0 : y - 127));
data->mousepos += delta * seconds;
Input::SetMousePos((ivec2)data->mousepos);
}



+ 2
- 2
src/platform/ps3/ps3input.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,7 +30,7 @@ public:
virtual ~Ps3Input();

protected:
virtual void TickGame(float deltams);
virtual void TickGame(float seconds);

private:
Ps3InputData *data;


+ 11
- 11
src/platform/sdl/sdlinput.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -31,7 +31,7 @@ class SdlInputData
friend class SdlInput;

private:
void Tick(float deltams);
void Tick(float seconds);

static ivec2 GetMousePos();
};
@@ -50,25 +50,25 @@ SdlInput::SdlInput()
m_gamegroup = GAMEGROUP_BEFORE;
}

void SdlInput::TickGame(float deltams)
void SdlInput::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);

#if !defined _WIN32
data->Tick(deltams);
data->Tick(seconds);
#endif
}

void SdlInput::TickDraw(float deltams)
void SdlInput::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

#if defined _WIN32
data->Tick(deltams);
data->Tick(seconds);
#endif
}

void SdlInputData::Tick(float deltams)
void SdlInputData::Tick(float seconds)
{
#if defined USE_SDL
/* Handle mouse input */
@@ -86,7 +86,7 @@ void SdlInputData::Tick(float deltams)
break;
#if 0
case SDL_KEYDOWN:
Input::KeyPressed(event.key.keysym.sym, deltams);
Input::KeyPressed(event.key.keysym.sym, seconds);
break;
#endif
case SDL_MOUSEBUTTONDOWN:
@@ -109,7 +109,7 @@ void SdlInputData::Tick(float deltams)
Uint8 *keystate = SDL_GetKeyState(NULL);
for (int i = 0; i < 256; i++)
if (keystate[i])
Input::KeyPressed(i, deltams);
Input::KeyPressed(i, seconds);
#endif
#endif
}


+ 3
- 3
src/platform/sdl/sdlinput.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -30,8 +30,8 @@ public:
virtual ~SdlInput();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
SdlInputData *data;


+ 3
- 3
src/sample.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -77,9 +77,9 @@ Sample::~Sample()
delete data;
}

void Sample::TickGame(float deltams)
void Sample::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

char const *Sample::GetName()


+ 2
- 2
src/sample.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -35,7 +35,7 @@ public:
protected:
/* Inherited from Entity */
virtual char const *GetName();
virtual void TickGame(float deltams);
virtual void TickGame(float seconds);

public:
/* New methods */


+ 4
- 4
src/sprite.cpp Datei anzeigen

@@ -41,14 +41,14 @@ Sprite::Sprite(TileSet *tileset, int id)
data->id = id;
}

void Sprite::TickGame(float deltams)
void Sprite::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void Sprite::TickDraw(float deltams)
void Sprite::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

Scene::GetDefault()->AddTile(data->tileset, data->id, m_position,
0, vec2(1.0f));


+ 3
- 3
src/sprite.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -31,8 +31,8 @@ public:
virtual ~Sprite();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

private:
SpriteData *data;


+ 3
- 3
src/text.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -80,9 +80,9 @@ void Text::SetAlign(int align)
data->align = align;
}

void Text::TickDraw(float deltams)
void Text::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

if (data->text)
{


+ 2
- 2
src/text.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -42,7 +42,7 @@ public:
};

protected:
virtual void TickDraw(float deltams);
virtual void TickDraw(float seconds);

private:
TextData *data;


+ 15
- 15
src/ticker.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -32,7 +32,7 @@ public:
TickerData() :
todolist(0), autolist(0),
nentities(0),
frame(0), recording(0), deltams(0), bias(0), fps(0),
frame(0), recording(0), deltatime(0), bias(0), fps(0),
quit(0), quitframe(0), quitdelay(20), panic(0)
{
for (int i = 0; i < Entity::ALLGROUP_END; i++)
@@ -68,7 +68,7 @@ private:
/* Fixed framerate management */
int frame, recording;
Timer timer;
float deltams, bias, fps;
float deltatime, bias, fps;

/* Background threads */
static void *GameThreadMain(void *p);
@@ -181,15 +181,15 @@ void *TickerData::GameThreadMain(void *p)

data->frame++;

/* If recording with fixed framerate, set deltams to a fixed value */
/* If recording with fixed framerate, set deltatime to a fixed value */
if (data->recording && data->fps)
{
data->deltams = 1000.0f / data->fps;
data->deltatime = 1.f / data->fps;
}
else
{
data->deltams = 1000.0f * data->timer.Get();
data->bias += data->deltams;
data->deltatime = data->timer.Get();
data->bias += data->deltatime;
}

/* If shutdown is stuck, kick the first entity we meet and see
@@ -278,7 +278,7 @@ void *TickerData::GameThreadMain(void *p)
Log::Error("entity not idle for game tick\n");
e->m_tickstate = Entity::STATE_PRETICK_GAME;
#endif
e->TickGame(data->deltams);
e->TickGame(data->deltatime);
#if !LOL_RELEASE
if (e->m_tickstate != Entity::STATE_POSTTICK_GAME)
Log::Error("entity missed super game tick\n");
@@ -368,7 +368,7 @@ void Ticker::TickDraw()
Log::Error("entity not idle for draw tick\n");
e->m_tickstate = Entity::STATE_PRETICK_DRAW;
#endif
e->TickDraw(data->deltams);
e->TickDraw(data->deltatime);
#if !LOL_RELEASE
if (e->m_tickstate != Entity::STATE_POSTTICK_DRAW)
Log::Error("entity missed super draw tick\n");
@@ -391,16 +391,16 @@ void Ticker::TickDraw()

/* If framerate is fixed, force wait time to 1/FPS. Otherwise, set wait
* time to 0. */
float framems = data->fps ? 1000.0f / data->fps : 0.0f;
float frametime = data->fps ? 1.f / data->fps : 0.f;

if (framems > data->bias + 200.0f)
framems = data->bias + 200.0f; // Don't go below 5 fps
if (framems > data->bias)
data->timer.Wait(1e-3f * (framems - data->bias));
if (frametime > data->bias + .2f)
frametime = data->bias + .2f; // Don't go below 5 fps
if (frametime > data->bias)
data->timer.Wait(frametime - data->bias);

/* If recording, do not try to compensate for lag. */
if (!data->recording)
data->bias -= framems;
data->bias -= frametime;
}

void Ticker::StartRecording()


+ 2
- 2
src/tileset.cpp Datei anzeigen

@@ -111,9 +111,9 @@ TileSet::~TileSet()
delete data;
}

void TileSet::TickDraw(float deltams)
void TileSet::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);

if (IsDestroying())
{


+ 1
- 1
src/tileset.h Datei anzeigen

@@ -37,7 +37,7 @@ public:
protected:
/* Inherited from Entity */
virtual char const *GetName();
virtual void TickDraw(float deltams);
virtual void TickDraw(float seconds);

public:
/* New methods */


+ 5
- 5
src/world.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -56,14 +56,14 @@ char const *World::GetName()
return "<world>";
}

void World::TickGame(float deltams)
void World::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void World::TickDraw(float deltams)
void World::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);
}

int World::GetWidth()


+ 3
- 3
src/world.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -32,8 +32,8 @@ public:
protected:
/* Inherited from Entity */
virtual char const *GetName();
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);

public:
/* New methods */


+ 5
- 5
src/worldentity.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -46,14 +46,14 @@ char const *WorldEntity::GetName()
return "<worldentity>";
}

void WorldEntity::TickGame(float deltams)
void WorldEntity::TickGame(float seconds)
{
Entity::TickGame(deltams);
Entity::TickGame(seconds);
}

void WorldEntity::TickDraw(float deltams)
void WorldEntity::TickDraw(float seconds)
{
Entity::TickDraw(deltams);
Entity::TickDraw(seconds);
}

} /* namespace lol */


+ 3
- 3
src/worldentity.h Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -39,8 +39,8 @@ protected:

virtual char const *GetName();

virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);
virtual void TickGame(float seconds);
virtual void TickDraw(float seconds);
};

} /* namespace lol */


+ 2
- 2
test/tutorial/01_triangle.cpp Datei anzeigen

@@ -42,9 +42,9 @@ public:
m_ready = false;
}

virtual void TickDraw(float deltams)
virtual void TickDraw(float seconds)
{
WorldEntity::TickDraw(deltams);
WorldEntity::TickDraw(seconds);

if (!m_ready)
{


+ 6
- 6
test/tutorial/02_cube.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine - Cube tutorial
//
// Copyright: (c) 2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -61,11 +61,11 @@ public:
m_ready = false;
}

virtual void TickGame(float deltams)
virtual void TickGame(float seconds)
{
WorldEntity::TickGame(deltams);
WorldEntity::TickGame(seconds);

m_angle += deltams / 1000.0f * 45.0f;
m_angle += seconds * 45.0f;

mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
mat4 model = mat4::translate(vec3(0, 0, -4.5));
@@ -75,9 +75,9 @@ public:
m_matrix = proj * view * model * anim;
}

virtual void TickDraw(float deltams)
virtual void TickDraw(float seconds)
{
WorldEntity::TickDraw(deltams);
WorldEntity::TickDraw(seconds);

if (!m_ready)
{


+ 13
- 13
test/tutorial/03_fractal.cpp Datei anzeigen

@@ -1,7 +1,7 @@
//
// Lol Engine - Fractal tutorial
//
// Copyright: (c) 2011 Sam Hocevar <sam@hocevar.net>
// Copyright: (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -100,7 +100,7 @@ public:
//m_center = f64cmplx(-.22815528839841, -1.11514249704382);
//m_center = f64cmplx(0.001643721971153, 0.822467633298876);
m_center = f64cmplx(-0.65823419062254, 0.50221777363480);
m_zoom_speed = -0.000025;
m_zoom_speed = -0.025;
#else
m_center = -0.75;
m_zoom_speed = 0.0;
@@ -201,9 +201,9 @@ public:
return m_radius * m_window2world * f64cmplx(dx, dy);
}

virtual void TickGame(float deltams)
virtual void TickGame(float seconds)
{
WorldEntity::TickGame(deltams);
WorldEntity::TickGame(seconds);

int prev_frame = m_frame;
m_frame = (m_frame + 1) % 4;
@@ -234,7 +234,7 @@ public:
m_drag = false;
if (m_translate != 0.0)
{
m_translate *= pow(2.0, -deltams * 0.005);
m_translate *= pow(2.0, -seconds * 5.0);
if (m_translate.norm() / m_radius < 1e-4)
m_translate = 0.0;
}
@@ -242,14 +242,14 @@ public:

if ((buttons[0] || buttons[2]) && m_mousepos.x != -1)
{
double zoom = buttons[0] ? -0.0005 : 0.0005;
m_zoom_speed += deltams * zoom;
if (m_zoom_speed / zoom > 5)
m_zoom_speed = 5 * zoom;
double zoom = buttons[0] ? -0.5 : 0.5;
m_zoom_speed += seconds * zoom;
if (m_zoom_speed / zoom > 5e-3f)
m_zoom_speed = 5e-3f * zoom;
}
else if (m_zoom_speed)
{
m_zoom_speed *= pow(2.0, -deltams * 0.005);
m_zoom_speed *= pow(2.0, -seconds * 5.0);
if (abs(m_zoom_speed) < 1e-5 || m_drag)
m_zoom_speed = 0.0;
}
@@ -259,7 +259,7 @@ public:
{
f64cmplx oldcenter = m_center;
double oldradius = m_radius;
double zoom = pow(2.0, deltams * m_zoom_speed);
double zoom = pow(2.0, seconds * 1e3f * m_zoom_speed);
if (m_radius * zoom > 8.0)
{
m_zoom_speed *= -1.0;
@@ -425,9 +425,9 @@ public:
}
}

virtual void TickDraw(float deltams)
virtual void TickDraw(float seconds)
{
WorldEntity::TickDraw(deltams);
WorldEntity::TickDraw(seconds);

static float const vertices[] =
{


+ 3
- 3
test/xolotl/xolotl.cpp Datei anzeigen

@@ -2,7 +2,7 @@
// Lol Engine - Xolotl algorithm test
//
// Copyright: (c) 2011 Soren Renner
// (c) 2011 Sam Hocevar <sam@hocevar.net>
// (c) 2011-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -49,12 +49,12 @@ public:

virtual char const *GetName() { return "Xolotl"; }

virtual void TickGame(float deltams)
virtual void TickGame(float seconds)
{

}

virtual void TickDraw(float deltams)
virtual void TickDraw(float seconds)
{

}


Laden…
Abbrechen
Speichern