Discuss Scratch

deasim
Scratcher
4 posts

Move Steps in Scrolling

Hello, I've been working on a western game for some time now and it's coming along smoothly, however, I have a problem with projectiles, I could just use the normal move steps block, however, I want something that uses the scrolling system so that the bullet accuracy is more realistic when the enemies are off-screen. I've looked at another thread (https://scratch.mit.edu/discuss/topic/26050/?page=1#post-232478) however the solution didn't work. All I need to know is how to convert the move steps block into scrolling, like making an object move towards a set direction, I'm assuming I'm gonna have to learn trigonometry for this so if anyone could point me in the right direction that would help. Here's the project: https://scratch.mit.edu/projects/601037160/, I'm just using normal move steps for the player's gun as of now so look into the code for the bulletAI sprite. I'm not really sure how to use the scratch blocks thing, so the code i currently have is:
change x by sin of direction * steps
change y by sin of direction * steps
Both x and y are variables.
Jereb-co7
Scratcher
100+ posts

Move Steps in Scrolling

deasim wrote:

Hello, I've been working on a western game for some time now and it's coming along smoothly, however, I have a problem with projectiles, I could just use the normal move steps block, however, I want something that uses the scrolling system so that the bullet accuracy is more realistic when the enemies are off-screen. I've looked at another thread (https://scratch.mit.edu/discuss/topic/26050/?page=1#post-232478) however the solution didn't work. All I need to know is how to convert the move steps block into scrolling, like making an object move towards a set direction, I'm assuming I'm gonna have to learn trigonometry for this so if anyone could point me in the right direction that would help. Here's the project: https://scratch.mit.edu/projects/601037160/, I'm just using normal move steps for the player's gun as of now so look into the code for the bulletAI sprite. I'm not really sure how to use the scratch blocks thing, so the code i currently have is:
change x by sin of direction * steps
change y by sin of direction * steps
Both x and y are variables.

Hello, deasim. It's actually simple to code your AI. Use this:


define move in steps: (speed) direction: (dir) make this "without screen refresh"
point in direction (dir)
move (speed) steps
change [RealX v] by (x position)
change [RealY v] by (y position)
go to x: (spawnX) y: (spawnY) // Where the bullet-bill is actually placed on the screen or "relativeX" and "relativeY"

Last edited by Jereb-co7 (Feb. 26, 2022 15:39:11)


Hi, I'm Jeremiah; A kid who likes coding. I want to help people and become successful. I pretty please want you to join a team called “Shappire games” to make projects I also want 200 followers at the end of 2022.

you wrote:

when green flag clicked
set [ I help you ] to [you help me]
if <( I help you ) = [you help me]> then
say [get scratchin'] for (2) secs
end
My account: Jereb-co7




Sincerely,


Jeremiah. B
deasim
Scratcher
4 posts

Move Steps in Scrolling

Thank you so so so much. Actual lifesaver, you're code didn't really work the way you wrote it, however, it gave me the idea to use a different script that does almost the same thing. Again, thank you ever so much.
Jereb-co7
Scratcher
100+ posts

Move Steps in Scrolling

deasim wrote:

Thank you so so so much. Actual lifesaver, you're code didn't really work the way you wrote it, however, it gave me the idea to use a different script that does almost the same thing. Again, thank you ever so much.

Thx for the follow!

Hi, I'm Jeremiah; A kid who likes coding. I want to help people and become successful. I pretty please want you to join a team called “Shappire games” to make projects I also want 200 followers at the end of 2022.

you wrote:

when green flag clicked
set [ I help you ] to [you help me]
if <( I help you ) = [you help me]> then
say [get scratchin'] for (2) secs
end
My account: Jereb-co7




Sincerely,


Jeremiah. B

Powered by DjangoBB