plateforme.py

Created by pommecrafter

Created on June 26, 2025

4.72 KB

en cour de developpement


from kandinsky import *
from ion import *
from time import *
locate="menu"
bg_menu=[30,30,30]
txt_menu=[0,250,0]
select=1
level=1
sky=[150,250,250]
x=30
y=140
bloc_color=[220,0,150]
bG_color=[60,60,60]
ball_color=[255,200,0]
line_color=[255,255,255]
pad_color=[255,255,255]
def menu(select,txt_menu,bg_menu):
  locate="menu"
  fill_rect(0,0,320,222,bg_menu)
  draw_string("plateformer 2",100,20,(250,250,250),bg_menu)
  draw_string("play",140,100,txt_menu,bg_menu)
  draw_string("level",135,150,(250,250,250),bg_menu)

def transition():
  for j in (line_color,bG_color):
    for i in range(0,340,20):
      fill_rect(0,0,i,222,j)
      sleep(0.01)

def level():
  locate="level"
  fill_rect(0,0,320,222,bg_menu)
  draw_string("1",20,100,txt_menu,bg_menu)
  draw_string("2",70,100,(250,250,250),bg_menu)
  draw_string("3",120,100,(250,250,250),bg_menu)
  draw_string("4",170,100,(250,250,250),bg_menu)
  draw_string("5",220,100,(250,250,250),bg_menu)
def niv1(x,y,sky):
  fill_rect(0,0,320,222,sky)
  fill_rect(0,170,320,222,txt_menu)
  fill_rect(0,0,50,50,'yellow')
  fill_rect(x,y,30,30,bloc_color)
menu(select,txt_menu,bg_menu)
while 1:
  if locate=="menu":
    if keydown(KEY_DOWN):
      select=2
      draw_string("play",140,100,(250,250,250),bg_menu)
      draw_string("level",135,150,txt_menu,bg_menu)
      print(select)
    if keydown(KEY_UP):
      select=1
      draw_string("play",140,100,txt_menu,bg_menu)
      draw_string("level",135,150,(250,250,250),bg_menu)
      print(select)
    if keydown(KEY_EXE) and select==1:
      transition()
      niv1(x,y,sky)
      locate="niv1"
    if keydown(KEY_EXE) and select==2:
      transition()
      level()
      locate="level"
      select=1
  if locate=="level":
    if keydown(KEY_RIGHT):
      select=select+1
    if keydown(KEY_LEFT):
      select=select-1
    if select==0:
      select=5
    if select==6:
      select=1
    if select==1:
      draw_string("1",20,100,txt_menu,bg_menu)
      draw_string("2",70,100,(250,250,250),bg_menu)
      draw_string("3",120,100,(250,250,250),bg_menu)
      draw_string("4",170,100,(250,250,250),bg_menu)
      draw_string("5",220,100,(250,250,250),bg_menu)
      sleep(0.1)
    elif select==2:
      draw_string("1",20,100,(250,250,250),bg_menu)
      draw_string("2",70,100,txt_menu,bg_menu)
      draw_string("3",120,100,(250,250,250),bg_menu)
      draw_string("4",170,100,(250,250,250),bg_menu)
      draw_string("5",220,100,(250,250,250),bg_menu)
      sleep(0.1)
    elif select==3:
      draw_string("1",20,100,(250,250,250),bg_menu)
      draw_string("2",70,100,(250,250,250),bg_menu)
      draw_string("3",120,100,txt_menu,bg_menu)
      draw_string("4",170,100,(250,250,250),bg_menu)
      draw_string("5",220,100,(250,250,250),bg_menu)
      sleep(0.1)
    elif select==4:
      draw_string("1",20,100,(250,250,250),bg_menu)
      draw_string("2",70,100,(250,250,250),bg_menu)
      draw_string("3",120,100,(250,250,250),bg_menu)
      draw_string("4",170,100,txt_menu,bg_menu)
      draw_string("5",220,100,(250,250,250),bg_menu)
      sleep(0.1)
    elif select==5:
      draw_string("1",20,100,(250,250,250),bg_menu)
      draw_string("2",70,100,(250,250,250),bg_menu)
      draw_string("3",120,100,(250,250,250),bg_menu)
      draw_string("4",170,100,(250,250,250),bg_menu)
      draw_string("5",220,100,txt_menu,bg_menu)
      sleep(0.1)
    if keydown(KEY_BACKSPACE):
      transition()
      menu(select,txt_menu,bg_menu)
      locate="menu"
  
    if select==1 and keydown(KEY_OK):
      transition()
      niv1(x,y,sky)
      locate="niv1"  
  
  if locate=="niv1" or locate=="niv2" or locate=="niv3" or locate=="niv4" or locate=="niv5":
    if keydown(KEY_RIGHT):
      fill_rect(x,y,30,30,sky)
      x=x+1
      fill_rect(x,y,30,30,bloc_color)
      sleep(0.0035)
    if keydown(KEY_LEFT):
      fill_rect(x,y,30,30,sky)
      x=x-1
      fill_rect(x,y,30,30,bloc_color)
      sleep(0.0035)
    if keydown(KEY_UP):
      for i in range(50):
        fill_rect(x,y,30,30,sky)
        y=y-1
        fill_rect(x,y,30,30,bloc_color)
        sleep(0.0035)
        if keydown(KEY_LEFT):
          fill_rect(x,y,30,30,sky)
          x=x-1
          fill_rect(x,y,30,30,bloc_color)
          sleep(0.0035)
        if keydown(KEY_RIGHT):
          fill_rect(x,y,30,30,sky)
          x=x+1
          fill_rect(x,y,30,30,bloc_color)
          sleep(0.0035)
      for i in range(50):
        fill_rect(x,y,30,30,sky)        
        y=y+1
        fill_rect(x,y,30,30,bloc_color)
        sleep(0.0035)
        if keydown(KEY_LEFT):
          fill_rect(x,y,30,30,sky)
          x=x-1
          fill_rect(x,y,30,30,bloc_color)
          sleep(0.0035)
        if keydown(KEY_RIGHT):
          fill_rect(x,y,30,30,sky)
          x=x+1
          fill_rect(x,y,30,30,bloc_color)
          sleep(0.0035)
        

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.