#include <litec.h>
#include <d3d9.h>
#include <acknex.h>
#include <default.c>
#define PRAGMA_ZERO
BMAP* canvas;
var format;
var pixel;
var coords_x = 0;
var coords_y = 0;
function snowing()
{
while(1)
{
c_trace(vector(random(30)-15,random(30)-15, 100), vector(random(30)-15,random(30)-15, -100), IGNORE_PASSABLE | IGNORE_ME | SCAN_TEXTURE | ACTIVATE_SHOOT);
wait(1);
}
}
function snowEvent()
{
coords_x = hit.u1;
coords_y = hit.v1;
}
action get_snow()
{
var coords_area = 4;
var coords_cur_x = coords_x - coords_area;
var coords_cur_y = coords_y - coords_area;
set(my, POLYGON);
my.emask |= ENABLE_SHOOT;
my.event = snowEvent;
while(1)
{
coords_cur_x = coords_x - coords_area*0.5;
coords_cur_y = coords_y - coords_area*0.5;
canvas = bmap_for_entity(my, 0); //1 is the number of the skin
format = bmap_lock(canvas, 0); // lock the canvas bitmap
pixel = pixel_for_vec(vector(255,255,255), 100, format);
pixel_to_bmap(canvas, coords_x, coords_y, pixel); // now write the pixel at the coords_x, coords_y position
while(coords_cur_x <= (coords_x + coords_area))
{
if((coords_cur_x < canvas.width ) && (coords_cur_y < canvas.height))
{
if((coords_cur_x > 0) && (coords_cur_y > 0))
{
pixel_to_bmap(canvas,coords_cur_x, coords_cur_y,pixel);
}
}
coords_cur_y += 1;
if(coords_cur_y > (coords_y + coords_area))
{
coords_cur_x += 1;
coords_cur_y = coords_y - coords_area;
}
}
bmap_unlock(canvas); // unlock the bitmap now
bmap_to_mipmap(canvas);
wait(1);
}
}
function main()
{
level_load(NULL);
camera.z = 30;
camera.tilt = -90;
ent_create("cube_black.mdl", vector(0,0,0), get_snow);
snowing();
}