Jump to content


Richard

Member Since 04 Oct 2003
Offline Last Active Private

Posts I've Made

In Topic: Platform Enemy Won't Do His Job!

18 September 2011 - 07:12 AM

if o_Player > x {
char = 1
}
if o_Player < x {
char = 0
}

I assume o_Player is the name of the player object resource? This code tries to compare that object resource name to the enemy's x coordinate, which doesn't make sense! Game Maker does internally give each resource a number, so as far as it is concerned it is acceptable to compare that to a numerical x coordinate and that is why you don't get an error - but I imagine you actually intended to compare the enemy's x coordinate to that of the player.

You could use o_Player.x to refer to the player's x coordinate, but only as long as you only ever use one single instance of the player object. If you do sometimes use more than one for any reason you'll need to use the instance ID of the specific player instance whose x coordinate you need to refer to.

Hope that helps.

Richard

In Topic: Test instance count problem

11 September 2011 - 01:00 PM

Wow, thanks I never thought about that, I added another check to see if its x or y are lower than 0 and it is now working flawlessly.

Haha - ain't this stuff fun?! Glad you got it working. Posted Image

In Topic: need a way to play a queue of sounds

11 September 2011 - 12:57 PM

omg,my speaker is broken(that why im using show_message instead)
is that a problem?

I'd be surprised if that was a problem when using the sound_isplaying function, but I'm afraid I don't know. It'd be easy enough for you to test this, though... Posted Image

oh and forgot,sorry for the double post but i already have a sound_started variable,it's call Playing[2](sorry for the comment_less codes)

Unless I haven't read your code carefully enough, though, that variable is not being used in the same way I was suggesting you might need to.

Mine is set up so that it is not set true when you give the command to play the sound - but only when the game detects that it has actually started playing. If you use the sound_isplaying function before then, it might be that you move onto the next sound before the first sound ever actually got started. As that help file excerpt warns, there might be a moment between you giving the command to play the sound and the sound actually starting, during which time the sound_isplaying function would return false.

You'll need to test this, though - try playing around with this idea. Unless anybody offers more reliable, convincing advice than me!

Richard

In Topic: Test instance count problem

11 September 2011 - 09:37 AM

//Kill if outside room
if y > room_height
{
 instance_destroy()
}
if x > room_width
{
 instance_destroy()
}

Do they always leave the room by going beyond the right hand edge or the bottom edge? What if their coordinates are less than 0 (or in other words, what if the objects are above the top of the room or to the left of the left hand edge of the room)?

Richard

In Topic: Turkey exercise

11 September 2011 - 09:16 AM

You could even use this function to choose the new x coordinate:

irandom_range(x1,x2)
Returns a random real number between x1  (inclusive) and x2 (inclusive). Both x1 and x2 must be integer values (otherwise  they are rounded down).

I think that's meant to say "a random integer" rather than real number - if the word integer is unfamiliar, it just means whole number. You're only interested in whole numbers when you're setting an instance's coordinate position, of course. If your turkey should be between x coordinates of 64 and 256, for example, you could do:

x = irandom_range(64, 256);
You're right that you need to use alarms to control the timing. You could use alarm 0 for the 5 second delay while the turkey is visible and alarm 1 for the 30 second delay before it reappears. In the alarm 0 event you'd set its x coordinate randomly, as we've suggested, and set alarm 1. In the alarm 1 event you could set its x coordinate to -100 (so it goes off screen) and set alarm 0.

If you haven't used alarms much before, read about them in the help file first. In particular, note that they are set in steps not seconds, so for example setting an alarm for 5 will be far less than 1 second! The room speed determines the number of steps per second. Hope that helps!

Richard