GlennimusPrime Posted November 23, 2022 Share Posted November 23, 2022 (edited) I'm trying to make a vex timer that colours a point travelling along a line. I've managed to make a time multiplier control to slow down the speed of the moving colour point, and also a frame offset control to set the start frame for the action to happen. What I'd love to implement is a way to set the amount of time the point is coloured - So if the time multiplier is set very low and the point colour is moving slowly, I'd like to be able to set the amount of frames the coloured point is visible for. As I'm always learning, I'd love if someone could take a look over this VEX and let me know if I've even set this up correctly and I am most open to changes if I have set this up poorly, or it can be shortened in any way. int time = $T*chf("time_mult")*$FPS; int time2 = floor(time - ($RFSTART-1) * chf("time_mult")); int time3 = time2 - chi("frame_offset") * chf("time_mult"); if (time3 != @ptnum){ @Cd = (0,0,0); } else { @Cd = set(1,0,0); } .hip file also attached. VEX_Timer.hiplc Edited November 23, 2022 by GlennimusPrime Quote Link to comment Share on other sites More sharing options...
3dome Posted November 24, 2022 Share Posted November 24, 2022 have a look at the scene or try my code...not sure if that's what you're after int speed = chi("num_frames_between_move"); int frames_on = chi("num_frames_turned_on"); int pt_to_turn_on = (@Frame-1000) / (speed + frames_on); int on = @Frame % (speed + frames_on) < frames_on; if(on && @ptnum==pt_to_turn_on) @Cd = {0,1,0}; dm_VEX_Timer.hiplc Quote Link to comment Share on other sites More sharing options...
GlennimusPrime Posted November 25, 2022 Author Share Posted November 25, 2022 (edited) Very close! Thanks for giving this a go @3dome, it almost works! If I set the num of frames between to 6 and the number of frames turned on to 3, the green dot seems to jump back one spot and then continue forward. I'd also love to implement a frame offset slider into this too if possible. I think some of your code here can help me try to work this out, but if anyone else has any ideas, they'd be greatly appreciated. Edited November 25, 2022 by GlennimusPrime Quote Link to comment Share on other sites More sharing options...
3dome Posted November 28, 2022 Share Posted November 28, 2022 (edited) On 11/25/2022 at 1:47 AM, GlennimusPrime said: Very close! Thanks for giving this a go @3dome, it almost works! If I set the num of frames between to 6 and the number of frames turned on to 3, the green dot seems to jump back one spot and then continue forward. I'd also love to implement a frame offset slider into this too if possible. I think some of your code here can help me try to work this out, but if anyone else has any ideas, they'd be greatly appreciated. yeah you're right, sorry for not thoroughly testing my code. here's an update that now should work fine and also has a offset parameter: (Edit: that variable name frame_from_one doesn't make sense as it's actually 0 when the first point turns green) //put $RFSTART into the parameter. Remove the -1 if you //don't want the first frame to be already counted int rfstart = chi("rfstart")-1; int offset = chi("offset"); int frame_from_one = int(@Frame - rfstart - offset); int speed = chi("num_frames_between_move"); int frames_on = chi("num_frames_turned_on"); int pt_to_turn_on = frame_from_one / (speed + frames_on); int on = frame_from_one % (speed + frames_on) < frames_on; if(frame_from_one >= 0 && (on && @ptnum==pt_to_turn_on)) @Cd = {0,1,0}; dm_VEX_Timer.hiplc Edited November 28, 2022 by 3dome 1 Quote Link to comment Share on other sites More sharing options...
GlennimusPrime Posted November 28, 2022 Author Share Posted November 28, 2022 This is great! Thanks so much @3dome, I can learn a lot from what you've built here for me. Nice to see how others piece together VEX, always something new to learn! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.