Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!
Log in

I forgot my password

Search
 
 

Display results as :
 


Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com
Keywords


Easy Gravity and Good Healthbars

View previous topic View next topic Go down

Easy Gravity and Good Healthbars

Post by Elmzran on Fri Jul 10, 2009 11:28 am

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)

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
I've been asked many time on how to make a healthbar and many times the person wants it to only be so long even if it's a lot of HP. (just goes down slower...etc) Well this code does it all. This one uses a line which is smaller and cleaner looking rather then a rectangle. Just set hpamount, hpmax, and make sure linelength=0 is in create. Also be sure to put the first part of the code in draw and the second part in step. You can mess with the numbers like the 10s for the height (raise number to raise bar). Now you can set any objects health and not worry about line lengths! Very Happy
avatar
Elmzran
Admin
Admin

Posts : 115
Points : 30676
GameML Reputation : 2
Join date : 2009-06-13
Location : Tasty Ham World!

View user profile http://www.tastyhamgames.com

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by 3d on Fri Jul 10, 2009 11:39 am

thanks for moving it.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 42366
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by CarnivorousA on Fri Jul 10, 2009 7:37 pm

I've got an easier healthbar code that works for individual objects.
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.

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 32582
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by 3d on Fri Jul 10, 2009 7:40 pm

cool!

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 42366
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Elmzran on Fri Jul 10, 2009 9:19 pm

Yeah, the health bar code I posted was for the Player's Health bar. But there both awesome.
avatar
Elmzran
Admin
Admin

Posts : 115
Points : 30676
GameML Reputation : 2
Join date : 2009-06-13
Location : Tasty Ham World!

View user profile http://www.tastyhamgames.com

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by CarnivorousA on Sat Jul 11, 2009 3:01 am

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.

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 32582
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by 3d on Sat Jul 11, 2009 8:11 am

Ive never needed healthbars, although i may use this. Any codes for 3d health bars?

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 42366
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by CarnivorousA on Sat Jul 11, 2009 8:51 pm

Would it not be the same?

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 32582
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by the sivart on Tue Jul 14, 2009 6:26 pm

you should try doing that in 3d Smile
avatar
the sivart
GameML Noob
GameML Noob

Posts : 3
Points : 30215
GameML Reputation : 1
Join date : 2009-07-14

View user profile

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by CarnivorousA on Tue Jul 14, 2009 7:56 pm

I can type everything I know about 3d in one post.
Code:
d3d_start()
d3d_end()
How will I know how to make healthbars in 3d?

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 32582
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by The Dark Ninja on Thu Aug 13, 2009 11:56 pm

do you mean like a 3d box for the health bar 3d
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by gogame1315 on Fri Aug 14, 2009 9:57 pm

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);

}
???
avatar
gogame1315
GameML Adventurer
GameML Adventurer

Posts : 103
Points : 32395
GameML Reputation : 10
Join date : 2009-07-10
Age : 21

View user profile http://www.yoyogames.com/members/gamesgo1315

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Sparx the Cy-Wolf on Tue Aug 25, 2009 2:02 pm

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!
avatar
Sparx the Cy-Wolf
Admin
Admin

Posts : 1775
Points : 32485
GameML Reputation : 5
Join date : 2009-06-07
Age : 26
Location : Mother ship

View user profile http://www.yoyogames.com/members/Sparx%20the%20Cy-wolf

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Sparx the Cy-Wolf on Thu Aug 27, 2009 1:10 am

Actually no it's ok, I managed to figure it out for myself.
Try my new game to see for yourself.
avatar
Sparx the Cy-Wolf
Admin
Admin

Posts : 1775
Points : 32485
GameML Reputation : 5
Join date : 2009-06-07
Age : 26
Location : Mother ship

View user profile http://www.yoyogames.com/members/Sparx%20the%20Cy-wolf

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by CarnivorousA on Fri Aug 28, 2009 6:18 am

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!
If an objct has a draw event it won't draw itself, you have to tell it to.

_________________
avatar
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 32582
GameML Reputation : 17
Join date : 2009-06-01
Age : 23
Location : At the bottom of the lake.

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Sparx the Cy-Wolf on Fri Aug 28, 2009 1:47 pm

So in otherwords, in the create event the first action should be to draw the sprite of the object....right?
(I suck at code)
avatar
Sparx the Cy-Wolf
Admin
Admin

Posts : 1775
Points : 32485
GameML Reputation : 5
Join date : 2009-06-07
Age : 26
Location : Mother ship

View user profile http://www.yoyogames.com/members/Sparx%20the%20Cy-wolf

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by The Dark Ninja on Fri Aug 28, 2009 2:14 pm

go away i am back
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Sparx the Cy-Wolf on Fri Aug 28, 2009 2:21 pm

Oh my god puppy's back!
avatar
Sparx the Cy-Wolf
Admin
Admin

Posts : 1775
Points : 32485
GameML Reputation : 5
Join date : 2009-06-07
Age : 26
Location : Mother ship

View user profile http://www.yoyogames.com/members/Sparx%20the%20Cy-wolf

Back to top Go down

Re: Easy Gravity and Good Healthbars

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum