From 63ff343e97e935dcfb6a3e216fbc52462c0d3eac Mon Sep 17 00:00:00 2001 From: Mikeymoo5 Date: Sat, 8 Feb 2025 11:42:31 -0600 Subject: [PATCH 1/2] VirtualPet --- pets/VirtualPet/cat-Sheet.bmp | Bin 0 -> 12342 bytes pets/VirtualPet/cat-Sheet.png | Bin 0 -> 517 bytes pets/VirtualPet/fireball.bmp | Bin 0 -> 3126 bytes pets/VirtualPet/forestbackground.bmp | Bin 0 -> 49206 bytes pets/VirtualPet/forestbackground.png | Bin 0 -> 455 bytes pets/VirtualPet/main.py | 160 +++++++++++++++++++++++++++ pets/VirtualPet/restart.bmp | Bin 0 -> 65674 bytes 7 files changed, 160 insertions(+) create mode 100644 pets/VirtualPet/cat-Sheet.bmp create mode 100644 pets/VirtualPet/cat-Sheet.png create mode 100644 pets/VirtualPet/fireball.bmp create mode 100644 pets/VirtualPet/forestbackground.bmp create mode 100644 pets/VirtualPet/forestbackground.png create mode 100644 pets/VirtualPet/main.py create mode 100644 pets/VirtualPet/restart.bmp diff --git a/pets/VirtualPet/cat-Sheet.bmp b/pets/VirtualPet/cat-Sheet.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9aaccb343b51c9c9779ddb25cd806d7adb8adfe9 GIT binary patch literal 12342 zcmeH~F>b>!3`NtqTc?g4J7&rOx_9V}iXJ5wO$aMyOzMj!WeIRn32{JEzA$%x?T?N^iGTR-(J&|661ZJ4xBFs|EuB%emGTDtcT`@#H(VDSE?m+ z`}F*f8?e~62)2ZhPs|VbU=)`uGFn1gd*c879PJnQOJ1v=2La~Nz*_zamPf?-tUM3E zP&c1wpq+J20jP2F8J=X9ZaIGo;(SezN6@o5c&DI-`T{Cj$c=e3s`Kl&s?xh`;a74(P5qpI1^w$bbW~cF~gU zswtw_!58&wa5W3!bSmvP&opkW2B{V`5`}kUw{~$iTkmQF`C0rqb zUHlLD_2v)%?GI1MANo+OHaZL7=X3Dcz25$m9x)5p9>61P$1-8?*$Nm8f1oX#9R9Es zFc|(oTR8bR{@`Cq?ew?e6DLRIncI($i2fpEdYX8*5uf0_`S?Gni2g*#br!{wZ*cLq zV-Z-87XBxGE}nm^;;nZ2d5{R)e9^V=jq+G|s&Vss`(x<0w%qzHh_p*o?uKtYMB@?f zM!#^?FkEd7{mKw^`_TSC@sw0&+;R&?Yyqm?u6zh@^>gU1JGL*f}@A& z0?=Dm2th0hz(88Im9?F7$N((cx<5EgVEI>;v_Hrgyzfu24^#l&_vhg`C#gZGanF1y zAGJx44gqu=AVOaPAaG8DRQ|H9Vm`uoQxo00?^vl8f_7-WFk*aVzHI_0mjz&QSpX)N zdH{%b=8P}Ij{}h0fGB?NR@nd<|ETH;fGH}N#uMlg&>DhX$8u?O|0RL<0F)4fidjnm zBXFq$dG!gXN!tG}rZJ?#78~ZOT$L(s&|_Qql9fd%K|GTxfng%zlc!!w0?WH#@r_Um zAKJ%KTMC~VzSMDNep4x!@@XGA06~zIC^sHdJ~jlo_N)P*=o`@{iZPd;^o~`00000NkvXX Hu0mjf8Ybmb literal 0 HcmV?d00001 diff --git a/pets/VirtualPet/fireball.bmp b/pets/VirtualPet/fireball.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8d40d351e48e988b0ef99192bdf43b277353c35a GIT binary patch literal 3126 zcmeH@F%H5|3`5Hd6B8pNbB7*)ottto&i W^;u6*X{mp0L~7n##FWj1-Gd(^jlwK%LhvM+fI( sprite2.x and + sprite1.y < sprite2.y + 32 and + sprite1.y + 32 > sprite2.y + ) + +death = displayio.OnDiskBitmap("restart.bmp") + +def display_game_over(): + global death_hi + death_hi = displayio.TileGrid( + death, + pixel_shader=cat_sheet.pixel_shader, + width=1, + height=1, + tile_width=128, + tile_height=128, + default_tile=0, + x=0, + y=0 + ) + splash.append(death_hi) + for i in fireballs: + splash.remove(i) + fireballs.clear() + +def main(): + clock = pygame.time.Clock() + delta = 0 + + frame = 0 + + hunger = 0 + main_menu = 0 + + feeding = False + + frame_change = 0.25 + + run = True + + while run: + delta = clock.tick(15) / 1000 + + frame_change -= delta + + if frame_change <= 0: + frame_change += 0.25 + frame = (frame + 1) % 4 + cat_sprite[0] = frame + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT: + if not feeding: + main_menu = max(-1, main_menu - 1) + else: + if cat_sprite.x == 64 - 16: + cat_sprite.x = 0 + else: + cat_sprite.x = 64 - 16 + if event.key == pygame.K_RIGHT: + if not feeding: + main_menu = min(+1, main_menu + 1) + else: + if cat_sprite.x == 0: + cat_sprite.x = 64 - 16 + else: + cat_sprite.x = 128 - 32 + if event.key == pygame.K_UP: + match main_menu: + case -1: + pass + case 0: + feeding = not feeding + + if not feeding: + cat_sprite.x = 64 - tile_width // 2 + case 1: + pass + + if not feeding and random.random() < 1.0e-4: + hunger = min(3, hunger + 1) + + # clear screen + for el in splash: + splash.remove(el) + + # draw background + match main_menu: + case -1: + pass + case 0: + splash.append(bg_sprite) + case 1: + pass + + # draw 'cat' + splash.append(cat_sprite) + + pygame.quit() + +main() \ No newline at end of file diff --git a/pets/VirtualPet/restart.bmp b/pets/VirtualPet/restart.bmp new file mode 100644 index 0000000000000000000000000000000000000000..66d4859a8ba809a1ed4f90be9534dcf2dcc56ff0 GIT binary patch literal 65674 zcmeI0yKY=J5QdLn!$8soF47pO0@qRPMvW^MaqU_!;5J2?G-_1qP245$OXML^r4BswAafp^Iz|5_}(xZ7=Qs7fB_hQ0T_S*7=Qs7fB_hQ0T_S*7=Qs7 zfPowX{C)qpY-skfIYzwBN9FN)@7{GZ4{LkYtUNt)pk4NRrdh zpzmUAd-hJbdgefTe)e&XG?!rGJI}rHcxs}xeBPJp8S~%Hta>m~Gk?XTY>zjlG;QwG zJ!fTHtB)o9lJA@?(Q5Tcy`fdpJAO-VEUDerlk%UtPsOyJ*_>LpYL>(+SBovl)7wYy zFUcd{U~~Q@KDpSIbDQ_v`#f{RIa7O^Z|>guj#}$YrTI$yOMFW6E%ob_Te{XReVg@{ zjy=1?dg(h#{N)qu=$brpTP>}<>PhLP&b;#Fbe86nzpR&TPN(KvZwt02KEzlJt!uSP z<3{DN@2SbD7+I^QweEt|*+|=(U-6fC^Hy@IN4Xj6eq=p1S4)1y%39rC>yf!sLu*dO z2P;ik-D%%yrB`E@=02BWsaC1Ka+dmg_<7`%MzHoxxpV8YWNr19u9xHqzS6gAoyjiM zob&IcdoHh6PU+{Gj!W^H^;oM%pHrE5-Al7JeywrdbxAL_p7mSpoUVLw_e;;c^_J%E<=?X|XnX|dLy`HD~;90BmYcyM8<9yO8 zv2pAX_Nl&j)Ggf_t(Mr3Pw}zMy~XVwru_08U=)~T4eGpjS_o4U90VV&|h!r5FObbqcF@{x^wbslVdSF`uj^VF)TWi2te zKIpvUo${3}iK+3Cey}z1ag4WKtiP3gst-CVsX@N7B{6I9(VK%^%bPCo4%-L2zQkKb z=R8`yx&GQdXr1%j+xgMzJvTq~LiU{RUha-m>)g!L3v1_MwtlZ#w_bfYkpz28hPrbDqG^TYg)J^z>o_V54$FaQHE00S@p126ysFaQHE h00S@p126ysFaQHE00S@p126ysFaQHE00ZL~_yXWkA-@0s literal 0 HcmV?d00001 From 68efddf4f0c8bb889c0c136eeddb25c3a26fd3b2 Mon Sep 17 00:00:00 2001 From: Mikeymoo5 Date: Sat, 15 Feb 2025 13:56:44 -0600 Subject: [PATCH 2/2] final commit --- pets/VirtualPet/bomb.png | Bin 0 -> 223 bytes pets/VirtualPet/cat-Sheet.png | Bin 517 -> 1018 bytes pets/VirtualPet/forestbackgroundcenter.png | Bin 0 -> 955 bytes pets/VirtualPet/forestbackgroundleft.png | Bin 0 -> 936 bytes pets/VirtualPet/forestbackgroundright.png | Bin 0 -> 589 bytes pets/VirtualPet/fruit.png | Bin 0 -> 290 bytes pets/VirtualPet/main.py | 236 +++++++++++++++------ pets/VirtualPet/numbers.png | Bin 0 -> 365 bytes 8 files changed, 173 insertions(+), 63 deletions(-) create mode 100644 pets/VirtualPet/bomb.png create mode 100644 pets/VirtualPet/forestbackgroundcenter.png create mode 100644 pets/VirtualPet/forestbackgroundleft.png create mode 100644 pets/VirtualPet/forestbackgroundright.png create mode 100644 pets/VirtualPet/fruit.png create mode 100644 pets/VirtualPet/numbers.png diff --git a/pets/VirtualPet/bomb.png b/pets/VirtualPet/bomb.png new file mode 100644 index 0000000000000000000000000000000000000000..1fb7279d7496fbbdb0957e29c0b0f4c222c9db9d GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJWu7jMArY-_r+M==DDb$f{%G{h zVq$y2_0JU-b`>TwcuNY1oUu8*-o=4~U68LSBj?1EZ2S550@rR-V$eOr*v70Q zTD&DT|I!woZF1X{-cEA7V0qofgyBle*Ppjqu0A`%lg)W+hUM44_6WDYRO9LPU($NH`|_r&{KBo(sew=TKS3j3^P6001Be1^@s6m49>f000BQNkl1 zF>d295F7?Bu5@!i+5qPw5AYWZ_z~v^nBohu0#FCd>&T^<-iLye67Jxz==Cmmlwe$C(UD)0mqmAPzG@wfdMfI0k0JZZc zeVotdMIAIv;~nQs@9FIk2n%ehZP!N3q^>Q1>iJVXmWmGmbRX<^djaBd44H&3_?P42 zfsH!OEr8njJ3iJBpMg(=H|_~55Tid);+X}|JE)vLRu-QDC&JC(=yC+^p5P6%EP1qV zk5Ic4ISJw`zjppY;xjm(&!d{qd}!O}zrfv7SWlND)Zx3`eknTt!1Nfj07U%P%O4OH zpN*zz06q4P6dW4-Slbwc^qbRn31g7)olJbdFddI-Kmbs?6Y%3Fdn|$y1fWqF|D@tG zFe1DGQ(P;hyvGrDZP7?9fZF+I1$hN*-yR1AuY0^QiW5NX{8M5xZIT}Dge188D+)F7 z_X<$$P5{1k0DP#C|NZ@aklpL+D`{`ePxWQ&SOJ>go6k8WA*TRpID=xwI!ZTElsKKe=rNbGHlgaJ>*-@Re*w#~f&fcUH7 zoOXN-_48|4J#n|7_SyC;-xdHs31Bn?Vp!AyU~K_W{vUhqFVChw<=RT| z@8>}CGkkLFgaF;1Fn1N2{WgXjl!)LD{E9Dt>n-PhFpkm575M|8#*l0Qm?p@y6$f+z zT>UPXsC58$qKTTum;-cb2pN-`7OCK~^;V>>&~}lvnmB*kPYFo96Vlg1lZKK4Fexq% zlqE1$2$>eZ0Q$A5QHnO_4Y=>kdE4H#6%`}R!q|2x1*p{ikW739kD*GqY1<%m4OqgYmoSD;0j>s& zZRbnhoB;W!^MUx}>92PFq*x@{O$BJyB&-zt5(H2K|Iu?mDqY$(++8r&&UZJxx&W;Q zv1_dUoC28T{}b{r^Fg!?V#{X)vo&Pxa%4fsSS9-W%KRk}d=ui?J_Ce*n^1xPYUeM7 oB7YM?A*TRJfFytJ5lIUC2Z~h@p;psCz5oCK07*qoM6N<$f?#^o&j0`b literal 517 zcmV+g0{Z=lP)^>gU1JGL*f}@A& z0?=Dm2th0hz(88Im9?F7$N((cx<5EgVEI>;v_Hrgyzfu24^#l&_vhg`C#gZGanF1y zAGJx44gqu=AVOaPAaG8DRQ|H9Vm`uoQxo00?^vl8f_7-WFk*aVzHI_0mjz&QSpX)N zdH{%b=8P}Ij{}h0fGB?NR@nd<|ETH;fGH}N#uMlg&>DhX$8u?O|0RL<0F)4fidjnm zBXFq$dG!gXN!tG}rZJ?#78~ZOT$L(s&|_Qql9fd%K|GTxfng%zlc!!w0?WH#@r_Um zAKJ%KTMC~VzSMDNep4x!@@XGA06~zIC^sHdJ~jlo_N)P*=o`@{iZPd;^o~`00000NkvXX Hu0mjf8Ybmb diff --git a/pets/VirtualPet/forestbackgroundcenter.png b/pets/VirtualPet/forestbackgroundcenter.png new file mode 100644 index 0000000000000000000000000000000000000000..b053ac30235f05a004c23dff1820b6c75c2b3215 GIT binary patch literal 955 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU~cksaSW-L^Y-q-An8Dc)`ye* zk5k-Sq=5M?!Jj^HO zl$l#MZkS#DFMnB6PX6Y%f4`?Wzq=4seWfC_Z~AeK_ZzCr$_&L&B|EFG-d}Ds?=Qm*C8%P!^k0T& zk0Tk8i~-3sus%NcX1ee<=0EcF^-?Qu&bBp^^LQKh*m?f`H9+H|=GAy+eM{@NRA}JQ z6THD*P%rgzk!o-I>f^Kaet6IMDs{fY%wxV~Mz>+j4Lj`;Tbitq9C*q^R4^Z#79`}XRe*M25*>*E)^ z_H+@t&O{^U~y5wJVKhi2W-u*m5#n#QnqPoU*_x*L`d5 zeNyy1ym7^XB`` zlOMaI_upFF7ALoOsjvLW+51+_t-tjCq364grJtkv)jzo1y~23EdizfQ1;_s!4xL<9 z`u@}0f4jIp6m8nmbX-{e{Odn*39%eEa!+>lug&4|ZBuxAEZgQ%s&9=>ad?5up?PJ` z+c;KV+uOqacdo-4NJ`rAn^7V@!$upPw&2O-zy5(5EaL0RE}r^t*~lS{MGJBog_}bI b!FTd1{k<2t8hzIQGbMwktDnm{r-UW|@`kVW literal 0 HcmV?d00001 diff --git a/pets/VirtualPet/forestbackgroundleft.png b/pets/VirtualPet/forestbackgroundleft.png new file mode 100644 index 0000000000000000000000000000000000000000..043ecee20516aee49391d451114f978b0b33c0bc GIT binary patch literal 936 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrV9xh+aSW-L^Y*T7(PamT_K(+l z_!IIRPV=~4iezP7%3a-dOjg%e(?>tv!B$g4^U}`5V_HQFTuX~j8lK=?kZ^5{Nao*( z6*~L>KM!|YV%k<4QM+Kq!4%V9$(;M^?UtF{e*Jy%ld@yqtN*Ni61Kyg;Sq;}3}c5f zLm`VoAHxye-*t0O{kYth&MJUas$w4d0ZzdN3npY~8-4}5d7{Y1fK{k}w>fY)x2Syf znpf+uZ~y-P(&P4%Yx`O{&wsYr8E>e6=1nF?oF~hNg6R1_bWTToU%e`8H&9qbsi2-u zz`t%<>eiF<&!(Bp_1kXWzx{b--uKU6KD}&w&G7Dd|JIY{n{Tzuo;fvj=ikB`V(uGW z&v|%hC+~vnPmekCwN3}=F->RO;=6CAs`~z1`Bsh?Hh~h|-@h}~vBd4HmrJ<5>AtEA z-=mGW@0Y&cU%&G?4!{Hr#4`w9)*Nj_yUgaIjvNLI$ z)#IbrUr(=4fBw*_A@=zHTD4!6&jqF*_^QaTTd-kA>0xz5IS|HY`K#7v6kx}PNgzTzIvkT(f!G` zA6edQ7CQ2~Wn=8={p@gxecS8v@6)?e)5^o=-oDG0a81_HV6I=bW5w)0 z5#b!`m<^1j_1B0w)_7=~-X!L-XRk($o$w8wgJ0(!Q0P-Q|M^L0?2Y$9YX6^op1t^3 zD+k--R@L{+bADTWU3&ceFZH|6Cf(ou{r;D)w~s&h7C+nf_4WI4@v~>1;1aO@B5nWc z-R0fyPrg0v`*(-D+P~9h`Hh8n972m9F*6mc%Z8EPr#E_lQ;*-f&x{iB$GJes2qlFS z|NqI*BmTRFL8c8&M*4~TrTgLx_ahilb-+?1iZL`2tY`dEb?Sy++T<2s4rK6j^>bP0 Hl+XkK{GpfM literal 0 HcmV?d00001 diff --git a/pets/VirtualPet/forestbackgroundright.png b/pets/VirtualPet/forestbackgroundright.png new file mode 100644 index 0000000000000000000000000000000000000000..85e8e3415bf510faaedeeed940b3a288a780e2b0 GIT binary patch literal 589 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU=s0kaSW-L^Y)IRUr3-x!^7s8 ztOxiqe05S7MW*Q;I@FdTReiT(DeK(c?is8J>96?`*dusZPb?NpoAdv-mtOj(N#CE_ z-Fwou`1}3-{PcrgpQUA1`km_+zkc@p_dlzThVsp0c*G*0-eAFagj2zfp>TC=y}#-I zJ)g_qB1|2^4s#eDh5i0FFY8_Z+xqrb@;Y;S@$2P(=VjMb)_r|=cKghkJLmKpe>Q0G ze=XlFZ!r65>bKi>?=$$f9!RYEAXZ@CB6ZV?#1WbJMVsV-C&IoR&X_F=0L+3*=TZv{xRh1@HCxf Swg#pT1_n=8KbLh*2~7ZH*65!A literal 0 HcmV?d00001 diff --git a/pets/VirtualPet/fruit.png b/pets/VirtualPet/fruit.png new file mode 100644 index 0000000000000000000000000000000000000000..15e0b2f4f05d8dd6061ccbe62966c97075c21078 GIT binary patch literal 290 zcmV+-0p0$IP);S96@jZ?&1=}t66+W*oOw+WB=TulBQec)XGZG3JkXc zpilOdHkGaDTY(QwYI+M|7&v?v@hvGT&~V)>h5;0PgeD|0W(I^LrVrsg0EhXw2jDOt zk7z+8YZPzRas&V4LDE;iT5hHP^cMX0ff9fpM(4MH?uC9!>5|~!aZBkV*K&7=mXFB^ o5yHH$*#$%c str: + return ':'.join(str(e).removeprefix('0') if i == 0 else str(e) for i, e in enumerate(time.ctime().split(' ')[3].split(':')[:2])) pygame.init() @@ -10,11 +13,64 @@ splash = displayio.Group() display.show(splash) -forest_background = displayio.OnDiskBitmap("forestbackground.png") -bg_sprite = displayio.TileGrid(forest_background, pixel_shader=forest_background.pixel_shader) -splash.append(bg_sprite) +forest_background_left = displayio.OnDiskBitmap("forestbackgroundleft.png") +forest_background_center = displayio.OnDiskBitmap("forestbackgroundcenter.png") +forest_background_right = displayio.OnDiskBitmap("forestbackgroundright.png") +bg_sprite_left = displayio.TileGrid(forest_background_left, pixel_shader=forest_background_left.pixel_shader) +bg_sprite_center = displayio.TileGrid(forest_background_center, pixel_shader=forest_background_center.pixel_shader) +bg_sprite_right = displayio.TileGrid(forest_background_right, pixel_shader=forest_background_right.pixel_shader) cat_sheet = displayio.OnDiskBitmap("cat-Sheet.png") +numbers_sheet = displayio.OnDiskBitmap("numbers.png") + +fruit = displayio.OnDiskBitmap("fruit.png") +bomb = displayio.OnDiskBitmap("bomb.png") + +def draw_char(char, x, y): + spr = displayio.TileGrid( + numbers_sheet, + pixel_shader=numbers_sheet.pixel_shader, + width=1, + height=1, + tile_width=8, + tile_height=9, + default_tile=0, + x=x, + y=y + ) + + if char == ':': + spr[0] = 10 + else: + spr[0] = int(char) + + return spr + +def new_fruit(x, y): + return displayio.TileGrid( + fruit, + pixel_shader=fruit.pixel_shader, + width=1, + height=1, + tile_width=32, + tile_height=32, + default_tile=0, + x=x, + y=y + ) + +def new_bomb(x, y): + return displayio.TileGrid( + bomb, + pixel_shader=bomb.pixel_shader, + width=1, + height=1, + tile_width=32, + tile_height=32, + default_tile=0, + x=x, + y=y + ) tile_width = 32 tile_height = 32 @@ -31,25 +87,6 @@ y=display.height - tile_height - 24 ) -fireball_bitmap = displayio.OnDiskBitmap("fireball.bmp") - -fireballs = [] - -def spawn_fireball(): - x_position = random.randint(0, display.width - fireball_bitmap.width) - fireball = displayio.TileGrid( - fireball_bitmap, - pixel_shader=fireball_bitmap.pixel_shader, - width=1, - height=1, - tile_width=fireball_bitmap.width, - tile_height=fireball_bitmap.height, - x=x_position, - y=-32 - ) - fireballs.append(fireball) - splash.append(fireball) - # Function to check for collisions def check_collision(sprite1, sprite2): return ( @@ -59,26 +96,6 @@ def check_collision(sprite1, sprite2): sprite1.y + 32 > sprite2.y ) -death = displayio.OnDiskBitmap("restart.bmp") - -def display_game_over(): - global death_hi - death_hi = displayio.TileGrid( - death, - pixel_shader=cat_sheet.pixel_shader, - width=1, - height=1, - tile_width=128, - tile_height=128, - default_tile=0, - x=0, - y=0 - ) - splash.append(death_hi) - for i in fireballs: - splash.remove(i) - fireballs.clear() - def main(): clock = pygame.time.Clock() delta = 0 @@ -90,19 +107,49 @@ def main(): feeding = False - frame_change = 0.25 + dead = False + + frame_change = 0.35 + + direction = 1 + + score = 0 + + last_minute = 0 + + feed_timer = 0 run = True + obs = [] + while run: delta = clock.tick(15) / 1000 + if feeding: + feed_timer -= delta + + if feed_timer <= 0: + feed_timer += 2 + + obs.append([ + random.randint(0, 1), + random.choice([0, 48, 96]), + -32 + ]) + frame_change -= delta if frame_change <= 0: - frame_change += 0.25 - frame = (frame + 1) % 4 + frame_change += 0.35 + frame += direction + if frame in [0, 3]: + direction *= -1 cat_sprite[0] = frame + + + if dead: + cat_sprite[0] = 4 for event in pygame.event.get(): if event.type == pygame.QUIT: @@ -125,36 +172,99 @@ def main(): else: cat_sprite.x = 128 - 32 if event.key == pygame.K_UP: - match main_menu: - case -1: - pass - case 0: - feeding = not feeding - - if not feeding: - cat_sprite.x = 64 - tile_width // 2 - case 1: - pass - - if not feeding and random.random() < 1.0e-4: + if not dead: + match main_menu: + case -1: + pass + case 0: + feeding = not feeding + + if not feeding: + cat_sprite.x = 64 - tile_width // 2 + else: + feed_timer = 0 + obs = [] + + if not hunger: + feeding = False + cat_sprite.x = 64 - tile_width // 2 + + case 1: + pass + else: + dead = False + hunger = 0 + score = 0 + + if not feeding and random.random() < 1.0e-3: + if hunger == 3: + dead = True + hunger = min(3, hunger + 1) # clear screen for el in splash: splash.remove(el) + timestr = get_time() + # draw background match main_menu: case -1: - pass + splash.append(bg_sprite_left) + + x, y = display.width // 2 - 5 * len(timestr), 8 + for c in timestr: + splash.append(draw_char(c, x, y)) + x += 10 case 0: - splash.append(bg_sprite) + splash.append(bg_sprite_center) case 1: - pass + splash.append(bg_sprite_right) + if not dead: + # update score + + minute = int(timestr.split(':')[1]) + if minute != last_minute: + if last_minute != 0: + score += 1 + last_minute = minute + + if feeding: + # draw obstacles + for o in obs[::-1]: + o[2] += delta * 35 + + if o[0]: + splash.append(n := new_fruit(o[1], o[2])) + + if check_collision(cat_sprite, n): + hunger -= 1 + obs.remove(o) + if hunger == 0: + feeding = False + cat_sprite.x = 64 - tile_width // 2 + continue + else: + splash.append(n := new_bomb(o[1], o[2])) + + if check_collision(cat_sprite, n): + feeding = False + cat_sprite.x = 64 - tile_width // 2 + # draw 'cat' splash.append(cat_sprite) - + + # draw score + x, y = 0, 0 + for c in str(score): + splash.append(draw_char(c, x, y)) + x += 10 + + # draw hunger + splash.append(draw_char(str(hunger)[0], 120, 0)) + pygame.quit() main() \ No newline at end of file diff --git a/pets/VirtualPet/numbers.png b/pets/VirtualPet/numbers.png new file mode 100644 index 0000000000000000000000000000000000000000..035671ad3e36270c382b4c8b4e606efc193e982b GIT binary patch literal 365 zcmV-z0h0cSP)37*hg4yu-ycejv1%`0HFSU6_DgW7eiu`- zJk4lR7^`ZA@8FX|ereT=-O7fNyl`^BZFMs%&FK3(GY1A75u46jZ>;z|=8~?#r_;>~{8=g-@Jn4to&a2SiJSg3UyVta& zm;M`vE90MJoJ&(``GX=5Y{^hy9jCiZ`0rlzHo-ydPA^s`8EL%%lp7jFdIRg600000 LNkvXXu0mjfa8snv literal 0 HcmV?d00001