mirror of
https://github.com/Febbweiss/sis.git
synced 2026-03-05 06:35:37 +00:00
Optim: better way to manage offset for each wave rows
This commit is contained in:
@@ -30,11 +30,19 @@ Game = {
|
|||||||
var row, col, wave = Game.wave.wave;
|
var row, col, wave = Game.wave.wave;
|
||||||
|
|
||||||
for (row = 0; row < wave.length; row = row + 1) {
|
for (row = 0; row < wave.length; row = row + 1) {
|
||||||
var aliensRow = wave[row],
|
var alien_width_avg = 0,
|
||||||
offset = (PLAYGROUND_WIDTH - ((aliensRow.length - 1) * 0.5 + aliensRow.length) * ALIENS_WIDTH) / 2;
|
aliens_row = wave[row],
|
||||||
|
offset = 0;
|
||||||
for (col = 0; col < aliensRow.length; col = col + 1) {
|
|
||||||
Game.setAlien(col, row, col * wave.length + row, offset, aliensRow[col], Game.wave.move);
|
for (col = 0; col < aliens_row.length; col = col + 1) {
|
||||||
|
alien_width_avg = alien_width_avg + aliens_row[col].animation.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
alien_width_avg = alien_width_avg / aliens_row.length;
|
||||||
|
offset = (PLAYGROUND_WIDTH - (aliens_row.length * 1.5 - 0.5) * alien_width_avg) / 2;
|
||||||
|
|
||||||
|
for (col = 0; col < aliens_row.length; col = col + 1) {
|
||||||
|
Game.setAlien(col, row, col * wave.length + row, offset, aliens_row[col], Game.wave.move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user