2018-01-16 23:52:49 +01:00
|
|
|
namespace brick {
|
2018-01-17 02:05:57 +01:00
|
|
|
/**
|
2018-01-31 02:02:22 +01:00
|
|
|
* Show a mood on the brick's screen
|
2018-01-17 02:05:57 +01:00
|
|
|
*/
|
|
|
|
//% weight=90
|
|
|
|
//% blockId=moodShow block="show mood %mood=mood_image_picker"
|
2018-01-31 02:02:22 +01:00
|
|
|
//% help=brick/show-mood
|
2018-01-17 02:05:57 +01:00
|
|
|
//% weight=101 group="Screen" blockGap=8
|
|
|
|
export function showMood(mood: Mood) {
|
|
|
|
if(mood)
|
|
|
|
mood.show();
|
|
|
|
}
|
|
|
|
|
2018-01-16 23:52:49 +01:00
|
|
|
/**
|
|
|
|
* A mood
|
|
|
|
*/
|
|
|
|
//% fixedInstances
|
|
|
|
export class Mood {
|
2018-01-17 02:05:57 +01:00
|
|
|
private image: Image;
|
|
|
|
private sound: Sound;
|
2018-02-07 07:18:39 +01:00
|
|
|
private light: StatusLight;
|
2018-01-16 23:52:49 +01:00
|
|
|
|
2018-02-07 07:18:39 +01:00
|
|
|
constructor(image: Image, sound: Sound, light: StatusLight) {
|
2018-01-16 23:52:49 +01:00
|
|
|
this.image = image;
|
|
|
|
this.sound = sound;
|
|
|
|
this.light = light;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the mood on the EV3
|
|
|
|
*/
|
|
|
|
show() {
|
2018-02-07 07:18:39 +01:00
|
|
|
brick.setStatusLight(this.light);
|
2018-01-16 23:52:49 +01:00
|
|
|
brick.showImage(this.image);
|
2018-01-17 01:44:32 +01:00
|
|
|
music.playSoundEffectUntilDone(this.sound);
|
2018-01-17 02:05:57 +01:00
|
|
|
loops.pause(20);
|
2018-01-16 23:52:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An image
|
|
|
|
* @param image the image
|
|
|
|
*/
|
|
|
|
//% blockId=mood_image_picker block="%image" shim=TD_ID
|
|
|
|
//% image.fieldEditor="images"
|
|
|
|
//% image.fieldOptions.columns=4
|
|
|
|
//% image.fieldOptions.width=400
|
|
|
|
//% group="Screen" weight=0 blockHidden=1
|
|
|
|
export function __moodImagePicker(mood: Mood): Mood {
|
|
|
|
return mood;
|
2018-01-17 02:05:57 +01:00
|
|
|
}
|
2018-01-17 01:21:02 +01:00
|
|
|
}
|
2018-01-16 23:52:49 +01:00
|
|
|
|
2018-01-17 01:21:02 +01:00
|
|
|
namespace moods {
|
2018-01-16 23:52:49 +01:00
|
|
|
/**
|
|
|
|
* A sleeping mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesSleeping
|
2018-02-07 07:18:39 +01:00
|
|
|
export const sleeping = new brick.Mood(images.eyesSleeping, sounds.expressionsSnoring, StatusLight.OrangePulse);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A awake mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesAwake
|
2018-02-07 07:18:39 +01:00
|
|
|
export const awake = new brick.Mood(images.eyesAwake, sounds.informationActivate, StatusLight.Orange);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A tired mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesTiredMiddle
|
2018-02-07 07:18:39 +01:00
|
|
|
export const tired = new brick.Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, StatusLight.OrangeFlash);
|
2018-01-17 02:05:57 +01:00
|
|
|
|
2018-01-16 23:52:49 +01:00
|
|
|
/**
|
|
|
|
* An angry mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesAngry
|
2018-02-07 07:18:39 +01:00
|
|
|
export const angry = new brick.Mood(images.eyesAngry, sounds.animalsDogGrowl, StatusLight.RedPulse);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A sad mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesTear
|
2018-02-07 07:18:39 +01:00
|
|
|
export const sad = new brick.Mood(images.eyesTear, sounds.animalsDogWhine, StatusLight.Red);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A dizzy mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesDizzy
|
2018-02-07 07:18:39 +01:00
|
|
|
export const dizzy = new brick.Mood(images.eyesDizzy, sounds.expressionsUhOh, StatusLight.OrangeFlash);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A knocked out mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesKnockedOut
|
2018-02-07 07:18:39 +01:00
|
|
|
export const knockedOut = new brick.Mood(images.eyesKnockedOut, sounds.informationError, StatusLight.RedFlash);
|
2018-01-17 02:05:57 +01:00
|
|
|
|
2018-01-16 23:52:49 +01:00
|
|
|
/**
|
|
|
|
* Looking around left
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesMiddleLeft
|
2018-02-07 07:18:39 +01:00
|
|
|
export const middleLeft = new brick.Mood(images.eyesMiddleLeft, sounds.informationAnalyze, StatusLight.Off);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Looking around right
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesMiddleRight
|
2018-02-07 07:18:39 +01:00
|
|
|
export const middleRight = new brick.Mood(images.eyesMiddleRight, sounds.informationAnalyze, StatusLight.Off);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In love mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesLove
|
2018-02-07 07:18:39 +01:00
|
|
|
export const love = new brick.Mood(images.eyesLove, sounds.expressionsMagicWand, StatusLight.GreenPulse);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In laughing mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesWinking
|
2018-02-07 07:18:39 +01:00
|
|
|
export const winking = new brick.Mood(images.eyesWinking, sounds.expressionsLaughing1, StatusLight.GreenFlash);
|
2018-01-16 23:52:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In a neutral mood
|
|
|
|
*/
|
|
|
|
//% fixedInstance jres=images.eyesNeutral
|
2018-02-07 07:18:39 +01:00
|
|
|
export const neutral = new brick.Mood(images.eyesNeutral, undefined, StatusLight.Green);
|
2018-01-16 23:52:49 +01:00
|
|
|
}
|