#๐Ÿ”’ problems in beginnner's code

77 messages ยท Page 1 of 1 (latest)

river sigilBOT
#

@bold rose

Python help channel opened

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.

karmic schooner
#

!pastebin if the code/error is too long @bold rose

river sigilBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

karmic schooner
#

if you're trying to share files, you can't.

bold rose
#

that sucks

#

how does this work

random coral
#

no it doesn't

bold rose
random coral
#

you know what does suck

#

viruses

bold rose
#

ah i think i got it

karmic schooner
#

nice

random coral
#

can you say what the problem is?

#

are you getting any error?

bold rose
#

no errors

random coral
#

ok

bold rose
#

when i launch the code:
-the first block dissapears after you place it
-the block you are currently placing has a copy of it and its overlaping

random coral
#

it's a pretty long code so if you're not sharing what the problem is it would be very hard to spot it like that

bold rose
#

thats the first block

#

when i place it this happens

#

the first block i placed dissapears and the next one i gets a copy of it

bold rose
#

and the previous copy dissapears too

#

the only block that stops is the red one at the beginning

#

but it disappears for some reason

random coral
#

new block is placed with down key right?

ember geyser
#

I don't know if this is the issue, but new_block = blocks[-1] doesn't make a copy. That makes that refer to the other block.

bold rose
random coral
#

ok

#

OK so it doesn't disappear you're just changing it

bold rose
#

changing it?

random coral
#

yes and then you also add a copy of it to the lisg

#

wait I'll show

#
else:
                        new_block = blocks[-1]
                        new_block.y -= 20
                        new_block.color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
                        new_block.speed += 0.5
                        blocks.append(Block(0, new_block.y, new_block.width, new_block.height, new_block.color, new_block.speed))
                        score += 1 ```
#

this else block runs when there are 1 or less blocks

#

so it will always run at the start

#

the first line takes the initial block and calls it "new_block"

#

blocks = [initial_block]

random coral
#

this is the same as saying new_block = initial_block

bold rose
#

blocks stop now

#

the second one dissapears now

#

and there is a moving copy instead

#

and its impossible to lose the game now

#

blocks get smaller for every part you miss, like intended

#

but if you miss while placing the block the game continues on

#

like so

#

@random coral i ask your assistance

#

lend me your help

#

i guess this post is not relevant anymore, since its old

random coral
#

give a minute hehe

bold rose
random coral
# bold rose

without looking at the code I can see that the collision checking only works partly. it places it on the correct height but it it doesn't check the horizontal collision

#

so make sure to check horizontal overlap as well

#

that invisible block is pretty weird, it might take me a while to find this bug

bold rose
#

the clone of the block is still appearing while placing

#

the second block, doesnt have a copy

#

until its gone

#

the following blocks have a copy

bold rose
random coral
#

can you update the code

bold rose
#

sure

random coral
#

doesn't work

bold rose
#

this one should

river sigilBOT
#
Python help channel closed

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.

#

๐Ÿ”’ problems in beginnner's code