Computer Science Canada Assistance - Health Bar for RPG styled game? |
Author: | Foxhunter [ Tue May 04, 2010 9:13 am ] | ||
Post subject: | Assistance - Health Bar for RPG styled game? | ||
What is it you are trying to achieve? We are trying to achieve a healthbar for our RPG styled game. WHenever you click 'Attack' we want the opponents 'Health bar' to go down. What is the problem you are having? We can't seem to create one. Describe what you have tried to solve this problem We attempted to create a green fillbox that had the 'x' values assigned to 'health' so when x is equal to zero, the x values would as well and the box wouldn t exist anymore. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) N/A
Please specify what version of Turing you are using 4.1.1 |
Author: | Foxhunter [ Tue May 04, 2010 9:52 am ] |
Post subject: | Re: Assistance - Health Bar for RPG styled game? |
Also, another issue I have come into. I want users to be able to use abilities in the game by pressing certain keys (Ie. Up arrow or something) But I don't want them to be able to just button mash the key so I added 'cooldowns' to the abilities. Ie. 10000 Ms, that they can't be used for. However by doing this, It delays the entire program so you can't do ANYTHING, until the cooldown is up. I would like the user to be able to use other abilities while the cooldown is . . cooling off. Here is relevant code. import GUI setscreen ("graphics:700;725") var Saphiron := Pic.FileNew ("Saphiron.jpg") var Health : int var Damage : int var count : int var pHealth : int var mDamage : int var damageA : int var damageB : int var damageC : int var DamageD : int var chars : array char of boolean Health := 1000 pHealth := 100 process Playmusic Music.PlayFile ("Doom 2 Shawn's got the shotgun.wav") end Playmusic fork Playmusic procedure AttackA delay (100) colour (black) put "Mutilate deals ", damageA, " to Saphiron!" Health := Health - damageA put "Saphiron's health is, ", Health, "!" delay (10000) colour (green) put "Mutilate is ready!" end AttackA procedure AttackB delay (100) colour (black) put "Deadly Strike deals ", damageB, " to Saphiron!" Health := Health - damageB put "Saphiron's health is, ", Health, "!" delay (10000) colour (green) put "Deadly Strike is ready!" end AttackB procedure mAttack put "Saphiron deals, ", mDamage, " to you!" pHealth := pHealth - mDamage put "Your Health is, ", pHealth, "!" end mAttack procedure attack locate (1, 1) put "You have dealt ", Damage, " to Saphiron!" delay (10) Health := Health - Damage end attack Pic.Draw (Saphiron, 150, 70, picMerge) var Attack : int := GUI.CreateButton (20, 10, 30, "Attack", attack) loop Input.KeyDown (chars) damageA := Rand.Int (9, 15) damageB := Rand.Int (1, 15) Damage := Rand.Int (3, 12) mDamage := Rand.Int (2, 7) GUI.SetColor (Attack, brightred) if chars (KEY_LEFT_ARROW) then AttackA end if if chars (KEY_RIGHT_ARROW) then AttackB end if delay (50) if Health <= 0 then put "You have defeated Saphiron!" delay (10000) cls end if if pHealth <= 0 then put "You have been slain!" end if exit when pHealth <= 0 exit when Health <= 0 exit when GUI.ProcessEvent end loop |
Author: | Insectoid [ Tue May 04, 2010 10:02 am ] | ||
Post subject: | RE:Assistance - Health Bar for RPG styled game? | ||
Instead of a delay, use a variable with the time that the ability was last used, ie
This way there is no delay. As for your health bar, you've got the right idea and that's all I'm gonna say. |
Author: | Foxhunter [ Wed May 05, 2010 9:12 am ] |
Post subject: | RE:Assistance - Health Bar for RPG styled game? |
Thanks! Hmm, i'll continue fiddling with the Health-bar then, and hopefully arrive at a decent one. Lets put in the code that you listed and see how it works, and if I can supplement the correct variables in, having some issues so far. But i'll get it. |