I'm working on making movement code for the "AI" (not really intelligent, but whatever) with this other guy, but the code we have set up feels really mechanical and stiff. We had to modify it from the glide code in order to add a pause function to the game. Does anyone know any good movement code to add to the enemies that feels like they're not on a fixed movement pattern, but will also respond to the variable "pause" being active and immediately stop moving?
Thanks for any input.
This is the game (without pause and glide code):
http://scratch.mit.edu/projects/SD7/2492155
This is our WIP version that has the mechanical-feeling movement that we're trying to fix:
http://scratch.mit.edu/projects/SD7/2522396
Offline
Well, try making it move with a (velocity) variable.
But TBH the jerky movement looks pretty nice
Offline
Ah, I see, you'd have to use velocity variables, like this.
when gf clicked forever move (velocity) steps end
when gf clicked repeat [10] change [velocity v] by [1] end repeat [10] change [velocity v] by [-1] endTry that script in a new project and see if that's the kind of movement you want.
Last edited by jji7skyline (2012-05-09 01:55:14)
Offline
SD7, did you not post a similar question a few days ago? If it's the same project, I posted a possible solution on the other thread.
Offline
@jji7skyline: I tried that and the ship stays at the top of the screen and doesn't move. Not sure if I'm setting the code up right, haven't messed with velocity before.
http://img545.imageshack.us/img545/3624 … city01.png
It plays the [change velocity by 1] code for about 1 second, and then that code shuts off (it's not highlighted in the side anymore
@LS97: This is all you said
LS97 wrote:
To avoid this, you can make your own glide method that mimics the block, but also checks for the pause variable every so often.
You never explained how to do that
Last edited by SD7 (2012-05-10 12:16:05)
Offline
OK then, I'll explain.
Constructing the whole script for you would take some time, so I'll just point you in the right direction. Try using something like this:
forever . . . // do stuff set [x change v] to [10] // replace glide method set [y change v] to [10] repeat (10) change x by ((x change) / (10)) change y by ((y change) / (10)) wait until <(paused) = (false)> end endOf course, that won't work very well and it has no control over time, but you can see where I'm getting
Last edited by LS97 (2012-05-11 11:56:08)
Offline
SD7 wrote:
Ok, that makes sense, but what's supposed to be where "do stuff" is? What else does it need to do?
Oh, that's just representing any script that needs to come before the glide.
I just assumed that is how you structured your code, but you can also simply replace the single "glide for X seconds" block with all the scripts that come after the ".../do stuff"
Offline