/// <summary> /// 1フレームぶんの処理を行う。 /// </summary> /// <param name="keys">GetHitKeyStateAll で取得したキー入力情報</param> public void Update(Key key) { // 移動(斜め移動が速くなるのは気にしないことにした) var currentSpeed = key.IsPressing(DX.KEY_INPUT_LSHIFT) ? slowSpeed : speed; if (key.IsPressing(DX.KEY_INPUT_UP)) { Position.Y -= currentSpeed; } if (key.IsPressing(DX.KEY_INPUT_LEFT)) { Position.X -= currentSpeed; } if (key.IsPressing(DX.KEY_INPUT_DOWN)) { Position.Y += currentSpeed; } if (key.IsPressing(DX.KEY_INPUT_RIGHT)) { Position.X += currentSpeed; } // 画面外に行かないようにする if (Position.X < Radius) { Position.X = Radius; } if (Position.Y < Radius) { Position.Y = Radius; } if (Position.X > 640 - Radius) { Position.X = 640 - Radius; } if (Position.Y > 480 - Radius) { Position.Y = 480 - Radius; } // 弾を発射 if (bulletFrame == 0 && key.IsPressing(DX.KEY_INPUT_Z)) { game.OwnBullets.Add(new Bullet(1, Position, 5, 3 * Math.PI / 2, 10.0, DX.GetColor(255, 255, 0))); bulletFrame = 12; } if (bulletFrame > 0) { --bulletFrame; } }
public ShootingGame(Key key, string scriptPath) { OwnChar = new OwnCharacter(this, new Position(320.0, 400.0)); OwnBullets = new List<Bullet>(); Enemies = new List<Enemy>(); EnemyBullets = new List<Bullet>(); this.key = key; // スクリプト読み込み this.ScriptPath = scriptPath; var loader = new ScriptLoader(this); var script = loader.Load(this.ScriptPath); runner = new ScriptRunner(this, script); }