move.py

Created by rockingchair1196

Created on May 28, 2024

3.75 KB

Hey ! Je suis RockingCha1r, et je vous présente mon tout nouveau jeu !

Move!

Dans ce jeu, vous devrez essayer de rejoindre l'arrivée, sans toucher aux obstacles ! Normalement, en dehors du dernier niveau, le jeu n'est pas très difficile ! J'espère que vous aimerez mon jeu !

Vous voulez regarder le code du jeu ? Vous pouvez essayer la version non-optimisée, avec un code bien plus lisible, ici

Classement


from math import*
from kandinsky import*
from ion import*
from time import*
red=color(255,50,50)
green=color(0,255,0)
black=color(0,0,0)
white=color(255,255,255)
class perso:
  global px,py
  def __init__():fill_rect(255,101,20,20,green);perso.use=0;perso.win=0;perso.x=55;perso.y=111
  def move():
    perso.use+=1;perso.lastx=perso.x;perso.lasty=perso.y
    if keydown(KEY_UP):perso.y-=1
    if keydown(KEY_DOWN):perso.y+=1
    if keydown(KEY_LEFT):perso.x-=1
    if keydown(KEY_RIGHT):perso.x+=1
  def draw():
    if perso.x!=perso.lastx or perso.y!=perso.lasty or perso.use==1:fill_rect(perso.x-10,perso.y-8,20,18,color(210,50,50));fill_rect(perso.x-8,perso.y-10,18,18,color(255,150,150));fill_rect(perso.x-8,perso.y-8,16,16,color(255,100,100))
  def play():perso.move();perso.draw();perso.borders()
  def levelend():
    if perso.win%2==0:fill_rect(0,0,320,222,black)
    else:fill_rect(0,0,320,222,white)
    if perso.win==0:fill_rect(10,10,20,20,green)
    if perso.win==1:fill_rect(290,192,20,20,green);fill_rect(260,50,20,180,red);fill_rect(210,-50,20,200,red)
    if perso.win==2:fill_rect(150,101,170,20,red);fill_rect(150,101,20,121,red);fill_rect(70,45,20,20,green)
    if perso.win==3:fill_rect(150,-100,20,195,red);fill_rect(150,125,20,200,red);fill_rect(210,-100,20,135,red);fill_rect(210,65,20,300,red);fill_rect(270,-100,20,260,red);fill_rect(270,190,20,150,red);fill_rect(295,10,20,20,green);fill_rect(0,0,320,1,red);fill_rect(0,221,320,1,red)
    if perso.win==4:fill_rect(10,10,20,20,green);fill_rect(10,91,20,20,green);fill_rect(10,192,20,20,green);fill_rect(290,192,20,20,green)
    if perso.win==5:fill_rect(-200,50,420,20,red);fill_rect(-200,150,300,20,red);fill_rect(130,100,20,500,red);fill_rect(80,-1000,20,1001,red);fill_rect(80,15,20,111,red);fill_rect(0,0,320,1,red);fill_rect(0,0,1,222,red);fill_rect(318,0,2,222,red);fill_rect(130,100,200,20,red);fill_rect(290,10,20,20,green)
    if perso.win==6:
      dx=40;dy=55
      while dy<222:fill_rect(dx,dy,2,200,red);dx+=2;dy+=2
      dx=40;dy=10
      while dy<187:fill_rect(dx,0,2,dy,red);dx+=2;dy+=2
      fill_rect(10,101,20,20,green)
    if perso.win==7:
      dx=40;dy=55
      while dy<222:fill_rect(dx,dy,2,200,red);dx+=2;dy+=2
      dx=30;dy=0
      while dy<187:fill_rect(dx,0,2,dy,red);dx+=2;dy+=2
      dx=227;dy=222
      while dx<320:fill_rect(dx,dy,2,200,red);dx+=2;dy-=2
      dx=217;dy=187
      while dx<320:fill_rect(dx,0,2,dy,red);dx+=2;dy-=2
      fill_rect(316,0,4,222,red);fill_rect(294,115,20,20,green)
    if perso.win==8:a='Temps : '+str(monotonic()-tps_start);print(str(a))
    perso.win+=1
  def borders():
    for i in range(5):
      z=i*4-9
      if get_pixel(perso.x+z,perso.y+11)==green:perso.levelend()
      if get_pixel(perso.x-z,perso.y-11)==green:perso.levelend()
      if get_pixel(perso.x-11,perso.y-z)==green:perso.levelend()
      if get_pixel(perso.x+11,perso.y+z)==green:perso.levelend()
      if get_pixel(perso.x+z,perso.y+11)==red:perso.win-=2;perso.levelend()
      if get_pixel(perso.x-z,perso.y-11)==red:perso.win-=2;perso.levelend()
      if get_pixel(perso.x-11,perso.y-z)==red:perso.win-=2;perso.levelend()
      if get_pixel(perso.x+11,perso.y+z)==red:perso.win-=2;perso.levelend()
tps_start=monotonic()
def play():
  perso.__init__()
  while 1==1:perso.play()
def menu():
  dx=135;dy=101
  while dy>30:draw_string('Move!',dx,dy);dy-=1;sleep(.015)
  draw_string('Jouer',135,150);draw_string('Par RockingCha1r',80,50);draw_string('Quitter',125,175);o=0
  while True:
    if keydown(KEY_OK):
      if o%2==0:play()
      else:raise BaseException('A la prochaine')
    if keydown(KEY_UP):o+=1;sleep(.25)
    if keydown(KEY_DOWN):o-=1;sleep(.25)
    if o%2==0:draw_string('> Jouer',125,150);draw_string(' Quitter ',115,175)
    else:draw_string(' Jouer ',125,150);draw_string('> Quitter',115,175)
menu()

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.