Discuss Scratch

SamuraiNinjaBento
Scratcher
82 posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

https://scratch.mit.edu/projects/256921833/

How can I make the coin teleport to a random location within the borders of the play area when the player touches the coin?
Rickyickerson
Scratcher
80 posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

if touching (coin) then
go to pick random x (180) to (-180) y (180) to (-180

Should work.

Last edited by Rickyickerson (Oct. 26, 2018 17:47:33)

kieranblackley
Scratcher
500+ posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

It is quit simple. In the Coin sprite add this line of code into the if statement:
go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))
I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley

Last edited by kieranblackley (Oct. 26, 2018 17:49:32)

SamuraiNinjaBento
Scratcher
82 posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

kieranblackley wrote:

It is quit simple. In the Coin sprite add this line of code into the if statement:
go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))
I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley

Thank you for that! It works like I imagined now. Do you by chance know how to solve the lag problem when too many enemies spawn?
kieranblackley
Scratcher
500+ posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

SamuraiNinjaBento wrote:

kieranblackley wrote:

It is quit simple. In the Coin sprite add this line of code into the if statement:
go to x: (pick random (-89) to (227)) y: (pick random (-167) to (167))
I hope that sorted your problem!
NOTE: Do not worry about how the x and y co-ordinates/positions seem weird. I made it so the coin would always stay in the play area.
-kieranblackley

Thank you for that! It works like I imagined now. Do you by chance know how to solve the lag problem when too many enemies spawn?
I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.
SamuraiNinjaBento
Scratcher
82 posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

kieranblackley wrote:

I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.

Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
kieranblackley
Scratcher
500+ posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

SamuraiNinjaBento wrote:

kieranblackley wrote:

I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.

Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problem:
SamuraiNinjaBento
Scratcher
82 posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

kieranblackley wrote:

SamuraiNinjaBento wrote:

kieranblackley wrote:

I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.

Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problem

Here is my computer I am on right now, my computer at my house is much better though. This is my school computer: My browser / operating system: ChromeOS 10895.78.0, Chrome 69.0.3497.120, Flash 31.0 (release 0)
kieranblackley
Scratcher
500+ posts

How do you make a sprite randomly teleport to a spot on the boxed area when the player touches it?

SamuraiNinjaBento wrote:

kieranblackley wrote:

SamuraiNinjaBento wrote:

kieranblackley wrote:

I am not sure, at the moment I am making a big tutorial on your other discussion forum about the character not walking smooth. I hope what I do fixes that problem as well in one of your other projects.

Oh well thank you, I thought nobody was gonna answer that one about my character… Thanks!
Now that I have had a little think about, here is a solution to the lag problem. If it does not fix anything, I am sorry. It might be your computer causing the problem

Here is my computer I am on right now, my computer at my house is much better though. This is my school computer: My browser / operating system: ChromeOS 10895.78.0, Chrome 69.0.3497.120, Flash 31.0 (release 0)
When you get home view the project and it should be better.

Powered by DjangoBB