Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Tev's Scripts

Tev

Member

In this thread I will post my Game Maker scripts. I am pretty new to code, but this is something I enjoy to do.

It may only be a simple script but I use it so often, I thought it may be of use to others. Even people who don't know how to code should be able to understand it.

To properly use it you have to have three sub-images for the sprite of the button. The first one should be when the button isn't being hovered over the second one should be when it is. The third one should be when the button is pressed.

CREATE EVENT:
Sets the speed the sprite plays through its sub images to 0. also sets the image the sprite displays at the start to 0.

image_speed=0
image_index=0


STEP EVENT:
The first part just checks whether or not the button is touching the mouse cursor. If it is it changes the sub-image to 2. If not it changes the sub-image to 0.
The second parts checks to see if it's being clicked by the left mouse button. If it is it changes the sub-image to 3.

if position_meeting(mouse_x,mouse_y,(self))
{
image_index=1
}
else
{
image_index=0
}

if mouse_check_button_pressed(mb_left)
{
image_index=2
}

I know it's fairly simple but I thought I'd contribute to the section considering it's pretty bland so far...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top