Discuss Scratch
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
if <دالی؟ دوسم> then
say [دوست دالم] for (2) secs
end
Last edited by armanhsasha (Dec. 5, 2020 13:33:49)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
if <mouse down?> then
say [منم]
else
think [منم] for (2) secs
end
Last edited by armanhsasha (Dec. 5, 2020 13:35:52)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
سلام.
برنامه ای بنویس که در آن از:
و
استفاده شده باشد
پیام بفرست که بفهمم فهمیدی
برنامه ای بنویس که در آن از:
stamp
broadcast [----------- v]
و
when green flag clicked
if <(x position) = [-----]> then
end
استفاده شده باشد
پیام بفرست که بفهمم فهمیدی
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
say [hi,I am arman] for (میخوای چقدر هر) secs
Last edited by armanhsasha (Dec. 5, 2020 15:46:05)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
when green flag clicked
forever
دارم دوست
end
Last edited by armanhsasha (Dec. 5, 2020 13:41:55)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
در ضمن
forever
if <دادی؟ انجام> then
share in arman and yazdan
end
end
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
2—-
when green flag clicked
broadcast [start v]//just have it so that there is only 1 green flag clicked
wait (2) secs//makes sure the project is connected to the cloud
set [☁ cloud check v] to [0]//If the player is a new scratcher or offline this should not work
set [☁ cloud check v] to [1]//Then this won't work either
if<(☁ cloud check)=[1]> then//if it equals 1, they are connected, if not, they are not
set [local player1 check v] to (☁ Player1 check)
set [local player2 check v] to (☁ Player2 check)
wait (5) secs//waiting because if a player is active, the player1 and 2 cloud variables will change every second so it is needed to make sure by waiting 5
if <(local player1 check)=(☁ Player1 check)> then//if the cloud check has not changed it means that nobody is playing as player 1, therefore, the player has been set as player1
set [Player ID v] to [1]//not cloud because the cloud variable for player1 will be updated so that other computers know that there is a player1
set [☁ Player1 check v] to [0]//just so it does not get that variable up to a million eventually
set [☁ Player1 coords v] to [500500]//the coordinate system adds 500 to each coordinate because then every number is a positive 3 digit number and an encoder or decoder is not necessary, basically, that is 0,0
broadcast [joined v]//tell the other sprites to do their stuff
else
if<(local player2 check)=(☁ Player2 check)> then//doing the same thing as above but if there already is a player1, it is needed to check for a player2
set [Player ID v] to [2]
set [☁ Player2 check v] to [0]
set [☁ Player2 coords v] to[500500]
broadcast [joined v]
else
broadcast [full v]//if both slots are taken a sprite is needed to tell the player the game is full
end
end
else
broadcast [not connected v]//if the cloud test run at the beginning fails, it is needed to tell them they are not connected to the cloud or are a new scratcher
end
Add this script for Player1's sprite.
when I receive [joined v]
wait (1) secs//just so that the sprite that tells you stuff has time
if <(Player ID)=[1]> then
forever//just the movement script
if <key [right arrow v] pressed?> then// This code is for the movement of Player1.
change x by (3)
end
if <key [left arrow v] pressed?> then
change x by (-3)
end
if <key [down arrow v] pressed?> then
change y by (-3)
end
if <key [up arrow v] pressed?> then
change y by (3)
end
set [☁ Player1 coords v] to (join((x position)+(500))((y position)+(500)))// telling all the other computers player1's position with the plus 500 method mentioned before
end
else
forever//if the player ID isn't one the sprite of player1 will go to the coordinates, again using the 500 method, but this time it is needed to subtract because these are the ones received from the other computer so they have already had 500 added
go to x:((join (letter (1) of (☁ Player1 coords))(join (letter (2) of (☁ Player1 coords))(letter (3) of (☁ Player 1 coords))))-[500])y:((join (letter (4) of (☁ Player1 coords))(join (letter (5) of (☁ Player1 coords))(letter (6) of (☁ Player 1 coords))))-[500])
end
end
when I receive [joined v]
if <(Player ID)=[1]> then
forever
change [☁ Player1 check v] by (1)//at the beginning, when the program is first run there is a five second wait for this variable to change, because after that whether there is a player1 or not is recorded
wait (1) secs
end
Last edited by armanhsasha (Dec. 10, 2020 10:55:34)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
1—–
when green flag clicked
broadcast [start v]//just have it so that there is only 1 green flag clicked
wait (2) secs//makes sure the project is connected to the cloud
set [☁ cloud check v] to [0]//If the player is a new scratcher or offline this should not work
set [☁ cloud check v] to [1]//Then this won't work either
if<(☁ cloud check)=[1]> then//if it equals 1, they are connected, if not, they are not
set [local player1 check v] to (☁ Player1 check)
set [local player2 check v] to (☁ Player2 check)
wait (5) secs//waiting because if a player is active, the player1 and 2 cloud variables will change every second so it is needed to make sure by waiting 5
if <(local player1 check)=(☁ Player1 check)> then//if the cloud check has not changed it means that nobody is playing as player 1, therefore, the player has been set as player1
set [Player ID v] to [1]//not cloud because the cloud variable for player1 will be updated so that other computers know that there is a player1
set [☁ Player1 check v] to [0]//just so it does not get that variable up to a million eventually
set [☁ Player1 coords v] to [500500]//the coordinate system adds 500 to each coordinate because then every number is a positive 3 digit number and an encoder or decoder is not necessary, basically, that is 0,0
broadcast [joined v]//tell the other sprites to do their stuff
else
if<(local player2 check)=(☁ Player2 check)> then//doing the same thing as above but if there already is a player1, it is needed to check for a player2
set [Player ID v] to [2]
set [☁ Player2 check v] to [0]
set [☁ Player2 coords v] to[500500]
broadcast [joined v]
else
broadcast [full v]//if both slots are taken a sprite is needed to tell the player the game is full
end
end
else
broadcast [not connected v]//if the cloud test run at the beginning fails, it is needed to tell them they are not connected to the cloud or are a new scratcher
end
Last edited by armanhsasha (Dec. 10, 2020 10:55:19)
- armanhsasha
-
39 posts
چت برای آرمان و یزدان
3—-
when I receive [joined v]
wait (1) secs//just so that the sprite that tells you stuff has time
if <(Player ID)=[1]> then
forever//just the movement script
if <key [right arrow v] pressed?> then// This code is for the movement of Player1.
change x by (3)
end
if <key [left arrow v] pressed?> then
change x by (-3)
end
if <key [down arrow v] pressed?> then
change y by (-3)
end
if <key [up arrow v] pressed?> then
change y by (3)
end
set [☁ Player1 coords v] to (join((x position)+(500))((y position)+(500)))// telling all the other computers player1's position with the plus 500 method mentioned before
end
else
forever//if the player ID isn't one the sprite of player1 will go to the coordinates, again using the 500 method, but this time it is needed to subtract because these are the ones received from the other computer so they have already had 500 added
go to x:((join (letter (1) of (☁ Player1 coords))(join (letter (2) of (☁ Player1 coords))(letter (3) of (☁ Player 1 coords))))-[500])y:((join (letter (4) of (☁ Player1 coords))(join (letter (5) of (☁ Player1 coords))(letter (6) of (☁ Player 1 coords))))-[500])
end
end
when I receive [joined v]
if <(Player ID)=[1]> then
forever
change [☁ Player1 check v] by (1)//at the beginning, when the program is first run there is a five second wait for this variable to change, because after that whether there is a player1 or not is recorded
wait (1) secs
end
This script is for Player2's sprite. All of player1's variables are transferred to player2's variables.
when I receive [joined v]
wait (1) secs
if <(Player ID)=[2]> then
forever
if <key [right arrow v] pressed?> then
change x by (3)
end
if <key [left arrow v] pressed?> then
change x by (-3)
end
if <key [down arrow v] pressed?> then
change y by (-3)
end
if <key [up arrow v] pressed?> then
change y by (3)
end
set [☁ Player2 coords v] to (join((x position)+(500))((y position)+(500)))
end
else
forever
go to x:((join (letter (1) of (☁ Player2 coords))(join (letter (2) of (☁ Player2 coords))(letter (3) of (☁ Player 2 coords))))-[500])y:((join (letter (4) of (☁ Player2 coords))(join (letter (5) of (☁ Player2 coords))(letter (6) of (☁ Player 2 coords))))-[500])
end
end
when I receive [joined v]
if <(Player ID)=[2]> then
forever
change [☁ Player2 check v] by (1)
wait (1) secs
end