; hsp3dish + fullscreen test. move stars. ; ; Windows10 x64 22H2 + HSP 3.7beta7 ; 2023/11/01 by mieki256 ; Licence : CC0 / Public Domain #include "hsp3dish.as" #include "d3m.hsp" #packopt name "fullscreen_zoom" #packopt type 0 #define TEX_FILE "star.png" ; #define TEX_FILE "star2.png" #pack TEX_FILE #define KB_ESC $000080 #define FRAMERATE 60 fps_display_enable = 1 ; get desktop size dispw = ginfo_dispx disph = ginfo_dispy ; initialize window without frame ; bgscr WindowID, width, height, mode, x, y bgscr 0, dispw, disph, 0, 0, 0 ; load image imgid = 3 celload TEX_FILE, imgid ; split image. set orign celdiv imgid, 512, 512, 256, 256 ; Set the buffer to draw from. Windows ID 0 gsel 0, 1 ; Set screen clear color to be performed when redraw 0 is called. ; 0 or 1, color ($000000 - $ffffff) ; setcls CLSMODE_SOLID, $4080c0 setcls CLSMODE_SOLID, $000000 font "Tahoma", 24, 1 randomize star_size = 0.75 dist = 150.0 ; screen distabce area_z = 5000 zmax = double(area_z) + dist ; rnd() only accepts 1 to 32768. ; adjust the value to stay within that range. area_m = 4.0 area_w = int((double(dispw) * zmax) / dist / area_m) area_h = int((double(disph) * zmax) / dist / area_m) objmax = 512 ; initialize stars work ddim posx, objmax ; position x ddim posy, objmax ; position y ddim posz, objmax ; position z dim px, objmax ; display position x dim py, objmax ; display position y ddim scalev, objmax ; scale dim alpha, obj_max ; alpha value repeat objmax gosub *get_newpos_xy posx(cnt) = nx posy(cnt) = ny posz(cnt) = double(rnd(area_z)) + dist px(cnt) = 0 py(cnt) = 0 scale(cnt) = 0.0 alpha(cnt) = 0 loop time_start = d3timer() endfg = 0 ; ---------------------------------------- *mainloop while endfg == 0 tm = d3timer() - time_start fps = d3getfps() ; get FPS ; ESC key to exit stick key, 0 if key & KB_ESC : endfg = 1 ; move stars spd = 40.0 repeat objmax posz(cnt) -= spd if posz(cnt) < (dist / 2.0) { posz(cnt) += zmax gosub *get_newpos_xy posx(cnt) = nx posy(cnt) = ny } ; get display x, y position px(cnt) = int(posx(cnt) * dist / posz(cnt)) + (dispw / 2) py(cnt) = int(posy(cnt) * dist / posz(cnt)) + (disph / 2) scalev(cnt) = star_size * dist / posz(cnt) size = int(512.0 * scalev(cnt)) x0 = px(cnt) - (size / 2) y0 = py(cnt) - (size / 2) x1 = px(cnt) + (size / 2) y1 = py(cnt) + (size / 2) if x1 < 0 or x0 > dispw or y1 < 0 or y0 > disph { ; out of display area. position reset posz(cnt) += zmax gosub *get_newpos_xy posx(cnt) = nx posy(cnt) = ny px(cnt) = int(posx(cnt) * dist / posz(cnt)) + (dispw / 2) py(cnt) = int(posy(cnt) * dist / posz(cnt)) + (disph / 2) scalev(cnt) = star_size * dist / posz(cnt) } ; get alpha value az = double(area_z) * 0.7 if posz(cnt) < az { alpha(cnt) = 255 } else { ; fade in z = posz(cnt) if z > zmax : z = zmax v0 = z - az v1 = zmax - az alpha(cnt) = int(255.0 - (255.0 * v0 / v1)) } loop ; ---------------------------------------- ; draw start redraw 0 ; clear screen ; color 64, 128, 192 ; boxf ; draw stars repeat objmax rot = 0.0 idx = 0 ; draw image by celput gmode gmode_add, 512, 512, alpha(cnt) pos px(cnt), py(cnt) rot = 0.0 idx = 0 celput imgid, idx, scalev(cnt), scalev(cnt), rot loop ; draw text if fps_display_enable { gmode gmode_rgb0 color 255, 255, 255 pos 10, 10 mes strf("[%dx%d] %d/%dFPS", dispw, disph, fps, FRAMERATE) } ; draw end. screen refersh redraw 1 await (1000 / FRAMERATE) ; await 12 wend *jobend: end *get_newpos_xy nx = double(rnd(area_w) - (area_w / 2)) * area_m ny = double(rnd(area_h) - (area_h / 2)) * area_m return