snack.py

Created by opktmgb

Created on April 12, 2022

2.52 KB

Un snack un peu plus évolué avec différents modes de jeux


from math import *;from time import *;from kandinsky import *;from ion import *;from random import *
best,cl,n_apple=[0,0,0],[(250,0,0),(250,250,0),(0,250,0),(0,240,240),(0,0,250),(200,0,200)],3
def salon(mode=0,score=0,color=2,ey=0):
  if best[mode]<score:best[mode]=score
  draw_string("survie (1) :"+str(best[0]),50,50);draw_string("immortel (2) :"+str(best[1]),50,70);draw_string("infini (3) :"+str(best[2]),50,90)
  while True:
    for i in range(6):
      fill_rect(30+i*30,190,20,20,cl[i])
    fill_rect(40,160,100,10,cl[color]);fill_rect(136,162,2,2,cl[ey]);fill_rect(136,166,2,2,cl[ey])
    if keydown(KEY_RIGHT):
      while True:
        if keydown(KEY_RIGHT)==False:color=color+1 if color<5 else 0;break
    if keydown(KEY_DOWN):
      while True:
        if keydown(KEY_DOWN)==False:ey=ey+1 if ey<5 else 0;break 
    if keydown(KEY_ONE):mode=0;break
    if keydown(KEY_TWO):mode=1;break
    if keydown(KEY_THREE):mode=2;draw_string("map infini ne te perds pas!",10,110);sleep(1);break
  draw_string("Press EXE to left...",110,200);sleep(1);fill_rect(0,0,320,222,"white");game(mode,color,ey)
  
def game(mode,color,ey):
  a,arec,orec,aple,score,cass=[(KEY_UP,0,-10),(KEY_DOWN,0,10),(KEY_RIGHT,10,0),(KEY_LEFT,-10,0)],-10,0,(20,100),7,[(110,100),(120,100),(130,100)]
  while True:
    for i in range(len(cass)):
      if i>(3+score):fill_rect(cass[i-1][0],cass[i-1][1],10,10,"white");fill_rect(cass[i-1][0]+2+int((cass[i-2][0]-cass[i-1][0])//2.5),cass[i-1][1]+2+int((cass[i-2][1]-cass[i-1][1])//2.5),6,6,cl[color]);fill_rect(cass[i][0],cass[i][1],10,10,"white");cass.pop(i)
      else:fill_rect(cass[i][0],cass[i][1],10,10,cl[color]);fill_rect(cass[0][0]+4+arec//5+orec//5,cass[0][1]+4+arec//5+orec//5,2,2,cl[ey]);fill_rect(cass[0][0]+4+arec//5-orec//5,cass[0][1]+4-arec//5+orec//5,2,2,cl[ey])
    if (0<=cass[0][0]+arec<320 and 0<=cass[0][1]+orec<220) or mode==2:cass.insert(0,(cass[0][0]+arec,cass[0][1]+orec))
    elif mode==0:mode=salon(mode,score-7,color,ey);break
    if mode==0 and cass[0]in cass[1:] or keydown(KEY_EXE):salon(mode,score-7,color,ey);break
    for i in range(4):
      if keydown(a[i][0]) and a[i][1]+arec!=0:arec=a[i][1];orec=a[i][2]
    if cass[0][0]==aple[0] and cass[0][1]==aple[1]:score+=1;aple=(randint(0,31)*10,randint(0,20)*10)
    fill_rect(aple[0],aple[1]+1,10,8,"red");fill_rect(aple[0]+2,aple[1],6,2,(0,230,0));fill_rect(aple[0]+4,aple[1]+1,2,3,(0,230,0));sleep(0.1-(0.001*(((score-0.5)/(2))-((1)/(score+0.5))+3)));draw_string(str(score-7),315-len(str(score-7)*9),3)
    fill_rect(aple[0]+1,aple[1]+9,8,1,"red")

salon()

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.