geomerty_dash.py

Created by dkfe123

Created on April 14, 2025

3.28 KB

ok ou flèche haut pour sauter. Touchez le vert pour gagner.


from math import *
from kandinsky import *
from ion import *
from time import *
def init():
  return(-250,100,0,0,True,0,0)
x,y,sc,s,p,e,cy=init()
c,f=(0,0,0),(0,0,125)
fill_rect(0,0,320,240,f)
def carteinit():
  return([0,1,-50,150,100,20,3,50,170,20,0,3,70,170,20,0,3,150,170,20,0,3,250,170,20,0,3,350,170,20,0,1,370,150,130,20,1,500,130,20,20,1,560,110,20,20,1,620,90,20,20,1,680,70,20,20,1,750,90,150,80,1,900,120,350,50,1,1250,90,100,80,1,950,65,100,20,1,1100,65,100,20,1,1400,70,20,20,1,1460,50,20,20,1,1520,70,20,20,1,1560,50,20,20,1,1650,0,20,20,1,1600,90,400,130,1,1700,0,250,50,1,1800,50,100,19,1,1970,110,30,20,1,2020,130,30,20,1,2100,130,150,20,3,2180,130,20,20,1,2300,100,50,20,2,2350,0,10,100])
carte=carteinit()
def niv(carte,cy):
  draw_string(str(round(sc)),0,0,c,f)
  fill_rect(0,170+cy,320,72,(0,0,0))
  for i in range(1,len(carte),5):
    if carte[i+1]<x+300 and carte[i+1]-x+carte[i+3]>0:
      if carte[i]==1:
        fill_rect(floor(carte[i+1]-x),floor(carte[i+2]+cy),carte[i+3],carte[i+4],c)
        fill_rect(floor(carte[i+1]-x+carte[i+3]),floor(carte[i+2]),floor(v),carte[i+4],f)
        fill_rect(floor(carte[i+1]-x),floor(carte[i+2]-ac),round(ac-cy),carte[i+4],f)
      elif carte[i]==2:
        fill_rect(floor(carte[i+1]-x),floor(carte[i+2]+cy),carte[i+3],carte[i+4],(0,255,0))
        fill_rect(floor(carte[i+1]-x+carte[i+3]),floor(carte[i+2]+cy),floor(v),carte[i+4],f)
      else:
        n=round(7-2*carte[i])
        xx,yy=floor(carte[i+1]-x),floor(carte[i+2]+cy)
        fill_rect(xx,yy,20,5,c)
        fill_rect(xx+21,yy,v,5,f)
        fill_rect(xx+3,yy-5*n,16,5,c)
        fill_rect(xx+20,yy-5*n,v,5,f)
        fill_rect(xx+5,yy-10*n,12,5,c)
        fill_rect(xx+17,yy-10*n,v,5,f)
        fill_rect(xx+7,yy-15*n,6,5,c)
        fill_rect(xx+14,yy-15*n,v,5,f)
def to(carte):
  if y>150:
    return(0,1,0)
  for i in range(1,len(carte),5):
    if carte[i+1]<x+320:
      if carte[i]<3:
        if x+20>carte[i+1] and x<carte[i+1]+carte[i+3]:
          if y+20>carte[i+2] and y<carte[i+2]+carte[i+4]:
            if carte[i]==1:
              return(0,1,0)
            elif carte[i]==2:
              return(0,0,1)
      if carte[i]==3:
        if carte[i+1]<x+7 and carte[i+2]<y+30 and y<carte[i+2]+20:
          return(1,0,0)
      if carte[i]==4:
        if carte[i+1]-x<7 and carte[i+2]+20>y and carte[i+2]<y+30:
          return(1,0,0)
  return(0,0,0)
def supp(carte,x):
  for i in range(1,len(carte),5):
    if i<=len(carte)-5:
      if carte[i+1]+carte[i+3]-x<-1:
        for w in range(5):
          carte.pop(i)
  return carte
g,ke,pa,v=0,1,0,1
while p:
  ac=cy
  cy=floor(130-y)
  cy=0
  supp(carte,x)
  niv(carte,cy)
  x,sc=x+v,sc+0.1
  mo,t,ga=to(carte)
  if ga==1:
    g=1
  if t==1:
    break
  m,t,ay,e=0,0,y,e+0.1
  y=y+e
  mo,t,ga=to(carte)
  if ga==1:
    g=1
  if mo==1:
    m=1
  if t==1:
    if e<0:
      m=1
    else:
      while t==1:
        y=y-0.08
        mo,t,ga=to(carte)
    e,s=0,0
  if s==0:
    if keydown(KEY_OK) or keydown(KEY_UP):
      y=y+1
      mo,t,ga=to(carte)
      if t==1:
        s,e=1,-3
      y=y-1
  if m==1 or g==1:
    p=False
  fill_rect(0,floor(ay),20,21,f)
  fill_rect(0,floor(y),20,21,c)
if g==0:
  draw_string("Perdu...",120,110,c,f)
else:
  draw_string("Gagne !",120,110,c,f)
draw_string("Score :",120,130,c,f)
draw_string(str(round(sc)),190,130,c,f)

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.