#include <acknex.h>
#include <default.c>
MATERIAL* mtlTransp = { // transparent black
effect = "
Texture TargetMap; // source bitmap
sampler2D smpSrc = sampler_state { texture = <TargetMap>; };
float4 process_transparent(float2 Tex: TEXCOORD0): COLOR
{
float4 Color = tex2D( smpSrc, Tex.xy);
if (Color.r <= 0.004 && Color.g <= 0.004 && Color.b <= 0.004)
{
Color.a = 0;
}
return Color;
}
technique Transp {
pass p1 {
AlphaBlendEnable = false;
PixelShader = compile ps_2_0 process_transparent();
}
}
";
}
//
ENTITY* player_ent;
//
//
//=== Problem Area ======================================================================
//
// declare workspace bmaps and view and controllers
//
BMAP* mm_overlay = "#256x256x32"; // actual FINAL bmap INTENDED for use as panel.bmap
// in visible mini_map panel with OVERLAY set ON
BMAP* mm_overlay2 = "#256x256x32"; // Processed BMAP
//
VIEW* mm_stage1 = { pan=90; tilt=-90; arc=135; bmap="#256x256x16"; flags=ISOMETRIC; }
//
BMAP* mm_overlay_butt = "#256x256x32"; //normally "mm_overlay_art.TGA"
PANEL* mm_stage2 = { button(0,0, mm_overlay_butt,mm_overlay_butt,NULL,NULL,NULL,NULL); }
//
PANEL* mini_map = { alpha=75; flags= SHOW | OVERLAY; /*| OVERLAY; */ }
//
// START minimap render processes
//
void mini_map_startup()
{
mm_stage2.bmap = mm_stage1.bmap; //render stage1 onto background of stage2
mm_stage2.target_map = mm_overlay; //render stage2 output to BMAP 'mm_overlay'
mini_map.bmap = mm_overlay2; //apply BMAP 'mm_overlay' as background of mini_map
//
wait(1); // //PAUSE to allow renderchain to initialise in correct order (it APPEARS)
set(mm_stage1, SHOW); set(mm_stage2, SHOW);
//
while(1)
{ if(player_ent!=NULL)
{
// keep mini-map aligned in top-right corner
mini_map.pos_x = screen_size.x - mini_map.size_x;
//
// move stage1(view) around to it follows the player
vec_set(mm_stage1.x, player_ent.x); mm_stage1.z = 1000;
}
wait(1);
//bmap_fill(mm_overlay, COLOR_BLACK, 100); // as per Heelx's suggestion... no change
bmap_process(mm_overlay2, mm_overlay, mtlTransp);
} }
//
//
//=========================================================================================
//
//
void mm_overlay_butt_startup() // FABRICATE an SAMPLE overlay-artwork for DEMO ONLY
{ wait(1); var x,y, xx,yy, tmp, fmt=bmap_lock(mm_overlay_butt,0);
var opaque = pixel_for_vec(COLOR_BLACK, 100, fmt);
var border = pixel_for_vec(COLOR_BLUE, 50, fmt);
var clear = pixel_for_vec(COLOR_WHITE, 0, fmt);
var center = mm_overlay_butt.width/2;
for(x=0; x<mm_overlay_butt.width; x++) for(y=0; y<mm_overlay_butt.height; y++)
{ pixel_to_bmap(mm_overlay_butt, x,y, opaque);
if (sqrt(pow(x-center,2)+pow(y-center,2))<(center-3))
{ pixel_to_bmap(mm_overlay_butt, x,y, clear); }
else if (sqrt(pow(x-center,2)+pow(y-center,2))<(center-0))
{ pixel_to_bmap(mm_overlay_butt, x,y, border); } }
bmap_unlock(mm_overlay_butt);
}
//
//
void main() // nothing in MAIN is important, it is just to create a DEMO environment.
{
video_mode = 7; wait(1); level_load(NULL); wait(1); sun_light=25;
vec_set(camera.x, vector(-100,-500,500)); vec_set(camera.pan, vector(75,-45,0));
draw_textmode("Times",0,32,100);
//--------------------------------------------------------------------------------------
//
you = ent_create(CUBE_MDL, vector(000,000,-100), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(51,51,2));
you = ent_create(CUBE_MDL, vector(400,000,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(1,51,10));
you = ent_create(CUBE_MDL, vector(000,400,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(51,1,10));
you = ent_create(CUBE_MDL, vector(-400,000,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(1,51,10));
you = ent_create(CUBE_MDL, vector(000,-400,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(51,1,10));
you = ent_create(CUBE_MDL, vector(175, 175,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(27,1,10));
you = ent_create(CUBE_MDL, vector(-175,-175,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(27,1,10));
you = ent_create(CUBE_MDL, vector(175,-175,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(1,27,10));
you = ent_create(CUBE_MDL, vector(-175,175,0), NULL); set(you, LIGHT);
vec_fill(you.blue, 15); vec_set(you.scale_x, vector(1,27,10));
//
// Create Player Entity
player_ent = ent_create(SPHERE_MDL, nullvector, NULL); set(player_ent, LIGHT);
vec_set(player_ent.blue, COLOR_GREEN); vec_fill(player_ent.scale_x, 2);
//
// Create Other Entities
ENTITY* blob[4];
blob[0] = ent_create(SPHERE_MDL, vector(250,250,0), NULL); set(blob[0], LIGHT);
blob[1] = ent_create(SPHERE_MDL, vector(-250,250,0), NULL); set(blob[1], LIGHT);
blob[2] = ent_create(SPHERE_MDL, vector(-250,-250,0), NULL);set(blob[2], LIGHT);
blob[3] = ent_create(SPHERE_MDL, vector(250,-250,0), NULL); set(blob[3], LIGHT);
//
//--------------------------------------------------------------------------------------
//
while(1)
{
//move entity about
player_ent.x += (key_d-key_a)*time_step*15; player_ent.x=clamp(player_ent.x,-375,375);
player_ent.y += (key_w-key_s)*time_step*15; player_ent.y=clamp(player_ent.y,-375,375);
//
//move blobs about randomly
int i; for(i=0; i<4; i++)
{ vec_set(blob[i].blue, COLOR_RED); vec_fill(blob[i].scale_x, 2.5+random(1));
blob[i].x += (random(10)-5)*time_step*5;
if((abs(blob[i].x)-250)>50) blob[i].x = sign(blob[i].x)*300;
if((abs(blob[i].x)-250)<-50) blob[i].x = sign(blob[i].x)*200;
blob[i].y += (random(10)-5)*time_step*5;
if((abs(blob[i].y)-250)>50) blob[i].y = sign(blob[i].y)*300;
if((abs(blob[i].y)-250)<-50) blob[i].y = sign(blob[i].y)*200; }
//
wait(1);
}
}