This commit is contained in:
Juri
2020-08-19 22:03:58 +02:00
parent 4ef7b9318f
commit 3152215415
291 changed files with 9511 additions and 2966 deletions

View File

@ -22,13 +22,13 @@ Here's a program that simulates cell life in the LED matrix. Use button ``A`` fo
let lifeChart: Image = null
//Use button A for the next iteration of game of life
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
input.onButtonPressed(Button.A, () => {
gameOfLife();
show();
})
//Use button B for reseting to random initial seed state
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
input.onButtonPressed(Button.B, () => {
reset();
show();
})

View File

@ -73,8 +73,8 @@ basic.forever(() => {
inside = 0
for (let i = 0; i < n; i++) {
// generate a point within the square
x = Math.randomRange(0, r + 1)
y = Math.randomRange(0, r + 1)
x = randint(0, r + 1)
y = randint(0, r + 1)
// test if the point is within the circle
// sqrt(x**2 + y**2) < r ==> x**2 + y**2 < r**2
if (x * x + y * y < r2) {

View File

@ -4,6 +4,6 @@ Generate a random coordinate and display it on the LED screen.
```blocks
basic.forever(() => {
led.toggle(Math.randomRange(0, 4), Math.randomRange(0, 4))
led.toggle(randint(0, 4), randint(0, 4))
})
```