Posted By: Pappenheimer
snowing - 11/24/10 11:37
Here is a simple snowing script.
It is a demo with a simple black box getting more and more covered with white dots.
snowing demo
The dots are very small (it depends on the size of the skin), so I want to add additional painting around the dots, but when I use the following part, it shows weird effects and eventually crashes. Maybe, someone has an idea to solve this issue?
Thanks in advance.
This is the whole script.
It is a demo with a simple black box getting more and more covered with white dots.
snowing demo
The dots are very small (it depends on the size of the skin), so I want to add additional painting around the dots, but when I use the following part, it shows weird effects and eventually crashes. Maybe, someone has an idea to solve this issue?
Thanks in advance.
Code:
while(coords_cur_x <= (coords_x + coords_area)) { 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; } }
This is the whole script.
Code:
#include <litec.h> #include <d3d9.h> #include <acknex.h> #include <default.c> #define PRAGMA_ZERO BMAP* canvas; var format; var pixel; var coords_x; var coords_y; 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()//needs an own variable to prevent it from colliding with similar tarrain actions { set(my, POLYGON); my.emask |= ENABLE_SHOOT; my.event = snowEvent; while(1) { // if(mouse_left) // { // while(mouse_left){wait(1);} // coords_x = random(10); // coords_y = random(10); var coords_area = 1; var coords_cur_x = coords_x - coords_area; var coords_cur_y = coords_y - coords_area; 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)) // { // 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(); }