Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Assistance - Health Bar for RPG styled game?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Foxhunter




PostPosted: 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

Turing:


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
Health := 100
pHealth := 100
process Playmusic
    Music.PlayFile ("Doom 2 Shawn's got the shotgun.wav")
end Playmusic

fork Playmusic

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
    put "Saphiron's health is, ", Health, "!"
end attack

Pic.Draw (Saphiron, 150, 70, picMerge)
 var Attack : int := GUI.CreateButton (20, 10, 30, "Attack", attack)

loop
    Damage := Rand.Int (3, 12)
    mDamage := Rand.Int (2 ,7)
    GUI.SetColor (Attack, brightred)
    delay (50)
    mAttack
    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









Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Foxhunter




PostPosted: 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
Insectoid




PostPosted: 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


code:

var abilityUsedTime := Time.Sec
if abilityButtonPressed && time.sec - abilityUsedTime > cooldownTime then
    abilityUsedTime := Time.Sec
    Cast_Ability
end if


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.
Foxhunter




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: