【GameMaker】 find length and width of rectangle given perimeter

Information about object: object3
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

global.click=0;
Step Event:
execute code:


if global.click==2
{
width=x2-x1;
height=y2-y1;
global.click++;
}
if mouse_check_button_released(mb_left) && global.click==1
{
x2=mouse_x;
y2 =mouse_y;
global.click+=1;
}
if mouse_check_button_released(mb_left) && global.click==0
{
x1=mouse_x;
y1= mouse_y;
global.click+=1;
}

Draw Event:
execute code:

if global.click==3
{
    draw_set_colour(c_white);
        draw_rectangle(x1,y1,x2,y2,false);
            draw_set_colour(c_blue);
                draw_text(10,20,"width "+string(width));
                    draw_text(10,40,"height "+string(height));
                        draw_text(10,60,"perimeter "+string(2*(width+height)));
                            draw_text(10,80,"area "+string(width*height));
                                
                            }
                            draw_text(100,100,"Click "+string(global.click));



Information about object: object4
Sprite: sprite1 Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Mouse Event for Left Released:
restart the game
execute code:

global.click = 0;

No comments:

Top 3 UX Design Articles of 2024 to Remember

Based on most subscriptions ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *