1234 |
int sx, sy; |
int sx, sy; |
1235 |
engine->world_to_screen(point, &sx, &sy); |
engine->world_to_screen(point, &sx, &sy); |
1236 |
|
|
1237 |
|
const int border = 1; |
1238 |
|
bool scrollx_p = (sx < gamearea.x + TileWidth*border) |
1239 |
|
|| (sx >= gamearea.x + gamearea.w - TileWidth*border); |
1240 |
|
|
1241 |
|
bool scrolly_p = (sy < gamearea.y + TileHeight*border) |
1242 |
|
|| (sy >= gamearea.y + gamearea.h - TileHeight*border); |
1243 |
|
|
1244 |
|
if (scrollx_p || scrolly_p) |
1245 |
|
{ |
1246 |
|
V2 olddest = destpos; |
1247 |
|
|
1248 |
|
currently_scrolling = true; |
1249 |
|
curpos = V2(ScrollX, ScrollY); |
1250 |
|
destpos = curpos + point - V2(ScrollX+gamearea.w/TileWidth/2, |
1251 |
|
ScrollY+gamearea.h/TileHeight/2); |
1252 |
|
destpos[0] = int(destpos[0]*TileWidth)/TileWidth; |
1253 |
|
destpos[1] = int(destpos[1]*TileHeight)/TileHeight; |
1254 |
|
destpos[0] = max(0, min((int) destpos[0], |
1255 |
|
engine->get_width()-gamearea.w/TileWidth)); |
1256 |
|
destpos[1] = max(0, min((int) destpos[1], |
1257 |
|
engine->get_height()-gamearea.h/TileHeight)); |
1258 |
|
if (!scrollx_p) |
1259 |
|
destpos[0] = olddest[0]; //ScrollX; |
1260 |
|
if (!scrolly_p) |
1261 |
|
destpos[1] = olddest[1]; //ScrollY; |
1262 |
|
|
1263 |
|
scrollspeed = Max(40.0, length(destpos-curpos)/TileWidth*5); |
1264 |
|
resttime = length(destpos - curpos)/scrollspeed; |
1265 |
|
dir = normalize(destpos - curpos); |
1266 |
|
} |
1267 |
if (currently_scrolling) { |
if (currently_scrolling) { |
1268 |
resttime -= dtime; |
resttime -= dtime; |
1269 |
if (resttime <= 0) { |
if (resttime <= 0) { |
1273 |
curpos += dir * scrollspeed*dtime; |
curpos += dir * scrollspeed*dtime; |
1274 |
engine->move_offset (curpos); |
engine->move_offset (curpos); |
1275 |
} |
} |
|
} else { |
|
|
const int border = 1; |
|
|
bool scrollx_p = (sx < gamearea.x + TileWidth*border) |
|
|
|| (sx >= gamearea.x + gamearea.w - TileWidth*border); |
|
|
|
|
|
bool scrolly_p = (sy < gamearea.y + TileHeight*border) |
|
|
|| (sy >= gamearea.y + gamearea.h - TileHeight*border); |
|
|
|
|
|
if (scrollx_p || scrolly_p) |
|
|
{ |
|
|
currently_scrolling = true; |
|
|
curpos = V2(ScrollX, ScrollY); |
|
|
destpos = curpos + point - V2(ScrollX+gamearea.w/TileWidth/2, |
|
|
ScrollY+gamearea.h/TileHeight/2); |
|
|
destpos[0] = int(destpos[0]*TileWidth)/TileWidth; |
|
|
destpos[1] = int(destpos[1]*TileHeight)/TileHeight; |
|
|
destpos[0] = max(0, min((int) destpos[0], |
|
|
engine->get_width()-gamearea.w/TileWidth)); |
|
|
destpos[1] = max(0, min((int) destpos[1], |
|
|
engine->get_height()-gamearea.h/TileHeight)); |
|
|
if (!scrollx_p) |
|
|
destpos[0] = ScrollX; |
|
|
if (!scrolly_p) |
|
|
destpos[1] = ScrollY; |
|
|
|
|
|
scrollspeed = Max(30, 0); |
|
|
resttime = length(destpos - curpos)/scrollspeed; |
|
|
dir = normalize(destpos - curpos); |
|
|
} |
|
1276 |
} |
} |
1277 |
} |
} |
1278 |
|
|
1612 |
return gamedpy->add_sprite (pos, m); |
return gamedpy->add_sprite (pos, m); |
1613 |
} |
} |
1614 |
|
|
1615 |
|
void display::ToggleFlag(DisplayFlags flag) |
|
void |
|
|
display::ToggleFlag(DisplayFlags flag) |
|
1616 |
{ |
{ |
1617 |
toggle_flags (display_flags, flag); |
toggle_flags (display_flags, flag); |
1618 |
} |
} |