加速度センサーでグラフィックコントロール | |
---|---|
private void main() { BrainPad.Display.Clear(); int x = 80, y = 50; while (true) { double dx = BrainPad.Accelerometer.ReadY(); x = (int)(x+dx*80); if (x < 0) x = 0; if(150 <= x) x=150-1; BrainPad.Display.DrawFilledRectangle(x, y, 10, 10, BrainPad.Color.Green); Thread.Sleep(40); BrainPad.Display.DrawFilledRectangle(x, y, 10, 10, BrainPad.Color.Black); } } |
1 2 3 ディスプレイ消去 4 ディスプレイの中心付近 5 永久ループ 6 7 横方向の傾斜を計測 8 移動座標を計算する 9 左に行きすぎか 10 右に行きすぎか 11 四角を描画 12 提示時間 13 四角を消去 14 15 |