Making a power hit bar

M

missfiebie

Guest
Hey guys and girls,
I am new in Game Maker so I need a little help.
I want to make a golf-like game in top down. The main-problem that I have is that i want to make a bar , where the player can see how strong he will hit the ball. So when you hold the mouse the bar raise and till a maximum. For example the bar starts by zero which is red and than goes to green as much powerful the hit gets. If its possible if you hold the bar goes back to red if you hold to long.
How do I programm that ?
 
D

DumbChester

Guest
You can make a Bar in many ways , You can use a Sprite with 100sub images or something easier
here's how you make that bar,
Create a object, name it obj_controller, no sprite , put it in your room

in that obj_controller's create event put this
Code:
power=0 //The variable for power
spd=5 //the speed of the bar increasing decreasing
can_shoot = true //this will determine if you can shoot or not, you don't want to shoot endlessly
in step event
Code:
//Check if can shoot then increase bar
if can_shoot = true
{
   if keyboard_check(mouse_button(mb_left))
        {
            if power < 100
               {
                    power +=spd
                }
            else
               {
                    power-=spd
               }
       }

//Checks the release
    if keyboard_check_released(mouse_button(mb_left))
        {
            can_shoot = false
             //Execute what happens if you release the bar
            can_shoot = true
        }



}

Similar to this, Tweak tweak and Discover things yourself , use manual too
 
Last edited by a moderator:
Top