Here's the code. I'm trying to create a value (VARIABLE1) that changes cyclically based on time.
FRAMERATE = 40
Sync On
Sync Rate FRAMERATE
SYNCCOUNT = 0
VAR1 = 47 `start value
VARIABLE1 = VAR1
VARIABLE1MAX = 863 `max value
VAR1TIME = 4 `time to complete cycle
PATHFRAMES1=FRAMERATE*VAR1TIME `framerate times seconds in the route
DIM Mover1(PATHFRAMES1)
for P = 1 to PATHFRAMES1
Mover1(P)=0
next P
FRAMENUMBER1=1
do
gosub Coords
gosub Debug
gosub RefScr
loop
REMSTART
You can set additional operations using:
if FRAMENUMBER# (operation) (anything from 1 to PATHFRAMES#)
REMEND
Coords:
REM This cycles from ~VARIABLE1 to ~VARIABLE1MAX and back again
inc FRAMENUMBER1,1
if FRAMENUMBER1 = PATHFRAMES1+1
FRAMENUMBER1 = 1 `reset cycle
endif
if FRAMENUMBER1 <= PATHFRAMES1/(VAR1TIME/2)
VARIABLE1 = VARIABLE1 + (abs(VARIABLE1MAX-VAR1)/(PATHFRAMES1/2)) `increases value until the halfway point of the cycle
endif
if FRAMENUMBER1 > PATHFRAMES1/(VAR1TIME/2)
VARIABLE1 = VARIABLE1 - (abs(VARIABLE1MAX-VAR1)/(PATHFRAMES1/2)) `decreases value after the halfway point of the cycle
endif
Mover1(FRAMENUMBER1) = VARIABLE1
return
Debug:
set cursor VARIABLE1,0 `so you can see it change
print VARIABLE1
seconds = SYNCCOUNT/FRAMERATE
print seconds
print Mover1(1)
print Mover1(40)
print Mover1(80)
print Mover1(120)
return
RefScr:
inc SYNCCOUNT,1
sync
cls
return
The problem is, VARIABLE1 decreases faster than it increases. Every cycle returns lower values. But VARIABLE1 is increasing by a fixed value 80 times (from 1 to 80), and then it decreases by the same rate 80 times (81 to 160). Where does the extra decrease come from?