Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A single line function to modify MOD for better pattern recognition....
#4
Well Steve fixed his and it has much less use of ABS:
Code: (Select All)
_Title "MOD versus modx test Petes new thing" ' b+ 2022-11-28
Screen _NewImage(800, 600, 32)
x = 300: y = 300: dx = -5
Do
    Cls
    Print "spacebar to exit this first screen, I want circle to exit stage left and enter stage right..."
    Circle (x, y), 20
    x = (x + dx) Mod _Width ' head left loop around and head left???
    _Display 'no blinking
    _Limit 10 ' 10 xs per sec
Loop Until _KeyDown(32)
Cls
Locate 15, 20: Print "That sucks, I am talking about normal MOD for negative numbers."
Print
Locate 17, 20: Print "  OK try Pete's new and improved super dupper modx(), zzz..."
_Display
Sleep
_KeyClear
Cls

x = 300: y = 300: dx = -5
Do
    Cls
    Print "escape to quit, circle should leave screen on left and return on right"
    Circle (x, y), 20
    x = Steve_ModX(x + dx, _Width) ' head left loop around and head left???
    If x > 400 Then
        Locate 30, 30: Print "It works! It works! Holy crap it works!"
    End If
    _Display 'no blinking
    _Limit 10 ' 10 xs per sec
Loop Until _KeyDown(27)

Function modx (i, j)
    modx = (Abs(i) - Abs(j) * ((Abs(i) \ Abs(j)) + (1 - Sgn(i)) \ 2)) * Sgn(i Mod j)
End Function

Function Steve_ModX (num1, num2)
    Steve_ModX = ((num1 Mod num2) + Abs(num2)) Mod num2 ' fixed for neg modulus with ABS
End Function

BTW don't save file from _title if ;-)) in _title
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: A single line function to modify MOD for better pattern recognition.... - by bplus - 11-29-2022, 12:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Function IsWord%(test$) bplus 5 240 02-26-2026, 02:51 PM
Last Post: mdijkens
  A hybrid pattern-based data compressor Dav 2 377 12-24-2025, 12:06 PM
Last Post: Dav
  Sample program using the new _Files$ function eoredson 30 9,347 09-29-2025, 02:55 PM
Last Post: dakra137
  Another Dir/File compare function. eoredson 0 528 01-11-2025, 03:48 AM
Last Post: eoredson
  Button rack or hotkey function OldMoses 6 1,503 01-09-2025, 08:20 PM
Last Post: Jack002

Forum Jump:


Users browsing this thread: 1 Guest(s)