Jump to content


Photo

Specify a range of values


  • Please log in to reply
4 replies to this topic

#1 _174413

_174413

    GMC Member

  • New Member
  • 22 posts
  • Version:GM8

Posted 22 July 2011 - 12:41 AM

Using the position_empty(x,y) function, I want to specify a range of values for x.

Specifically, the width of the object - from it's very left pixel to it's very right.

The object's coordinates start from the very top left as usual.

Can you help me? Have explained the question correctly?

Many thanks.
  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 22 July 2011 - 12:48 AM

You'd have to use a loop:

for (p=0; p<WIDTH; p+=1) {
  if (!position_empty(x+p, y)) {
    /* This position is not empty */
  }
}

Or perhaps you'd rather use the collision_line() function instead of position_empty()?

-IMP ;) :)
  • 0

#3 _174413

_174413

    GMC Member

  • New Member
  • 22 posts
  • Version:GM8

Posted 22 July 2011 - 12:52 AM

You'd have to use a loop:

for (p=0; p<WIDTH; p+=1) {
  if (!position_empty(x+p, y)) {
    /* This position is not empty */
  }
}

Or perhaps you'd rather use the collision_line() function instead of position_empty()?

-IMP ;) :)


A loop, huh? I hadn't thought of that. I'll have a go with the for loop.
I've not used collision_line() before. I'm not sure how it works. Could you provide a brief description?

Edited by _174413, 22 July 2011 - 12:52 AM.

  • 0

#4 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 22 July 2011 - 12:55 AM

I can copy and paste from the Help File, sure:

collision_line(x1,y1,x2,y2,obj,prec,notme) This function tests whether there is a collision between the line segment from (x1,y1) to (x2,y2) and entities of object obj. This is a powerful function. You can e.g. use it to test whether an instance can see another instance by checking whether the line segment between them intersects a wall.


So you can supply the keyword all as the object to check for.

-IMP ;) :)
  • 0

#5 _174413

_174413

    GMC Member

  • New Member
  • 22 posts
  • Version:GM8

Posted 22 July 2011 - 12:58 AM

I can copy and paste from the Help File, sure:

collision_line(x1,y1,x2,y2,obj,prec,notme) This function tests whether there is a collision between the line segment from (x1,y1) to (x2,y2) and entities of object obj. This is a powerful function. You can e.g. use it to test whether an instance can see another instance by checking whether the line segment between them intersects a wall.


So you can supply the keyword all as the object to check for.

-IMP ;) :)


Many thanks. I feel a bit guilty now that you've looked that up. I could've done it. I must look really lazy!
Anyway, I'll be alright now, so cheers for your help!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users