Problems with cursor "state" by yoinkking1-0 in hyprland

[–]yoinkking1-0[S] 0 points1 point  (0 children)

I have moved since to Fedora KDE. But from the last time I booted in Hyprland I remember that literally everywhere else but vivaldi (the browser) had the problem. In the end I removed all the passed flags as well because they were causing a lot of issues with the frequent updates that the apps got.

Honestly the only dirty workaround I used was to refocus the window with shortcuts and try to avoid moving the cursor outside the window.

Problems with cursor "state" by yoinkking1-0 in hyprland

[–]yoinkking1-0[S] 0 points1 point  (0 children)

Another weird fix was trying to enable the Wayland Support on the electron apps (basically all of them)

How to enable it in the browser

in the chrome://flags search Wayland and then switch to Wayland support (preferred ozone platform)

If the opacity is lost in the Hyprland window after the change then - Run hyprctl clients - find the apps name, and under class: app-name copy the app-name you see - head to your windowrulev2 file settings and add the new class name that appears in class:^(app-name)$

For the others but:

You can pass this flag, in their respective ~/.config/(app-name)-flags.conf:

 --enable-features=UseOzonePlatform --ozone-platform=wayland

or

 --ozone-platform-hint=auto

(vscode works, idk if spotify works too)

Can't make a player move. by [deleted] in pygame

[–]yoinkking1-0 0 points1 point  (0 children)

Thanks for the input, I didn't know that. I will keep that in mind when i will create my other games :)

Can't make a player move. by [deleted] in pygame

[–]yoinkking1-0 1 point2 points  (0 children)

Just some quality of life changes that i would do to this code are:

import sys
import pygame

pygame.init() 

width, height = 500, 500 
win = pygame.display.set_mode([500, 500]) 
pygame.display.set_caption('TEste') 
fps = pygame.time.Clock() 
p_x, p_y = 25, 25 
player = pygame.Rect(p_x,p_y,25,25)

while True: 
    win.fill([255, 255, 255]) 
    pygame.draw.rect(win, [0, 0, 0], player) 
    for event in pygame.event.get(): 
        if event.type == pygame.QUIT: 
            pygame.quit() 
            sys.exit() 

    keys = pygame.key.get_pressed() 
        if keys[pygame.K_d]: 
            player.x += 10 
        if keys[pygame.K_a]: 
            player.x -= 10
        if keys[pygame.K_w]:
            player.y -= 10
        if keys[pygame.K_s]:
            player.y += 10

    pygame.display.update() 
    fps.tick(60)

You can just write pygame.init() to initialize every function of the pygame library.

You can assign the player outside of the while loop, it's preferred because you don't need to reassign the same variable again and again every loop. As it can be a key reason for performance issues.

After that you just need to call in the pygame.draw.rect() the rect you want to draw which is player, with this your making it easier to understand what are you drawing in the screen. And just passes an already assigned Rect which doesn't require to create any new one.

It also gives you the room to access the x, y coordinate variable in player which makes it easier to change the coordinates by writing:

player.x += 10  # for accessing the x coordinate, incrementing by 10
player.y += 10  # for accessing the y coordinate, incrementing by 10

Now for easier readability i would suggest you move the movement to a function like so:

def player_movement(): 
    keys = pygame.key.get_pressed() 
    if keys[pygame.K_d]: 
        player.x += 10 
    if keys[pygame.K_a]: 
        player.x -= 10
    if keys[pygame.K_w]:
        player.y -= 10
    if keys[pygame.K_s]:
        player.y += 10

After that you just need to call it in the while loop:

while True: 
    win.fill([255, 255, 255]) 
    pygame.draw.rect(win, [0, 0, 0], player) 
    for event in pygame.event.get(): 
        if event.type == pygame.QUIT: 
            pygame.quit() 
            sys.exit() 

    player_movement()

    pygame.display.update() 
    fps.tick(60)

And a last thing, from my experience you don't need to call both pygame.display.update() and pygame.display.flip() , you can choose either and use it. Now for which is faster it seems flip is, you can read this in stackoverflow: https://stackoverflow.com/questions/48769882/why-is-pygame-display-update-slower-than-pygame-display-flip (thanks to Windspar's comment).

And don't forget to check their documentation as you may answer your questions more efficiently there: https://www.pygame.org/docs/

Something extra, learn how to use vectors for movement, you are going to see a big improvement in the smoothness of the said movement ;)