JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id='canvas' style='border:1px solid black;'>Your browser does not support canvas. Please update your browser.</canvas>
JavaScript
//Get canvas and context
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
//Capture keypresses
var keys = [];
document.onKeyDown = function (e) {keys[e.keyCode] = true;};
document.onKeyUp = function (e) {keys[e.keyCode] = false;};
//Set game variables
var characters = {};
characters.charList = [];
var player = {};
//Character constructor
function Character (Name, Strength, Speed, Intelligence, Reflexes, Age, Height, Weight, Weapon, UsesMagic, MagicType, Armor, Hair, Eyes, Skin, Clothes, Species, Type, Accessories) {
this.name = Name;
this.strength = Strength;
this.speed = Speed;
this.intelligence = Intelligence;
this.reflexes = Reflexes;
this.age = Age;
this.height = Height;
this.weight = Weight;
this.weapon = Weapon;
this.usesMagic = UsesMagic;
this.magicType = MagicType;
this.armor = Armor;
this.hair = Hair;
this.eyes = Eyes;
this.skin = Skin;
this.clothes = Clothes;
this.species = Species;
this.type = Type;
if (Accessories) {
this.accessories = Accessories;
}
characters.charList[characters.charList.length] = Name;
}
characters.Xantar = new Character('Xantar', 1, 1, 1, 1, 1, 1, 1, 'sword', true, 'derp', [], 'hair is brown\?', 'duh', 'foo', [], 'animale', 'wolf', []);
alert(characters.Xantar.weapon + ' ' + characters.Xantar.type);
//Activate mainloop and get value for pausing purposes
var mainloopInterval = setInterval(mainloop, 5);
//Main game loop
function mainloop(){
}