zengine/test/ZFontTest.cpp

86 lines
2.9 KiB
C++
Raw Normal View History

2002-11-21 05:40:49 +00:00
/*******************************************************************************
2002-12-29 06:50:19 +00:00
This file is Part of the ZEngine Library for 2D game development.
Copyright (C) 2002, 2003 James Turk
2002-11-21 05:40:49 +00:00
2003-07-10 20:45:39 +00:00
ZEngine is Licensed under a BSD-style license.
This example file is in the public domain, it may be used with no restrictions.
2002-11-21 05:40:49 +00:00
2002-12-29 06:50:19 +00:00
The maintainer of this library is James Turk (james@conceptofzero.net)
and the home of this Library is http://www.zengine.sourceforge.net
2002-11-21 05:40:49 +00:00
*******************************************************************************/
2002-12-29 07:09:44 +00:00
2003-09-09 02:45:58 +00:00
/*$Id: ZFontTest.cpp,v 1.15 2003/09/09 02:45:58 cozman Exp $*/
2003-01-04 05:17:56 +00:00
2002-11-21 05:40:49 +00:00
#include <ZEngine.h>
#include <string>
using namespace std;
using namespace ZE;
bool Initialize()
2002-11-21 05:40:49 +00:00
{
ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf");
2003-01-04 05:16:01 +00:00
int w,h,bpp,rate;
2002-11-21 05:40:49 +00:00
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");
2003-01-04 05:16:01 +00:00
rate = cfg.GetInt("ZFontTest","framerate",60);
2002-11-21 05:40:49 +00:00
engine->SetupDisplay(w,h,bpp,fs);
2003-01-04 05:16:01 +00:00
engine->SetDesiredFramerate(rate);
return engine->CreateDisplay(title);
2002-11-21 05:40:49 +00:00
}
void Test()
{
ZEngine *engine = ZEngine::GetInstance();
//Open and Setup all the Fonts and Create Images//
2003-01-04 05:16:01 +00:00
ZImage text[6];
2002-11-21 05:40:49 +00:00
ZFont almonte("data/almontew.ttf",48), axaxax("data/axaxax.ttf",32), betsy("data/betsy.ttf",64);
2003-06-11 05:51:15 +00:00
almonte.SetColor(255,0,0,128);
2002-11-21 05:40:49 +00:00
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]);
2002-11-21 05:40:49 +00:00
engine->Clear(); //clear screen
//draw the images//
for(int i=0; i <= 5; i++)
2003-08-02 01:18:45 +00:00
text[i].Draw(10*i,50*i);
engine->Update(); //update the screen
}
2002-11-21 05:40:49 +00:00
} while(!engine->QuitRequested()); //quit only when engine has encountered a quit request
}
2003-09-09 02:45:58 +00:00
int ZE_main(int argc, char *argv[])
2002-11-21 05:40:49 +00:00
{
if(Initialize())
Test();
2002-11-21 05:40:49 +00:00
return 0;
}