//Billentyű lenyomás eseménykezelője private void GameForm_KeyDown(object sender, KeyEventArgs e) { //ha nincs szünet, és tart a játék... if (!paused && !gameover) { switch (e.KeyCode) // megkapjuk a billentyűt { case Keys.W: //fel if (model.IsFloor(model.PlayerPos.X - 1, model.PlayerPos.Y)) { label_grid[model.PlayerPos.X, model.PlayerPos.Y].Image = imgs[0]; label_grid[model.PlayerPos.X - 1, model.PlayerPos.Y].Image = imgs[3]; model.Up(); } break; case Keys.A: //balra if (model.IsFloor(model.PlayerPos.X, model.PlayerPos.Y - 1)) { label_grid[model.PlayerPos.X, model.PlayerPos.Y].Image = imgs[0]; label_grid[model.PlayerPos.X, model.PlayerPos.Y - 1].Image = imgs[3]; model.Left(); } break; case Keys.S: //le if (model.IsFloor(model.PlayerPos.X + 1, model.PlayerPos.Y)) { label_grid[model.PlayerPos.X, model.PlayerPos.Y].Image = imgs[0]; label_grid[model.PlayerPos.X + 1, model.PlayerPos.Y].Image = imgs[3]; model.Down(); } break; case Keys.D: //jobbra if (model.IsFloor(model.PlayerPos.X, model.PlayerPos.Y + 1)) { label_grid[model.PlayerPos.X, model.PlayerPos.Y].Image = imgs[0]; label_grid[model.PlayerPos.X, model.PlayerPos.Y + 1].Image = imgs[3]; model.Right(); } break; default: break; } } }
public void YogiBearModelIsFloorTest() { model.Map = data.LoadFirstLevel(level1); Assert.IsFalse(model.IsFloor(10, 1)); for (Int32 i = 0; i < 8; i++) { for (Int32 j = 0; j < 8; j++) { if (model.Map[i][j] == 0 || model.Map[i][j] == 2 || model.Map[i][j] == 3) { Assert.IsTrue(model.IsFloor(i, j)); } else { Assert.IsFalse(model.IsFloor(i, j)); } } } }
private void MoveBear(Int32 direction) { if (!paused) { switch (direction) { case 1: if (model.IsFloor(model.PlayerPos.X - 1, model.PlayerPos.Y)) { model.Up(); } break; case 3: if (model.IsFloor(model.PlayerPos.X + 1, model.PlayerPos.Y)) { model.Down(); } break; case 4: if (model.IsFloor(model.PlayerPos.X, model.PlayerPos.Y + 1)) { model.Right(); } break; case 2: if (model.IsFloor(model.PlayerPos.X, model.PlayerPos.Y - 1)) { model.Left(); } break; default: break; } } RefreshGameFields(); OnPropertyChanged("Fields"); }