Jeu de combat : 1 joueur (YOU) contre le robot (BOT).
Commandes : Touche du haut : attaque (aléatoire) Touche du bas : défense (vous gagnez du soin) Touche OK : super attaque (attaque plus importante mais utilisable une fois)
from math import * from random import * from kandinsky import * from ion import * from time import * vie = [100, 100] n=randint(0,1) nom = ["YOU", "BOT"] dmin, dmax=10, 15 degat = randint(randint(dmin,12),dmax) super_fois=[0, 0] tour=0 def combat1(): if keydown(KEY_UP): attack() if keydown(KEY_DOWN): defense() if keydown(KEY_OK): if super_fois[0]==0: super_attack() else: print("Already used !") attack() def combat2(): global degat degat+=randint(0,2) if vie[1]>=90: attack() elif vie[1]<=20: if vie[0]<=30: attack() else: defense() elif vie[1]<=50: attack() else: combat_bot=randint(0,1) if combat_bot==0: attack() if combat_bot==1: defense() def attack(): vie[not(n)]-=degat print(nom[n]+" attacked "+nom[not(n)]+" : -"+str(degat)) suite() def defense(): vie[n]+=13 print(nom[n]+" healed : +13") suite() def super_attack(): super_degat=randint(16,2*dmin) vie[not(n)]-=super_degat print(nom[n]+" super attacked "+nom[not(n)]+" : -"+str(super_degat)) super_fois[n]=1 suite() def stat(): if vie[n]>100: vie[n]=100 if vie[not(n)]<0: vie[not(n)]=0 print("YOU : "+str(vie[0])+"Hp") print("BOT : "+str(vie[1])+"Hp") def suite(): global n global degat global dmax global tour stat() tour+=1 print() n=not(n) print(" ---"+nom[n]+"---") if (tour%6)==0: if dmax!=dmin: dmax-=1 degat=randint(dmin,dmax) stat() print(" ---"+nom[n]+"---") print() while vie[0]>0 and vie[1]>0: if n==0: combat1() elif n==1: combat2() sleep(0.2) round_=ceil(tour/2) print(" (dead)") print() print(" "+nom[not(n)]+" WIN ! (in "+str(round_)+" rounds)")