pxt-common-packages 10.4.1 → 10.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/common-sim.js +5 -5
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +8528 -8282
- package/libs/controller---none/built/debug/binary.js +8507 -8261
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-jsdoc-strings.json +2 -2
- package/libs/game/_locales/game-strings.json +2 -1
- package/libs/game/built/debug/binary.js +8416 -8170
- package/libs/game/controller.ts +24 -0
- package/libs/game/game.ts +13 -4
- package/libs/game/multiplayer.ts +5 -3
- package/libs/game/scene.ts +2 -0
- package/libs/game/sim/multiplayer.ts +6 -5
- package/libs/game/sprite.ts +1 -0
- package/libs/game/sprites.ts +13 -0
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mixer/instrument.ts +7 -0
- package/libs/mixer/melody.ts +1 -0
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/multiplayer/docs/reference/multiplayer/change-player-state-by.md +121 -0
- package/libs/multiplayer/docs/reference/multiplayer/game-over-player-win.md +88 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-by-index.md +40 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-by-number.md +34 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-by-sprite.md +109 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-property.md +55 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-sprite.md +59 -0
- package/libs/multiplayer/docs/reference/multiplayer/get-player-state.md +55 -0
- package/libs/multiplayer/docs/reference/multiplayer/is-button-pressed.md +44 -0
- package/libs/multiplayer/docs/reference/multiplayer/move-with-buttons.md +50 -0
- package/libs/multiplayer/docs/reference/multiplayer/multiplayer-state.md +55 -0
- package/libs/multiplayer/docs/reference/multiplayer/on-button-event.md +60 -0
- package/libs/multiplayer/docs/reference/multiplayer/on-controller-event.md +76 -0
- package/libs/multiplayer/docs/reference/multiplayer/on-life-zero.md +28 -0
- package/libs/multiplayer/docs/reference/multiplayer/on-score.md +30 -0
- package/libs/multiplayer/docs/reference/multiplayer/player-selector.md +51 -0
- package/libs/multiplayer/docs/reference/multiplayer/set-player-indicators-visible.md +69 -0
- package/libs/multiplayer/docs/reference/multiplayer/set-player-sprite.md +50 -0
- package/libs/multiplayer/docs/reference/multiplayer/set-player-state.md +139 -0
- package/libs/multiplayer/docs/reference/multiplayer.md +57 -0
- package/libs/multiplayer/docs/types/player.md +82 -0
- package/libs/multiplayer/fieldEditors.ts +1 -0
- package/libs/multiplayer/ns.ts +1 -1
- package/libs/multiplayer/player.ts +80 -48
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +10194 -9948
- package/libs/palette/built/debug/binary.js +8415 -8169
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +8415 -8169
- package/libs/storyboard/built/debug/binary.js +8415 -8169
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# change Player State By
|
|
2
|
+
|
|
3
|
+
Change a player state value by some amount.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.changePlayerStateBy(mp.playerSelector(mp.PlayerNumber.One), MultiplayerState.score, 0)
|
|
7
|
+
```
|
|
8
|
+
A [Player](/types/player) state value is changed by adding or subtracting some amount from the current value. The change amount is in the **delta** parameter. If the player's ``||mp:score||`` value is `20` and you want to add `1` to the score, set **delta** to `1`. Similarly, if you want to reduce ``||mp:score||`` to `15`, set **delta** to `-5`.
|
|
9
|
+
|
|
10
|
+
## Parameters
|
|
11
|
+
|
|
12
|
+
* **player**: the player to change the a **state** value for.
|
|
13
|
+
* **state**: the [state item](/reference/multiplayer/multiplayer-state) to change, such as `score` or `life`.
|
|
14
|
+
* **delta**: the amount to change the **state** value by.
|
|
15
|
+
|
|
16
|
+
## Example #example
|
|
17
|
+
|
|
18
|
+
Set `player 1` score state to `0`. Send the player's shark sprite across the screen to eat a goldfish on the opposite side. When the shark overlaps the goldfish, add `1` to `player 1` score state.
|
|
19
|
+
|
|
20
|
+
```blocks
|
|
21
|
+
namespace MultiplayerState {
|
|
22
|
+
export const gems = MultiplayerState.create()
|
|
23
|
+
}
|
|
24
|
+
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
|
|
25
|
+
goldfish.destroy(effects.warmRadial, 200)
|
|
26
|
+
mp.changePlayerStateBy(mp.playerSelector(mp.PlayerNumber.One), MultiplayerState.score, 1)
|
|
27
|
+
})
|
|
28
|
+
let chomp = false
|
|
29
|
+
let goldfish: Sprite = null
|
|
30
|
+
mp.setPlayerState(mp.playerSelector(mp.PlayerNumber.One), MultiplayerState.score, 0)
|
|
31
|
+
goldfish = sprites.create(img`
|
|
32
|
+
. . . . . . . . . . . . . . . .
|
|
33
|
+
. . . . . . . . c c c c . . . .
|
|
34
|
+
. . . . . . c c d d d d c . . .
|
|
35
|
+
. . . . . c c c c c c d c . . .
|
|
36
|
+
. . . . c c 4 4 4 4 d c c . . .
|
|
37
|
+
. . . c 4 d 4 4 4 4 4 1 c . c c
|
|
38
|
+
. . c 4 4 4 1 4 4 4 4 d 1 c 4 c
|
|
39
|
+
. c 4 4 4 4 1 4 4 4 4 4 1 c 4 c
|
|
40
|
+
f 4 4 4 4 4 1 4 4 4 4 4 1 4 4 f
|
|
41
|
+
f 4 4 4 f 4 1 c c 4 4 4 1 f 4 f
|
|
42
|
+
f 4 4 4 4 4 1 4 4 f 4 4 d f 4 f
|
|
43
|
+
. f 4 4 4 4 1 c 4 f 4 d f f f f
|
|
44
|
+
. . f f 4 d 4 4 f f 4 c f c . .
|
|
45
|
+
. . . . f f 4 4 4 4 c d b c . .
|
|
46
|
+
. . . . . . f f f f d d d c . .
|
|
47
|
+
. . . . . . . . . . c c c . . .
|
|
48
|
+
`, SpriteKind.Food)
|
|
49
|
+
goldfish.left = 0
|
|
50
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
51
|
+
.................ccfff..............
|
|
52
|
+
................cddbbf..............
|
|
53
|
+
...............cddbbf...............
|
|
54
|
+
..............fccbbcf............ccc
|
|
55
|
+
........ffffffccccccff.........ccbbc
|
|
56
|
+
......ffbbbbbbbbbbbbbcfff.....cdbbc.
|
|
57
|
+
....ffbbbbbbbbbcbcbbbbcccff..cddbbf.
|
|
58
|
+
....fbcbbbbbffbbcbcbbbcccccfffdbbf..
|
|
59
|
+
....fbbb1111ff1bcbcbbbcccccccbbbcf..
|
|
60
|
+
.....fb11111111bbbbbbcccccccccbccf..
|
|
61
|
+
......fccc33cc11bbbbccccccccfffbbcf.
|
|
62
|
+
.......fc131c111bbbcccccbdbc...fbbf.
|
|
63
|
+
........f33c111cbbbfdddddcc.....fbbf
|
|
64
|
+
.........ff1111fbdbbfddcc........fff
|
|
65
|
+
...........cccccfbdbbfc.............
|
|
66
|
+
.................fffff..............
|
|
67
|
+
`, SpriteKind.Player))
|
|
68
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).right = scene.screenWidth()
|
|
69
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).vx = -30
|
|
70
|
+
game.onUpdateInterval(500, function () {
|
|
71
|
+
if (chomp == true) {
|
|
72
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setImage(img`
|
|
73
|
+
....................ccfff...........
|
|
74
|
+
..........fffffffffcbbbbf...........
|
|
75
|
+
.........fbbbbbbbbbfffbf............
|
|
76
|
+
.........fbb111bffbbbbff............
|
|
77
|
+
.........fb11111ffbbbbbcff..........
|
|
78
|
+
.........f1cccc11bbcbcbcccf.........
|
|
79
|
+
..........fc1c1c1bbbcbcbcccf...ccccc
|
|
80
|
+
............c3331bbbcbcbccccfccddbbc
|
|
81
|
+
...........c333c1bbbbbbbcccccbddbcc.
|
|
82
|
+
...........c331c11bbbbbcccccccbbcc..
|
|
83
|
+
..........cc13c111bbbbccccccffbccf..
|
|
84
|
+
..........c111111cbbbcccccbbc.fccf..
|
|
85
|
+
...........cc1111cbbbfdddddc..fbbcf.
|
|
86
|
+
.............cccffbdbbfdddc....fbbf.
|
|
87
|
+
..................fbdbbfcc......fbbf
|
|
88
|
+
...................fffff.........fff
|
|
89
|
+
`)
|
|
90
|
+
} else {
|
|
91
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setImage(img`
|
|
92
|
+
.................ccfff..............
|
|
93
|
+
................cddbbf..............
|
|
94
|
+
...............cddbbf...............
|
|
95
|
+
..............fccbbcf............ccc
|
|
96
|
+
........ffffffccccccff.........ccbbc
|
|
97
|
+
......ffbbbbbbbbbbbbbcfff.....cdbbc.
|
|
98
|
+
....ffbbbbbbbbbcbcbbbbcccff..cddbbf.
|
|
99
|
+
....fbcbbbbbffbbcbcbbbcccccfffdbbf..
|
|
100
|
+
....fbbb1111ff1bcbcbbbcccccccbbbcf..
|
|
101
|
+
.....fb11111111bbbbbbcccccccccbccf..
|
|
102
|
+
......fccc33cc11bbbbccccccccfffbbcf.
|
|
103
|
+
.......fc131c111bbbcccccbdbc...fbbf.
|
|
104
|
+
........f33c111cbbbfdddddcc.....fbbf
|
|
105
|
+
.........ff1111fbdbbfddcc........fff
|
|
106
|
+
...........cccccfbdbbfc.............
|
|
107
|
+
.................fffff..............
|
|
108
|
+
`)
|
|
109
|
+
}
|
|
110
|
+
chomp = !(chomp)
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## See also #seealso
|
|
115
|
+
|
|
116
|
+
[set player state](/reference/multiplayer/set-player-state),
|
|
117
|
+
[get player state](/reference/multiplayer/get-player-state)
|
|
118
|
+
|
|
119
|
+
```package
|
|
120
|
+
multiplayer
|
|
121
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# game Over Player Win
|
|
2
|
+
|
|
3
|
+
End the game and set a player to win.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.gameOverPlayerWin(mp.playerSelector(mp.PlayerNumber.One))
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
* **player**: the [player](/types/player) set to win the game.
|
|
12
|
+
|
|
13
|
+
## Example #example
|
|
14
|
+
|
|
15
|
+
Send two player sprites moving around the screen. Place a food (donut) sprite at the left side of the screen. When a player sprite reaches the donut, that player wins the game.
|
|
16
|
+
|
|
17
|
+
```blocks
|
|
18
|
+
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
|
|
19
|
+
mp.gameOverPlayerWin(mp.getPlayerBySprite(sprite))
|
|
20
|
+
})
|
|
21
|
+
let mySprite = sprites.create(img`
|
|
22
|
+
. . . . . . b b b b a a . . . .
|
|
23
|
+
. . . . b b d d d 3 3 3 a a . .
|
|
24
|
+
. . . b d d d 3 3 3 3 3 3 a a .
|
|
25
|
+
. . b d d 3 3 3 3 3 3 3 3 3 a .
|
|
26
|
+
. b 3 d 3 3 3 3 3 b 3 3 3 3 a b
|
|
27
|
+
. b 3 3 3 3 3 a a 3 3 3 3 3 a b
|
|
28
|
+
b 3 3 3 3 3 a a 3 3 3 3 d a 4 b
|
|
29
|
+
b 3 3 3 3 b a 3 3 3 3 3 d a 4 b
|
|
30
|
+
b 3 3 3 3 3 3 3 3 3 3 d a 4 4 e
|
|
31
|
+
a 3 3 3 3 3 3 3 3 3 d a 4 4 4 e
|
|
32
|
+
a 3 3 3 3 3 3 3 d d a 4 4 4 e .
|
|
33
|
+
a a 3 3 3 d d d a a 4 4 4 e e .
|
|
34
|
+
. e a a a a a a 4 4 4 4 e e . .
|
|
35
|
+
. . e e b b 4 4 4 4 b e e . . .
|
|
36
|
+
. . . e e e e e e e e . . . . .
|
|
37
|
+
. . . . . . . . . . . . . . . .
|
|
38
|
+
`, SpriteKind.Food)
|
|
39
|
+
mySprite.left = 0
|
|
40
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
41
|
+
. . . . . f f f f f . . . . . .
|
|
42
|
+
. . . . f e e e e e f . . . . .
|
|
43
|
+
. . . f d d d d d d e f . . . .
|
|
44
|
+
. . f d f f d d f f d f f . . .
|
|
45
|
+
. c d d d e e d d d d e d f . .
|
|
46
|
+
. c d c d d d d c d d e f f . .
|
|
47
|
+
. c d d c c c c d d d e f f f f
|
|
48
|
+
. . c d d d d d d d e f f b d f
|
|
49
|
+
. . . c d d d d e e f f f d d f
|
|
50
|
+
. . . . f f f e e f e e e f f f
|
|
51
|
+
. . . . f e e e e e e e f f f .
|
|
52
|
+
. . . f e e e e e e f f f e f .
|
|
53
|
+
. . f f e e e e f f f f f e f .
|
|
54
|
+
. f b d f e e f b b f f f e f .
|
|
55
|
+
. f d d f f f f d d b f f f f .
|
|
56
|
+
. f f f f f f f f f f f f f . .
|
|
57
|
+
`, SpriteKind.Player))
|
|
58
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setBounceOnWall(true)
|
|
59
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setVelocity(40, -30)
|
|
60
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two), sprites.create(img`
|
|
61
|
+
. . . . . . . . . . . . . . . .
|
|
62
|
+
. . . . c c c c . . . . . . . .
|
|
63
|
+
. . c c 5 5 5 5 c c . . . . . .
|
|
64
|
+
. c 5 5 5 5 5 5 5 5 c . . . . .
|
|
65
|
+
c 5 5 5 5 5 1 f 5 5 5 c . . . .
|
|
66
|
+
c 5 5 5 5 5 f f 5 5 5 5 c . . .
|
|
67
|
+
c 5 5 5 5 5 5 5 5 5 5 5 c . . .
|
|
68
|
+
c c b b 1 b 5 5 5 5 5 5 d c . .
|
|
69
|
+
c 5 3 3 3 5 5 5 5 5 d d d c . .
|
|
70
|
+
. b 5 5 5 5 5 5 5 5 d d d c . .
|
|
71
|
+
. . c b b c 5 5 b d d d d c . .
|
|
72
|
+
. c b b c 5 5 b b d d d d c c c
|
|
73
|
+
. c c c c c c d d d d d d d d c
|
|
74
|
+
. . . c c c c d 5 5 b d d c c .
|
|
75
|
+
. . c b b c c c 5 5 b c c . . .
|
|
76
|
+
. . c c c c c d 5 5 c . . . . .
|
|
77
|
+
`, SpriteKind.Player))
|
|
78
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two)).setBounceOnWall(true)
|
|
79
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two)).setVelocity(50, 40)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## See also #seealso
|
|
83
|
+
|
|
84
|
+
[get player by sprite](/reference/multiplayer/get-player-by-sprite)
|
|
85
|
+
|
|
86
|
+
```package
|
|
87
|
+
multiplayer
|
|
88
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# get Player By Index
|
|
2
|
+
|
|
3
|
+
Get a Player from the multiplayer game list using an index value.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerByIndex(0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
You can get a [Player](/types/player) object from the multiplayer using an index value for a location in the list. Index values start at `0` for the first list location and range to the maximum number of players minus `1` (currently `4` players maximum so, the maximum list index is `4 - 1` = `3`).
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **index**: a [number](/types/number) that is the index of the Player in the multiplayer list.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* the [Player](/types/player) in the multiplayer list at location **index**.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Find all the players that have a score greater than `20` and give them a bonus of `5` points.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
let player: mp.Player = null
|
|
25
|
+
for (let index = 0; index <= 3; index++) {
|
|
26
|
+
player = mp.getPlayerByIndex(index)
|
|
27
|
+
if (mp.getPlayerState(player, MultiplayerState.score) > 20) {
|
|
28
|
+
mp.changePlayerStateBy(player, MultiplayerState.score, 5)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## See also #seealso
|
|
34
|
+
|
|
35
|
+
[player selector](/reference/multiplayer/player-selector),
|
|
36
|
+
[get player by number](/reference/multiplayer/get-player-by-number)
|
|
37
|
+
|
|
38
|
+
```package
|
|
39
|
+
multiplayer
|
|
40
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# get Player By Number
|
|
2
|
+
|
|
3
|
+
Get a game Player using a player number value.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerByNumber(0)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Rather than using a [player selector](/reference/multiplayer/player-selector), a [Player](/types/player) is returned for a player **number**. Player numbers start from `1` and range to the maximum number of players (currently `4`).
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **number**: a player [number](/types/number).
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* the [Player](/types/player) which matches **number**.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Give `player 4` an extra `5` life points.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
mp.changePlayerStateBy(mp.getPlayerByNumber(4), MultiplayerState.life, 5)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## See also #seealso
|
|
28
|
+
|
|
29
|
+
[player selector](/reference/multiplayer/player-selector),
|
|
30
|
+
[get player by index](/reference/multiplayer/get-player-by-index)
|
|
31
|
+
|
|
32
|
+
```package
|
|
33
|
+
multiplayer
|
|
34
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# get Player By Sprite
|
|
2
|
+
|
|
3
|
+
Get the Player that has this character sprite.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerBySprite(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
* **sprite**: the character sprite whose [Player](/types/player) is returned.
|
|
12
|
+
|
|
13
|
+
## Returns
|
|
14
|
+
|
|
15
|
+
* the [Player](/types/player) that is assigned this **sprite**.
|
|
16
|
+
|
|
17
|
+
## Example #example
|
|
18
|
+
|
|
19
|
+
Send 2 player sprites moving around the screen. When they overlap the hamburger sprite, make one player say that they like the hamburger and they other say that they don't.
|
|
20
|
+
|
|
21
|
+
```blocks
|
|
22
|
+
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
|
|
23
|
+
if (mp.getPlayerProperty(mp.getPlayerBySprite(sprite), mp.PlayerProperty.Number) == 1) {
|
|
24
|
+
sprite.sayText("Yum, burger!", 100, false)
|
|
25
|
+
} else {
|
|
26
|
+
sprite.sayText("Hate, burgers!", 100, false)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
let burger = sprites.create(img`
|
|
30
|
+
...........ccccc66666...........
|
|
31
|
+
........ccc4444444444666........
|
|
32
|
+
......cc444444444bb4444466......
|
|
33
|
+
.....cb4444bb4444b5b444444b.....
|
|
34
|
+
....eb4444b5b44444b44444444b....
|
|
35
|
+
...ebb44444b4444444444b444446...
|
|
36
|
+
..eb6bb444444444bb444b5b444446..
|
|
37
|
+
..e6bb5b44444444b5b444b44bb44e..
|
|
38
|
+
.e66b4b4444444444b4444444b5b44e.
|
|
39
|
+
.e6bb444444444444444444444bb44e.
|
|
40
|
+
eb66b44444bb444444444444444444be
|
|
41
|
+
eb66bb444b5b44444444bb44444444be
|
|
42
|
+
fb666b444bb444444444b5b4444444bf
|
|
43
|
+
fcb666b44444444444444bb444444bcf
|
|
44
|
+
.fbb6666b44444444444444444444bf.
|
|
45
|
+
.efbb66666bb4444444444444444bfe.
|
|
46
|
+
.86fcbb66666bbb44444444444bcc688
|
|
47
|
+
8772effcbbbbbbbbbbbbbbbbcfc22778
|
|
48
|
+
87722222cccccccccccccccc22226678
|
|
49
|
+
f866622222222222222222222276686f
|
|
50
|
+
fef866677766667777776667777fffef
|
|
51
|
+
fbff877768f86777777666776fffffbf
|
|
52
|
+
fbeffeefffeff7766688effeeeefeb6f
|
|
53
|
+
f6bfffeffeeeeeeeeeeeeefeeeeebb6e
|
|
54
|
+
f66ddfffffeeeffeffeeeeeffeedb46e
|
|
55
|
+
.c66ddd4effffffeeeeeffff4ddb46e.
|
|
56
|
+
.fc6b4dddddddddddddddddddb444ee.
|
|
57
|
+
..ff6bb444444444444444444444ee..
|
|
58
|
+
....ffbbbb4444444444444444ee....
|
|
59
|
+
......ffebbbbbb44444444eee......
|
|
60
|
+
.........fffffffcccccee.........
|
|
61
|
+
................................
|
|
62
|
+
`, SpriteKind.Food)
|
|
63
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
64
|
+
. . 4 4 4 . . . . 4 4 4 . . . .
|
|
65
|
+
. 4 5 5 5 e . . e 5 5 5 4 . . .
|
|
66
|
+
4 5 5 5 5 5 e e 5 5 5 5 5 4 . .
|
|
67
|
+
4 5 5 4 4 5 5 5 5 4 4 5 5 4 . .
|
|
68
|
+
e 5 4 4 5 5 5 5 5 5 4 4 5 e . .
|
|
69
|
+
. e e 5 5 5 5 5 5 5 5 e e . . .
|
|
70
|
+
. . e 5 f 5 5 5 5 f 5 e . . . .
|
|
71
|
+
. . f 5 5 5 4 4 5 5 5 f . . f f
|
|
72
|
+
. . f 4 5 5 f f 5 5 6 f . f 5 f
|
|
73
|
+
. . . f 6 6 6 6 6 6 4 4 f 5 5 f
|
|
74
|
+
. . . f 4 5 5 5 5 5 5 4 4 5 f .
|
|
75
|
+
. . . f 5 5 5 5 5 4 5 5 f f . .
|
|
76
|
+
. . . f 5 f f f 5 f f 5 f . . .
|
|
77
|
+
. . . f f . . f f . . f f . . .
|
|
78
|
+
`, SpriteKind.Player))
|
|
79
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two), sprites.create(img`
|
|
80
|
+
. . . . f f f f f . . . . . . .
|
|
81
|
+
. . . f e e e e e f f f . . . .
|
|
82
|
+
. . f d d d e e e e d d f . . .
|
|
83
|
+
. c d d d d d e e e b d c . . .
|
|
84
|
+
. c d d d d d d e e b d c . . .
|
|
85
|
+
c d d f d d f d e e f c . f f .
|
|
86
|
+
c d d f d d f d e e f . . f e f
|
|
87
|
+
c d e e d d d d e e f . . f e f
|
|
88
|
+
. f d d d c d e e f f . . f e f
|
|
89
|
+
. . f f f d e e e e e f . f e f
|
|
90
|
+
. . . . f e e e e e e e f f f .
|
|
91
|
+
. . . . f f e e e e e b f f . .
|
|
92
|
+
. . . f e f f e e c d d f f . .
|
|
93
|
+
. . f d d b d d c f f f . . . .
|
|
94
|
+
. . f d d c d d d f f . . . . .
|
|
95
|
+
. . . f f f f f f f . . . . . .
|
|
96
|
+
`, SpriteKind.Player))
|
|
97
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setVelocity(60, 50)
|
|
98
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).setBounceOnWall(true)
|
|
99
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two)).setVelocity(50, -50)
|
|
100
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two)).setBounceOnWall(true)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## See also #seealso
|
|
104
|
+
|
|
105
|
+
[get player sprite](/reference/multiplayer/get-player-sprite)
|
|
106
|
+
|
|
107
|
+
```package
|
|
108
|
+
multiplayer
|
|
109
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# get Player Property
|
|
2
|
+
|
|
3
|
+
Get the value of a Player property.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerProperty(mp.playerSelector(mp.PlayerNumber.One), PlayerProperty.Index)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Player properties contain identity information. These are set for a [Player](/types/player) object when it's created to uniquely identfy it. Currently, there are two properties: ``||mp:index||`` and ``||mp:number||``.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **player**: the [Player](/types/player) to get a property for. item value for.
|
|
14
|
+
* **prop**: the property to get a **value** for:
|
|
15
|
+
>* `index`: the zero-based index of the Player in the multiplayer object list.
|
|
16
|
+
>* `number`: the player identity number of the Player object.
|
|
17
|
+
|
|
18
|
+
## Returns
|
|
19
|
+
|
|
20
|
+
* a [number](/types/number) which is the value for the property.
|
|
21
|
+
|
|
22
|
+
## Example #example
|
|
23
|
+
|
|
24
|
+
Get the player number property for `player 1` and display it with its character sprite.
|
|
25
|
+
|
|
26
|
+
```blocks
|
|
27
|
+
scene.setBackgroundColor(10)
|
|
28
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
29
|
+
. . . . . f f f f f . . . . . .
|
|
30
|
+
. . . . f e e e e e f . . . . .
|
|
31
|
+
. . . f d d d d d d e f . . . .
|
|
32
|
+
. . f d f f d d f f d f f . . .
|
|
33
|
+
. c d d d e e d d d d e d f . .
|
|
34
|
+
. c d c d d d d c d d e f f . .
|
|
35
|
+
. c d d c c c c d d d e f f f f
|
|
36
|
+
. . c d d d d d d d e f f b d f
|
|
37
|
+
. . . c d d d d e e f f f d d f
|
|
38
|
+
. . . . f f f e e f e e e f f f
|
|
39
|
+
. . . . f e e e e e e e f f f .
|
|
40
|
+
. . . f e e e e e e f f f e f .
|
|
41
|
+
. . f f e e e e f f f f f e f .
|
|
42
|
+
. f b d f e e f b b f f f e f .
|
|
43
|
+
. f d d f f f f d d b f f f f .
|
|
44
|
+
. f f f f f f f f f f f f f . .
|
|
45
|
+
`, SpriteKind.Player))
|
|
46
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).sayText("I'm player " + mp.getPlayerProperty(mp.playerSelector(mp.PlayerNumber.One), mp.PlayerProperty.Number))
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## See also #seealso
|
|
50
|
+
|
|
51
|
+
[get player state](/reference/multiplayer/get-player-state)
|
|
52
|
+
|
|
53
|
+
```package
|
|
54
|
+
multiplayer
|
|
55
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# get Player Sprite
|
|
2
|
+
|
|
3
|
+
Get the character sprite assigned to a Player.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One))
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
* **player**: the [Player](/types/player) whose sprite will be returned.
|
|
12
|
+
|
|
13
|
+
## Returns
|
|
14
|
+
|
|
15
|
+
* the [sprite](/reference/types/sprite) that is assigned to the **player**.
|
|
16
|
+
|
|
17
|
+
## Example #example
|
|
18
|
+
|
|
19
|
+
Make a player sprite move across the screen. When the sprite reaches the edge of the screen, send the sprite back in the opposite direction and flip the image of the sprite.
|
|
20
|
+
|
|
21
|
+
```blocks
|
|
22
|
+
scene.setBackgroundColor(8)
|
|
23
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
24
|
+
.............ccfff..............
|
|
25
|
+
...........ccddbcf..............
|
|
26
|
+
..........ccddbbf...............
|
|
27
|
+
..........fccbbcf...............
|
|
28
|
+
.....fffffccccccff.........ccc..
|
|
29
|
+
...ffbbbbbbbcbbbbcfff....ccbbc..
|
|
30
|
+
..fbbbbbbbbcbcbbbbcccff.cdbbc...
|
|
31
|
+
ffbbbbbbffbbcbcbbbcccccfcdbbf...
|
|
32
|
+
fbcbbb11ff1bcbbbbbcccccffbbf....
|
|
33
|
+
fbbb11111111bbbbbcccccccbbcf....
|
|
34
|
+
.fb11133cc11bbbbcccccccccccf....
|
|
35
|
+
..fccc31c111bbbcccccbdbffbbcf...
|
|
36
|
+
...fc13c111cbbbfcddddcc..fbbf...
|
|
37
|
+
....fccc111fbdbbccdcc.....fbbf..
|
|
38
|
+
........ccccfcdbbcc........fff..
|
|
39
|
+
.............fffff..............
|
|
40
|
+
`, SpriteKind.Player))
|
|
41
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).vx = -20
|
|
42
|
+
game.onUpdateInterval(500, function () {
|
|
43
|
+
if (mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).x < 0 || mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).x > scene.screenWidth()) {
|
|
44
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).image.flipX()
|
|
45
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).vx = mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).vx * -1
|
|
46
|
+
} else {
|
|
47
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).startEffect(effects.bubbles, 100)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## See also #seealso
|
|
53
|
+
|
|
54
|
+
[set player sprite](/reference/multiplayer/set-player-sprite),
|
|
55
|
+
[get player by sprite](/reference/multiplayer/get-player-by-sprite)
|
|
56
|
+
|
|
57
|
+
```package
|
|
58
|
+
multiplayer
|
|
59
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# get Player State
|
|
2
|
+
|
|
3
|
+
Get the value of a Player state item.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.getPlayerState(mp.playerSelector(mp.PlayerNumber.One), MultiplayerState.score)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Information like the player's score and life count is contained with the [Player](/types/player) game object. The Player object has the ``||mp:score||`` and ``||mp:life||`` state items already added.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **player**: the [Player](/types/player) to get a state item value for.
|
|
14
|
+
* **state**: the [state item](/reference/multiplayer/multiplayer-state) to get a **value** for, such as `score` or `life`.
|
|
15
|
+
|
|
16
|
+
## Returns
|
|
17
|
+
|
|
18
|
+
* **value**: a [number](/types/number) which is the value for **state**.
|
|
19
|
+
|
|
20
|
+
## Example #example
|
|
21
|
+
|
|
22
|
+
Get the ``||mp:number||`` property for `player 3`.
|
|
23
|
+
|
|
24
|
+
```blocks
|
|
25
|
+
scene.setBackgroundColor(10)
|
|
26
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.One), sprites.create(img`
|
|
27
|
+
. . . . . f f f f f . . . . . .
|
|
28
|
+
. . . . f e e e e e f . . . . .
|
|
29
|
+
. . . f d d d d d d e f . . . .
|
|
30
|
+
. . f d f f d d f f d f f . . .
|
|
31
|
+
. c d d d e e d d d d e d f . .
|
|
32
|
+
. c d c d d d d c d d e f f . .
|
|
33
|
+
. c d d c c c c d d d e f f f f
|
|
34
|
+
. . c d d d d d d d e f f b d f
|
|
35
|
+
. . . c d d d d e e f f f d d f
|
|
36
|
+
. . . . f f f e e f e e e f f f
|
|
37
|
+
. . . . f e e e e e e e f f f .
|
|
38
|
+
. . . f e e e e e e f f f e f .
|
|
39
|
+
. . f f e e e e f f f f f e f .
|
|
40
|
+
. f b d f e e f b b f f f e f .
|
|
41
|
+
. f d d f f f f d d b f f f f .
|
|
42
|
+
. f f f f f f f f f f f f f . .
|
|
43
|
+
`, SpriteKind.Player))
|
|
44
|
+
mp.getPlayerSprite(mp.playerSelector(mp.PlayerNumber.One)).sayText("I'm player " + mp.getPlayerProperty(mp.playerSelector(mp.PlayerNumber.One), mp.PlayerProperty.Number))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## See also #seealso
|
|
48
|
+
|
|
49
|
+
[set player state](/refernece/multiplayer/set-player-state),
|
|
50
|
+
[change player state by](/reference/multiplayer/change-player-state-by),
|
|
51
|
+
[get player property](/reference/multiplayer/get-player-property)
|
|
52
|
+
|
|
53
|
+
```package
|
|
54
|
+
multiplayer
|
|
55
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# is Button Pressed
|
|
2
|
+
|
|
3
|
+
Check if a controller button for a player is pressed or not.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.isButtonPressed(mp.playerSelector(mp.PlayerNumber.One), mp.MultiplayerButton.A)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
* **player**: the player to check the controller button state for.
|
|
12
|
+
* **button**: the controller button to check for a pressed condition.
|
|
13
|
+
|
|
14
|
+
## Returns
|
|
15
|
+
|
|
16
|
+
* a [boolean](/types/boolean) value for the state of the **button** for the **player**. It is `true` if the button is pressed and `false` if the button is not pressed.
|
|
17
|
+
|
|
18
|
+
## Example #example
|
|
19
|
+
|
|
20
|
+
If `player 2` is pressing the up arrow button for too long, then`player 1` wins.
|
|
21
|
+
|
|
22
|
+
```blocks
|
|
23
|
+
let pressCount = 0
|
|
24
|
+
game.onUpdateInterval(500, function () {
|
|
25
|
+
if (mp.isButtonPressed(mp.playerSelector(mp.PlayerNumber.Two), mp.MultiplayerButton.Up)) {
|
|
26
|
+
pressCount += 1
|
|
27
|
+
if (pressCount > 1) {
|
|
28
|
+
mp.gameOverPlayerWin(mp.playerSelector(mp.PlayerNumber.One))
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
pressCount = 0
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## See also #seealso
|
|
37
|
+
|
|
38
|
+
[on button pressed](/reference/multiplayer/on-button-pressed),
|
|
39
|
+
[move with buttons](/reference/multiplayer/move-with-buttons)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
```package
|
|
43
|
+
multiplayer
|
|
44
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# move With Buttons
|
|
2
|
+
|
|
3
|
+
Add movement control to a player sprite with the controller arrow buttons.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
mp.moveWithButtons(mp.playerSelector(mp.PlayerNumber.One))
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A player's sprite will move vertically or horizontally with the controller's arrow buttons. The horizontal `vx` and vertical `vy` values a speeds (pixels per second) at which the sprite will move when an arrow button is pressed. If no values are set for `vx` and `vy`, the default value of `100` is used.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **player**: the player to set movement control for.
|
|
14
|
+
* **vx**: an optional velocity (speed) to move the player in the left or right direction. The default value is `100`.
|
|
15
|
+
* **vy**: an optional velocity (speed) to move the player the up or down direction. The default value is `100`.
|
|
16
|
+
|
|
17
|
+
## Example #example
|
|
18
|
+
|
|
19
|
+
Set a character sprite for `player 2` and make it move with the controller buttons.
|
|
20
|
+
|
|
21
|
+
```blocks
|
|
22
|
+
scene.setBackgroundColor(10)
|
|
23
|
+
mp.setPlayerSprite(mp.playerSelector(mp.PlayerNumber.Two), sprites.create(img`
|
|
24
|
+
. . . . . f f f f f . . . . . .
|
|
25
|
+
. . . . f e e e e e f . . . . .
|
|
26
|
+
. . . f d d d d d d e f . . . .
|
|
27
|
+
. . f d f f d d f f d f f . . .
|
|
28
|
+
. c d d d e e d d d d e d f . .
|
|
29
|
+
. c d c d d d d c d d e f f . .
|
|
30
|
+
. c d d c c c c d d d e f f f f
|
|
31
|
+
. . c d d d d d d d e f f b d f
|
|
32
|
+
. . . c d d d d e e f f f d d f
|
|
33
|
+
. . . . f f f e e f e e e f f f
|
|
34
|
+
. . . . f e e e e e e e f f f .
|
|
35
|
+
. . . f e e e e e e f f f e f .
|
|
36
|
+
. . f f e e e e f f f f f e f .
|
|
37
|
+
. f b d f e e f b b f f f e f .
|
|
38
|
+
. f d d f f f f d d b f f f f .
|
|
39
|
+
. f f f f f f f f f f f f f . .
|
|
40
|
+
`, SpriteKind.Player))
|
|
41
|
+
mp.moveWithButtons(mp.playerSelector(mp.PlayerNumber.Two))
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## See also #seealso
|
|
45
|
+
|
|
46
|
+
[is button pressed](/reference/multiplayer/is-button-pressed)
|
|
47
|
+
|
|
48
|
+
```package
|
|
49
|
+
multiplayer
|
|
50
|
+
```
|