Jump to content


Goose241

Member Since 16 Jun 2005
Offline Last Active Private

Topics I've Started

Restrict Mouse Movement

15 November 2010 - 12:41 AM

I would like to make a sort of "barrier" around the player, that within the mouse can move freely, but when it reaches the boundary it moves against it, like it's trapped:

Posted Image

I have this code in the step event right now:

dis = min(view_wview[0]/2,view_hview[0]/2);
if distance_to_point(mouse_x,mouse_y) > dis {
    display_mouse_set(x+lengthdir_x(dis,dir),y+lengthdir_y(dis,dir));
    }

But obviously that's not working.  Right now it just sets the mouse at the bottom of the screen.  What should I change, or is there another way I could do this better?

Help with enemy movement

12 November 2010 - 11:24 PM

I'm making a grid-based maze game, and I would like the enemies to figure out with directions they can go, and then choose one at random.  I have the creation event set as follows:

// 0 = right, 1 = up, 2 = left, 3 = down.
directions[0] = 0;
directions[1] = 1;
directions[2] = 2;
directions[3] = 3;

and the step event is:

    
if place_snapped(32,32) {
    dir = irandom(3);
    while !place_free(x+lengthdir_x(32,directions[dir]),y+lengthdir_y(32,directions[dir])) {
        dir = irandom(3);
        }
    motion_set((directions[dir]*90),4);
    }
    

But it's not working at all.  What am I doing wrong?

Creating an object from string

09 November 2010 - 08:12 AM

I know you can't create an object from a string, so I tried to make the object name and convert it to an id:

instance_create(10,20,real('object'+'6'));

But that's not working.  Any suggestions?

Firing a laser gun

08 November 2010 - 11:16 PM

Hi everyone,

I'm using this code from an example:

if global.drawlaser {
newx = x + 800 * cos(degtorad(direction));
newy = y - 800 * sin(degtorad(direction));
draw_set_color=c_yellow;
draw_line_width(x,y,newx,newy,2);
}

But when I run the game it comes out as a 1px width, black line.  How can I make it draw a different color, 2px width, and anti-aliased?

Thanks

Really Quick, Stupid Question

10 April 2010 - 06:50 AM

How do you raise something to a power in GML?