Snow Effect by Icy_Blue10th Oct 2003 8:16
|
---|
Summary simple snow effect, move camera around object and make Matrix for battle filed. Description simple snow effect, move camera around object and make Matrix for battle filed. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` Project: Snow Effect ` Program: Icy_Blue [Thailand] ` Created: 10/10/2003 00:00:00 `init sync on : sync rate 30 : hide mouse : autocam off : randomize timer() `set window on color light 0, rgb(255, 255, 255) `create snow type type TSnow g as float `Speed x as float `x position y as float `y position z as float `z position endtype #constant max_snow = 50 dim snow(max_snow) as TSnow `create snow for i = 1 to max_snow make object sphere i, 5 color object i, rgb(255, 255, 255) set object light i, 0 snow(i).y = 0 next i `create matrix make matrix 1, 1000, 1000, 20, 20 position matrix 1, -500, 0, -500 randomize matrix 1, 90 for z = 5 to 15 for x = 5 to 15 set matrix height 1, x, z, rnd(5) * sign() next x next z update matrix 1 `camera position cp as float cp = 0 `main loop repeat `move snow for i = 1 to max_snow snow(i).y = snow(i).y - (snow(i).g / 6) if snow(i).y <= 0 then new_snow(i) position object i, snow(i).x + (sin(snow(i).y * 3) * 10), snow(i).y, snow(i).z + (sin(snow(i).y * 3) * 10) next i `move camera `camera position position camera sin(cp) * 600, 300, cos(cp) * 400 point camera 0, 0, 0 `camera speed cp = WrapValue(cp + 0.03) `show FPS and message text 10, 10, "FPS : " + str$(screen fps()) text 10, 20, "ESC to exit" `update screen sync until escapekey() `function for create +1 or -1 function sign() x = int(rnd(1))-1 if x = 0 then x = 1 endfunction x `function for calculate new snow's position function new_snow(no) snow(no).g = rnd(6) + 3 snow(no).x = rnd(300) * sign() snow(no).y = rnd(300) + 300 snow(no).z = rnd(200) * sign() endfunction |