#define HSPTV #ifdef HSPTV #runtime "hsptv" #regcmd 18 #cmd hsptv_send $00 #define global RANKING_ENTRIES 30 #else #packopt name "reverse" #packopt hide 1 #define global RANKING_ENTRIES 100 #define global HSPTV_NAME "guest" #module hsptv_emu #define HSPTVDAT "hsptvdat.txt" // options は無視 #define global hsptv_send(%1, %2, %3 = "", %4 = 0) hsptv_send@hsptv_emu %1, %2, %3, %4 #deffunc hsptv_send@hsptv_emu var note, int param, str comment, int options if param < 0 { note = buf return } notesel buf index = notemax repeat notemax / 3 i = cnt * 3 noteget score, i if param > score { index = i break } loop noteadd comment, index noteadd HSPTV_NAME, index noteadd str(param), index if notemax / 3 > RANKING_ENTRIES { repeat 3 notedel notemax - 1 loop } notesave HSPTVDAT noteunsel note = buf return #global notesel buf@hsptv_emu exist HSPTVDAT@hsptv_emu if strsize > 0 { noteload HSPTVDAT@hsptv_emu } noteunsel dialog "フルスクリーンで起動しますか? [y/n]", 2 if stat == 6 { chgdisp 1, 640, 480 bgscr 1, 640, 480 gsel 1, 2 mouse -1 } else { gsel 0, 1 } #endif #uselib "user32" #func ClipCursor "ClipCursor" int #ifndef HSPTV # func GetClientRect "GetClientRect" int, var # func ClientToScreen "ClientToScreen" int, var #endif #module #define global rand _ #define global randn o #define global sincos e #defcfunc rand return (1.0 / 32768) * rnd(32768) #defcfunc randn double n return rand() * n /* #deffunc sincos double r sin_@ = sin(r) cos_@ = cos(r) return */ #global ZERO = 0.0 M1 = -1 FONT_NAME = "Tahoma" #const PI 3.14159265 #const PI2 (PI * 2) #enum STATE_TITLE = 0 #enum STATE_TITLE_OUT #enum STATE_RANKING #enum STATE_RANKING_OUT #enum STATE_GAME #enum STATE_GAMEOVER #enum STATE_GAMEOVER_OUT #enum OBJECT_TYPE = 0 #enum OBJECT_PX #enum OBJECT_PY #enum OBJECT_VX #enum OBJECT_VY #enum OBJECT_SIZE #enum OBJECT_ELEMENTS #const MAX_OBJECTS 1024 #define otype object notesel rank hsptv_send rank, -1 gosub *clip mouse -1 onexit *close repeat await 20 redraw 0 hsvcolor : boxf stick in px = 640 - mousex py = 480 - mousey if state >= STATE_GAME { level = (frames * 2 + score) / 1000 + rate / 10 if state == STATE_GAME & frames \ limit(10 - level / 5, 3, 7) == 0 { _otype = 1.0 + (randn(1000) >= limitf(300 + level, 300, 400)) _opx = randn(640) _opy = randn(480) _osize = randn(32 + rnd(12)) + 20 i = rnd(2) v = (randn(0.2 * limit(level / 3, 0, 30) + 8) + 1) * (1 - i * 2) / 2 _ovx = ZERO _ovy = ZERO os = _osize * 2 if rnd(2) { _opx = ZERO + i * (os + 640) - _osize _ovx = v } else { _opy = ZERO + i * (os + 480) - _osize _ovy = v } i = free(ptr) using(ptr) = i ptr++ objects(0, i) = _otype, _opx, _opy, _ovx, _ovy, _osize } alpha = 1 if state == STATE_GAMEOVER_OUT { alpha = (32.0 - frames) / 32 } repeat ptr dup cur_id, using(cnt) dup object, objects(0, cur_id) gosub *dup_object type = 0 + otype //if type { opx += ovx opy += ovy if abs(opx - 320) > 320 + osize | abs(opy - 240) > 240 + osize { *@ ptr-- free(ptr) = cur_id cur_id = using(ptr) } else : if state = STATE_GAME & abs(opx - px) < osize / 2 & abs(opy - py) < osize / 2 { if type - 1 { rate++ score += rate * 500 / osize } else { state = STATE_GAMEOVER frames = 0 } goto *@b } color 255, 64, 64 if type - 1 { hsvcolor , , 255 } gmode 5, osize, osize, alpha * 192 grect opx, opy os = osize * 0.7 gmode 6, os, os, alpha * 32 grect (opx - 320) * 0.95 + 320, (opy - 240) * 0.95 + 240 //boxf opx - 8, opy - 8, opx + 8, opy + 8 //} loop i = score - vscore if i > 50 { vscore += i / 10 } else : if i > 10 { vscore += limit(rate / 3, 3, 50) } else : if i { vscore += frames \ 2 } else { rate = 1 } x = 630 hsvcolor , , alpha * 255 if rate >= 3 | rate_vy != 608 { if i >= 10 { rate_vy = limit(rate_vy - 16, 472, 608) } else { rate_vy = limit(rate_vy + 8, 0, 608) } x = 632 s = "." + (rate \ 2 * 5) font FONT_NAME, 48 + limit(1.5 * rate, 0, 48) pos 640 : mes s x -= ginfo_mesx pos x, rate_vy - ginfo_mesy mes s s = "x" + (rate / 2) font FONT_NAME, 64 + limit(rate * 2, 0, 64) pos 640 : mes s pos x - ginfo_mesx, rate_vy - ginfo_mesy mes s } font FONT_NAME, 24 + limit(i, 0, 24) pos 640 : mes vscore i = limit(80 - frames, 0, 80) pos 630 - ginfo_mesx, 8 - i * i * (state == STATE_GAME) mes vscore if frames <= 64 & state == STATE_GAME { if frames > 46 { i = frames - 46 } else { i = limit(16 - frames, 0, 16) } pos 8 - i * i * 4 * (state == STATE_GAME), 8 hsvcolor , , 255 font FONT_NAME, 96 mes "start" } if state >= STATE_GAMEOVER { if state == STATE_GAMEOVER { i = limit(16 - frames, 0, 16) if in & 256 { ClipCursor mouse hsptv_send rank, score gosub *clip mouse -1 state = STATE_GAMEOVER_OUT frames = 0 } } else { i = frames if frames == 32 { state = STATE_RANKING frames = 0 } } pos 8 - i * i, 8 font FONT_NAME, 96 mes "game over" } } else : if state >= STATE_RANKING { y = 128 //active = limit((py - y) / 8, 1, notemax / 3) if state == STATE_RANKING_OUT { i = frames if frames == 16 { state = STATE_TITLE frames = 0 } } else { i = limit(16 - frames, 0, 16) if in & 256 { state = STATE_RANKING_OUT frames = 0 } } v = 255 - i * 15 font FONT_NAME, 40 items = notemax / 3 #const n 8 #const n_1 (n - 1) #const mm (RANKING_ENTRIES - n_1) m = limit(items - n_1, 0, mm) #const scroll_area (480 - 164) scroll = limit(40 * (py - 128) / (scroll_area / (m + 1)), 0, m * 40) #undef n #undef n_1 #undef mm #undef scroll_area #ifdef HSPTV #const n 3 SCROLL_COND = 50, 10, 0 SCROLL_SPEED = 13, 3, 1 #else #const n 4 SCROLL_COND = 100, 50, 10, 0 SCROLL_SPEED = 17, 13, 3, 1 #endif repeat n dup scc, SCROLL_COND(cnt) dup scs, SCROLL_SPEED(cnt) if scroll + scc > vscroll { vscroll += scs } if scroll - scc < vscroll { vscroll -= scs } loop #undef n hsvcolor , , v repeat items j = cnt * 3 noteget rscore, j noteget rname, j + 1 y = cnt * 40 + 128 - vscroll pos 48 - i * i, y mes strf("%02d ", cnt + 1) + rname pos 640 : mes rscore pos 596 + i * i - ginfo_mesx, y mes rscore loop hsvcolor , , 255 y = 0 repeat 64 gmode 6, 640, 2, 256 - cnt * 4 grect 320, cnt * 2, , , 4 grect 320, 480 - cnt loop hsvcolor , , v pos 8 - i * i * 4, 8 font FONT_NAME, 96 mes "ranking" } else { y = 280 if state { i = frames if frames == 16 { score = 0 vscore = 0 rate = 1 rate_vy = 544 dimtype objects, 3, OBJECT_ELEMENTS, MAX_OBJECTS dim free, MAX_OBJECTS dim using, MAX_OBJECTS foreach free free(cnt) = cnt loop ptr = 0 if active { if active == 2 { goto *close } state = STATE_RANKING } else { mouse -1 mouse rc(0) + 320, rc(1) + 240 state = STATE_GAME } frames = 0 } } else { active = (py - y) / 48 i = limit(16 - frames, 0, 16) if in & 256 { if active >= 0 & active <= 2 { state = STATE_TITLE_OUT frames = 0 } } } v = 255 - i * 15 hsvcolor , , v pos 8 - i * i * 4, 8 font FONT_NAME, 96 mes "reverse" font FONT_NAME, 48 //pos 171, 300 //mes "click to start" STRINGS = "start", "ranking", "quit" repeat 3 mx(cnt) = limit(mx(cnt) + 8 * (cnt == active) - 4, 0, 32) pos 420 - mx(cnt) + i * i, y hsvcolor , , v * (mx(cnt) * 4 + 127) / 255 mes STRINGS(cnt) y += 48 loop } if state < STATE_GAMEOVER { ship_x = 10, 16, 0 ship_y = 16, 10, 0 color repeat 2 i = cnt repeat 4 x = px - i - cnt \ 2 y = py - i - cnt / 2 pos x, y repeat 3 line x + ship_x(cnt), y + ship_y(cnt) loop loop hsvcolor , , 255 loop } redraw frames++ getkey i, 27 if i : goto *close loop *clip #ifdef HSPTV rc = ginfo_wx1, ginfo_wy1, ginfo_wx2, ginfo_wy2 #else dim rc, 4 GetClientRect hwnd, rc ClientToScreen hwnd, rc ClientToScreen hwnd, rc(2) #endif ClipCursor varptr(rc) return *close ClipCursor mouse end *dup_object // dup otype, object(OBJECT_TYPE) dup opx, object(OBJECT_PX) dup opy, object(OBJECT_PY) dup ovx, object(OBJECT_VX) dup ovy, object(OBJECT_VY) dup osize, object(OBJECT_SIZE) return