#π Pygame Tutorial help
24 messages Β· Page 1 of 1 (latest)
@elder quarry
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
it's a method of whatever is in PhysicsEntity
open scripts.entities
it might be custom and not a native pygame class
import pygame
class PhysicsEntity:
def __init__(self, game, e_type, position, size):
self.game = game
self.type = e_type
self.position = list(position)
self.size = size
self.velocity = [0, 0]
def update(self, movement=(0, 0)):
frame_movement = (movement[0] + self.velocity[0], movement[1] + self.velocity[1])
self.position[0] += frame_movement[0]
self.position[1] += frame_movement[1]
def render(self, surface):
surface.blit(self.game.assets['player'], self.position)
This is entities file
now you can see here what update does
I'm just wondering what ```py
self.player.update((self.movement[1] - self.movement[0], 0))
does
ooooooooooooooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhh
sorry I made a silly error
I didn't see that
When you do arithmetic operations with a boolean, it parses True as 1 and False as 0
def update(self, movement=(0, 0)):
frame_movement = (movement[0] + self.velocity[0], movement[1] + self.velocity[1])
self.position[0] += frame_movement[0]
self.position[1] += frame_movement[1]
this is what self.player.update will call
mhm I understood but was wondering what the update() does
yea thanks a lot
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.