Interpolater
From SWWorkshop
In Games motion will be define with speed, acceleration, torque etc.. But sometimes we don't want to calculate speed and acc. How can give motion another way. If we define start,end point and time. The objects automaticly calculate it's speed. Interpolate. You can use this tecnique any type of value. For example alpha,x,y,width,height,rot, etc..)
interpID=swInterpolaterCreate(0,1,10);
Api Docs
SwEngine, swGraphics, swInterpolator, swRect, swApplication
Source Code
#include "../../include/SWEngine.h" #pragma comment (lib,"../../lib/SWUtil.lib") #pragma comment (lib,"../../lib/SWTypes.lib") #pragma comment (lib,"../../lib/SWCore.lib") #pragma comment (lib,"../../lib/SWEngine.lib") #pragma comment (lib,"../../lib/SWGame.lib") #pragma comment (lib,"../../lib/SWGui.lib") swApplication interpolationApp; float alpha=0; int interpID=-1; //------------------------------------------------------------------------------------------- void GameLoop(){ swGraphicsBeginScene(); //Background swGraphicsSetBgColor0(0.6f,0.6f,0.6f); //5gen swGraphicsSetColor0(0.3,0.2,0.8,alpha); swGraphicsSetBlendingMode(SW_BLENDING_MODE_SOLID); alpha=swInterpolaterGetValue(interpID); swGraphicsRenderSolidElips0(300,300,200,200,5); swGraphicsEndScene(); } //------------------------------------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { //Application Settings interpolationApp.hInstance=hInstance; interpolationApp.fullScreen=false; interpolationApp.cursor=true; interpolationApp.width=800; interpolationApp.height=600; interpolationApp.title="Interpolation"; interpolationApp.path=""; interpolationApp.appRun=GameLoop; //Application Execution swEngineInit(&interpolationApp); //Init Application interpID=swInterpolaterCreate(0,1,10); swInterpolaterStart(interpID); swEngineRun(); swEngineExit(); return 0; }
