line endiing fiasco!
This commit is contained in:
parent
c4faafa8ca
commit
18ecb1905d
@ -1,86 +1,86 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZFontTest.cpp,v 1.17 2003/10/21 01:17:35 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
string title;
|
||||
|
||||
w = cfg.GetInt("ZFontTest","width",800);
|
||||
h = cfg.GetInt("ZFontTest","height",600);
|
||||
bpp = cfg.GetInt("ZFontTest","bpp",32);
|
||||
fs = cfg.GetBool("ZFontTest","fullscreen",false);
|
||||
title = cfg.GetString("ZFontTest","title","ZFont Test");
|
||||
rate = cfg.GetInt("ZFontTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
//Open and Setup all the Fonts and Create Images//
|
||||
ZImage text[6];
|
||||
ZFont almonte("data/almontew.ttf",48), axaxax("data/axaxax.ttf",32), betsy;//("data/betsy.ttf",64);
|
||||
betsy.OpenFromZip("data/data.zip","betsy.ttf",20);
|
||||
betsy.Resize(64);
|
||||
almonte.SetColor(255,0,0,128);
|
||||
almonte.DrawText("This is the font test.",text[0]);
|
||||
axaxax.SetColor(0,255,255);
|
||||
axaxax.SetStyle(true,false,false);
|
||||
axaxax.DrawText("Fonts free from: ",text[1]);
|
||||
axaxax.SetStyle(false,true,true);
|
||||
axaxax.DrawText("http://larabiefonts.com/",text[2]);
|
||||
almonte.SetBGColor(0,0,128);
|
||||
almonte.SetColor(0,0,255);
|
||||
almonte.SetStyle(false,true,false);
|
||||
almonte.DrawShadedText("Shaded, italic, bold and underlined tested. ",text[3]);
|
||||
betsy.SetColor(255,255,255);
|
||||
betsy.DrawText("Font test successful.",text[4]);
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
betsy.DrawText(FormatStr("FPS: %.2f",engine->GetFramerate()),text[5]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
//draw the images//
|
||||
for(int i=0; i <= 5; i++)
|
||||
text[i].Draw(10*i,50*i);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZFontTest.cpp,v 1.18 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
string title;
|
||||
|
||||
w = cfg.GetInt("ZFontTest","width",800);
|
||||
h = cfg.GetInt("ZFontTest","height",600);
|
||||
bpp = cfg.GetInt("ZFontTest","bpp",32);
|
||||
fs = cfg.GetBool("ZFontTest","fullscreen",false);
|
||||
title = cfg.GetString("ZFontTest","title","ZFont Test");
|
||||
rate = cfg.GetInt("ZFontTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
//Open and Setup all the Fonts and Create Images//
|
||||
ZImage text[6];
|
||||
ZFont almonte("data/almontew.ttf",48), axaxax("data/axaxax.ttf",32), betsy;//("data/betsy.ttf",64);
|
||||
betsy.OpenFromZip("data/data.zip","betsy.ttf",20);
|
||||
betsy.Resize(64);
|
||||
almonte.SetColor(255,0,0,128);
|
||||
almonte.DrawText("This is the font test.",text[0]);
|
||||
axaxax.SetColor(0,255,255);
|
||||
axaxax.SetStyle(true,false,false);
|
||||
axaxax.DrawText("Fonts free from: ",text[1]);
|
||||
axaxax.SetStyle(false,true,true);
|
||||
axaxax.DrawText("http://larabiefonts.com/",text[2]);
|
||||
almonte.SetBGColor(0,0,128);
|
||||
almonte.SetColor(0,0,255);
|
||||
almonte.SetStyle(false,true,false);
|
||||
almonte.DrawShadedText("Shaded, italic, bold and underlined tested. ",text[3]);
|
||||
betsy.SetColor(255,255,255);
|
||||
betsy.DrawText("Font test successful.",text[4]);
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
betsy.DrawText(FormatStr("FPS: %.2f",engine->GetFramerate()),text[5]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
//draw the images//
|
||||
for(int i=0; i <= 5; i++)
|
||||
text[i].Draw(10*i,50*i);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,143 +1,143 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZImageTest.cpp,v 1.27 2003/11/14 21:39:51 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZImageTest","width",800);
|
||||
h = cfg.GetInt("ZImageTest","height",600);
|
||||
bpp = cfg.GetInt("ZImageTest","bpp",32);
|
||||
fs = cfg.GetBool("ZImageTest","fullscreen",true);
|
||||
title = cfg.GetString("ZImageTest","title","ZImage Test");
|
||||
rate = cfg.GetInt("ZImageTest","framerate",60);
|
||||
|
||||
engine->SetDesiredFramerate(rate);
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
float angle=0.0f,movDelta;
|
||||
float alpha=128.0f,alphaDelta=15.0f;
|
||||
SDL_Surface *temp;
|
||||
|
||||
//Open and Setup all the Images//
|
||||
ZImage image1,image2,image3,image4,textImage;
|
||||
ZFont font("data/almontew.ttf",30);
|
||||
ZRect clipRect(400,300,30,30);
|
||||
|
||||
font.SetColor(0,255,0);
|
||||
font.SetBGColor(0,0,255);
|
||||
|
||||
temp = SDL_LoadBMP("data/rainbow.bmp"); //this is a separate surface
|
||||
image1.OpenFromZip("data/data.zip","test02.bmp");
|
||||
image1.SetColorKey(255,0,255);
|
||||
image2.Open("data/test01.bmp");
|
||||
image2.SetColorKey(255,0,255);
|
||||
image3.OpenFromImage(image2.Surface(),5,5,20,20);
|
||||
image4.Attach(temp); //this attaches the surface into itself
|
||||
|
||||
#if (GFX_BACKEND == ZE_OGL)
|
||||
image4.Resize(400,300);
|
||||
image4.Flip(true,false);
|
||||
#endif
|
||||
font.DrawShadedText("ZImage Test.",textImage);
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->ImagesNeedReload())
|
||||
{
|
||||
image1.Reload();
|
||||
image2.Reload();
|
||||
image3.Reload();
|
||||
image4.Reload();
|
||||
textImage.Reload();
|
||||
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
|
||||
}
|
||||
|
||||
//movement//
|
||||
movDelta = static_cast<float>(engine->GetFrameTime()*30);
|
||||
if(engine->KeyIsPressed(SDLK_LEFT))
|
||||
clipRect.MoveRel(-movDelta,0);
|
||||
if(engine->KeyIsPressed(SDLK_RIGHT))
|
||||
clipRect.MoveRel(movDelta,0);
|
||||
if(engine->KeyIsPressed(SDLK_UP))
|
||||
clipRect.MoveRel(0,-movDelta);
|
||||
if(engine->KeyIsPressed(SDLK_DOWN))
|
||||
clipRect.MoveRel(0,movDelta);
|
||||
if(engine->KeyIsPressed(SDLK_EQUALS))
|
||||
{
|
||||
clipRect.MoveRel(-1,-1);
|
||||
clipRect.ResizeRel(2,2);
|
||||
}
|
||||
if(engine->KeyIsPressed(SDLK_MINUS))
|
||||
{
|
||||
clipRect.MoveRel(1,1);
|
||||
clipRect.ResizeRel(-2,-2);
|
||||
}
|
||||
|
||||
if(engine->KeyIsPressed(SDLK_s))
|
||||
engine->ToggleFullscreen();
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
//draw the images//
|
||||
alpha += alphaDelta*engine->GetFrameTime();
|
||||
if(alpha >= 255 || alpha <= 0)
|
||||
alphaDelta *= -1.0f;
|
||||
image1.SetAlpha(static_cast<Uint8>(alpha));
|
||||
image1.Draw(0,0);
|
||||
|
||||
#if (GFX_BACKEND == ZE_OGL)
|
||||
image2.DrawRotated(100,0,angle);
|
||||
angle+=(150*engine->GetFrameTime());
|
||||
if(angle > 360)
|
||||
angle = 0.0f;
|
||||
#elif (GFX_BACKEND == ZE_SDL)
|
||||
image2.Draw(100,0);
|
||||
#endif
|
||||
|
||||
image3.Draw(200,0);
|
||||
image4.DrawClipped(400,300,clipRect);
|
||||
textImage.Draw(0,100);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
else
|
||||
engine->Delay(10);
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZImageTest.cpp,v 1.28 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZImageTest","width",800);
|
||||
h = cfg.GetInt("ZImageTest","height",600);
|
||||
bpp = cfg.GetInt("ZImageTest","bpp",32);
|
||||
fs = cfg.GetBool("ZImageTest","fullscreen",true);
|
||||
title = cfg.GetString("ZImageTest","title","ZImage Test");
|
||||
rate = cfg.GetInt("ZImageTest","framerate",60);
|
||||
|
||||
engine->SetDesiredFramerate(rate);
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
float angle=0.0f,movDelta;
|
||||
float alpha=128.0f,alphaDelta=15.0f;
|
||||
SDL_Surface *temp;
|
||||
|
||||
//Open and Setup all the Images//
|
||||
ZImage image1,image2,image3,image4,textImage;
|
||||
ZFont font("data/almontew.ttf",30);
|
||||
ZRect clipRect(400,300,30,30);
|
||||
|
||||
font.SetColor(0,255,0);
|
||||
font.SetBGColor(0,0,255);
|
||||
|
||||
temp = SDL_LoadBMP("data/rainbow.bmp"); //this is a separate surface
|
||||
image1.OpenFromZip("data/data.zip","test02.bmp");
|
||||
image1.SetColorKey(255,0,255);
|
||||
image2.Open("data/test01.bmp");
|
||||
image2.SetColorKey(255,0,255);
|
||||
image3.OpenFromImage(image2.Surface(),5,5,20,20);
|
||||
image4.Attach(temp); //this attaches the surface into itself
|
||||
|
||||
#if (GFX_BACKEND == ZE_OGL)
|
||||
image4.Resize(400,300);
|
||||
image4.Flip(true,false);
|
||||
#endif
|
||||
font.DrawShadedText("ZImage Test.",textImage);
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->ImagesNeedReload())
|
||||
{
|
||||
image1.Reload();
|
||||
image2.Reload();
|
||||
image3.Reload();
|
||||
image4.Reload();
|
||||
textImage.Reload();
|
||||
engine->SetReloadNeed(false); //very important for speed, without this you'd be reloading every frame
|
||||
}
|
||||
|
||||
//movement//
|
||||
movDelta = static_cast<float>(engine->GetFrameTime()*30);
|
||||
if(engine->KeyIsPressed(SDLK_LEFT))
|
||||
clipRect.MoveRel(-movDelta,0);
|
||||
if(engine->KeyIsPressed(SDLK_RIGHT))
|
||||
clipRect.MoveRel(movDelta,0);
|
||||
if(engine->KeyIsPressed(SDLK_UP))
|
||||
clipRect.MoveRel(0,-movDelta);
|
||||
if(engine->KeyIsPressed(SDLK_DOWN))
|
||||
clipRect.MoveRel(0,movDelta);
|
||||
if(engine->KeyIsPressed(SDLK_EQUALS))
|
||||
{
|
||||
clipRect.MoveRel(-1,-1);
|
||||
clipRect.ResizeRel(2,2);
|
||||
}
|
||||
if(engine->KeyIsPressed(SDLK_MINUS))
|
||||
{
|
||||
clipRect.MoveRel(1,1);
|
||||
clipRect.ResizeRel(-2,-2);
|
||||
}
|
||||
|
||||
if(engine->KeyIsPressed(SDLK_s))
|
||||
engine->ToggleFullscreen();
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
//draw the images//
|
||||
alpha += alphaDelta*engine->GetFrameTime();
|
||||
if(alpha >= 255 || alpha <= 0)
|
||||
alphaDelta *= -1.0f;
|
||||
image1.SetAlpha(static_cast<Uint8>(alpha));
|
||||
image1.Draw(0,0);
|
||||
|
||||
#if (GFX_BACKEND == ZE_OGL)
|
||||
image2.DrawRotated(100,0,angle);
|
||||
angle+=(150*engine->GetFrameTime());
|
||||
if(angle > 360)
|
||||
angle = 0.0f;
|
||||
#elif (GFX_BACKEND == ZE_SDL)
|
||||
image2.Draw(100,0);
|
||||
#endif
|
||||
|
||||
image3.Draw(200,0);
|
||||
image4.DrawClipped(400,300,clipRect);
|
||||
textImage.Draw(0,100);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
else
|
||||
engine->Delay(10);
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,96 +1,96 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZMouseTest.cpp,v 1.19 2003/10/21 01:17:35 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZMouseTest","width",800);
|
||||
h = cfg.GetInt("ZMouseTest","height",600);
|
||||
bpp = cfg.GetInt("ZMouseTest","bpp",32);
|
||||
fs = cfg.GetBool("ZMouseTest","fullscreen",false);
|
||||
title = cfg.GetString("ZMouseTest","title","ZMouse Test");
|
||||
rate = cfg.GetInt("ZMouseTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
//Open and Setup all the Images//
|
||||
ZImage text[3], cursor("data/cursor.bmp");
|
||||
ZFont font("data/almontew.ttf",30);
|
||||
SDL_Rect textRect;
|
||||
|
||||
engine->HideCursor();
|
||||
cursor.SetColorKey(255,0,255);
|
||||
|
||||
font.SetColor(0,255,0);
|
||||
font.SetBGColor(0,0,255);
|
||||
font.DrawText("Mouse Test",text[0]);
|
||||
font.DrawShadedText("Mouse Test",text[1]);
|
||||
textRect.x = textRect.y = 100;
|
||||
textRect.w = font.StringWidth("Mouse Test");
|
||||
textRect.h = font.StringHeight("Mouse Test");
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
|
||||
//show where mouse is (clicked or not)//
|
||||
if(engine->RButtonPressed())
|
||||
font.DrawText(FormatStr("Right button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||
else if(engine->LButtonPressed())
|
||||
font.DrawText(FormatStr("Left button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||
else if(engine->MButtonPressed())
|
||||
font.DrawText(FormatStr("Middle 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
|
||||
//draw the images//
|
||||
text[engine->MouseInRect(&textRect)].Draw(100,100);
|
||||
text[2].Draw(0,0);
|
||||
cursor.Draw(engine->MouseX()-8,engine->MouseY()-8);
|
||||
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZMouseTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZMouseTest","width",800);
|
||||
h = cfg.GetInt("ZMouseTest","height",600);
|
||||
bpp = cfg.GetInt("ZMouseTest","bpp",32);
|
||||
fs = cfg.GetBool("ZMouseTest","fullscreen",false);
|
||||
title = cfg.GetString("ZMouseTest","title","ZMouse Test");
|
||||
rate = cfg.GetInt("ZMouseTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
//Open and Setup all the Images//
|
||||
ZImage text[3], cursor("data/cursor.bmp");
|
||||
ZFont font("data/almontew.ttf",30);
|
||||
SDL_Rect textRect;
|
||||
|
||||
engine->HideCursor();
|
||||
cursor.SetColorKey(255,0,255);
|
||||
|
||||
font.SetColor(0,255,0);
|
||||
font.SetBGColor(0,0,255);
|
||||
font.DrawText("Mouse Test",text[0]);
|
||||
font.DrawShadedText("Mouse Test",text[1]);
|
||||
textRect.x = textRect.y = 100;
|
||||
textRect.w = font.StringWidth("Mouse Test");
|
||||
textRect.h = font.StringHeight("Mouse Test");
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
|
||||
//show where mouse is (clicked or not)//
|
||||
if(engine->RButtonPressed())
|
||||
font.DrawText(FormatStr("Right button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||
else if(engine->LButtonPressed())
|
||||
font.DrawText(FormatStr("Left button clicked at %d,%d",engine->MouseX(),engine->MouseY()),text[2]);
|
||||
else if(engine->MButtonPressed())
|
||||
font.DrawText(FormatStr("Middle 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
|
||||
//draw the images//
|
||||
text[engine->MouseInRect(&textRect)].Draw(100,100);
|
||||
text[2].Draw(0,0);
|
||||
cursor.Draw(engine->MouseX()-8,engine->MouseY()-8);
|
||||
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,109 +1,109 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZMusicTest.cpp,v 1.19 2003/10/21 01:17:35 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZMusicTest","width",800);
|
||||
h = cfg.GetInt("ZMusicTest","height",600);
|
||||
bpp = cfg.GetInt("ZMusicTest","bpp",32);
|
||||
fs = cfg.GetBool("ZMusicTest","fullscreen",false);
|
||||
title = cfg.GetString("ZMusicTest","title","ZMusic Test");
|
||||
rate = cfg.GetInt("ZMusicTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
ZMusic song("data/music.ogg");
|
||||
ZFont font("data/almontew.ttf",48);
|
||||
ZImage text[4];
|
||||
|
||||
if(!song.IsLoaded()) //this executes if there is no music.ogg file
|
||||
{
|
||||
engine->Clear();
|
||||
engine->CreateDisplay(800,70,32,false,"ZMusic Test");
|
||||
font.DrawText("Music.ogg does not exist, please read music.txt.",text[0]);
|
||||
text[0].Draw(0,0);
|
||||
engine->Update();
|
||||
do
|
||||
{
|
||||
engine->CheckEvents();
|
||||
engine->Update();
|
||||
} while(!engine->QuitRequested());
|
||||
}
|
||||
else //this is the actual example
|
||||
{
|
||||
font.DrawText("(P)ause\t(U)npause\t(R)ewind",text[0]);
|
||||
font.DrawText("(F)ade Out\t(H)alt\t",text[1]);
|
||||
font.DrawText("Space - Play\t Up/Down - Control Volume",text[2]);
|
||||
|
||||
song.Play();
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
if(engine->KeyIsPressed(SDLK_r))
|
||||
song.Rewind();
|
||||
if(engine->KeyIsPressed(SDLK_p))
|
||||
song.Pause();
|
||||
if(engine->KeyIsPressed(SDLK_u))
|
||||
song.Unpause();
|
||||
if(engine->KeyIsPressed(SDLK_f))
|
||||
song.Stop(5000);
|
||||
if(engine->KeyIsPressed(SDLK_h))
|
||||
song.Stop();
|
||||
if(engine->KeyIsPressed(SDLK_SPACE))
|
||||
song.Play();
|
||||
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]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
for(int i=0; i < 4; i++)
|
||||
text[i].Draw(0,i*50);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZMusicTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZMusicTest","width",800);
|
||||
h = cfg.GetInt("ZMusicTest","height",600);
|
||||
bpp = cfg.GetInt("ZMusicTest","bpp",32);
|
||||
fs = cfg.GetBool("ZMusicTest","fullscreen",false);
|
||||
title = cfg.GetString("ZMusicTest","title","ZMusic Test");
|
||||
rate = cfg.GetInt("ZMusicTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
ZMusic song("data/music.ogg");
|
||||
ZFont font("data/almontew.ttf",48);
|
||||
ZImage text[4];
|
||||
|
||||
if(!song.IsLoaded()) //this executes if there is no music.ogg file
|
||||
{
|
||||
engine->Clear();
|
||||
engine->CreateDisplay(800,70,32,false,"ZMusic Test");
|
||||
font.DrawText("Music.ogg does not exist, please read music.txt.",text[0]);
|
||||
text[0].Draw(0,0);
|
||||
engine->Update();
|
||||
do
|
||||
{
|
||||
engine->CheckEvents();
|
||||
engine->Update();
|
||||
} while(!engine->QuitRequested());
|
||||
}
|
||||
else //this is the actual example
|
||||
{
|
||||
font.DrawText("(P)ause\t(U)npause\t(R)ewind",text[0]);
|
||||
font.DrawText("(F)ade Out\t(H)alt\t",text[1]);
|
||||
font.DrawText("Space - Play\t Up/Down - Control Volume",text[2]);
|
||||
|
||||
song.Play();
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
if(engine->KeyIsPressed(SDLK_ESCAPE))
|
||||
engine->RequestQuit();
|
||||
if(engine->KeyIsPressed(SDLK_r))
|
||||
song.Rewind();
|
||||
if(engine->KeyIsPressed(SDLK_p))
|
||||
song.Pause();
|
||||
if(engine->KeyIsPressed(SDLK_u))
|
||||
song.Unpause();
|
||||
if(engine->KeyIsPressed(SDLK_f))
|
||||
song.Stop(5000);
|
||||
if(engine->KeyIsPressed(SDLK_h))
|
||||
song.Stop();
|
||||
if(engine->KeyIsPressed(SDLK_SPACE))
|
||||
song.Play();
|
||||
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]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
for(int i=0; i < 4; i++)
|
||||
text[i].Draw(0,i*50);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,89 +1,89 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZRectTest.cpp,v 1.20 2003/10/21 01:17:35 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZRectTest","Width",800);
|
||||
h = cfg.GetInt("ZRectTest","height",600);
|
||||
bpp = cfg.GetInt("ZRectTest","bpp",32);
|
||||
fs = cfg.GetBool("ZRectTest","fullscreen",false);
|
||||
title = cfg.GetString("ZRectTest","title","ZRect Test");
|
||||
rate = cfg.GetInt("ZRectTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZRect moveRect(0,0,25,25),stillRect(100,100,100,100);
|
||||
float movDelta;
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
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();
|
||||
moveRect.Draw(255,0,0,128);
|
||||
stillRect.Draw(0,0,255,128);
|
||||
moveRect.Intersection(stillRect).Draw(0,255,0);
|
||||
engine->Update();
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZRectTest.cpp,v 1.21 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZRectTest","Width",800);
|
||||
h = cfg.GetInt("ZRectTest","height",600);
|
||||
bpp = cfg.GetInt("ZRectTest","bpp",32);
|
||||
fs = cfg.GetBool("ZRectTest","fullscreen",false);
|
||||
title = cfg.GetString("ZRectTest","title","ZRect Test");
|
||||
rate = cfg.GetInt("ZRectTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZRect moveRect(0,0,25,25),stillRect(100,100,100,100);
|
||||
float movDelta;
|
||||
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
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();
|
||||
moveRect.Draw(255,0,0,128);
|
||||
stillRect.Draw(0,0,255,128);
|
||||
moveRect.Intersection(stillRect).Draw(0,255,0);
|
||||
engine->Update();
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,108 +1,108 @@
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZSoundTest.cpp,v 1.19 2003/10/21 01:17:35 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZSoundTest","width",800);
|
||||
h = cfg.GetInt("ZSoundTest","height",600);
|
||||
bpp = cfg.GetInt("ZSoundTest","bpp",32);
|
||||
fs = cfg.GetBool("ZSoundTest","fullscreen",false);
|
||||
title = cfg.GetString("ZSoundTest","title","ZSound Test");
|
||||
rate = cfg.GetInt("ZSoundTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
std::string name[5] = { "monkey", "rooster", "kick", "carcrash", "whip" };
|
||||
ZSound sample[5];
|
||||
ZFont font("data/almontew.ttf",48);
|
||||
ZImage text[6];
|
||||
int sampleNum = 0;
|
||||
|
||||
for(int i=0; i < 4; i++)
|
||||
sample[i].OpenFromZip("data/data.zip",FormatStr("%s.wav",name[i].c_str()));
|
||||
sample[4].Open("data/whip.wav");
|
||||
|
||||
|
||||
font.DrawText("(P)ause\t(U)npause",text[0]);
|
||||
font.DrawText("(F)ade Out\t(H)alt\t",text[1]);
|
||||
font.DrawText("Space - Play\t Up/Down - Control Volume",text[2]);
|
||||
font.DrawText("1-5 Change Sample Being Controlled",text[3]);
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
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]);
|
||||
font.DrawText(FormatStr("Sample: %s",name[sampleNum].c_str()),text[5]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
for(int i=0; i < 6; i++)
|
||||
text[i].Draw(0,i*50);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
This file is Part of the ZEngine Library for 2D game development.
|
||||
Copyright (C) 2002, 2003 James Turk
|
||||
|
||||
ZEngine is Licensed under a BSD-style license.
|
||||
This example file is in the public domain, it may be used with no restrictions.
|
||||
|
||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||
and the home of this Library is http://www.zengine.sourceforge.net
|
||||
*******************************************************************************/
|
||||
|
||||
/*$Id: ZSoundTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/
|
||||
|
||||
#include <ZEngine.h>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
using namespace ZE;
|
||||
|
||||
bool Initialize()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
ZConfigFile cfg("tests.zcf");
|
||||
int w,h,bpp,rate;
|
||||
bool fs;
|
||||
std::string title;
|
||||
|
||||
w = cfg.GetInt("ZSoundTest","width",800);
|
||||
h = cfg.GetInt("ZSoundTest","height",600);
|
||||
bpp = cfg.GetInt("ZSoundTest","bpp",32);
|
||||
fs = cfg.GetBool("ZSoundTest","fullscreen",false);
|
||||
title = cfg.GetString("ZSoundTest","title","ZSound Test");
|
||||
rate = cfg.GetInt("ZSoundTest","framerate",60);
|
||||
|
||||
return engine->CreateDisplay(w,h,bpp,fs,title);
|
||||
}
|
||||
|
||||
void Test()
|
||||
{
|
||||
ZEngine *engine = ZEngine::GetInstance();
|
||||
|
||||
std::string name[5] = { "monkey", "rooster", "kick", "carcrash", "whip" };
|
||||
ZSound sample[5];
|
||||
ZFont font("data/almontew.ttf",48);
|
||||
ZImage text[6];
|
||||
int sampleNum = 0;
|
||||
|
||||
for(int i=0; i < 4; i++)
|
||||
sample[i].OpenFromZip("data/data.zip",FormatStr("%s.wav",name[i].c_str()));
|
||||
sample[4].Open("data/whip.wav");
|
||||
|
||||
|
||||
font.DrawText("(P)ause\t(U)npause",text[0]);
|
||||
font.DrawText("(F)ade Out\t(H)alt\t",text[1]);
|
||||
font.DrawText("Space - Play\t Up/Down - Control Volume",text[2]);
|
||||
font.DrawText("1-5 Change Sample Being Controlled",text[3]);
|
||||
do
|
||||
{
|
||||
//In the active loop, check events first//
|
||||
engine->CheckEvents();
|
||||
|
||||
if(engine->IsActive())
|
||||
{
|
||||
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]);
|
||||
font.DrawText(FormatStr("Sample: %s",name[sampleNum].c_str()),text[5]);
|
||||
|
||||
engine->Clear(); //clear screen
|
||||
for(int i=0; i < 6; i++)
|
||||
text[i].Draw(0,i*50);
|
||||
engine->Update(); //update the screen
|
||||
}
|
||||
|
||||
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(Initialize())
|
||||
Test();
|
||||
ZEngine::ReleaseInstance();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user