the_lost_digger_v1_assets.py

Created by furicoda

Created on January 14, 2024

5.23 KB


from ion import keydown as kd;from random import randint as ran;from kandinsky import fill_rect as fl,set_pixel,draw_string,color;from math import sqrt;import numpy as np;from time import monotonic
def getvalueitem(item):return (0,1,4,10,25,75,125,200,400,800,0,0,0,0,0)[item]
def getnameitem(item):return("air","dirt","stone","coal","iron","gold","lapis","diamond","obscidia","uranium","oil","base","bomb","nuke")[item]
def getlifebloc(typ):return (0,1,2,3,6,10,20,30,50,100,1,4,4,4)[typ]
def getbombtex():return "0000020000000022000000012110000011211100011221111001121111100111111110011111111000111111000001111000"
def explosion(self,M,p,pos,de):
  M[pos[0]+pos[1]*16],e=0,[]
  for x in range(-p,p+1):
    for y in range(-p,p+1):
      if x!=-p and x!=p and y!=-p and y!=p:e.append((x,y))
  for d in tuple(e):
    if pos[0]+d[0]>=0 and pos[0]+d[0]<=15 and pos[1]+d[1]>=0 and pos[1]+d[1]<=10:
      tp=pos[0]+d[0]+(pos[1]+d[1])*16
      if tp==int(self.x/20)+int(self.y/20)*16:self.dead=1;self.gameover=True
      if M[tp]==9:self.explolist.append((4,(pos[0]+d[0],pos[1]+d[1]),200))
      elif M[tp]==10:self.explolist.append((2,(pos[0]+d[0],pos[1]+d[1]),2))
      elif getlifebloc(M[tp])<=de:M[tp]=0
  return M

def rounder(fl):return str(int(fl))
def refreshshop(iv,s):
  f=s.fuel;sh=s.shopmode;y=-20;os=0;o=0
  fl(298,8,14,204,"yellow");i=int(f*2);fl(300,210-i,10,i,"brown");fl(0,200,100,22,"black");draw_string(rounder(f)+"/100 L",190,200,"white","black");draw_string(rounder(s.money)+"$",5,205,"yellow","black")
  if sh==1:
    b=0
    for n in ("10L of fuel = "+rounder(s.fuelprice)+"$","one bomb = 150$"+" x"+str(s.nbofbombs),"+1 minage power = "+str(s.viminagepr)+"$","reduce consum= "+str(int(s.consopr))+"$","+1 scale of dig="+str(s.tailleminpr)+"$","+1 speed for:"+str(s.speedpr)+"$","+1 inv slot for:"+str(s.inventoryplpr)+"$","1 nuke:1000$+1 uranium x"+str(s.nbofnukes),"+10 fuel : 10 coal"):draw_string(n,0,b*20,"white","black");fl(250,b*20,15,15,"yellow" if b==s.shopbutn else "red");b+=1
    return
  if sh==2:
    b=0
    for n in ("press ok to dig","press + to\n set a bomb","","press - to\n explode the bombs"):draw_string(n,0,b*20,"white","black");b+=1
    return
  for e in iv:
    col="red"
    if o<10:draw_string(getnameitem(os)+" "+str(iv[os])+"x "+"value:"+str(getvalueitem(os))+"$",0,y,"white","black")
    if s.shopeleis==os:col="yellow"
    if o<10:fl(250,y,15,15,"red");fl(270,y,15,15,"red");fl(250+s.shopallorone*20,y,15,15,col);y+=20;os+=1
    o+=1
  fl(0,175,100,30,"black");draw_string(str(sum(iv))+"/"+str(s.maxinvplace),0,180,"orange","black")
def getbasetexture():return"0001001000021111112001200002101101001011010011001001001100101101001011012000021002111111200001001000"
def prishadow(t,x,y):
  if t[0]:
    if t[1]:fl(x*20+10,y*20,10,10,"black")
    if t[3]:fl(x*20,y*20,10,10,"black")
  if t[2] and t[3]:fl(x*20,y*20+10,10,10,"black")
  if t[2] and t[1]:fl(x*20+10,y*20+10,10,10,"black")

def getshadowmap(x,y,s):
  b,tr,t=x+y*16,{0,12,13},[1,1,1,1]
  if x>0:t[3]=not s.Mape[b-1] in tr
  if x<15:t[1]=not s.Mape[b+1] in tr
  if y>0:t[0]=not s.Mape[b-16] in tr
  if y<10:t[2]=not s.Mape[b+16] in tr
  return t
  
def setbloctex(x,y,t,self):
  tr={0,12,13}
  if not t in tr:sh=getshadowmap(x,y,self);h=sh.count(1)==4
  if t==0:fl(x*20,y*20,20,20,color(198,107,46))
  if t==1:
    fl(x*20,y*20,20,20,"black" if h else "brown")
    if not h:prishadow(sh,x,y)
  if t==2:
    fl(x*20,y*20,20,20,"black" if h else "grey")
    if not h:prishadow(sh,x,y)
  if t >2 and t<10:
    fl(x*20,y*20,20,20,"black" if h else "grey")
    if not h:
      fl(x*20,y*20,20,20,"grey");colos=("black",color(114,112,70),color(255,202,53),color(38,97,156),color(185,242,255),color(60,2,81),color(92,255,174))[t-3]
      for t in {(1,2),(1,3),(1,7),(2,1),(2,2),(2,6),(2,7),(2,9),(3,4),(3,6),(4,1),(4,4),(4,5),(5,1),(5,5),(5,8),(6,3),(6,8),(7,1),(7,2),(7,7),(7,8),(8,6),(8,7)}:fl(x*20+t[0]*2,y*20+t[1]*2,2,2,colos)
      prishadow(sh,x,y)
  if t==10:
    fl(x*20,y*20,20,20,"black" if h else color(20,10,30))
    if not h:prishadow(sh,x,y)
  if t==11:
    for xi in range(10):
        for yi in range(10):
            tp=getbasetexture()[xi+yi*10]
            if tp=="0":col=color(7,56,0)
            elif tp=="1":col=color(26,125,11)
            else:col=color(34,138,18)
            fl(x*20+xi*2,y*20+yi*2,2,2,col)
    prishadow(sh,x,y)
  elif t==12 or t==13:
    fl(x*20,y*20,20,20,color(198,107,46));texis=getbombtex()
    for stx in range(10):
      for sty in range(10):
        col=color(198,107,46)
        if texis[stx+sty*10]=="1":col="black" if t==12 else "green"
        if texis[stx+sty*10]=="2":col="yellow"
        set_pixel(x*20+5+stx,y*20+5+sty,col)

def launchscreen():
  fl(0,0,320,235,"cyan")
  draw_string("press ok to play",40,30,"red","cyan")
  fl(0,200,320,30,"green")

def refreshblock(self,posx,posy,Mape):
    typ=Mape[posx+posy*16]
    if typ==0:
      for xref,yref in {(0,0),(-1,0),(1,0),(0,-1),(0,1),(0,2),(0,-2),(2,0),(-2,0),(-1,1),(1,1),(-1,-1),(1,-1)}:
        if posx+xref>=0 and posx+xref<=15:
          if posy+yref>=0 and posy+yref<=10:
            typ=Mape[posx+xref+(posy+yref)*16];setbloctex(posx+xref,posy+yref,typ,self)
    self.undraw();self.draw()
def affitex(x,y,c,t,s):fl(x*20,y*20,20,20,color(198,107,46) if t==0 else "black") if c else setbloctex(x,y,t,s)

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.