fix: purchased weapons are now active in game (again) and panel font size reduced to 10px
This commit is contained in:
1 parent
36e13a6354
commit
85e59b4cfe
13 files changed
+68
-47
No files matched your search
+1
-1
@@ -14,6 +14,6 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="src/main.js?v=4"></script>
|
||||
<script type="module" src="src/main.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
import {PLAYER_MAX_ENERGY, PLAYER_INITIAL_POWER, PLAYER_ENERGY_POWER_MULTIPLIER} from './constants.js?v=4';
|
||||
import {randomInt} from './math.js?v=4';
|
||||
import {PLAYER_MAX_ENERGY, PLAYER_INITIAL_POWER, PLAYER_ENERGY_POWER_MULTIPLIER} from './constants.js?v=5';
|
||||
import {randomInt} from './math.js?v=5';
|
||||
|
||||
export const AI_TYPES = {
|
||||
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ export const PLAYER_STARTING_TOOLS = [
|
||||
|
||||
export const PANEL_WIDTH = 400;
|
||||
export const PANEL_HEIGHT = 300;
|
||||
export const PANEL_FONT_SIZE = 16;
|
||||
export const PANEL_FONT_SIZE = 10;
|
||||
export const PANEL_BG_COLOR = '#666';
|
||||
export const PANEL_BORDER_COLOR = '#333';
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import {splitWords} from './utils.js?v=4';
|
||||
import {parable} from './math.js?v=4';
|
||||
import {FONT_HEIGHT, FONT_WIDTH} from './constants.js?v=4';
|
||||
import {splitWords} from './utils.js?v=5';
|
||||
import {parable} from './math.js?v=5';
|
||||
import {FONT_HEIGHT, FONT_WIDTH} from './constants.js?v=5';
|
||||
|
||||
export function createCanvas(width, height) {
|
||||
const canvas = document.createElement('canvas');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {DEFAULT_KEYPRESS_DELAY} from './constants.js?v=4';
|
||||
import {DEFAULT_KEYPRESS_DELAY} from './constants.js?v=5';
|
||||
|
||||
const input = {};
|
||||
let lastKeypressTime = 0;
|
||||
|
||||
+37
-16
@@ -1,15 +1,15 @@
|
||||
import {AI_TYPES} from './ai.js?v=4';
|
||||
import {DEATH_SPECS, EXPLOSION_SHAKE_REDUCTION_FACTOR, H, MAX_EXPLOSION_SHAKE_FACTOR, MAX_WIND, PARTICLE_AMOUNT, PARTICLE_FADE_AMOUNT, PARTICLE_MAX_POWER_FACTOR, PARTICLE_MIN_LIFETIME, PARTICLE_MIN_POWER_FACTOR, PARTICLE_POWER_REDUCTION_FACTOR, PARTICLE_TIME_FACTOR, PARTICLE_WIND_REDUCTION_FACTOR, PLAYER_ANGLE_FAST_INCREMENT, PLAYER_ANGLE_INCREMENT, PLAYER_ANGLE_TICK_SOUND_INTERVAL, PLAYER_COLORS, PLAYER_ENERGY_POWER_MULTIPLIER, PLAYER_EXPLOSION_PARTICLE_POWER, PLAYER_FALL_DAMAGE_FACTOR, PLAYER_FALL_DAMAGE_HEIGHT, PLAYER_INITIAL_POWER, PLAYER_MAX_ENERGY, PLAYER_POWER_FAST_INCREMENT, PLAYER_POWER_INCREMENT, PLAYER_POWER_TICK_SOUND_INTERVAL, PLAYER_STARTING_TOOLS, PLAYER_STARTING_WEAPONS, PLAYER_TANK_BOUNDING_RADIUS, PLAYER_TANK_Y_FOOTPRINT, SHIELD_TYPES, TRAJECTORY_FADE_SPEED, TRAJECTORY_FLOAT_SPEED, W, WEAPON_TYPES, Z, STARTING_SCORE, SCORE_PER_KILL, SCORE_FOR_WIN, MARKET_ITEMS} from './constants.js?v=4';
|
||||
import {createCanvas, drawLine, drawRect, drawSemiCircle, drawText, loop, plot, strokeCircle} from './gfx.js?v=4';
|
||||
import {afterKeyDelay, key} from './input.js?v=4';
|
||||
import {clamp, deg2rad, distance, parable, random, randomInt, vec, wrap} from './math.js?v=4';
|
||||
import {PROJECTILE_TYPES} from './projectiles.js?v=4';
|
||||
import {generateSky} from './sky.js?v=4';
|
||||
import {playTickSound} from './sound.js?v=4';
|
||||
import {clipTerrain, closestLand, collapseTerrain, generateTerrain, isTerrain, landHeight} from './terrain.js?v=4';
|
||||
import {sample, shuffle} from './utils.js?v=4';
|
||||
import {EXPLOSION_TYPES} from './weapons.js?v=4';
|
||||
import {drawPanelBg, drawPanelTitle, drawPanelText, drawPanelDivider, drawPanelMenu, getPanelBounds} from './panel.js?v=4';
|
||||
import {AI_TYPES} from './ai.js?v=5';
|
||||
import {DEATH_SPECS, EXPLOSION_SHAKE_REDUCTION_FACTOR, H, MAX_EXPLOSION_SHAKE_FACTOR, MAX_WIND, PARTICLE_AMOUNT, PARTICLE_FADE_AMOUNT, PARTICLE_MAX_POWER_FACTOR, PARTICLE_MIN_LIFETIME, PARTICLE_MIN_POWER_FACTOR, PARTICLE_POWER_REDUCTION_FACTOR, PARTICLE_TIME_FACTOR, PARTICLE_WIND_REDUCTION_FACTOR, PLAYER_ANGLE_FAST_INCREMENT, PLAYER_ANGLE_INCREMENT, PLAYER_ANGLE_TICK_SOUND_INTERVAL, PLAYER_COLORS, PLAYER_ENERGY_POWER_MULTIPLIER, PLAYER_EXPLOSION_PARTICLE_POWER, PLAYER_FALL_DAMAGE_FACTOR, PLAYER_FALL_DAMAGE_HEIGHT, PLAYER_INITIAL_POWER, PLAYER_MAX_ENERGY, PLAYER_POWER_FAST_INCREMENT, PLAYER_POWER_INCREMENT, PLAYER_POWER_TICK_SOUND_INTERVAL, PLAYER_STARTING_TOOLS, PLAYER_STARTING_WEAPONS, PLAYER_TANK_BOUNDING_RADIUS, PLAYER_TANK_Y_FOOTPRINT, SHIELD_TYPES, TRAJECTORY_FADE_SPEED, TRAJECTORY_FLOAT_SPEED, W, WEAPON_TYPES, Z, STARTING_SCORE, SCORE_PER_KILL, SCORE_FOR_WIN, MARKET_ITEMS} from './constants.js?v=5';
|
||||
import {createCanvas, drawLine, drawRect, drawSemiCircle, drawText, loop, plot, strokeCircle} from './gfx.js?v=5';
|
||||
import {afterKeyDelay, key} from './input.js?v=5';
|
||||
import {clamp, deg2rad, distance, parable, random, randomInt, vec, wrap} from './math.js?v=5';
|
||||
import {PROJECTILE_TYPES} from './projectiles.js?v=5';
|
||||
import {generateSky} from './sky.js?v=5';
|
||||
import {playTickSound} from './sound.js?v=5';
|
||||
import {clipTerrain, closestLand, collapseTerrain, generateTerrain, isTerrain, landHeight} from './terrain.js?v=5';
|
||||
import {sample, shuffle} from './utils.js?v=5';
|
||||
import {EXPLOSION_TYPES} from './weapons.js?v=5';
|
||||
import {drawPanelBg, drawPanelTitle, drawPanelText, drawPanelDivider, drawPanelMenu, getPanelBounds} from './panel.js?v=5';
|
||||
|
||||
|
||||
let state = 'start-game';
|
||||
@@ -47,7 +47,6 @@ framebuffer.canvas.style.height = `${H * Z}px`;
|
||||
document.body.appendChild(framebuffer.canvas);
|
||||
|
||||
function init() {
|
||||
players = [];
|
||||
currentPlayer = 0;
|
||||
projectiles = [];
|
||||
explosions = [];
|
||||
@@ -196,7 +195,7 @@ function updateMarket() {
|
||||
playTickSound();
|
||||
}
|
||||
}
|
||||
else if (key(' ')) {
|
||||
else if (key('ArrowRight')) {
|
||||
if (afterKeyDelay()) {
|
||||
const item = marketItems[menuState.selected];
|
||||
const itemData = MARKET_ITEMS[item];
|
||||
@@ -213,6 +212,28 @@ function updateMarket() {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key('ArrowLeft')) {
|
||||
if (afterKeyDelay()) {
|
||||
const item = marketItems[menuState.selected];
|
||||
const itemData = MARKET_ITEMS[item];
|
||||
const humanPlayer = players.find(p => !p.ai);
|
||||
if (humanPlayer && item !== 'babyMissile' && item !== 'tracer') {
|
||||
const weapon = humanPlayer.weapons.find(w => w.type === item);
|
||||
if (weapon && weapon.ammo > 0) {
|
||||
const refund = itemData.price / itemData.ammo;
|
||||
score += refund;
|
||||
weapon.ammo--;
|
||||
if (weapon.ammo <= 0) {
|
||||
humanPlayer.weapons = humanPlayer.weapons.filter(w => w.type !== item);
|
||||
}
|
||||
playTickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key(' ')) {
|
||||
idle = true;
|
||||
}
|
||||
else if (key('Enter')) {
|
||||
if (afterKeyDelay()) {
|
||||
menuState = null;
|
||||
@@ -822,7 +843,7 @@ function drawMarketPanel() {
|
||||
}
|
||||
|
||||
drawPanelDivider(framebuffer, 280);
|
||||
drawPanelText(framebuffer, 'SPACE: Buy ENTER: Start Round', 160, 290, 'white');
|
||||
drawPanelText(framebuffer, 'RIGHT: Buy LEFT: Sell ENTER: Start Round', 160, 290, 'white');
|
||||
}
|
||||
|
||||
function drawRoundEndPanel() {
|
||||
@@ -859,7 +880,7 @@ function drawGameOverPanel() {
|
||||
const p = sortedPlayers[i];
|
||||
const text = `${p.name}: W:${p.wins} K:${p.kills} D:${p.deaths} S:${p.shotsFired}`;
|
||||
const color = i === 0 ? 'yellow' : 'white';
|
||||
drawPanelText(framebuffer, text, 160, y + i * 25, color);
|
||||
drawPanelText(framebuffer, text, 160, y + i * 16, color);
|
||||
}
|
||||
|
||||
drawPanelDivider(framebuffer, 280);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import {PANEL_WIDTH, PANEL_HEIGHT, PANEL_FONT_SIZE, PANEL_BG_COLOR, PANEL_BORDER_COLOR, W, H, FONT_WIDTH} from './constants.js?v=4';
|
||||
import {drawRect, drawLine} from './gfx.js?v=4';
|
||||
import {PANEL_WIDTH, PANEL_HEIGHT, PANEL_FONT_SIZE, PANEL_BG_COLOR, PANEL_BORDER_COLOR, W, H, FONT_WIDTH} from './constants.js?v=5';
|
||||
import {drawRect, drawLine} from './gfx.js?v=5';
|
||||
|
||||
const PANEL_X = (W - PANEL_WIDTH) / 2;
|
||||
const PANEL_Y = (H - PANEL_HEIGHT) / 2;
|
||||
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
import {H, PROJECTILE_ITERATIONS_PER_FRAME, PROJECTILE_ITERATION_PROGRESS, PROJECTILE_MAX_SOUND_FREQUENCY, PROJECTILE_MIN_SOUND_FREQUENCY, PROJECTILE_POWER_REDUCTION_FACTOR, PROJECTILE_WIND_REDUCTION_FACTOR, WEAPON_TYPES} from './constants.js?v=4';
|
||||
import {checkLineWith, drawLineVirtual} from './gfx.js?v=4';
|
||||
import {createParticles, isTank, isTankShield} from './main.js?v=4';
|
||||
import {deg2rad, parable} from './math.js?v=4';
|
||||
import {audio, createOsc} from './sound.js?v=4';
|
||||
import {isTerrain, landHeight} from './terrain.js?v=4';
|
||||
import {EXPLOSION_TYPES} from './weapons.js?v=4';
|
||||
import {H, PROJECTILE_ITERATIONS_PER_FRAME, PROJECTILE_ITERATION_PROGRESS, PROJECTILE_MAX_SOUND_FREQUENCY, PROJECTILE_MIN_SOUND_FREQUENCY, PROJECTILE_POWER_REDUCTION_FACTOR, PROJECTILE_WIND_REDUCTION_FACTOR, WEAPON_TYPES} from './constants.js?v=5';
|
||||
import {checkLineWith, drawLineVirtual} from './gfx.js?v=5';
|
||||
import {createParticles, isTank, isTankShield} from './main.js?v=5';
|
||||
import {deg2rad, parable} from './math.js?v=5';
|
||||
import {audio, createOsc} from './sound.js?v=5';
|
||||
import {isTerrain, landHeight} from './terrain.js?v=5';
|
||||
import {EXPLOSION_TYPES} from './weapons.js?v=5';
|
||||
|
||||
|
||||
export const PROJECTILE_TYPES = {
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import {SKY_COLORS} from './constants.js?v=4';
|
||||
import {drawRect} from './gfx.js?v=4';
|
||||
import {gradient} from './math.js?v=4';
|
||||
import {sample} from './utils.js?v=4';
|
||||
import {SKY_COLORS} from './constants.js?v=5';
|
||||
import {drawRect} from './gfx.js?v=5';
|
||||
import {gradient} from './math.js?v=5';
|
||||
import {sample} from './utils.js?v=5';
|
||||
|
||||
export function generateSky(ctx) {
|
||||
const {width, height} = ctx.canvas;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {SOUND_MUSIC_VOLUME, SOUND_SFX_VOLUME} from './constants.js?v=4';
|
||||
import {SOUND_MUSIC_VOLUME, SOUND_SFX_VOLUME} from './constants.js?v=5';
|
||||
|
||||
// @ts-ignore
|
||||
export const audio = new (window.AudioContext || window.webkitAudioContext)();
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import {clipCanvas, drawCircle, drawRect} from './gfx.js?v=4';
|
||||
import {clamp, coords2index, random, randomInt} from './math.js?v=4';
|
||||
import {sample} from './utils.js?v=4';
|
||||
import {clipCanvas, drawCircle, drawRect} from './gfx.js?v=5';
|
||||
import {clamp, coords2index, random, randomInt} from './math.js?v=5';
|
||||
import {sample} from './utils.js?v=5';
|
||||
|
||||
let cachedImageData;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import {randomInt} from './math.js?v=4';
|
||||
import {randomInt} from './math.js?v=5';
|
||||
|
||||
export function sample(arr) {
|
||||
return arr[randomInt(0, arr.length-1)];
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import {PLAYER_TANK_BOUNDING_RADIUS, PLAYER_TANK_Y_FOOTPRINT, SHIELD_TYPES} from './constants.js?v=4';
|
||||
import {drawCircle, plot} from './gfx.js?v=4';
|
||||
import {clamp, cycle, distance, randomInt} from './math.js?v=4';
|
||||
import {audio, createOsc} from './sound.js?v=4';
|
||||
import {clipTerrain} from './terrain.js?v=4';
|
||||
import {PLAYER_TANK_BOUNDING_RADIUS, PLAYER_TANK_Y_FOOTPRINT, SHIELD_TYPES} from './constants.js?v=5';
|
||||
import {drawCircle, plot} from './gfx.js?v=5';
|
||||
import {clamp, cycle, distance, randomInt} from './math.js?v=5';
|
||||
import {audio, createOsc} from './sound.js?v=5';
|
||||
import {clipTerrain} from './terrain.js?v=5';
|
||||
|
||||
export function drawExplosion(ctx, x, y, r) {
|
||||
const color = 255 - (16 * (r % 16));
|
||||
|
||||
Reference in new issue
Block a user