-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎙️⛸️ ↝ [SSP-33 SSC-40 SSM-40]: Trying to build some shitty maps, but …
…failing...about half
- Loading branch information
1 parent
c81717b
commit 8235586
Showing
10 changed files
with
1,196 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useState } from 'react' | ||
import { Diamond, Zap, Gem, Rocket, Crown } from 'lucide-react' | ||
|
||
type InventoryItem = { | ||
id: string | ||
name: string | ||
amount: number | ||
} | ||
|
||
type Props = { | ||
inventory: InventoryItem[] | ||
} | ||
|
||
export function Inventory({ inventory = [] }: Props) { | ||
const [hoveredItem, setHoveredItem] = useState<string | null>(null) | ||
|
||
const getIcon = (name: string) => { | ||
switch (name) { | ||
case 'Iron': | ||
return <Diamond className="text-[#FFE3BA]" /> | ||
case 'Copper': | ||
return <Zap className="text-[#FFE3BA]" /> | ||
case 'Gold': | ||
return <Gem className="text-[#FFE3BA]" /> | ||
case 'Titanium': | ||
return <Rocket className="text-[#FFE3BA]" /> | ||
case 'Platinum': | ||
return <Crown className="text-[#FFE3BA]" /> | ||
default: | ||
return <Diamond className="text-[#FFE3BA]" /> | ||
} | ||
} | ||
|
||
return ( | ||
<div className="space-y-2"> | ||
<h2 className="text-xl font-bold text-[#2C4F64]">Inventory</h2> | ||
<div className="flex space-x-4"> | ||
{inventory.map(item => ( | ||
<div | ||
key={item.id} | ||
className="relative flex items-center space-x-2 bg-gray-100 p-2 rounded-lg" | ||
onMouseEnter={() => setHoveredItem(item.id)} | ||
onMouseLeave={() => setHoveredItem(null)} | ||
> | ||
{getIcon(item.name)} | ||
<span className="font-bold">{item.amount}</span> | ||
{hoveredItem === item.id && ( | ||
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 bg-[#2C4F64] text-white px-2 py-1 rounded text-sm whitespace-nowrap"> | ||
{item.name} | ||
</div> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useEffect, useRef } from 'react' | ||
import { motion } from 'framer-motion' | ||
|
||
type MineralDeposit = { | ||
id: string | ||
name: string | ||
amount: number | ||
position: { x: number; y: number } | ||
} | ||
|
||
type Props = { | ||
deposits: MineralDeposit[] | ||
roverPosition: { x: number; y: number } | null | ||
selectedDeposit: MineralDeposit | null | ||
} | ||
|
||
export function TopographicMap({ deposits = [], roverPosition, selectedDeposit }: Props) { | ||
const canvasRef = useRef<HTMLCanvasElement>(null) | ||
|
||
useEffect(() => { | ||
const canvas = canvasRef.current | ||
if (!canvas) return | ||
|
||
const ctx = canvas.getContext('2d') | ||
if (!ctx) return | ||
|
||
// Draw topographic map (simplified version) | ||
ctx.fillStyle = '#f0f0f0' | ||
ctx.fillRect(0, 0, canvas.width, canvas.height) | ||
|
||
// Draw contour lines | ||
ctx.strokeStyle = '#d0d0d0' | ||
for (let i = 0; i < canvas.height; i += 20) { | ||
ctx.beginPath() | ||
ctx.moveTo(0, i) | ||
ctx.lineTo(canvas.width, i) | ||
ctx.stroke() | ||
} | ||
|
||
// Draw deposits | ||
deposits.forEach(deposit => { | ||
ctx.fillStyle = deposit.name === 'Iron' ? '#FFE3BA' : '#5FCBC3' | ||
ctx.beginPath() | ||
ctx.arc(deposit.position.x, deposit.position.y, Math.sqrt(deposit.amount) / 2, 0, 2 * Math.PI) | ||
ctx.fill() | ||
|
||
// Add deposit name | ||
ctx.fillStyle = '#2C4F64' | ||
ctx.font = '12px Arial' | ||
ctx.textAlign = 'center' | ||
ctx.fillText(deposit.name, deposit.position.x, deposit.position.y + Math.sqrt(deposit.amount) / 2 + 20) | ||
}) | ||
}, [deposits]) | ||
|
||
return ( | ||
<div className="relative w-full h-[400px]"> | ||
<canvas ref={canvasRef} className="w-full h-full" width={800} height={400} /> | ||
{roverPosition && ( | ||
<motion.div | ||
className="absolute w-4 h-4 bg-[#2C4F64] rounded-full" | ||
style={{ left: roverPosition.x, top: roverPosition.y }} | ||
animate={{ scale: [1, 1.2, 1] }} | ||
transition={{ repeat: Infinity, duration: 1 }} | ||
/> | ||
)} | ||
{selectedDeposit && ( | ||
<div | ||
className="absolute w-6 h-6 border-2 border-[#5FCBC3] rounded-full" | ||
style={{ left: selectedDeposit.position.x - 12, top: selectedDeposit.position.y - 12 }} | ||
/> | ||
)} | ||
</div> | ||
) | ||
} |
Oops, something went wrong.