Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Refactor name of var
Browse files Browse the repository at this point in the history
  • Loading branch information
Andru1999 committed Aug 1, 2018
1 parent 671d6fe commit efebe70
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Game/TestGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ window.onload = () => {
}).start();

}
LoadBaseResurses(eval_after_load_resurses);
loadBaseResurses(eval_after_load_resurses);
};

class Game {
Expand Down
116 changes: 58 additions & 58 deletions GraphicsEngine/ResursesLoader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";

function LoadBaseResurses(func) {
var TexturesArr = {};
var BaseSpritesArr = {};
var ImgArr = {};
function loadBaseResurses(func) {
var Textures = {};
var Sprites = {};
var Images = {};
// Почему размер клетки здесь?
var BaseCellSize = new Size(BaseCellHeight, BaseCellWidth);
LoadImg(
loadImg(
[
'Assets/BlueWallAndFloor.png',
'Assets/GreyWallAndFloor.png',
Expand All @@ -26,7 +27,7 @@ function LoadBaseResurses(func) {
"Assets/dmgsprite.png"
], func);

function LoadImg(urlArr, func) {
function loadImg(urlArr, func) {
let SothigToFixAJAX = urlArr.length;

function _load(url) {
Expand All @@ -43,69 +44,68 @@ function LoadBaseResurses(func) {
}

urlArr.forEach(function (url) {
ImgArr[url] = _load(url);
Images[url] = _load(url);
});
}


function genTextures(func) {
function AddBaseTexture(img, dx, dy, name) {
TexturesArr[name] = new Texture(img, dx, dy);
function addBaseTexture(img, dx, dy, name) {
Textures[name] = new Texture(img, dx, dy);
}

AddBaseTexture(ImgArr['Assets/BlueWallAndFloor.png'], 64, 64, "BlueWalls&Floor");
AddBaseTexture(ImgArr['Assets/GreyWallAndFloor.png'], 64, 64, "GreyWalls&Floor");
AddBaseTexture(ImgArr['Assets/WhiteWallAndFloor.png'], 64, 64, "WhiteWalls&Floor");
AddBaseTexture(ImgArr['Assets/Void.png'], 64, 64, "VoidTexture");
AddBaseTexture(ImgArr['Assets/Smoke.png'], 64, 64, "Smoke");
AddBaseTexture(ImgArr['Assets/WalkableSpace.png'], 64, 64, "WalkableSpase");
AddBaseTexture(ImgArr['Assets/AttackSpace.png'], 64, 64, "AttakSpase");
AddBaseTexture(ImgArr["Assets/mobs.png"], 16, 16, "Mobs");
AddBaseTexture(ImgArr['Assets/Hero.png'], 16, 21, "Hero");
AddBaseTexture(ImgArr["Assets/ExitButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "ExitButton");
AddBaseTexture(ImgArr["Assets/StartButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "StartButton");
AddBaseTexture(ImgArr["Assets/BackButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "BacktButton");
AddBaseTexture(ImgArr["Assets/OptionButton.png"], ImgArr["Assets/OptionButton.png"].width, ImgArr["Assets/OptionButton.png"].height, "OptionButton");
AddBaseTexture(ImgArr["Assets/AttackMoveButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "AttackMoveButton");
AddBaseTexture(ImgArr["Assets/NextButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "NextButton");
AddBaseTexture(ImgArr["Assets/MagicButton.png"], ImgArr["Assets/ExitButton.png"].width, ImgArr["Assets/ExitButton.png"].height, "MagicButton");
AddBaseTexture(ImgArr["Assets/dmgsprite.png"], 39, 39, "DmgTexture");
genBaseSprites(func);
addBaseTexture(Images['Assets/BlueWallAndFloor.png'], 64, 64, "BlueWalls&Floor");
addBaseTexture(Images['Assets/GreyWallAndFloor.png'], 64, 64, "GreyWalls&Floor");
addBaseTexture(Images['Assets/WhiteWallAndFloor.png'], 64, 64, "WhiteWalls&Floor");
addBaseTexture(Images['Assets/Void.png'], 64, 64, "VoidTexture");
addBaseTexture(Images['Assets/Smoke.png'], 64, 64, "Smoke");
addBaseTexture(Images['Assets/WalkableSpace.png'], 64, 64, "WalkableSpase");
addBaseTexture(Images['Assets/AttackSpace.png'], 64, 64, "AttakSpase");
addBaseTexture(Images["Assets/mobs.png"], 16, 16, "Mobs");
addBaseTexture(Images['Assets/Hero.png'], 16, 21, "Hero");
addBaseTexture(Images["Assets/ExitButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "ExitButton");
addBaseTexture(Images["Assets/StartButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "StartButton");
addBaseTexture(Images["Assets/BackButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "BacktButton");
addBaseTexture(Images["Assets/OptionButton.png"], Images["Assets/OptionButton.png"].width, Images["Assets/OptionButton.png"].height, "OptionButton");
addBaseTexture(Images["Assets/AttackMoveButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "AttackMoveButton");
addBaseTexture(Images["Assets/NextButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "NextButton");
addBaseTexture(Images["Assets/MagicButton.png"], Images["Assets/ExitButton.png"].width, Images["Assets/ExitButton.png"].height, "MagicButton");
addBaseTexture(Images["Assets/dmgsprite.png"], 39, 39, "DmgTexture");
genSprites(func);
}

function genBaseSprites(func) {
function AddBaseSkin(name, basetexture, size, framesArr) {
if (BaseSpritesArr[name] == undefined) {
BaseSpritesArr[name] = [];
}
BaseSpritesArr[name].push(new BaseSprite(TexturesArr[basetexture], size, framesArr));
function genSprites(func) {
function addBaseSkin(name, basetexture, size, framesArr) {
if (!Sprites[name])
Sprites[name] = [];
Sprites[name].push(new BaseSprite(Textures[basetexture], size, framesArr));
}

AddBaseSkin("wall", "BlueWalls&Floor", BaseCellSize, [0]);
AddBaseSkin("floor", "BlueWalls&Floor", BaseCellSize, [1]);
AddBaseSkin("wall", "GreyWalls&Floor", BaseCellSize, [0]);
AddBaseSkin("floor", "GreyWalls&Floor", BaseCellSize, [1]);
AddBaseSkin("wall", "WhiteWalls&Floor", BaseCellSize, [0]);
AddBaseSkin("floor", "WhiteWalls&Floor", BaseCellSize, [1]);
AddBaseSkin("void", "VoidTexture", BaseCellSize, [0]);
AddBaseSkin("hero", "Hero", BaseCellSize, [0]);
AddBaseSkin("hero", "Hero", BaseCellSize, [1]);
AddBaseSkin("hero", "Hero", BaseCellSize, [2]);
AddBaseSkin("hero", "Hero", BaseCellSize, [3]);
AddBaseSkin("area", "WalkableSpase", BaseCellSize, [0]);
AddBaseSkin("area", "AttakSpase", BaseCellSize, [0]);
AddBaseSkin("smoke", "Smoke", BaseCellSize, [0]);
AddBaseSkin("mob", "Mobs", BaseCellSize, [0]);
AddBaseSkin("mob", "Mobs", BaseCellSize, [1]);
AddBaseSkin("buttons", "StartButton", new Size(ImgArr["Assets/ExitButton.png"].width / 6, ImgArr["Assets/ExitButton.png"].height / 6), [0,1]); //0
AddBaseSkin("buttons", "ExitButton", new Size(ImgArr["Assets/ExitButton.png"].width / 6, ImgArr["Assets/ExitButton.png"].height / 6), [0]); //1
AddBaseSkin("buttons", "BacktButton", new Size(ImgArr["Assets/ExitButton.png"].width / 6, ImgArr["Assets/ExitButton.png"].height / 6), [0]); //2
AddBaseSkin("buttons", "AttackMoveButton", new Size(ImgArr["Assets/ExitButton.png"].width / 8, ImgArr["Assets/ExitButton.png"].height / 8), [0,1]); //3
AddBaseSkin("buttons", "OptionButton", new Size(ImgArr["Assets/OptionButton.png"].width / 8, ImgArr["Assets/OptionButton.png"].height / 8), [0]); //4
AddBaseSkin("buttons", "NextButton", new Size(ImgArr["Assets/ExitButton.png"].width / 8, ImgArr["Assets/ExitButton.png"].height / 8), [0]); //5
AddBaseSkin("buttons", "MagicButton", new Size(ImgArr["Assets/ExitButton.png"].width / 8, ImgArr["Assets/ExitButton.png"].height / 8), [0]); //6
AddBaseSkin("dmg", "DmgTexture", BaseCellSize, [0,1,2,3,4,5,6,7,8,9,10,11,12]); //6
func(BaseSpritesArr);
addBaseSkin("wall", "BlueWalls&Floor", BaseCellSize, [0]);
addBaseSkin("floor", "BlueWalls&Floor", BaseCellSize, [1]);
addBaseSkin("wall", "GreyWalls&Floor", BaseCellSize, [0]);
addBaseSkin("floor", "GreyWalls&Floor", BaseCellSize, [1]);
addBaseSkin("wall", "WhiteWalls&Floor", BaseCellSize, [0]);
addBaseSkin("floor", "WhiteWalls&Floor", BaseCellSize, [1]);
addBaseSkin("void", "VoidTexture", BaseCellSize, [0]);
addBaseSkin("hero", "Hero", BaseCellSize, [0]);
addBaseSkin("hero", "Hero", BaseCellSize, [1]);
addBaseSkin("hero", "Hero", BaseCellSize, [2]);
addBaseSkin("hero", "Hero", BaseCellSize, [3]);
addBaseSkin("area", "WalkableSpase", BaseCellSize, [0]);
addBaseSkin("area", "AttakSpase", BaseCellSize, [0]);
addBaseSkin("smoke", "Smoke", BaseCellSize, [0]);
addBaseSkin("mob", "Mobs", BaseCellSize, [0]);
addBaseSkin("mob", "Mobs", BaseCellSize, [1]);
addBaseSkin("buttons", "StartButton", new Size(Images["Assets/ExitButton.png"].width / 6, Images["Assets/ExitButton.png"].height / 6), [0,1]); //0
addBaseSkin("buttons", "ExitButton", new Size(Images["Assets/ExitButton.png"].width / 6, Images["Assets/ExitButton.png"].height / 6), [0]); //1
addBaseSkin("buttons", "BacktButton", new Size(Images["Assets/ExitButton.png"].width / 6, Images["Assets/ExitButton.png"].height / 6), [0]); //2
addBaseSkin("buttons", "AttackMoveButton", new Size(Images["Assets/ExitButton.png"].width / 8, Images["Assets/ExitButton.png"].height / 8), [0,1]); //3
addBaseSkin("buttons", "OptionButton", new Size(Images["Assets/OptionButton.png"].width / 8, Images["Assets/OptionButton.png"].height / 8), [0]); //4
addBaseSkin("buttons", "NextButton", new Size(Images["Assets/ExitButton.png"].width / 8, Images["Assets/ExitButton.png"].height / 8), [0]); //5
addBaseSkin("buttons", "MagicButton", new Size(Images["Assets/ExitButton.png"].width / 8, Images["Assets/ExitButton.png"].height / 8), [0]); //6
addBaseSkin("dmg", "DmgTexture", BaseCellSize, [0,1,2,3,4,5,6,7,8,9,10,11,12]); //6
func(Sprites);
}

}
Expand Down

0 comments on commit efebe70

Please sign in to comment.