You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB
HTML

<DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../static/game-style.css">
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp">
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin">
<script type="text/javascript" src="../static/brython.min.js">
</script>
<script type="text/javascript" src="../static/brython_stdlib.js">
</script>
<script>
if (!crossOriginIsolated) SharedArrayBuffer = ArrayBuffer;
</script>
</head>
<body onload="brython()">
<script type="text/python">
from browser import self as _self, bind, console
# implementation of blocking time.sleep()
def sleep(secs):
sab = _self.SharedArrayBuffer.new(128 * _self.Int32Array.BYTES_PER_ELEMENT)
buffer = _self.Int32Array.new(sab)
_self.Atomics.store(buffer, 0, -1)
_self.send({'status': 'sleep', 'seconds': secs, 'buffer': sab})
# block until main program resets buffer[0] to 1
_self.Atomics.wait(buffer, 0, -1)
sleep(1)
print("hello world")
sleep(3)
print("hello world")
</script>
</body>
</html>