Strict


Class Point2D
	Field x: Int
	Field y: Int
	
	Method New(_x: Int, _y: Int)
		x = _x
		y = _y
	End
End

Class IntRect
	Field x: Int, y: Int
	Field w: Int, h: Int
	
	Method New(_x: Int, _y: Int, _w: Int, _h: Int)
		x = _x
		y = _y
		w = _w
		h = _h
	End
End




Function MAX: Int  (a: Int, b: Int)
	If a > b Then Return a
	Return b
End

Function MIN: Int (a: Int, b: Int)
	If a < b Then Return a
	Return b
End

Function MINFLOAT: Float (a: Float, b: Float)
	If a < b Then Return a
	Return b
End

Function MAXFLOAT: Float (a: Float, b: Float)
	If a > b Then Return a
	Return b
End


Function RANGED: Float(v: Float, min: Int, max: Int)
	If v < min Then Return min
	If v > max Then Return max
	Return v
End


Function PointInRect: Bool (r: IntRect, x:Int, y: Int)
	If (y < r.y Or y > r.y+r.h) Return False 
	If (x < r.x Or x > r.x+r.w) Return False 
	
	Return True
End