• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Floating Ghost Enemies - Programming Help

W

Will Unwin

Guest
Hello, I'm currently working on a Ghostbusters inspired side scroller for my course and I'm having trouble creating enemies for the game. My idea was to have regular ghosts as enemies that would float around when idle, then chase the player upon them getting close to the ghosts.

I've been having a hard time implementing this, with the different code I've tried never working properly. I've got minimal experience with Game Maker so a lot of this is new to me, and all help is greatly appreciated.

Thank you friends.
 
Last edited by a moderator:

Tthecreator

Your Creator!
What code do you have already?
First just start with making the ghosts move around their spawn point. Just that.
How have you been taking that on?
My idea on how to take this is make the ghost move either left or right.
Then you pick random times for your ghost to change direction like this:
create event:
Code:
alarm[0]=irandom_random(3,10)//random time between 3 and 10 seconds
This code on top here takes a random time and sets up an alarm. (an alarm is like a timer which executes some code at the end of it.)
Alarm 0 event:
Code:
speed=speed*-1 //make the speed go the opposite way, by multiplying it by -1.
alarm[0]=irandom_random(3,10)//random time between 3 and 10 seconds
This will flip your direction then reset your alarm.


I hope that helped you somewhat. I dived right into some code, which you might not have that much experience at. But I hope you can at least read what it's supposed to do.
 
W

Will Unwin

Guest
Thank you for the quick reply! I'm starting here with no code, because none of it worked especially well and I thought it'd be better to start over with a clean slate. I also feel like I used the wrong language in my first post, as I used the word spawn point, implying I had a system that spawned enemies. What I instead meant was I wanted the ghosts to float around the point where I manually placed them within the room. Sorry if this caused any confusion.

I'll try that code out, see if it has any effect.
 
Top