added Stinus

This commit is contained in:
James Turk 2003-11-24 01:58:23 +00:00
parent d7d7192589
commit 7a4ba04e94

View File

@ -1,154 +1,154 @@
/******************************************************************************* /*******************************************************************************
This file is Part of the ZEngine Library for 2D game development. This file is Part of the ZEngine Library for 2D game development.
Copyright (C) 2002, 2003 James Turk Copyright (C) 2002, 2003 James Turk
ZEngine is Licensed under a BSD-style license. ZEngine is Licensed under a BSD-style license.
This example file is in the public domain, it may be used with no restrictions. 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) The maintainer of this library is James Turk (james@conceptofzero.net)
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: ZParticleTest.cpp,v 1.7 2003/10/21 01:17:35 cozman Exp $*/ /*$Id: ZParticleTest.cpp,v 1.8 2003/11/24 01:58:23 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
using namespace std; using namespace std;
using namespace ZE; using namespace ZE;
bool Initialize() bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp,rate;
bool fs; bool fs;
std::string title; std::string title;
w = cfg.GetInt("ZParticleTest","width",800); w = cfg.GetInt("ZParticleTest","width",800);
h = cfg.GetInt("ZParticleTest","height",600); h = cfg.GetInt("ZParticleTest","height",600);
bpp = cfg.GetInt("ZParticleTest","bpp",32); bpp = cfg.GetInt("ZParticleTest","bpp",32);
fs = cfg.GetBool("ZParticleTest","fullscreen",false); fs = cfg.GetBool("ZParticleTest","fullscreen",false);
title = cfg.GetString("ZParticleTest","title","ZParticle Test"); title = cfg.GetString("ZParticleTest","title","ZParticle Test");
rate = cfg.GetInt("ZParticleTest","framerate",60); rate = cfg.GetInt("ZParticleTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }
void Test() void Test()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZFont font("data/axaxax.ttf",20); ZFont font("data/axaxax.ttf",20);
ZImage text[3],bg; ZImage text[3],bg;
ZSimpleParticleSystem<ZSimpleParticle> effect[3]; ZSimpleParticleSystem<ZSimpleParticle> effect[3];
int effectNum=0,i; int effectNum=0,i;
effect[0].SetPosRange(350,300,450,350); effect[0].SetPosRange(350,300,450,350);
effect[0].SetColorRange(0,255,0,255,0,255,128,255); effect[0].SetColorRange(0,255,0,255,0,255,128,255);
effect[0].SetVelocityRange(-60,-300,60,-60); effect[0].SetVelocityRange(-60,-300,60,-60);
effect[0].SetEnergyRange(0.1f,2,-0.3f,0.05f); effect[0].SetEnergyRange(0.1f,2,-0.3f,0.05f);
effect[0].SetSizeRange(20,30,1,5); effect[0].SetSizeRange(20,30,1,5);
effect[0].SetDrawStyle(DS_IMAGE); effect[0].SetDrawStyle(DS_IMAGE);
effect[0].SetMaxParticles(2000); effect[0].SetMaxParticles(2000);
effect[0].SetRate(120); effect[0].SetRate(120);
effect[0].SetImage("data/particle1.tga"); effect[0].SetImage("data/particle1.tga");
effect[1].SetPosRange(0,0,static_cast<float>(engine->DisplayWidth()),20); effect[1].SetPosRange(0,0,static_cast<float>(engine->DisplayWidth()),20);
effect[1].SetColorRange(230,255,230,255,250,255,200,240); effect[1].SetColorRange(230,255,230,255,250,255,200,240);
effect[1].SetVelocityRange(-10,30,10,50); effect[1].SetVelocityRange(-10,30,10,50);
effect[1].SetEnergyRange(1,1); effect[1].SetEnergyRange(1,1);
effect[1].SetSizeRange(1,2); effect[1].SetSizeRange(1,2);
effect[1].SetDrawStyle(DS_POINT); effect[1].SetDrawStyle(DS_POINT);
effect[1].SetMaxParticles(3000); effect[1].SetMaxParticles(3000);
effect[1].SetRate(80); effect[1].SetRate(80);
effect[2].SetPosRange(300,500,420,550); effect[2].SetPosRange(300,500,420,550);
effect[2].SetColorRange(40,60,40,60,40,60,200,240); effect[2].SetColorRange(40,60,40,60,40,60,200,240);
effect[2].SetVelocityRange(-5,-1,5,-5); effect[2].SetVelocityRange(-5,-1,5,-5);
effect[2].SetEnergyRange(1,1); effect[2].SetEnergyRange(1,1);
effect[2].SetSizeRange(24,32,-1,-5); effect[2].SetSizeRange(24,32,-1,-5);
effect[2].SetDrawStyle(DS_IMAGE); effect[2].SetDrawStyle(DS_IMAGE);
effect[2].SetMaxParticles(250); effect[2].SetMaxParticles(250);
effect[2].SetRate(30); effect[2].SetRate(30);
effect[2].SetImage("data/particle2.tga"); effect[2].SetImage("data/particle2.tga");
bg.Open("data/rainbow.bmp"); bg.Open("data/rainbow.bmp");
#if (GFX_BACKEND == ZE_OGL) #if (GFX_BACKEND == ZE_OGL)
bg.Resize(engine->DisplayWidth()/2,engine->DisplayHeight()); //gives perspective on alpha on half of screen bg.Resize(engine->DisplayWidth()/2.0f,static_cast<float>(engine->DisplayHeight())); //gives perspective on alpha on half of screen
#endif #endif
font.DrawText("(P)ause (U)npause (C)lear",text[0]); font.DrawText("(P)ause (U)npause (C)lear",text[0]);
font.DrawText("1-3 : Change System Being Controlled",text[1]); font.DrawText("1-3 : Change System Being Controlled",text[1]);
font.DrawText("Controlling Color Sparkle Effect",text[2]); font.DrawText("Controlling Color Sparkle Effect",text[2]);
do do
{ {
engine->CheckEvents(); engine->CheckEvents();
if(engine->IsActive()) if(engine->IsActive())
{ {
if(engine->ImagesNeedReload()) if(engine->ImagesNeedReload())
{ {
for(i=0; i < 3; ++i) for(i=0; i < 3; ++i)
effect[i].ReloadImage(); effect[i].ReloadImage();
} }
if(engine->KeyIsPressed(SDLK_1)) if(engine->KeyIsPressed(SDLK_1))
{ {
effectNum = 0; effectNum = 0;
font.DrawText("Controlling Color Sparkle Effect",text[2]); font.DrawText("Controlling Color Sparkle Effect",text[2]);
} }
if(engine->KeyIsPressed(SDLK_2)) if(engine->KeyIsPressed(SDLK_2))
{ {
effectNum = 1; effectNum = 1;
font.DrawText("Controlling Snow Effect",text[2]); font.DrawText("Controlling Snow Effect",text[2]);
} }
if(engine->KeyIsPressed(SDLK_3)) if(engine->KeyIsPressed(SDLK_3))
{ {
effectNum = 2; effectNum = 2;
font.DrawText("Controlling Smokeish Effect",text[2]); font.DrawText("Controlling Smokeish Effect",text[2]);
} }
if(engine->KeyIsPressed(SDLK_p)) if(engine->KeyIsPressed(SDLK_p))
effect[effectNum].Pause(); effect[effectNum].Pause();
if(engine->KeyIsPressed(SDLK_u)) if(engine->KeyIsPressed(SDLK_u))
effect[effectNum].Unpause(); effect[effectNum].Unpause();
if(engine->KeyIsPressed(SDLK_c)) if(engine->KeyIsPressed(SDLK_c))
effect[effectNum].Clear(); effect[effectNum].Clear();
//do updating// //do updating//
if(engine->KeyIsPressed(SDLK_s)) if(engine->KeyIsPressed(SDLK_s))
engine->ToggleFullscreen(); engine->ToggleFullscreen();
if(engine->KeyIsPressed(SDLK_ESCAPE)) if(engine->KeyIsPressed(SDLK_ESCAPE))
engine->RequestQuit(); engine->RequestQuit();
for(i=0; i < 3; ++i) for(i=0; i < 3; ++i)
effect[i].Update(); effect[i].Update();
engine->Clear(); engine->Clear();
bg.Draw(0,0); bg.Draw(0,0);
for(i=0; i < 3; ++i) for(i=0; i < 3; ++i)
{ {
effect[i].Render(); effect[i].Render();
text[i].Draw(0,i*25); text[i].Draw(0,i*25);
} }
engine->Update(); engine->Update();
} }
else else
engine->Delay(10); engine->Delay(10);
} 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[])
{ {
if(Initialize()) if(Initialize())
Test(); Test();
ZEngine::ReleaseInstance(); ZEngine::ReleaseInstance();
return 0; return 0;
} }