#define MOUSE_LEFT_MARGIN 80
#define MOUSE_RIGHT_MARGIN (560-32)
-/* right_margin should noticed that the cursor is 32 pixels,
- so it should subtract that value */
-#define MOUSE_POS_SPEED 20
+
+/* scolling speed */
+#define KEYBOARD_SPEED 140
+#define MOUSE_SPEED 40
/* look */
#define SELECT_W 2 // size of the selections lines
{
int i;
i = false;
+ le_level_changed = true;
le_world->get_level()->name = level_settings_menu->get_item_by_id(MNID_NAME).input;
le_world->get_level()->author = level_settings_menu->get_item_by_id(MNID_AUTHOR).input;
mini_tile_width = 1;
int left_offset = (screen->w - 64 - le_world->get_level()->width*mini_tile_width) / 2;
- for (int y = 0; y < 15; ++y)
+ int mini_tile_height;
+ if(screen->h - 64 > le_world->get_level()->height * 4)
+ mini_tile_height = 4;
+ else if(screen->h - 64 > le_world->get_level()->height * 2)
+ mini_tile_height = 2;
+ else
+ mini_tile_height = 1;
+
+ for (int y = 0; y < le_world->get_level()->height; ++y)
for (int x = 0; x < le_world->get_level()->width; ++x)
{
}
- fillrect(left_offset, 0, le_world->get_level()->width*mini_tile_width, 15*4, 200, 200, 200, 128);
+ fillrect(left_offset, 0, le_world->get_level()->width*mini_tile_width, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 128);
fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 19*mini_tile_width, 2, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 2, 15*4, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width + 19*mini_tile_width - 2, 0, 2, 15*4, 200, 200, 200, 200);
- fillrect(left_offset + (pos_x/32)*mini_tile_width, 15*4-2, 19*mini_tile_width, 2, 200, 200, 200, 200);
+ fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
+ fillrect(left_offset + (pos_x/32)*mini_tile_width + 19*mini_tile_width - 2, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
+ fillrect(left_offset + (pos_x/32)*mini_tile_width, le_world->get_level()->height*mini_tile_height-2, 19*mini_tile_width, 2, 200, 200, 200, 200);
}
/* draw a grid (if selected) */
if(le_show_grid)
{
- for(x = 0; x < 19; x++)
+ for(x = 0; x < VISIBLE_TILES_X; x++)
fillrect(x*32 - ((int)pos_x % 32), 0, 1, screen->h, 225, 225, 225,255);
- for(y = 0; y < 15; y++)
- fillrect(0, y*32 - ((int)pos_y % 32), screen->w - 32, 1, 225, 225, 225,255);
+ for(y = 0; y < VISIBLE_TILES_Y; y++)
+ fillrect(0, y*32 - ((int)pos_y % 32), screen->w, 1, 225, 225, 225,255);
}
}
if(le_current.IsTile())
{
- Tile::draw(19 * 32, 14 * 32, le_current.tile);
+ Tile::draw(screen->w - 32, screen->h - 32, le_current.tile);
if(TileManager::instance()->get(le_current.tile)->editor_images.size() > 0)
- TileManager::instance()->get(le_current.tile)->editor_images[0]->draw( 19 * 32, 14 * 32);
+ TileManager::instance()->get(le_current.tile)->editor_images[0]->draw( screen->w - 32, screen->h - 32);
}
if(le_current.IsObject() && MouseCursor::current() != mouse_select_object)
{
- le_current.obj->draw_on_screen(19 * 32, 14 * 32);
+ le_current.obj->draw_on_screen(screen->w - 32, screen->h - 32);
le_current.obj->draw_on_screen(cursor_x,cursor_y);
}
void le_drawlevel()
{
- unsigned int y,x,s;
+ unsigned int y,x;
Uint8 a;
/* Draw the real background */
- if(le_world->get_level()->bkgd_image[0] != '\0')
- {
- s = (int)((float)pos_x * ((float)le_world->get_level()->bkgd_speed/100.0f)) % screen->w;
- le_world->get_level()->img_bkgd->draw_part(s,0,0,0,
- le_world->get_level()->img_bkgd->w - s - 32, le_world->get_level()->img_bkgd->h);
- le_world->get_level()->img_bkgd->draw_part(0,0,screen->w - s - 32 ,0,s,
- le_world->get_level()->img_bkgd->h);
- }
+ if (le_world->get_level()->img_bkgd)
+ le_world->get_level()->draw_bg();
else
- {
drawgradient(le_world->get_level()->bkgd_top, le_world->get_level()->bkgd_bottom);
- }
if(le_current.IsTile())
{
/* clearscreen(current_level.bkgd_red, current_level.bkgd_green, current_level.bkgd_blue); */
- for (y = 0; y < 15; ++y)
- for (x = 0; x < 20; ++x)
+ for (y = 0; y < VISIBLE_TILES_Y && y < (unsigned)le_world->get_level()->height; ++y)
+ for (x = 0; x < (unsigned)VISIBLE_TILES_X - 2; ++x)
{
if(active_tm == TM_BG)
/* draw whats inside stuff when cursor is selecting those */
/* (draw them all the time - is this the right behaviour?) */
- Tile* edit_image = TileManager::instance()->get(le_world->get_level()->ia_tiles[y + (int)(pos_x / 32)][x + (int)(pos_x / 32)]);
+ Tile* edit_image = TileManager::instance()->get(le_world->get_level()->ia_tiles[y + (int)(pos_y / 32)][x + (int)(pos_x / 32)]);
if(edit_image && !edit_image->editor_images.empty())
edit_image->editor_images[0]->draw( x * 32 - ((int)pos_x % 32), y*32 - ((int)pos_y % 32));
switch(le_move_left_bt->get_state())
{
case BUTTON_PRESSED:
- pos_x -= 192;
+ pos_x -= KEYBOARD_SPEED;
show_minimap = true;
break;
case BUTTON_HOVER:
- pos_x -= 32;
+ pos_x -= MOUSE_SPEED;
show_minimap = true;
break;
case BUTTON_CLICKED:
switch(le_move_right_bt->get_state())
{
case BUTTON_PRESSED:
- pos_x += 192;
+ pos_x += KEYBOARD_SPEED;
show_minimap = true;
break;
case BUTTON_HOVER:
- pos_x += 32;
+ pos_x += MOUSE_SPEED;
show_minimap = true;
break;
case BUTTON_CLICKED:
switch(le_move_up_bt->get_state())
{
case BUTTON_PRESSED:
- pos_y += 192;
+ pos_y -= KEYBOARD_SPEED;
show_minimap = true;
break;
case BUTTON_HOVER:
- pos_y += 32;
+ pos_y -= MOUSE_SPEED;
show_minimap = true;
break;
case BUTTON_CLICKED:
switch(le_move_down_bt->get_state())
{
case BUTTON_PRESSED:
- pos_y -= 192;
+ pos_y += KEYBOARD_SPEED;
show_minimap = true;
break;
case BUTTON_HOVER:
- pos_y -= 32;
+ pos_y += MOUSE_SPEED;
show_minimap = true;
break;
case BUTTON_CLICKED:
}
/* checking if pos_x and pos_y is within the limits... */
+ if(pos_x > (le_world->get_level()->width * 32 + 32*2) - screen->w)
+ pos_x = (le_world->get_level()->width * 32 + 32*2) - screen->w;
if(pos_x < 0)
pos_x = 0;
- if(pos_x > (le_world->get_level()->width * 32) - screen->w)
- pos_x = (le_world->get_level()->width * 32) - screen->w;
- if(pos_y < 0)
- pos_y = 0;
if(pos_y > (le_world->get_level()->height * 32) - screen->h)
pos_y = (le_world->get_level()->height * 32) - screen->h;
+ if(pos_y < 0)
+ pos_y = 0;
}