Legacy GM [Solved] draw_getpixel problem

D

Dxnxex

Guest
Hello,

I have a problem with function draw_getpixel.

Code:
var R,G,B;

var i = C_Sound;

draw_set_color(c_white);
draw_sprite_general(spr_exodus_colour,0,0,0,200,200,view_xview+view_wview-220,view_yview+20,1,1,0,c_white,C_Sound_bar[0],C_Sound_bar[0],c_white,1);
draw_sprite_stretched(spr_exodus_colour,1,view_xview+view_wview-235,view_yview+20,200,200)

if mouse_check_button(mb_left) {

    if point_in_rectangle(mouse_x,mouse_y,
    view_xview+view_wview-235+1,view_yview+20+1,
    view_xview+view_wview-235+12-1,view_yview+20+200-1) {
        
        C_Sound_bar[0] = draw_getpixel(mouse_x,mouse_y);
        
  }
  if mouse_x>= view_xview+view_wview-220+1 && mouse_x<=view_xview+view_wview-220+200-1{
    if mouse_y>= view_yview+20+1 && mouse_y<=view_yview+20+200-1{

    C_Sound_bar[i] = draw_getpixel_ext(mouse_x,mouse_y);
            B = (C_Sound_bar[i] >> 16) & 255;
            G = (C_Sound_bar[i] >> 8) & 255;
            R = C_Sound_bar[i] & 255;
    C_Sound_bar[i] = make_colour_rgb(R,G,B);           

  }}
 

 
}

When I do not make move in room it works perfectly, but after I move in room somewhere is bugs .. I dont know why? Can you guys please help?

Not MOVED room
sc_Work.png


Move camera in room (clicked on green)
SC_not.png
 

Simon Gust

Member
Must be mouse_x and mouse_y. They return the coordinates from 0 of the room instead of the screen.
use display_mouse_get_x() and display_mouse_get_y().
or mouse_x - view_xview and mouse_y - view_yview.
 
D

Dxnxex

Guest
Thank you very much,

Work both of versions :)

EDIT: display_mouse_get_ do not work in windowed mode
 
Last edited by a moderator:
Top