Advertisement
jargon

Keal's Sprite Lookup Unit Test

Nov 15th, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.39 KB | Gaming | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Keal's Sprite Lookup Unit Test</title>
  5. </head>
  6. <body>
  7. <script>
  8. // SparkedJS (Beta 2 A) :: "CSV/Frame Lookup.js"
  9.  
  10. var Maps = {};
  11.  
  12. var player;
  13.  
  14. player.map = 0;
  15.  
  16. Maps[player.map] = {
  17.     colorMap: {
  18.         "0": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Passage" },
  19.         "1": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Barrier" },
  20.         "2": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Passage" },
  21.         "3": { Sprite: "Sprite: \"Shield\" (Frame 1/1)", Cast: "Shield" },
  22.         "4": { Sprite: "Sprite: \"Bomb\" (Frame 1/1)", Cast: "Bomb" },
  23.         "5": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Passage" },
  24.         "6": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Mine" },
  25.         "7": { Sprite: "Sprite: \"Tank\" (Frame 1/1)", Cast: "Tank" },
  26.         "8": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Mine" },
  27.         "9": { Sprite: "Sprite: \"Passage\" (Frame 1/1)", Cast: "Passage" },
  28.         "S": { Sprite: "Sprite: \"Exit\" (Frame 1/1)", Cast: "Spawn" },
  29.         "X": { Sprite: "Sprite: \"Wall\" (Frame 1/1)", Cast: "Exit" }
  30.     }
  31. };
  32.  
  33. console.log(Sprite_Index_By_Key(undefined, 0));
  34.  
  35. function Sprite_Index_By_Key(arrayObject = undefined, param = 0) {
  36.        
  37.     if (!arrayObject){
  38.         arrayObject = Maps[player.map].colorMap;
  39.     }
  40.    
  41.     if (typeof param === `number`) param = param.toString();
  42.    
  43.     return Object.keys(arrayObject).find(key => key === param);
  44. }
  45. </script>
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement