05-01-2024, 03:59 PM
(This post was last modified: 05-01-2024, 04:04 PM by TerryRitchie.)
(05-01-2024, 01:32 PM)BloodyHash Wrote: say i made a character whom has 0 stats and he faced a slime the slime had 50 hp and he dealt only 2 hits how do i put that on the code im very new to GW_BASICThis is a very quick demo of how I would approach this.
Code: (Select All)
TYPE WEAPON ' define weapons
Name AS STRING ' name of weapon
HitDamage AS INTEGER ' damage weapon inflicts
END TYPE
TYPE CHARACTER ' define characters
HitPoints AS INTEGER ' hit points remaining
Weapon AS WEAPON ' weapon character yielding
END TYPE
DIM Player AS CHARACTER ' create a player
DIM Slime AS CHARACTER ' create an enemy
DIM Axe AS WEAPON ' create a player weapon
DIM Spit AS WEAPON ' create an enemy weapon
DIM KeyPress AS STRING ' any keyboard key press
DIM Enter AS STRING ' the ENTER key
DIM ESC AS STRING ' the ESC key
Enter = CHR$(13) ' define the ENTER key
ESC = CHR$(27) ' define the ESC key
Axe.Name = "Axe" ' give player weapon a name
Axe.HitDamage = 2 ' damage weapon posseses
Spit.Name = "Acid Spit" ' give enemy weapon a name
Spit.HitDamage = 10 ' damage weapon posses
Player.HitPoints = 50 ' set amount of HP player currently has
Player.Weapon = Axe ' give player a weapon
Slime.HitPoints = 50 ' set amount of HP Slime currently has
Slime.Weapon = Spit ' give Slime a weapon
DO
PRINT "The Slime currently has"; Slime.HitPoints; "hit points remaining."
PRINT
PRINT "Press ENTER to attack with your "; Player.Weapon.Name;"!"
PRINT
DO ' begin keyboard input loop
_LIMIT 10 ' check 10 times per second
KeyPress = INKEY$ ' get any key press
LOOP UNTIL KeyPress = Enter OR KeyPress = ESC ' leave when ENTER or ESC
Slime.HitPoints = Slime.HitPoints - Player.Weapon.HitDamage ' inflict damage on slime
PRINT "Your "; Player.Weapon.Name; " finds it mark! The Slime oozes in pain!"
PRINT
LOOP UNTIL _KEYDOWN(27) ' press ESC to end