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?
Related
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.
Is there a way to maximize the pygame window when intializing the window with set_mode without making it completely fulsscreen. I tried to get the required window_size by printing event.size, when VIDEORESIZE is called, which is (1920, 1017). But if I use this value for my window_size when setting mode I just get a window at the same size of a maximized window. If I press maximize in the top right corner it just switches between a thicker and a thinner border.
Obviously i want the thinner border, is that possible from the start?
You should try to use the
RESIZEABLE
When using set_mode in pygame like
DISPLAYSURF = pygame.display.set_mode((1920,1017), RESIZABLE)
I did a simple game using Python and Pygame.
The game works on both orientations (Portrait and Landscape) since that I play in the same orientation that I used to open the game.
If I rotate the device changing the orientation with the game running, everything appears at the wrong place.
The problem is that I don't know how to detect that the device was rotated to redraw the screen correctly.
Then, my question is:
How I can detect that the user rotated the device using only a Python or Pygame code?
IMPORTANT: Suggestions should not be related to any particular OS, because the same code must run on notebooks with touch screen (running Linux, Windows or OS X) and mobile devices (running Android or iOS).
OBSERVATION: I tried to create another screen to get its size and compare with the actual screen using pygame.display.set_mode() but this new screen returned the same size of the actual screen instead of have its width equals to actual screen height.
Thanks for your help.
You have to set the RESIZABLE flag when you generate the display surface by set_mode(). When the logical display resolution changes, then you get a VIDEORESIZE event:
screen = pygame.set_mode((0, 0), pygame.FULLSCREEN | pygame.pygame.RESIZABLE)
width, height = screen.get_size()
while run:
for event in pygame.event.get():
if event.type == pygame.VIDEORESIZE:
width, height = event.w, event.h
The code: https://pastebin.pl/view/6f60a32d
I have tried using opengl and tried putting all of the stuff into a surface, and none of them worked
if anyone have any ideas on how to zoom in my game pls help me
Use pygame.transform.smoothscale() to generate a scaled copy of the display pygame.Surface after drawing the scene:
zoomed_screen = pygame.transform.smoothscale(screen, (new_width, new_height))
Blit the zoomed Surface on the screen
screen.blit(zoomed_screen, ....)
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))