clear_the_bugs.py

Created by mathieu-croslacoste

Created on September 15, 2025

2.34 KB

Casio script ported to numworks


from kandinsky import fill_rect as F,set_pixel as S,draw_string as D
from time import*;from random import*
from ion import keydown as K
start=monotonic()
player="""       ##       
      #cc#      
     #c##c#     
    #c#  #c#    
 #c# ##  ## #c# 
#c# # #  # # #c#
#c# ######## #c#
#c#          #c#
#c#          #c#
#c            c#
#aa   a   a  ac#
#a a a a a  a a#
#a a aaa  a aaa#
#a a a a a  a a#
#cccccccccccccc#
 ############## """
C={"a":(255,0,0),"b":(0,255,0),"c":(0,0,255),
"d":(100,)*3,"e":(255,127,68),"f":(255,68,127),
"1":(127,255,68),"2":(127,68,255),"3":(68,255,127),
"4":(68,127,255),"5":(255,255,0),"6":(255,0,255),
"7":(0,255,255),"8":(255,127,0),"9":(0,255,127),
"0":(127,0,255),"#":(0,)*3}
def drawplayer(px,py):
 for dy in range(16):
  for dx in range(16):
   z=player[dy*17+dx]
   if z!=' ':S(px+dx,py+dy,C[z])
def drawBug(bug):
 z=0
 for i in hex(bug[2])[2:]+hex(bug[2]+1)[2:]:F(bug[0]+15*z,bug[1]+14,15,1,C[i]);z+=1
c='1'
print("Tirez sur les octets\nqui tombent du ciel\npour eliminer tous\nles bugs de ce\nprogramme. Mais\nplus vous corrigez\nplus il y a de bugs !\nEXE pour jouer (hardcore) >")
while c!='0'and c!='n':
 lasers=[];bytes=[];x=64;y=48;pc=0;f=80;last=0;exit=0
 while exit^1:
  F(x-8,y-8,16,16,(255,)*3)
  if K(1)and y>0:y-=4
  if K(2)and y<222:y+=4
  if K(0)and x>0:x-=4
  if K(3)and x<320:x+=4
  if(K(4)|K(52))and last>1:lasers.append([x,y-8]);last=0
  last+=1;p=0;dell=[]
  for i in lasers:
   F(i[0],i[1]+8,1,4,(255,)*3);i[1]-=4;F(i[0],i[1],1,4,(255,0,0))
   if i[1]<0:F(i[0],0,1,8,(255,)*3);dell.append(p)
   p+=1
  for i in dell:lasers.pop(i)
  i=0;drawplayer(x-8,y-8)
  D("pc="+hex(pc),1,1)
  if randint(1,f)==1:
   bytes.append([randint(0,285),-7,randint(0,254)])
#      if f>2:f-=16
#      if f<2:f=2
   if f>4:f-=16
   if f<4:f=2
  i=0
  while i<len(bytes):
   F(bytes[i][0],bytes[i][1],60,1,(255,)*3);drawBug(bytes[i]);bytes[i][1]+=1;tx=bytes[i][0];ty=bytes[i][1];n=0;delb=0
   while n<len(lasers):
    dx=lasers[n][0];dy=lasers[n][1]
    if dx>tx>dx-60 and dy>ty>dy-15:F(lasers[n][0],lasers[n][1],1,8,(255,)*3);lasers.pop(n);n-=1;delb=1;break
    n+=1
   if bytes[i][1]>222:exit=1;break
   if delb:F(bytes[0],bytes[1],60,15,(255,)*3);bytes.pop(i)
   else:i+=1
  while monotonic()-start<.07:0
  start=monotonic();pc+=1
 print("Une erreur est survenue.\npc="+hex(pc));c=input("Re\u0301esayer [Y=1/n=0] >").lower().strip()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.