python – Player not moving camera to the other side of the screen when hitting the screen edge

I’m working on a game where I want the player to appear on the other side of the screen when they get to the edge of the screen, essentially mimicking the background moving. When the player gets to the edge of the map, they shouldn’t be able to move anymore. I’m just trying to get the first part to work where the player appears on the other side of the screen after hitting the edge. My full code is below.

#Import the pygame module
import pygame
from pygame.locals import (


BLUE = (0,0,255)
PURPLE = (153,50,204)
GREEN = (0,128,0)


class Map():
    def __init__(self,map): = map
    def update_map(self):

# Define constants for the screen width and height
# Setup the clock for a decent framerate
clock = pygame.time.Clock()

# Define a player object by extending pygame.sprite.Sprite

# The surface drawn on the screen is now an attribute of 'player'
worldMaxX = SCREEN_WIDTH*3


class Camera():
    def __init__(self):
        self.worldX = 0
        self.worldY = 0
        self.cameraX = SCREEN_WIDTH
        self.cameraY = SCREEN_HEIGHT
    def worldCoordinates(self,screenX, screenY):
        worldX = self.cameraX + screenX
        worldY = self.cameraY + screenY
        return (worldX, worldY)

    def screenCoordinates(self,worldX, worldY):
        screenX = worldX - cameraX
        screenY = worldY - cameraY
        return (screenX,screenY)

class Player(Camera):
    def __init__(self):
        self.player_surface = pygame.Surface((25, 25))
        self.player_surface.fill((255, 0, 255))
        self.rect = self.player_surface.get_rect(center = (25,25))

    def update(self, pressed_keys):
        # Move the sprite based on user keypresses
        if pressed_keys(K_w):
            self.worldX,self.worldY = self.worldCoordinates(self.rect.x,self.rect.y)
            self.worldY -= SPEED
            self.rect.x,self.rect.y =  self.screenCoordinates(self.worldX,self.worldY)

        if pressed_keys(K_s):
            self.worldX,self.worldY = self.worldCoordinates(self.rect.x,self.rect.y)
            self.worldY += SPEED

            self.rect.x,self.rect.y =  self.screenCoordinates(self.worldX,self.worldY)

        if pressed_keys(K_a):
            self.worldX,self.worldY = self.worldCoordinates(self.rect.x,self.rect.y)
            self.worldX -= SPEED

            self.rect.x,self.rect.y =  self.screenCoordinates(self.worldX,self.worldY)

        if pressed_keys(K_d):
            self.worldX,self.worldY = self.worldCoordinates(self.rect.x,self.rect.y)
            self.worldX += SPEED
            self.rect.x,self.rect.y =  self.screenCoordinates(self.worldX,self.worldY)

    def updateCamera(self):
    #Move camera
        if (self.rect.x < 0):
            self.rect.x = SCREEN_WIDTH
        if (self.rect.x >= SCREEN_WIDTH):
            self.rect.x = 0
        if (self.rect.y <= 0):
            self.rect.y = SCREEN_HEIGHT
        if (self.rect.y >= SCREEN_HEIGHT):
            self.rect.y = 0

    def render(self,position):
        screen.blit(self.player_surface, position)

# Initialize pygame

# Create the screen object
# The size is determined by the constant SCREEN_WIDTH and SCREEN_HEIGHT
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

# Instantiate player. Right now, this is just a rectangle.
player = Player()

# Variable to keep the main loop running
running = True

# Main loop
while running:

    # for loop through the event queue

    for event in pygame.event.get():
        # Check for KEYDOWN event

        if event.type == KEYDOWN:
            # If the Esc key is pressed, then exit the main loop
            if event.key == K_ESCAPE:
                running = False
        # Check for QUIT event. If QUIT, then set running to false.
        elif event.type == QUIT:
            running = False

    # Get all the keys currently pressed
    pressed_keys = pygame.key.get_pressed()

    # Fill the screen with black
    screen.fill((0, 0, 0))

    # Draw the player on the screen

    # Update the display


What happens though is that my player square doesn’t appear on the other side of the screen when going left or up. But, I don’t understand why. I thought the code below would work, which it does when moving right, and down, but not up or left. What am I doing wrong with the camera method updateCamera that this isn’t happening the way I expect it too?

    def updateCamera(self):
    #Move camera
        if (self.rect.x < 0):
            self.rect.x = SCREEN_WIDTH
        if (self.rect.x >= SCREEN_WIDTH):
            self.rect.x = 0
        if (self.rect.y <= 0):
            self.rect.y = SCREEN_HEIGHT
        if (self.rect.y >= SCREEN_HEIGHT):
            self.rect.y = 0

Magento 2: which event fires before a product gets added into cart on the admin side?

When an admin wants to reorder an item I want to check whether that item is enabled or disabled and if its disabled I want to skip that product based on its SKUs from adding into my cart. Which event fires on the admin side that can help me to adding this feature into my magento site?

Faceted filtering vs side wide search

On some ecommerce websites, when user visits specific category he can narrow results using faceted filtering. Hovewer, text search field (usually placed on top of page) sometimes just redirects user to side-wide search results page.

What if we want to narrow category contents by specific phrase entered into search field (just like we use checkboxes in faceted search), but we also want to give option for side wide search.

What are best practices for using both of these functionalites simultaneously on one website?

How does one construct an octagon and side pairing transformations on that octagon, so that the surface is a closed surface of genus 2?

I am aiming to determine what are the initial characteristics of a side-pairing transformations for a hyperbolic octagon so that a Fuchsian group may be generated and a surface of genus 2 can be formed from the quotient of the hyperbolic plane and a Fuchsian group.

orders – Magento 2: Which event fires when I reorder from admin side?

I have activated reorder on my magento 2 site. Now I want a event which can catch reorder both in frontend and backend (admin). I am using “controller_action_predispatch_sales_order_reorder” for my front end which is working perfectly fine but I want to catch reorder on the backend as well. Can anyone tell me which event to use for backend as “controller_action_predispatch_adminhtml_sales_order_create_reorder” is not working for backend?

Here is my code:


<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch_adminhtml_sales_order_create_reorder">
    <observer name="admin_reorder_observer" instance="VoltLightingOrderInfoObserverAdminReorder" />

<event name="checkout_submit_all_after">
    <observer name="admin_order_observer" instance="VoltLightingOrderInfoObserverAdminOrder" />

Observer file


namespace VoltLightingOrderInfoObserver;

use MagentoFrameworkEventObserver;

use MagentoFrameworkEventObserverInterface;

class AdminReorder implements ObserverInterface

public function execute(Observer $observer)
    $order= $observer->getEvent();

    echo "hello world";


enter image description here

homepage – If my blog on the side has no traffic is it still contributing to my home page rank?

In other words, does my blog confer some domain authority to my website, despite the fact that it receives no traffic?

Note that my rank is very good, so I’m just trying to determine why.
My home page is by far my main source of traffic, and that’s what I want.

If the answer was “no”, then logically could I delete my blog without negatively affecting my rank? If “yes”, then I can only improve things by continuing to blog and update that content, correct?

dnd 5e – Does a Bugbear PC take damage when holding an enemy on the other side of a Wall of Fire with Grapple?

By the rules as written, the bugbear is not in the area that causes damage, so it won’t take damage.

One side of the wall, selected by you when you cast this spell, deals 5d8 fire damage to each creature that ends its turn within 10 feet of that side.

The bugbear is 15ft away.

A creature takes the same damage when it enters the wall for the first time on a turn or ends its turn there.

The bugbear is not entering the wall. It sounds strange, I agree. Another strange possibility is that another creature can cross the space with the bugbears arms without any issue, which again sounds strange.

Do the above make perfect sense? Not really. For these edge-cases, which are not covered by the rules (in this case, being able to grapple something that is 10ft away from you), the DM should use common sense and make rulings that the table agrees with.

Different groups will prefer different approaches. At my table, I’d make the bugbear not take any damage, and the grappling space with his arms would be difficult terrain (if some other creature decided to run across it somehow). Another reasonable ruling would cause damage to the Bugbear but grant him a Dexterity save. Other tables would come to their own conclusions.

PS: as the other answer stated, this 10ft grapple is only valid on the bugbear’s turn, when it attacks. After that, the enemy is no longer grappled. So most of the argument is pointless, the Bugbear will not end its turn inside the “danger zone”.

Comparing DirectAdmin and CPanel, side by side

I just signed up for an inexpensive DirectAdmin webhosting account, for the sole purpose of comparing DirectAdmin to CPanel (which I use at … | Read the rest of

dnd 5e – Should a Bugbear PC take damage when holding an enemy on the other side of a Wall of Fire with Grapple?

Bugbears have long arms, allowing them to grapple enemies 10 ft. away.

The Bugbear’s square is not in the effect range of the Wall of Fire.
However, about 5 ft. worth of one of the Bugbear’s hands is supposedly in a square that is.

Mechanically, should the Bugbear take damage? If so, simulationally, how do we reconcile that such a small fraction of the player being in the square and taking just as much damage as a character residing fully in the area of effect?

enter image description here

authentication – Securing client side code of react application

Consider splitting your React application into several SPAs. Each SPA is rendered by its own script bundle. For example you can have Login SPA rendered by login.js bundle and the rest of the application catered for by the App SPA rendered by app.js bundle.

The first bundle would allow users to login. After that their identity is established and the payment status is retrieved from a database. The link to the next webpage with the paid-only functionality will be conditionally shown to paid users, otherwise the link will be hidden but still easily discoverable by inspecting HTML via Page Source browser’s menu.
Following this link will make the webrowser load the second SPA which calls the API endpoints for the paid users and contains webpages restricted to the subscription.

Are there any methods to prevent(or harden the ability to remove certain restrictions/api calls etc) users to access the app without paying?

The webserver will refuse to serve the app.js bundle in case of a non-paying user.

As a practical example of a React app split into two SPAs with two script bundles see demo website and the Crisp React solution. The demo does not make the second bundle download conditional but this functionality can be easily added.