Skip to content

Commit e558104

Browse files
author
Andy Carle
committed
Initial Kinoma Studio project. Main application is currently a clickable 10x10 level editor that doesn't do anything.
0 parents  commit e558104

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.modules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<modulepath>
3+
<modulepathentry path="src" type="src"></modulepathentry>
4+
</modulepath>

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Parks</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.marvell.kinoma.kpr.kprBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>com.marvell.kinoma.kpr.application</nature>
16+
</natures>
17+
</projectDescription>

application.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<application xmlns="http://www.kinoma.com/kpr/application/1" id="parks" program="src/main" title="Parks">
3+
4+
</application>

src/main.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//@program
2+
3+
var TILESIZE = 20;
4+
5+
var NUMROWS = 10;
6+
var NUMCOLS = 10;
7+
8+
var getSkinsArray = function(...colors){
9+
var result = new Array();
10+
colors.forEach(color => {result.push(
11+
new Skin({fill: color, borders: {left:1, right:1, top:1, bottom:1}, stroke: "black"})
12+
)});
13+
return result;
14+
}
15+
16+
var whiteSkin = new Skin("white");
17+
var clearSkin = getSkinsArray("yellow")[0];
18+
var paintSkins = getSkinsArray("#1f78b4", "#33a02c", "#e31a1c", "#ff7f00", "#ff7f00", "#b2df8a", "#fb9a99", "#fdbf6f", "#cab2d6");
19+
var NUMSTATES = paintSkins.length;
20+
21+
class TileBehavior extends Behavior {
22+
onCreate(content, data){
23+
this.tile = data;
24+
content.skin = clearSkin;
25+
this.state = -1;
26+
}
27+
28+
onTouchBegan(content){
29+
this.tile.incrementState();
30+
}
31+
32+
updateColor(content){
33+
if (this.tile.state == -1){
34+
content.skin = clearSkin;
35+
}else{
36+
content.skin = paintSkins[this.tile.state];
37+
}
38+
}
39+
}
40+
41+
var ParkTile = Container.template($ => ({
42+
left: 0, top: 0, active: true, right: 0, bottom: 0, //width: TILESIZE, height: TILESIZE,
43+
Behavior: TileBehavior
44+
}));
45+
46+
47+
class Tile{
48+
constructor(x, y){
49+
this.x = x;
50+
this.y = y;
51+
this.state = -1;
52+
53+
this.content = new ParkTile(this);
54+
}
55+
56+
incrementState(){
57+
this.state++;
58+
if (this.state >= NUMSTATES) this.state = -1;
59+
this.content.delegate("updateColor");
60+
}
61+
62+
setState(state){
63+
this.state = state;
64+
this.content.delegate("updateColor");
65+
}
66+
}
67+
68+
var mainColumn = new Column({skin: whiteSkin, top:0, right:0, bottom:0, left:0});
69+
application.add(mainColumn);
70+
71+
var tiles = new Array();
72+
73+
for (let y = 0; y < NUMROWS; y++){
74+
let row = new Line({left: 0, right: 0, top: 0, bottom: 0});
75+
for (let x = 0; x < NUMCOLS; x++){
76+
let mytile = new Tile(x, y);
77+
tiles.push(mytile);
78+
row.add(mytile.content);
79+
}
80+
mainColumn.add(row);
81+
}

0 commit comments

Comments
 (0)