-
Notifications
You must be signed in to change notification settings - Fork 0
Hw6 game #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hw6 game #12
Conversation
tests are still waiting
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом так, но как-то уж очень нетехнично.
hw6Game/hw6Game/Game.cs
Outdated
| coordinates = map.GetPlayerCoordinates(); | ||
| switch (step) | ||
| { | ||
| case "left": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мм. Для этого и придумали enum-ы. Хотя, честно говоря, для этого придумали лямбды, чтобы switch-и тут не писать :) Подумайте, как это написать более красиво
|
|
||
| namespace hw6Game | ||
| { | ||
| public class EventLoop |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public event EventHandler<EventArgs> LeftHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> RightHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> UpHandler = (sender, args) => { }; | ||
| public event EventHandler<EventArgs> DownHandler = (sender, args) => { }; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
hw6Game/hw6Game.Test/MoveTest.cs
Outdated
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| eventLoop = new EventLoop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что-то он нигде не используется
hw6Game/hw6Game/Map.cs
Outdated
| public int y; | ||
| } | ||
|
|
||
| static private string[] mapPic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему он static?
hw6Game/hw6Game/Map.cs
Outdated
| { | ||
| public class Map | ||
| { | ||
| private struct PlayerCoordination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Координация", не "Координаты"?
|
|
||
| public event EventHandler<EventArgs> DownHandler = (sender, args) => { }; | ||
|
|
||
| public void Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Комментарии к методам и даже событиям тоже нужны, но ладно
hw6Game/hw6Game/Game.cs
Outdated
|
|
||
| public void OnLeft(object sender, EventArgs args) | ||
| { | ||
| Move("left"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну да, а если тут или в Move опечататься, то не будет работать, и компилятор не поругается. Варианты решения проблемы:
а) enum-ы,
б) лямбда-функции
Реализуйте что-то из этого :)
hw6Game/hw6Game/Map.cs
Outdated
|
|
||
| private string[] mapPic; | ||
|
|
||
| static private PlayerCoordinates player = new PlayerCoordinates(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Просто new(), зачем имя типа дважды писать
hw6Game/hw6Game/Map.cs
Outdated
| return false; | ||
| } | ||
| player.y -= 1; | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну тут точно стоило передавать в Move функцию, которая бы возвращала изменённую координату, чтобы четыре раза одно и то же не писать
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всё равно неаккуратно. Неаккуратных программистов вся команда ненавидит :)
| left, | ||
| right, | ||
| up, | ||
| down |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Элементы enum-а в .NET пишутся с заглавной
| public void OnLeft(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.left); | ||
| } | ||
|
|
||
| public void OnRight(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.right); | ||
| } | ||
|
|
||
| public void OnDown(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.down); | ||
| } | ||
|
|
||
| public void OnUp(object sender, EventArgs args) | ||
| { | ||
| Move(Moves.up); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Однострочники пишутся через =>
|
|
||
| private bool CheckMove((int x, int y) coord) | ||
| { | ||
| if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@') | |
| if (mapPic[coord.y][coord.x] != ' ' && mapPic[coord.y][coord.x] != '@') |
| return false; | ||
| } | ||
| player.x = coord.x; | ||
| player.y =coord.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| player.y =coord.y; | |
| player.y = coord.y; |
| default: | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expression switch?
No description provided.