public partial class Program
{
// x y
static BrainPad.Display.Image cat1 = new BrainPad.Display.Image(32, 37);
static BrainPad.Display.Image cat2 = new BrainPad.Display.Image(32, 37);
static ADcon mic;
static bool jumpState=false;
private void main()
{
BrainPad.Display.Clear();
BrainPad.LightBulb.SetColor(BrainPad.Color.Black);
getResourceBmp(cat1, Resources.BinaryResources.cat1_a);
getResourceBmp(cat2, Resources.BinaryResources.cat1_b);
mic = new ADcon(CPU.E1);
while (true)
{
BrainPad.Display.DrawImage(64, 80, cat1);
Thread.Sleep(500);
if (jumpState) jump();
BrainPad.Display.DrawImage(64, 80, cat2);
Thread.Sleep(500);
if (jumpState) jump();
}
}
static void micIn(object ob)
{
if (mic.Read() > 0.51) jumpState = true;
}
static void jump()
{
BrainPad.Display.DrawFilledRectangle(64, 80, 32, 37, BrainPad.Color.Black);
BrainPad.Display.DrawImage(64, 20, cat1);
Thread.Sleep(1000);
BrainPad.Display.DrawFilledRectangle(64, 20, 32, 37, BrainPad.Color.Black);
jumpState = false;
}
static void getResourceBmp(BrainPad.Display.Image image, Resources.BinaryResources id)
{ // 16bpp BGR565から変換する
byte[] z = (byte[])
ResourceUtility.GetObject(Resources.ResourceManager, id); //32*37=2368
BrainPad.Color color = new BrainPad.Color();
int dt = 0x42; // BMPのデータ開始アドレス
for (int Y = image.Height - 1; Y >= 0; Y--)
{
for (int X = 0; X < image.Width; X++)
{ // ピクセルデータの取得
byte d = z[dt++];
byte e = z[dt++];
color.B = (byte)(d & 0x1f);
color.G = (byte)(((d & 0xe0) >> 5) + ((e & 0x07) << 3));
color.R = (byte)((e & 0xf8) >> 3);
image.SetPixel(X, Y, color);
}
}
}
}
|
1
2
3
4
5
6 マイクの音をアナログ入力する
7 音がしたかのチェック
8
9
10
11
12
13
14 マイク入力ははE1に接続する
15
16
17
18
19 大きい音がしたらジャンプする
20
21
22
23
24
25
26
27
28 大きい音の検出。0.5が無音
29
30 猫をジャンプさせる
31
32
33
34
35
36
37
38 説明は前項にしている
39 ので上記を参照してください
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|