Oct-30-2017, 04:34 PM
hi every one
I'm trying to make a game , i need help to make the bullet start from the ship
i don't know how to use coords
this is the code
I'm trying to make a game , i need help to make the bullet start from the ship
i don't know how to use coords
this is the code
from tkinter import * import random import time WIDTH=600 HEIGHT=400 tk=Tk() c=Canvas(tk,width=WIDTH,height=HEIGHT) c.pack() def ship(a): c.create_polygon(a,a/2,a-20,a/2+30,a+20,a/2+30,fill="blue") return a def bullet(i): c.create_oval(i,i,i+5,i+5,fill="blue") #=================== KEYS ===================================== def go_left(event): c.move(1,-5,0) c.update() def go_right(event): c.move(1,5,0) c.update() def go_up(event): c.move(1,0,-5) c.update() def go_down(event): c.move(1,0,5) c.update() def spaceKey(event=0): c.move(2,0,-100) c.update() ship=ship(300) bult=bullet(298) 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()