Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Health Bar and Mouse Coordinates

Author
Message
flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 12th Jul 2006 19:33
I've been working on a 2D RTS for a little bit (the last ten minutes) and I've come up with this. Don't really know if anyone will need it except for a noob. One function controls health bar and the other just displays the mouse coordinates quickly (for development). When it comes to the colors then 1 is for black, 2 is for white, and 3 is for red.



a.k.a. "flockhound"
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th Jul 2006 20:48
For the color you can just pass a RGB value through the function without having to split it up into it's seperate components, then in the function do "ink color,0" even though it can be passed to the function in a RGB() format.

flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 12th Jul 2006 23:15 Edited at: 12th Jul 2006 23:18
Sorry if I misunderstand... What are you saying? Do you mean to pass each rgb value separately (like mouseCord(r,g,b))?

Thanks for replying too. I really need to learn how to optimize my code instead of flailing away with the archaic methods I prescribed myself as a noob.

a.k.a. "flockhound"
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 13th Jul 2006 18:51 Edited at: 13th Jul 2006 18:51
Well, you would imagine that if you wanted to pass proper colour values to a function, you would do MouseCoord(r,g,b) (which I think is why you made it so you can 'Select' colors from a list), but you can pass it as a normal value, i.e.

Call the function - mouseCoord(RGB(r,g,b))
and Declaring the function - mouseCoord(color)

Then just do 'ink Color,0'


Makes it more flexible rather than only having 3 choices of colours

flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 14th Jul 2006 14:37
Wow, thanks, Zotoaster!

a.k.a. "flockhound"
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 23rd Oct 2006 23:23
very cool. Can you use this in FPS games (first person shooter games?

Bach Tran

Login to post a reply

Server time is: 2024-11-23 03:19:27
Your offset time is: 2024-11-23 03:19:27