Text Mode Squash

(More or Less Complete Projects)

Text Mode Squash

Unread postby Mike Lobanovsky » Sun Aug 17, 2014 8:13 am

Please watch out for line wrap in the code. Use arrow keys to play, Esc, to quit.

Enjoy! :)

Code: Select all
#APPTYPE CONSOLE

#DLLDECLARE MSVCRT("GetChar")

MACRO TICKS()          = GetTickCount()
MACRO WAITKEY()        = GetChar()
MACRO GETKEY(A)        = GetAsyncKeyState(A)
MACRO DISPLAY(A, B, C) = (LOCATE(A, B, FALSE) + PRINTF("%s", $C))
MACRO SETCONS()        = (SetConsoleWindowInfo(GetStdHandle(&HFFFFFFF5), TRUE, @MAKEQUAD(0, MAKELONG(18, 17))) + _
                         SetConsoleTitleA("DO IT!")) // STD_OUTPUT_HANDLE
MACRO FIXCONS()        = (GetSystemMenu(GetConsoleWindow(), FALSE) + _
                         DeleteMenu(GetSystemMenu, &HF000, 0) + _ // SC_SIZE, MF_BYCOMMAND
                         DeleteMenu(GetSystemMenu, &HF020, 0) + _ // SC_MINIMIZE, MF_BYCOMMAND
                         DeleteMenu(GetSystemMenu, &HF030, 0)) // SC_MAXIMIZE, MF_BYCOMMAND

SETCONS()
FIXCONS()

CLS
DISPLAY(1, 1, "===================")
DISPLAY(3, 5, "FBSL SQUASH")
DISPLAY(5, 1, "===================")
DISPLAY(8, 2, "BROUGHT TO YOU BY")
DISPLAY(10, 5, "THE WATCHER")
DISPLAY(18, 2, "ENTER TO START...")
WAITKEY()

DIM X, H
DIM Y, V
DIM O, P
DIM R, S
DIM T1 = TICKS(), T2, T3, T4

:START
RANDOMIZE
CLS

X = 10: H = IIF(RANDINT(0, 1), 1, -1)
Y = 15: V = -1
R = 10: S = 0
T3 = CLOCK()

DISPLAY(16, R, "==")
WHILE Y <= 16
   T4 = "TIME: " & %(CLOCK() - T3)
   O = X: P = Y
   X = X + H: Y = Y + V
   DISPLAY(18, 1, "SCORE: " & S)
   DISPLAY(18, 19 - LEN(T4), T4)
   DISPLAY(Y, X, "o")
   DISPLAY(P, O, " ")

   IF GETKEY(27) THEN GOTO FINISH // VK_ESCAPE
   IF GETKEY(37) <> 0 ANDALSO R >= 1 THEN // VK_LEFT
      P = R
      R = R - 2
      IF R < 1 THEN R = 1
      DISPLAY(16, P, "  ")
      DISPLAY(16, R, "==")
   ELSEIF GETKEY(39) <> 0 ANDALSO R <= 17 THEN // VK_RIGHT
      P = R
      R = R + 2
      IF R > 19 THEN R = 19
      DISPLAY(16, P, "  ")
      DISPLAY(16, R, "==")
   END IF

   IF X + H < 1 ORELSE X + H > 19 THEN H = -H
   IF Y + V < 1 THEN V = -V
   IF Y + V > 15 ANDALSO X + H >= R ANDALSO X + H <= R + 1 THEN
      V = -V
      S = S + 1
      IF (X + H = R ANDALSO H > 0) ORELSE (X + H = R + 1 ANDALSO H < 0) THEN H = -H
   END IF
   WHILE T2 - T1 < 150
      T2 = TICKS()
   WEND
   T1 = TICKS
WEND
GOTO START
:FINISH
Attachments
TextModeSquash.PNG
TextModeSquash.PNG (4.04 KiB) Viewed 641 times
Mike
"Я старый солдат, мадам, и не знаю слов любви."
"I am an old soldier, ma'am, and I don't know the words of love."
"Je suis un vieux soldat, madame, et je ne connais pas les mots d'amour."
"Ich bin ein alter Soldat, gnädige Frau, und ich weiß nicht die Worte der Liebe."

__________________________________________________________________________________________________________________________________________________
(3.2GHz i5 Core Quad, 8GB RAM / 2 x nVidia GTX 550Ti SLI-bridged, 2GB VRAM)
(x86 Win XP Pro Russian Sp3/x86 Win Vista Ultimate Sp2/x64 Win 7 Ultimate Sp1/Wine in x64 elementaryOS Luna)
User avatar
Mike Lobanovsky
FBSL Administrator
FBSL Administrator
 
Posts: 1824
Joined: Tue Apr 19, 2005 8:22 am
Location: Republic of Belarus

Return to FBSL v3 Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron