前提
this.ProcessControls();を含めると画面が4分の1サイズで表示されるように成る。
問題のコードを入れなければ、正常に表示される
実現したいこと
画面が正常に表示されるようにしたい
発生している問題・エラーメッセージ
有りません
該当のソースコード
C#
1public partial class FormPrincipal : Form 2 { 3 DispatcherTimer gameLoopTimer { get; set; } 4 5 DispatcherTimer enemySpawnTimer { get; set; } 6 7 Bitmap screenBuffer { get; set; } 8 9 Graphics screenPainter { get; set; } 10 11 BackGround backGround { get; set; } 12 13 Player player { get; set; } 14 15 List<GameObject> gameObjects { get; set; } 16 17 public Random random { get; set; } 18 19 public FormPrincipal() 20 { 21 InitializeComponent(); 22 23 24 this.random = new Random(); 25 this.ClientSize = Media.BackGround.Size; 26 this.screenBuffer = new Bitmap(Media.BackGround.Width, Media.BackGround.Height); 27 this.screenPainter = Graphics.FromImage(this.screenBuffer); 28 this.gameObjects = new List<GameObject>(); 29 this.backGround = new BackGround(this.screenBuffer.Size, this.screenPainter); 30 this.player = new Player(this.screenBuffer.Size, this.screenPainter); 31 32 this.gameLoopTimer = new DispatcherTimer(DispatcherPriority.Render); 33 this.gameLoopTimer.Interval = TimeSpan.FromMilliseconds(16.66666); 34 this.gameLoopTimer.Tick += GameLoop; 35 36 this.enemySpawnTimer = new DispatcherTimer(DispatcherPriority.Render); 37 this.enemySpawnTimer.Interval = TimeSpan.FromMilliseconds(1000); 38 this.enemySpawnTimer.Tick += SpawnEnemy; 39 40 this.gameObjects.Add(backGround); 41 this.gameObjects.Add(player); 42 43 StartGame(); 44 } 45 46 public void StartGame() 47 { 48 this.gameLoopTimer.Start(); 49 this.enemySpawnTimer.Start(); 50 } 51 52 public void SpawnEnemy(object sender, EventArgs e) 53 { 54 Point enemyPosition = new Point(this.random.Next(74, this.screenBuffer.Width - 10) - 62); 55 Enemy enemy = new Enemy(this.screenBuffer.Size, this.screenPainter, enemyPosition); 56 this.gameObjects.Add(enemy); 57 } 58 59 public void GameLoop(object sender, EventArgs e) 60 { 61 this.gameObjects.RemoveAll(x => !x.Active); 62 63 this.ProcessControls(); 64 65 foreach (GameObject go in this.gameObjects) 66 { 67 68 go.UpDateObject(); 69 70 if (go.IsOutOfBounds()) 71 { 72 go.Destroy(); 73 } 74 75 76 } 77 this.Invalidate(); 78 } 79 80 private void FormPrincipal_Paint(object sender, PaintEventArgs e) 81 { 82 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; 83 e.Graphics.DrawImage(this.screenBuffer, 0, 0); 84 } 85 86 private void ProcessControls() 87 { 88 if (Keyboard.IsKeyDown(Key.Left)) player.MoveLeft(); 89 if (Keyboard.IsKeyDown(Key.Right)) player.MoveRight(); 90 if (Keyboard.IsKeyDown(Key.Up)) player.MoveUp(); 91 if (Keyboard.IsKeyDown(Key.Down)) player.MoveDown(); 92 } 93 94 private void FormPrincipal_Load(object sender, EventArgs e) 95 { 96 97 } 98 }
試したこと
いろいろ試して、もう覚えてない
補足情
 
> 退会済みユーザー
おいおいマジかよorz
