Accueil > Technique > Informatique > Python > Cinéma ascii > Le lancer du marteau
Le lancer du marteau
mardi 2 avril 2019, par
Programme python3, ascii art animé, pour des yeux olympiques
Screencast
Lancer du marteau
pyrhon3, ascii art animé
Fichier et code
~$ unzip lancer_marteau.zip
~$ cd lancer_marteau
~lancer_marteau$ python3 lancer_marteau.py
Sources
code
lancer_marteau.py :
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8
#
# sans titre.py
#
# Copyright 2019 Robert Sebille <robert@sebille.name>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
import os
import time as t
from platform import system
def cls():
""" Utilitaire qui efface l'écran suivant les systèmes """
if system() == 'Windows':
os.system("cls")
else:
os.system('clear')
sep = '#'
if __name__ == '__main__':
# Pub debian
with open('debian_pub_en.txt') as d:
p = d.readlines()
for l in p:
print(l, end='')
t.sleep(2)
# lecture des données
with open('lancer_marteau') as c:
l = c.readlines()
s = "".join(l)
myframes = s.split(sep)
sequence = 0
while True:
try:
# Joue le film et imprime les infos
no_myframe = 0
for f in myframes:
cls()
print(f)
print("Séquence: " + str(sequence) + " Frame: " +
str(no_myframe) + "\nFin = CTRL+C")
no_myframe += 1
t.sleep(0.10)
sequence += 1
# Interception de CTRL+C
except KeyboardInterrupt:
cls()
print("Reçu CTRL + C\n")
print("Au revoir ...\n")
input("Pressez Entrée pour finir")
exit()
pass
# local encoding
# import sys
# print(sys.getdefaultencoding())
données
lancer_marteau :
O_ || | ` || - || / \ || ° ° || # o o_ || \| ` || - || / \ || ° ° || # o_ || | ` || o-- || / \ || ° ° || # o_ || | ` || - || / \ || o° ° || # o_ || | ` || - || /|\ || °o ° || # o_ || | ` || - || / \ || ° o || # o_ || | ` || ---o || / \ || ° ° || # o_o || |/ || - || / \ || ° ° || # o_ || | ` || - || / \ || ° ° || # o o_ || \| ` || - || / \ || ° ° || # o_ || | ` || o-- || / \ || ° ° || # o_ || | ` || - || / \ || o° ° || # o_ || | ` || - || /|\ || °o ° || # o_ || | ` || - || / \ || ° o || # o_ || | ` || ---o || / \ || ° ° || # o_o || |/ || - || / \ || ° ° || # o_ || / ` --o || --- || ° | || ° || # o_ || / ` --o || --- || ° | || ° || # o_ || / ` || --- --o || ° | || ° || # o_ || / ` \ || --- o || ° | || ° || # o_ || / ` || --- --o || ° | || ° || # o_ || / ` || --- --o || ° | || ° || # o | |\ \\ - --*§ | / ° || # o \ |\ * - -** | * ° // # o * |\ * - * * | * ° * # \o/ * | * - * / \ * ° ° * # \o/ * | * - * / \ ° ° * # \o/ * | - * / \ ° ° * # o | - * | ° # o | - | °
debian_pub_en.txt :
_,met$$$$$gg. ,g$$$$$$$$$$$$$$$P. | | __| _ \ ,g$$P"" """Y$$.". | |\__ \ __/ ,$$P' `$$$. \__,_|____/\___| ',$$P ,ggs. `$$b: `d$$' ,$P"' . $$$ _, _, ,'`. $$P d$' , $$P `$$' `$$' `. ,' HEX $$: $$. - ,d$$' $$ $$ `' 64 65 62 69 61 6E $$; Y$b._ _,d$P' $$ $$ _, _ Y$$. `.`"Y$$$$P"' ,d$$$g$$ ,d$$$b. $$,d$$$b.`$$' g$$$$$b.`$$,d$$b. `$$b "-.__ ,$P' `$$ ,$P' `Y$. $$$' `$$ $$ "' `$$ $$$' `$$ `Y$$b $$' $$ $$' `$$ $$' $$ $$ ,ggggg$$ $$' $$ `Y$$. $$ $$ $$ggggg$$ $$ $$ $$ ,$P" $$ $$ $$ `$$b. $$ ,$$ $$. $$ ,$P $$ $$' ,$$ $$ $$ `Y$$b. `$g. ,$$$ `$$._ _., $$ _,g$P' $$ `$b. ,$$$ $$ $$ `"Y$b._ `Y$$P'$$. `Y$$$$P',$$$$P"' ,$$. `Y$$P'$$.$$. ,$$. `""""