The STLamp script was misaligned for some reason, so I managed to fix that.
Started working on goat tiles? Don't know how to do the proportions just yet.
Rebuilt STWaitframe to properly capture screen changes. It tells you which direction the screen is scrolling, as well as what screen locating info has changed.
Added off-screen rendering to lamp script. It didn't work, so I took it out. Need to play with it some more.
}
So I've been trying to fix my Lamp script, since it's a seemingly easy idea and gives a lot of play. In order to do it, though, I need to know whether or not link is walking into a dark screen, since if he is, you don't want the whole screen visible while scrolling into and out of it. To grab that info, this is basically what my Waitframe() wrapper looks like. It's going to eventually be double-stacked when I include ghosted enemies, since it has it's own Waitframe() wrapper... But I suspect this could be a generally useful script.
// Global Variable Declarations (Fold)
bool updateScreenChangeData = true;
int ScreenChangeData[8]; // Global screen change info.
// Indices for Screen Change data:
const int SCI_TYPE = 0; // How has the screen changed? Uses SCV_ constants.
const int SCI_DIRECTION = 1; // Uses DIR_ constants.
const int SCI_PREVSCREEN = 2; // Number of previous screen.
const int SCI_PREVMAP = 3; // Number of previous map.
const int SCI_PREVDMAPSCREEN = 4; // Number of previous dmap.
const int SCI_PREVDMAP = 5; // Number of previous dmap.
const int SCI_PREVTYPE = 6; // How has the screen changed? Uses SCV_ constants.
const int SCI_PREVDIRECTION = 7; // Uses DIR_ constants or SCV_NONE.
// Values for Screen change data:
const int SCV_NONE = -1;
const int SCV_NOCHANGE = 0;
const int SCV_SCREENCHANGED = 1;
const int SCV_MAPCHANGED = 2;
const int SCV_DMAPSCREENCHANGED = 4;
const int SCV_DMAPCHANGED = 8;
//(End Fold)
//Global Function Declarations (Fold)
void STWaitframe() {
// Store old screen change data.
if(updateScreenChangeData){
ScreenChangeData[SCI_PREVSCREEN] = Game->GetCurScreen();
ScreenChangeData[SCI_PREVDMAPSCREEN] = Game->GetCurDMapScreen();
ScreenChangeData[SCI_PREVDMAP] = Game->GetCurDMap();
ScreenChangeData[SCI_PREVMAP] = Game->GetCurMap();
ScreenChangeData[SCI_PREVTYPE] = ScreenChangeData[SCI_TYPE];
ScreenChangeData[SCI_PREVDIRECTION] = ScreenChangeData[SCI_DIRECTION];
updateScreenChangeData = false;
}
Waitframe();
ScreenChangeData[SCI_TYPE] = SCV_NOCHANGE;
ScreenChangeData[SCI_DIRECTION] = SCV_NONE;
// Check all the ways the the screen has chenged:
if(ScreenChangeData[SCI_PREVSCREEN] != Game->GetCurScreen()){
ScreenChangeData[SCI_TYPE] = SCV_SCREENCHANGED;
updateScreenChangeData = true;
}
if(ScreenChangeData[SCI_PREVDMAPSCREEN] != Game->GetCurDMapScreen()){
ScreenChangeData[SCI_TYPE] = SCV_DMAPSCREENCHANGED;
updateScreenChangeData = true;
}
if(ScreenChangeData[SCI_PREVMAP] != Game->GetCurMap()){
ScreenChangeData[SCI_TYPE] = SCV_MAPCHANGED;
updateScreenChangeData = true;
}
if(ScreenChangeData[SCI_PREVDMAP] != Game->GetCurDMap()){
ScreenChangeData[SCI_TYPE] = SCV_DMAPCHANGED;
updateScreenChangeData = true;
}
// If link is off screen (during scrolling), find out which direction
// we are scrolling in.
if(Link->X < 0){
ScreenChangeData[SCI_DIRECTION] = DIR_RIGHT;
} else if(Link->Y < 0) {
ScreenChangeData[SCI_DIRECTION] = DIR_DOWN;
} else if(Link->X > 240) {
ScreenChangeData[SCI_DIRECTION] = DIR_LEFT;
} else if(Link->Y > 160) {
ScreenChangeData[SCI_DIRECTION] = DIR_UP;
} else {
ScreenChangeData[SCI_DIRECTION] = SCV_NONE;
}
}
Some design notes on the Lamp Script:The main motivation for the script is the fact that I'm using a 100% 8-bit palette, which means dark room coloring is either impossible or stupid-hard to control. Plus, if I wanted to do temporary lighting, or room lighting only when a torch is lit, I'd have to either make my own lamp or my own dark-room script anyway. This extra control would probably be a boon to an independent lamp item anyway. I think everyone can agree that Z1 lamp and dark room behavior is a little antiquated? My only real complaint is the fact that I don't have variable opacity, so we can't do the fade in/out effect. But really, it's not necessary.
I will probably eventually expand the script to have multiple ranges of lamp-light. Mostly because, without a lamp, you shouldn't really be able to see anything. But it would be cool to let Link see in a small circle around him. Or to buy a brighter lamp later. So many exciting options!


