jeu_v_3.py

Created by vgalletramond

Created on January 14, 2025

12.9 KB


from kandinsky import fill_rect as f_r,draw_string as d_s
from random import randint as rd
from ion import keydown as kd
from time import sleep as sl


zombie = {"PV":30,"AT":13,"DEF":1}
squelette = {"PV":35,"AT":15,"DEF":3}
araigne = {"PV":50,"AT":20,"DEF":4}
gobelin = {"PV":40,"AT":25,"DEF":2}
blob = {"PV":90,"AT":12,"DEF":7}
shadow = {"PV":70,"AT":42,"DEF":4}
hydre = {"PV":200,"AT":60,"DEF":20}
en = ((zombie,'Zombie'),(squelette,'Squelette'),(araigne,'Araignée'),(gobelin,'Gobelin'),(blob,'Blob'),(shadow,'Shadow'),(hydre,'Hydre'))

def event(n_e,know):
    modif=0
    if n_e == 2:
        a_s_h(2,0,0,'boss'*(n%5==0))
        modif = rd(10,30-8*(n//10)*(4*(n//5)>12)+12*(30-4*(n//5)<12))
        h["PV"] += modif
    elif n_e == 1:
        sl(0.4)
        return
    elif n_e == 3:
        h["AT"] += 5
        modif = 5
    elif n_e == 4:
        h["DEF"] += 2
        modif = 2
    elif n_e == 5:
        modif = rd(10,15+5*(n//5))-h["DEF"]
        modif = int(modif*(1-0.2*(know==0)))
        modif *= (modif>0)
        h["PV"] -= modif
        h["PV"] *= (h["PV"]>0)
        if h["PV"] <= 0:
            a_s_h(n_e,0,modif,'boss'*(n%5==0))
            sl(1)
            init_jeu()
    elif n_e == 6:
        a_s_h(n_e,0,0,'boss'*(n%5==0))
        if know == 0:
            enne=en[rd(0,1+(n//4)*(n<24)+5*(n>=24))]
            enne[0]["PV"]=int(enne[0]["PV"]*0.8)
            enne[0]["AT"]=int(enne[0]["AT"]*0.8)
            enne[0]["DEF"]=int(enne[0]["DEF"]*0.8)
            combat(enne)
            enne[0]["AT"]=int(enne[0]["AT"]/0.8)
            enne[0]["DEF"]=int(enne[0]["DEF"]/0.8)
        elif know == 1:
            combat(en[rd(0,1+(n//5)*(n<25)+4*(n>=25))])
        modif = 0
    elif n_e == 7:
        global n_g
        n_g+=1
    elif n_e == 8:
        enne=en[(n//5)*(n//5<=6)+6*((n//5)>6)]
        enne[0]["PV"]=int(enne[0]["PV"]*1.5)
        enne[0]["AT"]=int(enne[0]["AT"]*1.5)
        enne[0]["DEF"]=int(enne[0]["DEF"]*1.5)
        combat(enne,1)
    a_s_h(n_e*(n_e!=6 and n_e!=8),0,modif,'boss'*(n_e==8)+'gemme'*(n_e==7))
    sl(0.4)
    return

def combat(m_i,boss=0):
    e_c = 1
    a_s_h(0,e_c,0,'boss'*(n%5==0),m_i[0],m_i[1])
    sl(1)
    while e_c == 1:
        m_i[0]["PV"] -= (h["AT"]-m_i[0]["DEF"])*((h["AT"]-m_i[0]["DEF"])>0)
        m_i[0]["PV"]*=(m_i[0]["PV"]>0)
        a_s_h(0,e_c,0,'boss'*(n%5==0),m_i[0],m_i[1])
        sl(1)
        if m_i[0]["PV"] <= 0:
            h["AT"]+=int(m_i[0]["AT"]/10)
            e_c = 0
            if boss == 1:
                global n_g
                n_g+=1
                m_i[0]["AT"]=int(m_i[0]["AT"]/1.5)
                m_i[0]["DEF"]=int(m_i[0]["DEF"]/1.5)
            return 
        h["PV"] -= (m_i[0]["AT"]-h["DEF"])*((m_i[0]["AT"]-h["DEF"])>0)
        h["PV"]*=(h["PV"]>0)
        a_s_h(0,e_c,0,'boss'*(n%5==0),m_i[0],m_i[1])
        sl(1)
        if h["PV"] <= 0:
            e_c = 0
            sl(1)
            return init_jeu()



def jeu():
    f_r(0,0,320,222,'black')
    for i in range(t_p):
        for j in range(t_p*2):
            red=(18+int((144-2)/t_p)*j,10+int((144-2)/t_p)*i,int((144-2)/t_p),int((144-2)/t_p))
            red2=(18+int((144-2)/t_p)*j+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),10+int((144-2)/t_p)*i+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),21*(t_p==4)+18*(t_p==5)+18*(t_p==6))
            f_r(red[0],red[1],red[2],red[3],'white')
            if g[i][j] == 'P':
                d_c(red[0],red[1],red[2])
            else:
                d_q_m(red2[0],red2[1],red2[2],g[i][j]//10)
    a_g()
    a_g2()
    a_s_h(0,0,0,'boss'*(n%5==0))
    barre_bas()
    
        

def a_g(ori=[0,0]):
    for char in range(len(g)):
        for pers in range(len(g[char])):
            if g[char][pers] == 'P':
                g[char][pers] = 11
            elif g[char][pers] == 'P0':
                g[char][pers] = 0
    eve = g[h["pos"][1]][h["pos"][0]]//10
    know = g[h["pos"][1]][h["pos"][0]]%10
    if g[h["pos"][1]][h["pos"][0]]//10 != 0:
        g[h["pos"][1]][h["pos"][0]] = 'P'
    else:
        g[h["pos"][1]][h["pos"][0]] = 'P0'
    f_r(18+int((144-2)/t_p)*ori[0],10+int((144-2)/t_p)*ori[1],int((144-2)/t_p),int((144-2)/t_p),'white')
    if str(g[ori[1]][ori[0]]) == '0':
        f_t["0"](18+int((144-2)/t_p)*ori[0]+9*(t_p==3)+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),10+int((144-2)/t_p)*ori[1]+9*(t_p==3)+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),30*(t_p==3)+21*(t_p==4)+18*(t_p==5)+18*(t_p==6))
    f_r(18+int((144-2)/t_p)*h["pos"][0],10+int((144-2)/t_p)*h["pos"][1],int((144-2)/t_p),int((144-2)/t_p),'white')
    d_c(18+int((144-2)/t_p)*h["pos"][0]+9*(t_p==3)+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),10+int((144-2)/t_p)*h["pos"][1]+9*(t_p==3)+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),30*(t_p==3)+21*(t_p==4)+18*(t_p==5)+18*(t_p==6))
    return eve,know

def a_g2():
    nb_qm=4+n
    unknow=[]
    for i in range(t_p*t_p*2-nb_qm):
        while 42:
            co=0
            x,y=rd(0,t_p*2-1),rd(0,t_p-1)
            if not(x==0 and y==0):
                for j in range(len(unknow)):
                    if unknow[j] == [x,y]:
                        co=1
                if co == 0:
                    unknow.append([x,y])
                    comp=(18+int((144-2)/t_p)*x,10+int((144-2)/t_p)*y,int((144-2)/t_p),int((144-2)/t_p))
                    comp2=(18+int((144-2)/t_p)*x+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),10+int((144-2)/t_p)*y+7*(t_p==4)+5*(t_p==5)+3*(t_p==6),21*(t_p==4)+18*(t_p==5)+18*(t_p==6))
                    if g[y][x]//10 == 8 or g[y][x]//10 == 7:
                        f_r(comp[0],comp[1],comp[2],comp[3],'#FFC914')
                    else:
                        f_r(comp[0],comp[1],comp[2],comp[3],'white')
                    if g[y][x]//10 != 1:
                        f_t[str(g[y][x]//10)](comp2[0],comp2[1],comp2[2])
                    g[y][x] = int(str(g[y][x])[0]+'1')
                    break


def pixel_heart(x,y,t):
    for j in range(9):
        for i in range((j==0)+(j==3)+(j==4)*2+(j==5)+(j==8),4+1*((j==1)+(j==7))+2*((j==2)+(j==6))+3*((j==3)+(j==5))+4*(j==4)):
            f_r(x+int(t/9)*j+int(1/2*((t+5)/9)),y+int(t/9)*i+int(1/2*((t+15)/7)),int(t/9),int(t/9),'#EBBAB9')
#F87575
def draw_cross(x,y,t):
    for j in range(5):
        for i in range(((j==1)+(j==3))+((j==2)+(j==5))*2,5,4*((j==0)+(j==4))+2*((j==1)+(j==3))+3*(j==2)):
            f_r(x+int(t/5)*j,y+int(t/5)*i,int(t/5),int(t/5),'#FFC914')

def draw_sword(x,y,t,c='#5EC960'):
    for j in range(9):
        for i in range(8*(j==0)+5*((j==1)+(j==2))+4*(j==3)+3*(j==4)+2*(j==5)+1*(j==6),9-2*(j==2)-1*(j==3)-3*(j==4)-4*(j==5)-5*(j==6)-6*(j==7)-7*(j==8),1+1*(j==1)):
            f_r(x+int(t/9)*j,y+int(t/9)*i,int(t/9),int(t/9),c)

def draw_sword_m(x,y,t):
    for j in range(9):
        for i in range(8*(j==8)+5*((j==7)+(j==6))+4*(j==5)+3*(j==4)+2*(j==3)+1*(j==2),9-2*(j==6)-1*(j==5)-3*(j==4)-4*(j==3)-5*(j==2)-6*(j==1)-7*(j==0),1+1*(j==7)):
            f_r(x+int(t/9)*j,y+int(t/9)*i,int(t/9),int(t/9),'#E02020')

def draw_spike(x,y,t):
    for j in range(9):
        for i in range(7*((j==0)+(j==8))+5*((j==1)+(j==7))+3*(j==2 or j==6)+1*(j==3 or j==5),8):
            f_r(x+int(t/9)*j,y+int(t/9)*i+int(1/2*(t/9)),int(t/9),int(t/9),'#E02020')

def draw_shield(x,y,t):
    for j in range(5):
        for i in range(6-2*((j==0)+(j==4))-1*((j==1)+(j==3))):
            f_r(x+int(t/6)*j+int(1/2*(t/6)),y+int(t/6)*i,int(t/6),int(t/6),'#5EC960')
#7C3626
def d_c(x,y,t):
    for j in range(5):
        for i in range(5*((j==0)+(j==4)),6*((j==0)+(j==4))+7*(j==2)+1*((j==1)+(j==3))):
            if (j==1)+(j==3):
                for k in range(3):
                    f_r(x+int(t/9)*j+int(2*(t/9)),y+int(t/9)*k,int(t/9),int(t/9),'black')
                f_r(x+int(t/9)*j+int(2*(t/9)),y+int(t/9)*4,int(t/9),int(t/9),'black')
                for k in range(2):
                    f_r(x+int(t/9)*j+int(2*(t/9)),y+int(t/9)*(k+7),int(t/9),int(t/9),'black')
                break
            else:
                f_r(x+int(t/9)*j+int(2*(t/9)),y+int(t/9)*i,int(t/9),int(t/9),'black')


def d_q_m(x,y,t,even):
    if rd(0,2)<2:
        if even == 5 or even == 6:
            col = '#E02020'
        elif even == 2 or even == 3 or even == 4:
            col = '#5EC960'
        else:
            col = 'black'
    else:
        col = 'black'
    for j in range(5):
        for i in range(1*((j==0)+(j==4)),1*((j==2)+(j==1))+3*((j==0)+(j==4))+4*(j==3),1*(j!=3)+3*(j==3)):
            if (j==2):
                f_r(x+int(t/8)*j+int(1.9*(t/8)),y+int(t/8),int(t/8),int(t/8),col)
                for k in range(2):
                    f_r(x+int(t/8)*j+int(1.9*(t/8)),y+int(t/8)*(k+4)+int(t/8),int(t/8),int(t/8),col)
                f_r(x+int(t/8)*j+int(1.9*(t/8)),y+int(t/8)*7+int(t/8),int(t/8),int(t/8),col)
                break
            else:
               f_r(x+int(t/8)*j+int(1.9*(t/8)),y+int(t/8)*i+int(t/8),int(t/8),int(t/8),col)

def d_g(x,y,t):
    for j in range(5):
        for i in range(2*(j==0 or j==4)+1*(j==1 or j==3),5-2*(j==0 or j==4)-1*(j==1 or j==3)):
            f_r(x+int(t/5)*j,y+int(t/5)*i,int(t/5),int(t/5),'#46A2DA')
      
def barre_bas():
    f_r(0, 200, 320, 22, (148, 113, 222))
    d_s( "nsi.xyz/themap", 2, 202, (242,)*3, (148, 113,222))
    d_s("N:"+str(n), 150, 202, (242,)*3, (148, 113,222))
    if n%5==0:
        d_s("Boss:"+str(n_g)+'/1',205,202,(242,)*3, (148, 113,222))
    else:
        d_s("Gemme:"+str(n_g)+'/1',205,202,(242,)*3, (148, 113,222))

#inspiré de nsi.xyz/escape
#a compacté comme nsi.xyz/escape
def a_s_h(n_e=0,e_c=0,modif=0,c_c='gemme',m='',n_m=''):
    f_r(0, 179, 320, 20, 'black')
    d_s("Heros",5,160,'white','black')
    txt=[]
    txt.append(str(int(h["PV"])))
    txt.append(str(int(h["AT"])))
    txt.append(str(int(h["DEF"])))
    wr=''
    for i in range(3):
        wr+=txt[i]+'  '
    d_s(wr,5,180,'white','black')
    pixel_heart(6+10*len(txt[0]),180,18)
    draw_sword(26+10*(len(txt[0])+len(txt[1])),180,18)
    draw_shield(46+10*(len(txt[0])+len(txt[1])+len(txt[2])),180,18)
    if n_e != 0 and n_e != 1:
        f_t[str(n_e)](151,180,18)
    if n_e == 2 or n_e == 3 or n_e == 4:
        d_s('+'+str(modif),283-10*len(str(modif)),180,(242,)*3, 'black')
        f_t[str(n_e)](295,180,18)
    elif n_e == 5:
        d_s('-'+str(modif),283-10*len(str(modif)),180,(242,)*3, 'black')
        f_t["2"](295,180,18)
    elif n_e == 7:
        d_s('+1',273,180,(242,)*3, 'black')
        f_t["7"](295,180,18)
    if e_c == 1:
        f_t["3"](150,180,18,'#E02020')
        f_t["6"](154,180,18)
        d_s(str(n_m),318-10*len(str(n_m)),160,'white','black')
        txt=[]
        txt.append(str(m["PV"]))
        txt.append(str(m["AT"]))
        txt.append(str(m["DEF"]))
        wr=''
        for i in range(3):
            wr+=txt[i]+'  '
        d_s(wr,285-10*(len(wr)-3),180,'white','black')
        pixel_heart(255-10*(len(txt[1])+len(txt[2])),180,18)
        draw_sword(275-10*len(txt[2]),180,18)
        draw_shield(295,180,18)
    elif e_c == 0:
        f_r(225, 160, 95, 19,'black')
        for i in range(len(en)):
            en[i][0]["PV"] = 200*(i==6)+70*(i==5)+90*(i==4)+40*(i==3)+50*(i==2)+35*(i==1)+30*(i==0)
    if c_c == 'gemme':
        d_s("Gemme:"+str(n_g)+'/1',205,202,(242,)*3, (148, 113,222))
    elif c_c == 'boss':
        d_s("Boss:"+str(n_g)+'/1',205,202,(242,)*3, (148, 113,222))
        

def init_jeu():
    global t_p,g,h,n_g
    n_g = 0
    t_p = (4+n//(8+n//5)*(n<32)+2*(n>=32))
    g = [[rd(0,1) for i in range(t_p*2)] for j in range(t_p)]
    for i in range(t_p):
        for j in range(t_p*2):
            if g[i][j] == 0:
                g[i][j] = rd(1,4)
            else:
                g[i][j] = rd(5,6)
            g[i][j] = int(str(g[i][j])+'0')
    g[rd(t_p-2,t_p-1)][rd(t_p*2-2,t_p*2-1)] = 0
    g[0][0] = 'P'
    while True:
        x,y=rd(2,t_p*2-1),rd(2,t_p-1)
        if g[y][x]//10 != 0:
            if n%5 == 0:
                if x%2 == 1 and y%2 == 1:
                    g[y][x] = int('8'+str(g[y][x])[1])
                    break
            else:
                g[y][x] = int('7'+str(g[y][x])[1])
                break
    h = {"PV":int(75+5*(n//4)),"AT":int(15+2*(n//5)),"DEF":int(0+1*(n//5)),"pos":[0,0]}
    return jeu()

f_t = {'P':d_c,'0':draw_cross,'2':pixel_heart,'3':draw_sword,'4':draw_shield,'5':draw_spike,'6':draw_sword_m,'7':d_g,'8':draw_sword_m}
n = 1
init_jeu()
while True:
    sl(0.5)
    stop = 0
    while stop == 0:
        orig=[h["pos"][0],h["pos"][1]]
        if kd(2):
            h["pos"][1] += 1*(h["pos"][1]+1<t_p)
            eve,know = a_g(orig)
            if eve == 0 and n_g == 1:
                n += 1
                init_jeu()
            event(eve,know)
        elif kd(3):
            h["pos"][0] += 1*(h["pos"][0]+1<t_p*2)
            eve,know = a_g(orig)
            if eve == 0 and n_g == 1:
                n += 1
                init_jeu()
            event(eve,know)
        elif kd(1):
            h["pos"][1] -= 1*(h["pos"][1]-1>=0)
            eve,know = a_g(orig)
            if eve == 0 and n_g == 1:
                n += 1
                init_jeu()
            event(eve,know)
        elif kd(0):
            h["pos"][0] -= 1*(h["pos"][0]-1>=0)
            eve,know = a_g(orig)
            if eve == 0 and n_g == 1:
                n += 1
                init_jeu()
            event(eve,know)

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.