Feature Overview
AMID()
Returns the median of a given positive and negative number.
- It is used in controlling the camera and parameters that can swing either + or -.
- This function consumes 10 Token.
x,y=0,0 w,h=16,8 -- range of movement(*2+1) while 1 do cls(12) camera(-64,-64) rectfill(w,h,-w,-h,0) ?'⬆️⬇️⬅️➡️ key to move',-60,-60 x+=tonum(btn(1))-tonum(btn(0)) x=amid(w,x) y+=tonum(btn(3))-tonum(btn(2)) y=amid(h,y) pset(x,y,8) ?x..' '..y,-w,h+1,7 flip() end |
This function will be included in the next version(0.14.0) of KNUTIL library.
If you want to determine that two values are within range, consider INRNG().
release note
[Please log in to post a comment]