-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest5.html
More file actions
130 lines (105 loc) · 2.61 KB
/
Copy pathtest5.html
File metadata and controls
130 lines (105 loc) · 2.61 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<html>
<head>
<script src="./data/screen.js"></script>
</head>
<style>
body{ padding:0; margin:0; background:#cccccc; width:100%; height:100%; overflow:hidden; }
</style>
<center><canvas style="border:1px solid #cecece; margin:10px; cursor:cross;" width="480px" height="600px" id="screen"> </canvas></center>
<script>
var test = function( setting ){
var monitor, gui = graphicalUserInterface( ( monitor = {
width: 480, height:600,
monitor: document.getElementById('screen'),
} ) ), sp= gui.tiles({
// mod
mod:1,
// colors palette
palette:[
0xFFffffff,0x000000, // default
0x555555, // border
0x00aa00, // p1
0x0000aa, // p2
0xbbbbbb,
0xaaaaaa,
0x006666,
0x2f4f4f // new reset
],
// size Tiles
offsetTilesX:6,
offsetTilesY:6,
}),
/*
* sprite warriors
*/
sprites = [
// blink
[0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,2,2,2,2,2,2,2],
// default
[1,1,1,1,1,1,1,6,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
// p1 & p2
[3,3,3,3,3,2,3,0,3,3,3,2,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,3,2,2,2,2,2,2,2],
[4,4,4,4,4,2,4,6,4,4,4,2,4,4,4,4,4,2,4,4,4,4,4,2,4,4,4,4,4,2,2,2,2,2,2,2],
//
[0,5,5,5,5,2,5,5,5,5,5,2,5,5,5,5,5,2,5,5,5,5,5,2,5,5,5,5,5,2,2,2,2,2,2,2],
[1,1,1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[8,8,8,8,8,8,8,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8],
[8,8,8,8,8,8,8,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8],
];
function light ( offset, nsprite ){
sp.setTilesByOffset(
offset,
sprites[ nsprite ]
);
gui.refresh( );
return true;
}
return {
blink: function( offset ){
return light(
offset,
0
);
},
setPlayer:function( offset, player ){
return light(
offset,
( player ? 2 : 3 )
);
},
/*
* clear Monitor
*/
reset:function( mem ){
var x = y = 0;
try{
console.log( )
for(; y < parseInt( monitor.height / 6 ); y++ ){
for( x= 0; x < parseInt( monitor.width / 6 ); x++ ){
sp.setTiles(
x, y,
sprites[
mem != undefined && mem[ x+(y*80) ] > -1 ?
( !(x%10) || !(y%10) ? 6 : 7 ) :
( !(x%10) || !(y%10) ? 1 : 5 )
]
);
}
}
gui.refresh( );
}catch(e){};
return 1;
},
};
}
/**/
var gm = test( );
gm.reset( );
var i = 0;
setInterval( function( ){
gm.setPlayer( i+parseInt(Math.random()*255),parseInt(Math.random()*2) );
i+=5;
i%=8000;
},60 );
</script>
</html>