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 84 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
8435f5a
Setting up GitHub Classroom Feedback
github-classroom[bot] Apr 11, 2022
a1bee8b
Updating README
Apr 11, 2022
4f42bee
Update bibliotek
PBundyra Apr 28, 2022
be8350e
Adding links
PBundyra Apr 28, 2022
8f1dea0
Update README.md
KatKlo Apr 28, 2022
b129124
Update README.md
PBundyra Apr 28, 2022
77f106e
Update README.md
PBundyra Apr 28, 2022
b7d6086
Update README.md
PBundyra Apr 28, 2022
6062c67
Update README.md
KatKlo May 3, 2022
969a5c8
Init ;
May 31, 2022
fb3e0b2
Fix bullets
KatKlo May 31, 2022
bc4a368
Add util for spawning bundles and make better looking floor
KatKlo Jun 16, 2022
96ae00e
Merge pull request #2 from mimuw-jnp2-rust/kasia
KatKlo Jun 16, 2022
c852d03
Add easy menu after death
KatKlo Jun 16, 2022
b28c0c0
Move spawn util into game module
KatKlo Jun 16, 2022
989bbe2
Add end menu and finish line
KatKlo Jun 16, 2022
b44a3f3
Merge branch 'main' into menu
KatKlo Jun 16, 2022
5beadf6
Make player falling impossible
KatKlo Jun 16, 2022
c31c446
More refactor
KatKlo Jun 17, 2022
c8200c6
player_textures -> game_textures
Jun 17, 2022
b647db7
Booster -> Powerup
Jun 17, 2022
d704378
Adding living being component and killing player as event
Jun 17, 2022
ca9c16d
Killing enemies by event and removing NASA calculations
Jun 17, 2022
02092c2
Adding kira audio
Jun 17, 2022
b7d2e5c
Adding basic audio
Jun 18, 2022
46862ee
Adding differents hit sound effects
Jun 18, 2022
b02da3a
Exetending audio features
Jun 18, 2022
742d98c
Add random generator
KatKlo Jun 18, 2022
1a20fb2
Better menu
KatKlo Jun 18, 2022
de3382e
Add missing files
KatKlo Jun 18, 2022
1e6dc69
Audio pretty much finished
Jun 18, 2022
f1d3e82
better ai
Jun 18, 2022
420fe5c
Fixing bug with double despawn of monsters
Jun 18, 2022
bad074d
Adding shooting timestep
Jun 18, 2022
08b3b5c
Removing it cuz it sucks
Jun 18, 2022
a2c4488
Add input for seed in menu
KatKlo Jun 18, 2022
2489769
Resolving bug with double despawning monsters
Jun 18, 2022
6086f20
Adding timers for powerups
Jun 18, 2022
49d702f
Adding assets
Jun 18, 2022
f7c0f87
Merging changes
Jun 18, 2022
c88f506
Add basic levels
KatKlo Jun 19, 2022
1e346ab
Merge changes
KatKlo Jun 19, 2022
c4d618f
Delete unused imports
KatKlo Jun 19, 2022
154fcdc
Better map generating
KatKlo Jun 19, 2022
9235489
Better spawning objects with components
KatKlo Jun 19, 2022
5436742
Add sensor colliders and fix problems with bullets and powerups
KatKlo Jun 19, 2022
3d0bbb0
Cleaner way of taking player from query
KatKlo Jun 19, 2022
22e0eb5
small fix in player's collider
KatKlo Jun 19, 2022
86e2932
Menu + sensors + refactor
KatKlo Jun 19, 2022
ac53128
Merging changes
Jun 19, 2022
285629c
Refactoring with rustfm
Jun 19, 2022
15d88d1
Better ai
Jun 19, 2022
99f2605
Player cant jump using bullets
Jun 19, 2022
0f4762a
Add images in win/fail menu
KatKlo Jun 19, 2022
2f201d3
Add difficulty and few images
KatKlo Jun 19, 2022
6cc72f2
Proper jumping reset
Jun 19, 2022
350b543
Refactoring events
Jun 19, 2022
f913617
Moving powerups functionalities to its own plugin
Jun 19, 2022
e2ad785
Handling death event
Jun 19, 2022
71793a8
Increasing jump impulse
Jun 19, 2022
0438c1c
Improving performance of ai by avoiding iterating over all enemies
Jun 19, 2022
3941b06
Deleting redundant comment
Jun 19, 2022
e180d88
Merge branch 'kasia' into patryk
Jun 19, 2022
3a06087
Merging branches
Jun 19, 2022
5569af3
Monster doesnt collide with powerups
Jun 19, 2022
89a9b6b
Renaming
Jun 19, 2022
ebca2f4
Enhancing performance by avoiding iterating over bullets
Jun 19, 2022
9b6e602
Pleasing clippy...
Jun 19, 2022
c73de5d
Adding valgrind
Jun 19, 2022
cf37120
Improving toml
Jun 19, 2022
1fa3970
Valgrinds shoot properly
Jun 20, 2022
96b6b70
Try to add audio trait but fails cuz of build-in events lifetimes
Jun 20, 2022
df7c20e
Previous audio
Jun 20, 2022
f271749
Before deleting livingbeing module
Jun 20, 2022
7d74257
Deleting livingbeing module
Jun 20, 2022
2e65fe1
Making bullets module seperate plugin
Jun 20, 2022
b79b719
Add finish line as wall and insert enemy type based on level
KatKlo Jun 20, 2022
6d1958d
Pleasing clippy
Jun 20, 2022
595c98c
Merge branch 'kasia' into patryk
Jun 20, 2022
8a23c4a
Adding com
PBundyra Jun 21, 2022
4aedda0
Deleting redundant functions
Jun 21, 2022
d34979e
Merge branch 'patryk' of github.com:mimuw-jnp2-rust/project-katklo-pb…
Jun 21, 2022
2b40988
Improving style
Jun 21, 2022
a29980f
Merge pull request #9 from mimuw-jnp2-rust/part-2
PBundyra Jun 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
Cargo.lock
/target
29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "mario_mim"
version = "0.1.0"
authors = [
"Katarzyna Kloc <[email protected]>",
"Patryk Bundyra <[email protected]>",
]
edition = "2021"

[dependencies]
bevy = { version = "0.7", features = [
"render",
"animation",
"bevy_winit",
"bevy_gilrs",
"png",
"hdr",
"filesystem_watcher",
"x11"
] }
bevy_rapier2d = "0.13"
bevy_kira_audio = { version = "0.9", features = ["ogg", ] }
rand = "0.8"
rand_pcg = "0.3"
rand_seeder = "0.2"
wasm-bindgen = "0.2"

[profile.dev.package.bevy_rapier2d]
opt-level = 3
63 changes: 48 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
# Frobnicator
# Placeholder na chadowy tytuł

## Autorzy
- Andrzej Głuszak (gr 9, @agluszak na githubie)
- Linus Torvalds (Uniwersytet Helsiński, @torvalds na githubie)
[Katarzyna Kloc](https://github.com/KatKlo) - [email protected]\
[Patryk Bundyra](https://github.com/PBundyra) - [email protected]

## Opis
Od zawsze chcieliśmy napisać grę komputerową.
Frobnicator będzie to gra platformowa, w której chodzi o to, żeby...
Odkąd CLion wypluł pierwsze segfaulty chcieliśmy napisać grę komputerową inspirowaną studencką przygodą na MIMie.\
GigaChadTytuł będzie to gra platformowa, w której chodzi o to, żeby… zdać. Chcemy stworzyć grę inspirowaną Super Mario Bros, ale w mimowskim wydaniu. Student będzie musiał pokonać bugi, wzmonić się pijąc kawę i kto wie, może nawet stawi czoła niektórym prowadzącym...

Z grubsza będziemy wzorować się na [tym tutorialu](https://dev.to/sbelzile/rust-platformer-part-1-bevy-and-ecs-2pci).
Z grubsza będziemy wzorować się na [tym tutorialu](https://dev.to/sbelzile/rust-platformer-part-1-bevy-and-ecs-2pci) oraz [oficjalnych przykładach uzycia](https://github.com/bevyengine/bevy/tree/latest/examples)

## Funkcjonalność
- Generowanie map
- Strzelanie
- AI dla wrogów (bardziej rozbudowane niż w tutorialu)
- Możliwość zapisywania i wczytywania stanu gry
- Punktacja
## Funkcjonalności
- generowanie losowych map
- ruch gracza po mapie z przeszkodami
- pokonywanie łatwych przeciwników
- zbieranie wzmocnień (np. szybszy ruch/dalszy skok)
- walka z finałowym bossem
- checkpointy

## Propozycja podziału na części
W pierwszej części stworzymy grę opartą na tutorialu (z lepszym AI) i jedną zahardcodowaną planszą.
W pierwszej części stworzymy grę opartą na tutorialu z podstawowymi funkcjonalnościami takimi jak:
- generowanie mapy
- generowanie przeciwnikow
- interakcja z przeciwnikami
- wzmocnienia
- menu początowe

W drugiej części dodamy do tego losowy generator map, zapisywanie/wczytywanie stanu gry oraz system punktacji.
W drugiej części dodamy:
- nowy rodzaj łatwych przeciwników
- finałowego bossa
- podział na poziomu na checkpointy z rosnącym poziomem trudności
- menu końcowe
- efekty dzwiękowe
- zdeployujemy grę używając WebAssembly
- parę easter eggów ;)

## Biblioteki
- Bevy
- może coś do serializacji danych? (czy mógłby Pan coś polecić?)

## Update po 1 części

Robiąc pierwszą część korzystaliśmy głównie z tych tutoriali:

- https://dev.to/sbelzile/rust-platformer-part-1-bevy-and-ecs-2pci
- https://www.youtube.com/watch?v=j7qHwb7geIM&ab_channel=JeremyChone
- https://www.youtube.com/watch?v=Yb3vInxzKGE&list=PL7r-PXl6ZPcCB_9zZFU0krBoGK3y5f5Vt&index=5&ab_channel=JeremyChone

oraz z dokumentacji i przykładów do Bevy oraz Rapiera.

Choć dużą część kodu wzieliśmy z ww. poradników, to używając najnowszej wersji Bevy musieliśmy przekształcić znaczną ilość kodu. Bardzo miło nam przyznać, że wywiązaliśmy się z wszystkich naszych zapowiedzi i zaimplementowaliśmy wszystkie przewidziane feature’y czyli:
- generowanie mapy
- generowanie przeciwnikow
- interakcja z przeciwnikami
- wzmocnienia
- menu początowe

Widzimy też pole na poprawę i rzeczy które chcemy dodać w kolejnej części projektu. Są to m. in. timery i fizykę wzmocnień (bardzo uciążliwe, bo rapier nie posiada akutalnej dokumentacji), czy dodanie własnych eventów i obsługa pewnych akcji w grze właśnie przez customowe eventy. Duża częśc logiki gry polega na losowaniu. To gdzie zostanie umieszczony przeciwnik, kiedy skoczy, jakie dostaniemy wzmocnienie jest oparte na z góry zadanym prawdopobieństwu. Korzystając z komponentów pogrupowaliśmy odpowiednie struktury, takie jak Enemy, albo Powerup, dzięki czemu zapewniliśmy skalowalność rozwiązania i zostawiliśmy sobie furtkę na dodanie kolejnych przeciwników i wzmocnień. Mimo, że żeby zapewnić rozgrywkę na wysokim poziomie potrzeba jeszcze dużo pracy, to gra jest obecnie w niezłym stanie, można w nią sensownie pograć i mieć odrobinę frajdy - gwarantujemy jej zwiększenie w kolejnej części :)


Binary file added assets/audio/background.ogg
Binary file not shown.
Binary file added assets/audio/death.ogg
Binary file not shown.
Binary file added assets/audio/drink1.ogg
Binary file not shown.
Binary file added assets/audio/drink2.ogg
Binary file not shown.
Binary file added assets/audio/drink3.ogg
Binary file not shown.
Binary file added assets/audio/fast_shoot.ogg
Binary file not shown.
Binary file added assets/audio/hit1.ogg
Binary file not shown.
Binary file added assets/audio/hit2.ogg
Binary file not shown.
Binary file added assets/audio/hit3.ogg
Binary file not shown.
Binary file added assets/audio/levelup.ogg
Binary file not shown.
Binary file added assets/audio/menu.ogg
Binary file not shown.
Binary file added assets/audio/shear.ogg
Binary file not shown.
Binary file added assets/audio/shoot.ogg
Binary file not shown.
Binary file added assets/fonts/FiraSans-LightItalic.ttf
Binary file not shown.
Binary file added assets/images/bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cobblestone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/enemy_bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/finish_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/floor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/rust.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/strong_bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/valgrind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/weak_bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/wojownik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/negative8.png
Binary file added assets/menu/negative9.png
Binary file added assets/menu/neutral1.png
Binary file added assets/menu/play.png
Binary file added assets/menu/positive1.png
Binary file added assets/menu/positive2.png
Binary file added assets/menu/positive3.png
Binary file added assets/menu/positive4.png
Binary file added assets/menu/positive5.png
Binary file added assets/menu/positive6.png
Binary file added assets/menu/positive7.png
Binary file added assets/menu/positive8.png
Binary file added assets/menu/positive9.png
Binary file added assets/menu/retry.png
154 changes: 154 additions & 0 deletions src/game/audio.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
use bevy::prelude::*;
use bevy_kira_audio::{Audio, AudioChannel, AudioPlugin, AudioSource};
use rand::{thread_rng, Rng};

use crate::AppState;

pub struct GameAudioPlugin;

pub struct AudioHitEvent;
pub struct AudioCoffeeEvent;
pub struct AudioRustEvent;
pub struct AudioFastShootEvent;
pub struct AudioShootEvent;
pub struct AudioDeadPlayerEvent;

pub struct AudioAssets {
bg: Handle<AudioSource>,
menu: Handle<AudioSource>,
hit1: Handle<AudioSource>,
hit2: Handle<AudioSource>,
hit3: Handle<AudioSource>,
death: Handle<AudioSource>,
drink1: Handle<AudioSource>,
drink2: Handle<AudioSource>,
drink3: Handle<AudioSource>,
shoot: Handle<AudioSource>,
fast_shoot: Handle<AudioSource>,
lvlup: Handle<AudioSource>,
bg_channel: AudioChannel,
menu_channel: AudioChannel,
}

impl Plugin for GameAudioPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(AudioPlugin)
.add_startup_system_to_stage(StartupStage::PreStartup, load_audio)
.add_system_set(SystemSet::on_enter(AppState::InGame).with_system(play_bg_music))
.add_system_set(SystemSet::on_exit(AppState::InGame).with_system(play_menu_music))
.add_system(play_hit_sfx)
.add_system(play_death_sfx)
.add_system(play_eat_sfx)
.add_system(play_lvlup_sfx)
.add_system(play_shoot_sfx)
.add_system(play_fast_shoot_sfx)
.add_startup_system(play_menu_music)
.add_event::<AudioRustEvent>()
.add_event::<AudioCoffeeEvent>()
.add_event::<AudioHitEvent>()
.add_event::<AudioFastShootEvent>()
.add_event::<AudioShootEvent>()
.add_event::<AudioDeadPlayerEvent>();
}
}

pub fn play_hit_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut audio_event: EventReader<AudioHitEvent>,
) {
audio_event.iter().for_each(|_| {
let mut rng = thread_rng();
match rng.gen_range(0..100) {
// 1/3 chance of playing each sound
0..=33 => audio.play(audio_state.hit1.clone()),
34..=67 => audio.play(audio_state.hit2.clone()),
_ => audio.play(audio_state.hit3.clone()),
};
});
}

pub fn play_eat_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut audio_event: EventReader<AudioCoffeeEvent>,
) {
audio_event.iter().for_each(|_| {
let mut rng = thread_rng();
match rng.gen_range(0..100) {
// 1/3 chance of playing each sound
0..=33 => audio.play(audio_state.drink1.clone()),
34..=67 => audio.play(audio_state.drink2.clone()),
_ => audio.play(audio_state.drink3.clone()),
};
});
}

pub fn play_lvlup_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut audio_event: EventReader<AudioRustEvent>,
) {
audio_event.iter().for_each(|_| {
audio.play(audio_state.lvlup.clone());
});
}

pub fn play_shoot_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut audio_event: EventReader<AudioShootEvent>,
) {
audio_event.iter().for_each(|_| {
audio.play(audio_state.shoot.clone());
});
}

pub fn play_fast_shoot_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut audio_event: EventReader<AudioFastShootEvent>,
) {
audio_event.iter().for_each(|_| {
audio.play(audio_state.fast_shoot.clone());
});
}

pub fn play_death_sfx(
audio: Res<Audio>,
audio_state: Res<AudioAssets>,
mut death_events: EventReader<AudioDeadPlayerEvent>,
) {
for _ in death_events.iter() {
audio.play(audio_state.death.clone());
}
}

fn play_bg_music(audio: Res<Audio>, audio_state: Res<AudioAssets>) {
audio.stop_channel(&audio_state.menu_channel);
audio.play_looped_in_channel(audio_state.bg.clone(), &audio_state.bg_channel);
}

fn play_menu_music(audio: Res<Audio>, audio_state: Res<AudioAssets>) {
audio.stop_channel(&audio_state.bg_channel);
audio.play_looped_in_channel(audio_state.menu.clone(), &audio_state.menu_channel);
}

fn load_audio(mut commands: Commands, assets: Res<AssetServer>) {
commands.insert_resource(AudioAssets {
bg: assets.load("audio/background.ogg"),
menu: assets.load("audio/menu.ogg"),
hit1: assets.load("audio/hit1.ogg"),
hit2: assets.load("audio/hit2.ogg"),
hit3: assets.load("audio/hit3.ogg"),
death: assets.load("audio/death.ogg"),
drink1: assets.load("audio/drink1.ogg"),
drink2: assets.load("audio/drink2.ogg"),
drink3: assets.load("audio/drink3.ogg"),
shoot: assets.load("audio/shoot.ogg"),
fast_shoot: assets.load("audio/fast_shoot.ogg"),
lvlup: assets.load("audio/levelup.ogg"),
bg_channel: AudioChannel::new("bg".to_string()),
menu_channel: AudioChannel::new("menu".to_string()),
});
}
Loading