-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMain.jack
53 lines (44 loc) · 1.22 KB
/
Main.jack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* NOTE: This implementation uses the default Screen.drawPixel method.
* Since Hack CPU does not have multiplication and division on hardware
* it is, obviously, slow to make these operations.
* So, since Mandelbrot set relies a lot on mulitplication/division,
* this implementation is slow.
*
* Maybe, in future we can optimize it somehow?
*/
class Main {
function void main() {
var Set set;
var char key;
var boolean exit;
let set = Set.new(1, 2, 512, 256);
let exit = false;
do set.draw();
while (~exit) {
while (key = 0) {
let key = Keyboard.keyPressed();
}
if (key = 81) {
let exit = true;
}
if (key = 130) {
do set.incMaxValue();
}
if (key = 131) {
do set.incMaxIterations();
}
if (key = 132) {
do set.decMaxValue();
}
if (key = 133) {
do set.decMaxIterations();
}
while (~(key = 0)) {
let key = Keyboard.keyPressed();
do set.draw();
}
}
return;
}
}