Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: leaderClass is not defined' in or related to this line: 'leaderList.push(spawnPoint.addChild(new LeaderClass({' Line Number: 126
Code edit (7 edits merged)
Please save this source code
User prompt
When spawning a leader, add it to the leaderList
Code edit (2 edits merged)
Please save this source code
User prompt
Add a leaderHat asset to the top of the leaderTroll2 class
User prompt
Rename the leaderHat asset to leaderTrollHat
Code edit (1 edits merged)
Please save this source code
User prompt
To each LeaderTroll
Code edit (2 edits merged)
Please save this source code
User prompt
when the spawnTimer expires, call the global table's spawn function after a random timeout of 0 to LEADER_SPAWN_VAR
Code edit (1 edits merged)
Please save this source code
User prompt
Add a spawn function to the table class which checks if the leaders array is not empty, then randomly pops an item off the array and creates an instance of it
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Add a new global function called handleSpawnTimer, which is called on tick. In the function: decrement the spawnTimer, if the spawnTimer is <= 0 then restart it with the spawnTime value, then multiply the spawnTime by the LEADER_SPAWN_FACTOR
Code edit (15 edits merged)
Please save this source code
User prompt
every tick reduce the countdown by 1, end the game when the countdown reaches 0
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: pox is not defined' in or related to this line: 'particleList.push(foreground.addChild(new HammerParticle({' Line Number: 498
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
Create 3 empty Containers; background, midground and foreground
Code edit (6 edits merged)
Please save this source code
User prompt
The ImpactParticles that HammerParticles create, should be added to the particleList array
/****
* Classes
****/
/**
* config {
* x : Number || 0,
* y : Number || 0,
* rotation : Number || 0,
* }
**/
var ConfigContainer = Container.expand(function (config) {
var self = Container.call(this);
config = config || {};
;
self.x = config.x || 0;
self.y = config.y || 0;
self.rotation = config.rotation || 0;
;
return self;
});
var Textbox = ConfigContainer.expand(function (message, config) {
var self = ConfigContainer.call(this, config);
config = config || {};
;
var background = self.addChild(new BorderedShape({
width: config.width,
height: config.height,
weight: 10,
anchorY: 1
}));
var textboxTail = self.attachAsset('textboxTail', {
y: 1,
x: 20,
tint: 0xbbbabe
});
var logo = self.addChild(new BorderedSymbol('logo', {
x: -20,
y: 20,
anchorX: 0,
anchorY: 1,
height: config.height + 40
}));
var typedText = self.addChild(new TypedText(message, {
x: logo.width,
y: -config.height / 2,
anchorY: 0.5,
delay: 50
}));
;
return self;
});
var Table = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
;
var currentY = 0;
var spawnPoints = [];
var takenPoints = [];
for (var i = 0; i < TABLE_SLICES; i++) {
var tableSliceId = 'tableSlice' + (i + 1);
var tableSlice = self.attachAsset(tableSliceId, {
x: 0,
y: currentY,
anchorX: 0.5,
anchorY: 0
});
var scaleRatio = config.width / tableSlice.width;
tableSlice.width = config.width;
tableSlice.height *= scaleRatio;
currentY += tableSlice.height;
var holeCount = TABLE_HOLES[i];
var offset = TABLE_HOLE_GAP * (holeCount - 1) / 2;
for (var j = 0; j < holeCount; j++) {
spawnPoints.push(self.addChild(new ConfigContainer({
x: -offset + TABLE_HOLE_GAP * j,
y: currentY
})));
}
}
;
return self;
});
var Leader = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
// Leader-specific properties and methods can be added here
return self;
});
var LeaderTroll1 = Leader.expand(function (config) {
var self = Leader.call(this, config);
config = config || {};
// LeaderTroll1-specific properties and methods can be added here
return self;
});
var ImpactParticle = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var selectedAsset = 'hammerParticle' + (1 + Math.floor(Math.random() * PARTICLE_HAMMER_ASSETS));
var particle = self.attachAsset(selectedAsset, {
rotation: PARTICLE_HAMMER_ROTATION * (Math.random() - 0.5),
anchorX: 0.5,
anchorY: 0.5
});
var elapsedTicks = 0;
;
self.update = update;
;
function update() {
elapsedTicks++;
if (elapsedTicks <= PARTICLE_HAMMER_STAGE_2) {
var scale = 1 + (PARTICLE_HAMMER_SCALE_MAX - 1) * elapsedTicks / PARTICLE_HAMMER_STAGE_2;
particle.scale.set(scale, scale);
} else if (elapsedTicks > PARTICLE_HAMMER_STAGE_2 && elapsedTicks <= PARTICLE_HAMMER_STAGE_2 + PARTICLE_HAMMER_STAGE_3) {
var progress = 1 - (elapsedTicks - PARTICLE_HAMMER_STAGE_2) / PARTICLE_HAMMER_STAGE_3;
var scale = PARTICLE_HAMMER_SCALE_MAX * progress;
particle.alpha = progress;
particle.scale.set(scale);
} else {
return true;
}
}
;
return self;
});
var HammerParticle = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
var hammer = self.attachAsset('hammer', {
anchorX: 0.5,
anchorY: 0.5
});
hammer.x = hammer.width / 2;
var elapsedTicks = 0;
var stage = 1;
self.update = function () {
elapsedTicks++;
if (stage === 1) {
if (elapsedTicks <= PARTICLE_HAMMER_STAGE_1) {
self.rotation += PARTICLE_HAMMER_SPIN / PARTICLE_HAMMER_STAGE_1;
} else {
elapsedTicks = 0;
stage++;
particleList.push(game.addChild(new ImpactParticle({
x: self.x,
y: self.y
})));
}
} else if (stage === 2) {
if (elapsedTicks <= PARTICLE_HAMMER_STAGE_2) {
var alpha = 1 - elapsedTicks / PARTICLE_HAMMER_STAGE_2;
self.alpha = alpha;
} else {
return true;
}
}
};
return self;
});
/**
* config {
* x : Number || 0, // See: ConfigContainer
* y : Number || 0, // See: ConfigContainer
* rotation : Number || 0, // See: ConfigContainer
* anchorX : Number || 0,
* anchorY : Number || 1,
* size : Number || TEXT_DEFAULT_SIZE,
* weight : Number || TEXT_DEFAULT_WEIGHT,
* font : String || TEXT_DEFAULT_FONT,
* fill : String || TEXT_DEFAULT_FILL,
* border : String || TEXT_DEFAULT_BORDER,
* }
**/
var BorderedText = ConfigContainer.expand(function (text, config) {
var self = ConfigContainer.call(this, config);
config = config || {};
;
var anchorX = config.anchorX !== undefined ? config.anchorX : 0;
var anchorY = config.anchorY !== undefined ? config.anchorY : 1;
var size = config.size !== undefined ? config.size : TEXT_DEFAULT_SIZE;
var weight = config.weight !== undefined ? config.weight : TEXT_DEFAULT_WEIGHT;
var font = config.font !== undefined ? config.font : TEXT_DEFAULT_FONT;
var textFill = config.fill !== undefined ? config.fill : TEXT_DEFAULT_FILL;
var borderFill = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
var textAssets = [];
var mainAsset;
;
self.setText = setText;
self.setFill = setFill;
;
function setText(newText) {
for (var i = 0; i < textAssets.length; i++) {
textAssets[i].setText(newText);
}
}
function setFill(newFill) {
textFill = newFill;
mainAsset.fill = newFill;
}
function buildTextAssets(newText) {
for (var i = 0; i < TEXT_OFFSETS.length; i++) {
var main = i === TEXT_OFFSETS.length - 1;
var fill = main ? textFill : borderFill;
var textAsset = textAssets[i];
if (textAsset) {
textAsset.destroy();
}
textAsset = self.addChild(new Text2(newText, {
fill: fill,
font: font,
size: size
}));
textAsset.anchor = {
x: anchorX,
y: anchorY
}; // NOTE: Cannot be set in config
textAsset.x = TEXT_OFFSETS[i][0] * weight; // NOTE: Cannot be set in config
textAsset.y = TEXT_OFFSETS[i][1] * weight; // NOTE: Cannot be set in config
textAssets[i] = textAsset;
}
mainAsset = textAssets[TEXT_OFFSETS.length - 1];
}
;
buildTextAssets(text);
return self;
});
var TypedText = BorderedText.expand(function (text, config) {
var self = BorderedText.call(this, text, config);
var baseSetText = self.setText;
config = config || {};
;
var counter = 0;
var delay = config.delay;
var interval;
;
self.setText = setText;
self.completed = false;
;
function setText(newText) {
if (interval) {
LK.clearInterval(interval);
}
self.completed = false;
text = newText;
counter = 0;
interval = LK.setInterval(updateText, delay);
updateText();
}
function updateText() {
var subText = text.substr(0, ++counter).replace(/#/g, '');
baseSetText(subText);
if (counter === text.length) {
LK.clearInterval(interval);
self.completed = true;
}
}
;
setText(text);
return self;
});
/**
* var config = {
* x : Number || 0, // See: ConfigContainer
* y : Number || 0, // See: ConfigContainer
* rotation : Number || 0, // See: ConfigContainer
* anchorX : Number || .5,
* anchorY : Number || .5,
* scale : Number || undefined,
* scaleX : Number || scale,
* scaleY : Number || scale,
* weight : Number || TEXT_DEFAULT_WEIGHT,
* width : Number || undefined, // Auto-calculated if left undefined and height is set
* height : Number || undefined, // Auto-calculated if left undefined and width is set
* tint : String || 0xFFFFFF, // Not tinted by default
* border : String || TEXT_DEFAULT_BORDER,
* }
**/
var BorderedSymbol = ConfigContainer.expand(function (symbol, config) {
var self = ConfigContainer.call(this, config);
config = config || {};
var width = config.width !== undefined ? config.width : undefined;
var height = config.height !== undefined ? config.height : undefined;
var scale = config.scale !== undefined ? config.scale : undefined;
var scaleX = config.scaleX !== undefined ? config.scaleX : scale;
var scaleY = config.scaleY !== undefined ? config.scaleX : scale;
var weight = config.weight !== undefined ? config.weight : TEXT_DEFAULT_WEIGHT;
var anchorX = config.anchorX !== undefined ? config.anchorX : .5;
var anchorY = config.anchorY !== undefined ? config.anchorY : .5;
var symbolTint = config.tint !== undefined ? config.tint : 0xFFFFFF;
var borderTint = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
var mainSymbol;
var symbolAssets = [];
;
self.setSymbol = buildSymbolAssets;
self.setTint = setTint;
;
function setTint(newTint) {
// NOTE: Tinting is currently broken (cannot use string)
// mainSymbol.tint = newTint;
// symbolConfig.tint = newTint
}
function buildSymbolAssets(newSymbol) {
for (var i = 0; i < TEXT_OFFSETS.length; i++) {
var main = i === TEXT_OFFSETS.length - 1;
var symbolAsset = symbolAssets[i];
if (symbolAsset) {
symbolAsset.destroy();
}
symbolAsset = self.attachAsset(newSymbol, {
// tint: main ? symbolTint : borderTint,
tint: main ? 0xFFFFFF : 0x000000,
// NOTE: Tinting is currently broken (cannot use string)
x: TEXT_OFFSETS[i][0] * weight,
y: TEXT_OFFSETS[i][1] * weight,
anchorX: anchorX,
anchorY: anchorY
});
if (width !== undefined && height === undefined) {
height = symbolAsset.height * (width / symbolAsset.width);
} else if (height !== undefined && width === undefined) {
width = symbolAsset.width * (height / symbolAsset.height);
}
symbolAsset.width = width;
symbolAsset.height = height;
if (scaleX !== undefined && scaleY !== undefined) {
symbolAsset.scale.set(scaleX, scaleY);
}
symbolAssets[i] = symbolAsset;
}
mainSymbol = symbolAssets[TEXT_OFFSETS.length - 1];
}
;
buildSymbolAssets(symbol);
return self;
});
/**
* config {
* x : Number || 0, // See: ConfigContainer
* y : Number || 0, // See: ConfigContainer
* rotation : Number || 0, // See: ConfigContainer
* anchorX : Number || 0,
* anchorY : Number || 0,
* width : Number || 100,
* height : Number || 100,
* weight : Number || TEXT_DEFAULT_WEIGHT,
* shape : String || 'square',
* fill : String || TEXT_DEFAULT_FILL,
* border : String || TEXT_DEFAULT_BORDER,
* }
**/
var BorderedShape = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
;
var anchorX = config.anchorX !== undefined ? config.anchorX : 0;
var anchorY = config.anchorY !== undefined ? config.anchorY : 0;
var width = config.width !== undefined ? config.width : 100;
var height = config.height !== undefined ? config.height : 100;
var weight = config.weight !== undefined ? config.weight : TEXT_DEFAULT_WEIGHT;
var shape = config.shape !== undefined ? config.shape : 'shapeRectangle';
var frontTint = 0xFFFFFF; //hexToHex(config.fill !== undefined ? config.fill : TEXT_DEFAULT_FILL);
var borderTint = 0x000000; //hexToHex(config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER);
var background = self.attachAsset(shape, {
x: weight * 2 * (anchorX - 0.5),
y: weight * 2 * (anchorY - 0.5),
tint: borderTint,
width: width + 2 * weight,
height: height + 2 * weight,
anchorX: anchorX,
anchorY: anchorY
});
var foreground = self.attachAsset(shape, {
tint: frontTint,
width: width,
height: height,
anchorX: anchorX,
anchorY: anchorY
});
;
return self;
});
/****
* Initialize Game
****/
// Assets will be automatically initialized based on usage in the code.
var game = new LK.Game({
backgroundColor: 0xD3D3D3 // Init game with light grey background
});
/****
* Game Code
****/
;
//==============================================================================
// Global constants & settings
//==============================================================================
;
// Math constants / pre-calculations
var MATH_2_PI = Math.PI * 2;
var MATH_HALF_PI = Math.PI / 2;
var MATH_QUARTER_PI = Math.PI / 4;
var MATH_HALF_ROOT_3 = Math.sqrt(3) / 2; // Required by: TEXT_OFFSETS, BorderedText, BorderedSymbol, BorderedShape, SymbolText
var MATH_APPROX_ZERO = 0.0000001;
;
// Text settings
var TEXT_OFFSETS = [[0, 1], [MATH_HALF_ROOT_3, 0.5], [MATH_HALF_ROOT_3, -0.5], [0, -1], [-MATH_HALF_ROOT_3, -0.5], [-MATH_HALF_ROOT_3, 0.5], [0, 0]]; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_WEIGHT = 6; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_BORDER = '#000000'; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_FILL = '#FFFFFF'; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_FONT = 'Arial'; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_SIZE = 50; // Required by: BorderedText, SymbolText
var TEXT_DEFAULT_MARGIN = 10; // Required by: SymbolText
;
// Game constants
var GAME_TICKS = 60;
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
;
// Particle settings
var PARTICLE_HAMMER_SPIN = -MATH_QUARTER_PI * 3;
var PARTICLE_HAMMER_STAGE_1 = Math.round(0.075 * GAME_TICKS);
var PARTICLE_HAMMER_STAGE_2 = Math.round(0.075 * GAME_TICKS);
var PARTICLE_HAMMER_STAGE_3 = Math.round(0.4 * GAME_TICKS);
var PARTICLE_HAMMER_ASSETS = 5;
var PARTICLE_HAMMER_ROTATION = MATH_QUARTER_PI;
var PARTICLE_HAMMER_SCALE_MAX = 2.0;
// Other constants
var TABLE_SLICES = 6;
var TABLE_HOLES = [1, 2, 3, 2, 1, 0];
var TABLE_HOLE_GAP = 778;
;
//==============================================================================
// Global variables
//==============================================================================
;
var centerTable = game.addChild(new Table({
x: GAME_WIDTH / 2,
y: GAME_HEIGHT / 2 - 500,
width: 2500
}));
// Initialize an array to keep track of HammerParticles
var particleList = [];
;
//==============================================================================
// Game events
//==============================================================================
;
game.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
particleList.push(game.addChild(new HammerParticle({
x: pos.x,
y: pos.y
})));
});
;
LK.on('tick', function () {
for (var i = particleList.length - 1; i >= 0; i--) {
if (particleList[i].update()) {
particleList[i].destroy();
particleList.splice(i, 1);
}
}
});
//==============================================================================
// Global functions
//==============================================================================
;
function hexToHex(input) {
if (typeof input === 'string') {
return parseInt(input.replace(/^#/, ''), 16);
} else if (typeof input === 'number') {
return '#' + input.toString(16).padStart(6, '0');
}
return input;
}
logo for a company called "blue lizard entertainment" using a damaged font and frozen elements.
Pixel art of the bam symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of bam comic symbol.
pixel art of pow comic symbol.
pixel art of plastic squeaky hammer.
pixel art of a large, round, red start button.