#include <acknex.h>
#include <default.c>
ENTITY* player_ent;
BMAP* mm_overlay_butt = "#256x256x32"; //normally "mm_overlay_art.TGA"
BMAP* bmpMinimap = "#256x256x32";
MATERIAL *mtlMinimap =
{
skin1 = mm_overlay_butt;
effect = "
const float4x4 matWorldViewProj;
float4 vecColor, vecSunDir, vecAmbient;
texture mtlSkin1;
sampler MaskSampler = sampler_state { Texture = <mtlSkin1>; };
void VS (
in float4 inPos: POSITION,
in float3 inNormal : NORMAL,
out float4 outPos: POSITION,
out float2 outScreen: TEXCOORD0,
out float3 outNormal: TEXCOORD1 )
{
outPos = mul( inPos, matWorldViewProj );
outScreen = ( outPos.xy * 0.5f ) - 0.5f;
outNormal = inNormal;
}
void PS (
in float2 inScreen: TEXCOORD0,
in float3 inNormal: TEXCOORD1,
out float4 Color0 : COLOR0 )
{
float fDiffuse = saturate ( dot ( -vecSunDir.xyz, inNormal ) ) + vecAmbient.w;
float Mask = tex2D ( MaskSampler, inScreen ).r;
Color0.rgb = vecColor.rgb * fDiffuse;
Color0.a = Mask;
}
technique tech
{
pass p0
{
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();
}
}
";
}
VIEW* mm_stage1 = { bmap=bmpMinimap; material=mtlMinimap; pan=90; tilt=-90; arc=115; flags=ISOMETRIC; }
PANEL* mini_map = { bmap=bmpMinimap; }
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(vector(255,255,255), 100, fmt);
var border = pixel_for_vec(vector(128,128,128), 100, fmt);
var clear = pixel_for_vec(vector(0,0,0), 100, 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++)
{ if (sqrt(pow(x-center,2)+pow(y-center,2))>center)
{ pixel_to_bmap(mm_overlay_butt, x,y, clear); }
else if (sqrt(pow(x-center,2)+pow(y-center,2))>(center-6))
{ pixel_to_bmap(mm_overlay_butt, x,y, border); }
else { pixel_to_bmap(mm_overlay_butt, x,y, opaque); }
}
bmap_unlock(mm_overlay_butt);
}
//
// START minimap render processes
//
//
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, 128); 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, 128); 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, 128); 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, 128); 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, 128); 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, 128); 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, 128); 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, 128); 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, 128); 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, vector(0,128,0)); 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);
//
//--------------------------------------------------------------------------------------
//
camera.ambient = -100;
wait(1); // //PAUSE to allow renderchain to initialise in correct order (it APPEARS)
set(mm_stage1, SHOW);
set(mini_map, SHOW);
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, vector(0,0,128)); 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; }
//
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);
}
}