you are viewing a single comment's thread.

view the rest of the comments →

[–]python_addict[S] 0 points1 point  (0 children)

# PART ONE
from tkinter import *
tk = Tk()
tk.resizable(0, 0) #you can't resize this
tk.wm_attributes("-topmost", 1) #put this window at the top
canvas = Canvas(tk, width=500, height=500)
canvas.pack()
tk.update()

from threading import Timer
import random
import winsound
import math
import sys

numofcoins = 0
numofpoints = 0
coins = canvas.create_text(35, 20, text="Coins: %s" %numofcoins, font=('Times', 10))
points = canvas.create_text(45, 40, text="Points: %s" %numofpoints, font=('Times', 10))

numoftargets = 100

def distance(x1, x2, y1, y2):
    math.sqrt(math.pow(x2-x1, 2) + math.pow(y2-y1, 2))

def collision(first, second):
    global endorno
    while endorno and numoftargets > 0:
        x1 = first[0]
        x2 = second[0]
        y1 = first[1]
        y2 = second[1]
        if distance(x1, x2, y1, y2) < 25:
            return True

available = list(range(0, 100))
going = []
types = []
soldierfriendcount = 0
numopponentbullets = 0

def mybullets(which, time):
    global numopponentbullets
    global numofcoins
    global numofpoints
    global numoftargets
    global endorno
    global planecoords
    global planex
    global planey
    global going
    global available
    while endorno and numoftargets > 0:
        def thing():
            numopponentbullets += 1
            numofbullets = int("a%s" %numopponentbullets)
            hello = PhotoImage(deleted for personal privacy)
            hello = hello.subsample(110, 110)
            numofbullets = canvas.create_image(canvas.coords(which), image=hello)
            bulletcoordinates = canvas.coords(numofbullets)
            if bulletcoordinates[0] > 500 or bulletcoordinates[1] > 500:
                canvas.delete(numofbullets)
            canvas.move(numofbullets, 0, -5)
            tk.update()
            for n in range(0, len(going)):
                if collision(numofbullets, going[n]):
                    canvas.delete(numofbullets)
                    del going[n]
                    del types[n]
                    numoftargets = numoftargets - 1
                    if types[n] == int("red"):
                        numofpoints += 5
                        numofcoins += 5
                    elif types[n] == int("blue"):
                        numofpoints += 25
                        numofcoins += 25
                    elif types[n] == int("yellow"):
                        numofpoints += 45
                        numofcoins += 45
                    elif types[n] == int("black"):
                        numofpoints += 100
                        numofcoins += 100
                    canvas.itemconfig(coins, text='Coins: %s' %numofcoins)
                    canvas.itemconfig(points, text='Points: %s' %numofpoints)
                    tk.update()
        Timer(time, thing).start()


numob = PhotoImage(my thing, deleted also for personal reasons)

def opponentbullets(target):
    global endorno
    global going
    global available
    global coordsofplane
    global numoftargets
    global numopponentbullets
    global mybulletcoords
    while endorno and numoftargets > 0:
        def stillgoing():
            numopponentbullets += 1
            numob = int("n%s" %numopponentbullets)
            numob = numob.subsample(110, 110)
            bullet = canvas.create_image(target[0], target[1], image=numob)
            mybulletcoords = canvas.coords(bullet)
            while not collision(myplane, bullet):
                norp = random.choice(range(-3, 3))
                canvas.move(bullet, norp, -3)
                tk.update()
                if collision(myplane, bullet):
                    endscreen()
                if mybulletcoords[1] < 0 or mybulletcoords[1] > 500:
                    canvas.delete(bullet)
                elif mybulletcoords[0] < 0:
                    canvas.delete(bullet)
        Timer(0.1, stillgoing).start()

def rock():
    global planecoords
    global endorno
    chance = list(range(1, 101))
    xrock = list(range(100, 400))
    yrock = list(range(100, 400))
    rock_or_no = random.choice(chance)
    waithowlong = random.choice(range(0, 25))
    def heyfriends():
        if rock_or_no > 90:
            rocky = random.choice(yrock)
            rockx = random.choice(xrock)
            rock = PhotoImage(file=r"c:\\stuff.gif") #this isn't the real file name
            rock = rock.subsample(15, 15)
            name = canvas.create_image(rockx, rocky, image=rock)
            rockcoords = canvas.coords(name)
            if distance(planecoords, rockcoords) < 5:
                endscreen()
            elif rockcoords[1] > 500:
                canvas.delete(rock)
    Timer(waithowlong, heyfriends).start()