Adrien Thibaut (Carnot 2026, Premiere)
UNIVERS / THÈME CHOISI
Tower defence
MODE D'EMPLOI
Touches : Z Q S D pour les déplacement de la caméra clic droit pour les tirs clic gauche pour les tours x pour quitter
PRÉSENTATION / EXPLICATIONS
Vous incarnez Napoléon au début du XIX e siècle ,la coalitions des grandes puissances européennes vous attaques vous êtes encerclés par le Grande-Bretagne , la Prusse, la Russie, les royaumes italiens, l'Espagne le Portugal, et encore plus. Votre but défendre Paris des invasions et sauvez la France. Quatre chemins mènent à Paris : Le Nord où débarquent les anglais, l'Est où ce trouve la Prusse et la Russie ,le Sud Est d'où viennent les armées italiennes, et le sud Ouest d'où viennent les portugais et les espagnoles. Ainsi placé des tours de défense sur le territoire Français pour empêchés les armées adversaire d'atteindre Paris .
import pyxel
import random
# taille de la fenetre 128x128 pixels
pyxel.init(128, 128, title="Nuit du Code")
pyxel.load("theme.pyxres")
pyxel.mouse(True)
tete_x = 50
tete_y = 50
ennemi1_x= 185
ennemi1_y = 150
x= 0
y=0
tours = []
tirs =[]
w = 128
h = 128
camera_x = ennemi1_x-30
camera_y = ennemi1_y-30
coordonne=[(63,52), (64,52),(63,53),(64,53),(65,52),(65,53)]
coordonne = [(x*8, y*8) for x,y in coordonne]
pyxel.camera(camera_x,camera_y)
gameover = False
def deplacement_camera():
global camera_x , camera_y
if pyxel.btn(pyxel.KEY_D):
if ( camera_x < 78*2) :
camera_x = camera_x + 2
if pyxel.btn(pyxel.KEY_Q):
if (camera_x > 39/8 ) :
camera_x = camera_x - 2
if pyxel.btn(pyxel.KEY_S):
if ( camera_y < 86*3.70) :
camera_y = camera_y + 2
if pyxel.btn(pyxel.KEY_Z):
if (camera_y > 23 /8) :
camera_y = camera_y - 2
return camera_x, camera_y
def ajout_tir(x,y):
tirs.append((x,y))
return tirs
def ajout_tour(x,y):
tours.append((x,y))
return tours
def deplacement(x,y):
direction_x = position_x
direction_y = position_y
def update():
global tete_x, tete_y, ennemi1_x, ennemi1_y, tirs,camera_x, camera_y, chateau_x, chateau_y, coordonne
position_x1 = pyxel.mouse_x+camera_x
position_y1 = pyxel.mouse_y+camera_y
if pyxel.btnp(pyxel.MOUSE_BUTTON_LEFT)== True:
ajout_tour(position_x1, position_y1)
if pyxel.btn(pyxel.MOUSE_BUTTON_RIGHT)==True:
assert len(tours)>0
ajout_tir(position_x1,position_y1)
if pyxel.btnp(pyxel.KEY_X):
pyxel.quit()
camera_x , camera_y = deplacement_camera()
for lignes in coordonne:
x, y=lignes
if x == ennemi1_x and y==ennemi1_y:
gameover = True
else:
ennemi1_y += 0.1
def draw():
global tete_x, tete_y, w, ennemi1_x, ennemi1_y,tours, x, y,camera_x, camera_y, coordonne,gameover
pyxel.cls(0)
pyxel.rect(10, 10, 20, 20, 11)
pyxel.camera(camera_x,camera_y)
pyxel.bltm(0,0,0,40*8,24*8,56*8, 56*8)
pyxel.blt(ennemi1_x,ennemi1_y,0,32,0,16,16,0)
for coord in tirs:
x,y=coord
pyxel.blt(x,y,0,32,48,16,16,0,pyxel.atan2(pyxel.mouse_x, pyxel.mouse_y))
for coord in tours:
x, y= coord
pyxel.blt(x,y,0,0,48,16,16,0)
if gameover == True :
pyxel.text(180,180,"Vous avez perdu",8,1)
pyxel.run(update, draw)