Fangames > Programming Questions
Making a save blocker
PanKarmelek:
Hello!
I decided to have fun and make a fangame. I understand the basics of Gamemaker but I'm having a small problem. How do I make a save blocker? I tried it many different ways but I just don't know how to force an object to block bullets. I'd really appreciate the help, thanks! :atkHappy:
Kyir:
You might be using a fairly archaic engine if it doesn't come with them constructed already. Anyway, there are a bunch of different ways, so I'm just going to copy/paste the code from the KS engine for you.
Create an object called bulletBlocker and give it a sprite. Using a 32x32 one is easiest. Make sure the visible box is unchecked unless you want it to be something the player can see.
In the step event of the bullet object, use this code:
if place_meeting(x+hspeed,y,bulletBlocker) {
instance_destroy();
}
Then, just place the bulletBlocker object wherever you want bullets to be blocked.
If you want to make something fancy a slightly different method is better. For instance, if you want to make something that animates whenever a bullet hits it, you'll want to make that entire animation before anything else (make sure it starts from an image that is empty if you want it to be invisible at first.) Set image_speed = 0 in the create event. Then instead of using code in the bullet use a collision event in the bullet blocker object to destroy the bullet and set the image_speed to something above 0. That will play the animation.
Then just make an animation end event that sets the image_index and image_speed back to 0 so everything goes back to normal when the animation's done playing. It's pretty simple when it comes down to it, and you can apply this sort of coding to a lot of other things in your game.
Again though, I would make sure you're using a modern engine before getting too far in your game.
PanKarmelek:
Thanks for help! I'm using the yuutu engine. I hope it's good?
Kyir:
I think yuutu used to be standard? I never used it personally. YoYo's GMS engine is probably better annotated if you're still trying to find your way around an engine.
PanKarmelek:
I'm still learning, my fangame is nothing really special. The problem I have is that I can't make an object that's like, 1px wide and will block the bullets. Im gonna try to use the thing you just gave me, maybe it will work.
Navigation
[0] Message Index
[#] Next page
Go to full version