Skip to content
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

Open
wants to merge 44 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 44 commits into from

Conversation

github-classroom[bot]
Copy link
Contributor

@github-classroom github-classroom bot commented Nov 11, 2022

👋! 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:

  • Click the Files changed tab to see all of the changes pushed to 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”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @monty930

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.

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...

Copy link

@agluszak agluszak left a 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"] }

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!");

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
Comment on lines 63 to 71
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,

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
Comment on lines 120 to 131
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;
}
}

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>)>,

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()) {

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(

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 {

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!");

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),

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

Copy link

@agluszak agluszak left a 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\
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants