ski_alpha.py

Created by mael57703

Created on January 19, 2026

16.3 KB

C’est un jeu de ski créé directement sur la calculatrice ( ça a donc été un peu long ) ! Bref, le but est de descendre à ski en esquivant plusieurs obstacles tels que des buissons, des arbres, des rochers ou même d’autres skieurs. On peut aussi prendre des tremplins qui nous propulsent !!


#Modules

from math import *
from turtle import *
from random import *
from kandinsky import *
from ion import *
from time import *

#GRAPHISME

#Couleurs

blanc_cas=(255,250,245)
bleu_c=(180,210,255)
bleu_f=(30,30,255)
gris=(120,130,135)
gris_f=(50,60,65)
jaune=(255,210,30)
vert=(0,255,130)
vert_f=(0,120,40)
marron=(150,70,30)
beige=(250,220,180)
couleur=[bleu_f,'blue',bleu_c,vert_f,'green',vert,jaune,'yellow',beige,'brown',marron,'orange','red','pink','purple','white',gris,'gray',gris_f,'black']
couleurp=[beige,jaune,marron]
tch_c_tt=0
tch_c_cps=12
tch_c_jmb=18
tch_c_ski=5

#Triangle

def triangle(A,B,C,couleur) :
  points = sorted([A,B,C],key=lambda p: p[1])
  (x1,y1),(x2,y2),(x3,y3) = points
  def interp_x(xa,ya,xb,yb,y) :
    if yb==ya :
      return xa
    return xa+(y-ya)*(xb-xa)/(yb-ya)
  for y in range(int(y1),int(y3)+1) :
    if y<y2 :
      xa=interp_x(x1,y1,x2,y2,y)
      xb=interp_x(x1,y1,x3,y3,y)
    else :
      xa=interp_x(x2,y2,x3,y3,y)
      xb=interp_x(x1,y1,x3,y3,y)
    if xa>xb :
      xa,xb=xb,xa
    fill_rect(int(xa),y,int(xb-xa),1,couleur)
      
#Disque

def disque(cx,cy,r,couleur) :
  for y in range(cy-r,cy+r+1) :
    dy=y-cy
    if abs(dy)>r :
      continue
    dx=sqrt(r**2-dy**2)
    x_gauche=int(cx-dx)
    x_droite=int(cx+dx)
    fill_rect(x_gauche,y,x_droite-x_gauche+1,1,couleur)

#Personnage

def peter(x,y) :
  disque(x+10,y+2,2,couleurp[tch_c_tt])
  fill_rect(x+8,y+4,4,6,couleur[tch_c_cps])
  fill_rect(x+7,y+4,6,4,couleur[tch_c_cps])
  fill_rect(x+8,y+10,4,4,couleur[tch_c_jmb])
  
def peter_1(x,y) :
  fill_rect(x+8,y+14,4,6,couleur[tch_c_ski])
  peter(x,y)
  
def peter_2(x,y) :
  triangle((x+8,y+14),(x+8,y+18),(x+4,y+18),couleur[tch_c_ski])
  triangle((x+8,y+14),(x+12,y+14),(x+8,y+18),couleur[tch_c_ski])
  triangle((x+12,y+12),(x+14,y+12),(x+12,y+14),couleur[tch_c_ski])
  peter(x,y)
  
def peter_3(x,y) :
  triangle((x+12,y+14),(x+12,y+18),(x+16,y+18),couleur[tch_c_ski])
  triangle((x+12,y+14),(x+8,y+14),(x+12,y+18),couleur[tch_c_ski])
  triangle((x+8,y+12),(x+6,y+12),(x+8,y+14),couleur[tch_c_ski])
  peter(x,y)

def mega_peter() :
  disque(220,40,20,couleurp[tch_c_tt])
  fill_rect(180,60,80,40,couleur[tch_c_cps])
  fill_rect(200,100,40,40,couleur[tch_c_cps])
  fill_rect(200,140,40,40,couleur[tch_c_jmb])
  triangle((200,140),(200,180),(160,140),couleur[tch_c_ski])
  triangle((200,180),(240,180),(240,220),couleur[tch_c_ski])
  triangle((240,180),(240,220),(280,220),couleur[tch_c_ski])

#Intro

def intro() :
  fill_rect(0,0,320,240,gris_f)
  fill_rect(5,5,310,213,blanc_cas)
  fill_rect(120,30,80,35,gris_f)
  fill_rect(140,180,100,20,'black')
  x=130
  for i in range(5) :
    x+=20
    fill_rect(x,180,10,10,'white')
  x=120
  for i in range(5) :
    x+=20
    fill_rect(x,190,10,10,'white')
  draw_string("SKI",int(142.5),40,'white',gris_f)
  draw_string("BY Mael",10,197,'black',blanc_cas)
  draw_string("_",40,150,'black',blanc_cas)
  peter_3(40,60)
  buisson(5,20)
  buisson(15,20)
  buisson(295,5)
  buisson(5,120)
  sapin(80,5)
  sapin(240,40)
  trou(260,80)
  trou(80,100)
  rocher(200,120)
  pioupiou(140,140)
  pioupiou(280,160)
  forme_coeur(60,160,'red')
  forme_coeur(80,160,'red')
  k=False
  while k==False :
    if keydown(KEY_EXE) :
      k=True
    sleep(0.1)
  sleep(0.2)

#Cartes

def carte_1(y) :
  fill_rect(0,y,320,800,blanc_cas)
  fill_rect(0,y+680,320,30,'black')
  x=-10
  for i in range(16):
    x+=20
    fill_rect(x,y+680,10,10,'white')
  x=-20
  for i in range(16):
    x+=20
    fill_rect(x,y+690,10,10,'white')
  sapin(80,y+100)
  sapin(140,y+160)
  sapin(260,y+180)
  sapin(160,y+360)
  sapin(20,y+440)
  sapin(80,y+600)
  sapin(20,y+660)
  
  buisson(240,y+60)
  buisson(200,y+220)
  buisson(20,y+220)
  buisson(100,y+280)
  buisson(120,y+280)
  buisson(280,y+520)
  buisson(300,y+520)
  
  trou(280,y+40)
  trou(140,y+60)
  trou(300,y+120)
  trou(40,y+180)
  trou(280,y+400)
  trou(100,y+420)
  trou(240,y+640)
  
  rocher(240,y+100)
  rocher(40,y+160)
  rocher(300,y+240)
  rocher(40,y+320)
  rocher(160,y+520)
  rocher(20,y+560)
  
  pioupiou(20,y+80)
  pioupiou(180,y+120)
  pioupiou(100,y+220)
  pioupiou(220,y+280)
  pioupiou(180,y+420)
  pioupiou(280,y+460)
  pioupiou(220,y+560)
  pioupiou(40,y+620)
  
  rampe(180,y+40)
  rampe(180,y+60)
  rampe(120,y+120)
  rampe(0,y+240)
  rampe(0,y+260)
  rampe(0,y+280)
  rampe(240,y+340)
  rampe(240,y+360)
  rampe(100,y+380)
  rampe(200,y+480)
  rampe(60,y+500)
  rampe(60,y+520)
  rampe(180,y+620)

#Pts de vie

def forme_coeur(x,y,couleur) :
  triangle((x,y+5),(x+20,y+5),(x+10,y+20),couleur)
  disque(x+5,y+5,5,couleur)
  disque(x+15,y+5,5,couleur)
  
def coeur(pts_vie) :
  fill_rect(240,0,80,30,gris_f)
  for i in range(1,pts_vie+1) :
    forme_coeur(220+(i*25),5,'red')
  
niveau=["Facile","Moyen","Difficile"]
tch_niv=0

#Fleche retour

def retour() :
  triangle((10,15),(20,5),(20,25),'black')
  fill_rect(20,10,30,10,'black')

#Fleche skin

def fleche_skin(y) :
  triangle((100,y),(100,y+20),(120,y+10),bleu_c)
  fill_rect(70,y+5,30,10,bleu_c)

#Ecrans d arrivee et de mort

def arrive() :
  fill_rect(60,90,190,35,vert)
  draw_string("Vous avez GAGNE !",70,100,jaune,vert)

def mort() :
  fill_rect(0,80,320,80,'black')
  fill_rect(0,90,320,60,'red')
  draw_string("Vous etes MORT !",90,110,'white','red')

#Decors cartes

def rampe(x,y) :
  triangle((x,y),(x+20,y),(x+10,y+20),bleu_c)
  triangle((x+5,y),(x+15,y),(x+10,y+10),blanc_cas)

def trou(x,y) :
  disque(x+10,y+10,10,gris_f)
  disque(x+10,y+10,int(7.5),gris)

def buisson(x,y) :
  fill_rect(x,y+15,20,5,vert_f)
  disque(x+5,y+15,5,vert_f)
  disque(x+int(12.5),y+15,int(7.5),vert_f)
  disque(x+int(7.5),y+10,int(2.5),vert_f)
  fill_rect(x+5,y+20,15,int(3),blanc_cas)

def sapin(x,y) :
  fill_rect(x+int(7.5),y+15,5,5,marron)
  triangle((x+10,y),(x+5,y+5),(x+15,y+5),vert_f)
  triangle((x+10,y),(x+5,y+10),(x+15,y+10),vert_f)
  triangle((x+10,y),(x+5,y+15),(x+15,y+15),vert_f)
  
def rocher(x,y) :
  triangle((x+10,y+5),(x,y+15),(x+15,y+15),gris_f)
  fill_rect(x,y+15,20,5,gris)
  disque(x+15,y+15,5,gris)
  triangle((x+int(2.5),y+5),(x,y+15),(x+5,y+15),gris)

def pioupiou(x,y) :
  disque(x+10,y+4,2,beige)
  fill_rect(x+8,y+6,4,8,gris_f)
  fill_rect(x+9,y+14,2,4,jaune)
  fill_rect(x+4,y+18,10,1,bleu_f)

#MENU

#Variables

tch_menu=1
menu=True

#Decors

sleep(0.2)
intro()
while menu==True :
  if keydown(KEY_BACKSPACE) :
    fill_rect(0,0,320,240,'black')
    draw_string("Merci d avoir joue !",70,90,'white','black')
    draw_string("A bientot !",110,120,'white','black')
    sleep(2.5)
    fill_rect(0,0,320,240,'white')
    break
  fill_rect(0,0,320,240,blanc_cas)
  if tch_menu==1 : 
     draw_string("> JEU",80,75,bleu_f,blanc_cas)
     draw_string("PARAMETRES",100,100,bleu_f,blanc_cas)
     draw_string("AUTRES JEUX",100,125,bleu_f,blanc_cas)
  if tch_menu==2 :
    draw_string("JEU",100,75,bleu_f,blanc_cas)
    draw_string("> PARAMETRES",80,100,bleu_f,blanc_cas)
    draw_string("AUTRES JEUX",100,125,bleu_f,blanc_cas)
  if tch_menu==3 :
    draw_string("JEU",100,75,bleu_f,blanc_cas)
    draw_string("PARAMETRE5",100,100,bleu_f,blanc_cas)
    draw_string("> AUTRES JEUX",80,125,bleu_f,blanc_cas)
      
#Detection de touches

  if keydown(KEY_UP) :
    tch_menu-=1
  if keydown(KEY_DOWN) :
    tch_menu+=1
  if tch_menu<1 :
    tch_menu=3
  if tch_menu>3 :
    tch_menu=1
  if keydown(KEY_EXE) :

#AUTRES JEUX

    if tch_menu==3 :

#Variables

      tch_autre=1

#Decors

      sleep(0.2)
      while True :
        fill_rect(0,0,320,240,gris_f)
        draw_string("Par le meme",90,50,'white',gris_f)
        draw_string("createur :",100,65,'white',gris_f)
        retour()
        if tch_autre==1 :
          draw_string("> FILM",80,100,'white',gris_f)
          draw_string("CLICKER",100,125,'white',gris_f)
          draw_string("CALCUL",100,150,'white',gris_f)
        if tch_autre==2 :
          draw_string("FILM",100,100,'white',gris_f)
          draw_string("> CLICKER",80,125,'white',gris_f)
          draw_string("CALCUL",100,150,'white',gris_f)
        if tch_autre==3 :
          draw_string("FILM",100,100,'white',gris_f)
          draw_string("CLICKER",100,125,'white',gris_f)
          draw_string("> CALCUL",80,150,'white',gris_f)

#Detection de touches

        if keydown(KEY_UP) :
          tch_autre-=1
        if keydown(KEY_DOWN) :
          tch_autre+=1
        if tch_autre<1 :
          tch_autre=3
        if tch_autre>3 :
          tch_autre=1
        if keydown(KEY_EXE) :
          if tch_autre==1 :
            from film import *
          if tch_autre==2 :
            from clicker import *
          if tch_autre==3 :
            from calcul import *
        if keydown(KEY_ANS) :
          break
        sleep(0.15)

#PARAMETRES

    if tch_menu==2 :

#Variables
    
      menu=False
      tch_par=1
    
#Decors
      
      sleep(0.2)  
      while menu==False :
        fill_rect(0,0,320,240,gris_f)
        retour()
        if tch_par==1 :
          draw_string("> NIVEAU : "+niveau[tch_niv],80,75,'white',gris_f)
          draw_string("SKIN",100,100,'white',gris_f)
          draw_string("TOUCHES",100,125,'white',gris_f)
          draw_string("CODE",100,150,'white',gris_f)
        if tch_par==2 :
          draw_string("NIVEAU : "+niveau[tch_niv],100,75,'white',gris_f)
          draw_string("> SKIN",80,100,'white',gris_f)
          draw_string("TOUCHES",100,125,'white',gris_f)
          draw_string("CODE",100,150,'white',gris_f)
        if tch_par==3 :
          draw_string("NIVEAU : "+niveau[tch_niv],100,75,'white',gris_f)
          draw_string("SKIN",100,100,'white',gris_f)
          draw_string("> TOUCHES",80,125,'white',gris_f)
          draw_string("CODE",100,150,'white',gris_f)
        if tch_par==4 :
          draw_string("NIVEAU : "+niveau[tch_niv],100,75,'white',gris_f)
          draw_string("SKIN",100,100,'white',gris_f)
          draw_string("TOUCHES",100,125,'white',gris_f)
          draw_string("> CODE",80,150,'white',gris_f)

#Detection de touches

        if keydown(KEY_UP) :
          tch_par-=1
        if keydown(KEY_DOWN) :
          tch_par+=1
        if tch_par<1 :
          tch_par=2
        if tch_par>2 :
          tch_par=1
        if keydown(KEY_ANS) :
          menu=True
          break
        if tch_par==1 :
          if keydown(KEY_PLUS) or keydown(KEY_RIGHT):
            tch_niv+=1
            sleep(0.2)
          if keydown(KEY_MINUS) or keydown(KEY_LEFT):
            tch_niv-=1
            sleep(0.2)
          if tch_niv>2 :
            tch_niv=0
          if tch_niv<0 :
            tch_niv=2
        sleep(0.1)
        if keydown(KEY_EXE) :

#SKIN

          if tch_par==2 :

#Variables

            y=30
            tch_skin=1

#Decors

            while True :
              fill_rect(0,0,320,240,gris_f)
              retour()
              fleche_skin(y)
              fill_rect(150,10,140,230,blanc_cas)
              mega_peter() 

#Detection de touches

              if keydown(KEY_UP) :
                tch_skin-=1
                sleep(0.1)
              if keydown(KEY_DOWN) :
                tch_skin+=1
                sleep(0.1)
              if tch_skin<1 :
                tch_skin=4
              if tch_skin>4 :
                tch_skin=1
              if keydown(KEY_ANS) :
                sleep(0.1)
                break
              
              if tch_skin==1 :
                y=30
                if keydown(KEY_RIGHT) :
                  tch_c_tt+=1
                if keydown(KEY_LEFT) :
                  tch_c_tt-=1
                sleep(0.1)
              if tch_skin==2 :
                y=90
                if keydown(KEY_RIGHT) :
                  tch_c_cps+=1
                if keydown(KEY_LEFT) :
                  tch_c_cps-=1
                sleep(0.1)
              if tch_skin==3 :
                y=150
                if keydown(KEY_RIGHT) :
                  tch_c_jmb+=1
                if keydown(KEY_LEFT) :
                  tch_c_jmb-=1
                sleep(0.1)
              if tch_skin==4 :
                y=190
                if keydown(KEY_RIGHT) :
                  tch_c_ski+=1
                if keydown(KEY_LEFT) :
                  tch_c_ski-=1
                sleep(0.1)
              
              if tch_c_tt<0 :
                tch_c_tt=2
              if tch_c_tt>2 :
                tch_c_tt=0
              if tch_c_cps<0 :
                tch_c_cps=19
              if tch_c_cps>19 :
                tch_c_cps=0
              if tch_c_jmb<0 :
                tch_c_jmb=19
              if tch_c_jmb>19 :
                tch_c_jmb=0
              if tch_c_ski<0 :
                tch_c_ski=19
              if tch_c_ski>19 :
                tch_c_ski=0
              sleep(0.1)

#MENU CARTES

    if tch_menu==1 :

#Variables

      carte=1

#Decors

      sleep(0.2)
      while True :
        if carte==1 :
          carte_1(0)
          fill_rect(0,180,320,60,gris_f)
          draw_string("CARTE 1",125,195,'white',gris_f)
          triangle((290,150),(310,160),(290,170),jaune)
        if carte==2 :
          fill_rect(0,0,320,180,gris)
          draw_string("BIENTOT",120,80,gris,'black')
          draw_string("DISPONIBLE",110,95,gris,'black')
          fill_rect(0,180,320,60,gris_f)
          draw_string("CARTE 2",125,195,'white',gris_f)
          triangle((30,150),(10,160),(30,170),jaune)
        retour()
        
#Detection de touches

        if keydown(KEY_RIGHT) :
          carte=2
        if keydown(KEY_LEFT) :
          carte=1
        if keydown(KEY_ANS) :
          break
        if keydown(KEY_EXE) :
          
#JEU

          if carte==1 :
            
#Variables

            x=160
            y=0
            pos=1
            yc=0
            pts_vie=3
            degat=tch_niv+1
            pos_yc0=[(80,100),(140,160),(240,60),(280,40),(140,60),(300,120),(240,100),(40,160),(20,80),(180,120)]
            pos_yc120=[(260,60),(200,100),(20,100),(100,160),(40,60),(300,120),(100,100),(220,160),(120,160)]
            pos_yc240=[(160,120),(280,160),(40,80)]
            pos_yc360=[(20,80),(280,160),(300,160),(100,60),(160,160),(180,80),(280,100)]
            pos_yc480=[(80,100),(20,180),(240,160),(20,80),(220,80),(40,140)]
            
            pos_t1_0=[(120,120)]
            pos_t2_0=[(180,40)]
            pos_t3_120=[(0,120)]
            pos_t1_240=[(100,140)]
            pos_t2_240=[(240,100)]
            pos_t1_360=[(200,120)]
            pos_t2_360=[(60,140)]
            pos_t1_480=[(180,140)]

#Decors

            sleep(0.2)
            carte_1(yc)
            retour()
            peter(x,y)
            coeur(3)
            sleep(1)
            while True :
              carte_1(yc)
              retour()
              coeur(pts_vie)
              if pos==1 :
                peter_1(x,y)
              if pos==2 :
                peter_2(x,y)
              if pos==3 :
                peter_3(x,y)

#Detection de touches

              if keydown(KEY_DOWN) :
                y+=20
                pos=1
              if keydown(KEY_LEFT) :
                y+=20
                x-=20
                pos=2
              if keydown(KEY_RIGHT) :
                y+=20
                x+=20
                pos=3
              if keydown(KEY_ANS) :
                break
              
#Detection de position              
              
              if (yc==0 and (x,y) in pos_yc0) or (yc==-120 and (x,y) in pos_yc120) or (yc==-240 and (x,y) in pos_yc240) or (yc==-360 and (x,y) in pos_yc360) or (yc==-480 and (x,y) in pos_yc480) :
                pts_vie=pts_vie-degat
                y+=20
              
              if (yc==0 and (x,y) in pos_t1_0) or (yc==-240 and (x,y) in pos_t1_240) or (yc==-360 and (x,y) in pos_t1_360) or (yc==-480 and (x,y) in pos_t1_480) :
                y+=40
                
              if (yc==0 and (x,y) in pos_t2_0) or (yc==-240 and (x,y) in pos_t2_240) or (yc==-360 and (x,y) in pos_t2_360) or (yc==-360 and (x,y) in pos_t2_360) :
                y+=80
                
              if (yc==-120 and (x,y) in pos_t3_120) :
                y+=120
                
              if x>300 :
                pts_vie=pts_vie-degat
                x=280
              if x<0 :
                pts_vie=pts_vie-degat
                x=20
              
              if y>=180 and yc>(-480) :
                yc-=120
                y=60
              
              if yc<=(-480) and y==220 :
                arrive()
                sleep(2)
                break
              if pts_vie<=0 :
                coeur(0)
                mort()
                sleep(2)
                break
              sleep(0.15)
        sleep(0.15)
  sleep(0.15)

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.