planeur_bombe.py

Created by florian-allard

Created on August 09, 2024

1.65 KB

Un petit jeu inspiré de BombRun sur Casio. Le planeur doit raser la ville avant de pouvoir atterrir. Un appui sur EXE ou OK permet de lâcher une bombe pour raser un immeuble. Attention au timing ! Si le planeur heurte un immeuble, c’est perdu !
Version couleur du 14/03/2021. La version initiale est disponible ici.


from random import randint
from kandinsky import get_pixel,draw_string,fill_rect
from ion import *
from time import sleep

while 1:
  nb_immeubles = 32
  draw_string("EXE pour lancer une partie",30,100,(160,0,255))
  while not (keydown(KEY_EXE) or keydown(KEY_OK)):True
  while keydown(KEY_EXE) or keydown(KEY_OK):True
  fill_rect(0,0,319,221,'white')
  for a in range(nb_immeubles):
    c = randint(1,12)
    for b in range(c+1):
      draw_string("œ",10*a,207-14*c+14*b,((200-30*c)%255,(40+35*c)%255,(210-40*c)%255))#((255-30*c)%255,(30+30*c)%255,(70+70*c)%255)#((255-50*c)%255,(120+40*c)%256,30+20*c)

  x = 0
  y = 10
  drop = False

  while y < 10+14*14 and nb_immeubles > 0:
    x += 10
    if x > 310:
      x = 0
      y += 14
    if (x < 310 and sum(get_pixel(x+16,y+7)) < 248*3) or (x == 310 and sum(get_pixel(0+5,y+14+7)) < 248*3):
      draw_string("C'est perdu, ça a touché !",30,80,"red")
      break
    draw_string(">",x,y-1,'green')
    k = 0
    for k in range(15):
      if (keydown(KEY_EXE) or keydown(KEY_OK)) and not drop:
        bx = x
        by = y
        drop = True
      sleep(0.01)
    if drop:
      draw_string(" ",bx,by)
      by += 14
      if by < 210 and sum(get_pixel(bx+6,by+7)) < 248*3: #s'il y a un immeuble
        for etage in range(by,210,14): #alors on l'efface
          draw_string(" ",bx,etage)
        nb_immeubles -= 1
        drop = False
      elif by < 210: #sinon la bombe descend
        draw_string("°",bx-1,by,'red')
      else:
        drop = False
    #draw_string(str(nb_immeubles),150,2)
    if y > 10+13*14 or nb_immeubles == 0:
      draw_string("C'est gagné, bravo !!",55,80)
    draw_string(" ",x,y-1)

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.