I'm working on a way to use the keypad as a rudimentary track-pad to move an object on-screen.
So far it's been working decently.

Code:
DAARSE
det(0
//sets colors to black
det(2,000
//draws boarders
det(36,290,0,320,240
det(36,0,0,50,240
det(36,50,0,290,50
//repeats untill [del] is pressed
Repeat getKey(56)
getKey→KEY
//checks if user pressed a key
If KEY
//sets color to white
det(2,255
//clears the  section of the screen that the cursor can move. (I'll be replacing this with a better way later)
det(36,50,50,240,240
//sets color to some green color
det(2,102
End
//checks that the keys are within the 'track pad' boundries
If KEY≤46 and KEY≥10 and KEY≠39 and KEY≠31 and KEY≠23 and KEY≠15
//displays a circle at the coordinates
det(33,320-((KEY/8)*50),300-remainder(KEY,8)*40,5
End
End
det(1

(I've been doing on-calc programming, I haven't gotten to the point where I need SC yet) Razz

Next I'd like to add a projectile, that uses realistic physics, and will jump from a random point of the bottom of the screen, fly up a random height, then lands on the bottom of the screen at a random point. I know I need to use a quadratic formula, but I'm not sure how to add the realistic physics. How would I do this?
TheLastMillennial wrote:
I'm working on a way to use the keypad as a rudimentary track-pad to move an object on-screen.
So far it's been working decently.

Code:
DAARSE
det(0
//sets colors to black
det(2,000
//draws boarders
det(36,290,0,320,240
det(36,0,0,50,240
det(36,50,0,290,50
//repeats untill [del] is pressed
Repeat getKey(56)
getKey→KEY
//checks if user pressed a key
If KEY
//sets color to white
det(2,255
//clears the  section of the screen that the cursor can move. (I'll be replacing this with a better way later)
det(36,50,50,240,240
//sets color to some green color
det(2,102
End
//checks that the keys are within the 'track pad' boundries
If KEY≤46 and KEY≥10 and KEY≠39 and KEY≠31 and KEY≠23 and KEY≠15
//displays a circle at the coordinates
det(33,320-((KEY/8)*50),300-remainder(KEY,8)*40,5
End
End
det(1

(I've been doing on-calc programming, I haven't gotten to the point where I need SC yet) Razz

Next I'd like to add a projectile, that uses realistic physics, and will jump from a random point of the bottom of the screen, fly up a random height, then lands on the bottom of the screen at a random point. I know I need to use a quadratic formula, but I'm not sure how to add the realistic physics. How would I do this?

Sooooo fruit ninja Razz
There is actually a really cool port that was made for the monochromes back in the day, which used the keyboard as some sort of trackpad (you would swipe across, hitting a bunch of buttons to slice the fruit)
Here is a link to that
Ok time for some projectile mechanics Razz
I will be using frictionless motion, because it is much easier to calculate, and adding in some friction really wouldn't add anything to the gameplay.
Hopefully, since this is how projectiles move in real life (on the moon or something Laughing), it will look as realistic as possible.
As for the projectiles, you have to calculate the position of the projectile at different points. There are 2 displacement formulas for X and Y
Quote:
y = viy • t + 0.5 • g • t2
x = vix * t

In here, X and Y are what we are looking for. g on earth is about 9.8, but I feel like you will have to reduce that to something like 5 for it to feel more like fruit ninja. viy and vix are initial velocities (you must decide on initial velocities, which I suggest should be picked at random within a certain range) and t is calculated in a for loop. The smaller the step of your loop, the smoother the path of the projectile will be.
You can calculate how long it will take for the projectile to travel all the way back down, which will give you what the range of the for loop for t should be. Here is a formula I just made up, which is surely in a textbook somewhere to calculate the total time of flight by using 2 vectors that add together (Vx and Vy)
probably not me wrote:
Z=√(Vx²+Vy²)
Ttot=(2*Z*(Vy/Z))/g

Once you have X and Y, it's simply a matter of erasing the previous sprite and redrawing it in the new coordinates.
Another interesting thing is that if you want to throw your projectiles straight up (with a horizontal velocity of 0m/s), then these formulas simplify quite a bit, so that might be an interesting thing to try out and see if it looks bad Razz
I'm not sure if there is a better way to do it in ICE, because of course, all these values will have to be integers, which might result is pretty pointy parabolas... However, PT_ had to create projectile motions in ICE when he made his Snowball Struggle game for CC18, and I remember it running very well, so maybe he has a better way.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement