Updated examples to provide better style and use newer features.
This commit is contained in:
parent
206f74ec90
commit
3de4a7a26f
@ -1,11 +1,12 @@
|
|||||||
ZEngine Version Log for Version 0.8.1
|
ZEngine Version Log for Version 0.8.1
|
||||||
$Id: changelog.txt,v 1.22 2003/01/12 07:09:04 cozman Exp $
|
$Id: changelog.txt,v 1.23 2003/01/12 19:01:17 cozman Exp $
|
||||||
|
|
||||||
0.8.2
|
0.8.2
|
||||||
|
-Updated examples to use newer features and check for errors.
|
||||||
-Changed ZEngine::CreateDisplay to return a bool.
|
-Changed ZEngine::CreateDisplay to return a bool.
|
||||||
-Added \since option to documentation (Everything after 0.8.0 will be labeled with a version.)
|
-Added \since option to documentation (Everything after 0.8.0 will be labeled with a version.)
|
||||||
-Added "desired framerate" code to ZEngine.
|
|
||||||
-Added "desired framerate" functionality into the test programs.
|
-Added "desired framerate" functionality into the test programs.
|
||||||
|
-Added "desired framerate" code to ZEngine.
|
||||||
-Fixed OpenGL color bleed in ZRect.
|
-Fixed OpenGL color bleed in ZRect.
|
||||||
|
|
||||||
0.8.1
|
0.8.1
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZFontTest.cpp,v 1.10 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZFontTest.cpp,v 1.11 2003/01/12 19:00:14 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZFontTest","framerate",60);
|
rate = cfg.GetInt("ZFontTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -60,15 +60,18 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
if(engine->IsActive())
|
||||||
engine->RequestQuit();
|
{
|
||||||
betsy.DrawText(FormatStr("FPS: %.2f",engine->GetFramerate()),text[5]);
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
|
engine->RequestQuit();
|
||||||
|
betsy.DrawText(FormatStr("FPS: %.2f",engine->GetFramerate()),text[5]);
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
engine->Clear(); //clear screen
|
||||||
//draw the images//
|
//draw the images//
|
||||||
for(int i=0; i <= 5; i++)
|
for(int i=0; i <= 5; i++)
|
||||||
text[i].Draw(10.0f*i,50.0f*i);
|
text[i].Draw(10.0f*i,50.0f*i);
|
||||||
engine->Update(); //update the screen
|
engine->Update(); //update the screen
|
||||||
|
}
|
||||||
|
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
@ -77,9 +80,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZImageTest.cpp,v 1.13 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZImageTest.cpp,v 1.14 2003/01/12 19:00:15 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZImageTest","framerate",60);
|
rate = cfg.GetInt("ZImageTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -62,47 +62,52 @@ void Test()
|
|||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
|
|
||||||
if(engine->ImagesNeedReload())
|
if(engine->IsActive())
|
||||||
{
|
{
|
||||||
image1.Reload();
|
if(engine->ImagesNeedReload())
|
||||||
image2.Reload();
|
{
|
||||||
image3.Reload();
|
image1.Reload();
|
||||||
textImage.Reload();
|
image2.Reload();
|
||||||
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
|
image3.Reload();
|
||||||
|
textImage.Reload();
|
||||||
|
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
|
||||||
|
}
|
||||||
|
|
||||||
|
if(engine->KeyIsPressed(SDLK_s))
|
||||||
|
{
|
||||||
|
//code to toggle screen//
|
||||||
|
engine->SetupDisplay(engine->Width(),engine->Height(),engine->BPP(),!engine->IsFullscreen());
|
||||||
|
engine->CreateDisplay("ZImage Test");
|
||||||
|
engine->SetReloadNeed(true);
|
||||||
|
}
|
||||||
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
|
engine->RequestQuit();
|
||||||
|
|
||||||
|
engine->Clear(); //clear screen
|
||||||
|
//draw the images//
|
||||||
|
image1.Draw(0,0);
|
||||||
|
|
||||||
|
image2.DrawRotated(100,0,angle);
|
||||||
|
if(++angle > 360)
|
||||||
|
angle = 0.0f;
|
||||||
|
|
||||||
|
image3.Draw(200,0);
|
||||||
|
textImage.Draw(0,100);
|
||||||
|
engine->Update(); //update the screen
|
||||||
}
|
}
|
||||||
|
|
||||||
if(engine->KeyIsPressed(SDLK_s))
|
|
||||||
{
|
|
||||||
//code to toggle screen//
|
|
||||||
engine->SetupDisplay(engine->Width(),engine->Height(),engine->BPP(),!engine->IsFullscreen());
|
|
||||||
engine->CreateDisplay("ZImage Test");
|
|
||||||
engine->SetReloadNeed(true);
|
|
||||||
}
|
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
|
||||||
//draw the images//
|
|
||||||
image1.Draw(0,0);
|
|
||||||
|
|
||||||
image2.DrawRotated(100,0,angle);
|
|
||||||
if(++angle > 360)
|
|
||||||
angle = 0.0f;
|
|
||||||
|
|
||||||
image3.Draw(200,0);
|
|
||||||
textImage.Draw(0,100);
|
|
||||||
engine->Update(); //update the screen
|
|
||||||
|
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZMouseTest.cpp,v 1.11 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZMouseTest.cpp,v 1.12 2003/01/12 19:00:17 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZMouseTest","framerate",60);
|
rate = cfg.GetInt("ZMouseTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -59,25 +59,29 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
|
||||||
|
|
||||||
//show where mouse is (clicked or not)//
|
if(engine->IsActive())
|
||||||
if(engine->RButtonPressed())
|
{
|
||||||
font.DrawText(FormatStr("Right button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
else if(engine->LButtonPressed())
|
engine->RequestQuit();
|
||||||
font.DrawText(FormatStr("Left button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
|
||||||
else
|
|
||||||
font.DrawText(FormatStr("Mouse at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
|
||||||
|
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
//show where mouse is (clicked or not)//
|
||||||
//draw the images//
|
if(engine->RButtonPressed())
|
||||||
text[engine->MouseInRect(&textRect)].Draw(100,100);
|
font.DrawText(FormatStr("Right button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||||
text[2].Draw(0,0);
|
else if(engine->LButtonPressed())
|
||||||
cursor.Draw(engine->MouseX()-8.0f,engine->MouseY()-8.0f);
|
font.DrawText(FormatStr("Left button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||||
|
else
|
||||||
|
font.DrawText(FormatStr("Mouse at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||||
|
|
||||||
|
|
||||||
engine->Update(); //update the screen
|
engine->Clear(); //clear screen
|
||||||
|
//draw the images//
|
||||||
|
text[engine->MouseInRect(&textRect)].Draw(100,100);
|
||||||
|
text[2].Draw(0,0);
|
||||||
|
cursor.Draw(engine->MouseX()-8.0f,engine->MouseY()-8.0f);
|
||||||
|
|
||||||
|
engine->Update(); //update the screen
|
||||||
|
}
|
||||||
|
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
@ -86,9 +90,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZMusicTest.cpp,v 1.12 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZMusicTest.cpp,v 1.13 2003/01/12 19:00:19 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZMusicTest","framerate",60);
|
rate = cfg.GetInt("ZMusicTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -53,7 +53,6 @@ void Test()
|
|||||||
engine->Update();
|
engine->Update();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
engine->Update();
|
engine->Update();
|
||||||
} while(!engine->QuitRequested());
|
} while(!engine->QuitRequested());
|
||||||
@ -69,32 +68,36 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
if(engine->IsActive())
|
||||||
if(engine->KeyIsPressed(SDLK_r))
|
{
|
||||||
song.Rewind();
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
if(engine->KeyIsPressed(SDLK_p))
|
engine->RequestQuit();
|
||||||
song.Pause();
|
if(engine->KeyIsPressed(SDLK_r))
|
||||||
if(engine->KeyIsPressed(SDLK_u))
|
song.Rewind();
|
||||||
song.Unpause();
|
if(engine->KeyIsPressed(SDLK_p))
|
||||||
if(engine->KeyIsPressed(SDLK_f))
|
song.Pause();
|
||||||
song.Stop(5000);
|
if(engine->KeyIsPressed(SDLK_u))
|
||||||
if(engine->KeyIsPressed(SDLK_h))
|
song.Unpause();
|
||||||
song.Stop();
|
if(engine->KeyIsPressed(SDLK_f))
|
||||||
if(engine->KeyIsPressed(SDLK_SPACE))
|
song.Stop(5000);
|
||||||
song.Play();
|
if(engine->KeyIsPressed(SDLK_h))
|
||||||
if(engine->KeyIsPressed(SDLK_UP))
|
song.Stop();
|
||||||
song.SetVolume(song.Volume()+1);
|
if(engine->KeyIsPressed(SDLK_SPACE))
|
||||||
if(engine->KeyIsPressed(SDLK_DOWN))
|
song.Play();
|
||||||
song.SetVolume(song.Volume()-1);
|
if(engine->KeyIsPressed(SDLK_UP))
|
||||||
|
song.SetVolume(song.Volume()+1);
|
||||||
|
if(engine->KeyIsPressed(SDLK_DOWN))
|
||||||
|
song.SetVolume(song.Volume()-1);
|
||||||
|
|
||||||
|
|
||||||
font.DrawText(FormatStr("Volume: %d",song.Volume()),text[3]);
|
font.DrawText(FormatStr("Volume: %d",song.Volume()),text[3]);
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
engine->Clear(); //clear screen
|
||||||
for(int i=0; i < 4; i++)
|
for(int i=0; i < 4; i++)
|
||||||
text[i].Draw(0,i*50.0f);
|
text[i].Draw(0,i*50.0f);
|
||||||
engine->Update(); //update the screen
|
engine->Update(); //update the screen
|
||||||
|
}
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,9 +106,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZRectTest.cpp,v 1.14 2003/01/08 06:07:07 cozman Exp $*/
|
/*$Id: ZRectTest.cpp,v 1.15 2003/01/12 19:00:21 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZRectTest","framerate",60);
|
rate = cfg.GetInt("ZRectTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -45,34 +45,38 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
|
||||||
//movement//
|
|
||||||
movDelta = static_cast<float>(engine->GetFrameTime()*30);
|
|
||||||
if(engine->KeyIsPressed(SDLK_LEFT))
|
|
||||||
moveRect.MoveRel(-movDelta,0);
|
|
||||||
if(engine->KeyIsPressed(SDLK_RIGHT))
|
|
||||||
moveRect.MoveRel(movDelta,0);
|
|
||||||
if(engine->KeyIsPressed(SDLK_UP))
|
|
||||||
moveRect.MoveRel(0,-movDelta);
|
|
||||||
if(engine->KeyIsPressed(SDLK_DOWN))
|
|
||||||
moveRect.MoveRel(0,movDelta);
|
|
||||||
if(engine->KeyIsPressed(SDLK_EQUALS))
|
|
||||||
{
|
|
||||||
moveRect.MoveRel(-1,-1);
|
|
||||||
moveRect.ResizeRel(2,2);
|
|
||||||
}
|
|
||||||
if(engine->KeyIsPressed(SDLK_MINUS))
|
|
||||||
{
|
|
||||||
moveRect.MoveRel(1,1);
|
|
||||||
moveRect.ResizeRel(-2,-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
engine->Clear();
|
if(engine->IsActive())
|
||||||
moveRect.Draw(255,0,0,128);
|
{
|
||||||
stillRect.Draw(0,0,255,128);
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
moveRect.Intersection(stillRect).Draw(0,255,0);
|
engine->RequestQuit();
|
||||||
engine->Update();
|
//movement//
|
||||||
|
movDelta = static_cast<float>(engine->GetFrameTime()*30);
|
||||||
|
if(engine->KeyIsPressed(SDLK_LEFT))
|
||||||
|
moveRect.MoveRel(-movDelta,0);
|
||||||
|
if(engine->KeyIsPressed(SDLK_RIGHT))
|
||||||
|
moveRect.MoveRel(movDelta,0);
|
||||||
|
if(engine->KeyIsPressed(SDLK_UP))
|
||||||
|
moveRect.MoveRel(0,-movDelta);
|
||||||
|
if(engine->KeyIsPressed(SDLK_DOWN))
|
||||||
|
moveRect.MoveRel(0,movDelta);
|
||||||
|
if(engine->KeyIsPressed(SDLK_EQUALS))
|
||||||
|
{
|
||||||
|
moveRect.MoveRel(-1,-1);
|
||||||
|
moveRect.ResizeRel(2,2);
|
||||||
|
}
|
||||||
|
if(engine->KeyIsPressed(SDLK_MINUS))
|
||||||
|
{
|
||||||
|
moveRect.MoveRel(1,1);
|
||||||
|
moveRect.ResizeRel(-2,-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
engine->Clear();
|
||||||
|
moveRect.Draw(255,0,0,128);
|
||||||
|
stillRect.Draw(0,0,255,128);
|
||||||
|
moveRect.Intersection(stillRect).Draw(0,255,0);
|
||||||
|
engine->Update();
|
||||||
|
}
|
||||||
|
|
||||||
} while(!engine->QuitRequested());
|
} while(!engine->QuitRequested());
|
||||||
}
|
}
|
||||||
@ -81,9 +85,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZSoundTest.cpp,v 1.10 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZSoundTest.cpp,v 1.11 2003/01/12 19:00:22 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZSoundTest","framerate",60);
|
rate = cfg.GetInt("ZSoundTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -56,40 +56,44 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
|
||||||
if(engine->KeyIsPressed(SDLK_1))
|
|
||||||
sampleNum = 0;
|
|
||||||
if(engine->KeyIsPressed(SDLK_2))
|
|
||||||
sampleNum = 1;
|
|
||||||
if(engine->KeyIsPressed(SDLK_3))
|
|
||||||
sampleNum = 2;
|
|
||||||
if(engine->KeyIsPressed(SDLK_4))
|
|
||||||
sampleNum = 3;
|
|
||||||
if(engine->KeyIsPressed(SDLK_5))
|
|
||||||
sampleNum = 4;
|
|
||||||
if(engine->KeyIsPressed(SDLK_p))
|
|
||||||
sample[sampleNum].Pause();
|
|
||||||
if(engine->KeyIsPressed(SDLK_u))
|
|
||||||
sample[sampleNum].Unpause();
|
|
||||||
if(engine->KeyIsPressed(SDLK_f))
|
|
||||||
sample[sampleNum].Stop(5000);
|
|
||||||
if(engine->KeyIsPressed(SDLK_h))
|
|
||||||
sample[sampleNum].Stop();
|
|
||||||
if(engine->KeyIsPressed(SDLK_SPACE))
|
|
||||||
sample[sampleNum].Play();
|
|
||||||
if(engine->KeyIsPressed(SDLK_UP))
|
|
||||||
sample[sampleNum].SetVolume(sample[sampleNum].Volume()+1);
|
|
||||||
if(engine->KeyIsPressed(SDLK_DOWN))
|
|
||||||
sample[sampleNum].SetVolume(sample[sampleNum].Volume()-1);
|
|
||||||
|
|
||||||
font.DrawText(FormatStr("Volume: %d",sample[sampleNum].Volume()),text[4]);
|
if(engine->IsActive())
|
||||||
font.DrawText(FormatStr("Sample: %s",name[sampleNum].c_str()),text[5]);
|
{
|
||||||
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
|
engine->RequestQuit();
|
||||||
|
if(engine->KeyIsPressed(SDLK_1))
|
||||||
|
sampleNum = 0;
|
||||||
|
if(engine->KeyIsPressed(SDLK_2))
|
||||||
|
sampleNum = 1;
|
||||||
|
if(engine->KeyIsPressed(SDLK_3))
|
||||||
|
sampleNum = 2;
|
||||||
|
if(engine->KeyIsPressed(SDLK_4))
|
||||||
|
sampleNum = 3;
|
||||||
|
if(engine->KeyIsPressed(SDLK_5))
|
||||||
|
sampleNum = 4;
|
||||||
|
if(engine->KeyIsPressed(SDLK_p))
|
||||||
|
sample[sampleNum].Pause();
|
||||||
|
if(engine->KeyIsPressed(SDLK_u))
|
||||||
|
sample[sampleNum].Unpause();
|
||||||
|
if(engine->KeyIsPressed(SDLK_f))
|
||||||
|
sample[sampleNum].Stop(5000);
|
||||||
|
if(engine->KeyIsPressed(SDLK_h))
|
||||||
|
sample[sampleNum].Stop();
|
||||||
|
if(engine->KeyIsPressed(SDLK_SPACE))
|
||||||
|
sample[sampleNum].Play();
|
||||||
|
if(engine->KeyIsPressed(SDLK_UP))
|
||||||
|
sample[sampleNum].SetVolume(sample[sampleNum].Volume()+1);
|
||||||
|
if(engine->KeyIsPressed(SDLK_DOWN))
|
||||||
|
sample[sampleNum].SetVolume(sample[sampleNum].Volume()-1);
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
font.DrawText(FormatStr("Volume: %d",sample[sampleNum].Volume()),text[4]);
|
||||||
for(int i=0; i < 6; i++)
|
font.DrawText(FormatStr("Sample: %s",name[sampleNum].c_str()),text[5]);
|
||||||
text[i].Draw(0,i*50.0f);
|
|
||||||
engine->Update(); //update the screen
|
engine->Clear(); //clear screen
|
||||||
|
for(int i=0; i < 6; i++)
|
||||||
|
text[i].Draw(0,i*50.0f);
|
||||||
|
engine->Update(); //update the screen
|
||||||
|
}
|
||||||
|
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
@ -98,9 +102,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZTimerTest.cpp,v 1.10 2003/01/04 05:18:51 cozman Exp $*/
|
/*$Id: ZTimerTest.cpp,v 1.11 2003/01/12 19:00:25 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
|
||||||
void Initialize()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
ZConfigFile cfg("tests.zcf");
|
ZConfigFile cfg("tests.zcf");
|
||||||
@ -31,8 +31,8 @@ void Initialize()
|
|||||||
rate = cfg.GetInt("ZTimerTest","framerate",60);
|
rate = cfg.GetInt("ZTimerTest","framerate",60);
|
||||||
|
|
||||||
engine->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
engine->CreateDisplay(title);
|
|
||||||
engine->SetDesiredFramerate(rate);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test()
|
void Test()
|
||||||
@ -54,60 +54,64 @@ void Test()
|
|||||||
{
|
{
|
||||||
//In the active loop, check events first//
|
//In the active loop, check events first//
|
||||||
engine->CheckEvents();
|
engine->CheckEvents();
|
||||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
|
||||||
engine->RequestQuit();
|
if(engine->IsActive())
|
||||||
//pause current timer//
|
|
||||||
if(engine->KeyIsPressed(SDLK_p))
|
|
||||||
{
|
{
|
||||||
switch(curTimer)
|
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||||
|
engine->RequestQuit();
|
||||||
|
//pause current timer//
|
||||||
|
if(engine->KeyIsPressed(SDLK_p))
|
||||||
{
|
{
|
||||||
case 0:
|
switch(curTimer)
|
||||||
engine->PauseTimer();
|
{
|
||||||
break;
|
case 0:
|
||||||
case 1:
|
engine->PauseTimer();
|
||||||
TimerOne.Pause();
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 2:
|
TimerOne.Pause();
|
||||||
TimerTwo.Pause();
|
break;
|
||||||
break;
|
case 2:
|
||||||
|
TimerTwo.Pause();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
//unpause current timer//
|
||||||
//unpause current timer//
|
if(engine->KeyIsPressed(SDLK_u))
|
||||||
if(engine->KeyIsPressed(SDLK_u))
|
|
||||||
{
|
|
||||||
switch(curTimer)
|
|
||||||
{
|
{
|
||||||
case 0:
|
switch(curTimer)
|
||||||
engine->UnpauseTimer();
|
{
|
||||||
break;
|
case 0:
|
||||||
case 1:
|
engine->UnpauseTimer();
|
||||||
TimerOne.Unpause();
|
break;
|
||||||
break;
|
case 1:
|
||||||
case 2:
|
TimerOne.Unpause();
|
||||||
TimerTwo.Unpause();
|
break;
|
||||||
break;
|
case 2:
|
||||||
|
TimerTwo.Unpause();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//switch//
|
||||||
|
if(engine->KeyIsPressed(SDLK_t))
|
||||||
|
{
|
||||||
|
if(++curTimer > 2)
|
||||||
|
curTimer = 0;
|
||||||
|
engine->Delay(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Render all the fonts//
|
||||||
|
font.DrawText(FormatStr("Current Timer: %s",TimerName[curTimer].c_str()),text[0]);
|
||||||
|
font.DrawText(FormatStr("%s Time: %d",TimerName[0].c_str(),engine->GetTime()),text[1]);
|
||||||
|
font.DrawText(FormatStr("%s Time: %d",TimerName[1].c_str(),TimerOne.GetTime()),text[2]);
|
||||||
|
font.DrawText(FormatStr("%s Time: %d",TimerName[2].c_str(),TimerTwo.GetTime()),text[3]);
|
||||||
|
|
||||||
|
engine->Clear(); //clear screen
|
||||||
|
|
||||||
|
for(int i=0; i <= 4; i++)
|
||||||
|
text[i].Draw(0,i*50.0f);
|
||||||
|
|
||||||
|
engine->Update(); //update the screen
|
||||||
}
|
}
|
||||||
//switch//
|
|
||||||
if(engine->KeyIsPressed(SDLK_t))
|
|
||||||
{
|
|
||||||
if(++curTimer > 2)
|
|
||||||
curTimer = 0;
|
|
||||||
engine->Delay(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Render all the fonts//
|
|
||||||
font.DrawText(FormatStr("Current Timer: %s",TimerName[curTimer].c_str()),text[0]);
|
|
||||||
font.DrawText(FormatStr("%s Time: %d",TimerName[0].c_str(),engine->GetTime()),text[1]);
|
|
||||||
font.DrawText(FormatStr("%s Time: %d",TimerName[1].c_str(),TimerOne.GetTime()),text[2]);
|
|
||||||
font.DrawText(FormatStr("%s Time: %d",TimerName[2].c_str(),TimerTwo.GetTime()),text[3]);
|
|
||||||
|
|
||||||
engine->Clear(); //clear screen
|
|
||||||
|
|
||||||
for(int i=0; i <= 4; i++)
|
|
||||||
text[i].Draw(0,i*50.0f);
|
|
||||||
|
|
||||||
engine->Update(); //update the screen
|
|
||||||
|
|
||||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||||
}
|
}
|
||||||
@ -116,9 +120,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ZEngine *engine = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
|
||||||
Initialize();
|
if(Initialize())
|
||||||
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
{
|
||||||
Test();
|
//engine->InitPhysFS(argv[0]); //remove this line if PhysFS is not available
|
||||||
|
Test();
|
||||||
|
}
|
||||||
|
|
||||||
ZEngine::ReleaseInstance(); //release engine instance
|
ZEngine::ReleaseInstance(); //release engine instance
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user