JSFiddle - React, Tailwind, and code Playground

by Castrolol

JavaScript

var PrototypeJump = PrototypeJump || {}; //instance namespace

(function(w){

	(function(w){
		
		w.Point = function(x,y,z){
		
			this.x = x || 0;
			this.y = y || 0;
			this.z = z || 0;
			
		};

		w.Point.prototype.add = function(otherPoint){
			
			var retorno = this.clone();
			
			retorno.x += ( otherPoint || {x:0}).x;
			retorno.y += ( otherPoint || {x:0}).y;
			retorno.z += ( otherPoint || {x:0}).z;
			
			return retorno;
		};
		
		w.Point.prototype.clone = function(){
			
			return new w.Point(this.x, this.y, this.z);
			
		};
		
	})(w);

	(function(w){
		w.Size = function(w,h){
		
			this.width = w || 0;
			this.height = h || 0;
			var that = this;
			
			Object.defineProperty(this, "w", {
				set: function(value){
					that.width = value;
				},
				get: function(value){
					return that.width;
				}				
			});
			
			Object.defineProperty(this, "h", {
				set: function(value){
					that.height = value;
				},
				get: function(){
					return that.height;
				}				
			});
		
		};
				
	})(w);

	(function(w){
		
		w.Rect = function(position, size){
			
			this.position = position || new w.Point();
			this.size = size || new w.Size();		
		};
		
		w.Rect.prototype.checkColision = function(rect){
			
			var self = this;
			var other = rect;
			
			var x1 = self.position.x;			
			var y1 = self.position.y;
			var w1 = self.size.w;			
			var h1 = self.size.h;
			
			var x2 = other.position.x;			
			var y2 = other.position.y;
			var w2 = other.size.w;
			var h2 = other.size.h;
			
			if( x1 < x2 ){
				
				if( x1 + w1 > x2 ) {
				
					if( y1 < y2 ){
						
						if( y1 + h1 > y2 ) return true;
					}else{
						if( y2 + h2 > y1 ) return true;												
					}
				
				}
				
			}else {
				
				if( x2 + w2 > x1 ){
					
					if( y1 < y2 ){
						
						if( y1 + h1 > y2 ) return true;
					}else{
						if( y2 + h2 > y1 ) return true;												
					}					
				}
				
			}
			
			return false;
		};
		
		w.Rect.prototype.isInRect =...