HP Prime для всех

English  Русский 
Lights Out games-app screenshot}}
Название Lights Out
Описание Game where you must turn out all the lights.
Автор Ariel Palazzesi

Исходный код (скачать):

Исходный код отформатирован программными средствами сайта

Строки с ICON ресурсами были обрезаны.

EXPORT lightsout3() BEGIN local XX, YY, AA, M; local XX1, YY1, NIVEL, FINAL, SUMA, MOVI; local xmouse, ymouse, matriz; PRINT(); NIVEL := 5; CHOOSE(M, "Board Size", "4x4", "5x5", "6x6"); IF M <> 0 THEN NIVEL := M+3; END; CHOOSE(M, "Game mode", "Random", "All On"); matriz := [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1,… IF M == 1 THEN FOR XX FROM 1 TO NIVEL DO FOR YY FROM 1 TO NIVEL DO IF RANDOM(1) > 0.5 THEN matriz[XX, YY] := 1; ELSE matriz[XX, YY] := 0; END; END; END; END; DIMGROB_P(G1, 320, 240); RECT(); DIMGROB_P(G2, 1, 18, {#D200F200F300F4:64, #AE00AF00AF00D0:64, #6800680068008C:64, #68006800680068:64, #680068:64}); XX := (160-16*NIVEL); YY := (160+16*NIVEL); FOR AA FROM XX TO YY DO BLIT_P(G2, AA, 22); END; DIMGROB_P(G2, 64, 18, {#F400F400F400F4:64, #F400F400F400F4:64, #F400F400F400F4:64, #F400F400F400F4:64, #F400F400F400F4:6BLIT_P(G2, 128, 22); DIMGROB_P(G2, 32, 32, {#B02020001400B02:64, #3F2F3F2F3F2F3F2F:64, #3F2F3F2F3F2F3F2F:64, #3F2F3F2F3F2F3F2F:64, #3F2F3F2F3DIMGROB_P(G3, 32, 32, {#8C00680025008C:64, #F300F400F300F3:64, #F300F300F400F3:64, #F300F400F300F3:64, #F300F300F400F3:6FOR XX FROM 1 TO NIVEL DO FOR YY FROM 1 TO NIVEL DO IF matriz[XX, YY] == 1 THEN BLIT_P(G2, (XX-1) * 32 + (160-16*NIVEL), (YY-1) * 32+40); ELSE BLIT_P(G3, (XX-1) * 32 + (160-16*NIVEL), (YY-1) * 32+40); END; END; END; TEXTOUT_P("MOVES: ", 0, 0); FINAL := 0; MOVI := 0; WHILE FINAL == 0 DO L0 := WAIT(-1); IF SIZE(L0) > 1 THEN IF L0(1) == #3d THEN xmouse := L0(2); ymouse := L0(3); IF xmouse > (160-16*NIVEL) AND xmouse < (160+16*NIVEL) AND ymouse > 40 AND ymouse < (40+NIVEL*32) THEN XX1 := IP((xmouse - (160-16*NIVEL)) /32); YY1 := IP((ymouse - 40) /32); MOVI := MOVI + 1; RECT_P(G0, 0, 0, 120, 20); TEXTOUT_P("MOVES: ", 0, 0); TEXTOUT_P(MOVI, 80, 0); IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; IF XX1 > 0 THEN XX1 := XX1 - 1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; XX1 := XX1 + 1; ELSE XX1 := NIVEL-1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; XX1 := 0; END; IF XX1 < (NIVEL-1) THEN XX1 := XX1 + 1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; XX1 := XX1 - 1; ELSE XX1 := 0; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; XX1 := NIVEL-1; END; IF YY1 < (NIVEL-1) THEN YY1 := YY1 + 1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; YY1 := YY1 - 1; ELSE YY1 := 0; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; YY1 := NIVEL-1; END; IF YY1 > 0 THEN YY1 := YY1 - 1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; YY1 := YY1 + 1; ELSE YY1 := NIVEL-1; IF matriz[YY1+1, XX1+1] == 1 THEN BLIT_P(G3, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 0; ELSE BLIT_P(G2, XX1*32 + (160-16*NIVEL), YY1*32+40); matriz[YY1+1, XX1+1] := 1; END; YY1 := 0; END; END; END; END; SUMA := 0; FOR XX FROM 1 TO NIVEL DO FOR YY FROM 1 TO NIVEL DO SUMA := SUMA + matriz[XX, YY]; END; END; IF SUMA == 0 THEN MSGBOX("Solved in "+MOVI+" moves!"); FINAL := 1; END; END; END;

Комментарии