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.

229 lines
6.4 KiB
C++

#include <lowlevellib.h>
#include <windows.h>
#include <gl/gl.h>
int os_main(int ac, char ** av, char ** env)
{
llgfx_enable_stretchwindow = true;
llgfx_SetDisplayMode(1024,768,32,0,0);
llgfx_id logo = llgfx_LoadGfx("NeHe.png",LLGFX_COLORKEY);
llgfx_id zone = llgfx_LoadGfx("zone.png");
llgfx_id sterne = llgfx_LoadGfx("sterne.png");
llgfx_id geschwader = llgfx_LoadGfx("geschwader.png");
llgfx_id maus = llgfx_LoadGfx("Maus.png",LLGFX_COLORKEY|LLGFX_CENTERORIGIN);
llgfx_id wing = llgfx_LoadGfx("wing.png",LLGFX_COLORKEY|LLGFX_CENTERORIGIN);
llgfx_id scope = llgfx_LoadGfx("scope.png");
queue<CLayerSprite> spriteQ;
queue<CLayerSprite> spriteOld;
CFps fps;
fps.m_visible=true;
llsound_id sid2 = llsound_LoadSnd("thumplo.wav");
llsound_id sid = llsound_CloneSnd( sid2);
//llsound_Play(sid,LLSOUND_LOOP);
llirq_ResetTime();
while(osmain_endgame==false){
float delta = llirq_GetDeltaTime();
static float tileblitscroll = 0;
tileblitscroll -= delta * 300;
llgfx_sBLITFX blitfx;
blitfx.angle_x = 0;
blitfx.angle_y = 0;
blitfx.angle_z = 0;
//llgfx_ClearScreen(BLACK);
// HIntergrund
llgfx_TILE_BLIT(0,sterne,0.0f,tileblitscroll,0,0,0);
blitfx.scale_x = 0.1;
blitfx.scale_y = 0.1;
blitfx.angle_z = ll3d::Mod(tileblitscroll*4,360.0f);
blitfx.angle_x = 0;//ll3d::Mod(tileblitscroll*16,360.0f);
blitfx.angle_y = 0;
blitfx.fixalpha = ll3d::Mod(llirq_uptime/10,1.0f);
llgfx_SetOrigin( logo, 500, 100);
//llgfx_CenterOrigin( logo );
llgfx_BLIT(0,logo,400,400,0,BLIT_SRC_ALPHA|BLIT_STRETCH|BLIT_ROTATE,&blitfx);
blitfx.scale_x = 0.5;
blitfx.scale_y = 0.5f;
//llgfx_TILE_BLIT(0,zone,-tileblitscroll*4,-tileblitscroll*5,0,BLIT_SRC_ALPHA,&blitfx);
if(llinput_MouseBtn1 )
for(int i = 0 ; i < 10; i++ )
{
CLayerSprite *sp = spriteOld.Get();
if(sp==NULL)sp = new CLayerSprite();
spriteQ.Put(sp);
sp->m_gfx = wing;
sp->m_valid = true;
sp->m_blitflag = BLIT_SRC_ALPHA|BLIT_STRETCH|BLIT_SRC_CENTERED|BLIT_ROTATE;
sp->m_blitfx.scale_x=sp->m_blitfx.scale_y=llirq_GetRandF(1.0,4.0f);
sp->m_blitfx.angle_x = 0.0f;
sp->m_blitfx.angle_y = 0.0f;
sp->m_blitfx.angle_z = 0.0f;
sp->m_acceleration = sp->m_blitfx.scale_x *sp->m_blitfx.scale_x * 40;
sp->m_position.m_u = llinput_MouseX;
sp->m_position.m_v = llinput_MouseY;
sp->m_lifetime = 10;
}
while(CLayerSprite *sp = spriteQ.Next())
{
sp->m_position.m_v += delta * sp->m_acceleration;
if( sp->m_position.m_v > llgfx_displayheight){
sp->m_position.m_v = 0;
}
if( sp->m_blitfx.scale_x > 1.0){
sp->m_blitfx.scale_x -= delta;
sp->m_blitfx.scale_y -= delta;
}
sp->m_acceleration = sp->m_blitfx.scale_x *sp->m_blitfx.scale_x * 40;
sp->m_blitfx.angle_z = 90+ll3d::getDegree(sp->GetAngleToPoint(llinput_MouseX,llinput_MouseY));
sp->Draw(0);
sp->m_lifetime -= delta;
if(sp->m_lifetime <= 0 ){
spriteQ.Remove(sp);
spriteOld.Put(sp);
}
}
/*
glViewport(0,0,llgfx_displaywidth,llgfx_displayheight); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, llgfx_displaywidth, llgfx_displayheight, 0, 100000, -10000);
glTranslatef(llinput_MouseX,llinput_MouseY,0);
static float spin = 0;
spin += llirq_GetDeltaTime() * 200;
glRotatef(spin,0,0,1 );
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
//glTranslatef(llinput_MouseX,llinput_MouseY,0);
glPushMatrix();
int x = 0;
int y = 0;
int w = 300;
int h = 200;
glTranslatef(-w/2,-h/2,0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,6);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_ONE);
glColor4f(1.0f, 1.0f, 1.0f, 0.75f);
glBegin(GL_QUADS); // Begin Drawing The Textured Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f( x,y, 0.0);
glTexCoord2f(1.0f, 0.0f); glVertex3f( x+w,y, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( x+w,y+h, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( x,y+h, 0.0f);
glEnd();
glPopMatrix();
*/
llgfx_sRECT rect = {0,0,200,100};
blitfx.fixalpha = (float)llinput_MouseY / (float)llgfx_displayheight;
blitfx.scale_x = 2;
blitfx.scale_y = 2;
blitfx.angle_z = ll3d::Mod(tileblitscroll,360.0f);
blitfx.angle_x = 0;
blitfx.angle_y = 0;
blitfx.color1 = YELLOW;
blitfx.color2 = RED;
blitfx.color3 = BLACK;
blitfx.color4 = BLACK;
llgfx_BLITColor(0,0,0,&rect,BLIT_SRC_CENTERED|BLIT_DST_CENTERED|BLIT_STRETCH|BLIT_ROTATE|BLIT_FXBLEND,&blitfx);
blitfx.angle_z = 0;
blitfx.scale_x = blitfx.scale_y = 1;
llgfx_BLIT(0,maus,llinput_MouseX,llinput_MouseY,0,BLIT_SRC_CKEY|BLIT_STRETCH,&blitfx);
blitfx.fixalpha = (float)llinput_MouseY / (float)llgfx_displayheight;
llgfx_BLIT(0,scope,0,0,0,BLIT_FXDIFF,&blitfx);
fps.Action(delta);
fps.Draw(0);
llgfx_Printf("Sprites: %d",spriteQ.InQueue());
llgfx_Printf("\n\nA - Exit Game ---");
llgfx_Printf("\n\nALT-RETURN toggle Fullscreen");
llgfx_Printf("\n\n Mouse %d:%d",llinput_MouseX,llinput_MouseY);
float l = llsound_GetSndLength(sid);
llgfx_Printf( "\nl=%f",l);
float p = llsound_GetSndPlaytime(sid);
llgfx_Printf( "\np=%f",p);
int status = llsound_GetStatus(sid);
llgfx_Printf( "\ns=%d",status );
llgfx_Printf( "\nuptime=%f",llirq_uptime);
llgfx_Printf( "\ndelta=%f",delta);
float xpos = ll3d::Mod((float)tileblitscroll,(float)llgfx_displaywidth);
llgfx_DrawCircle(0, xpos,200.0f,(float)llinput_MouseY,YELLOW);
llgfx_DrawLine(0,xpos,200.0f,0.0f,(float)llgfx_displayheight,GOLD);
if( Justdown(llinput_Keys[LLINPUT_KEY_B]) ){
llsound_Stop(sid);
}
if( Justdown(llinput_Keys[LLINPUT_KEY_A]) ){
osmain_endgame = true;
}
if( Justdown(llinput_Keys[LLINPUT_KEY_RETURN])
&& down(llinput_Keys[LLINPUT_LMENU]) ){
llgfx_ToggleFullscreen();
}
llgfx_SetTextPos(400,300);
blitfx.scale_x = ll3d::Mod(llirq_uptime,6);
blitfx.scale_y = ll3d::Mod(llirq_uptime,6);
blitfx.color1 = BLACK;
blitfx.color2 = blitfx.color1;
llgfx_DrawText(0,"HELLO",BLIT_STRETCH|BLIT_FXCOLOR,&blitfx);
//Frameloop Zeichnen ist fertig, Backbuffer anzeigen
llgfx_FlipScreen(1);
llsound_Update(delta);
llinput_Update();
llirq_Sleep(10);
}
return 0;
}