name = "UnNamed";
author = "UnNamed";
song_title = "Mortimers_chipdisko.mod";
- bkgd_image = "arctis.png";
+ bkgd_image = "arctis.jpg";
width = 0;
height = 0;
start_pos_x = 100;
writer.start_list("point");
writer.write_int("x", i->x);
writer.write_int("y", i->y);
+ writer.end_list("point");
}
writer.end_list("reset-points");
void
Level::resize(int new_width, int new_height)
{
- // first: resize height
- ia_tiles.resize(new_height * width, 0);
- bg_tiles.resize(new_height * width, 0);
- fg_tiles.resize(new_height * width, 0);
- height = new_height;
+ if(new_width < width) {
+ // remap tiles for new width
+ for(int y = 0; y < height && y < new_height; ++y) {
+ for(int x = 0; x < new_width; ++x) {
+ ia_tiles[y * new_width + x] = ia_tiles[y * width + x];
+ bg_tiles[y * new_width + x] = bg_tiles[y * width + x];
+ fg_tiles[y * new_width + x] = fg_tiles[y * width + x];
+ }
+ }
+ }
- // remap horizontal tiles for new width
- int np = 0;
- for(int y = 0; y < height; ++y) {
- for(int x = 0; x < new_width && x < width; ++x) {
- ia_tiles[np] = ia_tiles[y * width + x];
- bg_tiles[np] = bg_tiles[y * width + x];
- fg_tiles[np] = fg_tiles[y * width + x];
- np++;
+ ia_tiles.resize(new_width * new_height);
+ bg_tiles.resize(new_width * new_height);
+ fg_tiles.resize(new_width * new_height);
+
+ if(new_width > width) {
+ // remap tiles
+ for(int y = std::min(height, new_height)-1; y >= 0; --y) {
+ for(int x = new_width-1; x >= 0; --x) {
+ if(x >= width) {
+ ia_tiles[y * new_width + x] = 0;
+ bg_tiles[y * new_width + x] = 0;
+ fg_tiles[y * new_width + x] = 0;
+ } else {
+ ia_tiles[y * new_width + x] = ia_tiles[y * width + x];
+ bg_tiles[y * new_width + x] = bg_tiles[y * width + x];
+ fg_tiles[y * new_width + x] = fg_tiles[y * width + x];
+ }
+ }
}
}
- ia_tiles.resize(new_height * new_width);
- bg_tiles.resize(new_height * new_width);
- fg_tiles.resize(new_height * new_width);
-
+ height = new_height;
width = new_width;
}
}
}
-void Level::draw_bg()
-{
- if(img_bkgd)
- {
- // Tile background horizontally
- int sx = (int)((float)scroll_x * ((float)bkgd_speed/100.0f)) % img_bkgd->w;
- int sy = (int)((float)scroll_y * ((float)bkgd_speed/100.0f)) % img_bkgd->h;
- for (int x = 0; (x-1)*img_bkgd->w <= screen->w; x++)
- for (int y = 0; (y-1)*img_bkgd->h <= screen->h; y++)
- img_bkgd->draw_part(x == 0 ? sx : 0, y == 0 ? sy : 0,
- x == 0 ? 0 : (img_bkgd->w * x) - sx, y == 0 ? 0 : (img_bkgd->h * y) - sy,
- x == 0 ? img_bkgd->w - sx : img_bkgd->w, y == 0 ? img_bkgd->h - sy : img_bkgd->h);
- }
- else
- {
- drawgradient(bkgd_top, bkgd_bottom);
- }
-}
-
void
Level::load_song()
{