I'm making a platformer game with python turtle, the game not built for high graphics any way, the rendering created with pen, but I still want a way to make the pen less pixelated,
I tried a lot of things like using tkinter root.tk.call('tk', 'scaling', 2.0) and ctypes.windll.shcore.SetProcessDpiAwareness(1)
but it just don't work on the turtle pen graphics.
example:
from turtle import *
wn = Screen()
wn.colormode(255)
pen = Turtle()
pen.speed(0)
pen.ht()
pen.pu()
pen.pensize(15)
pen.pencolor(0, 255, 255)
pen.setpos(-150, -50)
pen.pd()
pen.setpos(150, 50)
wn.mainloop()
So that code draws a diagonal line, but as you can see it is too pixelated, and I guess it has resolution limit (not sure):
screen shot from the code up
screen shot of the life bar from my own game when using 1920x1080 resolution and it still seems like 720p not anti aliased
so if you know any way to do it, really thanks, if you can't find a way to do it through turtle or tkinter, or any other trusted module, I don't even care if I have to edit turtle for the solution.
Related
Is there a way to export a python turtle drawing to a video?
The video should contain the real-time drawing process.
In particular I'm not interested in a screen-recording workaround, but a solution that would work in a headless system like a cloud environment.
Here's an example of a turtle drawing
import turtle
tr = turtle.Turtle()
rad = 80
tr.circle(rad)
turtle.done()
How do I zoom out on the canvas so I'll be able to see everything that is drawn from the turtle in Python. As the name suggests, I use the Turtle from Python to draw a binary tree of certain strings. I could of course force the turtle to draw more narrowly, but then the leaves would be too close to each other. That's why I'm looking for an option to zoom out on the thee when the turtle is done with its drawings.
The screenshot below should show my frustration. As you can see, it is not possible for me to see the whole binary tree.
Have not included the whole code. But let me know if you want to see it. Here is a snippet though.
import turtle
turtle.screensize(5000, 3000)
t = turtle.Turtle()
t.hideturtle()
t.speed(0); turtle.delay(0)
h = height(root)
jumpto(0, 30*h)
draw(root, 0, 30*h, 40*h) #function to draw
t.hideturtle()
turtle.mainloop()
I am trying to work with the screen in turtle and am confused about the dimensions of the screen. So in this example:
import turtle
screen = turtle.Screen()
print(screen.screensize())
turtle.done()
Python prints the dimension of the turtle window to be (400,300). However, the screen looks much bigger on the desktop and when I move the turtle by 640 pixels to the right (from the center) or 540 pixels downwards then the edge of the screen is reached. This would indicate that the screensize is 1280 * 1080 pixels.
So my specific questions are:
What information do I get from calling screen.screensize()
When the turtle is moved, is it moved in pixels or is another metric used?
So many thanks in advance!
Let's clear up some misconceptions about turtle window size:
First, the default window you get in standalone turtle is 50% of your display width and 75% of your display height. Which means that not everyone gets the same default window. Something to consider when writing turtle software for others.
You can set the window's size using the setup() method or function. You can get the current window size using the window_width() and window_height() methods or functions.
The screensize() method or function gets/sets the size of the backing store for the window. Generally, the return value is of no use to you, as the area the turtle can travel is the size of the window, so no backing store needed. It's there for folks who, for example, want a 500x500 window onto a 2000x2000 plane that the turtle can wander. Then scrollbars appear to allow you to move that peephole of a window about the larger plane.
You can modify many of turtle's default behaviors with a turtle.cfg file.
You can also find this in the turtle documentation: https://docs.python.org/3/library/turtle.html#screenspecific
I want to create a game in pygame but want it to have pixelated graphics, so instead of resizing a pixelated image, i was hoping to just change the resolution of the pygame screen .
screen = pygame.display.set_mode((width, height))
Thanks.
Make two screens. One with your desired resolution( let's call screen) and the other with your desired screen size(let's call window). Then blit screen into window while scaling it to the size of the window.
window.blit(pygame.transform.scale(screen,(windoWidth,windowHeight)),(0,0))
That should work.
EDIT: As the Ted's comments suggests it will be more easy to understand like this.
resized_screen = pygame.transform.scale(screen, (windoWidth,windowHeight))
window.blit(resized_screen, (0, 0))
Code:
import pygame
pygame.init()
screen = pygame.display.set_mode((400, 400))
What happens:
The pygame screen pulls up, but there is a black box covering the top right-hand corner of the screen. I would post a picture but stack overflow wouldn't let me.
Yes, so what are you trying to make happen?
pygame.display.set_mode((0, 0)) should make that box full screen. Is that your objective?