Skip to content

Commit f283f34

Browse files
author
pushkin
committed
Поправил анимацю взрыва + подбор оригинальных парамеров
1 parent 0276c63 commit f283f34

5 files changed

Lines changed: 29 additions & 21 deletions

File tree

public/src/game.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@ socket.on('state', (state) => {
227227
const isMine = (typeof e.ownerId === 'string') && e.ownerId.startsWith(myId);
228228

229229
if (e.type === 'WALL_HIT') {
230-
createExplosion(e.x, e.y, EXPLOSION_SMALL);
230+
createExplosion(e.x + 2, e.y + 2, EXPLOSION_SMALL);
231231
if (isMine) audio.play('miss_hit');
232232
}
233233
else if (e.type === 'SHIELD_HIT') {
234-
createExplosion(e.x, e.y, EXPLOSION_SMALL);
234+
createExplosion(e.x + 2, e.y + 2, EXPLOSION_SMALL);
235235
if (isMine) audio.play('brick_hit');
236236
}
237237
else if (e.type === 'HIT') {
238-
createExplosion(e.x, e.y, EXPLOSION_SMALL);
238+
createExplosion(e.x + 2, e.y + 2, EXPLOSION_SMALL);
239239
if (isMine) {
240240
if (e.isSteel) {
241241
// Разрушил бетон?
@@ -248,17 +248,17 @@ socket.on('state', (state) => {
248248
}
249249
}
250250
else if (e.type === 'TANK_EXPLODE') {
251-
createExplosion(e.x, e.y, EXPLOSION_BIG);
251+
createExplosion(e.x + 8, e.y + 8, EXPLOSION_BIG);
252252
if (e.isPlayer) audio.play('explosion_player');
253253
else audio.play('explosion_bot');
254254
}
255255
else if (e.type === 'BASE_DESTROY') {
256-
createExplosion(e.x, e.y, EXPLOSION_BIG);
256+
createExplosion(e.x + 8, e.y + 8, EXPLOSION_BIG);
257257
audio.play('base_crash');
258258
audio.play('game_over');
259259
}
260260
else if (e.type === 'ARMOR_HIT') {
261-
createExplosion(e.x, e.y, EXPLOSION_SMALL);
261+
createExplosion(e.x + 8, e.y + 8, EXPLOSION_SMALL);
262262
audio.play('armor_hit');
263263
}
264264
else if (e.type === 'PLAYER_FIRE') {

public/src/renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SPRITES } from './sprites.js';
2-
import { TILE_SIZE, TILE_BIG_SIZE } from '../shared/config.js';
2+
import { TILE_SIZE, TILE_BIG_SIZE, SERVER_FPS } from '../shared/config.js';
33
import { drawRotated } from './client_utils.js';
44

55
// --- КАРТА ---
@@ -290,7 +290,7 @@ export function createExplosion(x, y, type = EXPLOSION_SMALL) {
290290
x, y, type,
291291
frameIndex: 0,
292292
timer: 0,
293-
animationSpeed: 4,
293+
animationSpeed: 0.2 * SERVER_FPS,
294294
isDead: false
295295
});
296296
}

public/src/sprites.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const SPRITES = {
8484
[256, 128, 16, 16], [272, 128, 16, 16], [288, 128, 16, 16]
8585
],
8686
explosion_big: [
87-
[304, 128, 32, 32], [336, 128, 32, 32]
87+
[256, 128, 16, 16], [272, 128, 16, 16], [304, 128, 32, 32], [336, 128, 32, 32]
8888
],
8989
bonuses: {
9090
helmet: [256, 112, 16, 16],

shared/config.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const SERVER_FPS = 60;
1+
export const SERVER_FPS = 30;
22

33
export const TILE_SIZE = 8;
44
export const TILE_BIG_SIZE = 16;
@@ -37,21 +37,26 @@ export const TEAMS_CONFIG = [
3737
}
3838
];
3939

40+
const TANK_SPEED_SLOW = 35;
41+
const TANK_SPEED_FAST = 60;
42+
43+
const BULLET_SPEED_SLOW = 125;
44+
const BULLET_SPEED_FAST = 250;
4045

4146
export const TANK_STATS = {
42-
basic: { speed: 35 / SERVER_FPS, hp: 1, bulletSpeed: 120 / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'basic'},
43-
fast: { speed: 60 / SERVER_FPS, hp: 1, bulletSpeed: 120 / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'fast',},
44-
armor: { speed: 35 / SERVER_FPS, hp: 1, bulletSpeed: 180 / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'armor'},
45-
heavy: { speed: 35 / SERVER_FPS, hp: 4, bulletSpeed: 180 / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'heavy'},
47+
basic: { speed: TANK_SPEED_SLOW / SERVER_FPS, hp: 1, bulletSpeed: BULLET_SPEED_SLOW / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'basic'},
48+
fast: { speed: TANK_SPEED_FAST / SERVER_FPS, hp: 1, bulletSpeed: BULLET_SPEED_SLOW / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'fast',},
49+
armor: { speed: TANK_SPEED_SLOW / SERVER_FPS, hp: 1, bulletSpeed: BULLET_SPEED_FAST / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'armor'},
50+
heavy: { speed: TANK_SPEED_SLOW / SERVER_FPS, hp: 4, bulletSpeed: BULLET_SPEED_FAST / SERVER_FPS, bulletCooldown: SERVER_FPS, canBreakSteel: false, spriteKey: 'heavy'},
4651

4752
player: {
48-
speed: 60 / SERVER_FPS,
53+
speed: TANK_SPEED_FAST / SERVER_FPS,
4954
hp: 1,
5055
levels: {
51-
1: { bulletSpeed: 120 / SERVER_FPS, bulletCount: 1, cooldown: Math.floor(0.33 * SERVER_FPS), canBreakSteel: false },
52-
2: { bulletSpeed: 180 / SERVER_FPS, bulletCount: 1, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: false },
53-
3: { bulletSpeed: 180 / SERVER_FPS, bulletCount: 2, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: false },
54-
4: { bulletSpeed: 180 / SERVER_FPS, bulletCount: 2, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: true }
56+
1: { bulletSpeed: BULLET_SPEED_SLOW / SERVER_FPS, bulletCount: 1, cooldown: Math.floor(0.33 * SERVER_FPS), canBreakSteel: false },
57+
2: { bulletSpeed: BULLET_SPEED_FAST / SERVER_FPS, bulletCount: 1, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: false },
58+
3: { bulletSpeed: BULLET_SPEED_FAST / SERVER_FPS, bulletCount: 2, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: false },
59+
4: { bulletSpeed: BULLET_SPEED_FAST / SERVER_FPS, bulletCount: 2, cooldown: Math.floor(0.20 * SERVER_FPS), canBreakSteel: true }
5560
}
5661
}
5762
};
@@ -99,5 +104,5 @@ export const BULLET_COOLDOWN_FAST = 8;
99104

100105
export const CHAT_HISTORY_LENGTH = 100;
101106

102-
export const TANK_SNAP_GRID = 8;
103-
export const TANK_SNAP_TOLERANCE = 8;
107+
export const TANK_SNAP_GRID = 4;
108+
export const TANK_SNAP_TOLERANCE = 4;

shared/tank.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,8 @@ export function updateTankMovement(tank, direction, gameWidth, gameHeight, map,
103103
}
104104
}
105105

106+
tank.x = Math.max(0, Math.min(tank.x, gameWidth - TILE_BIG_SIZE));
107+
tank.y = Math.max(0, Math.min(tank.y, gameHeight - TILE_BIG_SIZE));
108+
106109
return true;
107110
}

0 commit comments

Comments
 (0)