-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ea8a17
commit 570e20e
Showing
12 changed files
with
1,949 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,59 @@ | ||
export const CELL_SIZE = 32; | ||
|
||
export function getCellImage(cell: string) { | ||
if (cell === "Z") { | ||
return ( | ||
<img | ||
src="/entities/zombie_alive_1.svg" | ||
alt="Zombie" | ||
className="w-full h-full" | ||
/> | ||
); | ||
} | ||
if (cell === "P") { | ||
return ( | ||
<img | ||
src="/entities/player_alive_1.svg" | ||
alt="Player" | ||
className="w-full h-full" | ||
/> | ||
); | ||
} | ||
if (cell === "R") { | ||
return ( | ||
<img src="/entities/rocks.png" alt="Block" className="w-full h-full" /> | ||
); | ||
} | ||
if (cell === "B") { | ||
return ( | ||
<img src="/entities/block.svg" alt="Block" className="w-full h-full" /> | ||
); | ||
} | ||
return null; | ||
} | ||
|
||
export function Map({ map }: { map: string[][] }) { | ||
return ( | ||
<div> | ||
{map.map((row, y) => ( | ||
<div key={y} className="flex"> | ||
{row.map((cell, x) => ( | ||
<div | ||
key={x} | ||
className={`size-16 border flex items-center justify-center text-2xl dark:bg-black bg-slate-50`} | ||
> | ||
{cell} | ||
</div> | ||
))} | ||
</div> | ||
))} | ||
<div className="relative"> | ||
<img | ||
src="/map.png" | ||
alt="Background Map" | ||
className="absolute inset-0 w-full h-full object-cover opacity-50" | ||
/> | ||
<div className="relative z-10"> | ||
{map.map((row, y) => ( | ||
<div key={y} className="flex"> | ||
{row.map((cell, x) => ( | ||
<div | ||
key={x} | ||
className={`size-16 border dark:border-gray-300 border-gray-700 flex items-center justify-center text-2xl bg-transparent`} | ||
> | ||
{getCellImage(cell)} | ||
</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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.