Check-in [cd0c5b8aa0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add basic cursor moving around.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cd0c5b8aa02371f31984eeaa30ee9c65457541a5
User & Date: stephanie.gawroriski 2019-07-02 17:01:30
Context
2019-07-02
22:49
Fill in randomly with noise. check-in: d0df7a244d user: stephanie.gawroriski tags: trunk
17:01
Add basic cursor moving around. check-in: cd0c5b8aa0 user: stephanie.gawroriski tags: trunk
16:44
Caching and drawing of background tiles. check-in: 74ac124f83 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/GameInterface.java.

44
45
46
47
48
49
50




















51
52
53
54
55
56
57
...
143
144
145
146
147
148
149








150
151
152
153
154
155
156
...
164
165
166
167
168
169
170
171


172


































































		
		// Initialize variables
		this.game = __g;
		
		// Setup canvas view and such
		this.setTitle("Squirrel Quarrel");
	}




















	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected final void paint(Graphics __g)
................................................................................
				
				// Get the byte code for this tile
				byte b = tiles[bbase + x];
				
				// Draw background tile
				__g.drawImage(TileMap.imageBackground(b), lx, ly, 0);
				








				// Draw cursor box?
				if (cx == x && cy == y)
				{
					// Draw solid line
					__g.setStrokeStyle(Graphics.SOLID);
					__g.setColor(0xFFFF00);
					__g.drawRect(lx, ly,
................................................................................
					
					// Make it solid again
					__g.setStrokeStyle(Graphics.SOLID);
				}
			}
		}
	}
}












































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
		
		// Initialize variables
		this.game = __g;
		
		// Setup canvas view and such
		this.setTitle("Squirrel Quarrel");
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyPressed(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/02
	 */
	@Override
	protected final void keyRepeated(int __kc)
	{
		this.__inputKey(__kc);
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/07/01
	 */
	@Override
	protected final void paint(Graphics __g)
................................................................................
				
				// Get the byte code for this tile
				byte b = tiles[bbase + x];
				
				// Draw background tile
				__g.drawImage(TileMap.imageBackground(b), lx, ly, 0);
				
				// Draw a basic grid to make things a bit easier to see
				__g.setStrokeStyle(Graphics.DOTTED);
				__g.setColor(0x000000);
				__g.drawLine(lx, ly,
					lx + TileMap.TILE_PIXELS, ly);
				__g.drawLine(lx, ly,
					lx, ly + TileMap.TILE_PIXELS);
				
				// Draw cursor box?
				if (cx == x && cy == y)
				{
					// Draw solid line
					__g.setStrokeStyle(Graphics.SOLID);
					__g.setColor(0xFFFF00);
					__g.drawRect(lx, ly,
................................................................................
					
					// Make it solid again
					__g.setStrokeStyle(Graphics.SOLID);
				}
			}
		}
	}
	
	/**
	 * Handles the specified key.
	 *
	 * @param __kc The key code to handle.
	 * @since 2019/07/02
	 */
	private final void __inputKey(int __kc)
	{
		// Prefer pure game actions, if those are not available fallback to
		// the dial pad. Match traditional SquirrelJME game layout.
		int ga = this.getGameAction(__kc);
		if (ga == 0)
			switch (__kc)
			{
				case Canvas.KEY_NUM1: ga = Canvas.GAME_A; break;
				case Canvas.KEY_NUM2: ga = Canvas.UP; break;
				case Canvas.KEY_NUM3: ga = Canvas.GAME_B; break;
				
				case Canvas.KEY_NUM4: ga = Canvas.LEFT; break;
				case Canvas.KEY_NUM5: ga = Canvas.FIRE; break;
				case Canvas.KEY_NUM6: ga = Canvas.RIGHT; break;
				
				case Canvas.KEY_NUM7: ga = Canvas.GAME_C; break;
				case Canvas.KEY_NUM8: ga = Canvas.DOWN; break;
				case Canvas.KEY_NUM9: ga = Canvas.GAME_D; break;
			}
		
		// Ignore invalid actions
		if (ga == 0)
			return;
		
		// Stuff actions could be performed on
		MutablePoint cursor = this.cursor;
		Game game = this.game;
		TileMap tilemap = game.tilemap;
		
		// Perform the actions
		switch (ga)
		{
				// Cursor up
			case Canvas.UP:
				if (--cursor.y < 0)
					cursor.y = 0;
				break;
				
				// Cursor left
			case Canvas.LEFT:
				if (--cursor.x < 0)
					cursor.x = 0;
				break;
				
				// Cursor Right
			case Canvas.RIGHT:
				if (++cursor.x >= tilemap.tilewidth)
					cursor.x = tilemap.tilewidth - 1;
				break;
				
				// Cursor Down
			case Canvas.DOWN:
				if (++cursor.y >= tilemap.tileheight)
					cursor.y = tilemap.tileheight - 1;
				break;
		}
		
		// Do repaint the view!
		this.repaint();
	}
}