Universal Time?

Building a Space Invaders-style video game activity. Instead of lateral motion, I’m adjusting cannon angle, using button input.

I’m using the “buttonHistory” feature to keep track of barrel endpoint at time the “fire” button is pressed. I’m using timeSincePress to simulate projectile flight. This results in a nifty effect where you can hit “fire” and the projectile speeds away even as the barrel moves.

Unfortunately the firing resets every time you it the “fire” button, because of the timeSincePress reset. The end result is that you the next “fire” triggers two simultaneous shots, one from the new angle, a second from the original.

Is there any way to merge (or hack) the button commands so that the calculator is tracking each moving point under a different time variable?


Cool idea!

If you aren’t going to use the lists, just replace your two u and v numberList lines with:

number(“u_{list}”): button4.history(“xCoord”).elementAt(button4.pressCount)
number(“v_{list}”): button4.history(“yCoord”).elementAt(button4.pressCount)

Your numberList lines are firing the entire lists of captures, which is a wonderful feature if that’s what you want.

Assuming you want to keep the lists of coordinates, you might make another couple of variables and a point – maybe u_{x}=u_{list}, v_{y}=v_{list}, and the point \left(u_{x},\ v_{y}\right)-- and use these in your Collision Detection folder instead of u_{list} and v_{list}. Hide the list variable graph and show the other point. Add two lines to your graph1 computation layer:

number(“u_{x}”): button4.history(“xCoord”).elementAt(button4.pressCount)
number(“v_{x}”): button4.history(“yCoord”).elementAt(button4.pressCount)

The numberList and trajectories could be used to make a simple firework display.

Thanks! I’ll give this code a try tonight.

In the meantime, I hacked a game clock that effectively “timestamps” each button click. It’s not as elegant as sophisticated as the commands you give here, but I was pretty proud of myself.