Giter Club home page Giter Club logo

jslib's Issues

add features to error function

add "%o" placeholder with argument "this" and line number ("new Error().lineNumber") to error function

("... Function: %o ... Line: %o ...", this, newError().lineNumber);

raycasting

Add simple raycast that can rotate around a single point (points x and y positions also modifiable) that uses the isColliding() function to detect collision with an object

change menu class

change menu class to this new reworked one:

function Menu() {
	this.defaultstyling = "position:fixed;width:65vw;height:70vh;z-index:5000;background-color:#cecece;border-radius:2em;border-style:solid;border-width:0.2em;border-color:black;border-radius:1.5em;filter:drop-shadow(0.2em 0.2em 0.2em rgba(0,0,0,0.6));";
	this.new = function(id, title, innerhtml) {
		if(id != "demo"){if(isempty(id) || isempty(innerhtml)){error("values for Menu.new() can't be left undefined, empty or null!");return;}}
		if(id == "demo"){title="Demo Menu - Title";innerhtml="This is the content of the menu.<br>You can add <b>HTML</b> <i>tags</i> <u>of</u> <sup>all</sup> <sub>sorts</sub> here,<br>like <button>Buttons</button> or <input type='text' placeholder='Inputs'> or even iframes:<br><iframe src='https://www.example.com'></iframe><br><br>";}
		
		var menu = document.createElement("div");
		menu.id="jsl_menu" + id;
		menu.style=Menu.defaultstyling + "top:120vh;";
		menu.innerHTML='<div class="menu_title" style="font-size:1.5em;text-align:center;padding:0.2em;">' + title + '</div><div style="height:1em;"></div><div class="menu_content" style="font-size:1em;text-align:center;padding:0.2em;">' + innerhtml + '</div><img style="z-index:0;position:absolute;top:0px;right:0px;width:2em;height:2em;cursor:pointer;border-radius:20vw;" title="Close" src="https://raw.githubusercontent.com/Sv443/TextAdventureGame/master/raw_red.png" onclick="Menu.close(' + "'" + id + "'" + ');"></img><img style="z-index:1;position:absolute;top:0px;right:0px;width:2em;height:2em;cursor:pointer;border-radius:20vw;" title="Close" src="https://raw.githubusercontent.com/Sv443/TextAdventureGame/master/whitex.png" onclick="Menu.close(' + "'" + id + "'" + ');"></img>';
		document.body.appendChild(menu);
	}
	this.open = function(id) {
		if(isempty(gebid("jsl_menu" + id))){error("you need to create the menu before you try to open it or you entered the wrong id");return;}
		stylebid("jsl_menu" + id, Menu.defaultstyling + "top:15vh;left:17.5vw;");
		document.addEventListener("keydown", function(e){if(e.keyCode == 27){Menu.close(id);}});
	}
	this.close = function(id) {
		if(isempty(gebid("jsl_menu" + id))){error("you need to create the menu before you try to close it or you entered the wrong id");return;}
		stylebid("jsl_menu" + id, Menu.defaultstyling + "top:120vh;");
	}
	this.theme = function(theme) {
		if(theme == "light"){
			Menu.defaultstyling = "position:fixed;width:65vw;height:70vh;z-index:5000;background-color:#cecece;border-radius:2em;border-style:solid;border-width:0.2em;border-color:black;border-radius:1.5em;filter:drop-shadow(0.2em 0.2em 0.2em rgba(0,0,0,0.6));";
		}
		else if(theme == "dark") {
			Menu.defaultstyling = "position:fixed;width:65vw;height:70vh;z-index:5000;background-color:#353535;border-radius:2em;border-style:solid;border-width:0.2em;border-color:white;border-radius:1.5em;color:white;filter:drop-shadow(0.2em 0.2em 0.2em rgba(0,0,0,0.6));";
		}
	}
	this.demonstrate = function() {
		Menu.new('demo');
		Menu.open('demo');
	}
}

collision detection

add this collision function:

function isColliding(a, b) {
    return !(
        ((a.y + a.height) < (b.y)) ||
        (a.y > (b.y + b.height)) ||
        ((a.x + a.width) < b.x) ||
        (a.x > (b.x + b.width))
    );
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.