News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Plz Help

Started by thejealousguy, December 13, 2011, 11:02:53 AM

Previous topic - Next topic

thejealousguy

I'm preparing an MASM code about hangman game..
Do you have any idea on how to code??

qWord

Quote from: thejealousguy on December 13, 2011, 11:02:53 AM
I'm preparing an MASM code about hangman game..
Do you have any idea on how to code??

yes
FPU in a trice: SmplMath
It's that simple!

jj2007

Me I have no idea but I am sure Alfonso Víctor Caballero Hurtado has one or two, see attachment :bg

jj2007

I could not resist the temptation to roll my own.
Open the attachment, run the exe, and test your knowledge: This hangman asks for Windows.inc structures :toothy

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Recall "\Masm32\include\Windows.inc", L$()
   call Hangman
   Locate(3,9)
   Inkey "Bye                "
   Exit
Hangman proc
LOCAL ct, fail, good, slen, curline, hWnd
   ClearLocalVariables uses edi esi ebx ecx
   xchg eax, ebx
   mov hWnd, rv(GetForegroundWindow)
   Rand()
   .Repeat
      mov curline, Rand(ebx)
      Let edi=L$(eax)
      .if Instr_(edi, "struct", 5)
         inc ct
         Let edi=Left$(edi, edx-1)
         Let edi=Trim$(edi)
         mov slen, Len(edi)
         Locate(3,5)
         Print String$(slen, ". ")
         Print Space$(20)
         Clr fail, good
         .Repeat
            .Repeat
               Locate(3, 7)
               Inkey "Type a lowercase letter (Esc to quit, + for next try): "
            .Until eax=="+" || eax==27 || (eax>="a" && eax<="z") || eax=="_"
            .Break .if eax==27 || eax=="+"
            xchg eax, esi
            and esi, 11011111b
            .if Instr_(edi, Chr$(esi))
               mov [eax], "@"
               lea eax, [1+2*edx]
               Locate(eax, 5)
               inc good
               Print Chr$(esi)
            .else
               Locate(3, 9)
               inc fail
               Print Str$("%i errors ", fail)
            .endif
            mov edx, good
         .Until eax==27 || edx>=slen || eax=="+"
         .if edx==slen
            MsgBox hWnd, L$(curline), "Congrats:", MB_OKCANCEL
         .endif
      .endif         
   .Until ct>3 || eax==27 || eax==IDCANCEL
   PopUses
   ret
Hangman endp
end start

thejealousguy

Thank you.. I will try my best..