cele
This commit is contained in:
parent
b55b76f413
commit
3972d0de03
35
statek.py
35
statek.py
|
|
@ -4,7 +4,6 @@ from random import randrange
|
|||
import tkinter.ttk as tk
|
||||
|
||||
|
||||
|
||||
def obroc_prostokat_o_2_stopnie_zg(canvas, element_id):
|
||||
wspolrzedne = canvas.coords(element_id)
|
||||
xs = [wspolrzedne[i] for i in range(0, len(wspolrzedne), 2)]
|
||||
|
|
@ -93,7 +92,7 @@ def strzal_z_karabinu():
|
|||
|
||||
kat_myszy = math.atan2(mysz_y - cy, mysz_x - cx)
|
||||
|
||||
dlugosc_lufy = 15
|
||||
dlugosc_lufy = 8
|
||||
start_x = cx + dlugosc_lufy * math.cos(kat_myszy)
|
||||
start_y = cy + dlugosc_lufy * math.sin(kat_myszy)
|
||||
|
||||
|
|
@ -119,7 +118,7 @@ def stzal_gluwny(event):
|
|||
|
||||
kat_myszy = math.atan2(mysz_y - cy, mysz_x - cx)
|
||||
|
||||
dlugosc_lufy = 15
|
||||
dlugosc_lufy = 8
|
||||
start_x = cx + dlugosc_lufy * math.cos(kat_myszy)
|
||||
start_y = cy + dlugosc_lufy * math.sin(kat_myszy)
|
||||
|
||||
|
|
@ -133,6 +132,17 @@ def stzal_gluwny(event):
|
|||
pociski.append({"id": id_pocisku, "dx": dx, "dy": dy})
|
||||
|
||||
|
||||
def cele_ruch():
|
||||
global cele
|
||||
for idx, c in enumerate(cele):
|
||||
if c["x1"] > 0:
|
||||
canvas.move(c["id"], -1, 0)
|
||||
c["x1"] -= 1
|
||||
c["x2"] -= 1
|
||||
|
||||
print(idx, c["x1"], c["y1"], c["x2"], c["y2"])
|
||||
|
||||
|
||||
def aktualizuj_karabiny():
|
||||
global cele_zniszczone
|
||||
szerokosc_okna = canvas.winfo_width()
|
||||
|
|
@ -191,6 +201,7 @@ def aktualizuj_karabiny():
|
|||
if cele_zniszczone == cel_wymagany:
|
||||
tekst_celu["text"] = "MISJA UKOŃCZONA! ZNISZCZYŁEŚ CELE!"
|
||||
tekst_celu["foreground"] = "gold"
|
||||
root.after(5000, lambda: tekst_celu.pack_forget())
|
||||
|
||||
kamyki_do_usuniecia.sort(reverse=True)
|
||||
for idx in kamyki_do_usuniecia:
|
||||
|
|
@ -439,14 +450,26 @@ def gluwna():
|
|||
aktualizuj_pozycje_figur()
|
||||
|
||||
rk_slad = 1.5
|
||||
klawisze_ruchu = ["w", "s", "a", "d"]
|
||||
|
||||
sxl = (wspol[0] * 3 + wspol[6]) / 4
|
||||
syl = (wspol[1] * 3 + wspol[7]) / 4
|
||||
sxp = (wspol[0] + wspol[6] * 3) / 4
|
||||
syp = (wspol[1] + wspol[7] * 3) / 4
|
||||
|
||||
k1 = "#00" + str(randrange(4000, 6000, 100))
|
||||
k2 = "#00" + str(randrange(4000, 6000, 100))
|
||||
if any(wcisniete_klawisze[k] for k in klawisze_ruchu):
|
||||
k1 = "#00" + str(randrange(5000, 6000, 100))
|
||||
k2 = "#00" + str(randrange(5000, 6000, 100))
|
||||
sl = True
|
||||
elif x != 0:
|
||||
k1 = "#00" + str(randrange(6000, 7000, 100))
|
||||
k2 = "#00" + str(randrange(6000, 7000, 100))
|
||||
sl = True
|
||||
else:
|
||||
sl = False
|
||||
k2=k1="#000000"
|
||||
|
||||
if sl:
|
||||
t1 = canvas.create_oval(sxl - rk_slad, syl - rk_slad, sxl + rk_slad, syl + rk_slad, fill=k1, outline="")
|
||||
t2 = canvas.create_oval(sxp - rk_slad, syp - rk_slad, sxp + rk_slad, syp + rk_slad, fill=k2, outline="")
|
||||
canvas.tag_lower(t1)
|
||||
|
|
@ -454,6 +477,7 @@ def gluwna():
|
|||
canvas.tag_lower(t1)
|
||||
canvas.tag_lower(t2)
|
||||
|
||||
cele_ruch()
|
||||
root.after(16, gluwna)
|
||||
|
||||
|
||||
|
|
@ -566,7 +590,6 @@ for tekst in teksty_napisow:
|
|||
id_tekstu = canvas.create_text(0, 0, text=tekst, font=("Arial", 10, "bold"), fill="black")
|
||||
napisy_ids.append(id_tekstu)
|
||||
|
||||
|
||||
cele = []
|
||||
cele_zniszczone = 0
|
||||
cel_wymagany = 5
|
||||
|
|
|
|||
Loading…
Reference in a new issue