Egg and Spoon example (#429)
This commit is contained in:
		
							
								
								
									
										28
									
								
								docs/examples/egg-and-spoon.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								docs/examples/egg-and-spoon.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
# Egg and Spoon race
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let accY = 0
 | 
			
		||||
let accX = 0
 | 
			
		||||
let y = 0
 | 
			
		||||
let x = 0
 | 
			
		||||
basic.forever(() => {
 | 
			
		||||
    led.plot(x, y)
 | 
			
		||||
    accX = input.acceleration(Dimension.X)
 | 
			
		||||
    accY = input.acceleration(Dimension.Y)
 | 
			
		||||
    if (accX < -150 && x > 0) {
 | 
			
		||||
        x += -1
 | 
			
		||||
    } else if (accX > 150 && x < 4) {
 | 
			
		||||
        x += 1
 | 
			
		||||
    }
 | 
			
		||||
    if (accY < -150 && y > 0) {
 | 
			
		||||
        y += -1
 | 
			
		||||
    } else if (accY > 150 && y < 4) {
 | 
			
		||||
        y += 1
 | 
			
		||||
    }
 | 
			
		||||
    basic.pause(500)
 | 
			
		||||
    basic.clearScreen()
 | 
			
		||||
})
 | 
			
		||||
x = 2
 | 
			
		||||
y = 2
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
		Reference in New Issue
	
	Block a user