Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Base drawing of the selection box. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
054c4350b4bc204383854ff60ba8b8e1 |
User & Date: | stephanie.gawroriski 2019-07-02 16:33:30 |
Context
2019-07-02
| ||
16:44 | Caching and drawing of background tiles. check-in: 74ac124f83 user: stephanie.gawroriski tags: trunk | |
16:33 | Base drawing of the selection box. check-in: 054c4350b4 user: stephanie.gawroriski tags: trunk | |
15:59 | Add the basic tile type graphics. check-in: 735fc0af48 user: stephanie.gawroriski tags: trunk | |
Changes
Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/GameInterface.java.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
48
49
50
51
52
53
54
55
56
57
|
*/ public final class GameInterface extends Canvas { /** The game this will be drawing and interacting with. */ protected final Game game; /** * Initializes the game interface. * * @param __g The game to interact with. * @throws NullPointerException On null arguments. * @since 2019/07/01 */ ................................................................................ /** * {@inheritDoc} * @since 2019/07/01 */ @Override protected final void paint(Graphics __g) { } } |
>
>
>
>
>
>
|
>
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
*/ public final class GameInterface extends Canvas { /** The game this will be drawing and interacting with. */ protected final Game game; /** The current cursor tile. */ protected final MutablePoint cursor = new MutablePoint(); /** * Initializes the game interface. * * @param __g The game to interact with. * @throws NullPointerException On null arguments. * @since 2019/07/01 */ ................................................................................ /** * {@inheritDoc} * @since 2019/07/01 */ @Override protected final void paint(Graphics __g) { // Get game details to draw Game game = this.game; // Get the canvas dimensions int cw = this.getWidth(), ch = this.getHeight(); // Draw the tile map this.__drawTiles(__g, cw, ch, game.tilemap); } /** * Draws the underlying tilemap. * * @param __g The graphics to draw to. * @param __cw The canvas width. * @param __ch The canvas height. * @param __tilemap The raw tile data. * @throws NullPointerException On null arguments. * @since 2019/07/02 */ private final void __drawTiles(Graphics __g, int __cw, int __ch, TileMap __tilemap) throws NullPointerException { if (__g == null || __tilemap == null) throw new NullPointerException("NARG"); // Size of the map in tiles int mtw = __tilemap.tilewidth, mth = __tilemap.tileheight; // Size of the view in tiles, an extra tile is given so that they are // not clipped off the right side at all! int vtw = (__cw + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS, vth = (__ch + TileMap.TILE_PIXELS_MASK) / TileMap.TILE_PIXELS; // Half of the view, used for centering and capping int vsw = vtw / 2, vsh = vth / 2; // Get the cursor position and determine how that is drawn, the view // is always centered on it for simplicity MutablePoint cursor = this.cursor; int cx = cursor.x, cy = cursor.y, vtx = cx - (vtw / 2), vty = cy - (vth / 2); // Passed bounds on the right side? if (vtx > mtw - vsw) vtx = mtw - vsw; if (vty > mth - vsh) vty = mth - vsh; if (vtx < 0) vtx = 0; if (vty < 0) vty = 0; // End tile positions int etx = vtx + vtw, ety = vty + vth; if (etx > mtw) etx = mtw; if (ety > mth) ety = mth; // Get the background logical tile data byte[] tiles = __tilemap._tiles; // Draw all tiles in the region for (int y = vty; y < ety; y++) { // Logical tile Y on screen int ly = (y - vty) * TileMap.TILE_PIXELS; // Scan in row for (int x = vtx; x < etx; x++) { // Determine logical screen position of file int lx = (x - vtx) * TileMap.TILE_PIXELS; // Draw cursor box? if (cx == x && cy == y) { // Dotted purple box __g.setStrokeStyle(Graphics.DOTTED); __g.setColor(0xFF00FF); __g.drawRect(lx, ly, TileMap.TILE_PIXELS, TileMap.TILE_PIXELS); // Make it solid again __g.setStrokeStyle(Graphics.SOLID); } } } } } |
Added runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/MutablePoint.java.
> > > > > > > > > > > > > > > > > > > > > > > > > |
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 |
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*- // --------------------------------------------------------------------------- // Multi-Phasic Applications: SquirrelJME // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net> // --------------------------------------------------------------------------- // SquirrelJME is under the GNU General Public License v3+, or later. // See license.mkd for licensing and copyright information. // --------------------------------------------------------------------------- package dev.shadowtail.squirrelquarrel; /** * This represents a point which is mutable. * * @since 2019/07/02 */ public final class MutablePoint { /** X position. */ public int x; /** Y position. */ public int y; } |
Changes to runt/mids/squirrel-quarrel/dev/shadowtail/squirrelquarrel/TileMap.java.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
* @since 2019/07/01 */ public final class TileMap { /** Each tile is 16x16 pixels. */ public static final int TILE_PIXELS = 16; /** The size of the map. */ public final MapSize size; /** The width of the map in tiles. */ public final int tilewidth; |
> > > > |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
* @since 2019/07/01 */ public final class TileMap { /** Each tile is 16x16 pixels. */ public static final int TILE_PIXELS = 16; /** Mask for pixels. */ public static final int TILE_PIXELS_MASK = 15; /** The size of the map. */ public final MapSize size; /** The width of the map in tiles. */ public final int tilewidth; |