Login Register






QBasic CLI Game filter_list
Author
Message
QBasic CLI Game #1
The game itself is very short but the idea behind this is the dice function.
Code:
DECLARE FUNCTION dice% (statement$) RANDOMIZE TIMER TYPE WEAPONTYPE 'type for weapon name AS STRING * 12 power AS STRING * 12 END TYPE TYPE OBJECTTYPE 'type for monster hp AS INTEGER weapon AS WEAPONTYPE armor AS INTEGER END TYPE DIM mee AS OBJECTTYPE 'i had to put mee since qb has already defined something for me DIM monster AS OBJECTTYPE 'this is the enemy mee.hp = 20 mee.weapon.name = "Spear" mee.weapon.power = "1d6+1" mee.armor = 5 monster.hp = 20 monster.weapon.name = "Battleaxe" monster.weapon.power = "2d6" monster.armor = 1 DO CLS PRINT "Your HP: "; mee.hp PRINT "Monster's HP:"; monster.hp PRINT PRINT "Choose:" PRINT "1. Attack" PRINT "2. Run away" menu: DO: button$ = INKEY$: LOOP UNTIL button$ <> "" SELECT CASE button$ CASE "1" 'ATTACK!! attack = dice(mee.weapon.power) cover = dice("1d" + LTRIM$(STR$(monster.armor + 1)) + "-1") damage = attack - cover IF damage < 0 THEN damage = 0 monster.hp = monster.hp - damage PRINT PRINT "You attack with " + RTRIM$(mee.weapon.name); PRINT " (" + RTRIM$(mee.weapon.power); ") "; PRINT "and you make"; attack; "points of damage."; PRINT "Monster's armor blocks damage worth of "; cover; " points, "; PRINT "so monster loses"; damage; "HP points"; IF monster.hp <= 0 THEN PRINT " and it dies. Congratulations, you won the game!" EXIT DO ELSE PRINT "." END IF PRINT PRINT "Press any key." SLEEP CASE "2" 'PAKOON! getaway = dice("1d5") 'Possibility of escape is 20 % PRINT IF getaway = 1 THEN PRINT "You were able to run away!"; PRINT "But you're still in panic and you look behind"; PRINT "and you stumble., "; PRINT "You fall into a huge hole which is full of sharp spikes."; PRINT "Unfortunatly you die"; PRINT "Thank god this is only a game so you can start again :P."; EXIT DO 'exit from the loop ELSE PRINT "You were unable to escape"; PRINT PRINT "Press any key." SLEEP END IF CASE ELSE: GOTO menu 'THIS SPAGHETTI TASTES DISGUSTING! END SELECT attack = dice(monster.weapon.power) cover = dice("1d" + LTRIM$(STR$(mee.armor + 1)) + "-1") damage = attack - cover IF damage < 0 THEN damage = 0 mee.hp = mee.hp - damage PRINT PRINT "Monster attacks with " + RTRIM$(monster.weapon.name); PRINT " (" + RTRIM$(monster.weapon.power); ") "; PRINT "and makes "; attack; "points of damage."; PRINT "Your armor protects you from"; cover; "points of hp loss, "; PRINT "so you lost "; damage; "hp points"; IF mee.hp <= 0 THEN PRINT " and you die. Maybe next time." EXIT DO ELSE PRINT "." END IF PRINT PRINT "Press any key." SLEEP LOOP FUNCTION dice% (statement$) DEFINT A-Z statement$ = LTRIM$(RTRIM$(statement$)) FOR i = 1 TO LEN(statement$) character$ = MID$(statement$, i, 1) IF LCASE$(character$) <> "d" THEN multiplier$ = multiplier$ + character$ ELSE EXIT FOR END IF NEXT i in = i FOR i = i + 1 TO LEN(statement$) character$ = MID$(statement$, i, 1) 'if it's not + nor - IF LCASE$(character$) <> "+" OR LCASE$(character$) <> "-" THEN sides$ = sides$ + character$ in = in + 1 ELSE EXIT FOR END IF NEXT i change$ = MID$(statement$, in - 1) LET result = 0 k = VAL(multiplier$) m = VAL(change$) s = VAL(sides$) FOR i = 1 TO k result = result + (INT(RND * s) + m + 1) NEXT i dice = result 'return results DEFSNG A-Z END FUNCTION


Reply

QBasic CLI Game #2
The game itself is very short but the idea behind this is the dice function.
Code:
DECLARE FUNCTION dice% (statement$) RANDOMIZE TIMER TYPE WEAPONTYPE 'type for weapon name AS STRING * 12 power AS STRING * 12 END TYPE TYPE OBJECTTYPE 'type for monster hp AS INTEGER weapon AS WEAPONTYPE armor AS INTEGER END TYPE DIM mee AS OBJECTTYPE 'i had to put mee since qb has already defined something for me DIM monster AS OBJECTTYPE 'this is the enemy mee.hp = 20 mee.weapon.name = "Spear" mee.weapon.power = "1d6+1" mee.armor = 5 monster.hp = 20 monster.weapon.name = "Battleaxe" monster.weapon.power = "2d6" monster.armor = 1 DO CLS PRINT "Your HP: "; mee.hp PRINT "Monster's HP:"; monster.hp PRINT PRINT "Choose:" PRINT "1. Attack" PRINT "2. Run away" menu: DO: button$ = INKEY$: LOOP UNTIL button$ <> "" SELECT CASE button$ CASE "1" 'ATTACK!! attack = dice(mee.weapon.power) cover = dice("1d" + LTRIM$(STR$(monster.armor + 1)) + "-1") damage = attack - cover IF damage < 0 THEN damage = 0 monster.hp = monster.hp - damage PRINT PRINT "You attack with " + RTRIM$(mee.weapon.name); PRINT " (" + RTRIM$(mee.weapon.power); ") "; PRINT "and you make"; attack; "points of damage."; PRINT "Monster's armor blocks damage worth of "; cover; " points, "; PRINT "so monster loses"; damage; "HP points"; IF monster.hp <= 0 THEN PRINT " and it dies. Congratulations, you won the game!" EXIT DO ELSE PRINT "." END IF PRINT PRINT "Press any key." SLEEP CASE "2" 'PAKOON! getaway = dice("1d5") 'Possibility of escape is 20 % PRINT IF getaway = 1 THEN PRINT "You were able to run away!"; PRINT "But you're still in panic and you look behind"; PRINT "and you stumble., "; PRINT "You fall into a huge hole which is full of sharp spikes."; PRINT "Unfortunatly you die"; PRINT "Thank god this is only a game so you can start again :P."; EXIT DO 'exit from the loop ELSE PRINT "You were unable to escape"; PRINT PRINT "Press any key." SLEEP END IF CASE ELSE: GOTO menu 'THIS SPAGHETTI TASTES DISGUSTING! END SELECT attack = dice(monster.weapon.power) cover = dice("1d" + LTRIM$(STR$(mee.armor + 1)) + "-1") damage = attack - cover IF damage < 0 THEN damage = 0 mee.hp = mee.hp - damage PRINT PRINT "Monster attacks with " + RTRIM$(monster.weapon.name); PRINT " (" + RTRIM$(monster.weapon.power); ") "; PRINT "and makes "; attack; "points of damage."; PRINT "Your armor protects you from"; cover; "points of hp loss, "; PRINT "so you lost "; damage; "hp points"; IF mee.hp <= 0 THEN PRINT " and you die. Maybe next time." EXIT DO ELSE PRINT "." END IF PRINT PRINT "Press any key." SLEEP LOOP FUNCTION dice% (statement$) DEFINT A-Z statement$ = LTRIM$(RTRIM$(statement$)) FOR i = 1 TO LEN(statement$) character$ = MID$(statement$, i, 1) IF LCASE$(character$) <> "d" THEN multiplier$ = multiplier$ + character$ ELSE EXIT FOR END IF NEXT i in = i FOR i = i + 1 TO LEN(statement$) character$ = MID$(statement$, i, 1) 'if it's not + nor - IF LCASE$(character$) <> "+" OR LCASE$(character$) <> "-" THEN sides$ = sides$ + character$ in = in + 1 ELSE EXIT FOR END IF NEXT i change$ = MID$(statement$, in - 1) LET result = 0 k = VAL(multiplier$) m = VAL(change$) s = VAL(sides$) FOR i = 1 TO k result = result + (INT(RND * s) + m + 1) NEXT i dice = result 'return results DEFSNG A-Z END FUNCTION


Reply

RE: QBasic CLI Game #3
Looks fascinating. Good job. Biggrin
I'll try to write one for pokemon when I get time.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: QBasic CLI Game #4
Looks fascinating. Good job. Biggrin
I'll try to write one for pokemon when I get time.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: QBasic CLI Game #5
(11-01-2013, 06:28 PM)Coder-san Wrote: Looks fascinating. Good job. Biggrin
I'll try to write one for pokemon when I get time.

Sounds awesome!
I'm looking forward to it.


Reply

RE: QBasic CLI Game #6
(11-01-2013, 06:28 PM)Coder-san Wrote: Looks fascinating. Good job. Biggrin
I'll try to write one for pokemon when I get time.

Sounds awesome!
I'm looking forward to it.


Reply

RE: QBasic CLI Game #7
It's good to see about these nearly forgotten languages.

Carry on.

Reply

RE: QBasic CLI Game #8
(11-04-2013, 09:57 PM)noize Wrote: It's good to see about these nearly forgotten languages.

Carry on.

Yeah. QB can be fun i need to do something with graphics.


Reply