RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Help with Win32API

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 39
N
2014 Zero to Hero
I have the following code:
Code: [Select]

@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh
         
# Computer move
@best_move.call()
refresh

@best_move is a function that can take quite long to execute, but @do_move is instant. I want the board to be redrawn after @do_move, before @best_move is called, but instead refresh doesn't seem to be run until after both Win32APIs are called.

 

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
From the looks of your code it would seem everything is called in a single frame which means that everything updates at once.

If you want a pause between @do_move and @before_best you need to add it in between.

Code: [Select]
@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh

# Wait 60 frames (Only the Graphics module is updated)
Graphics.wait(60)
         
# Computer move
@best_move.call()
refresh

Graphics.wait is not probably what you want, but you can visibly see a pause after @do_move. You will probably want to add your own wait method if things are moving or being animated on screen.

***
Rep:
Level 39
N
2014 Zero to Hero
From the looks of your code it would seem everything is called in a single frame which means that everything updates at once.

If you want a pause between @do_move and @before_best you need to add it in between.

Code: [Select]
@do_move = Win32API.new("ChessEngine.dll", "do_move", ['I','I'], "I")
@best_move = Win32API.new("ChessEngine.dll", "best_move", "", "L")

...

# Player move
@do_move.call(@from, @cursor)
refresh

# Wait 60 frames (Only the Graphics module is updated)
Graphics.wait(60)
         
# Computer move
@best_move.call()
refresh

Graphics.wait is not probably what you want, but you can visibly see a pause after @do_move. You will probably want to add your own wait method if things are moving or being animated on screen.

Ah, you're right.

I tried simply putting a Graphics.update between them and that worked. :D