the_space_game_1.py

Created by opktmgb

Created on May 08, 2024

7.47 KB

Jeu de vaisseau spatial🚀 au beau milieu de météorites🪐 toujours plus résistantes et plus nombreuses ! Heureusement dans la galaxie des êtres bienfaisants peuvent laisser des cadeaux🎁 qui vous seront très utile pour avancer dans le jeu… ( +1vie💖 ou + 1 dégât ou + 1 pts de cadence de tir⚡. Ok ou Boîte à outils pour tirer. Flèche pour se déplacer. Home ou Exe pour faire une pause.


#le but du jeu est simple : survivre!
#Pour parvenir a la fin du jeu, vous
#beneficiez de tirs qui detruisent 
#les asteroides.  
#les cadeaux vous donnent soit des vies,
#soit une augmentation de la cadence
#des tirs, soit un point de degats en
#plus pour vos tirs
from math import *;from kandinsky import *;from random import *;from time import *;from ion import *
fill_rect(0,0,320,230,"black")
life=1;your_life=4;dega=1;cadence=35
nb_cadence=1;cadfire=False;xy=0;exa=200
exb=0;exc=0;explos=20;ac=0;br=False;fe=0
g=2;difw=20;wai=0;cdif=0;jd=True;hb=50;con=0
colo=["black",'red','blue','green','orange','yellow','grey','brown',(190,0,0),(160,0,0),(130,0,0),(100,0,0),(70,0,0),(0,0,0),(0,100,0),(0,50,0),(0,0,100),(0,0,50),(255,255,255)]
score,realcomtage,comptage,score_bl,poob=0,0,0,0,[]
t_cad,llcad,tir=randint(100,400),330,0
ltir,poub,pou=[],[],[]
lltir,lwai,llwai,llife=[],[],[],[]
a=False;b=False;c=False;cad=False
fine=True;dif=18

def ship(hb,cano=(110,110,110)):
  e=[(19,hb-3,2,1,(180,180,180)),(19,hb-2,3,1,"grey"),(19,hb-1,7,1,cano),(19,hb,1,3,cano),(20,hb,4,3,colo[dega]) if len(colo)>dega else (20,hb,4,3,colo[len(colo)-1]),(24,hb,3,3,"grey"),(19,hb+3,7,1,cano),(19,hb+4,3,1,"grey"),(19,hb+5,2,1,(180,180,180)),(27,hb+1,1,1,(190,190,190))]
  for i in e:
    fill_rect(i[0],i[1],i[2],i[3],i[4])

def explose(hb):
  f=[[(7,hb-14,2,1),(7,hb-13,3,1),(36,hb-13,3,1),(8,hb-12,4,1),(34,hb-12,5,1),(8,hb-11,6,1)],[(32,hb-11,7,1),(9,hb-10,7,1),(30,hb-10,8,1),(9,hb-9,9,1),(29,hb-9,9,1),(10,hb-8,10,1)],[(28,hb-8,10,1),(10,hb-7,11,1),(27,hb-7,10,1),(11,hb-6,12,1),(26,hb-6,11,1),(11,hb-5,13,1)],[(25,hb-5,12,1),(12,hb-4,24,1),(12,hb-3,24,1),(13,hb-2,22,1),(14,hb-1,21,1),(15,hb,19,1)],[(15,hb+1,19,1),(14,hb+2,20,1),(14,hb+3,20,1),(13,hb+4,22,1),(13,hb+5,23,1),(12,hb+6,25,1)],[(12,hb+7,26,1),(11,hb+8,28,1),(11,hb+9,8,1),(22,hb+9,19,1),(10,hb+10,7,1),(25,hb+10,18,1)],[(10,hb+11,6,1),(28,hb+11,16,1),(9,hb+12,6,1),(31,hb+12,14,1),(9,hb+13,5,1),(34,hb+13,12,1)],[(8,hb+14,5,1),(37,hb+14,9,1),(8,hb+15,4,1),(40,hb+15,7,1),(7,hb+16,4,1),(43,hb+16,4,1)],[(7,hb+17,3,1),(44,hb+17,3,1),(7,hb+18,2,1)]]
  col=[(250,200,100),(240,180,80),(235,160,60),(230,140,40),(220,120,20),(210,100,0),(200,80,0),(190,60,0),(180,40,0)]
  for i in range(len(f)):
    for j in f[i]:
      fill_rect(j[0],j[1],j[2],j[3],col[i])
  ship(hb,(135,135,135))
        
  
while jd:
  realcomtage+=1
  poub=[]
  if keydown(1):
    if hb>4:
      fill_rect(19,hb+5,2,1,"black")
      fill_rect(21,hb+4,1,1,"black")
      fill_rect(22,hb+3,4,1,"black")
      fill_rect(26,hb+2,1,1,"black")
      fill_rect(27,hb+1,1,1,"black")
      hb-=1
  if keydown(2):
    if hb<216:
      fill_rect(19,hb-3,2,1,"black")
      fill_rect(21,hb-2,1,1,"black")
      fill_rect(22,hb-1,4,1,"black")
      fill_rect(26,hb,1,1,"black")
      fill_rect(27,hb+1,1,1,"black")
      hb+=1
  ship(hb)
  if keydown(KEY_OK) or keydown(KEY_TOOLBOX):
    if con!=cadence:con+=1
    else:
      tir+=1
      ltir.append(hb)
      lltir.append(27)
      con=0
  for i in range(0,tir,1):
    fill_rect(lltir[i]-3,ltir[i],2,4,'black')
    fill_rect(lltir[i],ltir[i],4,4,'orange')
    lltir[i]+=2
    if lltir[i]>322:
      pou.append(i)
  if len(pou)>0:
    pou.sort()
    for i in range(len(pou)):
      fill_rect(lltir[pou[i]-i]-2,ltir[pou[i]-i],4,4,'black')
      lltir.pop(pou[i]-i)
      ltir.pop(pou[i]-i)
      tir-=1
    pou.clear()
  wai+=1
  if wai>=dif and fine==True:
    lwai.append(randint(2,214))
    llwai.append(322)
    llife.append(life)
    wai=0
  for j in range(len(llwai)):
    fill_rect(llwai[j]+4+g,lwai[j],g+1,7+fe,'black')
    theco=colo[llife[j]]
    fill_rect(llwai[j],lwai[j],7+fe,7+fe,theco)
    llwai[j]-=g
    if llwai[j]<-6:
      b=True
      poub.append(j)
      score_bl-=1 
    if 2<llwai[j]-20<4+g and -7<lwai[j]-hb<7:
      your_life-=1
      draw_string("you lost 1 health",95,100,colo[life],"black")
      sleep(1)
      if your_life>=1:
        fill_rect(0,0,320,230,"black")
      if your_life<=0:
        explose(hb)
        sleep(0.00001)
        fill_rect(50,50,200,120,"grey");fill_rect(52,52,196,116,(90,20,20));draw_string("GAME OVER !",102,60,"white",(90,20,20));draw_string("SCORE : "+str(score),60,100,"white",(90,20,20));draw_string("BLOCK : "+str(score_bl),61,130,"white",(90,20,20))
        sleep(2)
        br=True
    if br:break
    for defe in range(tir):
      if -3<llwai[j]-lltir[defe]<3 and -7<lwai[j]-ltir[defe]<4:
        llife[j]-=dega
        fill_rect(lltir[defe]-1,ltir[defe],7,5,(0,0,0))
        pou.append(defe)
        if llife[j]<=0:
          b=True
          poub.append(j)    
  if br:break
  if b:
    poub.sort()
    for z in range(len(poub)):
      score_bl+=1
      score+=30*life
      comptage+=20
      zy=poub[z]
      fill_rect(llwai[zy-z]+g,lwai[zy-z],8,7,"black")
      llwai.pop(zy-z)
      lwai.pop(zy-z)
      llife.pop(zy-z)
      b=False
    poub.clear()
  if comptage>(7*life+1)*1000:
    if life!=18:life+=1
    else:
      fill_rect(50,50,200,120,"grey");fill_rect(52,52,196,116,(210,100,0));draw_string("YOU ARE A WINNER !",60,60,"white",(210,100,0));draw_string("SCORE : "+str(score),60,100,"white",(210,100,0));draw_string("BLOCK : "+str(score_bl),61,130,"white",(210,100,0))
      br=True
    if br:break
    draw_string("wave {}".format(life),100,100,colo[life],"black")
    sleep(0.8)
    fill_rect(0,0,400,400,"black")
    dif-=4
    if dif<=1:
      g=4;dif=1;wai-=6
  score+=1
  comptage+=1
  if realcomtage>=(5*life+50*your_life+500)and fine==True:
    cad=True
    lcad=randint(3,214)
    llcad=330
    realcomtage=0
  if cad:
      llcad-=1
      fill_rect(llcad+7,lcad-3,1,7,colo[0]);fill_rect(llcad+5,lcad-4,1,1,colo[0]);fill_rect(llcad+4,lcad-5,1,1,colo[0]);fill_rect(llcad,lcad-3,3,3,colo[1]);fill_rect(llcad,lcad+1,3,3,colo[1]);fill_rect(llcad+4,lcad-3,3,3,colo[1]);fill_rect(llcad+4,lcad+1,3,3,colo[1]);fill_rect(llcad,lcad,7,1,colo[5]);fill_rect(llcad+3,lcad-5,1,9,colo[5]);fill_rect(llcad+2,lcad-4,3,1,colo[5])
      if llcad==-8:cad=False
      if llcad==20 and -7<lcad-hb<6:
        augm=randint(-1,3)
        fill_rect(llcad,lcad-5,7,9,colo[0])
        if augm==0:your_life+=1
        elif augm==2:
          con-=50
          cadence=cadence-8 if cadence>9 else 3 
          nb_cadence+=1
        else:dega+=1;lcad=0;llcad=0
        cad=False
  draw_string(str(score),270,0,(50,200,250),(0,0,0))
  for draw_life in range(your_life):
    fill_rect(180+(9*draw_life)+1,6,2,1,"pink");fill_rect(180+(9*draw_life)+4,6,2,1,"pink");fill_rect(180+(9*draw_life),7,7,2,"pink");fill_rect(180+(9*draw_life)+1,9,5,1,"pink");fill_rect(180+(9*draw_life)+2,10,3,1,"pink");fill_rect(180+(9*draw_life)+3,11,1,1,"pink")
  for draw_cadence in range(nb_cadence):
    fill_rect(260+(9*draw_cadence),207,1,9,(200,150,0));fill_rect(260+(9*draw_cadence)+1,208,1,7,(200,150,0));fill_rect(260+(9*draw_cadence)+2,212,1,2,(200,150,0));fill_rect(260+(9*draw_cadence)+3,211,1,2,(200,150,0));fill_rect(260+(9*draw_cadence)+4,210,1,9,(200,150,0));fill_rect(260+(9*draw_cadence)+5,209,1,11,(200,150,0))
  if keydown(KEY_EXE) or keydown(KEY_HOME):
    fill_rect(50,50,200,120,"grey");fill_rect(52,52,196,116,(20,20,50));draw_string("GAME PAUSE",100,60,"white",(20,20,50));draw_string("SCORE : {}".format(score),60,100,"white",(20,20,50));draw_string("BLOCK : {}".format(score_bl),61,130,"white",(20,20,50));pause=True
    while keydown(KEY_EXE) or keydown(KEY_HOME):sleep(0.05)
    while pause:
      if keydown(KEY_EXE) or keydown(KEY_OK) or keydown(KEY_HOME):
        pause=False
        while keydown(KEY_EXE) or keydown(KEY_OK) or keydown(KEY_HOME):sleep(0.05)
        fill_rect(49,49,300,200,colo[0])

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.