Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Keal's Sprite Lookup Unit Test</title>
- </head>
- <body>
- <script>
- // SparkedJS (Beta 2 A) :: "CSV/Frame Lookup.js"
- var Maps = {};
- var player;
- player.map = 0;
- Maps[player.map] = {
- colorMap: {
- "0": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Passage" },
- "1": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Barrier" },
- "2": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Passage" },
- "3": { Sprite: "Sprite: \"Shield\" (Frame 1/1)", Cast: "Shield" },
- "4": { Sprite: "Sprite: \"Bomb\" (Frame 1/1)", Cast: "Bomb" },
- "5": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Passage" },
- "6": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Mine" },
- "7": { Sprite: "Sprite: \"Tank\" (Frame 1/1)", Cast: "Tank" },
- "8": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Mine" },
- "9": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Passage" },
- "S": { Sprite: "Sprite: \"Exit\" (Frame 1/1)", Cast: "Spawn" },
- "X": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Exit" }
- }
- };
- console.log(Sprite_Index_By_Key(undefined, 0));
- function Sprite_Index_By_Key(arrayObject = undefined, param = 0) {
- if (!arrayObject){
- arrayObject = Maps[player.map].colorMap;
- }
- if (typeof param === `number`) param = param.toString();
- return Object.keys(arrayObject).find(key => key === param);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement