-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feedback #1
base: feedback
Are you sure you want to change the base?
Feedback #1
Conversation
README.md
Outdated
|
||
In the second part we're going to add random map generator, saving/loading, scores and a more sophisticated AI. | ||
In the second part I'm going to add enemies, lives, stones and saving-loading system. |
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.
nie wiem czy to nie za mało...
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.
Przetwarzanie mapy jest boleśnie powtórzone kilka razy. Oprócz tego kod powtarza się w wielu miejscach. Przydałoby się podniesienie poziomu abstrakcji zamiast techniki programowania "kopiuj-wklej". Gra działa poprawnie, ale jakość kodu jest niezbyt dobra, poza tym kod jest nieskomplikowany (in a bad way).
3.5/5
edition = "2021" | ||
|
||
[dependencies] | ||
bevy = { version = "0.6", features = ["dynamic"] } |
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.
stara wersja
|
||
// Creates bushes vector and places bushes on the map, basing on /assets/map.txt file | ||
fn spawn_bushes(mut commands: Commands, texture: Res<CharacterTextures>) { | ||
let file = File::open("assets/map.txt").expect("Couldn't open map asset!"); |
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.
lepiej byłoby, gdyby istaniał jakiś jeden system, co sparsuje raz a dobrze ten plik i umieści tablicę z rodzajami w pól jako resource
src/player.rs
Outdated
speed: PLAYER_SPEED, | ||
health: INIT_HEALTH, | ||
diamonds: 0, | ||
keys: 0, | ||
last_up_movement: STARTUP_LAST_MOVEMENT, | ||
last_down_movement: STARTUP_LAST_MOVEMENT, | ||
last_right_movement: STARTUP_LAST_MOVEMENT, | ||
last_left_movement: STARTUP_LAST_MOVEMENT, | ||
unchecked_movement: 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.
lepiej napisać implementację traitu Default i tutaj użyć Player::default()
src/player.rs
Outdated
if keyboard.pressed(KeyCode::Left) { | ||
if player.last_left_movement + MINIMUM_MOVE_BREAK <= time.seconds_since_startup() as f32 { | ||
x_delta -= TILE_SIZE; | ||
player.last_left_movement = time.seconds_since_startup() as f32; | ||
} | ||
} | ||
if keyboard.pressed(KeyCode::Right) { | ||
if player.last_right_movement + MINIMUM_MOVE_BREAK <= time.seconds_since_startup() as f32 { | ||
x_delta += TILE_SIZE; | ||
player.last_right_movement = time.seconds_since_startup() as f32; | ||
} | ||
} |
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.
powtórzony kod
fn player_interractions( | ||
mut commands: Commands, | ||
mut player_query: Query<(&mut Player, &mut Transform)>, | ||
bush_query_transform: Query<&Transform, (With<BushCollider>, Without<Player>)>, |
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.
zamiast odczytywać pozycję z komponentu Transform, proponuję zrobić komponent np. Position, i na jego podstawie ustawiać Transform - wtedy rysowanie i pozycja "logiczna" będą od siebie oddzielone, co pozwoli np. na skalowanie
} | ||
|
||
// door check | ||
for iter in door_query_transform.iter().zip(door_query_entity.iter()) { |
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.
proponuję podzielić ten sytem na kilka mniejszych i wprowadzić jakąś abstrakcję - np. zdefiniować jakąś strukturę która zawiera informacje co się ma stać po kolizji: czy obiekt ma zniknąć i jak mają zmienić się statystyki gracza
src/player.rs
Outdated
} | ||
|
||
// Checks if the player movement would cause the wall collision. | ||
fn check_wall_collision( |
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.
lepsza byłaby nazwa np. "would_collide_with_wall" - wtedy byłoby jasne co oznacza true i false
src/player.rs
Outdated
position | ||
} | ||
|
||
fn check_simple_collision(position1: &Vec3, position2: &Vec3) -> bool { |
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.
po co używać Vec3, skoro korzysta Pani tylko z dwóch wymiarów?
('g', GRASS_IDX), | ||
]); | ||
|
||
let file = File::open("assets/map.txt").expect("Couldn't open map asset!"); |
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.
i znowu wczytywanie...
&mut commands, | ||
&texture, | ||
tile_idx, | ||
Vec3::new(x as f32 * TILE_SIZE, -(y as f32) * TILE_SIZE, 100.0), |
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.
to przydałoby się wyciągnąć do funkcji
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.
Sama gra wygląda w porządku, ale niestety wielu rzeczy, na które zwróciłem uwagę w poprzedniej części, nie udało się naprawić. Kod nie przeszedł ogólnej refaktoryzacji, na którą zasługuje. A jednak kod jest tutaj ważniejszy. 4/5
}) | ||
.id(); | ||
fn put_init_values_to_file() { | ||
let data = "{\"speed\":10.0,\"health\":3,\"diamonds\":0,\"keys\":0,\"last_up_move\ |
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.
a czemu nie stworzyć normalnej struktury i użyć serde do zserializowania jej do pliku?
👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to
main
since the assignment started. Your teacher can see this too.Notes for teachers
Use this PR to leave feedback. Here are some tips:
main
since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.main
. Click a commit to see specific changes.For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @monty930