HP Prime for All

English  Русский 
Sinus Ranger games-app screenshot}}
Name Sinus Ranger
Description A 2D open world game which design is a bit similar to the well known game minecraft. You can explore an infinite world which can be flat or have hills, build with different blocks, dig the ground and shoot enemys.
Author David Traum

Source code (download):

Source code formatted by website engine

//By David Traum (dtraum.com) LOCAL LOCX, CO; LOCAL SW := GROBW_P(); LOCAL SH := GROBH_P(); LOCAL BACK := #CECEE7h; LOCAL EARTH := #320032; LOCAL GROUND := #316331h; LOCAL SAND := RGB(247, 231, 175); LOCAL DARKSAND := RGB(167, 131, 105); LOCAL PLAYER := RGB(255, 0, 255); LOCAL WHITE := RGB(255, 255, 255); LOCAL BLACK := RGB(0, 0, 0); LOCAL GREEN := RGB(0, 255, 0); LOCAL OUTLINE := RGB(10, 10, 10); LOCAL RED := RGB(255, 0, 0); LOCAL AIM := RED; LOCAL SUN_INNER := RGB(200, 200, 0), SUN_OUTER := RGB(150, 150, 0); LOCAL PX, PY, PVY, PS, HG, STATE; LOCAL CTY, CX, CY; LOCAL AX, AY, RAND, HP, BUFFER, BUFFER2, BUFFER3, BUFFER4; LOCAL SHX, SHY, SVX, SVY, EQP, WEATHER, RY, WETI; LOCAL EX, EY, EVX, ESX, ESY, ESVX, ESVY, EST; LOCAL ENM, WATER, LASTWATER, BIOME, BIOMEG, BIOMET, CITEM, BLL; RESET() BEGIN LOCX := 0; PX := SW*0.5; PY := 10; PVY := 0; PS := 10; STATE := 0; CTY := 0; CX := SW+40; CY := 40; AX := 0; AY := 0; RAND := RANDOM() * 0.01; HP := 100; SHX := 0; SHY := 0; EX := -400; EY := 30; EVX := 1; ESX := 0; EST := 0; LASTWATER := FALSE; CITEM := 0; BLL := 0; EQP := 0; WEATHER := 0; WETI := 0; END; PICKCOLOR() BEGIN RECT_P(G0, 0, 0, 50, SH, RGB(255, 0, 0)); RECT_P(G0, 50, 0, 100, SH, RGB(0, 255, 0)); RECT_P(G0, 100, 0, 150, SH, RGB(0, 0, 255)); RECT_P(G0, 150, 0, 200, SH, RGB(255, 255, 0)); RECT_P(G0, 200, 0, 250, SH, RGB(0, 255, 255)); RECT_P(G0, 250, 0, 300, SH, RGB(255, 0, 255)); RECT_P(G0, 300, 0, 350, SH, RGB(0, 0, 0)); TEXTOUT_P("Select Color", G0, 100, 20, 7, BLACK); WHILE 1 == 1 DO WAIT(-1); IF MOUSE(0) > 0 THEN RETURN GETPIX_P(MOUSE(0), MOUSE(1)); END; END; END; GRASS(LX, LY, GC) BEGIN RECT_P(GC, LX-5, LY-5, LX+5, LY+5, GROUND); FOR CO FROM LX-5 TO LX+5 DO LINE_P(GC, CO, LY-5, CO, LY - (RANDOM() * 5), EARTH); END; END; CACTUSBLOCK(LX, LY, GC) BEGIN RECT_P(G2, LX-5, LY-5, LX+5, LY+5, RGB(0, 150, 0)); FOR I FROM 0 TO 5 DO X := (LX-4) + (RANDOM() * 8); Y := (LY-4) + (RANDOM() * 8); RECT_P(G2, X, Y, X+1, Y+1, BLACK); END; END; CACTUS(LX, LY, GC) BEGIN CACTUSBLOCK(LX, LY, GC); CACTUSBLOCK(LX, LY-10, GC); CACTUSBLOCK(LX, LY-20, GC); //IF RANDOM() > 0.5 THEN //CACTUSBLOCK(LX, LY-30); //END; END; WOOD(LX, LY, GC) BEGIN RECT_P(GC, LX-5, LY-5, LX+5, LY+5, RGB(165, 42, 42)); END; ORE(LX, LY, CLR, GC) BEGIN RECT_P(GC, LX-5, LY-5, LX+5, LY+5, RGB(80, 80, 80)); FOR I FROM 0 TO 5 DO X := (LX-5) + (RANDOM() * 8); Y := (LY-5) + (RANDOM() * 8); RECT_P(GC, X, Y, X+1, Y+1, CLR); END; END; LEAVES(LX, LY, GC) BEGIN RECT_P(GC, LX-5, LY-5, LX+5, LY+5, SUN_OUTER); FOR I FROM 0 TO 15 DO PIXON_P(GC, (LX-5) + (RANDOM() * 10), (LY-5) + (RANDOM() * 10), SUN_INNER); END; END; TREE(LX, LY, GC) BEGIN WOOD(LX, LY, GC); WOOD(LX, LY-10, GC); WOOD(LX, LY-20, GC); WOOD(LX, LY-30, GC); WOOD(LX, LY-40, GC); LEAVES(LX, LY-50, GC); LEAVES(LX-10, LY-40, GC); LEAVES(LX+10, LY-40, GC); LEAVES(LX-10, LY-30, GC); LEAVES(LX-20, LY-30, GC); LEAVES(LX+10, LY-30, GC); LEAVES(LX+20, LY-30, GC); END; ENEMY(LX, LY, CIN, COUT) BEGIN RECT_P(G1, LX-PS, LY-PS, LX+PS, LY+PS, COUT, CIN); PIXON_P(G1, LX-3, LY-3, COUT); PIXON_P(G1, LX+3, LY-3, COUT); LINE_P(G1, LX-2, LY+3, LX+2, LY+3, COUT); RECT_P(G1, LX-PS, LY-5, LX-PS*3, LY+5, COUT, CIN); RECT_P(G1, LX+PS, LY-5, LX+PS*3, LY+5, COUT, CIN); END; DIG(LX, LY, RNG) BEGIN RECT_P(G2, LX-RNG, LY-RNG, LX+RNG, LY+RNG, BACK); END; ENEMYUPDATE() BEGIN IF EVX > 0 THEN IF EX < SW+100 THEN EX := EX+EVX; ELSE EVX := EVX*-1; EX := EX+EVX; END; ELSE IF EX > -100 THEN EX := EX+EVX; ELSE EVX := EVX*-1; EX := EX+EVX; END; END; IF EX > 0 AND EX < SW THEN EST := EST+1; IF EST > 250 - (ENM*100) AND ESX == 0 THEN ESX := EX; ESY := EY; ESVX := ((PX-LOCX) - EX) * 0.01; ESVY := (PY-EY) * 0.01; EST := 0; END; END; IF ESX > 0 THEN ESX := ESX+ESVX; ESY := ESY+ESVY; IF √(((PX-LOCX) - ESX)^2) + (PY-ESY)^2 < 40 THEN HP := HP-30; ESX := 0; ELSE IF GETPIX_P(G2, ESX, ESY)≠BACK THEN DIG(ESX, ESY, ENM*4); ESX := 0; END; END; END; ENEMY(EX, EY, WHITE, RED); END; CLOUD(LX, LY, TY, GC, COL) BEGIN CASE IF TY < 1 THEN RECT_P(GC, LX-10, LY-10, LX, LY, COL); RECT_P(GC, LX, LY, LX+40, LY+15, COL); RECT_P(GC, LX+10, LY-10, LX+30, LY+20, COL); END; IF TY > 1 AND TY < 2 THEN RECT_P(GC, LX-15, LY-15, LX, LY+5, COL); RECT_P(GC, LX, LY, LX+20, LY+10, COL); RECT_P(GC, LX-10, LY-15, LX, LY+25, COL); END; END; END; CLOUDUPDATE() BEGIN CX := CX-0.4; CLOUD(CX, CY, CTY, G1, WHITE); IF CX < -40 THEN CTY := RANDOM() * 2; CY := (RANDOM() * 40) + 20; CX := SW + (RANDOM() * 100) + 40; END; END; BLOCK(PX, PY, ID, GC) BEGIN CASE IF ID == 0 THEN GRASS(PX, PY, GC); END; IF ID == 1 THEN WOOD(PX, PY, GC); END; IF ID == 2 THEN CACTUSBLOCK(PX, PY, GC); END; IF ID == 3 THEN ORE(PX, PY, 0, GC); END; IF ID == 4 THEN ORE(PX, PY, RGB(180, 180, 220), GC); END; IF ID == 5 THEN ORE(PX, PY, RGB(255, 215, 0), GC); END; IF ID == 6 THEN LEAVES(PX, PY, GC); END; END; END; RECALC() BEGIN RECT_P(G2, BACK); //ARC_P(G2, SW-60, 60, 40, SUN_INNER); RECT_P(G0, 18, 38, SW-18, 52, BLACK); //TEXTOUT_P("Generating...", G0, 20, 15, 2, BLACK); BUFFER := 0; BUFFER2 := 40 + (RANDOM() * 190); BUFFER3 := 0; BUFFER4 := RANDOM() * 40; IF BLL > 3 THEN BIOME := RANDOM() * 1.5; BLL := 0; END; BLL := BLL+1; WATER := RANDOM() > 0.5; IF LASTWATER == TRUE THEN WATER := TRUE; END; IF BIOME > 1 AND BIOME < 2 THEN IF LASTWATER == TRUE THEN BIOME := 0.5; ELSE WATER := FALSE; END; END; CASE IF BIOME < 1 THEN BIOMEG := GROUND; BIOMET := EARTH; END; IF BIOME > 1 AND BIOME < 2 THEN BIOMEG := SAND; BIOMET := DARKSAND; END; END; FOR CO FROM 0 TO SW DO HG := SH - (SIN((LOCX+CO) * (0.010+RAND)) + 1.05) * 60; LINE_P(G2, CO, SH, CO, HG, BIOMEG); LINE_P(G2, CO, HG - (RANDOM() * 5), CO, HG + (RANDOM() * 10), BIOMET); RECT_P(G0, 20, 40, 20 + ((CO/SW) * (SW-40)), 50, GREEN); IF BUFFER > BUFFER2 AND HG < 200 THEN CASE IF BIOME < 1 THEN TREE(CO, HG, G2); END; IF BIOME > 1 AND BIOME < 2 THEN CACTUS(CO, HG, G2); END; END; BUFFER := 0; END; IF WATER == TRUE AND HG > 200 THEN LINE_P(G2, CO, 200, CO, HG, RGB(0, 0, 255)); END; IF BUFFER3 > BUFFER4 THEN IF RANDOM() > 0.5 THEN ORE(CO, SH - (RANDOM() * (SH-HG-20)), RGB(180, 180, 220), G2); ELSE ORE(CO, SH - (RANDOM() * (SH-HG-20)), RGB(255, 215, 0), G2); END; BUFFER3 := 0; BUFFER4 := RANDOM() * 40; END; BUFFER := BUFFER+1; BUFFER3 := BUFFER3+1; END; IF WATER == TRUE AND HG > 200 THEN LASTWATER := TRUE; ELSE LASTWATER := FALSE; END; END; RENDER() BEGIN BLIT_P(G1, G2); RECT_P(G1, SW-60, 20, SW-20, 60, SUN_OUTER, SUN_INNER); CLOUDUPDATE(); IF STATE≠0 AND ENM > 1 THEN ENEMYUPDATE(); END; RECT_P(G1, PX-PS-LOCX, PY-PS, PX+PS-LOCX, PY+PS + (PVY*2), OUTLINE, PLAYER); PIXON_P(G1, PX-3-LOCX, PY-3, OUTLINE); PIXON_P(G1, PX+3-LOCX, PY-3, OUTLINE); LINE_P(G1, PX-2-LOCX, PY+3, PX+2-LOCX, PY+3, OUTLINE); IF WEATHER == 1 THEN BLIT_P(G1, 0, 0, SW, SH, G3, 0, RY, SW, RY+SH, 0); RY := RY-2; IF RY < 0 THEN RY := SH*9; END; END; IF STATE == 0 THEN TEXTOUT_P("SinusRanger", G1, 100, 50, 7, OUTLINE); TEXTOUT_P("Press ENTER to start!", G1, 100, 90, 2, OUTLINE); TEXTOUT_P("© David Traum (david-traum.com)", G1, 5, SH-15, 1, WHITE); ELSE //TEXTOUT_P(PX+"/"+PY+"/"+LOCX, G1, 5, 5, 1, BLACK); //RECT_P(G1, 50, 200, 250, 230, WHITE); END; IF SHX > 0 THEN RECT_P(G1, SHX-2, SHY-2, SHX+2, SHY+2, BLACK); END; IF ESX > 0 THEN RECT_P(G1, ESX-2, ESY-2, ESX+2, ESY+2, RED); END; IF AX > 0 THEN LINE_P(G1, AX-15, AY-15, AX-5, AY-5, AIM); LINE_P(G1, AX+15, AY+15, AX+5, AY+5, AIM); LINE_P(G1, AX+15, AY-15, AX+5, AY-5, AIM); LINE_P(G1, AX-15, AY+15, AX-5, AY+5, AIM); END; RECT_P(G1, 0, 0, SW, 15, OUTLINE); LINE_P(G1, 0, 15, SW, 15, WHITE); TEXTOUT_P(HP+"% SinusRanger @ HP-Prime © David Traum", G1, 5, 2, 1, WHITE); BLOCK(45, 5, EQP, G1); BLIT_P(G0, G1); END; UPDATE() BEGIN WETI := WETI+1; IF WETI > 2000 THEN WEATHER := WEATHER+1; IF WEATHER > 1 THEN WEATHER := 0; END; CASE IF WEATHER == 1 THEN RY := SH*10; END; END; WETI := 0; END; PY := PY+PVY; IF GETPIX_P(G2, PX-LOCX, PY+PS) == BACK THEN PVY := PVY+0.1; ELSE IF PVY > 3.7 THEN HP := HP - (PVY-3.5); END; PVY := 0; RETURN true; END; IF GETPIX_P(G2, PX-LOCX, PY)≠BACK THEN PY := PY+10; END; RETURN false; END; UPDATESHOT() BEGIN IF SHX > 0 THEN SVY := SVY+0.03; SHX := SHX+SVX; SHY := SHY+SVY; IF GETPIX_P(G2, SHX, SHY)≠BACK THEN DIG(SHX, SHY, 5); SHX := 0; END; IF √((EX-SHX)^2) + ((EY-SHY)^2) < 40 THEN EX := -1000; ESX := 0; SHX := 0; END; END; END; MOVE(DR) BEGIN IF STATE≠1 THEN RETURN; END; BUFFER := GETPIX_P(G2, (PX-LOCX) + DR, PY+PS); IF BUFFER≠BACK THEN IF BUFFER≠#FFh THEN PY := PY-2; ELSE PX := PX-DR*0.5; RETURN; END; ELSE PX := PX-DR; END; END; REL(KC) BEGIN WHILE ISKEYDOWN(KC) DO WAIT(0.01); END; END; EXPORT SinusRanger() BEGIN PRINT(); PRINT("Preparing memory..."); DIMGROB_P(G1, SW, SH); DIMGROB_P(G2, SW, SH); DIMGROB_P(G3, SW, SH*10); RESET(); PRINT("Generating resources..."); RECT_P(G3, 0, 0, SW, SH*10, RGB(0, 0, 0)); FOR BUFFER FROM 0 TO 5000 DO PIXON_P(G3, RANDOM() * SW, RANDOM() * SH*10, RGB(0, 0, 255)); END; CHOOSE(BUFFER, "Menu", {"Run Game", "How to play", "Clear Memory"}); IF BUFFER == 2 THEN PRINT(); PRINT("SinusRanger - How to play"); PRINT(""); PRINT(" Move: Wheel Left/Right"); PRINT(" Dive: Wheel Up/Down"); PRINT(" Jump: Enter"); PRINT(" Switch Build/Destroy: +"); PRINT(" Build/Destroy: _"); PRINT(" Shoot: ."); PRINT(" Aim: Touchscreen"); PRINT(" Reset: Delete"); PRINT(" Change Block: , "); PRINT(" New Chunk: Plot"); PRINT(""); PRINT("Version: 1.2"); RETURN; END; IF BUFFER == 3 THEN MSGBOX("Restart reqired"); DIMGROB_P(G9, 999999, 999999); RETURN; END; CHOOSE(ENM, "Difficulty", {"Peaceful", "Normal", "Hard"}); PLAYER := PICKCOLOR(); RECALC(); WHILE NOT ISKEYDOWN(4) DO RENDER(); UPDATE(); UPDATESHOT(); IF ISKEYDOWN(8) THEN MOVE(-2); END; IF ISKEYDOWN(7) THEN MOVE(2); END; IF ISKEYDOWN(30) THEN IF GETPIX_P(G2, PX-LOCX, PY+PS)≠BACK THEN STATE := 1; PVY := -3.5; END; END; IF PX > SW+LOCX THEN LOCX := LOCX + (SW-30); RECALC(); END; IF ISKEYDOWN(29) THEN EQP := EQP+1; IF EQP > 6 THEN EQP := 0; END; REL(29); END; IF ISKEYDOWN(6) THEN RECALC(); END; IF ISKEYDOWN(49) THEN IF AIM == GREEN THEN BLOCK(AX, AY, EQP, G2); ELSE DIG(AX, AY, 5); END; END; IF ISKEYDOWN(50) THEN IF AIM == GREEN THEN AIM := RED; ELSE AIM := GREEN; END; REL(50); END; IF PX-LOCX < 0 THEN LOCX := LOCX - (SW-30); RECALC(); END; IF MOUSE(0) > 0 THEN AX := MOUSE(0); AY := MOUSE(1); END; IF ISKEYDOWN(19) THEN RESET(); RECALC(); END; IF ISKEYDOWN(33) THEN AY := AY-10; REL(33); END; IF ISKEYDOWN(37) THEN AX := AX-10; REL(37); END; IF ISKEYDOWN(39) THEN AX := AX+10; REL(39); END; IF ISKEYDOWN(43) THEN AY := AY+10; REL(43); END; IF ISKEYDOWN(48) AND AX > 0 AND SHX == 0 THEN SHX := PX-LOCX; SHY := PY; SVX := (AX - (PX-LOCX)) * 0.02; SVY := (AY-PY) * 0.02; END; IF HP < 100 THEN HP := HP+0.01; END; IF HP < 0 THEN RESET(); RECALC(); END; IF ISKEYDOWN(12) THEN IF GETPIX_P(G2, (PX-LOCX), PY+PS+2) == #FFh THEN PY := PY+1; END; END; IF ISKEYDOWN(2) THEN IF GETPIX_P(G2, (PX-LOCX), PY+PS+1) == #FFh THEN PY := PY-1; END; END; END; END;

Comments