-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandom.jack
65 lines (61 loc) · 1.22 KB
/
Random.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
54
55
56
57
58
59
60
61
62
63
64
65
class Random
{
field int horizontalX;
field int verticalY;
static int counter;
static int dimensionX;
static int dimensionY;
constructor Random new()
{
let verticalY = 0;
let dimensionX = 512;
let dimensionY = 256;
let counter = 100;
let horizontalX = 0;
return this;
}
method void dispose()
{
do Memory.deAlloc(this);
return;
}
method int randomX(int x)
{
var int t;
let horizontalX = dimensionX + x + counter;
let t = horizontalX - dimensionX;
while(t > dimensionX)
{
let t = t - dimensionX;
}
if(t > 508)
{
let t = 508;
}
if(t < 4)
{
let t = 4;
}
return t;
}
method int randomY(int y)
{
var int t;
let verticalY = dimensionY + y + counter;
let t = verticalY - dimensionY;
while(t > dimensionY)
{
let t = t - dimensionY;
}
if(t > 252)
{
let t = 252;
}
if(t < 4)
{
let t = 4;
}
let counter = counter + 100;
return t;
}
}