You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
8.1 KiB
C++

#include <lowlevellib.h>
float dirx = 120;
float diry = 60;
float scale = 1.0f;
float scalespeed = 1;
float SCALEMAX = 4.5f;
float si = 1.0f;
float ti = 0.0f;
float co = 1.0f;
float totaltime = 0;
float sinustime = 0;
int frames = 0;
float xx, jj;
float delta = 0;
int cur_frame = 0;
CFps fps;
void frame_loop_start()
{
delta = llirq_GetDeltaTime();
fps.Action(delta);
ti += delta;
totaltime += delta;
sinustime += delta;
while( sinustime > PI2 )
sinustime -= PI2;
si = ll3d::Sin(sinustime);
co = ll3d::Cos(sinustime);
frames ++;
}
void frame_loop_ende()
{
fps.Draw(0);
llgfx_FlipScreen(1);
llinput_Update();
llsound_Update();
if( llinput_Keys[LLINPUT_KEY_A] )
osmain_endgame = true;
if( llinput_Keys[LLINPUT_CURSOR_LEFT] )
if( dirx > 0 ) dirx = -dirx;
if( llinput_Keys[LLINPUT_CURSOR_RIGHT] )
if( dirx < 0 ) dirx = -dirx;
if( llinput_Keys[LLINPUT_CURSOR_UP] )
if( diry > 0 ) diry = -diry;
if( llinput_Keys[LLINPUT_CURSOR_DOWN] )
if( diry < 0 ) diry = -diry;
}
// wartet bis losgelassen
void wait_a()
{
while( llinput_Keys[LLINPUT_KEY_A] )
{
llinput_Update();
}
}
int FtpTransfer(char * curFilename, int totalbytes, int totalfiles, int percentcomplete, void *userPtr )
{
llgfx_ClearScreen(RED);
llgfx_Printf("File: %s\n", curFilename);
llgfx_Printf("percentcomplete: %d",percentcomplete);
llgfx_FlipScreen(0);
llinput_Update();
llsound_Update();
if( osmain_endgame == true )
return -1;
return 0;
}
int os_main(int argc,char **argv,char **envp)
{
fps.m_visible =1;
llgfx_SetDisplayMode( 320, 240, 16, 0 );
// llfile_eSTREAM ftpstream = llfile_OpenStream( LLFILE_STREAM_FTP, "10.16.19.1:tpe:ux1tpe");
llfile_eSTREAM ftpstream = llfile_OpenStream( LLFILE_STREAM_FTP, "levelone.alfahosting.org:web95:web9599");
if( ftpstream ){
// //llfile_IoCtlStream( ftpstream,"OPEN","auftragsliste");
// llfile_IoCtlStream( ftpstream,"OPEN","/html/appriv/starbreaker_pc.zip");
//
// char buf[8192];
// llfile_ReadStream( ftpstream, buf, sizeof(buf) );
// llfile_CloseStream(ftpstream);
llfile_PushModule(ftpstream, new CReadHookModule(1024,FtpTransfer,0), HEAD);
int size = 0;
llfile_current_stream = ftpstream;
//llfile_LoadToMem("/html/appriv/xenitris_demo.jpg",&size);
llfile_LoadToMem("/html/appriv/spaccygalaxians.zip",&size);
//llfile_LoadToMem("/html/appriv/xenitris_workspace_copy.rar",&size);
}
llfile_current_stream = LLFILE_STREAM_STDIO;
DebugOutLn("Loading Gfx");
xx=0;
jj=0;
llsound_id jingle = llsound_LoadSnd("TEKKI_FX_BANK03_002.WAV",0);
// llsound_id jingle = llsound_LoadSnd("jedisounds/bird.wav");
llsound_id loop = llsound_LoadSnd("closer.wav");
loop = llsound_CloneSnd(jingle);
#if 0
llfile_eSTREAM str;
if( str = llfile_OpenStream( LLFILE_STREAM_ZIP, "testgfx.zip" ) )
{
llfile_current_stream = str;
}
#endif
llgfx_id background = llgfx_LoadGfx("background_24.png",0);
llgfx_id logo = llgfx_LoadGfx("one03.png",LLGFX_COLORKEY);
DebugOutLn("background=%d",background);
DebugOutLn("logo=%d",logo);
bool wait_mouse_release = false;
// llsound_SetVolume(loop,1.5);
// llsound_SetFrequency(loop,19000);
// llsound_Play(loop,LLSOUND_LOOP);
llsound_id musik = llsound_LoadSnd("aaaa_base.ogg",LLSOUND_STREAM);
// llsound_id musik = llsound_LoadSnd("aaaa_base.mp3",LLSOUND_STREAM);
llsound_Resume(musik,LLSOUND_LOOP,0);
while(osmain_endgame==false)
{
frame_loop_start();
llgfx_ClearScreen();
llgfx_BLIT(0,logo);
cur_frame = 0;
cur_frame ++ ;
if (cur_frame >=16 )
cur_frame=0;
xx += dirx * delta;
jj += diry * delta;
if( scale >= SCALEMAX )
scale = SCALEMAX,scalespeed*=-1;
if( scale <= - SCALEMAX)
scale = - SCALEMAX, scalespeed*=-1;
scale += scalespeed * delta;
if( (llinput_MouseBtn1&0x3) == 1 ){
float time = llsound_GetSndLength(musik);
float newtime = llirq_GetRandF(0,time);
newtime = 0;
// llsound_Resume(musik,LLSOUND_LOOP,newtime);
llsound_Play(jingle);
}
llgfx_Printf("\nllinput_MouseBtn1:%d",(int)llinput_MouseBtn1);
llgfx_Printf("\nMusik Pos: %f sec", llsound_GetSndPlaytime(musik) );
llgfx_Printf("\nMusik Status: %d", llsound_GetStatus(musik));
llgfx_Printf("\nsnd Pos: %f sec", llsound_GetSndPlaytime(jingle) );
llgfx_Printf("\nsnd Status: %d", llsound_GetStatus(jingle));
frame_loop_ende();
}
wait_a();
osmain_endgame=false;
SCALEMAX = 1.0f;
while(osmain_endgame==false)
{
frame_loop_start();
llgfx_TILE_BLIT(0,background,(int)xx,(int)jj);
llgfx_sBLITFX blitfx;
blitfx.scale_x = scale;
blitfx.scale_y = scale;
blitfx.fixalpha = si;
int blitflag = 0;
blitflag = BLIT_DST_CENTERED | BLIT_FXBLEND;
llgfx_BLIT(0,logo,0,0,0,blitflag,&blitfx);
cur_frame = 0;
cur_frame ++ ;
if (cur_frame >=16 )
cur_frame=0;
xx += dirx * delta;
jj += diry * delta;
scale += scalespeed * delta;
if( scale >= SCALEMAX )
scale = SCALEMAX,scalespeed*=-1;
if( scale <= - SCALEMAX)
scale = - SCALEMAX, scalespeed*=-1;
frame_loop_ende();
}
wait_a();
osmain_endgame=false;
llgfx_id background2 = llgfx_LoadGfx("paper.png",0);
while(osmain_endgame==false)
{
frame_loop_start();
llgfx_TILE_BLIT(0,background2,(int)xx,(int)jj);
llgfx_sBLITFX blitfx;
blitfx.scale_x = scale;
blitfx.scale_y = scale;
blitfx.fixalpha = 0.5f;
int blitflag = 0;
blitflag = BLIT_DST_CENTERED;
llgfx_SetOrigin(logo,2,2);
llgfx_BLIT(0,logo,0,0,0,blitflag|BLIT_FXSUB,&blitfx);
llgfx_SetOrigin(logo,0,0);
blitfx.fixalpha = 0.9f;
llgfx_BLIT(0,logo,0,0,0,BLIT_FXADD,&blitfx);
cur_frame = 0;
cur_frame ++ ;
if (cur_frame >=16 )
cur_frame=0;
xx += dirx * delta;
jj += diry * delta;
if( scale >= SCALEMAX )
scale = SCALEMAX,scalespeed*=-1;
if( scale <= - SCALEMAX)
scale = - SCALEMAX, scalespeed*=-1;
scale += scalespeed * delta;
frame_loop_ende();
}
wait_a();
osmain_endgame=false;
while(osmain_endgame==false)
{
frame_loop_start();
llgfx_sBLITFX blitfx;
blitfx.scale_x = scale;
blitfx.scale_y = scale;
blitfx.fixalpha = 0.5f;
llgfx_TILE_BLIT(0,background2,(int)xx,(int)jj);
llgfx_TILE_BLIT(0,background,(int)(xx/2),(int)(jj/2),0,BLIT_FXSUB,&blitfx);
int blitflag = 0;
blitflag = BLIT_DST_CENTERED;
llgfx_SetOrigin(logo,2,2);
llgfx_BLIT(0,logo,0,0,0,blitflag|BLIT_FXSUB,&blitfx);
llgfx_SetOrigin(logo,0,0);
blitfx.fixalpha = 0.9f;
llgfx_BLIT(0,logo,0,0,0,BLIT_FXADD,&blitfx);
cur_frame = 0;
cur_frame ++ ;
if (cur_frame >=16 )
cur_frame=0;
xx += dirx * delta;
jj += diry * delta;
if( scale >= SCALEMAX )
scale = SCALEMAX,scalespeed*=-1;
if( scale <= - SCALEMAX)
scale = - SCALEMAX, scalespeed*=-1;
scale += scalespeed * delta;
frame_loop_ende();
}
wait_a();
osmain_endgame=false;
SCALEMAX=32;
while(osmain_endgame==false)
{
frame_loop_start();
llgfx_sBLITFX blitfx;
blitfx.scale_x = scale;
blitfx.scale_y = scale;
blitfx.fixalpha = 0.5f;
llgfx_TILE_BLIT(0,background,(int)xx,(int)jj);
llgfx_TILE_BLIT(0,background2,(int)(xx/2),(int)(jj/2),0,BLIT_SCANLINES,&blitfx);
int blitflag = 0;
blitflag = BLIT_DST_CENTERED;
llgfx_SetOrigin(logo,0,0);
blitfx.fixalpha = 0.9f;
llgfx_BLIT(0,logo,0,0,0,BLIT_STRETCH|BLIT_DST_CENTERED|BLIT_SCANLINES,&blitfx);
cur_frame = 0;
cur_frame ++ ;
if (cur_frame >=16 )
cur_frame=0;
xx += dirx * delta;
jj += diry * delta;
float multiplier = 0.05f + ((ll3d::Abs(scale) / SCALEMAX)*32);
if( scalespeed < 0 )
scalespeed = - multiplier;
else
scalespeed = multiplier;
if( scale >= SCALEMAX )
scale = SCALEMAX,scalespeed*=-1;
if( scale <= - SCALEMAX)
scale = - SCALEMAX, scalespeed*=-1;
scale += scalespeed * delta;
frame_loop_ende();
}
/*
llgfx_id explo = llgfx_LoadGfx("explosion-1-all.png",LLGFX_COLORKEY);
llgfx_SetFrameCount(explo,LLGFX_FRAME_COUNT,16);
llgfx_id tmpgfx = llgfx_ROTATE_BLIT(explo,(s_rect*)cur_frame,360*scale);
llgfx_BLIT(0,tmpgfx,(int)(160+co*80),(int)(120+si*80),0,BLIT_STRETCH|BLIT_FXMUL|BLIT_SRC_CENTERED,&blitfx),
llgfx_ReleaseGfx(tmpgfx);
*/
CDebug::WriteLn("overage frametime=%f", totaltime / (frames+1) );
CDebug::WriteLn("maxpeak memory = %d", llmem_maxpeak_allocated_memory );
return 0;
}