I've made a space invaders type of game, where the AI moves even if you don't. It runs good, but to make the game more complex, I want to add a faster and faster function. I already have a delay so it isn't too hard, and the game is fairly optimized. So, how do I make the enemy AI slower, without putting a lag on my own controls.
Here is what I have now (conclusion):
:ClrHome :Repeat L=0 <-- Until you have 0 lives. :rand(1 <-- Delay, yeah.. I have a TI-82. :getKey->K AI Movement :If K=Something :Then :Move Left :End :If K=Something Else :Then :Move Right :End :If K=Enter :Then :Shoot :If X=AI Xvar :Then :Reset AI Position :S+100->S <-- Score :Output(1,1,"P :End :End :ClrHome :Output 5,7,S <-- Score Screen :Pause :Stop :End
Now, I can add the delay, but It would slow down the entire game, not the AI. So, lets take a look at the first part again.
**:Start Delay Time->A** :ClrHome :Repeat L=0 <-- Until you have 0 lives. :--rand(1-- <-- Lets remove this. **:DelVar A :While A≥B <-- Variable A is reduced each time, and so is the delay. :B+1->B :End** :getKey->K
Now couple this with the code below:
:If K=Enter :Then :Shoot :If X=AI Xvar :Then :Reset AI Position :A/2->A <-- Reduce the delay. :S+100->S <-- Score. :Output(1,1,"P :End
You see why this doesn't work right? I can't figure out how to make the controls responsive while the AI is moving slower.