xxxxxxxxxx
159
const sundown = 62;
const sunrise = 89;
const Sol = 36000;
var dai = 0;
var me = new stats();
var sun = 0;
var moon = 0;
var task = [];
var descript = [];
var button = [];
var here = die;
var beasts=[];
// globals
var here = die;
var there = 0;
var acts = [];
//keys
var ngkey = false;
var sgkey = false;
var cache = false;
function setup() {
createCanvas(800, 800);
translate(210, 200);
loadIt();
show();
}
function saveIt() {
localStorage.setItem("saveLHRM", JSON.stringify(me));
}
function loadIt() {
var yu = JSON.parse(localStorage.getItem("saveLHRM"));
if(yu==null){yu=new stats();}
yu.agility = new skill("agility", yu.agility.level, yu.agility.Mlevel);
yu.strength = new skill("strength", yu.strength.level, yu.strength.Mlevel);
yu.dexterity = new skill("dexterity",yu.dexterity.level,yu.dexterity.Mlevel);
yu.constitution = new skill("constitution",yu.constitution.level,yu.constitution.Mlevel);
yu.speed = new skill("speed", yu.speed.level, yu.speed.Mlevel);
yu.spirit = new skill("spirit", yu.spirit.level, yu.spirit.Mlevel);
yu.charisma = new skill("charisma", yu.charisma.level, yu.charisma.Mlevel);
yu.endurance = new skill("endurance",yu.endurance.level,yu.endurance.Mlevel);
yu.intelligence = new skill("intelligence",yu.intelligence.level,yu.intelligence.Mlevel);
yu.criminality = new skill("criminality",yu.criminality.level,yu.criminality.Mlevel);
yu.show = me.show;
me = yu;
saveIt();
}
function show() {
me.minu++;
me.energy -= 1 / (1 + me.endurance.level);
me.drunk = me.drunk * 0.99;
strokeWeight(3);
// background(180, 180, 200);
if (here!=die && here!=collapse)
{
if(me.energy<0)go(collapse);
if(me.hp<0)go(die);
}
if (key == "0") here.show();
if (there != here) {
descript = [];
killButts();
here.code();
}
stars();
//action bar
fill(150, 150, 80);
rect(-200, 0, 400, 40, 2);
ShowActs();
sheet();
here.code();
there = here;
saveIt()
}
function keyPressed() {
show();
}
var sun =0;
function stars() {
sun = createVector(-170, 0);
sun = sun.rotate((me.minu * TAU) / 80);
fill(40 - sun.y, 20 - sun.y, 10 - sun.y * 2);
circle(0, 0, 380);
fill(200, 200, 80);
if (sun.y < 30) {
circle(sun.x, sun.y, 39);
circle(sun.x, sun.y, 8);
}
moon = createVector(0, -170);
moon = moon.rotate(me.minu * (TAU / 80 + TAU / 2800));
fill(200, 200, 150);
if (moon.y < 30) {
circle(moon.x, moon.y, 39);
}
//draw the stars
textAlign(CENTER);
randomSeed(1);
for (i = 0; i < 800; i++) {
textSize(random(2, 20));
fill(200 + random(50), 200 + random(50), 200 + random(50), sun.y + 30);
var star = createVector(random(-400, 400), random(-400, 400));
star.rotate((me.minu * TAU) / 80);
if (star.y < 10 && mag(star.x, star.y) < 180) text("𓇼", star.x, star.y);
}
randomSeed(millis());
textAlign(LEFT);
fill(0);
var y = -180;
text("Year "+round(1+me.minu/Sol),-200,y);
text("Month "+round(1+me.minu/Sol/10),-200,y+=20);
text("Week "+round(1+me.minu/Sol/12/4),-200,y+=20);
text("Day "+round(1+me.minu/Sol/12/4/9),-200,y+=20);
text("Hour "+round(1+(me.minu%100)/10),-200,y+=20);
text(round(1+(me.minu%100)),-200,y+=20);
}
function say(A) {
acts.push(A);
ShowActs();
}
function ShowActs() {
fill(150, 125, 125);
rect(-200, 320, 400, 270, 10, 10);
fill(0);
textSize(20);
while (acts.length > 12) acts.shift(); //trim
fill(0);
for (i = 0; i < acts.length; i++) {
fill(0);
text(acts[i], -175, 325 + i * 21, 500);
noFill();
rect(-200,325+i*21,400,21);
}
}
function desc(A) {
fill(150, 125, 125);
rect(-200, 40, 400, 280, 10, 10);
fill(0);
textSize(20);
text(A, -180, 60, 380);
}
function clr() {
acts = [];
}