Log in
Search
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.Easy Gravity and Good Healthbars
+3
CarnivorousA
3d
Elmzran
7 posters
:: Game Making :: Game Maker Help :: Code Database
Page 1 of 1
Easy Gravity and Good Healthbars
I went on the GMC and found a list of a bunch of awesome codes that work wonders.
Here's a code for Easy yet Good Gravity for Platformers:
1. Easy gravity (platformers)
This code helps because it creates gravity ONLY if there is space under you that doesn't have a solid object. It also limits your vertical speed which helps with falling through floor bugs. Lowering the number helps more but may make it look less realistic. Try using different limit amounts. Change obj_Solid to whatever object you use for your ground. It can be a parent object if you use more then 1 for your ground objects.
And here's some awesome code for a Good Healthbar.
Good Healthbar
Here's a code for Easy yet Good Gravity for Platformers:
1. Easy gravity (platformers)
- Code:
if !instance_place(x,y+1,obj_Solid)
gravity=0.5
if instance_place(x,y+1,obj_Solid)
gravity=0
if vspeed>10
vspeed=10
This code helps because it creates gravity ONLY if there is space under you that doesn't have a solid object. It also limits your vertical speed which helps with falling through floor bugs. Lowering the number helps more but may make it look less realistic. Try using different limit amounts. Change obj_Solid to whatever object you use for your ground. It can be a parent object if you use more then 1 for your ground objects.
And here's some awesome code for a Good Healthbar.
Good Healthbar
- Code:
//DRAW:
draw_set_color(c_red)
draw_line(x,y-10,x+linelength,y-10)
if hpamount > hpmax hpamount = hpmax
if hpamount < 0 hpamount = 0
//STEP:
linelength= hpamount / hpmax * sprite_width
Re: Easy Gravity and Good Healthbars
I've got an easier healthbar code that works for individual objects.
Make a hp variable in the create event, in this code the default hp is 10, so it says hp*10 so it's 100. Change this. If you have a hp of 100 get rid of the *10, if you have a hp of 50 make it *2 etc, so it's 100.
- Code:
draw_healthbar(self.x,self.y-4,self.x+31,self.y,hp*10,c_red,c_lime,c_lime,0,true,true)
Make a hp variable in the create event, in this code the default hp is 10, so it says hp*10 so it's 100. Change this. If you have a hp of 100 get rid of the *10, if you have a hp of 50 make it *2 etc, so it's 100.
Re: Easy Gravity and Good Healthbars
Yeah, the health bar code I posted was for the Player's Health bar. But there both awesome.
Re: Easy Gravity and Good Healthbars
After so long, I try and try to get individual healthbars to work, and I find out you can do it with one line of code. I was both annoyed and glad.
Re: Easy Gravity and Good Healthbars
Ive never needed healthbars, although i may use this. Any codes for 3d health bars?
Re: Easy Gravity and Good Healthbars
you should try doing that in 3d
the sivart- GameML Noob
- Posts : 3
Points : 54095
GameML Reputation : 1
Join date : 2009-07-14
Re: Easy Gravity and Good Healthbars
I can type everything I know about 3d in one post.
- Code:
d3d_start()
d3d_end()
Re: Easy Gravity and Good Healthbars
wouldn't you just use the code
- Code:
{
d3d_set_projection_ortho(0,0,640,480,0);
d3d_set_hidden(false);
draw_healthbar(x1,y1,x2,y2,health,c_black,c_red,c_lime,0,true,true);
d3d_set_hidden(true);
}
Re: Easy Gravity and Good Healthbars
Is it possible to create two separate health bars for two different objects at the top of the screen, you know like street fighter?
By the way Elmzran, I tried using the codes for the health bar and it did work to some degree, it's just the actual sprite for the object disappears.
I know it may have something to do with the DRAW event but I just don't know what!
By the way Elmzran, I tried using the codes for the health bar and it did work to some degree, it's just the actual sprite for the object disappears.
I know it may have something to do with the DRAW event but I just don't know what!
Re: Easy Gravity and Good Healthbars
Actually no it's ok, I managed to figure it out for myself.
Try my new game to see for yourself.
Try my new game to see for yourself.
Re: Easy Gravity and Good Healthbars
If an objct has a draw event it won't draw itself, you have to tell it to.Sparx the Cy-Wolf wrote:I tried using the codes for the health bar and it did work to some degree, it's just the actual sprite for the object disappears.
I know it may have something to do with the DRAW event but I just don't know what!
Re: Easy Gravity and Good Healthbars
So in otherwords, in the create event the first action should be to draw the sprite of the object....right?
(I suck at code)
(I suck at code)
Similar topics
» maybe an easy answer
» "Zero Gravity" collisions
» good bye to certain people
» good person or no?
» Simple(but good) Sliding Movement
» "Zero Gravity" collisions
» good bye to certain people
» good person or no?
» Simple(but good) Sliding Movement
:: Game Making :: Game Maker Help :: Code Database
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|