infantryfight.py

Created by eta45

Created on October 03, 2021

12.6 KB

Combat pour deux joueurs. Il faut Oméga dernière version pour éxécuter ce script. https://getomega.dev/install Bon jeu!


from math import *
from random import *
from kandinsky import *
from kandinsky import fill_rect as fr
from kandinsky import get_pixel as gp
from kandinsky import draw_line as dl
from ion import *
from ion import keydown as k
from time import *
print("Bienvenu dans infantryfight v6.2\ndevellope par Aymeric @BG.\nmerci a charles @chachou pour ses idees et \npour les maps ainsi que thadee @Ducas")
help=int(input("aide? oui(1) non(2): "))
if help==1:print("deplacement:\njoueur 1: fleches\njoueur 2:e,ans,exe,+\n "),sleep(2),print("couteau:\n j1: ln\nj2: \",\"\n \ntir:\n j1: nalpha,cos,log,exp\nj2: boite a outils,racine carree,\npuissance,\"I\"\n "),sleep(2),print("Changer d arme:\nJ1: sin\nJ2: \"-\""),sleep(2),print("petits carres:\nblanc: machette\nviolet: +1 vie\n "),sleep(1),print("tu meurs au bout de 12 shoots.\nBon courage!")
map=int(input("map:\n1:Apocalyps walls\n2:Grimber gun\n3:Edge of tommorow land\n4:Death Room\n5:Deses brain\n6:Bloody man\n:"))
cf,cn,cj2,ck=(150,100,70),(0,5,0),(0,100,5),(25,60,30)
fr(0,0,320,222,(0,0,248))
fr(20,20,25,4,cn),fr(20,24,4,8,cn),fr(36,24,4,15,cn),fr(175,21,2,2,cn)
fr(20,180,40,3,cn),fr(20,183,23,4,(140,110,80)),fr(33,187,4,10,(140,110,80)),fr(5,183,15,7,(140,110,80)),fr(59,179,1,1,cn)
fr(235,20,50,10,cn),fr(220,30,28,6,cn),fr(220,36,10,6,cn)
fr(230,185,68,5,cn),fr(250,182,15,3,cn),fr(240,178,35,4,cn),fr(230,190,45,5,(140,110,80)),fr(210,192,20,9,(140,110,80))
ab,e,f,m,li=0,30,40,0,[]
cho=["premiere arme joueur un","deuxieme arme","premiere arme joueur deux","deuxieme arme"," "]
fr(e,f,8,8,cn)
while ab==0:
  draw_string(cho[m],50,100,(200,0,0),(0,0,248))
  if k(KEY_UP) and f>100:
    fr(e,f,10,10,(0,0,248))
    f-=160
    fr(e,f,10,10,cn)
  if k(KEY_DOWN) and f<100:
    fr(e,f,10,10,(0,0,248))
    f+=160
    fr(e,f,10,10,cn)
  if k(KEY_RIGHT) and e<100:
    fr(e,f,10,10,(0,0,248))
    e+=200
    fr(e,f,10,10,cn)
  if k(KEY_LEFT) and e>100:
    fr(e,f,10,10,(0,0,248))
    e-=200
    fr(e,f,10,10,cn)
  if k(KEY_OK):
    fr(e,f,10,10,(248,0,0))
    if e<100 and f<100:li.append(1)
    if e>100 and f<100:li.append(3)
    if e<100 and f>100:li.append(2)
    if e>100 and f>100:li.append(4)
    fr(50,100,250,20,(0,0,248))
    m+=1
    sleep(0.2)
    fr(e,f,10,10,cn)
  if m==4:ab=1
arme1,sa1,arme2,sa2=li
xd,wi1,wi2,direc,co1,co2,compte1,compte2,k1,k2,xbdv1,xbdv2,r1,r2,b1,b2,tour,a,b,x,y,rafale1,rafale2,score1,score2=310,0,0,0,0,0,0,0,0,0,60,60,0,0,1,1,0,10,20,292,205,1,1,0,0
eclat,fin,b1,b2,bonusv1,bonusv2,t1,t2,ra1,ra2,baz1,baz2=True,False,False,False,False,False,False,False,False,False,False,False
fr(0,0,320,240,cf)
if map==1:fr(50,50,30,30,(0,120,0)),fr(260,100,30,30,(0,120,0)),fr(190,160,40,30,(130,80,30)),fr(280,150,38,6,(130,80,30)),fr(40,180,6,40,(130,80,30)),fr(200,50,48,5,(130,80,30)),fr(104,80,6,50,(130,80,30)),fr(144,86,25,5,(130,80,30)),dl(59,79,160,190,(0,200,0)),dl(310,40,160,190,(0,200,0))
if map==2:fr(60,26,6,60,(150,120,40)),fr(20,80,166,6,(150,120,40)),fr(120,86,6,74,(150,120,40)),fr(126,154,20,6,(150,120,40)),fr(180,26,6,134,(150,120,40)),fr(186,40,74,6,(150,120,40)),fr(280,40,40,6,(150,120,40)),fr(186,114,56,6,(150,120,40)),fr(280,114,74,6,(150,120,40)),fr(240,160,40,6,(150,120,40)),fr(200,180,6,20,(150,120,40)),fr(40,120,40,80,(0,0,100)),fr(220,80,80,20,(0,0,100))
if map==3:fr(100,26,80,6,(100,100,100)),fr(20,140,100,6,(100,100,100)),fr(80,160,6,40,(100,100,100)),fr(86,180,114,6,(100,100,100)),fr(140,32,6,138,(100,100,100)),fr(146,140,120,6,(100,100,100)),fr(280,80,6,120,(100,100,100)),fr(40,60,60,40,(50,50,50)),fr(180,66,40,20,(50,50,50)),fr(240,26,20,20,(50,50,50))
if map==4:fr(80,26,40,20,(170,200,0)),fr(60,80,160,20,(170,200,0)),fr(200,26,20,60,(170,200,0)),fr(220,80,40,60,(170,200,0)),fr(120,100,20,100,(170,200,0)),fr(80,140,40,20,(170,200,0)),fr(160,140,40,20,(170,200,0)),fr(220,180,60,20,(170,200,0))
if map==5:fr(114,25,6,60,(0,250,0)),fr(200,25,6,60,(0,250,0)),fr(120,40,80,5,(0,250,0)),fr(30,120,135,5,(248,252,248)),fr(30,175,135,5,(248,252,248)),fr(30,125,5,50,(248,252,248)),fr(165,120,5,60,(248,252,248)),fr(50,125,95,50,(100,50,200)),draw_string("DJ DES",65,143,(10,10,10),(100,50,200)),fr(200,105,80,30,(200,0,0)),fr(25,50,21,20,(250,0,0))
if map==6:fr(124,25,72,6,ck),fr(100,40,122,6,ck),fr(75,54,25,62,ck),fr(225,54,25,62,ck),fr(125,66,25,25,(250,0,0)),fr(175,66,25,25,(250,0,0)),fr(154,110,12,6,(10,10,10)),fr(104,139,120,6,ck),fr(29,152,50,50,ck),fr(254,152,50,50,ck),fr(123,152,16,50,ck),fr(152,152,16,50,(250,0,0)),fr(181,152,16,50,ck),dl(25,60,120,32,(250,0,0)),dl(200,32,295,60,(250,0,0))
fr(a,b,6,6,cn),fr(x,y,6,6,cj2)
def bv():fr(0,0,320,15,(0,0,200)),fr(5,5,6,6,(2,10,0)),fr(170,5,6,6,(0,99,10)),fr(15,5,xbdv1,6,(r1,0,0)),fr(180,5,xbdv2,6,(r2,0,0))
bv()
ti=floor(monotonic())
while not fin:
  try:
    tour+=1
    if k(KEY_MINUS) and tour>wi2:
      s,wi2=arme2,tour+6
      arme2=sa2
      sa2=s
    if k(KEY_SINE) and tour>wi1:
      s,wi1=arme1,tour+6
      arme1=sa1
      sa1=s
    if map==5 and tour%5==0:fr(250,165,40,40,(randint(0,250),randint(0,250),randint(0,250)))
    if map==6:draw_string("By CHACHOU",114,203,(10,10,10),cf)
    if tour==450:
      st=False
      while not st:
        xb1,yb1=randint(0,315),randint(16,215)
        if gp(xb1,yb1)==(144,100,64) and gp(xb1+4,yb1+4)==(144,100,64) and gp(xb1,yb1+4)==(144,100,64) and gp(xb1+4,yb1)==(144,100,64):st=True
      fr(xb1,yb1,5,5,(120,180,200))
    if tour==800:
      st=False
      while not st:
        xb2,yb2=randint(0,315),randint(0,215)
        if gp(xb2+1,yb2+1)==(144,100,64) and gp(xb2+4,yb2+4)==(144,100,64) and gp(xb2+4,yb2)==(144,100,64) and gp(xb2,yb2+4)==(144,100,64):st=True
      fr(xb2,yb2,5,5,(200,0,200))
    if k(KEY_RIGHT):
      fr(a,b,6,6,cf)
      if gp(a+8,b)==(144,100,64) and gp(a+8,b+5)==(144,100,64):a+=3
      fr(a,b,6,6,cn)
    if k(KEY_LEFT):
      fr(a,b,6,6,cf)
      if gp(a-3,b)==(144,100,64) and gp(a-3,b+5)==(144,100,64):a-=3
      fr(a,b,6,6,cn)
    if k(KEY_UP):
      fr(a,b,6,6,cf)
      if gp(a,b-3)==(144,100,64) and gp(a+5,b-3)==(144,100,64):b-=3
      fr(a,b,6,6,cn)
    if k(KEY_DOWN):
      fr(a,b,6,6,cf)
      if gp(a,b+8)==(144,100,64) and gp(a+5,b+8)==(144,100,64): b+=3
      fr(a,b,6,6,cn)
    if k(KEY_EXE):
      fr(x,y,6,6,cf)
      if gp(x+8,y)==(144,100,64) and gp(x+8,y+5)==(144,100,64):x+=3
      fr(x,y,6,6,cj2)
    if k(KEY_EE):
      fr(x,y,6,6,cf)
      if gp(x-3,y)==(144,100,64) and gp(x-3,y+5)==(144,100,64):x-=3
      fr(x,y,6,6,cj2) 
    if k(KEY_ANS):
      fr(x,y,6,6,cf)
      if gp(x,y+8)==(144,100,64) and gp(x+5,y+8)==(144,100,64):y+=3
      fr(x,y,6,6,cj2) 
    if k(KEY_PLUS):
      fr(x,y,6,6,cf)
      if gp(x,y-3)==(144,100,64) and gp(x+5,y-3)==(144,100,64):y-=3
      fr(x,y,6,6,cj2) 
    if k(KEY_FOUR):direc=1
    if k(KEY_SEVEN):direc=2
    if k(KEY_FIVE):direc=3
    if k(KEY_ONE):direc=4
    if direc!=0:
      c1,arret=compte1,False
      if direc==1:s,t,m,n,u,z,w,c,d,e,r,v=-1,2,-4,0,-21,-1,-1,0,-20,0,-6,0
      if direc==2:s,t,m,n,u,z,w,c,d,e,r,v=2,-1,0,-4,0,-21,0,-1,0,-20,0,-6
      if direc==3:s,t,m,n,u,z,w,c,d,e,r,v=6,2,4,0,20,0,1,0,20,0,6,0
      if direc==4:s,t,m,n,u,z,w,c,d,e,r,v=2,6,0,4,0,21,0,1,0,20,0,6
      xtir,ytir=a+s,b+t
      if arme1==3:h=25
      else:h=17
      if tour>=compte1:compte1=tour+h
      xobj,yobj=xtir,ytir
      for i in range(5):
        xobj,yobj=xobj+m,yobj+n
        if gp(xobj,yobj)!=(144,100,64):arret=True
      while not arret:
        if arme1==2 and tour%3==0:arret=True
        if arme1==3 and tour<c1:arret=True
        if arme1==4 and tour<c1:arret=True
        xobj,yobj=xtir+u,ytir+z
        for i in range(6):
          coul=gp(xobj,yobj)
          if coul!=(144,100,64) and arme1!=3:
            if coul==(0,100,0):t1=True
            if coul==(200,0,200):bonusv1=True
            arret=True
          if coul!=(144,100,64) and arme1==3:baz1,xbaz1,ybaz1,arret=True,xobj,yobj,True
          xobj,yobj=xobj+w,yobj+c
        if arret!=True:
          dl(xtir,ytir,xtir+d,ytir+e,cf)
          xtir,ytir=xtir+r,ytir+v
          dl(xtir,ytir,xtir+d,ytir+e,(200,0,0))
        if arret==True:draw_line(xtir,ytir,xtir+d,ytir+e,cf)
    direc=0
    if k(KEY_IMAGINARY):direc=1
    if k(KEY_TOOLBOX):direc=2
    if k(KEY_POWER):direc=3
    if k(KEY_SQRT):direc=4
    if direc!=0:
      c2,arret=compte2,False
      if direc==1:s,t,m,n,u,z,w,c,d,e,r,v=-1,2,-4,0,-21,-1,-1,0,-20,0,-6,0
      if direc==2:s,t,m,n,u,z,w,c,d,e,r,v=2,-1,0,-4,0,-21,0,-1,0,-20,0,-6
      if direc==3:s,t,m,n,u,z,w,c,d,e,r,v=6,2,4,0,20,0,1,0,20,0,6,0
      if direc==4:s,t,m,n,u,z,w,c,d,e,r,v=2,6,0,4,0,21,0,1,0,20,0,6
      xtir,ytir=x+s,y+t
      if arme2==3:h=25
      else:h=17
      if tour>=compte2:compte2=tour+h
      xobj,yobj=xtir,ytir
      for i in range(6):
        xobj,yobj=xobj+m,yobj+n
        if gp(xobj,yobj)!=(144,100,64):arret=True
      while not arret:
        if arme2==2 and tour%3==0:arret=True
        if arme2==3 and tour<c2:arret=True
        if arme2==4 and tour<c2:arret=True
        xobj,yobj=xtir+u,ytir+z
        for i in range(6):
          coul=gp(xobj,yobj)
          if coul!=(144,100,64) and arme2!=3:
            if coul==(0,4,0):t2=True
            if coul==(200,0,200):bonusv2=True
            arret=True
          if coul!=(144,100,64) and arme2==3:baz2,xbaz2,ybaz2,arret=True,xobj,yobj,True
          xobj,yobj=xobj+w,yobj+c
        if arret!=True:
          dl(xtir,ytir,xtir+d,ytir+e,cf)
          xtir,ytir=xtir+r,ytir+v
          dl(xtir,ytir,xtir+d,ytir+e,(200,0,0))
        if arret==True:draw_line(xtir,ytir,xtir+d,ytir+e,cf)
    direc=0
    if k(KEY_COMMA):
      if tour<co2:pass
      else:
        co2=tour+4
        xobj,yobj=x-10,y-10
        for i in range(26):
          for i in range(26):
            coul=gp(xobj,yobj)
            if coul!=(144,100,64):
              if coul==(0,4,0):t2,k2=True,1
              if coul==(200,0,200):bonusv2=True
              if coul==(120,180,200):
                rafale2=2
                fr(xb1,yb1,5,5,cf)
            xobj+=1
          xobj=x-10
          yobj+=1
    if k(KEY_ZERO):
      if tour<co1:pass
      else:
        co1=tour+4
        xobj,yobj=a-10,b-10
        for i in range(26):
          for i in range(26):
            coul=gp(xobj,yobj)
            if coul!=(144,100,64):
              if coul==(0,100,0):t1,k1=True,1
              if coul==(200,0,200):bonusv1=True
              if coul==(120,180,200):
                rafale1=2
                fr(xb1,yb1,5,5,cf)
            xobj+=1
          xobj=a-10
          yobj+=1
    if bonusv1==True:
      bonusv1=False
      if score2>0:
        score2,r1,xbdv1=score2-1,r1-49,xbdv1+10
        fr(xb2,yb2,5,5,cf),fr(15,5,60,6,(0,0,200)),fr(15,5,xbdv1,6,(r1,0,0))
    if bonusv2==True:
      bonusv2=False
      if score1>0:
        score1,r2,xbdv2=score1-1,r2-49,xbdv2+10
        fr(xb2,yb2,5,5,cf),fr(180,5,60,6,(0,0,200)),fr(180,5,xbdv2,6,(r2,0,0))
    if t1==True:
      t1=False
      if k1==1:p,k1=1*rafale1,0
      else:p=arme1
      if xbdv2>=5:
        xbdv2,r2,score1=xbdv2-(5*p),r2+(20*p),score1+p
        if xbdv2<0:xbdv2=0
        fr(180,5,60,6,(0,0,200)),fr(180,5,xbdv2,6,(r2,0,0)),fr(x,y,6,6,(248,0,0)),sleep(0.3),fr(x,y,6,6,(0,100,5))
    if t2==True:
      t2=False
      if k2==1:p,k2=1*rafale2,0
      else:p=arme2
      if xbdv1>=5:
        r1,xbdv1,score2=r1+(20*p),xbdv1-(5*p),score2+p
        if xbdv1<0:xbdv1=0
        fr(15,5,60,6,(0,0,200)),fr(15,5,xbdv1,6,(r1,0,0)),fr(a,b,6,6,(248,0,0)),sleep(0.3),fr(a,b,6,6,cn)
    if baz1==True:
      ec,xobj,yobj,baz1=0,xbaz1-7,ybaz1-7,False
      for i in range(15):
        for i in range(15):
          coul=gp(xobj,yobj)
          if coul!=(144,100,64):
            if coul==(0,100,0):t1=True
            if coul!=(0,0,0) and coul!=(0,0,200):ec=1
          xobj+=1
        xobj,yobj=xbaz1-7,yobj+1
      if ec==1:ec=0,fr(xbaz1-7,ybaz1-7,15,15,(250,250,0)),sleep(0.3),fr(xbaz1-7,ybaz1-7,15,15,cf)
      bv()
    if baz2==True:
      ec,xobj,yobj,baz2=0,xbaz2-7,ybaz2-7,False
      for i in range(15):
        for i in range(15):
          coul=gp(xobj,yobj)
          if coul!=(144,100,64):
            if coul==(0,4,0):t2=True
            if coul!=(0,0,0) and coul!=(0,0,200):ec=1
          xobj+=1
        xobj,yobj=xbaz2-7,yobj+1
      if ec==1:ec=0,fr(xbaz2-7,ybaz2-7,15,15,(250,250,0)),sleep(0.3),fr(xbaz2-7,ybaz2-7,15,15,cf)
      bv()
    if k(KEY_BACK):fin=True
    mon=floor(monotonic())
    if mon-ti==10:xd=300
    if mon-ti==100:xd==290
    draw_string(str(mon-ti),xd,0,(0,250,0),(0,0,200))
    if score1>=12 or score2>=12 or (mon-ti)==100:
      draw_string("Fin du jeu!",10,15,(250,0,0),cn)
      print("joueur noir:",score1,"joueur vert:",score2)
      if score1>score2:print("Bravo joueur noir!")
      elif score1==score2:print("Egalite!")
      else:print("Bravo joueur vert!")
      fin=True
    draw_string(str(arme1),0,15,(10,10,10),cf),draw_string(str(arme2),308,200,(10,10,10),cf)
  except KeyboardInterrupt:
    pass

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.