Game Maker Community YoYo Games

Welcome Guest ( Log In | Register )

> Novice Forum Rules

Novice and intermediate users who are using Drag & Drop action icons, or still learning GML, can get help from more experienced members.

Please READ the Novice Q&A Forum Rules prior to posting. And remember that the General GMC Rules apply here too.

 
Reply to this topicStart new topic
Curved Health Bar, That's not straight (SOLVED)
lDGlH@x0r
post Nov 7 2009, 07:36 PM
Post #1


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



I want to know how you would make a health bar that's not straight but I want to make a health bar that curves a bit in the middle, Like

|\_______/|
\_________/

This is what my bar orgiginally look like
-________________
|________________|


This post has been edited by lDGlH@x0r: Nov 8 2009, 03:17 AM
Go to the top of the page
 
+Quote Post
FoxInABox
post Nov 7 2009, 07:39 PM
Post #2


GMC Member
Group Icon

Group: GMC Member
Posts: 2678
Joined: 15-December 06
From: Norway
Member No.: 66159



try using:
draw_sprite_part

to draw the bar empty with the sprite with the bar full on top of it
Go to the top of the page
 
+Quote Post
StarTrek
post Nov 7 2009, 07:39 PM
Post #3


Yesterdays games
Group Icon

Group: GMC Member
Posts: 614
Joined: 7-December 08
From: Sweden
Member No.: 124474



Make a sprite looking like your healthbar, then use "sprite_draw_part"
Go to the top of the page
 
+Quote Post
lDGlH@x0r
post Nov 7 2009, 07:47 PM
Post #4


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



Can someone explain how to work this function a bit more
Go to the top of the page
 
+Quote Post
@Alex@
post Nov 7 2009, 07:59 PM
Post #5


GMC Member
Group Icon

Group: GMC Member
Posts: 715
Joined: 25-August 07
Member No.: 86899



Manual can be used for an explanation

QUOTE
draw_sprite_part(sprite,subimg,left,top,width,heig
ht,x,y) Draws the indicated part of subimage subimg (-1 = current) of the sprite with the top-left corner of the part at position (x,y).


Theres also
CODE
draw_sprite_part_ext(sprite,subimg,left,top,width,height,x,y,xscale
,yscale,color,alpha) Draws the indicated part of subimage subimg (-1 = current) of the sprite with the top-left corner of the part at position (x,y) but now with scale factors and a color and transparency setting.


I think its pretty self explanitory.

This post has been edited by @Alex@: Nov 7 2009, 07:59 PM
Go to the top of the page
 
+Quote Post
lDGlH@x0r
post Nov 7 2009, 08:04 PM
Post #6


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



If I did Draw Sprite Part for the Bar, it would make it rectangle (straight) insteasd of curved.
Go to the top of the page
 
+Quote Post
@Alex@
post Nov 7 2009, 08:11 PM
Post #7


GMC Member
Group Icon

Group: GMC Member
Posts: 715
Joined: 25-August 07
Member No.: 86899



You'd create a sprite of the curved bar and draw it.
Go to the top of the page
 
+Quote Post
lDGlH@x0r
post Nov 7 2009, 08:23 PM
Post #8


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



It would get drawn but how would the health bar work
Go to the top of the page
 
+Quote Post
jabelar
post Nov 7 2009, 11:51 PM
Post #9


GMC Member
Group Icon

Group: GMC Member
Posts: 1909
Joined: 3-October 07
Member No.: 89861



Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.
Go to the top of the page
 
+Quote Post
krele
post Nov 7 2009, 11:54 PM
Post #10


GMC Member
Group Icon

Group: GMC Member
Posts: 426
Joined: 19-January 07
From: Croatia
Member No.: 68656



QUOTE (jabelar @ Nov 8 2009, 12:51 AM) *
Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.

No it fills up perfectly. You must create a curved healthbar as a sprite first, not just a rectangle...

That's also the stupidest and time consuming way. It also leeches memory and increases loading times.

I'll make you an example of how you can use this without blend modes, only with sprite_draw_part... Left and Right arrow keys decrease/increase healthbar.

http://willhostforfood.com/files4/9/5/3/95...1/healthbar.gmk

There... Hope you understand how much easier it is with sprite_draw_part...

This post has been edited by krele: Nov 8 2009, 12:18 AM
Go to the top of the page
 
+Quote Post
lDGlH@x0r
post Nov 8 2009, 02:35 AM
Post #11


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



Wow thanks man, the example is was really good and helped alot. I know how to add on from that, This problem is now SOLVED
Go to the top of the page
 
+Quote Post
GMsoftware
post Nov 8 2009, 02:51 AM
Post #12


Game maker software
Group Icon

Group: GMC Member
Posts: 128
Joined: 19-October 09
From: Australia GMT +10:00
Member No.: 143027



well make the title SAY "solved"
Go to the top of the page
 
+Quote Post
jabelar
post Nov 8 2009, 02:59 AM
Post #13


GMC Member
Group Icon

Group: GMC Member
Posts: 1909
Joined: 3-October 07
Member No.: 89861



QUOTE (krele @ Nov 7 2009, 03:54 PM) *
QUOTE (jabelar @ Nov 8 2009, 12:51 AM) *
Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.

No it fills up perfectly. You must create a curved healthbar as a sprite first, not just a rectangle...

That's also the stupidest and time consuming way. It also leeches memory and increases loading times.

I'll make you an example of how you can use this without blend modes, only with sprite_draw_part... Left and Right arrow keys decrease/increase healthbar.

http://willhostforfood.com/files4/9/5/3/95...1/healthbar.gmk

There... Hope you understand how much easier it is with sprite_draw_part...

No, sorry that is not very good. It deleted the rectangle which is not perfect. For a fully curved health bar you'd see it looked very poor. It only looked okay because you used a wavy healthbar that was almost straight. Try doing a semi-circle and you'd see what I mean.

Here is your same example with a actually curved healthbar:


This post has been edited by jabelar: Nov 8 2009, 03:05 AM
Go to the top of the page
 
+Quote Post
lDGlH@x0r
post Nov 8 2009, 03:54 AM
Post #14


GMC Member
Group Icon

Group: GMC Member
Posts: 186
Joined: 17-May 08
Member No.: 107076



QUOTE (jabelar @ Nov 7 2009, 11:59 PM) *
QUOTE (krele @ Nov 7 2009, 03:54 PM) *
QUOTE (jabelar @ Nov 8 2009, 12:51 AM) *
Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.

No it fills up perfectly. You must create a curved healthbar as a sprite first, not just a rectangle...

That's also the stupidest and time consuming way. It also leeches memory and increases loading times.

I'll make you an example of how you can use this without blend modes, only with sprite_draw_part... Left and Right arrow keys decrease/increase healthbar.

http://willhostforfood.com/files4/9/5/3/95...1/healthbar.gmk

There... Hope you understand how much easier it is with sprite_draw_part...

No, sorry that is not very good. It deleted the rectangle which is not perfect. For a fully curved health bar you'd see it looked very poor. It only looked okay because you used a wavy healthbar that was almost straight. Try doing a semi-circle and you'd see what I mean.

Here is your same example with a actually curved healthbar:



Your semi cirlces sides are facing up like this


_------_
\\_____//
\_____/

Mine is like this,


|\_____/|
\ ______/


I know that kreles example won't work all the time, but it works for my health bar so I happy.


This post has been edited by lDGlH@x0r: Nov 8 2009, 03:54 AM
Go to the top of the page
 
+Quote Post
jabelar
post Nov 8 2009, 05:01 AM
Post #15


GMC Member
Group Icon

Group: GMC Member
Posts: 1909
Joined: 3-October 07
Member No.: 89861



QUOTE (lDGlH@x0r @ Nov 7 2009, 07:54 PM) *
QUOTE (jabelar @ Nov 7 2009, 11:59 PM) *
QUOTE (krele @ Nov 7 2009, 03:54 PM) *
QUOTE (jabelar @ Nov 8 2009, 12:51 AM) *
Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.

No it fills up perfectly. You must create a curved healthbar as a sprite first, not just a rectangle...

That's also the stupidest and time consuming way. It also leeches memory and increases loading times.

I'll make you an example of how you can use this without blend modes, only with sprite_draw_part... Left and Right arrow keys decrease/increase healthbar.

http://willhostforfood.com/files4/9/5/3/95...1/healthbar.gmk

There... Hope you understand how much easier it is with sprite_draw_part...

No, sorry that is not very good. It deleted the rectangle which is not perfect. For a fully curved health bar you'd see it looked very poor. It only looked okay because you used a wavy healthbar that was almost straight. Try doing a semi-circle and you'd see what I mean.

Here is your same example with a actually curved healthbar:



Your semi cirlces sides are facing up like this


_------_
\\_____//
\_____/

Mine is like this,


|\_____/|
\ ______/


I know that kreles example won't work all the time, but it works for my health bar so I happy.


Yeah, I shouldn't have been so critical. You can treat an almost straight healthbar like a straight healthbar. If that's all you need that's fine.

I just objected to the fact that he thought it would work generally for a curved healthbar. Like a lot of people are interested in having a semi-circle, a full circle, something like a Mario air circle (when he's underwater) or even a totally irregular shape. Those require a technique with lots of sprites, unfortunately, or lots of math if you want to draw primitives and the shape is regular.

This post has been edited by jabelar: Nov 8 2009, 05:02 AM
Go to the top of the page
 
+Quote Post
krele
post Nov 8 2009, 02:17 PM
Post #16


GMC Member
Group Icon

Group: GMC Member
Posts: 426
Joined: 19-January 07
From: Croatia
Member No.: 68656



QUOTE (jabelar @ Nov 8 2009, 06:01 AM) *
QUOTE (lDGlH@x0r @ Nov 7 2009, 07:54 PM) *
QUOTE (jabelar @ Nov 7 2009, 11:59 PM) *
QUOTE (krele @ Nov 7 2009, 03:54 PM) *
QUOTE (jabelar @ Nov 8 2009, 12:51 AM) *
Okay, draw_sprite_part() won't quite work because it draws a rectangular part, so if you want the health to fill up nicely around the curve it wouldn't look quite right.

I think the simplest way is to just create a number of sprites (maybe 100 versions) to represent each health level, and then just switch the sprite based on the value of health. It is a bit of work, but simple idea.

Otherwise you'll have to use complex blending modes to erase parts of the sprite. Coding that is probably more work than just creating a bunch of sprites.

If you use a vector art program like Adobe Illustrator (there are also open source vector art programs), it might save some work using a "clipping mask" and just adjusting the color underneath to create all the sprites necessary. But only if you're already comfortable with that sort of art program.

No it fills up perfectly. You must create a curved healthbar as a sprite first, not just a rectangle...

That's also the stupidest and time consuming way. It also leeches memory and increases loading times.

I'll make you an example of how you can use this without blend modes, only with sprite_draw_part... Left and Right arrow keys decrease/increase healthbar.

http://willhostforfood.com/files4/9/5/3/95...1/healthbar.gmk

There... Hope you understand how much easier it is with sprite_draw_part...

No, sorry that is not very good. It deleted the rectangle which is not perfect. For a fully curved health bar you'd see it looked very poor. It only looked okay because you used a wavy healthbar that was almost straight. Try doing a semi-circle and you'd see what I mean.

Here is your same example with a actually curved healthbar:



Your semi cirlces sides are facing up like this


_------_
\\_____//
\_____/

Mine is like this,


|\_____/|
\ ______/


I know that kreles example won't work all the time, but it works for my health bar so I happy.


Yeah, I shouldn't have been so critical. You can treat an almost straight healthbar like a straight healthbar. If that's all you need that's fine.

I just objected to the fact that he thought it would work generally for a curved healthbar. Like a lot of people are interested in having a semi-circle, a full circle, something like a Mario air circle (when he's underwater) or even a totally irregular shape. Those require a technique with lots of sprites, unfortunately, or lots of math if you want to draw primitives and the shape is regular.

Wrong again... Game maker can handle those types of healthbars without many sprites. Mario healthbar can easily be made with no sprites, no math, shape doesn't have to be regular.

New example:
http://willhostforfood.com/files4/8/3/3/83...2/healthbar.gmk

Credits to Mr_R for the script.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd November 2009 - 11:31 AM