From 3cfa00be14c37a1f06ab88632e5755cf75ae1e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zuzana=20Arnoldov=C3=A1?= Date: Tue, 19 Sep 2023 22:35:46 +0200 Subject: [PATCH] WIP topdown game --- Makefile | 3 +- assets/chicken.png | Bin 0 -> 943 bytes assets/grass.png | Bin 0 -> 292 bytes comfy/examples/ecs_topdown_game.rs | 91 +++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 assets/chicken.png create mode 100644 assets/grass.png create mode 100644 comfy/examples/ecs_topdown_game.rs diff --git a/Makefile b/Makefile index 0fa17a8..ff8920b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ # EXAMPLE=particles # EXAMPLE=post_processing # EXAMPLE=shapes -EXAMPLE=ecs_sprite +# EXAMPLE=ecs_sprite +EXAMPLE=ecs_topdown_game # default: build-examples # default: wasm-build diff --git a/assets/chicken.png b/assets/chicken.png new file mode 100644 index 0000000000000000000000000000000000000000..570a94aa586f67228a256ed762fc69a1e3bdddc6 GIT binary patch literal 943 zcmV;g15o^lP)o*`A_SD;H?A)??4 z174QhWoG{X8_y>pjLmQ68w@)vHUNvoVzF2(7K_DVv2H`Nu??_TEEbEUQ*mCG_3I?v zd+k}MV6Fz3kDDJ`W7RKmF6=FSXDn7NmvdRZ23=#wtTIpyB;0eRr7hd|S8&yPl$!@DUW_4X=myIC zZSvm7pFF$9soqcSKWxXJPW~SqSXLbj0E*KbAkX>-?>xJ5G4i6u;3w)oN%#8wF!>G5 z9mV(fH^c=v92?$>t(uT=-@5r~IPvoke8n{lR9yERdsPhGHuKD5H~?@Tf9e?6=10um zYJg3rU#!~Q6KSBO2zl4~$3A|c{WpX0;b@(|XNK$N_^D>DzklL+S^xf$5hu=)pF#uu z?)+w%qHf}D(SNY+O^5wYJknox&#;l;*>Qq9sr!`cjc$kD1ngp7nqKj(kTB4VW_XjfwAT049F3Ov{(u=V-k%vZA;+dKM6_;=WEC>{W=k9@?1 z!cyM1;8o2lIA3Y|^vn3UlFu{PKD@*0+j*wV8#2EuKcs(+V!3`B6_0nNxTZ?vZDPng zHHOdpRMwRjYaSziXdV-D%KoR$7pHkCFD@)428Q1((^B^+Efl|5rl=ZpET;BQ`D60m z#EJO&=|Hy4N8F|i=C(zL%5PJ@n9p}T)cu)fp2`=GcbCCWcL0V>Ht7+PhBrRC49H{u_@T{DmFN7?`3JxKV+@|fVzF2(7K_DVu~^?t{{i()ZNo|_ R;%oo_002ovPDHLkV1kD+*jfMp literal 0 HcmV?d00001 diff --git a/assets/grass.png b/assets/grass.png new file mode 100644 index 0000000000000000000000000000000000000000..610e4e8c4f4923a1ad3ddc95bcb8b3e235411eaf GIT binary patch literal 292 zcmV+<0o(qGP)66Faq{ak~HKluqEO{?gBLrMbH9TH^30U1++T; z#y|@=0xAJ5N`gv&R1%V))bsN~r1t`PGpqn@zZh14b_<0NP>Pm|zrj+pw2`!4sY3|Z qLheJgqL%aM1k^qr(+Q}JdjUT`&p&-@1Vxzu0000() + .iter() + { + // Handle movement and animation + let mut moved = false; + let speed = 1.0; + + if is_key_down(KeyCode::W) { + transform.position.y += speed * dt; + moved = true; + } + if is_key_down(KeyCode::S) { + transform.position.y -= speed * dt; + moved = true; + } + if is_key_down(KeyCode::A) { + transform.position.x -= speed * dt; + moved = true; + } + if is_key_down(KeyCode::D) { + transform.position.x += speed * dt; + moved = true; + } + + main_camera_mut().center = transform.position; + } +}