Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input.onButtonPressed(Button.A, function () {
- if (iscooldown == true) {
- return
- }
- i = Math.clamp(0,Infinity,i + 1)
- basic.showNumber(i)
- while (true) {
- wait(delta_time)
- timepassed += delta_time
- console.log(timepassed)
- if (timepassed >= cooldown) {
- break;
- }
- }
- timepassed = 0
- iscooldown = false
- })
- function wait (second: number) {
- n = second * 1000
- basic.pause(n)
- return n
- }
- input.onButtonPressed(Button.AB, function () {
- timepassed = 0
- timepassed2 = 0
- i = 0
- basic.showNumber(i)
- for (let value of music_data) {
- if (last_value == value) {
- wait(delta_time)
- }
- music.playTone(value, music.beat(BeatFraction.Whole))
- last_value = value
- }
- })
- input.onButtonPressed(Button.B, function () {
- if (iscooldown == true) {
- return
- }
- i = Math.clamp(0, Infinity, i - 1)
- basic.showNumber(i)
- while (true) {
- wait(delta_time)
- timepassed2 += delta_time
- console.log(timepassed2)
- if (timepassed2 >= cooldown) {
- break;
- }
- }
- timepassed2 = 0
- iscooldown = false
- })
- let last_value = 0
- let n = 0
- let cooldown = 0
- let iscooldown = false
- let music_data: number[] = []
- let delta_time = 0
- let timepassed = 0
- let timepassed2 = 0
- let i = 0
- delta_time = 0.016
- basic.showNumber(i)
- // 330 = E | 294 = D | 262 = C
- music_data = [
- 330,
- 294,
- 262,
- 294,
- 330,
- 330,
- 330,
- 294,
- 294,
- 294,
- 330,
- 330,
- 330,
- 294,
- 262,
- 294,
- 330,
- 330,
- 330,
- 294,
- 294,
- 330,
- 294,
- 262
- ]
Advertisement
Add Comment
Please, Sign In to add comment