Menu

Macro Library

Honguito98

Macro Library

Mouse

Reads Mouse and keyboard input.
Change 'InputHit' to 'InputHit 1' to no wait for keystroke.

Dependencies:

  • Fn.dll or Seta_Core.dll or bg.exe
  • Set Fn variable to exe name.

Return values:

  • !X! X coord.
  • !Y! Y coord.
  • !Btn! Mouse Button code.
  • !Kbd! Keyboard button code.
  • !Char! Keyboard character -space not supported-
  • !WStatus! Is focused or not the window.
  • !Wheel! Returns current mouse wheel position.

Example:

%Mouse%
Cls
Echo;Mouse Pos. is: !X!.!Y!
Echo;Mouse button is: !Btn!
Echo;Keyboard code and char.: !Kbd! - "!Char!"
Echo;Is focused window?: !WStatus!
Echo;Wheel Position: !Wheel!

Code:

<Macro=Mouse|1>
    If Not Defined __FData (
        Set __FData=Mouse_!Random!.tmp
        For /L %# in (1,1,3) Do If Exist !__FData! Set __FData=Mouse_!Random!.tmp
    )
    !Fn! Inputhit 1 >!__FData!
    For /F "Tokens=1-5" %A in (!__FData!) Do (
        Set "Char="
        If %A Equ -2 (
            Set WStatus=Not Present
        ) Else Set WStatus=Focused
        If %A Geq 0 Set Y=%A
        If %B Geq 0 Set X=%B
        If %C Geq 0 If %C Leq 5 Set Btn=%C
        If %C Geq 10000  Set/a Wheel+=1
        If %C Leq -10000 Set/a Wheel-=1 
        If "%E" Neq "" Set "Char=%E"
        Set Kbd=%D
    )
</Macro=Mouse>

SelectBox

MenuBox

Physics

Compare two objects and returns 'true (1)' if these are touching, else will return 'false (0)' as errorlevel

Dependencies:

  • Set each sprite type X.Y.W.H measures

Return values:
!Errorlevel! = (1) for 'are touching' and (0) for 'nothing'

Example:

Set Goomba.x=10
Set Goomba.y=10
Set Goomba.h=16
Set Goomba.w=16

Set Player.x=0
Set Player.y=0
Set Player.w=10
Set Player.h=15
%Physics% Player Goomba
If !Errorlevel! Equ 1 Echo; Player touchs a goomba
If !Errorlevel! Equ 0 Echo; Player still alive

Code:

<Macro=Physics|2>
Set /a^
"__W_p=%1.W + %1.X,"^
"__H_p=%1.H + %1.Y,"^
"__X_p=%1.X,"^
"__Y_p=%1.Y"

For /F "Tokens=1-2" %X in ("!%2!") Do (
    Set /a^
    "__W_e=%2.W + %Y,"^
    "__H_e=%2.H + %X,"^
    "__X_e=%Y,"^
    "__Y_e=%X,"^
    "__C1=0,"^
    "__C2=0"

    Rem X
    If !__W_p! Gtr !__X_e! (
        If !__W_p! Lss !__W_e! (
            Set __C1=1
        ) Else (
            If !__X_p! Lss !__W_e! Set __C1=1
        )
    )
    Rem Y
    If !__H_p! Gtr !__Y_e! (
        If !__H_p! Lss !__H_e! (
            Set __C2=1
        ) Else (
            If !__Y_p! Lss !__H_e! Set __C2=1
        )
    )

    If "!__C1!!__C2!" == "11" (Call) Else (Call )
)

</Macro=Physics>

Render

Gpu

FCalc

Fixed-floating point calculator.
Change prec var for decimal precision
Co-developer: einstein1969

Dependencies:

  • None

Return values:

  • !Int! integer result
  • !Float! fixed-f.p. result

Example:

%FCalc% 12.5 + 12.5
Echo;!Int!.!Float!

%FCalc% 12 * 2.56
Echo;!Int!.!Float!

%FCalc% 12 / 2.56
Echo;!Int!.!Float!

%FCalc% 12 - 2.56
Echo;!Int!.!Float!

Code:

<Macro=FCalc|2>
set Sum1=%1
set Mode=%2
set Sum2=%3
set prec=2
For %P in (!prec!) do (

    For %T in (1;2) Do (

    for /f tokens^=1-4^ delims^=+^"^  %f in ("!Sum%T!") do set Sum%T=0000000000%~f%~g%~h%~i

    set i%T=!Sum%T:*.=!0!Sum%T:~0,%P!
        For %I in ("!Sum%T:*.=!") do if not "%~I" == "!Sum%T!" set i%T=!Sum%T:.%~I=!!i%T:~0,1!!i%T:~1,%P!

    for /f "tokens=* delims=0" %z in ("!i%T!") do set /a "i%T=(%z+5)/10"

    )
    set Div.acc=1!Sum1:~0,%P!

    if "!Mode!" equ "/" (
        set /a Total=!i1!*!Div.acc!/!i2!
    ) else (
    if "!Mode!" equ "*" (
        set /a Total=!i1!*!i2!/!Div.acc!
    ) else set /a Total=!i1!!Mode!!i2!
    )

    If !total! geq 0 (
        set /a "Int=Total/Div.acc, Float=Total % Div.acc"
    ) else  set /a "Int=Total/Div.acc, Float=-(Total % Div.acc)"

    set Float=!Sum1:~0,%P!!Float!
    set Float=!Float:~-%P!
)
</Macro=FCalc>

Mult


Related

Wiki: Home
Wiki: Macro Definition

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.