Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- # member variables here, example:
- # var a=2
- # var b="textvar"
- var mousepos
- var screenx = 200
- var screeny = 200
- func _ready():
- set_process(true)
- pass
- func _process(delta):
- update()
- func _draw():
- mousepos = get_viewport().get_mouse_pos()
- draw_rect(Rect2(0,0,screenx,screeny),Color(255,255,255))
- draw_line(Vector2(0,screeny*.5),Vector2(screenx,screeny*.5),Color(0,0,0))
- draw_line(Vector2(screenx*.5,0),Vector2(screenx*.5,screeny),Color(0,0,0))
- if mousepos.x < 100 and mousepos.y < 100:
- draw_rect(Rect2(0,0,100,100),Color(0,0,0))
- elif mousepos.x > 100 and mousepos.y < 100:
- draw_rect(Rect2(100,0,100,100),Color(0,0,0))
- elif mousepos.x < 100 and mousepos.y > 100:
- draw_rect(Rect2(0,100,100,100),Color(0,0,0))
- elif mousepos.x > 100 and mousepos.y > 100:
- draw_rect(Rect2(100,100,100,100),Color(0,0,0))
- print(mousepos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement