Hi, I'm working on an RPG game, i have the player point at the mouse forever, and move forward and away from the mouse, but how do I have it move sideways (move left and right but not just the x axis, y axis should also be involved).
Offline
Okay, here's part of it:
if (key [left arrow v] pressed?) change x by (([sin v] of (direction)) * [movement]) change y by (([cos v] of (direction)) * [movement]) end if (key [right arrow v] pressed?) change x by ((0) - (([sin v] of (direction)) * [movement])) change y by ((0) - (([cos v] of (direction)) * [movement])) end
Last edited by ErnieParke (2012-11-23 22:30:58)
Offline
ErnieParke wrote:
Okay, here's part of it:
if (key [left arrow v] pressed?) change x by (([sin v] of (direction)) * [movement]) change y by (([cos v] of (direction)) * [movement]) end if (key [right arrow v] pressed?) change x by ((0) - (([sin v] of (direction)) * [movement])) change y by ((0) - (([cos v] of (direction)) * [movement])) end
I'm pretty sure I got this much correct, though something might have gone awry.
Anyway, I hope that this helps!
Thanks! I'll try it, but i'm confused by what to put for movement, does 1 = 1 step, or mushc smaller or larger.
Offline
ArloarLoLs wrote:
ErnieParke wrote:
Okay, here's part of it:
if (key [left arrow v] pressed?) change x by (([sin v] of (direction)) * [movement]) change y by (([cos v] of (direction)) * [movement]) end if (key [right arrow v] pressed?) change x by ((0) - (([sin v] of (direction)) * [movement])) change y by ((0) - (([cos v] of (direction)) * [movement])) end
I'm pretty sure I got this much correct, though something might have gone awry.
Anyway, I hope that this helps!Thanks! I'll try it, but i'm confused by what to put for movement, does 1 = 1 step, or mushc smaller or larger.
Correct, 1 would equal 1 step, and now you just need to replace movement with how many steps you want to move left and right.
Oh, and I'm not sure if I've said this to you yet, but hello and welcome to Scratch!
Last edited by ErnieParke (2012-11-24 11:59:21)
Offline
ErnieParke wrote:
ArloarLoLs wrote:
ErnieParke wrote:
Okay, here's part of it:
if (key [left arrow v] pressed?) change x by (([sin v] of (direction)) * [movement]) change y by (([cos v] of (direction)) * [movement]) end if (key [right arrow v] pressed?) change x by ((0) - (([sin v] of (direction)) * [movement])) change y by ((0) - (([cos v] of (direction)) * [movement])) end
I'm pretty sure I got this much correct, though something might have gone awry.
Anyway, I hope that this helps!Thanks! I'll try it, but i'm confused by what to put for movement, does 1 = 1 step, or mushc smaller or larger.
Correct, 1 would equal 1 step, and now you just need to replace movement with how many steps you want to move left and right.
Oh, and I'm not sure if I've said this to you yet, but hello and welcome to Scratch!
XD thanks! Actually ive been using scratch since 2009, i just stopped for a while and made a new account. But again, you've helped alot!
Offline
ArloarLoLs wrote:
ErnieParke wrote:
ArloarLoLs wrote:
Thanks! I'll try it, but i'm confused by what to put for movement, does 1 = 1 step, or mushc smaller or larger.
Correct, 1 would equal 1 step, and now you just need to replace movement with how many steps you want to move left and right.
Oh, and I'm not sure if I've said this to you yet, but hello and welcome to Scratch!XD thanks! Actually ive been using scratch since 2009, i just stopped for a while and made a new account. But again, you've helped alot!
Well I'm glad to here that!
Offline
ErnieParke wrote:
ArloarLoLs wrote:
ErnieParke wrote:
Correct, 1 would equal 1 step, and now you just need to replace movement with how many steps you want to move left and right.
Oh, and I'm not sure if I've said this to you yet, but hello and welcome to Scratch!XD thanks! Actually ive been using scratch since 2009, i just stopped for a while and made a new account. But again, you've helped alot!
Well I'm glad to here that!
By the way, do you happen to know how to move forward and backward?
Offline
ErnieParke wrote:
Okay, here's part of it:
if (key [left arrow v] pressed?) change x by (([sin v] of (direction)) * [movement]) change y by (([cos v] of (direction)) * [movement]) end if (key [right arrow v] pressed?) change x by ((0) - (([sin v] of (direction)) * [movement])) change y by ((0) - (([cos v] of (direction)) * [movement])) end
I'm pretty sure I got this much correct, though something might have gone awry.
Anyway, I hope that this helps!
So I tried this code, it is the code for moving forward and backwards XD, do you know how to do left and right?
Offline
ErnieParke wrote:
Okay, here's part of it:
if (key [right arrow v] pressed?) change x by (([cos v] of (direction)) * [movement]) change y by ((0) - (([sin v] of (direction)) * [movement])) end if (key [left arrow v] pressed?) change x by ((0) - (([cos v] of (direction)) * [movement])) change y by (([sin v] of (direction)) * [movement]) end
I'm pretty sure I got this much correct, though something might have gone awry.
Anyway, I hope that this helps!
Ohhh… My mistake.
Anyway, I fixed the code ^^.
Edit: Fixed again.
Last edited by ErnieParke (2012-11-24 16:24:27)
Offline