Friday, March 24, 2017

a difficult introduction

<script>
function sns20170324f1111(request) {

function getwhattomove() {
return document.getElementById("sns20170324f1111whattomove")}
function getspeed() {
return document.getElementById("sns20170324f1111speed")}
function getmotion() {
return document.getElementById("sns20170324f1111motion")}
function getdirection() {
return document.getElementById("sns20170324f1111direction")}
function getframe() {
return document.getElementById(getwhattomove())}

function startmotion() {
getmotion.innerHTML = 1
move()}
function stopmotion() {getmotion.innerHTML = 0}

function move() {
if (getmotion.innerHTML === "1") {updown();leftright();plusminus()}
setTimeout (move,100)}

deprecated
function up() {
var frame = getframe()
var pos = frame.style.top[frame.style.top.length - 1]
frame.style.top = (frame.style.top - getspeed()) + pos}
deprecated

function updown() {
var frame = getframe()
var speed = parseFloat(getupdownspeed().innerHTML)
frame.style.top = frame.style.top + speed}

OK, what's the logic, here?
the state of motion is stored in some elements
the what to move element
and i think three direction elements: updown, leftright, and plusminus
and a speed element

the move function calls updown(), leftright(), and plusminus() if (getmotion.innerHTML === "1")
then calls itself again

Nice!

So, the elements that store motion information are:
<div id="sns20170324f1111motion"></div>
<div id="sns20170324f1111speed"></div>
...
it could be done as an array ... as arrays ...
there are three speeds, updownspeed, leftrightspeed, and plusminusspeed
there are three directions, plusminusdirection ...
oh, but negative and positive speed values indicate direction

in that case:
<div id="sns20170324f1111updownspeed"></div>
<div id="sns20170324f1111leftrightspeed"></div>
<div id="sns20170324f1111plusminusspeed"></div>
(will be easier)

let's think about how motion gets ... adjusted
eight buttons: up, down, left, right, plus, minus, faster, and slower

ooooops
too complicated
wait
no
but

the up button should start up motion at the ... oh no ...
ok, there's one speed for all motion

wait ... wait!

i've always fantasized there would be a separate speed control for each motion




} // sns20170324f1111
</script>

No comments:

Post a Comment