forums

TNT Basic Forums > Programming Q&A
Map Viewport Problems
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-25-2003 00:10

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

It seems that whenever I Open Map Viewport, sections of the map are at first drawn with the same image as the tile about 10 or so tiles above them, then when you scroll away from them so that they are off-screen and then come back, they are drawn correctly. It's very strange and annoying. I don't modify map tiles during my game, so I have no idea what's causing it. Could it be a bug?

10-25-2003 03:36

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

I doubt it. Just check your code and make sure you clear the canvas before you draw it, are NOT using "draw map section", etc.

10-25-2003 05:35

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

No, I use a Map Viewport, not a normal viewport, so I wouldn't have to make/clear a canvas, or use 'Draw Map Section'. Unless you mean I have to clear canvas 0 before I open a Map Viewport?

10-25-2003 07:02

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Argh!

Ok... this is very bad...

The uDG deadline is really soon and whenever you start a game, sections of the ground are drawn as sky until they are offscreen (out of the Map Viewport bounds), whereapon they are corrected. Is there anything that could cause this at all? I'm getting really desperate...

I the only map commands present in the entire piece of code are Load Map, Open Map Viewport, Close Viewport and Unload Map.

There are no 'Draw Map Section' or 'Set Map Tile' commands or anything, nothing which I imagine could produce such effects. Help!

10-25-2003 14:00

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Are you using hardware mode on OS 8.6 ? This often causes horrible graphics bugs.

10-25-2003 14:47

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

If you can post some code I can look at it.

10-26-2003 04:48

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Nope, not using 8.6, not using Hardware mode.

I'm using OS X in software, and the same problem occurs in OS 9.

10-26-2003 05:27

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

If you can be bothered, I'd really appreciate it.

Here is the main game part: (I've excluded most things which have no relevance to the drawing of the map viewport, otherwise it would be ridiculously long)


***

Fade Down
Hide Mouse
LoadMap(map)
DrawFrame(false, false, false, -1)
Fade Up

'note: there woud usually be a couple of procedure calls here to set up the level and characters, once they are loaded they are automated by DrawFrame.

repeat

DrawFrame(false,false,false,-1)

until endlv

DrawFrame(true,true,1,3)
Fade Down
Show Mouse
UnloadMap(map)
Sprite Off
DrawFrame(true,true,1,3)
Fade Up

***

Ok. DrawFrame moves all the sprites, manages the sound/music, scrolls the map, and then, coincidently enough, draws the frame. Here is the part of DrawFrame which controls the map scrolling:

***

if thunderprev=true 'thunderprev is whether or not there was a flash of thunder last frame. if there was, the viewport would have had to been closed, so that the whole canvas could be painted white.
Open Map Viewport 1,0,0,0 to frame[0],frame[1]
thunderprev=false
end if
ScrollMap() 'scrollmap updates frame[7] and frame[8], the variables for the X and Y offset of the viewport. it does not actually change anything except those variables.

if frame[7]+Viewport Width(1)>MapWidth*MapTileWidth ' this part makes sure the viewport is within the bounds of the map
frame[7]=(MapWidth*MapTileWidth)-Viewport Width(1)
end if
if frame[7]<0
frame[7]=0
end if
if frame[8]+Viewport Height(1)>MapHeight*MapTileHeight
frame[8]=(MapHeight*MapTileHeight)-Viewport Height(1)
end if
if frame[8]<0
frame[8]=0
end if

Set Viewport Offset 1,frame[7],frame[8]

WeatherManager() ' controls rain/snow/leaf sprites
HandleSprites() ' controls player and enemy sprites
' neither actually change the map viewport, but HandleSprites changes frame[7] and frame[8] (so that the viewport focuses on the player sprite)

***

LoadMap, which is called at the start of the game to setup the map, always has the glitch without fail. when it opens the map, it draws the bottom 2 rows of tiles which the image of the tile 10 squares above it. the tiles, as i mentioned before, automatically correct themselves once they are off-screen. Here is the LoadMap Procedure (in full)

***

Load Map id+128
Open Map Viewport 1,0,0,0 to frame[0],frame[1]
fade down
Draw Frame
fade up
frame[5]=id ' frame[5] contains the id of the current map.

***

Sorry if I haven't explained it very well. If you need clarification on anything just ask.

If anyone can be bothered reading through 3000 lines of code and wants to help me out, I could send the full code to you.

I'm just completely out of ideas. Nowhere in my code do I refer to on- and off-screen tiles, let alone change any tiles, so while it doesn't make sense that the problem's there in the first place, it makes even less sense that the tiles correct themselves after being off-screen... Maybe my maps are corrupted...

10-26-2003 06:07

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Hm, ok, so the map tiles at the bottom remain incorrect until they go offscreen, right? Meaning that you can scroll in the other direction and they remain incorrect?

It seems like something was drawn in the canvas with the map; that would explain why it dissapears when the section goes offscreen and the map is redrawn. Make sure that you're not drawing anything on the canvas with the map in it.

10-26-2003 07:25

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

I didn't know you could draw onto a Map Viewport canvas.

Well, after an incredible amount of experimentation, I've narrowed it down:

When the Map Viewport is initially opened,

Tiles from the bottom three rows of the map are drawn with the pictures of tiles about 12 squares above them.

Tiles from the top eleven rows of the map are drawn with a repetitive pattern of tiles which is taken from 17 tiles in from the left at the same height.

The tiles are corrected if they are not visible at the Draw Frame command. So randomly scrolling around for a bit without actually drawing a frame does not fix it.


This is confusing the hell out of me... It's got to be a bug... Nothing in my code even remotely resembles what's going on here...

10-26-2003 07:27

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Oh yeah, I forgot to mention that the tiles are only corrected if they are either above, to the left, or to the right of the Map Viewport. for some reason if you scroll above the messed up tiles (so they are below the viewport), it doesn't correct them.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.