Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Commit 8e39a27

Browse files
committed
minor cleanup
1 parent 9d60bc3 commit 8e39a27

8 files changed

Lines changed: 2 additions & 250 deletions

File tree

‎debugger.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// Add your code here
2-
3-
// debugger for a rule
4-
// - use neighborhood to generate a tile map
5-
61
namespace tileworld {
72
// - attaches to VM
83
// - shows state of sprites (old arrows; new arrows)

‎home.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
namespace tileworld {
32

43
const helpString = "00map,10paint,20code,30play,90settings,"; // 40debug,50music

‎imageeditor.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace tileworld {
2+
23
const yoff = 4;
34
const colorSize = 8;
45
const paintSize = 6;

‎mytilemap.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
namespace scene {
32

43
export function setTileMap(map: Image, scale = TileScale.Sixteen) {

‎ruleTransform.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
// Add your code here
21
namespace tileworld {
32

4-
// ------------------------------------------------------------------------------------
5-
// a simple (but not complete) way to change the transforms on a rule
6-
73
const transformMap = [ RuleTransforms.None, RuleTransforms.HorzMirror, RuleTransforms.VertMirror,
84
RuleTransforms.LeftRotate, RuleTransforms.RightRotate, RuleTransforms.Rotate3Way];
95
const transformImages = [ yellowSprite, flipHoriz, flipVert, leftRotate, rightRotate, rotate3way];

‎ruledisplay.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Add your code here
2-
31
namespace tileworld {
42

53
export const editorRow = 2;

‎test.ts‎

Lines changed: 1 addition & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -1,235 +1 @@
1-
namespace sample {
2-
export const player = img`
3-
. . . . . . f f f f . . . . . .
4-
. . . . f f f 2 2 f f f . . . .
5-
. . . f f f 2 3 2 2 f f f . . .
6-
. . f f f e e e e e e f f f . .
7-
. . f f e 2 2 2 2 2 2 e e f . .
8-
. . f e 2 f f f f f f 2 e f . .
9-
. . f f f f e e e e f f f f . .
10-
. f f e f b f 4 4 f b f e f f .
11-
. f e e 4 1 f d d f 1 4 e e f .
12-
. . f e e d d d d d d e e f . .
13-
. . . f e e 4 4 4 4 e e f . . .
14-
. . e 4 f 2 2 2 2 2 2 f 4 e . .
15-
. . 4 d f 2 2 2 2 2 2 f d 4 . .
16-
. . 4 4 f 4 4 5 5 4 4 f 4 4 . .
17-
. . . . . f f f f f f . . . . .
18-
. . . . . f f . . f f . . . . .
19-
`;
20-
export const diamond = img`
21-
. . . . . . . . . . . . . . . .
22-
. . . . 8 8 8 8 8 8 8 8 . . . .
23-
. . . 8 8 8 8 9 9 9 1 1 . . . .
24-
. . 8 8 8 8 9 9 9 9 1 1 1 1 . .
25-
. 8 8 8 8 8 8 9 9 1 1 1 1 1 1 .
26-
. 8 8 8 8 8 8 8 1 1 1 1 1 1 1 .
27-
. 9 9 9 9 9 9 9 9 9 9 9 9 9 9 .
28-
. 9 9 9 9 9 9 9 1 1 1 1 1 1 1 .
29-
. 9 9 9 9 9 9 9 1 1 1 1 1 1 1 .
30-
. . 9 9 9 9 9 9 1 1 1 1 1 1 . .
31-
. . . 9 9 9 9 9 1 1 1 1 1 . . .
32-
. . . . 9 9 9 9 1 1 1 1 . . . .
33-
. . . . . 9 9 9 1 1 1 . . . . .
34-
. . . . . . 9 9 1 1 . . . . . .
35-
. . . . . . . 9 1 . . . . . . .
36-
. . . . . . . . . . . . . . . .
37-
`;
38-
export const boulder = img`
39-
. . . . . c c b b b . . . . . .
40-
. . . . c b d d d d b . . . . .
41-
. . . . c d d d d d d b b . . .
42-
. . . . c d d d d d d d d b . .
43-
. . . c b b d d d d d d d b . .
44-
. . . c b b d d d d d d d b . .
45-
. c c c c b b b b d d d b b b .
46-
. c d d b c b b b b b b b b d b
47-
c b b d d d b b b b b d d b d b
48-
c c b b d d d d d d d b b b d c
49-
c b c c c b b b b b b b d d c c
50-
c c b b c c c c b d d d b c c b
51-
. c c c c c c c c c c c b b b b
52-
. . c c c c c b b b b b b b c .
53-
. . . . . . c c b b b b c c . .
54-
. . . . . . . . c c c c . . . .
55-
`;
56-
export const enemy = img`
57-
. . . . . . . f f f f . . . . .
58-
. . . . . f f 1 1 1 1 f f . . .
59-
. . . . f b 1 1 1 1 1 1 b f . .
60-
. . . . f 1 1 1 1 1 1 1 1 f . .
61-
. . . f d 1 1 1 1 1 1 1 1 d f .
62-
. 7 . f d 1 1 1 1 1 1 1 1 d f .
63-
7 . . f d 1 1 1 1 1 1 1 1 d f .
64-
7 . . f d 1 1 1 1 1 1 1 1 d f .
65-
7 . . f d d d 1 1 1 1 d d d f f
66-
7 7 . f b d b f d d f b d b f c
67-
7 7 7 f c d c f 1 1 f c d c f b
68-
. 7 7 f f f b d b 1 b d f f c f
69-
. f c b 1 b c f f f f f f . . .
70-
. f 1 c 1 c 1 f f f f f f . . .
71-
. f d f d f d f f f f f . . . .
72-
. . f . f . f . . . . . . . . .
73-
`;
74-
export const wall = img`
75-
d d d d d d d d d d d d d d d 8
76-
d 6 6 6 8 8 8 6 6 6 6 6 6 6 8 8
77-
d 6 6 8 6 6 6 8 6 6 6 6 6 6 8 8
78-
d 6 8 6 8 8 8 6 8 8 8 8 8 8 8 8
79-
d 8 6 8 8 d 8 8 6 6 6 6 6 6 8 8
80-
d 8 6 8 d d d 8 6 8 8 8 8 8 6 8
81-
d 8 6 8 8 d 8 8 6 6 6 6 6 6 8 8
82-
d 6 8 6 8 8 8 6 8 8 8 8 8 8 8 8
83-
d 6 6 6 6 6 6 6 6 8 6 6 6 6 8 8
84-
d 8 8 8 6 6 6 6 6 8 8 6 6 8 6 8
85-
d 6 6 6 6 6 6 6 6 8 8 8 8 8 6 8
86-
d 8 8 8 6 6 6 6 6 6 6 6 6 6 6 8
87-
d 6 6 6 6 6 6 6 6 6 6 6 6 6 6 8
88-
d 8 8 8 8 6 6 6 6 8 8 8 8 8 6 8
89-
d 6 6 6 6 6 6 6 8 8 6 6 6 8 6 8
90-
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
91-
`;
92-
export const wall2 = img`
93-
c c c c c c c c c c c c c c c 8
94-
c b b b 8 8 8 b b b b b b b 8 8
95-
c b b 8 b b b 8 b b b b b b 8 8
96-
c b 8 b 8 8 8 b 8 8 8 8 8 8 8 8
97-
c 8 b 8 8 6 8 8 b b b b b b 8 8
98-
c 8 b 8 6 6 6 8 b 8 8 8 8 8 b 8
99-
c 8 b 8 8 6 8 8 b b b b b b 8 8
100-
c b 8 b 8 8 8 b 8 8 8 8 8 8 8 8
101-
c b b b b b b b b 8 b b b b 8 8
102-
c 8 8 8 b b b b b 8 8 b b 8 b 8
103-
c b b b b b b b b 8 8 8 8 8 b 8
104-
c 8 8 8 b b b b b b b b b b b 8
105-
c b b b b b b b b b b b b b b 8
106-
c 8 8 8 8 b b b b 8 8 8 8 8 b 8
107-
c b b b b b b b 8 8 b b b 8 b 8
108-
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
109-
`;
110-
export const dirt = img`
111-
f e e e e e f e e e e 4 4 4 4 e
112-
e e 4 4 e e e f f f e e e e e e
113-
e 4 4 4 4 4 e e f f f f f e e e
114-
e 4 4 4 4 4 4 e f e e e e e f e
115-
e 4 4 4 4 4 4 e f e 4 4 4 4 e f
116-
e e 4 4 4 4 4 f e 4 4 4 4 4 4 e
117-
e e e 4 4 4 e e e 4 4 4 4 4 4 e
118-
f f e e e e e f e 4 4 4 4 4 4 e
119-
f e e e 4 4 4 e f e 4 4 4 4 e e
120-
f e e 4 4 4 4 4 e e e e 4 4 e f
121-
e e 4 4 4 4 4 4 4 e f e e e e f
122-
f e 4 4 4 4 4 4 4 e e f f f e e
123-
f e 4 4 4 4 4 4 4 e f e e e e f
124-
e f e 4 4 4 4 4 e f e 4 4 e e e
125-
e e f e 4 4 4 e f e 4 4 4 4 e e
126-
f e e f e e e f e 4 4 4 4 4 4 e
127-
`;
128-
export const space = img`
129-
f f f f f f f f f f f c c c c f
130-
f f c c f f f f f f f f f f f f
131-
f c c c c c f f f f f f f f f f
132-
f c c c c c c f f f f f f f f f
133-
f c c c c c c f f f c c c c f f
134-
f f c c c c c f f c c c c c c f
135-
f f f c c c f f f c c c c c c f
136-
f f f f f f f f f c c c c c c f
137-
f f f f c c c f f f c c c c f f
138-
f f f c c c c c f f f f c c f f
139-
f f c c c c c c c f f f f f f f
140-
f f c c c c c c c f f f f f f f
141-
f f c c c c c c c f f f f f f f
142-
f f f c c c c c f f f c c f f f
143-
f f f f c c c f f f c c c c f f
144-
f f f f f f f f f c c c c c c f
145-
`;
146-
/*
147-
export const movable = [player, boulder, diamond, enemy];
148-
export const fixed = [space, wall, dirt, wall2];
149-
export const all = [].concat(fixed).concat(movable);
150-
151-
let wallId = all.indexOf(wall);
152-
let spaceId = all.indexOf(space);
153-
let playerId = all.indexOf(player);
154-
let enemyId = all.indexOf(enemy);
155-
let boulderId = all.indexOf(boulder);
156-
let diamondId = all.indexOf(diamond);
157-
158-
function TileAt(id: number, col: number, row: number): WhenDo {
159-
return new WhenDo(col, row, tileworld.fillAttr(AttrType.Exclude, 7, id, AttrType.Include), []);
160-
}
161-
162-
function SpriteAt(id: number, col: number, row: number): WhenDo {
163-
let attrs = tileworld.fillAttr(AttrType.Exclude, 7, id, AttrType.Include);
164-
attrs[0] = attrs[1] = attrs[2] = AttrType.OK;
165-
return new WhenDo(col, row, attrs, []);
166-
}
167-
168-
let tp = TileAt(spaceId, 2, 3)
169-
tp.predicate[playerId] = AttrType.OK;
170-
tp.predicate[enemyId] = AttrType.OK;
171-
let playerMove = tileworld.fillAttr(AttrType.OK, 7, boulderId, AttrType.Exclude);
172-
playerMove[wallId] = AttrType.Exclude;
173-
174-
let moveRight = [new Command(CommandType.Move, MoveDirection.Right)]
175-
let moveLeft = [new Command(CommandType.Move, MoveDirection.Left)]
176-
177-
let boulderRight = SpriteAt(boulderId, 3, 2)
178-
boulderRight.commands = moveRight;
179-
180-
let boulderLeft = SpriteAt(boulderId, 1, 2)
181-
boulderLeft.commands = moveLeft;
182-
183-
let playerPaint = new Rule([playerId], RuleType.Resting, MoveDirection.Left,
184-
[new WhenDo(2,2,[],[new Command(CommandType.Paint,spaceId)])]
185-
);
186-
187-
function playerMoveRule(dir: MoveDirection) {
188-
return new Rule([playerId], RuleType.Pushing, dir,
189-
[new WhenDo(2, 2, [],
190-
[new Command(CommandType.Move, dir),
191-
new Command(CommandType.Paint, spaceId) ]),
192-
new WhenDo(2 + tileworld.moveXdelta(dir), 2+tileworld.moveYdelta(dir), playerMove, []) ]
193-
);
194-
}
195-
196-
let playerMoveBoulderRight = new Rule([playerId], RuleType.Pushing, MoveDirection.Right,
197-
[new WhenDo(2, 2, [], moveRight), boulderRight, TileAt(spaceId, 4, 2)]
198-
);
199-
200-
let playerMoveBoulderLeft = new Rule([playerId], RuleType.Pushing, MoveDirection.Left,
201-
[new WhenDo(2, 2, [], moveLeft), boulderLeft, TileAt(spaceId, 0, 2)]
202-
);
203-
204-
let boulderFallDown = new Rule([boulderId], RuleType.Resting, MoveDirection.Left,
205-
[new WhenDo(2, 2, [], [new Command(CommandType.Move, MoveDirection.Down)]), TileAt(spaceId, 2, 3)]
206-
);
207-
208-
let boulderFallingDown = new Rule([boulderId], RuleType.Moving, MoveDirection.Down,
209-
[new WhenDo(2, 2, [], [new Command(CommandType.Move, MoveDirection.Down)]), tp]
210-
);
211-
212-
let boulderFallLeft: Rule = new Rule([boulderId], RuleType.Resting, MoveDirection.Left,
213-
[new WhenDo(2, 2, [], [new Command(CommandType.Move, MoveDirection.Left)]),
214-
SpriteAt(boulderId, 2, 3), TileAt(spaceId, 1, 2), TileAt(spaceId,1,3) ]
215-
);
216-
217-
export let project = new tileworld.Project(
218-
"TW1-",
219-
fixed,
220-
movable,
221-
tileworld.makeIds([boulderFallDown, boulderFallLeft, boulderFallingDown,
222-
playerPaint, playerMoveRule(0), playerMoveRule(1), playerMoveRule(2), playerMoveRule(3),
223-
playerMoveBoulderRight, playerMoveBoulderLeft])
224-
);
225-
let world = image.create(32, 24);
226-
world.fill(2);
227-
world.drawRect(0, 0, 32, 24, 1);
228-
project.setWorld(world);
229-
let sprites = image.create(32, 24);
230-
sprites.fill(0xf);
231-
sprites.setPixel(4,4,4);
232-
project.setSprites(sprites);
233-
project.setPlayer(playerId);
234-
*/
235-
}
1+
// test code here

‎utilities.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Add your code here
2-
31
namespace tileworld {
42

53
const zeroCode = "0".charCodeAt(0);

0 commit comments

Comments
 (0)