Jump to content


Photo

Question about using a step event


  • Please log in to reply
10 replies to this topic

#1 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 01:26 AM

Hello,

I'm sorry that I'm new and not familiar with this program. I'm using the lite Windows version. I went through both tutorials that came with the game (a bouncing fruits game and a scrolling shooter) and made it through both (though the scrolling shooter one had several places where the author assumed the reader was familiar with certain functions that I was still unfamiliar with - but a couple Google searches got me through it). I've managed to get a start on my game, but I'm having a hard time getting a certain function to work.

Part of the game involves a building that falls into disrepair each night. I've created a day/night cycle using an object called 'night' which is just a giant black screen set at alpha 0.5 (I watched a tutorial on Youtube to figure that part out). I was able to set up a timeline which causes the 'night' object to be created every set interval and then destroyed again after a moment. This functions fairly smoothly for a day/night cycle.

What I'm having trouble with is convincing the building to be damaged when the night object appears. I thought it would a fairly simple matter of adding a step event with 'test instance count' from the control pane. I set it to 'if number of objects obj_night is equal to 1', then added start and end blocks underneath to destroy the 'wall' objects and replace them with damaged wall objects. (Technically, I use the 'create random' feature to make it about a 50% chance that each wall portion becomes damaged.) But when I test it, the night object appears as it should, but the walls do not change. I'm not sure what I'm doing wrong. To the best of my understanding, the 'step' event is supposed to constantly monitor, so I would think that it would notice when the night object appears and therefore cause the ensuing actions to occur. What am I missing?

Thank you so much for your help. I'm sorry again for bothering you. I tried to search and see if there was an answer to my question, but I was unable to find anything.
  • 0

#2 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1123 posts
  • Version:GM7

Posted 11 August 2012 - 02:00 AM

How exactly are you destroying and creating blocks? Is each wall a different object? Are you sure the object that you have the code in is in the room when night time comes around (since I'm not sure what object you have doing this)? You are destroying all wall objects and recreating each one?
  • 0

#3 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 02:12 AM

How exactly are you destroying and creating blocks? Is each wall a different object? Are you sure the object that you have the code in is in the room when night time comes around (since I'm not sure what object you have doing this)? You are destroying all wall objects and recreating each one?



Thank you very much for your response! What I had used before was a timer event which activated two actions: destroy the instance (under main1 tab) and create random under the same tab, using the 'relative' option to make sure that the damaged wall object was created in the same space. Using a timer, this worked perfectly every time. I technically could simply change all the timers to coincide with the night timeline, but I thought it would be a lot easier if I could just have the objects change when the timeline creates the 'night' object (that way, if I change my mind on the timing, I don't have to go and change the timing for every object).

Each wall is a different object. Originally, each wall was set on the timer to destroy itself and then create at random either a new wall or a damaged wall (about 50% chance). This worked perfectly. After I learned a bit more about timelines and how to create a day/night cycle (more below on that part), I thought it would be easier to make the walls respond to the night object's presence rather than a timer (see above). I deleted the timer, then added a 'step' event which tells it, if the number of object 'night' is equal to 1, to go through the destroy/create random cycle. I used start and end blocks before and after those two commands (destroy and create random) to make sure they were both tied into the 'test instance count' action. However, when the night object appears, the walls do not change. I watched it through two cycles just in case the 50% chance came up VERY lucky, but nothing changed in the second appearance of 'night,' either.

As for the 'night' object, I have an invisible object which also sets off timers. It is in the room. I gave it a 'create' event to set the night timeline. The night timeline then creates the object 'night' and destroys it after a second. I am not sure where the object is created. It's basically a sprite the size of the entire screen made completely of black with alpha set at 0.5 (so it basically darkens the entire game for a second, then returns to normal brightness; hence the appearance of day/night). I'm assuming the object is present because the screen does go dark at the correct timing when I test the game. But the wall objects do not respond as if the night object is present.
  • 0

#4 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1123 posts
  • Version:GM7

Posted 11 August 2012 - 02:21 AM

Actually, you can keep the timer. Just activate the timer in the timeline and set it (timer) to 1. That way, you won't have to worry about matching the timer and timeline.

The only reason why your current method isn't working is that there is more than one night object being created (perhaps 2). You said the night lasts for about a second, but if you got your method to work, your code would run through multiple times causing more walls to be damaged than what you originally planned.
  • 0

#5 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 02:30 AM

Thank you so very much! I feel a bit dopey for not thinking of that myself; I guess I got overly excited about using the new tricks I'd learned in the tutorials... :) Thank you again!
  • 0

#6 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 03:04 AM

Sigh... I must be doing something wrong. I tried to do what you suggested: I adjusted the timeline to include setting 'timer 0' to 1. Then I deleted what I'd done before with the 'wall' object and instead put a 'timer event' (timer 0) with the actions 'destroy' and 'create random.' Nothing happened. I tried moving the timer action up and down the timeline list. Nothing made it work. Finally, just to make sure I wasn't going crazy, I deleted the timer from the timeline and instead set it in the wall, like I had before - a 'create' event with the action of setting 'timer 0' to 90 (the same number of steps before the first 'night cycle' on the timeline). The walls damaged themselves just like they had before, the way they're supposed to (the timing was a bit off, not sure why).

I'm not sure what I'm doing wrong. Or maybe this is just because I have the lite version? I'm not sure why timer 0 will function perfectly on the object but not on the timeline, which is attached to an object and set in the room. :(
  • 0

#7 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1123 posts
  • Version:GM7

Posted 11 August 2012 - 03:12 AM

You remembered to set the timer for the wall object right? The little bubbles on top that list 'self other object:' Setting it to self does nothing.
  • 0

#8 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 03:28 AM

*facepalm*

Thank you. I changed the bubble to 'object' and made it the wall object. Now the damage happens as expected.

However... the damage happens a full second before the night cycle begins. Not sure why?
  • 0

#9 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 04:57 AM

I think I figured it out. It's working now. Not sure what I did to make it work now, but now it does... :) Thank you again very much!
  • 0

#10 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1026 posts
  • Version:GM8.1

Posted 11 August 2012 - 12:43 PM

(though the scrolling shooter one had several places where the author assumed the reader was familiar with certain functions that I was still unfamiliar with - but a couple Google searches got me through it)


I just want to point out that if you press F1 in Game Maker, or click on the blue and white interrogation mark icon, the help file will pop up, which is basically a user manual, with all the functions. That should save you quite a few trips to Google.
  • 0

#11 Aggeloi

Aggeloi

    GMC Member

  • New Member
  • 7 posts
  • Version:GM8

Posted 11 August 2012 - 04:55 PM

LOL - oh yes, I've become well acquainted with that function! But there were some things that I still had to turn to Google for help understanding. I'm not trying to slam the tutorial itself; it was well-written for someone who has at least a basic understanding of the program. For a complete newb like myself, it just took a couple extra steps to figure it out. But I got there in the end :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users