0 votes

can someone help me please
i try to recreate tetris game following this tutorial

https://www.youtube.com/watch?v=fne_uEozW9o&t=140s

but i encounter a problem when the block almost arrive at bottom and i suddenly rotate it, it become over the game area, what should i do to fix it ?

i try to put box collision at bottom, but because the block only using 2dnode and sprite,it's not working(i try to put collision box on block node but it' not working)
is it the problem in my rotate code

func can_rotate(val) -> bool:
if Globals.inactive.has(Vector2(get_parent().position.x+val.x,get_parent().position.y+val.y)) or is_off_screen(Vector2(get_parent().position.x+val.x,get_parent().position.y+val.y)):
    return false
else:
    return true

func isoffscreen(vec) -> bool:
if vec.x < 0:
return true
elif vec.x >= getparent().getparent().getrect().size.x:
return true
elif vec.y < 0:
return true
elif vec.y >= get
parent().getparent().getrect().size.y:
return true
else:
return false

how to change is_off_screen to sprite size?
https://ibb.co/7RGf7Xr
thank you for your help

problem

Godot version 3.3.2
in Engine by (14 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.