Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help needed
#3
(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_BASIC
This 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
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
help needed - by BloodyHash - 05-01-2024, 01:32 PM
RE: help needed - by bplus - 05-01-2024, 02:17 PM
RE: help needed - by BloodyHash - 05-01-2024, 04:15 PM
RE: help needed - by TerryRitchie - 05-01-2024, 04:17 PM
RE: help needed - by BloodyHash - 05-01-2024, 04:20 PM
RE: help needed - by TerryRitchie - 05-01-2024, 03:59 PM
RE: help needed - by BloodyHash - 05-01-2024, 04:06 PM
RE: help needed - by TerryRitchie - 05-01-2024, 04:13 PM
RE: help needed - by bplus - 05-01-2024, 06:00 PM
RE: help needed - by TerryRitchie - 05-01-2024, 08:11 PM



Users browsing this thread: 1 Guest(s)