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.
482 lines
10 KiB
C++
482 lines
10 KiB
C++
#define SYS_PLATFORM_WIN32_PLUGIN
|
|
#include <lowlevellib.h>
|
|
#include "FMLoader.h"
|
|
|
|
CFMLoader gl_Loader;
|
|
|
|
|
|
#define SYS_PLATFORM_WIN32_DX5
|
|
#include <lowlevellib.h>
|
|
|
|
|
|
|
|
CVec2f vec_mouse;
|
|
|
|
float speedadd = 0;
|
|
|
|
|
|
llgfx_id gfx_nebula = 0;
|
|
llgfx_id gfx_mouse = 0;
|
|
llgfx_id gfx_star1 = 0;
|
|
llgfx_id gfx_star2 = 0;
|
|
llgfx_id gfx_star3 = 0;
|
|
llgfx_id gfx_star4 = 0;
|
|
llgfx_id gfx_blackhole = 0;
|
|
llgfx_id gfx_meteor_rot = 0;
|
|
|
|
|
|
class CMeteor : public CLayerSprite {
|
|
public:
|
|
CMeteor()
|
|
{
|
|
m_valid = true;
|
|
m_visible = true;
|
|
m_position.m_u = llirq_GetRand(llgfx_displaywidth);
|
|
m_position.m_v = llirq_GetRand(llgfx_displayheight);
|
|
m_frame_cnt = 101;
|
|
m_frame_time = 0.05f;
|
|
m_gfx = llgfx_AddRef(gfx_meteor_rot);
|
|
m_blitflag = BLIT_SRC_ALPHA|BLIT_STRETCH|BLIT_SRC_CENTERED;
|
|
m_blitfx.scale_x = m_blitfx.scale_y = 1.0f;
|
|
|
|
int type = llirq_GetRand(4);
|
|
|
|
switch( type )
|
|
{
|
|
case 0:
|
|
m_scale = 1.0f;
|
|
break;
|
|
case 1:
|
|
m_scale = 0.8f;
|
|
break;
|
|
case 2:
|
|
m_scale = 0.6f;
|
|
break;
|
|
case 3:
|
|
m_scale = 0.4f;
|
|
break;
|
|
}
|
|
|
|
speed = llirq_GetRandF(0,0.4f);
|
|
speed += m_blitfx.fixalpha;
|
|
}
|
|
|
|
float speed;
|
|
|
|
void Action(float delta){
|
|
CLayerSprite::Action(delta);
|
|
|
|
float x = m_position.m_u - llinput_MouseX;
|
|
float y = m_position.m_v - llinput_MouseY;
|
|
float r = ll3d::Sqrt(x*x+y*y);
|
|
float phi = ll3d::Atan2(y,x);
|
|
phi += (40+speedadd)/r*delta*2*speed;
|
|
|
|
x = r*ll3d::Cos(phi);
|
|
y = r*ll3d::Sin(phi);
|
|
m_position.m_u = llinput_MouseX + x;
|
|
m_position.m_v = llinput_MouseY + y;
|
|
if(m_position.m_u<0)m_position.m_u += llgfx_displaywidth;
|
|
if(m_position.m_u>llgfx_displaywidth)m_position.m_u -= llgfx_displaywidth;
|
|
if(m_position.m_v<0)m_position.m_v += llgfx_displayheight;
|
|
if(m_position.m_v>llgfx_displayheight)m_position.m_v -= llgfx_displayheight;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CGravPoint : public CActor
|
|
{
|
|
public:
|
|
CGravPoint(){
|
|
m_position.m_u = llinput_MouseX;
|
|
m_position.m_v = llinput_MouseY;
|
|
m_blitfx.fixalpha = 1;
|
|
m_lifetime = 10;
|
|
}
|
|
|
|
void Action(float delta)
|
|
{
|
|
CActor::Action(delta);
|
|
|
|
m_blitfx.fixalpha = 0.5f + 0.5f * (m_lifetime / 10);
|
|
}
|
|
|
|
void Draw(llgfx_id dst){
|
|
|
|
llgfx_BLIT(0,gfx_blackhole,
|
|
m_position.m_u,m_position.m_v,0,BLIT_SRC_ALPHA|BLIT_FXBLEND|BLIT_SRC_CENTERED,&m_blitfx);
|
|
//llgfx_DrawCircle(dst,m_position.m_u,m_position.m_v,16,BLUE);
|
|
}
|
|
};
|
|
|
|
class CStar :public CLayerImage
|
|
{
|
|
public:
|
|
CStar()
|
|
{
|
|
int type = llirq_GetRand(4);
|
|
|
|
switch( type )
|
|
{
|
|
case 0:
|
|
m_blitfx.fixalpha = 1.0f;
|
|
m_gfx = llgfx_AddRef(gfx_star1);
|
|
break;
|
|
case 1:
|
|
m_blitfx.fixalpha = 0.8f;
|
|
m_gfx = llgfx_AddRef(gfx_star2);
|
|
break;
|
|
case 2:
|
|
m_blitfx.fixalpha = 0.6f;
|
|
m_gfx = llgfx_AddRef(gfx_star3);
|
|
break;
|
|
case 3:
|
|
m_blitfx.fixalpha = 0.4f;
|
|
m_gfx = llgfx_AddRef(gfx_star4);
|
|
break;
|
|
}
|
|
|
|
speed = llirq_GetRandF(0,0.4f);
|
|
speed += m_blitfx.fixalpha;
|
|
|
|
m_blitflag = BLIT_SRC_ALPHA|BLIT_FXBLEND|BLIT_SRC_CENTERED;
|
|
m_visible = true;
|
|
m_valid = true;
|
|
m_position.m_u = (float)llirq_GetRand(llgfx_displaywidth);
|
|
m_position.m_v = (float)llirq_GetRand(llgfx_displayheight);
|
|
//ParseLine("set gravity=400:400 mass=100");
|
|
// CStabAction_SetGravityPtr * p = new CStabAction_SetGravityPtr(this,&vec_mouse,1000);
|
|
// m_actions.Put(p);
|
|
}
|
|
|
|
float speed;
|
|
|
|
void Action(float delta){
|
|
CLayerImage::Action(delta);
|
|
|
|
float x = m_position.m_u - llinput_MouseX;
|
|
float y = m_position.m_v - llinput_MouseY;
|
|
float r = ll3d::Sqrt(x*x+y*y);
|
|
float phi = ll3d::Atan2(y,x);
|
|
phi += (40+speedadd)/r*delta*2*speed;
|
|
|
|
x = r*ll3d::Cos(phi);
|
|
y = r*ll3d::Sin(phi);
|
|
m_position.m_u = llinput_MouseX + x;
|
|
m_position.m_v = llinput_MouseY + y;
|
|
if(m_position.m_u<0)m_position.m_u += llgfx_displaywidth;
|
|
if(m_position.m_u>llgfx_displaywidth)m_position.m_u -= llgfx_displaywidth;
|
|
if(m_position.m_v<0)m_position.m_v += llgfx_displayheight;
|
|
if(m_position.m_v>llgfx_displayheight)m_position.m_v -= llgfx_displayheight;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
extern CReadHookModule *plugin_readhook;
|
|
|
|
int callback(char * curFilename, int totalbytes, int totalfiles, int percentcomplete, void *userPtr )
|
|
{
|
|
llgfx_ClearScreen(BLACK);
|
|
llgfx_Printf("Level One Entertainment - l3lib plugin, prototype\n\n");
|
|
llgfx_Printf("Loading %s, %d%% complete", curFilename, percentcomplete);
|
|
llgfx_FlipScreen(0);
|
|
return 0;
|
|
}
|
|
|
|
int os_main(int argc, char **argv, char **envp )
|
|
{
|
|
//llgfx_SetDisplayMode(1024,768,32,0,0);
|
|
|
|
|
|
if( plugin_readhook )
|
|
{
|
|
llgfx_SetDisplayMode(0,0,0,0,0);
|
|
plugin_readhook->SetCallback(callback);
|
|
}
|
|
else
|
|
{
|
|
llgfx_SetDisplayMode(333,470,16,0,0);
|
|
}
|
|
|
|
if( osmain_endgame == true ) return 0;
|
|
//gfx_nebula = llgfx_LoadGfx("nebula2.png");
|
|
gfx_nebula = llgfx_LoadGfx("nebula.jpg");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_blackhole = llgfx_LoadGfx("blackhole.png");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_mouse = llgfx_LoadGfx("mouse.png");
|
|
if( osmain_endgame == true ) return 0;
|
|
llgfx_LoadTileMap("stars.png");
|
|
|
|
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_star1 = llgfx_LoadGfx("star1");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_star2 = llgfx_LoadGfx("star2");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_star3 = llgfx_LoadGfx("star3");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_star4 = llgfx_LoadGfx("star4");
|
|
if( osmain_endgame == true ) return 0;
|
|
gfx_meteor_rot = llgfx_LoadGfx("meteor_anim_rot.png");
|
|
if( osmain_endgame == true ) return 0;
|
|
llgfx_SetFrameCount(gfx_meteor_rot,LLGFX_FRAME_COUNT,101);
|
|
|
|
llgfx_CenterOrigin(gfx_mouse);
|
|
|
|
s_font myFont1;
|
|
llgfx_LoadFont("tahoma.png",&myFont1);
|
|
s_font myFont2;
|
|
llgfx_LoadFont("tahoma8.png",&myFont2);
|
|
|
|
llgfx_SelectFont(&myFont1);
|
|
llgfx_tab_pos[0] = 16;
|
|
|
|
myFont1.blitflag = BLIT_SRC_ALPHA;
|
|
myFont2.blitflag = BLIT_SRC_ALPHA;
|
|
|
|
queue<CStar> starfield;
|
|
|
|
int cnt = 100;
|
|
while( cnt -- > 0 )
|
|
{
|
|
starfield.Put(new CStar());
|
|
}
|
|
|
|
queue<CGravPoint> grav;
|
|
queue<CMeteor> meteors;
|
|
|
|
|
|
|
|
CFps fps;
|
|
fps.m_visible=true;
|
|
|
|
int xb=0;
|
|
int yb=0;
|
|
int xba=0;
|
|
int yba=0;
|
|
CTimer wait;
|
|
wait.Set(1);
|
|
|
|
CLayerSurface surface;
|
|
surface.color(TURQUOISE);
|
|
surface.xysize(70,20);
|
|
surface.SetPos(10,100);
|
|
surface.m_visible = true;
|
|
surface.m_valid = true;
|
|
surface.m_blitflag = BLIT_FXBLEND;
|
|
surface.m_blitfx.fixalpha = 0.5f;
|
|
|
|
while(osmain_endgame==false)
|
|
{
|
|
float delta = llirq_GetDeltaTime();
|
|
|
|
if(llinput_MouseRelX > 0 ){xba--;wait.Reset();}
|
|
if(llinput_MouseRelX < 0 ){xba++;wait.Reset();}
|
|
if(llinput_MouseRelY > 0 ){yba--;wait.Reset();}
|
|
if(llinput_MouseRelY < 0 ){yba++;wait.Reset();}
|
|
|
|
if( xba < -4 ) xba=-4;
|
|
if( yba < -4 ) yba=-4;
|
|
if( xba > +4 ) xba=4;
|
|
if( yba > +4 ) yba=4;
|
|
|
|
if( wait.Action(delta) ){
|
|
if( xba < 0 ) xba++;
|
|
if( xba > 0 ) xba--;
|
|
if( yba < 0 ) yba++;
|
|
if( yba > 0 ) yba--;
|
|
}
|
|
|
|
xb+=xba;
|
|
yb+=yba;
|
|
|
|
//llgfx_BLITFast(0,gfx_nebula);
|
|
llgfx_TILE_BLIT(0,gfx_nebula,xb,yb);
|
|
|
|
vec_mouse.m_u = llinput_MouseX;
|
|
vec_mouse.m_v = llinput_MouseY;
|
|
|
|
while( CStar *S = starfield.Next() )
|
|
{
|
|
S->Action(delta);
|
|
S->Draw(0);
|
|
}
|
|
while( CMeteor *M = meteors.Next() )
|
|
{
|
|
M->Action(delta);
|
|
M->Draw(0);
|
|
}
|
|
|
|
while( CGravPoint *G = grav.Next() )
|
|
{
|
|
G->Action(delta);
|
|
G->Draw(0);
|
|
if( G->m_lifetime <= 0 )
|
|
{
|
|
CVec2f * search_adr = &G->m_position;
|
|
while(CStar *S = starfield.Next())
|
|
{
|
|
while(CStabAction * CS = S->m_actions.Next() )
|
|
{
|
|
if( CS->GetType() == stab_SET_GRAVITY_PTR )
|
|
{
|
|
if( ((CStabAction_SetGravityPtr*)CS)->m_GravitationOrg == search_adr )
|
|
S->m_actions.Remove(CS);
|
|
}
|
|
}
|
|
}
|
|
grav.Remove(G);
|
|
}
|
|
}
|
|
|
|
llgfx_BLIT(0,gfx_mouse,llinput_MouseX,llinput_MouseY,0,BLIT_SRC_ALPHA);
|
|
|
|
|
|
/* int test = llirq_GetRand(8);
|
|
if( test == 0 ){
|
|
CMeteor *M = new CMeteor();
|
|
meteors.Put(M);
|
|
M->m_lifetime = 4;
|
|
}
|
|
*/
|
|
|
|
if( Justdown(llinput_MouseBtn1) ){
|
|
CGravPoint *G = new CGravPoint();
|
|
grav.Put(G);
|
|
while(CStar *S = starfield.Next())
|
|
{
|
|
S->m_actions.Put( new CStabAction_SetGravityPtr(S,&G->m_position,5000));
|
|
}
|
|
}
|
|
|
|
if( llinput_MouseBtn2 ){
|
|
/* CActor collision_actor;
|
|
collision_actor.m_radius = 16;
|
|
collision_actor.m_position.m_u = llinput_MouseX;
|
|
collision_actor.m_position.m_v = llinput_MouseY;
|
|
while(CGravPoint *G = grav.Next())
|
|
{
|
|
if( G->TestCollisionCircle(&collision_actor) == true )
|
|
{
|
|
CVec2f * search_adr = &G->m_position;
|
|
while(CStar *S = starfield.Next())
|
|
{
|
|
while(CStabAction * CS = S->m_actions.Next() )
|
|
{
|
|
if( CS->GetType() == stab_SET_GRAVITY_PTR )
|
|
{
|
|
if( ((CStabAction_SetGravityPtr*)CS)->m_GravitationOrg == search_adr )
|
|
S->m_actions.Remove(CS);
|
|
}
|
|
}
|
|
}
|
|
grav.Remove(G);
|
|
}
|
|
}
|
|
*/
|
|
|
|
// saugt sterne
|
|
|
|
CActor collision_actor;
|
|
collision_actor.m_radius = 32;
|
|
collision_actor.m_position.m_u = llinput_MouseX;
|
|
collision_actor.m_position.m_v = llinput_MouseY;
|
|
while(CStar *S = starfield.Next())
|
|
{
|
|
if( S->TestCollisionCircle(&collision_actor) == true )
|
|
{
|
|
starfield.Remove(S);
|
|
delete S;
|
|
}
|
|
}
|
|
}
|
|
|
|
if( llinput_MouseBtn2 == 0 &&
|
|
(llinput_MouseRelX != 0 || llinput_MouseRelY != 0) )
|
|
{
|
|
if( ll3d::Abs(llinput_MouseRelX) > 32 ||
|
|
ll3d::Abs(llinput_MouseRelY) > 32 )
|
|
{
|
|
speedadd += 100*delta;
|
|
if(speedadd == 0 )
|
|
speedadd = 1;
|
|
}
|
|
|
|
int cnt = 4;
|
|
while( cnt -- )
|
|
{
|
|
CStar * S = new CStar();
|
|
S->m_position = vec_mouse;
|
|
S->m_position.m_u += llinput_MouseRelX * llirq_GetRandI(8);
|
|
S->m_position.m_v += llinput_MouseRelY * llirq_GetRandI(8);
|
|
starfield.Put( S );
|
|
while(CGravPoint *G = grav.Next())
|
|
{
|
|
S->m_actions.Put( new CStabAction_SetGravityPtr(S,&G->m_position,5000));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
speedadd -= (speedadd*0.5f)*delta;
|
|
|
|
|
|
fps.Action(delta);
|
|
static bool toggle=true;
|
|
if( Justdown(llinput_Keys[LLINPUT_KEY_SPACE]) )
|
|
toggle = !toggle;
|
|
|
|
llgfx_SelectFont(&myFont1);
|
|
llgfx_SetTextPos(10,10);
|
|
llgfx_SetTextRect(llgfx_displaywidth,llgfx_displayheight);
|
|
|
|
llgfx_DrawText(
|
|
0,
|
|
"NEBULASTARS 1.0\n",
|
|
BLIT_SRC_ALPHA,
|
|
0
|
|
);
|
|
|
|
if(toggle)
|
|
{
|
|
llgfx_SelectFont(&myFont2);
|
|
llgfx_Printf("Particel Count:\t%d\n", starfield.InQueue());
|
|
llgfx_Printf("Gravitiy Points:\t%d\n", grav.InQueue());
|
|
llgfx_Printf("Energy:\t%f\n", speedadd);
|
|
}
|
|
|
|
|
|
if( ll2d::IsPointInRect(surface.m_position_rect,llinput_MouseX,llinput_MouseY))
|
|
{
|
|
surface.m_blitflag = BLIT_FXADD;
|
|
if( Justdown(llinput_MouseBtn1) )
|
|
llgfx_ToggleFullscreen();
|
|
}
|
|
else
|
|
surface.m_blitflag = BLIT_FXBLEND;
|
|
|
|
if( llgfx_fullscreen ){
|
|
llgfx_DrawText(16, 102, "Desktop" );
|
|
}
|
|
else{
|
|
llgfx_DrawText(16, 102, "Fullscreen" );
|
|
}
|
|
surface.Action(delta);
|
|
surface.Draw(0);
|
|
|
|
|
|
//llgfx_Printf("%d %d",llinput_MouseX,llinput_MouseY);
|
|
|
|
llgfx_FlipScreen(0);
|
|
llinput_Update();
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|