Jump to content

How do I make the turtle go to the edge of the screen in python?

DietzDiet
 Share

Go to solution Solved by Sauron,

The screen has a border that covers part of the edges and since the position is relative to the center of the sprite it's hidden by the border when you send it right to the edge. Just send it to -240 or so instead.

 

If you want to better understand what's happening I suggest you try the live interpreter instead of running the whole script. This will let you try different numbers and realize what you're doing wrong. It will get you a lot farther and a lot faster than just asking here for every tiny problem.

How do I make the turtle go to the edge of the screen in python? I am trying to do that but it goes off screen every time 😞
 

from turtle import Turtle, Screen

screen = Screen()

screen.setup(width=500, height=400)
answer = screen.textinput(title="Choose Your Turtle", prompt="Which turtle do you think will win? Red, Green, Blue , Yellow, or Pink!")

tim = Turtle()

tim.penup()

tim.goto(x=-250, y=0)
tim.showturtle()
tim.pendown()

screen.exitonclick()

 

Link to comment
Share on other sites

Link to post
Share on other sites

The screen has a border that covers part of the edges and since the position is relative to the center of the sprite it's hidden by the border when you send it right to the edge. Just send it to -240 or so instead.

 

If you want to better understand what's happening I suggest you try the live interpreter instead of running the whole script. This will let you try different numbers and realize what you're doing wrong. It will get you a lot farther and a lot faster than just asking here for every tiny problem.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

What is scaling and how does it work? Asus PB287Q unboxing! Console alternatives :D Watch Netflix with Kodi on Arch Linux Sharing folders over the internet using SSH Beginner's Guide To LTT (by iamdarkyoshi)

Sauron'stm Product Scores:

Spoiler

Just a list of my personal scores for some products, in no particular order, with brief comments. I just got the idea to do them so they aren't many for now :)

Don't take these as complete reviews or final truths - they are just my personal impressions on products I may or may not have used, summed up in a couple of sentences and a rough score. All scores take into account the unit's price and time of release, heavily so, therefore don't expect absolute performance to be reflected here.

 

-Lenovo Thinkpad X220 - [8/10]

Spoiler

A durable and reliable machine that is relatively lightweight, has all the hardware it needs to never feel sluggish and has a great IPS matte screen. Downsides are mostly due to its age, most notably the screen resolution of 1366x768 and usb 2.0 ports.

 

-Apple Macbook (2015) - [Garbage -/10]

Spoiler

From my perspective, this product has no redeeming factors given its price and the competition. It is underpowered, overpriced, impractical due to its single port and is made redundant even by Apple's own iPad pro line.

 

-OnePlus X - [7/10]

Spoiler

A good phone for the price. It does everything I (and most people) need without being sluggish and has no particularly bad flaws. The lack of recent software updates and relatively barebones feature kit (most notably the lack of 5GHz wifi, biometric sensors and backlight for the capacitive buttons) prevent it from being exceptional.

 

-Microsoft Surface Book 2 - [Garbage - -/10]

Spoiler

Overpriced and rushed, offers nothing notable compared to the competition, doesn't come with an adequate charger despite the premium price. Worse than the Macbook for not even offering the small plus sides of having macOS. Buy a Razer Blade if you want high performance in a (relatively) light package.

 

-Intel Core i7 2600/k - [9/10]

Spoiler

Quite possibly Intel's best product launch ever. It had all the bleeding edge features of the time, it came with a very significant performance improvement over its predecessor and it had a soldered heatspreader, allowing for efficient cooling and great overclocking. Even the "locked" version could be overclocked through the multiplier within (quite reasonable) limits.

 

-Apple iPad Pro - [5/10]

Spoiler

A pretty good product, sunk by its price (plus the extra cost of the physical keyboard and the pencil). Buy it if you don't mind the Apple tax and are looking for a very light office machine with an excellent digitizer. Particularly good for rich students. Bad for cheap tinkerers like myself.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Your problem is using goto with a negative number.

 

Turtle coordinates start with (0, 0) in the top left corner, and go to (width, height) in the bottom right corner. Increasing x goes right, decreasing goes left, increasing y goes down, decreasing goes up. So in your case goto(-250, 0) means go to 250 pixels left of the top left corner, which is off the screen.

 

Nope. Totally wrong. I was thinking of another similar library.

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×