Card renderer with sprites, tiles

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












This contains the elements of the map rendered in the variables (characters, sprites, tiles). However, I have not yet added any comment for the functions. It does not really help me move forward.



import constants from 'engine/constants';
import MapPoint from 'engine/MapPoint';
import cache, downloadTextures from 'engine/AssetsManager';

var characters = ;
var cells = ;
var sprites = ;

exports.characters = characters;
exports.cells = cells;
exports.sprites = sprites;

const drawTile = ( tileset, tile, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (tileset)
image = cache.tilesets[tileset][tile];

else
image = cache.tiles[tile];


context.drawImage(image, screenX, screenY, width, height);
;

exports.drawTile = drawTile;

const drawSprite = ( spritesheet, sprite, index, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (spritesheet)
image = cache.spritesheets[spritesheet][sprite];

else
image = cache.spritesheets[sprite];


context.drawImage(image, screenX, screenY, width, height);


exports.drawSprite = drawSprite;

const setGameMapData = informations =>

const onTexturesLoaded = () =>
characters = informations.characters;
cells = informations.cells;
sprites = informations.textures.filter(texture => texture.sprite)
tiles = informations.textures.filter(texture => texture.tile)
;

downloadTextures(informations.textures, onTexturesLoaded);
;

exports.setGameMapData = setGameMapData;






share|improve this question

















  • 1




    Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
    – Sam Onela
    Jan 9 at 18:44
















up vote
0
down vote

favorite












This contains the elements of the map rendered in the variables (characters, sprites, tiles). However, I have not yet added any comment for the functions. It does not really help me move forward.



import constants from 'engine/constants';
import MapPoint from 'engine/MapPoint';
import cache, downloadTextures from 'engine/AssetsManager';

var characters = ;
var cells = ;
var sprites = ;

exports.characters = characters;
exports.cells = cells;
exports.sprites = sprites;

const drawTile = ( tileset, tile, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (tileset)
image = cache.tilesets[tileset][tile];

else
image = cache.tiles[tile];


context.drawImage(image, screenX, screenY, width, height);
;

exports.drawTile = drawTile;

const drawSprite = ( spritesheet, sprite, index, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (spritesheet)
image = cache.spritesheets[spritesheet][sprite];

else
image = cache.spritesheets[sprite];


context.drawImage(image, screenX, screenY, width, height);


exports.drawSprite = drawSprite;

const setGameMapData = informations =>

const onTexturesLoaded = () =>
characters = informations.characters;
cells = informations.cells;
sprites = informations.textures.filter(texture => texture.sprite)
tiles = informations.textures.filter(texture => texture.tile)
;

downloadTextures(informations.textures, onTexturesLoaded);
;

exports.setGameMapData = setGameMapData;






share|improve this question

















  • 1




    Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
    – Sam Onela
    Jan 9 at 18:44












up vote
0
down vote

favorite









up vote
0
down vote

favorite











This contains the elements of the map rendered in the variables (characters, sprites, tiles). However, I have not yet added any comment for the functions. It does not really help me move forward.



import constants from 'engine/constants';
import MapPoint from 'engine/MapPoint';
import cache, downloadTextures from 'engine/AssetsManager';

var characters = ;
var cells = ;
var sprites = ;

exports.characters = characters;
exports.cells = cells;
exports.sprites = sprites;

const drawTile = ( tileset, tile, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (tileset)
image = cache.tilesets[tileset][tile];

else
image = cache.tiles[tile];


context.drawImage(image, screenX, screenY, width, height);
;

exports.drawTile = drawTile;

const drawSprite = ( spritesheet, sprite, index, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (spritesheet)
image = cache.spritesheets[spritesheet][sprite];

else
image = cache.spritesheets[sprite];


context.drawImage(image, screenX, screenY, width, height);


exports.drawSprite = drawSprite;

const setGameMapData = informations =>

const onTexturesLoaded = () =>
characters = informations.characters;
cells = informations.cells;
sprites = informations.textures.filter(texture => texture.sprite)
tiles = informations.textures.filter(texture => texture.tile)
;

downloadTextures(informations.textures, onTexturesLoaded);
;

exports.setGameMapData = setGameMapData;






share|improve this question













This contains the elements of the map rendered in the variables (characters, sprites, tiles). However, I have not yet added any comment for the functions. It does not really help me move forward.



import constants from 'engine/constants';
import MapPoint from 'engine/MapPoint';
import cache, downloadTextures from 'engine/AssetsManager';

var characters = ;
var cells = ;
var sprites = ;

exports.characters = characters;
exports.cells = cells;
exports.sprites = sprites;

const drawTile = ( tileset, tile, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (tileset)
image = cache.tilesets[tileset][tile];

else
image = cache.tiles[tile];


context.drawImage(image, screenX, screenY, width, height);
;

exports.drawTile = drawTile;

const drawSprite = ( spritesheet, sprite, index, width, height ) =>
var image;
var screenX = 0, screenY = 0;

if (spritesheet)
image = cache.spritesheets[spritesheet][sprite];

else
image = cache.spritesheets[sprite];


context.drawImage(image, screenX, screenY, width, height);


exports.drawSprite = drawSprite;

const setGameMapData = informations =>

const onTexturesLoaded = () =>
characters = informations.characters;
cells = informations.cells;
sprites = informations.textures.filter(texture => texture.sprite)
tiles = informations.textures.filter(texture => texture.tile)
;

downloadTextures(informations.textures, onTexturesLoaded);
;

exports.setGameMapData = setGameMapData;








share|improve this question












share|improve this question




share|improve this question








edited Jan 14 at 23:39









Jamal♦

30.1k11114225




30.1k11114225









asked Jan 9 at 12:17









ken

325




325







  • 1




    Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
    – Sam Onela
    Jan 9 at 18:44












  • 1




    Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
    – Sam Onela
    Jan 9 at 18:44







1




1




Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
– Sam Onela
Jan 9 at 18:44




Welcome to Code Review! I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to edit and give it a different title if there is something more appropriate. Also, per "I think you think of lol" - are you thinking we are laughing out loud?
– Sam Onela
Jan 9 at 18:44















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f184651%2fcard-renderer-with-sprites-tiles%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f184651%2fcard-renderer-with-sprites-tiles%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Python Lists

Aion

JavaScript Array Iteration Methods