From 69146203d42cd1a92bbdb186c3ae8b9c04b1b267 Mon Sep 17 00:00:00 2001 From: Pio Date: Sat, 19 Jan 2019 17:45:22 +0100 Subject: [PATCH] Implemented ephemeral hiscore. --- gbg.bas | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/gbg.bas b/gbg.bas index 0f3c9a4..210b273 100644 --- a/gbg.bas +++ b/gbg.bas @@ -59,6 +59,7 @@ Type game_type As Short w, h As UByte speed = 1 As Double tim, speed_timer, menu_timer + As Short score = 0, hiscore = 0 End Type @@ -70,7 +71,6 @@ ReDim Shared help () As String Dim Shared As UByte playabletiles, numberoftiles Dim Shared As Short columns=1, rows=1 Dim Shared As Byte wrap, gravity, randominputs, randomgoals, inputrotate -Dim Shared score As Short=0 ReDim Shared tilesfiles(0) As String ReDim Shared randomtable() As UByte Dim Shared keypress As String @@ -407,6 +407,12 @@ Function matchshape(x As Short,y As Short) As Byte End Function +Sub score(inc As Short) + game.score += inc + If game.score > game.hiscore Then game.hiscore = game.score +End Sub + + Sub checksituation() Dim As Byte x, y, gap, removed=False, scoremulti=0, existsnextvariation=False, gotonextvariation=True For y=0 To rows-1 + maxgoalsh : For x=0 To columns-1 + maxgoalsw @@ -454,7 +460,7 @@ Sub checksituation() EndIf Next x: Next y EndIf - score+=scoremulti*10 + score(scoremulti * 10) 'check exit For y=0 To rows-1 : For x=0 To columns-1 If originalplayfield(x,y)=253 Then @@ -539,7 +545,7 @@ Sub loadTiles(increment As Byte) game.w = tilewidth*columns : game.h = tilewidth*rows tilesimg = ImageCreate(tilewidth, tilewidth*(3+numberoftiles)) BLoad tilesfile, tilesimg - scoreimg = ImageCreate(122,20) + scoreimg = ImageCreate(130,20) BLoad GFXPATH+"/brojke.bmp", scoreimg resizewindow() ScreenSet 0,1 @@ -547,15 +553,15 @@ Sub loadTiles(increment As Byte) End Sub -Sub drawscore +Sub drawscore() Dim As UByte a,digit Dim As Byte numberstarted=False Dim xpx As UShort = tilewidth*columns Line(0,0)-(xpx,16),RGB(0,0,0),BF For a=0 To 9 'max 10 digits - traze se otpozadi - If 10^a > score Then Exit For - digit=Fix((score Mod 10^(a+1)) / 10^a) + If 10^a > game.score Then Exit For + digit=Fix((game.score Mod 10^(a+1)) / 10^a) If digit=1 Then xpx-=5 Put (xpx,1),scoreimg,(13,0)-(17,14),PSet @@ -567,6 +573,10 @@ Sub drawscore Put (xpx,1),scoreimg,(-8+digit*13,0)-(-8+12+digit*13,14),PSet EndIf Next + If game.score > 0 And game.score = game.hiscore Then + xpx-=13 + Put (xpx,1),scoreimg,(122,0)-(130,14),PSet + End If End Sub @@ -708,7 +718,7 @@ End Sub Sub gameRestart() - score = 0 + game.score = 0 game.speed = 1 initplayfield() blok.init() @@ -761,6 +771,7 @@ Function loadgame(filename As String) As Byte Loop Until Eof(1) Close #1 If Not loadedcycle Then loadcycle() + game.hiscore = 0 gameRestart() loadTiles(0) Return True @@ -840,7 +851,7 @@ End Function Sub gameOver() Dim As Short starty = 0, y = 0, endy - Dim As Byte scoredrawn = False + Dim As Byte scoredrawn Dim tim2 As Double scoredrawn = settings.show_score If settings.show_score Then starty += SCORE_INDICATOR_SIZE @@ -909,7 +920,7 @@ Do drawplayfield() Case Chr(255) + "P" 'down If gravity Then - score+=1 + score(1) blok.drop() Else blok.move(0,1) @@ -919,7 +930,7 @@ Do loadTiles(1) Case Chr(13) 'Enter = fix or drop If gravity Then - Do : score+=1 : Loop While blok.move(0,1) + Do : score(1) : Loop While blok.move(0,1) EndIf checksituation() blok.init() -- 2.11.4.GIT