Классический пинг понг выполненный в стиле монохромных дисплеев. Без использования файлов.
Исходный код
Код:#fullscreen(true) #orientation(@portrait) 'colors dim color_background = color(255,180,225,180) dim color_element = color(255,40,50,40) setuiparam(@consolebackground,color_element) setuiparam(@consoletext,color_background) sleep(100) printline("This game created in Pocket Basic for android") sleep(500) printline("loading") sleep(2000) 'canvas setview(@canvas) dim acw = 60 dim ach = toint(acw * (@height / @width)) initcanvas(acw,ach,5,true) 'data dim scorestring dim fieldh = toint(ach*0.85) dim ballx,bally dim ballxv,ballyv dim boardplayer, boardcpu dim scoreplayer, scorecpu dim winner dim winnerstrings = arraycreate2("Player win","Cpu win") goto("splash") #mark("start") winner=0 ballx = random(10,acw-10) bally = random(10,fieldh-10) ballxv = 2-random(0,4) ballyv = 2-random(0,4) if ballyv=0 then ballyv=1 endif boardplayer = toint(acw/2) boardcpu = toint(acw/2) scoreplayer = 0 scorecpu = 0 scorestring= "0:0" gosub("repaint") sleep(500) goto("gameloop") #mark("gameloop") gosub("logic") gosub("repaint") if winner>0 then goto("gameover") endif meterstart() smartsleep(30) goto("gameloop") #mark("logic") if touchx()>=0 then boardplayer= touchx() endif if ballyv <0 then if boardcpu-3 > ballx then boardcpu = boardcpu -random(0,4) endif if boardcpu+3 < ballx then boardcpu = boardcpu +random(0,4) endif endif if ballx+ballxv>=acw or ballx+ballxv<=0-1 then ballxv = abs(ballxv)/ballxv * (0-random(1,2)) playtone(700,100) endif if bally+ballyv>= fieldh then ballyv = abs(ballyv)/ballyv * (0-random(1,2)) ballxv = 2-random(0,4) if ballx<boardplayer-4 or ballx > boardplayer+4 then scorecpu=scorecpu+1 gosub("checkwinner") playtone(900,100) else playtone(670,100) endif endif if bally+ballyv<=0 then ballyv = abs(ballyv)/ballyv * (0-random(1,2)) ballxv = 2 - random(0,4) if ballx<boardcpu-4 or ballx > boardcpu+4 then scoreplayer=scoreplayer+1 gosub("checkwinner") playtone(900,100) else playtone(670,100) endif endif ballx=ballx+ballxv bally=bally+ballyv return() #mark("repaint") drawcolor(color_background) drawline(0,0,acw,0,color_element,1) drawrect(0,fieldh,acw,ach-fieldh,color_element,true,0) drawrect(boardplayer-4,fieldh-1,8,1,color_element,true,0) drawrect(boardcpu-4,1,8,1,color_element,true,0) drawrect(ballx-1,bally-1,2,2,color_element,true,0) 'drawtext(meterfinish(),1,fieldh+10,color_background,9) drawtext(scorestring,toint(acw/2)-toint(textwidth(scorestring,9)/2)-1, fieldh +12, color_background,9) repaint() return() #mark("splash") clearcanvas() dim menutimer =0 #mark("splashloop") sleep(50) menutimer=menutimer+1 if touchx()>=0 then playtone(900,100) sleep(100) playtone(600,100) undim menutimer gosub("change") goto("start") endif drawcolor(color_background) drawrect(2,9,56,18,color_element,true,0) drawrect(0,7,59,21,color_element,false,0) drawtext("monochrome",2,17,color_background,9) drawtext("pong",37,24,color_background,9) if mod(menutimer,10)<5 then drawtext("touch for start",3,65,color_element,8) endif repaint() goto("splashloop") #mark("checkwinner") scorestring= tostring(scoreplayer) & ":" & tostring(scorecpu) if scoreplayer=5 then winner=1 else if scorecpu=5 then winner=2 endif endif return() #mark("gameover") drawrect(2,35,acw-4,19,color_element,true,0) drawtext(arrayget(winnerstrings,winner-1), toint(acw/2) - toint(textwidth(arrayget(winnerstrings,winner-1),10)/2)-1,47,color_background,10) repaint() sleep(300) playtone(700,100) sleep(200) playtone(700,100) sleep(100) playtone(600,1000) sleep(2000) gosub("change") goto("splash") #mark("change") dim I = 0 for I to ach-1 step 2 smartsleep(10) drawrect(0,I,acw,2,color_element,true,0) repaint() next undim I sleep(300) return()