Skip to content

Commit

Permalink
colors in designer
Browse files Browse the repository at this point in the history
  • Loading branch information
gtanczyk committed Oct 2, 2024
1 parent 16da890 commit c377af2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion games/masterplan/src/screens/designer/canvas-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ export const CanvasGrid: React.FC<CanvasGridProps> = React.memo(

if (unitImages[unit.type]) {
for (let xi = 0; xi < unit.sizeCol; xi++)
for (let yi = 0; yi < unit.sizeRow; yi++)
for (let yi = 0; yi < unit.sizeRow; yi++) {
ctx.drawImage(unitImages[unit.type], x + xi * cellWidth, y + yi * cellHeight, cellWidth, cellHeight);
// Draw small rectangle representing unit's life
ctx.fillStyle = isPlayerArea ? '#ff0000' : '#00ff00';
ctx.fillRect(x + xi * cellWidth, y + yi * cellHeight + 10, 10, 5);
}
} else {
// Fallback to colored rectangle if image is not loaded
ctx.fillStyle = unit.type === 'archer' ? 'green' : unit.type === 'tank' ? 'blue' : 'red';
Expand Down

0 comments on commit c377af2

Please sign in to comment.