Discuss Scratch

25wjefferies
Scratcher
8 posts

Collision Help

In my game (featured on my account at the moment) after 10 enemies are destroyed, a big one shows up. How do I make it so that the sprite doesn't run through the big enemy? Would appreciate any advice I can get.
Game: https://scratch.mit.edu/projects/563679295/

EDIT: How do I make it so that the big enemy switched costumes every time I touch it? It works at the moment, but if you just stay still, it will still change costumes because of my temporary wait block.

Last edited by 25wjefferies (Aug. 26, 2021 23:48:12)

MasterofTheBrick
Scratcher
1000+ posts

Collision Help

This basic collision script should help.

forever
set [X v] to (x position)
set [Y v] to (y position)
Movement scripts ::grey
if <touching [big enemy v] ?> then
go to x: (X) y: (y)
end
end
25wjefferies
Scratcher
8 posts

Collision Help

MasterofTheBrick wrote:

This basic collision script should help.

forever
set [X v] to (x position)
set [Y v] to (y position)
Movement scripts ::grey
if <touching [big enemy v] ?> then
go to x: (X) y: (y)
end
end
This isn't working, did I mess something up?
MasterofTheBrick
Scratcher
1000+ posts

Collision Help

25wjefferies wrote:

This isn't working, did I mess something up?
Looks like you confused the variables with the movement blocks, and vice versa.

Look at the scripts carefully again, and make the necessary changes to your own.

set [x v] to (x position)
set [y v] to (y position)

The orange blocks are variable blocks, while the blue reporters are movement blocks. Essentially, the snippet of code above is made up of the 4 blocks below:

set [x v] to [] //variable block

set [y v] to [] //variable block

(x position) //movement block

(y position) //movement block


Same goes for the detection script:

if <touching [boss v] ?> then
go to x: (x) y: (y)
end

Split it up, and you get these 3 blocks.

(x) //variable block

(y) //variable block

go to x: () y: () //movement block
25wjefferies
Scratcher
8 posts

Collision Help

MasterofTheBrick wrote:

25wjefferies wrote:

This isn't working, did I mess something up?
Looks like you confused the variables with the movement blocks, and vice versa.

Look at the scripts carefully again, and make the necessary changes to your own.

set [x v] to (x position)
set [y v] to (y position)

The orange blocks are variable blocks, while the blue reporters are movement blocks. Essentially, the snippet of code above is made up of the 4 blocks below:

set [x v] to [] //variable block

set [y v] to [] //variable block

(x position) //movement block

(y position) //movement block


Same goes for the detection script:

if <touching [boss v] ?> then
go to x: (x) y: (y)
end

Split it up, and you get these 3 blocks.

(x) //variable block

(y) //variable block

MasteroftheBrick wrote:

This works, except now the player moves too fast (to the point where the player gets stuck in the wall)

Last edited by 25wjefferies (Aug. 27, 2021 17:02:58)

25wjefferies
Scratcher
8 posts

Collision Help

MasterofTheBrick wrote:

25wjefferies wrote:

This isn't working, did I mess something up?
Looks like you confused the variables with the movement blocks, and vice versa.

Look at the scripts carefully again, and make the necessary changes to your own.

set [x v] to (x position)
set [y v] to (y position)

The orange blocks are variable blocks, while the blue reporters are movement blocks. Essentially, the snippet of code above is made up of the 4 blocks below:

set [x v] to [] //variable block

set [y v] to [] //variable block

(x position) //movement block

(y position) //movement block


Same goes for the detection script:

if <touching [boss v] ?> then
go to x: (x) y: (y)
end

Split it up, and you get these 3 blocks.

(x) //variable block

(y) //variable block

go to x: () y: () //movement block[/quote]

This works, except now the player moves too fast.

Powered by DjangoBB