Nov-13-2017, 09:12 AM
(Nov-13-2017, 06:13 AM)heiner55 Wrote: I took the liberty of changing some names in your program
from tkinter import * from time import time, sleep import random WIDTH =600 HEIGHT=400 tk=Tk() cs=Canvas(tk,width=WIDTH,height=HEIGHT) cs.pack() def create_ship(x,y): return cs.create_polygon(x,y, x-20,y+30, x+20,y+30, fill="blue") def create_bull(x,y): return cs.create_oval(x-3,y-3, x+3,y+3, fill="blue") def go_left(event): cs.move(ship,-5,0) cs.update() def go_right(event): cs.move(ship,5,0) cs.update() def go_up(event): cs.move(ship,0,-5) cs.update() def go_down(event): cs.move(ship,0,5) cs.update() def spaceKey(event=0): cs.move(bult,0,-50) cs.update() ship = create_ship(300,200) bult = create_bull(300,200) tk.bind("<Left>", go_left) tk.bind("<Right>", go_right) tk.bind("<Up>", go_up) tk.bind("<Down>", go_down) tk.bind('<space>', spaceKey) tk.mainloop()
Thank you very much for your help
Your idea is good
But I'm looking for something else,
What i want is how to make it shoot like (space invaders), I don't know how to use coords, and I didn't found any good tutorial or explanation.
Thank you again