Сообщение от qwert_ukg
|
да и есть соображения по поводу избавления от тормозов (ФПС ужасен)
|
ну а что вы хотели? Подобные конструкции не есть гуд
space.innerHTML +=
'<div id="ship" style="left:' + ship.x + 'px;bottom:' + ship.y + 'px">\
<table border="0" cellspacing="0" cellpadding="0">\
<tr>\
<td></td>\
<td class="top">\
<div class="fire_l" style="display: ' + ship.fire_l + ';"></div>\
</td>\
<td rowspan="2" style="vertical-align: bottom; height: 36px;">\
<div id="body"></div>\
</td>\
<td class="top">\
<div class="fire_r" style="display: ' + ship.fire_r + ';"></div>\
</td>\
<td></td>\
</tr>\
<tr>\
<td rowspan="2" class="ship_left">\
<div id="left_engine_1" style="display: ' + ship.engine_l_1 + ';"></div>\
<div id="left_engine_2" style="display: ' + ship.engine_l_2 + ';"></div>\
</td>\
<td rowspan="2" style="vertical-align:bottom;">\
<div id="body_left"></div>\
</td>\
<td rowspan="2" style="vertical-align:bottom;">\
<div id="body_right"></div>\
</td>\
<td class="ship_right" rowspan="2">\
<div id="right_engine_1" style="display: ' + ship.engine_r_1 + ';"></div>\
<div id="right_engine_2" style="display: ' + ship.engine_r_2 + ';"></div>\
</td>\
</tr>\
<tr>\
<td class="ship_bottom" rowspan="2">\
<div id="engine_1" style="display: ' + ship.engine_1 + ';"></div>\
<div id="engine_2" style="display: ' + ship.engine_2 + ';"></div>\
<div id="main_engine_1" style="display: ' + ship.engine_m_1 + ';"></div>\
<div id="main_engine_2" style="display: ' + ship.engine_m_2 + ';"></div>\
</td>\
</tr>\
<tr>\
<td></td>\
<td class="ship_bottom_left">\
<div id="left_engine_f_1" style="display: ' + ship.left_engine_f_1 + ';"></div>\
<div id="left_engine_f_2" style="display: ' + ship.left_engine_f_2 + ';"></div>\
</td>\
<td class="ship_bottom_right">\
<div id="right_engine_f_1" style="display: ' + ship.right_engine_f_1 + ';"></div>\
<div id="right_engine_f_2" style="display: ' + ship.right_engine_f_2 + ';"></div>\
</td>\
<td></td>\
</tr>\
</table>\
</div>';
}
это можно сократить/оптимизировать
if(ship.engine_1 == 'block'){
ship.engine_1 = 'none';
ship.engine_2 = 'block';
}else{
ship.engine_2 = 'none';
ship.engine_1 = 'block';
}
}else{
ship.engine_1 = 'none';
ship.engine_2 = 'none';
}
if(ship.engine_m == true){
if(ship.engine_m_1 == 'block'){
ship.engine_m_1 = 'none';
ship.engine_m_2 = 'block';
}else{
ship.engine_m_2 = 'none';
ship.engine_m_1 = 'block';
}
}else{
ship.engine_m_1 = 'none';
ship.engine_m_2 = 'none';
}
if(ship.engine_r == true){
if(ship.engine_r_1 == 'block'){
ship.engine_r_1 = 'none';
ship.engine_r_2 = 'block';
}else{
ship.engine_r_2 = 'none';
ship.engine_r_1 = 'block';
}
}else{
ship.engine_r_1 = 'none';
ship.engine_r_2 = 'none';
}
if(ship.engine_l == true){
if(ship.engine_l_1 == 'block'){
ship.engine_l_1 = 'none';
ship.engine_l_2 = 'block';
}else{
ship.engine_l_2 = 'none';
ship.engine_l_1 = 'block';
}
}else{
ship.engine_l_1 = 'none';
ship.engine_l_2 = 'none';
}
if(ship.left_engine_f == true){
if(ship.left_engine_f_1 == 'block'){
ship.left_engine_f_1 = 'none';
ship.left_engine_f_2 = 'block';
}else{
ship.left_engine_f_2 = 'none';
ship.left_engine_f_1 = 'block';
}
}else{
ship.left_engine_f_1 = 'none';
ship.left_engine_f_2 = 'none';
}
if(ship.right_engine_f == true){
if(ship.right_engine_f_1 == 'block'){
ship.right_engine_f_1 = 'none';
ship.right_engine_f_2 = 'block';
}else{
ship.right_engine_f_2 = 'none';
ship.right_engine_f_1 = 'block';
}
}else{
ship.right_engine_f_1 = 'none';
ship.right_engine_f_2 = 'none';
}
if(ship.fire == true){
if(ship.fire_l == 'block'){
ship.fire_l = 'none';
ship.fire_r = 'block';
}else{
ship.fire_r = 'none';
ship.fire_l = 'block';
}
}else{
ship.fire_r = 'none';
ship.fire_l = 'none';
}
В целом (личное мое впечатление) мало ООП