diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 09:40:40 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-01-30 09:40:40 -0500 |
commit | aa3d2a1e1d13b04a8c5801629e077668214bc3ff (patch) | |
tree | 91b616e4527259368f368c23ce2cf525544e5bf5 /src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java | |
parent | 58c3529f14de0e5142e0ba0927d3c7aa9288c799 (diff) | |
download | fourpuzzle-aa3d2a1e1d13b04a8c5801629e077668214bc3ff.tar.gz fourpuzzle-aa3d2a1e1d13b04a8c5801629e077668214bc3ff.tar.bz2 fourpuzzle-aa3d2a1e1d13b04a8c5801629e077668214bc3ff.zip |
Added viewpoint scrolling
Now, maps can be larger than (20,15) and the map will scroll as the hero walks across the middle. However, Southward and Eastward middle-traversing appears to warp reality just a little and there are a few kinks that need to be straightened out. Map layer caching has also been added because the lower and upper layers of a map never change, so they are cached after the first rendering.
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java index bc0073e..d02c7ed 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/Map.java | |||
@@ -11,6 +11,8 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.EventList; | |||
11 | import com.fourisland.fourpuzzle.gamestate.mapview.event.HeroEvent; | 11 | import com.fourisland.fourpuzzle.gamestate.mapview.event.HeroEvent; |
12 | import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; | 12 | import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; |
13 | import java.awt.Dimension; | 13 | import java.awt.Dimension; |
14 | import java.awt.Graphics2D; | ||
15 | import java.awt.image.BufferedImage; | ||
14 | import java.util.HashMap; | 16 | import java.util.HashMap; |
15 | import java.util.Vector; | 17 | import java.util.Vector; |
16 | 18 | ||
@@ -185,4 +187,61 @@ public abstract class Map { | |||
185 | this.music = music; | 187 | this.music = music; |
186 | } | 188 | } |
187 | 189 | ||
190 | BufferedImage lowerLayer = null; | ||
191 | public BufferedImage renderLower() | ||
192 | { | ||
193 | if (lowerLayer == null) | ||
194 | { | ||
195 | lowerLayer = new BufferedImage(size.width*16, size.height*16, BufferedImage.TYPE_INT_ARGB); | ||
196 | Graphics2D g = lowerLayer.createGraphics(); | ||
197 | ChipSet chipSetObj = ChipSet.getChipSet(chipSet); | ||
198 | int i,x,y; | ||
199 | for (i=0;i<mapData.size();i++) | ||
200 | { | ||
201 | for (y=0;y<size.height;y++) | ||
202 | { | ||
203 | for (x=0;x<size.width;x++) | ||
204 | { | ||
205 | int tile = mapData.get(i).get(x+(y*size.width)); | ||
206 | if (chipSetObj.getChipSetData().get(tile).getLayer() != Layer.Above) | ||
207 | { | ||
208 | g.drawImage(chipSetObj.getImage(tile), x*16, y*16, null); | ||
209 | } | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | |||
215 | return lowerLayer; | ||
216 | |||
217 | } | ||
218 | |||
219 | BufferedImage upperLayer = null; | ||
220 | public BufferedImage renderUpper() | ||
221 | { | ||
222 | if (upperLayer == null) | ||
223 | { | ||
224 | upperLayer = new BufferedImage(size.width*16, size.height*16, BufferedImage.TYPE_INT_ARGB); | ||
225 | Graphics2D g = upperLayer.createGraphics(); | ||
226 | ChipSet chipSetObj = ChipSet.getChipSet(chipSet); | ||
227 | int i,x,y; | ||
228 | for (i=0;i<mapData.size();i++) | ||
229 | { | ||
230 | for (y=0;y<size.height;y++) | ||
231 | { | ||
232 | for (x=0;x<size.width;x++) | ||
233 | { | ||
234 | int tile = mapData.get(i).get(x+(y*size.width)); | ||
235 | if (chipSetObj.getChipSetData().get(tile).getLayer() == Layer.Above) | ||
236 | { | ||
237 | g.drawImage(chipSetObj.getImage(tile), x*16, y*16, null); | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | |||
244 | return upperLayer; | ||
245 | } | ||
246 | |||
188 | } | 247 | } |