frames.py

Created by pikube

Created on November 07, 2019

2.22 KB

ATTENTION: CE PROGRAMME EXIGE TOUTE LA MEMOIRE DE LA CALCULATRICE, ET EST COUPLE AU SCRIPT labyrinth.py (voir mes autres scripts).

Si vous souhaitez changez les textures, modifiez la méthode “draw_” suivie du nom de la texture, devant être au final comprise dans un carré de 21 par 17 pixels.

UPDATE: Une version largement améliorée est à présent disponible! Cherchez frames_2 dans scripts de pikube


from math import *
import kandinsky
import random
import time
global leaves
global white_leaves
white_leaves=(127,204,136)
leaves=(65,163,78)
def fill(a,b,c,d,e):
  kandinsky.fill_rect(a,b,c,d,e)
def draw_terrain(x,y):
  fill(x,y,21,17,(89,192,103))
def draw_tree(x,y):
  draw_terrain(x,y)
  #21by17
  for loop in range(4):
    fill(10-loop+x,0+3*loop+y,1+2*loop,1,leaves)
    fill(9-loop+x,1+3*loop+y,3+2*loop,1,leaves)
    fill(8-loop+x,2+3*loop+y,5+2*loop,1,leaves)
  fill(4+x,12+y,13,1,leaves)
  fill(9+x,13+y,3,4,(137,73,0))
def draw_grass(x,y,neighbour):
  draw_terrain(x,y)
  if neighbour==0:#flower
    pass
  else:
    if x%2==0 and y%2==1:
      a=leaves
      b=white_leaves
    else:
      a=white_leaves
      b=leaves
    fill(x+2,y+1,2,2,a)
    fill(x+10,y+9,2,2,b)
    fill(x+18,y+12,2,2,b)
def draw_player(x,y):
    fill(x+1,y,4,7,(255,255,255))
    fill(x+2,y+13,3,4,(255,255,255))
    fill(x+16,y,4,7,(255,255,255))
    fill(x+16,y+13,3,4,(255,255,255))
    fill(x+5,y+4,11,11,(0,87,172))
    fill(x+7,y+6,7,7,(139,191,229))
    fill(x+9,y+8,3,3,(255,255,255))
def draw_water(x,y):
  fill(x,y,21,17,(0,0,255))
  fill(x+2+(6*y)%10,y+5+(x+y*52)%10,3,3,(150,150,255))
  fill(x+5+(x*48)%10,y+2+(48*x)%10,3,3,(150,150,255))
  fill(x+9+(y*y*6)%10,y+6+(10*x*y)%10,3,3,(150,150,255))
def draw_rock(x,y):
  fill(x,y,21,17,(104,52,0))
  fill(x+2,y+3,1,5,(104,76,49))
  fill(x+12,y+8,1,6,(104,76,49))
  fill(x+6,y+6,1,4,(86,43,0))
  fill(x+15,y+1,1,4,(86,43,0))
def draw_wall(x,y,c):
  fill(x,y,21,17,(100,100,100))
  draw_key(x,y,c)
def draw_key(x,y,d):
  c=(5*abs(d)+50,2*abs(d)+210,3*abs(d)+27)
  fill(x+8,y+2,5,5,c)
  fill(x+10,y+7,1,7,c)
  fill(x+10,y+13,4,2,c)
  fill(x+10,y+11,2,1,c)
def draw_trophey(x,y):
  draw_terrain(x,y)
  gold=(250,240,10)
  fill(x+2,y+4,1,6,gold)
  fill(x+2,y+4,4,1,gold)
  fill(x+2,y+9,4,1,gold)
  fill(x+6,y+2,8,10,gold)
  fill(x+14,y+4,4,1,gold)
  fill(x+17,y+4,1,6,gold)
  fill(x+14,y+9,4,1,gold)
  fill(x+8,y+12,3,4,gold)
  fill(x+6,y+14,8,2,gold)
def refresh():
  fill(0,0,2,222,(0,0,0))
  fill(320-3,0,3,222,(0,0,0))
  fill(0,221,320,1,(0,0,0))
def text(string):
  fill(10,150,320-20,72,(0,0,0))
  fill(11,151,318-22,70,(255,255,255))
  kandinsky.draw_string(string,20,165)
  time.sleep(5)
  fill(0,0,320,222,(0,0,0))

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.