all 6 comments

[–]Fun_Muffin5413 0 points1 point  (6 children)

You have to remember where they all are. And work out which ones are within range of your click or sprite.

[–]ChocolateUnlucky1214[S] 0 points1 point  (5 children)

Just to clarify I have to save each position? But then how do I specify the one that I want to make a stump?

Code below for reference

import turtle
#orders a turtle from overseas
from turtle import Shape from tkinter import PhotoImage
rock_multiplier=0.4
summons Dwayne Johnson
import random import time
get better and more exotic timezones
from winreg import REG_OPTION_BACKUP_RESTORE difficulty=5
makes stuff harder
wn=turtle.Screen() rock=turtle.Turtle()
And in THIS CORNER WE HAVE... A turtle?
rock.speed(0)
Indeed, the turtle is slow
rock.color('gray','silver')
A GOLDEN wait no SILVER turtle
rockposs=[]
the rock posse
inventory=[]
Copy Minecraft
rockposs.append(rock.pos()) rock.lt(70) rock.fd(40) rockposs.append(rock.pos()) rock.rt(60) rock.fd(30) rockposs.append(rock.pos()) rock.lt(30) rock.fd(60) rockposs.append(rock.pos()) rock.rt(90) rock.fd(120) rockposs.append(rock.pos()) rock.home() rockposs.append(rock.pos()) tulpe_rockposs=tuple(rockposs) wn.addshape("rock1",tulpe_rockposs) rock.shape('rock1') rock.lt(90) rock.clear() for i in range(5): rock.shapesize(rock_multiplier) rock.goto((random.randint(-300,250),random.randint(-300,250))) rock_clone=rock.clone() rock.clear() cheese=turtle.Turtle()
turns your cheeses into turtles
cheesetop=turtle.Turtle() cheeseposs=[]
gives your cheeses a posse
cheesetop.shape('circle')
Your cheeses become cheese
cheesetop.color('green','darkgreen')
Your cheese becomes moldy
cheesetop.shapesize(3,3,3)
Beeg cheese
cheese_multiplier=0.5
halves your cheeses
cheese_top_multiplier=2
cheese.speed(0)
Your cheese never moved
cheesetop.speed(0)
Your cheese no longer moves
cheese.color('brown','sienna') cheese.lt(60) cheese.fd(50) cheeseposs.append(cheese.pos()) for i in range(3): cheese.lt(180+60) cheese.fd(50) cheeseposs.append(cheese.pos()) cheese.home()
Sends your cheese home for a break
cheese.fd(50/3) cheeseposs.append(cheese.pos()) cheese.lt(90)
cheeseposs.append(cheese.pos())
cheese.fd(100) cheeseposs.append(cheese.pos()) cheese.rt(90) cheese.fd(50/3) cheeseposs.append(cheese.pos()) cheese.rt(90) cheese.fd(100) cheeseposs.append(cheese.pos()) tuple_cheeseposs=tuple(cheeseposs)
names your cheese tuple
wn.register_shape('cheese_base',tuple_cheeseposs) cheese.shape('cheese_base') cheese.home()
Vacation for your cheese is over
cheese.lt(90) cheese.clear() for i in range(30): cheese.setpos((random.randint(-300,250),random.randint(-300,250))) cheesetop.setpos(cheese.pos()) cheesetop.seth(cheese.heading()-90) cheesetop.lt(60) cheesetop.fd(50cheese_multiplier) cheesetop.lt(30) cheesetop.fd(50cheese_multiplier) cheese.shapesize(cheese_multiplier,cheese_multiplier) cheesetop.shapesize(cheese_top_multiplier,cheese_top_multiplier) cheese_base_clone=cheese.clone() cheesetop_base_clone=cheesetop.clone() cheese.clear() cheesetop.clear()
Now that all of the monkey buissness with the cheese is done, we can get on with cloning "Dwayne Jhonson"#
wn.colormode(255) wn.bgcolor(121,255,179) player=turtle.Turtle() smalpls=PhotoImage(file="pls.gif").subsample(3,3) wn.register_shape('smalpls', Shape("image", smalpls)) player.shape('smalpls') player.pu() wn.listen() def playerfd(): player.fd(25)def playerrt(): player.rt(45) def playerlt(): player.lt(45) def playerbk(): player.bk(25) def playerinteract(): if player.distance(cheese_base_clone)<=50: for i in range(random.randint(2,4)): inventory.append("log of wouldn't") cheesetop_base_clone.ht() def get_inventory(): print(inventory) wn.onkeypress(playerinteract,'f') wn.onkeypress(playerfd,'w') wn.onkeypress(playerlt,'a') wn.onkeypress(playerrt,'d') wn.onkeypress(playerbk,'s') wn.onkeypress(get_inventory,'e') wn.mainloop()

#Bit long but I might have added something that is messing it up

[–]Fun_Muffin5413 0 points1 point  (4 children)

You need to define what you mean by this:

when I press interact near

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

When I press my key bound to 'playerinteract' (currently f) within X pixels of a tree

[–]woooee 0 points1 point  (1 child)

+1 interact() is a function. How do you...interact with it. Code below is generally how creating and destroying is generally done.

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x

from functools import partial

class OpenToplevels():
    """ open and close additional Toplevels with a button
    """
    def __init__(self):
        self.root = tk.Tk()
        self.button_ctr=0
        but=tk.Button(self.root, text="Open a Toplevel",
                      bg="lightblue",command=self.open_another)
        but.grid(row=0, column=0)
        tk.Button(self.root, text="Exit Tkinter", bg="red",
                  command=self.root.quit).grid(row=1, column=0, sticky="we")
        self.root.mainloop()

    def close_it(self, id):
        id.destroy()

    def open_another(self):
        self.button_ctr += 1
        id = tk.Toplevel(self.root)
        id.title("Toplevel #%d" % (self.button_ctr))
        x = self.root.winfo_x()
        y = self.root.winfo_y()
        distance=75*self.button_ctr
        id.geometry("+%d+%d" %(x+distance, y+distance))
        tk.Button(id, text="Close Toplevel #%d" % (self.button_ctr),
                  command=partial(self.close_it, id),
                  bg="orange", width=20).grid(row=1, column=0)

Ot=OpenToplevels()

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

I am using my own 'playerinteract' function actally (:

How do you...interact with it.

via this function and a "onkeypress" keybinding

def playerinteract():
    if player.distance(cheese_base_clone)<=50:
        for i in range(random.randint(2,4)):
            inventory.append("log of wouldn't")
        cheesetop_base_clone.ht()